Re: External material/graphics empty samples

2011-07-31 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 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).

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.

pavel


Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.


ii  libqt4-dev  
4:4.7.2-0ubuntu6.2   Qt 4 development files


I would try to search for some issue in parsing/interpreting the 
ext_template file.


T.



Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.


Btw, the attached patch brings that tab back to life for me.

Can I commit ?

T.
Index: src/frontends/qt4/GuiExternal.cpp
===
--- src/frontends/qt4/GuiExternal.cpp	(revisione 39394)
+++ src/frontends/qt4/GuiExternal.cpp	(copia locale)
@@ -32,6 +32,7 @@
 #include support/lstrings.h
 #include support/lyxlib.h
 #include support/os.h
+#include support/debug.h
 
 #include LengthCombo.h
 #include qt_helpers.h
@@ -512,25 +513,25 @@
 	TransformIDs::const_iterator tr_begin = transformIds.begin();
 	TransformIDs::const_iterator const tr_end = transformIds.end();
 
-	bool found = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
-	rotationGB-setEnabled(found);
+	bool rotate = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
+	rotationGB-setEnabled(rotate);
 
-	found = std::find(tr_begin, tr_end, external::Resize) != tr_end;
-	scaleGB-setEnabled(found);
+	bool resize = std::find(tr_begin, tr_end, external::Resize) != tr_end;
+	scaleGB-setEnabled(resize);
 
-	found = std::find(tr_begin, tr_end, external::Clip) != tr_end;
-	cropGB-setEnabled(found);
+	bool clip = std::find(tr_begin, tr_end, external::Clip) != tr_end;
+	cropGB-setEnabled(clip);
 
-	tab-setTabEnabled(tab-indexOf(sizetab),
-		rotationGB-isEnabled()
-		|| scaleGB-isEnabled()
-		|| cropGB-isEnabled());
+	sizetab-setEnabled(rotate || resize || clip);
+	tab-setTabEnabled(tab-indexOf(sizetab), rotate || resize || clip);
 
-	found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
+	bool found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
+	LYXERR(Debug::GUI, Extra found =   found);
 	optionsGB-setEnabled(found);
 
 	bool scaled = displayGB-isChecked()  displayGB-isEnabled() 
 			!isBufferReadonly()  (templ.preview_mode != PREVIEW_INSTANT);
+	LYXERR(Debug::GUI, Scaled found =   found);
 	displayscaleED-setEnabled(scaled);
 	scaleLA-setEnabled(scaled);
 


Re: External material/graphics empty samples

2011-07-31 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 Il 31/07/2011 11:19, Pavel Sanda ha scritto:
 whats your qt version? i already tested its gray even in 1.6.1-10.  unless
 my memory play nasty games with me, this really worked - i was able to set
 size of external images.. what remains is that something in qt changed.

 Btw, the attached patch brings that tab back to life for me.

 Can I commit ?

yes, thanks. this is also for branch Richard.

pavel


Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 20:27, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.

Btw, the attached patch brings that tab back to life for me.

Can I commit ?

yes, thanks. this is also for branch Richard.


r39399

and

r39400

for branch.

T.


Re: External material/graphics empty samples

2011-07-31 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> 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).

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.

pavel


Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.


ii  libqt4-dev  
4:4.7.2-0ubuntu6.2   Qt 4 development files


I would try to search for some issue in parsing/interpreting the 
ext_template file.


T.



Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.


Btw, the attached patch brings that tab back to life for me.

Can I commit ?

T.
Index: src/frontends/qt4/GuiExternal.cpp
===
--- src/frontends/qt4/GuiExternal.cpp	(revisione 39394)
+++ src/frontends/qt4/GuiExternal.cpp	(copia locale)
@@ -32,6 +32,7 @@
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 #include "support/os.h"
+#include "support/debug.h"
 
 #include "LengthCombo.h"
 #include "qt_helpers.h"
@@ -512,25 +513,25 @@
 	TransformIDs::const_iterator tr_begin = transformIds.begin();
 	TransformIDs::const_iterator const tr_end = transformIds.end();
 
-	bool found = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
-	rotationGB->setEnabled(found);
+	bool rotate = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
+	rotationGB->setEnabled(rotate);
 
-	found = std::find(tr_begin, tr_end, external::Resize) != tr_end;
-	scaleGB->setEnabled(found);
+	bool resize = std::find(tr_begin, tr_end, external::Resize) != tr_end;
+	scaleGB->setEnabled(resize);
 
-	found = std::find(tr_begin, tr_end, external::Clip) != tr_end;
-	cropGB->setEnabled(found);
+	bool clip = std::find(tr_begin, tr_end, external::Clip) != tr_end;
+	cropGB->setEnabled(clip);
 
-	tab->setTabEnabled(tab->indexOf(sizetab),
-		rotationGB->isEnabled()
-		|| scaleGB->isEnabled()
-		|| cropGB->isEnabled());
+	sizetab->setEnabled(rotate || resize || clip);
+	tab->setTabEnabled(tab->indexOf(sizetab), rotate || resize || clip);
 
-	found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
+	bool found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
+	LYXERR(Debug::GUI, "Extra found = " << found);
 	optionsGB->setEnabled(found);
 
 	bool scaled = displayGB->isChecked() && displayGB->isEnabled() &&
 			!isBufferReadonly() && (templ.preview_mode != PREVIEW_INSTANT);
+	LYXERR(Debug::GUI, "Scaled found = " << found);
 	displayscaleED->setEnabled(scaled);
 	scaleLA->setEnabled(scaled);
 


Re: External material/graphics empty samples

2011-07-31 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> Il 31/07/2011 11:19, Pavel Sanda ha scritto:
>> whats your qt version? i already tested its gray even in 1.6.1-10.  unless
>> my memory play nasty games with me, this really worked - i was able to set
>> size of external images.. what remains is that something in qt changed.
>
> Btw, the attached patch brings that tab back to life for me.
>
> Can I commit ?

