]> git.lyx.org Git - features.git/commitdiff
patch from Dekel
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 26 May 2000 00:00:02 +0000 (00:00 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 26 May 2000 00:00:02 +0000 (00:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@772 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
forms/lyx.fd
src/LyXAction.C
src/buffer.C
src/commandtags.h
src/lyx.C
src/lyx.h
src/lyx_cb.C
src/menus.C
src/table.C

index ab830cbedc21fcd03f64c960e3d463ac460a3ac9..1ca7aa470af6e74d5665d92cc7dd530b5b598c8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-05-25 Dekel Tsur  <dekel@math.tau.ac.il>
+
+       * src/lyx_cb.C (RefUpdateCB): disable appropriate buttons when
+       there are no labels, or when buffer is readonly.
+
+       * src/menus.C (ShowRefsMenu) disable appropriate menu items when
+       there are no labels, buffer is SGML, or when buffer is readonly.
+
 2000-05-25  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/LColor.C (LColor): change a couple of grey40 to grey60
index db766115466c761f9dcf994865dd1256b60fbbed..8547380f3f61dab7698a9aa1299e8bc7da52f535 100644 (file)
@@ -590,7 +590,7 @@ label: Insert Reference|#I^M
 shortcut: 
 resize: FL_RESIZE_NONE
 gravity: FL_SouthWest FL_SouthWest
-name: 
+name: ref
 callback: RefSelectCB
 argument: 0
 
@@ -608,7 +608,7 @@ label: Insert Page Number|#P
 shortcut: 
 resize: FL_RESIZE_NONE
 gravity: FL_SouthWest FL_SouthWest
-name: 
+name: pageref
 callback: RefSelectCB
 argument: 1
 
@@ -626,7 +626,7 @@ label: Go to Reference|#G
 shortcut: 
 resize: FL_RESIZE_NONE
 gravity: FL_SouthWest FL_SouthWest
-name: 
+name: gotoref
 callback: RefSelectCB
 argument: 5
 
index d0daf533f8785a33e70d83462182efe60aa0f957..4fc46c8dc07553c8afb9b2058940bae7a5c3df55 100644 (file)
@@ -298,8 +298,6 @@ void LyXAction::init()
                { LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
                { LFUN_INSERT_NOTE, "note-insert", "", Noop },
                { LFUN_GOTONOTE, "note-next", "", ReadOnly },
-               { LFUN_INSET_NUMBER , "number-inset-insert",
-                 N_("Insert a new Number Inset"), Noop },
                { LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
                { LFUN_DOWN_PARAGRAPH, "paragraph-down",
                  N_("Go one paragraph down"), ReadOnly },
@@ -323,7 +321,7 @@ void LyXAction::init()
                { LFUN_REFBACK, "reference-back", "", ReadOnly },
                { LFUN_REFGOTO, "reference-goto", "", ReadOnly },
                { LFUN_INSERT_REF, "reference-insert",
-                 N_("Insert cross reference"), Noop },
+                 N_("Insert cross reference"), ReadOnly },
                { LFUN_REFTOGGLE, "reference-toggle", "", Noop },
                { LFUN_NEXT, "screen-down", "", ReadOnly },
                { LFUN_NEXTSEL, "screen-down-select", "", ReadOnly },
index c170b1c9790e8dc8fc4ae28beaa8d2fc1a13b909..7d1be9cb8956e8aefbc56f6e0468699fa95484d2 100644 (file)
@@ -3906,7 +3906,7 @@ void Buffer::markDepClean(string const & name)
                        item = new DEPCLEAN;
                        item->clean = true;
                        item->master = name;
-                       item->next = 0;;
+                       item->next = 0;
                }
        }
 }
