]> git.lyx.org Git - features.git/commitdiff
The Ok button is now activated in the Include dialog when the filename is
authorAngus Leeming <leeming@lyx.org>
Tue, 12 Jun 2001 12:39:26 +0000 (12:39 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 12 Jun 2001 12:39:26 +0000 (12:39 +0000)
input from the keyboard.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2105 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormInclude.C
src/frontends/xforms/form_include.C
src/frontends/xforms/forms/form_include.fd

index fd4ee4a1ad1cf273c0cecfb6fcb3069b63be4397..02e1f07cbcc5c02004852ea9e03d9053d43785fc 100644 (file)
@@ -1,5 +1,9 @@
 2001-06-12  Angus Leeming  <a.leeming@ic.ac.uk>
 
+       * FormInclude.C:
+       * form_include.fd: (various places): Ok button is now activated when
+       the filename is input from the keyboard.
+
        * FormPreferences.C white-space change in various places.
        (Converters::GetTo): get the contents of "to" not "from"! Thus fix bug
        that disabled addition of new converters.
index 372db8d4226861d1638a0612584f51ff6ea76917..42015d2d3e15da46964ef74baefe8278fc38e35b 100644 (file)
@@ -21,7 +21,7 @@
 #include "form_include.h"
 #include "insets/insetinclude.h"
 #include "xforms_helpers.h" // setEnabled
-#include "support/lstrings.h" // compare
+#include "support/lstrings.h" // strip
 
 typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
 
@@ -34,6 +34,8 @@ void FormInclude::build()
 {
        dialog_.reset(build_include());
 
+       fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
+
        // Manage the ok and cancel buttons
        bc().setOK(dialog_->button_ok);
        bc().setCancel(dialog_->button_cancel);
@@ -106,6 +108,8 @@ void FormInclude::apply()
 
 ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
 {
+       ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
+
        if (ob == dialog_->button_browse) {
                ControlInclude::Type type;
                if (fl_get_button(dialog_->check_useinput))
@@ -121,24 +125,26 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
                fl_set_input(dialog_->input_filename, out_name.c_str());
                fl_unfreeze_form(form()); 
 
-               return ButtonPolicy::SMI_VALID;
-       }
-
-       if (ob == dialog_->button_load) {
-               if (compare(fl_get_input(dialog_->input_filename),"")) {
+       } else if (ob == dialog_->button_load) {
+               string const in_name = fl_get_input(dialog_->input_filename);
+               if (!strip(in_name).empty()) {
                        ApplyButton();
-                       return ButtonPolicy::SMI_NOOP;
+                       action = ButtonPolicy::SMI_NOOP;
                }
-       }
 
-       if (ob == dialog_->check_verbatim) {
+       } else if (ob == dialog_->check_verbatim) {
                setEnabled(dialog_->check_visiblespace, true);
 
        } else if (ob == dialog_->check_useinclude ||
                   ob == dialog_->check_useinput) {
                fl_set_button(dialog_->check_visiblespace, 0);
                setEnabled(dialog_->check_visiblespace, false);
+
+       } else if (ob == dialog_->input_filename) {
+               string const in_name = fl_get_input(dialog_->input_filename);
+               if (strip(in_name).empty())
+                       action = ButtonPolicy::SMI_INVALID;
        }
        
-       return ButtonPolicy::SMI_VALID;
+       return action;
 }
index 8e602c31e6048807ccc191d608690cc3bc48c6ab..8cf2f8b8a8804fef1e41d43b875c0a0f2e2ba17c 100644 (file)
@@ -63,6 +63,7 @@ FD_form_include * FormInclude::build_include()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Visible space|#s");
     fdui->check_visiblespace = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 180, 100, 150, 30, idex(_(dummy)));
index 8a69831e98ecd713f4190f0fa3118e64953029c4..79c41820289ff69093acb86d0c9dadeab35bcc26 100644 (file)
@@ -153,7 +153,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: input_filename
-callback: 
+callback: C_FormBaseInputCB
 argument: 
 
 --------------------