yes, thanks. this is also for branch Richard.

pavel


Re: External material/graphics empty samples

2011-07-31 Thread Tommaso Cucinotta

Il 31/07/2011 20:27, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

Il 31/07/2011 11:19, Pavel Sanda ha scritto:

whats your qt version? i already tested its gray even in 1.6.1-10.  unless
my memory play nasty games with me, this really worked - i was able to set
size of external images.. what remains is that something in qt changed.

Btw, the attached patch brings that tab back to life for me.

Can I commit ?

yes, thanks. this is also for branch Richard.


r39399

and

r39400

for branch.

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: 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: External material/graphics empty samples

2011-07-29 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 Il 23/07/2011 21:14, Pavel Sanda ha scritto:
 hmm and where is the edit button? :)

 there's no edit button in that dialog. The LyX workflow would be:
 1) insert-external material...
 2) fill details in the dialog, click Ok
 3) right-click on the previewed image, choose Edit...

this looks strange. context menu is nice but shouldn't be replacement for 
dialog.

 another strange thing, how is that i can't go to size tab for figure files 
 now?

 what is the size tab ?

when you go to the external material dialog, there are three tabs on the top.
the third one for size rotation is always disabled no matter what i do.
do you see it as well?

 So, my question: does it make sense to have these 2 separate insets ?

to me yes. spreadsheat table is no graphics material.
secondly its kind of API for people who want to develop their own external
material.

pavel


Re: External material/graphics empty samples

2011-07-29 Thread Tommaso Cucinotta

Il 29/07/2011 10:30, Pavel Sanda ha scritto:

So, my question: does it make sense to have these 2 separate insets ?

to me yes. spreadsheat table is no graphics material.
secondly its kind of API for people who want to develop their own external
material.


Thanks for your comments, Pavel.

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 ?


Thanks,

T.

Index: src/Format.cpp
===
--- src/Format.cpp  (revisione 39372)
+++ src/Format.cpp  (copia locale)
@@ -128,15 +128,25 @@
 }


+/// For a zipped format, try the filename extension first, then the contents
+/// (otherwise it is always guessed as zip and we're in trouble)
 string Formats::getFormatFromFile(FileName const  filename) const
 {
if (filename.empty())
return string();

-   string const format = filename.guessFormatFromContents();
-   if (!format.empty())
-   return format;
+   string const  ex = filename.extension();
+   bool zipped_format = (ex == odg || ex == sxd
+   || ex == odt || ex == sxw || ex == docx
+   || ex == ods || ex == sxc || ex == xlsx
+   || ex == gnumeric);

+   if (!zipped_format) {
+   string const format = filename.guessFormatFromContents();
+   if (!format.empty())
+   return format;
+   }
+
// try to find a format from the file extension.
string const ext = getExtension(filename.absFileName());
if (!ext.empty()) {
@@ -151,6 +161,12 @@
return cit-name();
}
}
+
+   if (zipped_format) {
+   string const format = filename.guessFormatFromContents();
+   if (!format.empty())
+   return format;
+   }
return string();
 }




Re: External material/graphics empty samples

2011-07-29 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> Il 23/07/2011 21:14, Pavel Sanda ha scritto:
>> hmm and where is the edit button? :)
>
> there's no edit button in that dialog. The LyX workflow would be:
> 1) insert->external material...
> 2) fill details in the dialog, click Ok
> 3) right-click on the previewed image, choose Edit...

this looks strange. context menu is nice but shouldn't be replacement for 
dialog.

>> another strange thing, how is that i can't go to size tab for figure files 
>> now?
>
> what is the "size tab" ?

when you go to the external material dialog, there are three tabs on the top.
the third one for size rotation is always disabled no matter what i do.
do you see it as well?

> So, my question: does it make sense to have these 2 separate insets ?

to me yes. spreadsheat table is no graphics material.
secondly its kind of API for people who want to develop their own external
material.

pavel


Re: External material/graphics empty samples

2011-07-29 Thread Tommaso Cucinotta

Il 29/07/2011 10:30, Pavel Sanda ha scritto:

So, my question: does it make sense to have these 2 separate insets ?

to me yes. spreadsheat table is no graphics material.
secondly its kind of API for people who want to develop their own external
material.


Thanks for your comments, Pavel.

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 ?


Thanks,

T.

Index: src/Format.cpp
===
--- src/Format.cpp  (revisione 39372)
+++ src/Format.cpp  (copia locale)
@@ -128,15 +128,25 @@
 }


+/// For a zipped format, try the filename extension first, then the contents
+/// (otherwise it is always guessed as zip and we're in trouble)
 string Formats::getFormatFromFile(FileName const&  filename) const
 {
if (filename.empty())
return string();

-   string const format = filename.guessFormatFromContents();
-   if (!format.empty())
-   return format;
+   string const&  ex = filename.extension();
+   bool zipped_format = (ex == "odg" || ex == "sxd"
+   || ex == "odt" || ex == "sxw" || ex == "docx"
+   || ex == "ods" || ex == "sxc" || ex == "xlsx"
+   || ex == "gnumeric");

+   if (!zipped_format) {
+   string const format = filename.guessFormatFromContents();
+   if (!format.empty())
+   return format;
+   }
+
// try to find a format from the file extension.
string const ext = getExtension(filename.absFileName());
if (!ext.empty()) {
@@ -151,6 +161,12 @@
return cit->name();
}
}
+
+   if (zipped_format) {
+   string const format = filename.guessFormatFromContents();
+   if (!format.empty())
+   return format;
+   }
return string();
 }




Re: External material/graphics empty samples

2011-07-24 Thread Tommaso Cucinotta

Il 23/07/2011 21:03, Pavel Sanda ha scritto:

so we ought to ship binary files which will be the new ones?
why not ask the external application instead?


simply because not every application supports opening a non-existent file.
Shipping sample files seems to me the easiest thing to do.

T.



Re: External material/graphics empty samples

2011-07-24 Thread Tommaso Cucinotta

