Re: cmd-line conversion of gnumeric and ods files.

2011-07-30 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 for the particular case of dia the distinction makes no big sense indeed,
 its more of letting user to know that we do support dia at all...

 I see - this would be addressable via a selection combo-box in the
 GuiGraphics dialog which could be very similar to the one you have
 in the GuiExternal dialog.

note that i'm not proposing that this 'letting know' must stay there.
(better to kill it completely than add just next hardcoded set of
extensions to edialog etc.) the only 'must' is that older documents
still work.

 (another point was to distinguish drawing formats we support out of the 
 box
 with imagemagick and which require external tools, like dia. we have
 already broken this with eg .svg though.)

 Isn't ImageMagick an external tool as well ?

well, even python is :) so the distinction is more about which tools
are installed by default with lyx. imagemagick is.

pavel


Re: Image Lifecycle (Create) Patch - Video

2011-07-30 Thread Edwin Leuven
Tommaso Cucinotta tomm...@lyx.org wrote:
 actually, in the previous patch on the Trac by Vincent (which I discovered
 later, when I seeked for a place on Trac where to drop my own patch), the
 mouse coordinates are used to decide where to actually drop.

that's how it should be. could you use that code in your patch?

 Even though, I don't know if that patch gives you the usual visual
 feedback (I guess you're referring to a kind of cursor showing in the
 document where the image is being placed while you're dragging it before
 dropping).

yes

ed.


[patch] fix bug 6622

2011-07-30 Thread Uwe Stöhr
The attached patch add the missing possibility to de/select the package undertilde. This was not yet 
added because of the fileformat freeze for LyX 2.0. So it is time to put it in now.

OK Georg?

regards Uwe
Index: development/FORMAT
===
--- development/FORMAT	(revision 39382)
+++ development/FORMAT	(working copy)
@@ -11,6 +11,11 @@
 
 ---
 
+2011-07-30 Uwe Stöhr uwesto...@web.de
+	* Format incremented to 415 (r36xxx)
+	  support for the LaTeX-package undertilde (fix bug 6622)
+	  New buffer param \use_undertilde
+
 2011-07-02 Pavel Sanda sa...@lyx.org
 	* Format incremented to 414 (r)
 	  New InsetSpace param \textvisiblespace
Index: lib/lyx2lyx/lyx_2_1.py
===
--- lib/lyx2lyx/lyx_2_1.py	(revision 39382)
+++ lib/lyx2lyx/lyx_2_1.py	(working copy)
@@ -25,14 +25,14 @@
 
 # Uncomment only what you need to import, please.
 
-from parser_tools import find_token, find_end_of_inset
+from parser_tools import find_token, find_end_of_inset, get_value
 
 #from parser_tools import find_token, find_end_of, find_tokens, \
   #find_token_exact, find_end_of_inset, find_end_of_layout, \
   #find_token_backwards, is_in_inset, get_value, get_quoted_value, \
   #del_token, check_token, get_option_value
 
-from lyx2lyx_tools import put_cmd_in_ert
+from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
 
 #from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
 #  put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
@@ -69,15 +69,67 @@
 document.body[i:end + 1] = subst
 
 