index 66829c1bd4d506a563e68567e053c3074bc7c6c3..1703b4a3c691add846dc6ed0e92e34b2097790f2 100644 (file)
@@ -245,7 +245,6 @@ enum kb_action {
        LFUN_INSET_ERT,                 // Jug 20000218
        LFUN_INSERT_GRAPHICS,           // Lgb 20000226
        LFUN_INSET_FOOTNOTE,            // Jug 20000307
-       LFUN_INSET_NUMBER,              // Dekel 20000402
        LFUN_PARAGRAPH_SPACING,         // Lgb 20000411
        LFUN_INSET_TABULAR,             // Jug 20000412
        LFUN_LOFVIEW,                   // Dekel 20000519       
index 6af592d34525bcc2eec967eff6db8fd276a33a02..3747cc7da1c6ba190bd1a38329f1d369f842d0b5 100644 (file)
--- a/src/lyx.C
+++ b/src/lyx.C
@@ -159,15 +159,15 @@ FD_form_ref *create_form_form_ref(void)
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
     fl_set_object_callback(obj, RefHideCB, 0);
-  obj = fl_add_button(FL_NORMAL_BUTTON, 310, 60, 160, 30, idex(_("Insert Reference|#I^M")));fl_set_button_shortcut(obj, scex(_("Insert Reference|#I^M")), 1);
+  fdui->ref = obj = fl_add_button(FL_NORMAL_BUTTON, 310, 60, 160, 30, idex(_("Insert Reference|#I^M")));fl_set_button_shortcut(obj, scex(_("Insert Reference|#I^M")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
     fl_set_object_callback(obj, RefSelectCB, 0);
-  obj = fl_add_button(FL_NORMAL_BUTTON, 310, 100, 160, 30, idex(_("Insert Page Number|#P")));fl_set_button_shortcut(obj, scex(_("Insert Page Number|#P")), 1);
+  fdui->pageref = obj = fl_add_button(FL_NORMAL_BUTTON, 310, 100, 160, 30, idex(_("Insert Page Number|#P")));fl_set_button_shortcut(obj, scex(_("Insert Page Number|#P")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
     fl_set_object_callback(obj, RefSelectCB, 1);
-  obj = fl_add_button(FL_NORMAL_BUTTON, 310, 280, 160, 30, idex(_("Go to Reference|#G")));fl_set_button_shortcut(obj, scex(_("Go to Reference|#G")), 1);
+  fdui->gotoref = obj = fl_add_button(FL_NORMAL_BUTTON, 310, 280, 160, 30, idex(_("Go to Reference|#G")));fl_set_button_shortcut(obj, scex(_("Go to Reference|#G")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
     fl_set_object_callback(obj, RefSelectCB, 5);
index 45961281646b26648e1be75734b5a0c9d6ae467d..181b09a46de20fb778922499ef77b70dc177f3d2 100644 (file)
--- a/src/lyx.h
+++ b/src/lyx.h
@@ -73,6 +73,9 @@ typedef struct {
        char *cdata;
        long  ldata;
        FL_OBJECT *browser_ref;
+       FL_OBJECT *ref;
+       FL_OBJECT *pageref;
+       FL_OBJECT *gotoref;
        FL_OBJECT *ref_name;
        FL_OBJECT *sort;
        FL_OBJECT *vref;
index 1b4db6807f3759805d6955fd13cd01ce5b56ccfb..54210ed8efeb2fd644931a21784a34770e4920ec 100644 (file)
@@ -3256,40 +3256,59 @@ extern "C" void RefUpdateCB(FL_OBJECT *, long)
        }
        fl_set_browser_topline(brow, topline);
 
-       if (!fl_get_browser_maxline(brow)) {
+       bool empty = refs.empty();
+       bool sgml = current_view->buffer()->isSGML();
+       bool readonly = current_view->buffer()->isReadonly();
+
+       if (empty) {
                fl_add_browser_line(brow, 
                                    _("*** No labels found in document ***"));
                fl_deactivate_object(brow);
+               fl_deactivate_object(fd_form_ref->gotoref);
+               fl_set_object_lcol(fd_form_ref->gotoref, FL_INACTIVE);
        } else {
                fl_select_browser_line(brow, topline);
                fl_activate_object(brow);
+               fl_activate_object(fd_form_ref->gotoref);
+               fl_set_object_lcol(fd_form_ref->gotoref, FL_BLACK);
        }
-       if (current_view->buffer()->isReadonly()) {
-               // would be better to de/activate insert buttons
-               // but that's more work... besides this works. ARRae
-               fl_hide_form(fd_form_ref->form_ref);
-       }
-       if (!current_view->buffer()->isSGML()) {
-               fl_deactivate_object(fd_form_ref->ref_name);
-               fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
 
+       if (empty || readonly) {
+               fl_deactivate_object(fd_form_ref->ref);
+               fl_set_object_lcol(fd_form_ref->ref, FL_INACTIVE);
+               fl_deactivate_object(fd_form_ref->pageref);
+               fl_set_object_lcol(fd_form_ref->pageref, FL_INACTIVE);
+       } else {
+               fl_activate_object(fd_form_ref->ref);
+               fl_set_object_lcol(fd_form_ref->ref, FL_BLACK);
+               fl_activate_object(fd_form_ref->pageref);
+               fl_set_object_lcol(fd_form_ref->pageref, FL_BLACK);
+       }
+       
+       if (empty || readonly || sgml) {
+               fl_deactivate_object(fd_form_ref->vref);
+               fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
+               fl_deactivate_object(fd_form_ref->vpageref);
+               fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
+               fl_deactivate_object(fd_form_ref->prettyref);
+               fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
+       } else {
                fl_activate_object(fd_form_ref->vref);
                fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
                fl_activate_object(fd_form_ref->vpageref);
                fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
                fl_activate_object(fd_form_ref->prettyref);
                fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
-       } else {
+       }
+
+       if (sgml) {
                fl_activate_object(fd_form_ref->ref_name);
                fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
-
-               fl_deactivate_object(fd_form_ref->vref);
-               fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
-               fl_deactivate_object(fd_form_ref->vpageref);
-               fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
-               fl_deactivate_object(fd_form_ref->prettyref);
-               fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
+       } else {
+               fl_deactivate_object(fd_form_ref->ref_name);
+               fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
        }
+
        fl_show_object(brow);
 }
 
index 4ca5bc8effe01ef227cb6590f6a0a768dc48e0ab..dede19f841df76435827b4e4469335f6e1fb8742 100644 (file)
@@ -665,7 +665,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
        for (LastFiles::const_iterator cit = lastfiles->begin();
             cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
                string tmp = tostr(ii);
-               string tmp2 = tmp + "#" + tmp;;
+               string tmp2 = tmp + "#" + tmp;
                tmp += ". " + MakeDisplayPath((*cit), 30);
                fl_addtopup(FileMenu, tmp.c_str());
                fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
@@ -816,7 +816,7 @@ void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
        for (LastFiles::const_iterator cit = lastfiles->begin();
             cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
                string tmp = tostr(ii);
-               string tmp2 = tmp + "#" + tmp;;
+               string tmp2 = tmp + "#" + tmp;
                tmp += ". " + MakeDisplayPath((*cit), 30);
                fl_addtopup(FileMenu, tmp.c_str());
                fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
@@ -1454,7 +1454,9 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
        sort(label_list.begin(), label_list.end());
 
        //xgettext:no-c-format
-       static char const * MenuNames[5] = { N_("Insert Page Number%m"),
+       static char const * MenuNames[6] = { N_("Insert Reference%m"),
+       //xgettext:no-c-format
+                                            N_("Insert Page Number%m"),
        //xgettext:no-c-format
                                             N_("Insert vref%m"),
        //xgettext:no-c-format
@@ -1462,21 +1464,30 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
        //xgettext:no-c-format
                                             N_("Insert Pretty Ref%m"),
        //xgettext:no-c-format
-                                            N_("Goto Reference%m%l") };
+                                            N_("Goto Reference%m") };
 
-       for (int j = 1; j <= 5; ++j) {
+       for (int j = 0; j < 6; ++j) {
                int menu2 = fl_newpup(FL_ObjWin(ob));
                menus.push_back(menu2);
                Add_to_refs_menu(label_list, 1+j*BIG_NUM, menu2, menus, ob);
-               fl_addtopup(RefsMenu, _(MenuNames[j-1]), menu2);
+               fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
        }
 
-       fl_addtopup(RefsMenu, _("Insert Reference:%d%x0"));
-       Add_to_refs_menu(label_list, 1, RefsMenu, menus, ob);
+       bool empty = label_list.empty();
+       bool sgml = buffer->isSGML();
+       bool readonly = buffer->isReadonly();
 
-       if (label_list.empty())
-               for (int j = 1; j <= 5; ++j)
-                       fl_setpup_mode(RefsMenu, j, FL_PUP_GREY);
+       if (empty)
+               fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
+       if (empty || readonly) {
+               fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
+               fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
+       }
+       if (empty || readonly || sgml) {
+               fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
+               fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
+               fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
+       }
 
        fl_setpup_position(
                men->_view->getForm()->x + ob->x,
index adccb93d9e4c8974bc1e8b54b0e616d4f3c90e0a..bd12c5fe26a25c724e235b890d26ce019b8c5aa0 100644 (file)
@@ -187,7 +187,7 @@ LyXTable & LyXTable::operator=(LyXTable const & lt)
 LyXTable * LyXTable::Clone()
 {
     LyXTable * result = new LyXTable(rows, columns);
-    int row, column;;
+    int row, column;
 
     for (row = 0; row < rows; ++row) {
         for (column = 0; column < columns; ++column) {