Il 23/07/2011 21:14, Pavel Sanda ha scritto:

hmm and where is the edit button? :)


there's no edit button in that dialog. The LyX workflow would be:
1) insert-external material...
2) fill details in the dialog, click Ok
3) right-click on the previewed image, choose Edit...


shouldn't it be the edit button, which creates new material in cases it doesn't 
exist yet?


That may be an addition as well. Perhaps name the button as 
Create/Edit, or
name it as Create when the file doesn't exist, and Edit if it exists. 
And, right after
file creation, yes, we could pop up the external editor (don't know 
whether to close

the dialog first).

another strange thing, how is that i can't go to size tab for figure files now?


what is the size tab ?

This is probably the lack of homogeneity I was suffering of: if you go for

  Insert-Picture... (or, Image..., whatever the menu is in English)

then the properties dialog (when I left-click on the image) is richer, as
I can decide the size on paper, on screen, rotation, etc.

If, instead, I go for

  Insert-External Material...

then, the properties dialog is completely different. Shouldn't it be the 
same ?


In both cases, the Edit button is only on [Right Click - Edit 
Externally...], and
it is missing from the associated properties/settings dialog shown with 
[Left Click].


So, my question: does it make sense to have these 2 separate insets ?

-) insets/InsetGraphics, with qt4/GuiExternal
-) insets/InsetExternal, with qt4/GuiGraphics

Shouldn't they be merged together ?

T.



Re: External material/graphics empty samples

2011-07-24 Thread Tommaso Cucinotta

Il 23/07/2011 21:03, Pavel Sanda ha scritto:

so we ought to ship binary files which will be the new ones?
why not ask the external application instead?


simply because not every application supports opening a non-existent file.
Shipping sample files seems to me the easiest thing to do.

T.



Re: External material/graphics empty samples

2011-07-24 Thread Tommaso Cucinotta

Il 23/07/2011 21:14, Pavel Sanda ha scritto:

hmm and where is the edit button? :)


there's no edit button in that dialog. The LyX workflow would be:
1) insert->external material...
2) fill details in the dialog, click Ok
3) right-click on the previewed image, choose Edit...


shouldn't it be the edit button, which creates new material in cases it doesn't 
exist yet?


That may be an addition as well. Perhaps name the button as 
"Create/Edit", or
name it as Create when the file doesn't exist, and Edit if it exists. 
And, right after
file creation, yes, we could pop up the external editor (don't know 
whether to close

the dialog first).

another strange thing, how is that i can't go to size tab for figure files now?


what is the "size tab" ?

This is probably the lack of homogeneity I was suffering of: if you go for

  Insert->Picture... (or, Image..., whatever the menu is in English)

then the properties dialog (when I left-click on the image) is richer, as
I can decide the size on paper, on screen, rotation, etc.

If, instead, I go for

  Insert->External Material...

then, the properties dialog is completely different. Shouldn't it be the 
same ?


In both cases, the Edit button is only on [Right Click -> Edit 
Externally...], and
it is missing from the associated properties/settings dialog shown with 
[Left Click].


So, my question: does it make sense to have these 2 separate insets ?

-) insets/InsetGraphics, with qt4/GuiExternal
-) insets/InsetExternal, with qt4/GuiGraphics

Shouldn't they be merged together ?

T.



Re: External material/graphics empty samples

2011-07-23 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 Il 22/07/2011 18:47, Pavel Sanda ha scritto:
 Tommaso Cucinotta wrote:
 I dropped the new patch on #3205, so that we don't forget about it.
 its uncomfortable to comment on the patches coming in gzip form, i.e.
 the chances to get some reaction is smaller this way.
 pavel
 because it contained binary sample files (.odt, ...). Let me attach to this 
 message
 the part without them.

added files are not part of the patches by default.
so we ought to ship binary files which will be the new ones?
why not ask the external application instead?

pavel


Re: External material/graphics empty samples

2011-07-23 Thread Pavel Sanda
Pavel Sanda wrote:
 Tommaso Cucinotta wrote:
  Il 22/07/2011 18:47, Pavel Sanda ha scritto:
  Tommaso Cucinotta wrote:
  I dropped the new patch on #3205, so that we don't forget about it.
  its uncomfortable to comment on the patches coming in gzip form, i.e.
  the chances to get some reaction is smaller this way.
  pavel
  because it contained binary sample files (.odt, ...). Let me attach to this 
  message
  the part without them.
 
 added files are not part of the patches by default.
 so we ought to ship binary files which will be the new ones?
 why not ask the external application instead?

hmm and where is the edit button? :)
shouldn't it be the edit button, which creates new material in cases it doesn't 
exist yet?

another strange thing, how is that i can't go to size tab for figure files now?

pavel


Re: External material/graphics empty samples

2011-07-23 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> Il 22/07/2011 18:47, Pavel Sanda ha scritto:
>> Tommaso Cucinotta wrote:
>>> I dropped the new patch on #3205, so that we don't forget about it.
>> its uncomfortable to comment on the patches coming in gzip form, i.e.
>> the chances to get some reaction is smaller this way.
>> pavel
> because it contained binary sample files (.odt, ...). Let me attach to this 
> message
> the part without them.

added files are not part of the patches by default.
so we ought to ship binary files which will be the new ones?
why not ask the external application instead?

pavel


Re: External material/graphics empty samples

2011-07-23 Thread Pavel Sanda
Pavel Sanda wrote:
> Tommaso Cucinotta wrote:
> > Il 22/07/2011 18:47, Pavel Sanda ha scritto:
> >> Tommaso Cucinotta wrote:
> >>> I dropped the new patch on #3205, so that we don't forget about it.
> >> its uncomfortable to comment on the patches coming in gzip form, i.e.
> >> the chances to get some reaction is smaller this way.
> >> pavel
> > because it contained binary sample files (.odt, ...). Let me attach to this 
> > message
> > the part without them.
> 
> added files are not part of the patches by default.
> so we ought to ship binary files which will be the new ones?
> why not ask the external application instead?