+def convert_undertilde(document):
+ Load undertilde automatically 
+i = find_token(document.header, \\use_mathdots , 0)
+if i != -1:
+  document.header.insert(i + 1, \\use_undertilde 1)
+
+
+def revert_undertilde(document):
+ Load undertilde if used in the document 
+
+undertilde = find_token(document.header, \\use_undertilde , 0)
+if undertilde == -1:
+  document.warning(No \\use_undertilde line. Assuming auto.)
+else:
+  val = get_value(document.header, \\use_undertilde, undertilde)
+  document.warning(valid \\use_undertilde value:  + val + . Assuming auto.)
+  del document.header[undertilde]
+  try:
+usetilde = int(val)
+  except:
+document.warning(Invalid \\use_undertilde value:  + val + . Assuming auto.)
+# probably usedots has not been changed, but be safe.
+usetilde = 1
+
+  if usetilde == 0:
+# do not load case
+return
+  if usetilde == 2:
+# force load case
+add_to_preamble(document, [\\usepackage{undertilde}])
+return
+
+# so we are in the auto case. we want to load undertilde if \utilde is used.
+i = 0
+while True:
+  i = find_token(document.body, '\\begin_inset Formula', i)
+  if i == -1:
+return
+  j = find_end_of_inset(document.body, i)
+  if j == -1:
+document.warning(Malformed LyX document: Can't find end of Formula inset at line  + str(i))
+i += 1
+continue
+  code = \n.join(document.body[i:j])
+  if code.find(\\utilde) != -1:
+add_to_preamble(document, [\\@ifundefined{utilde}{\\usepackage{undertilde}}])
+return
+  i = j
+
+
 ##
 # Conversion hub
 #
 
 supported_versions = [2.1.0,2.1]
-convert = [[414, []]
+convert = [[414, []],
+   [415, [convert_undertilde]]
   ]
 
-revert =  [[413, [revert_visible_space]]
+revert =  [[414, [revert_undertilde]],
+   [413, [revert_visible_space]]
   ]
 
 
Index: lib/symbols
===
--- lib/symbols	(revision 39382)
+++ lib/symbols	(working copy)
@@ -30,10 +30,7 @@
 #have a possibility to turn automatic loading off like for ams
 #undertilde  decoration none   accents
 undertilde  decoration none
-#Do not load automatically, since it might conflict with user macros and we
-#don't have a possibility to turn automatic loading off like for ams
-#utilde  decoration none   undertilde
-utilde  decoration none
+utilde  decoration none   undertilde
 vec decoration none
 widehat decoration none
 widetilde   decoration none
Index: lib/ui/stdtoolbars.inc
===
--- lib/ui/stdtoolbars.inc	(revision 39382)
+++ lib/ui/stdtoolbars.inc	(working copy)
@@ -398,8 +398,7 @@
 		Item check math-insert \check
 		Item widehat math-insert \widehat
 		Item widetilde math-insert \widetilde
-# enable this once the undertilde package is loaded automatically
-#		Item utilde math-insert \utilde
+		Item utilde math-insert \utilde
 		Item vec math-insert \vec
 		Item acute math-insert \acute
 		Item ddot math-insert \ddot
Index: src/Buffer.cpp

Re: Image Lifecycle (Create) Patch - Video

2011-07-30 Thread Tommaso Cucinotta

Il 30/07/2011 06:48, Jens Nöckel ha scritto:

To me it seems that this could be a great job for an external launcher utility 
or an operating system service, but not a feature that LyX should be 
responsible for. I guess Nautilus proves this point. Sorry to be so 
conservative about this, but for LyX to start shipping binary template files of 
a myriad other programs seems the wrong approach (not to mention all those 
hard-coded file extensions).

How about creating a separate launcher application with all those templates and 
the mechanism for recognizing extensions. The user could (optionally) install 
it separately from LyX, and its presence could be detected by LyX at 
reconfigure time. Then at least one would have decoupled updating and 
development of LyX and this launcher application.


Hi,

I understand very well the rationale of your proposal, and I have to 
admit I would love it, in principle. Not only, I would push it further: 
take out of LyX the whole logic concerning file-format detection, 
conversion and launching of external editors, and just leave that job to 
such an external utility. For example, this external tool (one or more) 
could have not only the ability to detect file formats, but also to 
understand which editors/viewers are installed on the system (e.g., what 
configure.py does now for LyX), the ability to launch the proper 
viewer/editor for a given file type (e.g., what gnome-open and kde-open 
already do), to convert files from one format to another (a'la convert 
from ImageMagick, but not only images -- also spreadsheets and other LyX 
external material), etc. With a proper integration via command-line or a 
specific API (better), such a tool/library could be useful in a number 
of ways across the OS.


However, LyX for now embeds all that logic about formats and 
conversions, and is already aware of external applications (viewers, 
editors, converters) that are installed on the OS. Therefore, I don't 
see too much of a big and dangerous step if we also ship a few empty 
samples with it. Actually, it's of course simpler (for me) to think of 
this last kind of step than the one formerly sketched out above :-).


Bye,

T.



Re: External material/graphics empty samples

2011-07-30 Thread Tommaso Cucinotta

Il 30/07/2011 11:44, Pavel Sanda ha scritto:



If you had a look at those 2 patches (images and ext material), I had a
common need, i.e., the patch below.

Do you think it may be a safe/right one, or might it be dangerous or have
unforeseeable side effects ?

iirc we return zip type for files which uses zip internally and you encounter
this as a problem for odX files, right?


exactly: LyX will unzip the whole document directory, and at such a point
you can't do anything with that: nor viewing, nor editing, nor converting.


.dia is still not solved correctly since it can be both raw/zipped.


I need to check these both options (I normally use whatever is the dia's 
default).

still waiting for your answer about the tab issue, since i suspect it has
something to do with qt version. is there some case size/orientation is
enabled in external material for your setup (qt 4.7 here)?


sure, I had a look: the size tab of the External Material dialog is gray 
and can never be activated (I just tried dia, xfig and chess).
However, the ext_templates file uses the options Rotate etc.., so it 
should appear instead. (just checked it's not my patch's fault, but it's 
like that also on lyx-2.0.0 that comes with my Ubuntu).


Thanks, bye.

T.


Re: r39383 - lyx-devel/trunk/lib/lyx2lyx

2011-07-30 Thread Richard Heck
On 07/30/2011 12:40 PM, uwesto...@lyx.org wrote:
 Author: uwestoehr
 Date: Sat Jul 30 18:40:03 2011
 New Revision: 39383
 URL: http://www.lyx.org/trac/changeset/39383

 Log:
 lyx_2_0.py: fix bug when exporting documents containing \iddots in math to 
 LyX 1.6.x
 This must also go to branch, OK Richard?

OK.

rh



Re: cmd-line conversion of gnumeric and ods files.

2011-07-30 Thread Pavel Sanda
Tommaso Cucinotta wrote:
>> for the particular case of dia the distinction makes no big sense indeed,
>> its more of letting user to know that we do support dia at all...
>
> I see - this would be addressable via a selection combo-box in the
> GuiGraphics dialog which could be very similar to the one you have
> in the GuiExternal dialog.

note that i'm not proposing that this 'letting know' must stay there.
(better to kill it completely than add just next hardcoded set of
extensions to edialog etc.) the only 'must' is that older documents
still work.

>> (another point was to distinguish drawing formats we support out of the 
>> box
>> with imagemagick and which require external tools, like dia. we have
>> already broken this with eg .svg though.)
>
> Isn't ImageMagick an external tool as well ?

well, even python is :) so the distinction is more about which tools
are installed by default with lyx. imagemagick is.

pavel


Re: Image Lifecycle (Create) Patch - Video

2011-07-30 Thread Edwin Leuven
Tommaso Cucinotta  wrote:
> actually, in the previous patch on the Trac by Vincent (which I discovered
> later, when I seeked for a place on Trac where to drop my own patch), the
> mouse coordinates are used to decide where to actually drop.

that's how it should be. could you use that code in your patch?

> Even though, I don't know if that patch gives you the "usual visual
> feedback" (I guess you're referring to a kind of cursor showing in the
> document where the image is being placed while you're dragging it before
> dropping).

