]> git.lyx.org Git - features.git/commitdiff
Herbert's patch, part 2
authorAngus Leeming <leeming@lyx.org>
Mon, 20 Aug 2001 13:41:06 +0000 (13:41 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 20 Aug 2001 13:41:06 +0000 (13:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2557 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/form_bibtex.C
src/frontends/xforms/form_bibtex.h
src/frontends/xforms/forms/form_bibtex.fd

index 86d9de895eb491a5ad2db865bb033288bf490998..7fee6fb4f37ea0874ac8fad1b83adcee23cc7356 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-20  Herbert Voss  <voss@perce.de>
+
+       * FormBibtex.C:
+       * forms/form_bibtex.fd: enhanced bibtex-data gui to browse for
+       databases and styles. Added an option for "bibliography into toc"
+
 2001-08-18  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * FormMathsBitmap.h: use the lyx::shared_c_ptr that uses free() to
index 266a5d90372f9be38148e1e94b6dc5185542f4bf..99b86403634a1ec3483f136bab1fa8a730b8da40 100644 (file)
@@ -5,6 +5,7 @@
  *
  * \author Angus Leeming
  * \author John Levon
+ * \author Herbert Voss <voss@lyx.org>
  */
 
 #ifdef __GNUG__
@@ -19,6 +20,8 @@
 #include "gettext.h"
 #include "debug.h"
 #include "support/lstrings.h"
+#include "support/filetools.h"
+
 
 typedef FormCB<ControlBibtex, FormDB<FD_form_bibtex> > base_class;
 
@@ -38,16 +41,53 @@ void FormBibtex::build()
        bc().setOK(dialog_->button_ok);
        bc().setCancel(dialog_->button_cancel);
 
+       bc().addReadOnly(dialog_->database_browse);
        bc().addReadOnly(dialog_->database);
+       bc().addReadOnly(dialog_->style_browse);
        bc().addReadOnly(dialog_->style);
+       bc().addReadOnly(dialog_->radio_bibtotoc);
 }
 
 
-ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long)
 {
-       // minimal validation 
-       if (!compare(fl_get_input(dialog_->database),""))
+       if (ob == dialog_->database_browse) {
+               string const in_name  = fl_get_input(dialog_->database);
+               fl_freeze_form(form()); 
+               string out_name = 
+                       controller().Browse(in_name,
+                                           "Select Database",
+                                           "*.bib| BibTeX Databases (*.bib)");
+               if (suffixIs(out_name,".bib")) {
+                       // to prevent names like xxxbib.bib
+                       // latex needs it without suffix
+                       out_name = ChangeExtension(out_name,"");
+               }
+    
+               fl_set_input(dialog_->database, out_name.c_str());
+               fl_unfreeze_form(form()); 
+       }       
+
+       if (ob == dialog_->style_browse) {
+               string const in_name  = fl_get_input(dialog_->style);
+               fl_freeze_form(form()); 
+               string out_name = 
+                       controller().Browse(in_name,
+                                           "Select BibTeX-Style",
+                                           "*.bst| BibTeX Styles (*.bst)");
+               if (suffixIs(out_name,".bst")) {
+                       // to prevent names like xxxbib.bib
+                       // name for display only
+                       out_name = OnlyFilename(ChangeExtension(out_name,""));
+               }
+
+               fl_set_input(dialog_->style, out_name.c_str());
+               fl_unfreeze_form(form()); 
+       }
+  
+       if (!compare(fl_get_input(dialog_->database),"")) {
                return ButtonPolicy::SMI_NOOP;
+       }
 
        return ButtonPolicy::SMI_VALID;
 }
@@ -57,13 +97,42 @@ void FormBibtex::update()
 {
        fl_set_input(dialog_->database,
                     controller().params().getContents().c_str());
-       fl_set_input(dialog_->style,
-                    controller().params().getOptions().c_str());
+        string bibtotoc = "bibtotoc";
+       string bibstyle (controller().params().getOptions().c_str());
+       if (prefixIs(bibstyle,bibtotoc)) { // bibtotoc exists?
+               fl_set_button(dialog_->radio_bibtotoc,1);
+               if (contains(bibstyle,',')) { // bibstyle exists?
+                       bibstyle = split(bibstyle,bibtotoc,',');
+               } else {
+                       bibstyle = "";
+               }
+
+               fl_set_input(dialog_->style,bibstyle.c_str());
+
+       } else {
+               fl_set_button(dialog_->radio_bibtotoc,0);
+               fl_set_input(dialog_->style,bibstyle.c_str());
+       }
 }
 
 
 void FormBibtex::apply()
 {
        controller().params().setContents(fl_get_input(dialog_->database));
-       controller().params().setOptions(fl_get_input(dialog_->style));
+       string const bibstyle = fl_get_input(dialog_->style); // may be empty!
+
+       if ((fl_get_button(dialog_->radio_bibtotoc) > 0) &&
+           (!bibstyle.empty())) {
+               // both bibtotoc and style
+               controller().params().setOptions("bibtotoc,"+bibstyle);
+       } else {
+               if (fl_get_button(dialog_->radio_bibtotoc) > 0) {
+                       // bibtotoc and no style
+                       controller().params().setOptions("bibtotoc");
+               } else {
+                       // only style
+                       controller().params().setOptions(bibstyle);
+               }
+       }
 }