hmm and where is the edit button? :)
shouldn't it be the edit button, which creates new material in cases it doesn't 
exist yet?

another strange thing, how is that i can't go to size tab for figure files now?

pavel


Re: External material/graphics empty samples

2011-07-22 Thread Tommaso Cucinotta

I dropped the new patch on #3205, so that we don't forget about it.

T.

Il 22/07/2011 06:22, Tommaso Cucinotta ha scritto:

Hi all,

I just reworked the patch on the current trunk, plus I added a few 
desirable things:


-) Insert-External Material...- enter filename (e.g., foo.dia or 
foo.ods or foo.gnumeric), press Create and you get an empty template;
-) type a file-name with an extension, and the template type is 
inferred from the dropdown box, if the extension is recognized;
-) choose a different template from the drop-down, and the file-name 
extension is automatically inferred;
-) each template may be associated with a list of different sample 
filenames and associated extensions;

   for example, in the gnumeric section of external_templates:
 Sample sample.gnumeric,sample.ods

The only thing that is missing, is that I'D LOVE HAVING THIS FOR 
INSERT-FIGURE. Indeed, if I use it for inserting DIA figures etc., 
then I get a poorer properties pane (e.g., rotation, size on paper and 
on screen, etc.). Furthermore, the image is not previewed.
Instead, if I use Insert-Figure, then I don't have this new feature 
that I really like :-).


Anyone willing to give it a try ?

Bye,

T.

Il 24/04/2011 23:31, Tommaso Cucinotta ha scritto:

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say preliminary because things that one may want to add are:
-) launch also the editor, when you press Create...
-) add another Edit... button for launching the external editor
-) better control of *where* the new file is created (in the patch 
it is the current folder, but I guess I should use the folder of the 
.lyx file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the Create button, detect the non-existent file on 
dialog Ok button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select Dia *and* provide a file-name like 
mydrawing.dia -- the latter just includes the former info).


T.






Re: External material/graphics empty samples

2011-07-22 Thread Pavel Sanda
Tommaso Cucinotta wrote:
 I dropped the new patch on #3205, so that we don't forget about it.

its uncomfortable to comment on the patches coming in gzip form, i.e.
the chances to get some reaction is smaller this way.
pavel


Re: External material/graphics empty samples

2011-07-22 Thread Tommaso Cucinotta

Il 22/07/2011 18:47, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

I dropped the new patch on #3205, so that we don't forget about it.

its uncomfortable to comment on the patches coming in gzip form, i.e.
the chances to get some reaction is smaller this way.
pavel
because it contained binary sample files (.odt, ...). Let me attach to 
this message

the part without them.

Thanks,

T.
Index: lib/external_templates
===
--- lib/external_templates	(revisione 39362)
+++ lib/external_templates	(copia locale)
@@ -44,6 +44,7 @@
 	HelpTextEnd
 	InputFormat gnumeric
 	FileFilter *.{gnumeric,ods,xls}
+	Sample sample.gnumeric,sample.ods
 	AutomaticProduction true
 	Format LaTeX
 		Product \\def\\inputGnumericTable{}\\input{$$AbsOrRelPathMaster$$Basename.tex}
@@ -376,6 +377,7 @@
 	HelpTextEnd
 	InputFormat dia
 	FileFilter *.dia
+	Sample sample.dia
 	AutomaticProduction true
 	# LyX has hard-coded support for these transformations
 	Transform Rotate
Index: lib/configure.py
===
--- lib/configure.py	(revisione 39362)
+++ lib/configure.py	(copia locale)
@@ -458,6 +458,9 @@
 checkViewerEditor('a Dia viewer and editor', ['dia'],
 rc_entry = [r'\Format diadia DIA %%	%%	vector'])
 #
+checkViewerEditor('an OpenOffice Calc viewer and editor', ['oocalc'],
+rc_entry = [r'\Format odsods ODS %%	%%	vector'])
+#
 checkViewerEditor('a Grace viewer and editor', ['xmgrace'],
 rc_entry = [r'\Format agragr Grace   %%	%%	vector'])
 #
Index: src/insets/ExternalTemplate.cpp
===
--- src/insets/ExternalTemplate.cpp	(revisione 39362)
+++ src/insets/ExternalTemplate.cpp	(copia locale)
@@ -303,6 +303,20 @@
 }
 
 
