From 988613eac8848dc571e1c2cd8b13977faa62f599 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 26 May 2000 00:00:02 +0000 Subject: [PATCH] patch from Dekel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@772 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 8 +++++++ forms/lyx.fd | 6 +++--- src/LyXAction.C | 4 +--- src/buffer.C | 2 +- src/commandtags.h | 1 - src/lyx.C | 6 +++--- src/lyx.h | 3 +++ src/lyx_cb.C | 53 ++++++++++++++++++++++++++++++++--------------- src/menus.C | 33 +++++++++++++++++++---------- src/table.C | 2 +- 10 files changed, 78 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab830cbedc..1ca7aa470a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-05-25 Dekel Tsur + + * 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 * src/LColor.C (LColor): change a couple of grey40 to grey60 diff --git a/forms/lyx.fd b/forms/lyx.fd index db76611546..8547380f3f 100644 --- a/forms/lyx.fd +++ b/forms/lyx.fd @@ -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 diff --git a/src/LyXAction.C b/src/LyXAction.C index d0daf533f8..4fc46c8dc0 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -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 }, diff --git a/src/buffer.C b/src/buffer.C index c170b1c979..7d1be9cb89 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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; } } } diff --git a/src/commandtags.h b/src/commandtags.h index 66829c1bd4..1703b4a3c6 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -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 diff --git a/src/lyx.C b/src/lyx.C index 6af592d345..3747cc7da1 100644 --- 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); diff --git a/src/lyx.h b/src/lyx.h index 4596128164..181b09a46d 100644 --- 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; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 1b4db6807f..54210ed8ef 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -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); } diff --git a/src/menus.C b/src/menus.C index 4ca5bc8eff..dede19f841 100644 --- a/src/menus.C +++ b/src/menus.C @@ -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, diff --git a/src/table.C b/src/table.C index adccb93d9e..bd12c5fe26 100644 --- a/src/table.C +++ b/src/table.C @@ -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) { -- 2.39.5