+
index 68c1f44ba3ecf3c45d566e99c92f22df180e0ff6..0406be916cd8ccd62dfb63ca5ceb02eb5a3341d8 100644 (file)
@@ -22,33 +22,39 @@ FD_form_bibtex * FormBibtex::build_bibtex()
   FL_OBJECT *obj;
   FD_form_bibtex *fdui = new FD_form_bibtex;
 
-  fdui->form = fl_bgn_form(FL_NO_BOX, 220, 130);
+  fdui->form = fl_bgn_form(FL_NO_BOX, 450, 170);
   fdui->form->u_vdata = this;
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 220, 130, "");
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 450, 170, "");
   {
     char const * const dummy = N_("Database:|#D");
-    fdui->database = obj = fl_add_input(FL_NORMAL_INPUT, 80, 10, 130, 30, idex(_(dummy)));
+    fdui->database = obj = fl_add_input(FL_NORMAL_INPUT, 90, 10, 260, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 20, 90, 90, 30, _("OK"));
+  fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 250, 130, 90, 30, _("OK"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseOKCB, 3);
   {
     char const * const dummy = N_("Cancel|^[");
-    fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 120, 90, 90, 30, idex(_(dummy)));
+    fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 130, 90, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseCancelCB, 2);
   {
     char const * const dummy = N_("Style:|#S");
-    fdui->style = obj = fl_add_input(FL_NORMAL_INPUT, 80, 50, 130, 30, idex(_(dummy)));
+    fdui->style = obj = fl_add_input(FL_NORMAL_INPUT, 90, 50, 260, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->database_browse = obj = fl_add_button(FL_PUSH_BUTTON, 360, 10, 80, 30, _("Browse"));
+    fl_set_button_shortcut(obj, _("B"), 1);
+  fdui->style_browse = obj = fl_add_button(FL_PUSH_BUTTON, 360, 50, 80, 30, _("Browse"));
+    fl_set_button_shortcut(obj, _("l"), 1);
+  fdui->radio_bibtotoc = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 90, 90, 30, 30, _("Add bibliography to TOC"));
+    fl_set_button_shortcut(obj, _("T"), 1);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index 8189af6e7a38b30abf7e929f40d1a2dc2faf03e9..4ec2b787832d126bd8a6c9fa01bba3a10cde0fc7 100644 (file)
@@ -19,6 +19,9 @@ struct FD_form_bibtex {
        FL_OBJECT *button_ok;
        FL_OBJECT *button_cancel;
        FL_OBJECT *style;
+       FL_OBJECT *database_browse;
+       FL_OBJECT *style_browse;
+       FL_OBJECT *radio_bibtotoc;
 };
 
 #endif /* FD_form_bibtex_h_ */
index 65693be14487cba0173675ac8c75c02142b0d3b2..9ac61232487e7de491a6fe0622aef539513d0352 100644 (file)
@@ -8,14 +8,14 @@ Unit of measure: FL_COORD_PIXEL
 
 =============== FORM ===============
 Name: form_bibtex
-Width: 220
-Height: 130
-Number of Objects: 5
+Width: 450
+Height: 170
+Number of Objects: 8
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 220 130
+box: 0 0 450 170
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -33,7 +33,7 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 80 10 130 30
+box: 90 10 260 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT
@@ -51,7 +51,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: RETURN_BUTTON
-box: 20 90 90 30
+box: 250 130 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -69,7 +69,7 @@ argument: 3
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 120 90 90 30
+box: 350 130 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -87,7 +87,7 @@ argument: 2
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 80 50 130 30
+box: 90 50 260 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT
@@ -102,5 +102,59 @@ name: style
 callback: C_FormBaseInputCB
 argument: 0
 
+--------------------
+class: FL_BUTTON
+type: PUSH_BUTTON
+box: 360 10 80 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Browse
+shortcut: B
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: database_browse
+callback: 
+argument: database
+
+--------------------
+class: FL_BUTTON
+type: PUSH_BUTTON
+box: 360 50 80 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Browse
+shortcut: l
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: style_browse
+callback: 
+argument: 
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 90 90 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Add bibliography to TOC
+shortcut: T
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_bibtotoc
+callback: 
+argument: 
+
 ==============================
 create_the_forms