+static void readSamples(std::mapstring,string  samples, string s) {
+	size_t pos = 0, new_pos;
+	do {
+		new_pos = s.find(,, pos);
+		if (new_pos == string::npos)
+			new_pos = s.length();
+		string fname = s.substr(pos, new_pos - pos);
+		string ext = FileName(fname).extension();
+		LYXERR(Debug::EXTERNAL, adding sample mapping:   ext   =   fname);
+		samples[ext] = fname;
+		pos = new_pos + 1;
+	} while (pos  s.length());
+}
+
 void Template::readTemplate(Lexer  lex)
 {
 	enum {
@@ -314,7 +328,8 @@
 		TO_PREVIEW,
 		TO_TRANSFORM,
 		TO_FORMAT,
-		TO_END
+		TO_END,
+		TO_SAMPLE
 	};
 
 	LexerKeyword templateoptiontags[] = {
@@ -325,6 +340,7 @@
 		{ helptext, TO_HELPTEXT },
 		{ inputformat, TO_INPUTFORMAT },
 		{ preview, TO_PREVIEW },
+		{ sample, TO_SAMPLE },
 		{ templateend, TO_END },
 		{ transform, TO_TRANSFORM }
 	};
@@ -387,6 +403,11 @@
 		case TO_END:
 			return;
 
+		case TO_SAMPLE:
+			lex.next(true);
+			readSamples(samples, lex.getString());
+			break;
+
 		default:
 			lex.printError(external::Template::readTemplate: 
    Wrong tag: $$Token);
Index: src/insets/ExternalTemplate.h
===
--- src/insets/ExternalTemplate.h	(revisione 39362)
+++ src/insets/ExternalTemplate.h	(copia locale)
@@ -68,6 +68,8 @@
 	PreviewMode preview_mode;
 	/// A collection of transforms that we can use to transform the data.
 	std::vectorTransformID transformIds;
+	/// Map from extensions to pathnames of corresponding sample empty files
+	std::mapstd::string,std::string samples;
 
 	/// This is the information needed to support a specific output format
 	class Format {
Index: src/frontends/qt4/ui/ExternalUi.ui
===
--- src/frontends/qt4/ui/ExternalUi.ui	(revisione 39362)
+++ src/frontends/qt4/ui/ExternalUi.ui	(copia locale)
@@ -1,107 +1,108 @@
-ui version=4.0 
+?xml version=1.0 encoding=UTF-8?
+ui version=4.0
  classExternalUi/class
- widget class=QDialog name=ExternalUi 
-  property name=geometry 
+ widget class=QDialog name=ExternalUi
+  property name=geometry
rect
 x0/x
 y0/y
 width386/width
-height453/height
+height491/height
/rect
   /property
-  property name=windowTitle 
+  property name=windowTitle
string/
   /property
-  property name=sizeGripEnabled 
+  property name=sizeGripEnabled
booltrue/bool
   /property
-  layout class=QGridLayout 
-   property name=margin 
+  layout class=QGridLayout
+   property name=margin
 number9/number
/property
-   property name=spacing 
+   property name=spacing
 number6/number
/property
-   item row=0 column=0 
-widget class=QTabWidget name=tab 
- property name=toolTip 
+   item row=0 column=0
+widget class=QTabWidget name=tab
+ property name=toolTip
   string/
  /property
- property name=currentIndex 
+ property name=currentIndex
   number0/number
  /property
- widget class=QWidget name=filetab 
-  attribute name=title 
+ widget 

Re: External material/graphics empty samples

2011-07-22 Thread Tommaso Cucinotta

I dropped the new patch on #3205, so that we don't forget about it.

T.

Il 22/07/2011 06:22, Tommaso Cucinotta ha scritto:

Hi all,

I just reworked the patch on the current trunk, plus I added a few 
desirable things:


-) Insert->External Material...-> enter filename (e.g., foo.dia or 
foo.ods or foo.gnumeric), press Create and you get an empty template;
-) type a file-name with an extension, and the template type is 
inferred from the dropdown box, if the extension is recognized;
-) choose a different template from the drop-down, and the file-name 
extension is automatically inferred;
-) each template may be associated with a list of different sample 
filenames and associated extensions;

   for example, in the gnumeric section of external_templates:
 Sample "sample.gnumeric,sample.ods"

The only thing that is missing, is that I'D LOVE HAVING THIS FOR 
INSERT->FIGURE. Indeed, if I use it for inserting DIA figures etc., 
then I get a poorer properties pane (e.g., rotation, size on paper and 
on screen, etc.). Furthermore, the image is not previewed.
Instead, if I use Insert->Figure, then I don't have this new feature 
that I really like :-).


Anyone willing to give it a try ?

Bye,

T.

Il 24/04/2011 23:31, Tommaso Cucinotta ha scritto:

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say "preliminary" because things that one may want to add are:
-) launch also the editor, when you press "Create..."
-) add another "Edit..." button for launching the external editor
-) better control of *where* the new file is created (in the patch 
it is the current folder, but I guess I should use the folder of the 
".lyx" file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the "Create" button, detect the non-existent file on 
dialog "Ok" button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select "Dia" *and* provide a file-name like 
"mydrawing.dia" -- the latter just includes the former info).


T.






Re: External material/graphics empty samples

2011-07-22 Thread Pavel Sanda
Tommaso Cucinotta wrote:
> I dropped the new patch on #3205, so that we don't forget about it.

its uncomfortable to comment on the patches coming in gzip form, i.e.
the chances to get some reaction is smaller this way.
pavel


Re: External material/graphics empty samples

2011-07-22 Thread Tommaso Cucinotta

Il 22/07/2011 18:47, Pavel Sanda ha scritto:

Tommaso Cucinotta wrote:

I dropped the new patch on #3205, so that we don't forget about it.

its uncomfortable to comment on the patches coming in gzip form, i.e.
the chances to get some reaction is smaller this way.
pavel
because it contained binary sample files (.odt, ...). Let me attach to 
this message

the part without them.

Thanks,

T.
Index: lib/external_templates
===
--- lib/external_templates	(revisione 39362)
+++ lib/external_templates	(copia locale)
@@ -44,6 +44,7 @@
 	HelpTextEnd
 	InputFormat "gnumeric"
 	FileFilter "*.{gnumeric,ods,xls}"
+	Sample "sample.gnumeric,sample.ods"
 	AutomaticProduction true
 	Format LaTeX
 		Product "\\def\\inputGnumericTable{}\\input{$$AbsOrRelPathMaster$$Basename.tex}"
@@ -376,6 +377,7 @@
 	HelpTextEnd
 	InputFormat dia
 	FileFilter "*.dia"
+	Sample "sample.dia"
 	AutomaticProduction true
 	# LyX has hard-coded support for these transformations
 	Transform Rotate
Index: lib/configure.py
===
--- lib/configure.py	(revisione 39362)
+++ lib/configure.py	(copia locale)
@@ -458,6 +458,9 @@
 checkViewerEditor('a Dia viewer and editor', ['dia'],
 rc_entry = [r'\Format diadia DIA"" "%%"	"%%"	"vector"'])
 #
+checkViewerEditor('an OpenOffice Calc viewer and editor', ['oocalc'],
+rc_entry = [r'\Format odsods ODS"" "%%"	"%%"	"vector"'])
+#
 checkViewerEditor('a Grace viewer and editor', ['xmgrace'],
 rc_entry = [r'\Format agragr Grace  "" "%%"	"%%"	"vector"'])
 #