yes

ed.


[patch] fix bug 6622

2011-07-30 Thread Uwe Stöhr
The attached patch add the missing possibility to de/select the package undertilde. This was not yet 
added because of the fileformat freeze for LyX 2.0. So it is time to put it in now.

OK Georg?

regards Uwe
Index: development/FORMAT
===
--- development/FORMAT	(revision 39382)
+++ development/FORMAT	(working copy)
@@ -11,6 +11,11 @@
 
 ---
 
+2011-07-30 Uwe Stöhr 
+	* Format incremented to 415 (r36xxx)
+	  support for the LaTeX-package undertilde (fix bug 6622)
+	  New buffer param \use_undertilde
+
 2011-07-02 Pavel Sanda 
 	* Format incremented to 414 (r)
 	  New InsetSpace param \textvisiblespace
Index: lib/lyx2lyx/lyx_2_1.py
===
--- lib/lyx2lyx/lyx_2_1.py	(revision 39382)
+++ lib/lyx2lyx/lyx_2_1.py	(working copy)
@@ -25,14 +25,14 @@
 
 # Uncomment only what you need to import, please.
 
-from parser_tools import find_token, find_end_of_inset
+from parser_tools import find_token, find_end_of_inset, get_value
 
 #from parser_tools import find_token, find_end_of, find_tokens, \
   #find_token_exact, find_end_of_inset, find_end_of_layout, \
   #find_token_backwards, is_in_inset, get_value, get_quoted_value, \
   #del_token, check_token, get_option_value
 