Index: src/insets/ExternalTemplate.cpp
===
--- src/insets/ExternalTemplate.cpp	(revisione 39362)
+++ src/insets/ExternalTemplate.cpp	(copia locale)
@@ -303,6 +303,20 @@
 }
 
 
+static void readSamples(std::map & samples, string s) {
+	size_t pos = 0, new_pos;
+	do {
+		new_pos = s.find(",", pos);
+		if (new_pos == string::npos)
+			new_pos = s.length();
+		string fname = s.substr(pos, new_pos - pos);
+		string ext = FileName(fname).extension();
+		LYXERR(Debug::EXTERNAL, "adding sample mapping: " << ext << " => " << fname);
+		samples[ext] = fname;
+		pos = new_pos + 1;
+	} while (pos < s.length());
+}
+
 void Template::readTemplate(Lexer & lex)
 {
 	enum {
@@ -314,7 +328,8 @@
 		TO_PREVIEW,
 		TO_TRANSFORM,
 		TO_FORMAT,
-		TO_END
+		TO_END,
+		TO_SAMPLE
 	};
 
 	LexerKeyword templateoptiontags[] = {
@@ -325,6 +340,7 @@
 		{ "helptext", TO_HELPTEXT },
 		{ "inputformat", TO_INPUTFORMAT },
 		{ "preview", TO_PREVIEW },
+		{ "sample", TO_SAMPLE },
 		{ "templateend", TO_END },
 		{ "transform", TO_TRANSFORM }
 	};
@@ -387,6 +403,11 @@
 		case TO_END:
 			return;
 
+		case TO_SAMPLE:
+			lex.next(true);
+			readSamples(samples, lex.getString());
+			break;
+
 		default:
 			lex.printError("external::Template::readTemplate: "
    "Wrong tag: $$Token");
Index: src/insets/ExternalTemplate.h
===
--- src/insets/ExternalTemplate.h	(revisione 39362)
+++ src/insets/ExternalTemplate.h	(copia locale)
@@ -68,6 +68,8 @@
 	PreviewMode preview_mode;
 	/// A collection of transforms that we can use to transform the data.
 	std::vector transformIds;
+	/// Map from extensions to pathnames of corresponding sample empty files
+	std::map samples;
 
 	/// This is the information needed to support a specific output format
 	class Format {
Index: src/frontends/qt4/ui/ExternalUi.ui
===
--- src/frontends/qt4/ui/ExternalUi.ui	(revisione 39362)
+++ src/frontends/qt4/ui/ExternalUi.ui	(copia locale)
@@ -1,107 +1,108 @@
-
+
+
  ExternalUi
- 
-  
+ 
+  

 0
 0
 386
-453
+491

   
-  
+  

   
-  
+  
true
   
-  
-   
+  
+   
 9

-   
+   
 6

-   
-
- 
+   
+
+ 
   
  
- 
+ 
   0
  
- 
-  
+ 
+  
File
   
-  
-   
+  
+   
 9

-   
+   
 6

-   
-
- 
+   
+
+ 
   Filename
  
 

-   
-
- 
+   
+
+ 
   Filename
  
- 
+ 
   File:
  
- 
+ 
   fileED
  
 

-   
-
- 
+   
+
+ 
   Select a file
  
- 
+ 
   Browse...
  
 

-   
-
- 
+   
+
+ 
   Draft
  
 

-   
-
- 
+   
+
+ 
   Template
  
-   

Re: External material/graphics empty samples

2011-07-21 Thread Tommaso Cucinotta

Hi all,

I just reworked the patch on the current trunk, plus I added a few 
desirable things:


-) Insert-External Material...- enter filename (e.g., foo.dia or 
foo.ods or foo.gnumeric), press Create and you get an empty template;
-) type a file-name with an extension, and the template type is inferred 
from the dropdown box, if the extension is recognized;
-) choose a different template from the drop-down, and the file-name 
extension is automatically inferred;
-) each template may be associated with a list of different sample 
filenames and associated extensions;

   for example, in the gnumeric section of external_templates:
 Sample sample.gnumeric,sample.ods

The only thing that is missing, is that I'D LOVE HAVING THIS FOR 
INSERT-FIGURE. Indeed, if I use it for inserting DIA figures etc., then 
I get a poorer properties pane (e.g., rotation, size on paper and on 
screen, etc.). Furthermore, the image is not previewed.
Instead, if I use Insert-Figure, then I don't have this new feature 
that I really like :-).


Anyone willing to give it a try ?

Bye,

T.

Il 24/04/2011 23:31, Tommaso Cucinotta ha scritto:

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say preliminary because things that one may want to add are:
-) launch also the editor, when you press Create...
-) add another Edit... button for launching the external editor
-) better control of *where* the new file is created (in the patch it 
is the current folder, but I guess I should use the folder of the 
.lyx file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the Create button, detect the non-existent file on 
dialog Ok button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select Dia *and* provide a file-name like 
mydrawing.dia -- the latter just includes the former info).


T.




lyx-create-external-material.patch.gz
Description: GNU Zip compressed data


Re: External material/graphics empty samples

2011-07-21 Thread Tommaso Cucinotta

Hi all,

I just reworked the patch on the current trunk, plus I added a few 
desirable things:


-) Insert->External Material...-> enter filename (e.g., foo.dia or 
foo.ods or foo.gnumeric), press Create and you get an empty template;
-) type a file-name with an extension, and the template type is inferred 
from the dropdown box, if the extension is recognized;
-) choose a different template from the drop-down, and the file-name 
extension is automatically inferred;
-) each template may be associated with a list of different sample 
filenames and associated extensions;

   for example, in the gnumeric section of external_templates:
 Sample "sample.gnumeric,sample.ods"

The only thing that is missing, is that I'D LOVE HAVING THIS FOR 
INSERT->FIGURE. Indeed, if I use it for inserting DIA figures etc., then 
I get a poorer properties pane (e.g., rotation, size on paper and on 
screen, etc.). Furthermore, the image is not previewed.
Instead, if I use Insert->Figure, then I don't have this new feature 
that I really like :-).


Anyone willing to give it a try ?

Bye,

T.

Il 24/04/2011 23:31, Tommaso Cucinotta ha scritto:

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say "preliminary" because things that one may want to add are:
-) launch also the editor, when you press "Create..."
-) add another "Edit..." button for launching the external editor
-) better control of *where* the new file is created (in the patch it 
is the current folder, but I guess I should use the folder of the 
".lyx" file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the "Create" button, detect the non-existent file on 
dialog "Ok" button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select "Dia" *and* provide a file-name like 
"mydrawing.dia" -- the latter just includes the former info).


T.




lyx-create-external-material.patch.gz
Description: GNU Zip compressed data


Re: External material/graphics empty samples

2011-04-24 Thread Tommaso Cucinotta

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say preliminary because things that one may want to add are:
-) launch also the editor, when you press Create...
-) add another Edit... button for launching the external editor
-) better control of *where* the new file is created (in the patch it 
is the current folder, but I guess I should use the folder of the 
.lyx file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the Create button, detect the non-existent file on 
dialog Ok button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select Dia *and* provide a file-name like 
mydrawing.dia -- the latter just includes the former info).


T.


Re: External material/graphics empty samples

2011-04-24 Thread Tommaso Cucinotta

Il 23/04/2011 23:48, Tommaso Cucinotta ha scritto:

I say "preliminary" because things that one may want to add are:
-) launch also the editor, when you press "Create..."
-) add another "Edit..." button for launching the external editor
-) better control of *where* the new file is created (in the patch it 
is the current folder, but I guess I should use the folder of the 
".lyx" file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


I forgot to mention:

-) instead of the "Create" button, detect the non-existent file on 
dialog "Ok" button, and query the user if the file doesn't exist
-) self-detect the format of the new file from the provided filename 
extension, if present, instead of relying on the choice Combo (it's a 
burden to have to select "Dia" *and* provide a file-name like 
"mydrawing.dia" -- the latter just includes the former info).


T.


External material/graphics empty samples (was: Re: Simple Drawing Ability)

2011-04-23 Thread Tommaso Cucinotta

Il 20/04/2011 18:25, Jens Nöckel ha scritto:

On Apr 19, 2011, at 3:06 PM, Tommaso Cucinotta wrote:

AFAIK, after the thread

  http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg154697.html

there was no actual implementation of this feature, for creating
quickly empty external files over which to invoke an external editor.

In the current trunk, you can specify a non-existent external file in
the Insert -  External Material... dialog, but when trying to externally
edit you get a non-existent file error dialog.

Is there anyone with a patch for this ? (i.e., a create button the
Insert -  External Material... dialog).

Guess #3205 is the corresponding Trac entry (#5726 seems related as well).

Regarding the topic Simple Drawing Ability - just in case this was 
overlooked, let me mention that simple drawings can be made by copy and paste.

[...]

That's fine for quickly pasting images from the clipboard, but I'd like 
something that gives me control of what I'm inserting (and its source 
format), without the burden to have to launch the program externally 
first, create a new file, place it into the same working folder as the 
.lyx I'm editing, then back to LyX, insert it, and re-edit.


Shortly, please try the attached preliminary patch.

It adds a Create button in the Insert-File-External Material... 
dialog which creates an empty file with the name specified by the user 
by copying from a file template, which is found into the lib/samples 
folder, with the filename specified into the a new Sample property of 
external material items.


I say preliminary because things that one may want to add are:
-) launch also the editor, when you press Create...
-) add another Edit... button for launching the external editor
-) better control of *where* the new file is created (in the patch it is 
the current folder, but I guess I should use the folder of the .lyx 
file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


On a related note, as a user, I'm really confused by:
-) Insert-Graphics...
-) Insert-File-External Material..., then pick dia or XFig

From a user viewpoint, what is supposed to be the difference between 
these 2 actions ?


And also by (despite the documentation):
-) Insert-Date
-) Insert-File-External Material..., then pick Date

Any comments welcome!

T.

Index: src/insets/ExternalTemplate.cpp
===
--- src/insets/ExternalTemplate.cpp	(revisione 38483)
+++ src/insets/ExternalTemplate.cpp	(copia locale)
@@ -313,7 +313,8 @@
 		TO_PREVIEW,
 		TO_TRANSFORM,
 		TO_FORMAT,
-		TO_END
+		TO_END,
+		TO_SAMPLE
 	};
 
 	LexerKeyword templateoptiontags[] = {
@@ -325,7 +326,8 @@
 		{ inputformat, TO_INPUTFORMAT },
 		{ preview, TO_PREVIEW },
 		{ templateend, TO_END },
-		{ transform, TO_TRANSFORM }
+		{ transform, TO_TRANSFORM },
+		{ sample, TO_SAMPLE }
 	};
 
 	PushPopHelper pph(lex, templateoptiontags);
@@ -386,6 +388,11 @@
 		case TO_END:
 			return;
 
+		case TO_SAMPLE:
+			lex.next(true);
+			sample = lex.getString();
+			break;
+
 		default:
 			lex.printError(external::Template::readTemplate: 
    Wrong tag: $$Token);
Index: src/insets/ExternalTemplate.h
===
--- src/insets/ExternalTemplate.h	(revisione 38483)
+++ src/insets/ExternalTemplate.h	(copia locale)
@@ -66,6 +66,8 @@
 	PreviewMode preview_mode;
 	/// A collection of transforms that we can use to transform the data.
 	std::vectorTransformID transformIds;