-from lyx2lyx_tools import put_cmd_in_ert
+from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
 
 #from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
 #  put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
@@ -69,15 +69,67 @@
 document.body[i:end + 1] = subst
 
 
+def convert_undertilde(document):
+" Load undertilde automatically "
+i = find_token(document.header, "\\use_mathdots" , 0)
+if i != -1:
+  document.header.insert(i + 1, "\\use_undertilde 1")
+
+
+def revert_undertilde(document):
+" Load undertilde if used in the document "
+
+undertilde = find_token(document.header, "\\use_undertilde" , 0)
+if undertilde == -1:
+  document.warning("No \\use_undertilde line. Assuming auto.")
+else:
+  val = get_value(document.header, "\\use_undertilde", undertilde)
+  document.warning("valid \\use_undertilde value: " + val + ". Assuming auto.")
+  del document.header[undertilde]
+  try:
+usetilde = int(val)
+  except:
+document.warning("Invalid \\use_undertilde value: " + val + ". Assuming auto.")
+# probably usedots has not been changed, but be safe.
+usetilde = 1
+
+  if usetilde == 0:
+# do not load case
+return
+  if usetilde == 2:
+# force load case
+add_to_preamble(document, ["\\usepackage{undertilde}"])
+return
+
+# so we are in the auto case. we want to load undertilde if \utilde is used.
+i = 0
+while True:
+  i = find_token(document.body, '\\begin_inset Formula', i)
+  if i == -1:
+return
+  j = find_end_of_inset(document.body, i)
+  if j == -1:
+document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i))
+i += 1
+continue
+  code = "\n".join(document.body[i:j])
+  if code.find("\\utilde") != -1:
+add_to_preamble(document, ["\\@ifundefined{utilde}{\\usepackage{undertilde}}"])
+return
+  i = j
+
+
 ##
 # Conversion hub
 #
 
 supported_versions = ["2.1.0","2.1"]
-convert = [[414, []]
+convert = [[414, []],
+   [415, [convert_undertilde]]
   ]
 
-revert =  [[413, [revert_visible_space]]
+revert =  [[414, [revert_undertilde]],
+   [413, [revert_visible_space]]
   ]
 
 
Index: lib/symbols
===
--- lib/symbols	(revision 39382)
+++ lib/symbols	(working copy)
@@ -30,10 +30,7 @@
 #have a possibility to turn automatic loading off like for ams
 #undertilde  decoration none   accents
 undertilde  decoration none
-#Do not load automatically, since it might conflict with user macros and we
-#don't have a possibility to turn automatic loading off like for ams
-#utilde  decoration none   undertilde
-utilde  decoration none
+utilde  decoration none   undertilde
 vec decoration none
 widehat decoration none
 widetilde   decoration none
Index: lib/ui/stdtoolbars.inc
===
--- lib/ui/stdtoolbars.inc	(revision 39382)
+++ lib/ui/stdtoolbars.inc	(working copy)
@@ -398,8 +398,7 @@
 		Item "check" "math-insert \check"
 		Item "widehat" "math-insert \widehat"
 		Item "widetilde" "math-insert \widetilde"
-# enable this once the undertilde package is loaded automatically
-#		Item "utilde" "math-insert \utilde"
+		Item "utilde" "math-insert \utilde"
 		Item "vec" "math-insert \vec"
 		Item "acute" "math-insert \acute"
 		Item "ddot" "math-insert 

Re: Image Lifecycle (Create) Patch - Video

2011-07-30 Thread Tommaso Cucinotta

Il 30/07/2011 06:48, Jens Nöckel ha scritto:

To me it seems that this could be a great job for an external launcher utility 
or an operating system service, but not a feature that LyX should be 
responsible for. I guess Nautilus proves this point. Sorry to be so 
conservative about this, but for LyX to start shipping binary template files of 
a myriad other programs seems the wrong approach (not to mention all those 
hard-coded file extensions).

How about creating a separate launcher application with all those templates and 
the mechanism for recognizing extensions. The user could (optionally) install 
it separately from LyX, and its presence could be detected by LyX at 
reconfigure time. Then at least one would have decoupled updating and 
development of LyX and this launcher application.


Hi,

I understand very well the rationale of your proposal, and I have to 
admit I would love it, in principle. Not only, I would push it further: 
take out of LyX the whole logic concerning file-format detection, 
conversion and launching of external editors, and just leave that job to 
such an external utility. For example, this external tool (one or more) 
could have not only the ability to detect file formats, but also to 
understand which editors/viewers are installed on the system (e.g., what 
configure.py does now for LyX), the ability to launch the proper 
viewer/editor for a given file type (e.g., what gnome-open and kde-open 
already do), to convert files from one format to another (a'la convert 
from ImageMagick, but not only images -- also spreadsheets and other LyX 
external material), etc. With a proper integration via command-line or a 
specific API (better), such a tool/library could be useful in a number 
of ways across the OS.


However, LyX for now embeds all that logic about formats and 
conversions, and is already aware of external applications (viewers, 
editors, converters) that are installed on the OS. Therefore, I don't 
see too much of a big and dangerous step if we also ship a few empty 
samples with it. Actually, it's of course simpler (for me) to think of 
this last kind of step than the one formerly sketched out above :-).


Bye,

T.



Re: External material/graphics empty samples

2011-07-30 Thread Tommaso Cucinotta

Il 30/07/2011 11:44, Pavel Sanda ha scritto:



If you had a look at those 2 patches (images and ext material), I had a
common need, i.e., the patch below.

Do you think it may be a safe/right one, or might it be dangerous or have
unforeseeable side effects ?

iirc we return zip type for files which uses zip internally and you encounter
this as a problem for odX files, right?


exactly: LyX will unzip the whole document directory, and at such a point
you can't do anything with that: nor viewing, nor editing, nor converting.


.dia is still not solved correctly since it can be both raw/zipped.


I need to check these both options (I normally use whatever is the dia's 
default).

still waiting for your answer about the "tab" issue, since i suspect it has
something to do with qt version. is there some case size/orientation is
enabled in external material for your setup (qt 4.7 here)?


sure, I had a look: the size tab of the External Material dialog is gray 
and can never be activated (I just tried dia, xfig and chess).
However, the ext_templates file uses the options Rotate etc.., so it 
should appear instead. (just checked it's not my patch's fault, but it's 
like that also on lyx-2.0.0 that comes with my Ubuntu).


Thanks, bye.

T.


Re: r39383 - lyx-devel/trunk/lib/lyx2lyx

2011-07-30 Thread Richard Heck
On 07/30/2011 12:40 PM, uwesto...@lyx.org wrote:
> Author: uwestoehr
> Date: Sat Jul 30 18:40:03 2011
> New Revision: 39383
> URL: http://www.lyx.org/trac/changeset/39383
>
> Log:
> lyx_2_0.py: fix bug when exporting documents containing \iddots in math to 
> LyX 1.6.x
> This must also go to branch, OK Richard?
>
OK.

rh