+	/// Pathname of a sample empty file
+	std::string sample;
 
 	/// This is the information needed to support a specific output format
 	class Format {
Index: src/frontends/qt4/ui/ExternalUi.ui
===
--- src/frontends/qt4/ui/ExternalUi.ui	(revisione 38483)
+++ src/frontends/qt4/ui/ExternalUi.ui	(copia locale)
@@ -1,107 +1,108 @@
-ui version=4.0 
+?xml version=1.0 encoding=UTF-8?
+ui version=4.0
  classExternalUi/class
- widget class=QDialog name=ExternalUi 
-  property name=geometry 
+ widget class=QDialog name=ExternalUi
+  property name=geometry
rect
 x0/x
 y0/y
 width386/width
-height453/height
+height491/height
/rect
   /property
-  property name=windowTitle 
+  property name=windowTitle
string/
   /property
-  property name=sizeGripEnabled 
+  property name=sizeGripEnabled
booltrue/bool
   /property
-  layout class=QGridLayout 
-   property name=margin 
+  layout class=QGridLayout
+   property name=margin
 number9/number
/property
-   property name=spacing 
+   property name=spacing
 number6/number
/property
-   item row=0 column=0 
-widget class=QTabWidget name=tab 
- property name=toolTip 
+   item row=0 column=0
+widget class=QTabWidget name=tab
+ property name=toolTip
   string/
  /property

External material/graphics empty samples (was: Re: Simple Drawing Ability)

2011-04-23 Thread Tommaso Cucinotta

Il 20/04/2011 18:25, Jens Nöckel ha scritto:

On Apr 19, 2011, at 3:06 PM, Tommaso Cucinotta wrote:

AFAIK, after the thread

  http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg154697.html

there was no actual implementation of this feature, for creating
quickly empty external files over which to invoke an external editor.

In the current trunk, you can specify a non-existent external file in
the Insert ->  External Material... dialog, but when trying to externally
edit you get a "non-existent file" error dialog.

Is there anyone with a patch for this ? (i.e., a "create" button the
Insert ->  External Material... dialog).

Guess #3205 is the corresponding Trac entry (#5726 seems related as well).

Regarding the topic "Simple Drawing Ability" - just in case this was 
overlooked, let me mention that simple drawings can be made by copy and paste.

[...]

That's fine for quickly pasting images from the clipboard, but I'd like 
something that gives me control of what I'm inserting (and its source 
format), without the burden to have to launch the program externally 
first, create a new file, place it into the same working folder as the 
".lyx" I'm editing, then back to LyX, insert it, and re-edit.


Shortly, please try the attached preliminary patch.

It adds a "Create" button in the "Insert->File->External Material..." 
dialog which creates an empty file with the name specified by the user 
by copying from a file template, which is found into the "lib/samples" 
folder, with the filename specified into the a new "Sample" property of 
external material items.


I say "preliminary" because things that one may want to add are:
-) launch also the editor, when you press "Create..."
-) add another "Edit..." button for launching the external editor
-) better control of *where* the new file is created (in the patch it is 
the current folder, but I guess I should use the folder of the ".lyx" 
file I'm inserting into (how to get that ?)
-) possibility to use different empty template files, and to specify 
which one we want (e.g., for images, .png, .svg, .dia, ...).


On a related note, as a user, I'm really confused by:
-) Insert->Graphics...
-) Insert->File->External Material..., then pick "dia" or "XFig"

From a user viewpoint, what is supposed to be the difference between 
these 2 actions ?


And also by (despite the documentation):
-) Insert->Date
-) Insert->File->External Material..., then pick "Date"

Any comments welcome!

T.

Index: src/insets/ExternalTemplate.cpp
===
--- src/insets/ExternalTemplate.cpp	(revisione 38483)
+++ src/insets/ExternalTemplate.cpp	(copia locale)
@@ -313,7 +313,8 @@
 		TO_PREVIEW,
 		TO_TRANSFORM,
 		TO_FORMAT,
-		TO_END
+		TO_END,
+		TO_SAMPLE
 	};
 
 	LexerKeyword templateoptiontags[] = {
@@ -325,7 +326,8 @@
 		{ "inputformat", TO_INPUTFORMAT },
 		{ "preview", TO_PREVIEW },
 		{ "templateend", TO_END },
-		{ "transform", TO_TRANSFORM }
+		{ "transform", TO_TRANSFORM },
+		{ "sample", TO_SAMPLE }
 	};
 
 	PushPopHelper pph(lex, templateoptiontags);
@@ -386,6 +388,11 @@
 		case TO_END:
 			return;
 
+		case TO_SAMPLE:
+			lex.next(true);
+			sample = lex.getString();
+			break;
+
 		default:
 			lex.printError("external::Template::readTemplate: "
    "Wrong tag: $$Token");
Index: src/insets/ExternalTemplate.h
===
--- src/insets/ExternalTemplate.h	(revisione 38483)
+++ src/insets/ExternalTemplate.h	(copia locale)
@@ -66,6 +66,8 @@
 	PreviewMode preview_mode;
 	/// A collection of transforms that we can use to transform the data.
 	std::vector transformIds;
+	/// Pathname of a sample empty file
+	std::string sample;
 
 	/// This is the information needed to support a specific output format
 	class Format {
Index: src/frontends/qt4/ui/ExternalUi.ui
===
--- src/frontends/qt4/ui/ExternalUi.ui	(revisione 38483)
+++ src/frontends/qt4/ui/ExternalUi.ui	(copia locale)
@@ -1,107 +1,108 @@
-
+
+
  ExternalUi
- 
-  
+ 
+  

 0
 0
 386
-453
+491

   
-  
+  

   
-  
+  
true
   
-  
-   
+  
+   
 9

-   
+   
 6

-   
-
- 
+   
+
+ 
   
  
- 
+ 
   0
  
- 
-  
+ 
+  
File
   
-  
-   
+  
+   
 9

-   
+   
 6

-   
-
- 
+   
+
+ 
   Filename
  
 

-   
-
- 
+   
+
+ 
   Filename
  
- 
+ 
   File:
  
- 
+ 
   fileED
  
 

-   
-
- 
+   
+
+ 
   Select a file
  
- 
+ 
   Browse...
  
 

-   
-
-