From 38a20ba481884df3444b00b132d0be6b4e726e63 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 27 Mar 2002 10:07:57 +0000 Subject: [PATCH] A lean, clean and working start to the new, improved gnome frontend. Apparently. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3848 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gnome/ChangeLog | 30 + src/frontends/gnome/Dialogs.C | 78 +- src/frontends/gnome/FormCitation.C | 958 ------------------ src/frontends/gnome/FormCitation.h | 161 --- src/frontends/gnome/FormCopyright.C | 61 -- src/frontends/gnome/FormCopyright.h | 55 - src/frontends/gnome/FormCredits.C | 104 -- src/frontends/gnome/FormCredits.h | 55 - src/frontends/gnome/FormIndex.C | 201 ---- src/frontends/gnome/FormIndex.h | 80 -- src/frontends/gnome/FormPrint.C | 206 ---- src/frontends/gnome/FormPrint.h | 104 -- src/frontends/gnome/FormRef.C | 460 --------- src/frontends/gnome/FormRef.h | 141 --- src/frontends/gnome/FormToc.C | 266 ----- src/frontends/gnome/FormToc.h | 91 -- src/frontends/gnome/{FormERT.C => GERT.C} | 34 +- src/frontends/gnome/{FormERT.h => GERT.h} | 8 +- src/frontends/gnome/{FormError.C => GError.C} | 14 +- src/frontends/gnome/{FormError.h => GError.h} | 8 +- .../{FormTabularCreate.C => GTabularCreate.C} | 50 +- .../{FormTabularCreate.h => GTabularCreate.h} | 6 +- src/frontends/gnome/{FormUrl.C => GUrl.C} | 44 +- src/frontends/gnome/{FormUrl.h => GUrl.h} | 8 +- src/frontends/gnome/GnomeBase.C | 35 +- src/frontends/gnome/Makefile.am | 16 +- src/frontends/gnome/README | 13 +- src/frontends/gnome/gnomeBC.C | 8 +- 28 files changed, 154 insertions(+), 3141 deletions(-) delete mode 100644 src/frontends/gnome/FormCitation.C delete mode 100644 src/frontends/gnome/FormCitation.h delete mode 100644 src/frontends/gnome/FormCopyright.C delete mode 100644 src/frontends/gnome/FormCopyright.h delete mode 100644 src/frontends/gnome/FormCredits.C delete mode 100644 src/frontends/gnome/FormCredits.h delete mode 100644 src/frontends/gnome/FormIndex.C delete mode 100644 src/frontends/gnome/FormIndex.h delete mode 100644 src/frontends/gnome/FormPrint.C delete mode 100644 src/frontends/gnome/FormPrint.h delete mode 100644 src/frontends/gnome/FormRef.C delete mode 100644 src/frontends/gnome/FormRef.h delete mode 100644 src/frontends/gnome/FormToc.C delete mode 100644 src/frontends/gnome/FormToc.h rename src/frontends/gnome/{FormERT.C => GERT.C} (75%) rename src/frontends/gnome/{FormERT.h => GERT.h} (95%) rename src/frontends/gnome/{FormError.C => GError.C} (73%) rename src/frontends/gnome/{FormError.h => GError.h} (94%) rename src/frontends/gnome/{FormTabularCreate.C => GTabularCreate.C} (51%) rename src/frontends/gnome/{FormTabularCreate.h => GTabularCreate.h} (95%) rename src/frontends/gnome/{FormUrl.C => GUrl.C} (78%) rename src/frontends/gnome/{FormUrl.h => GUrl.h} (96%) diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index d2904c5f36..ccf015ccd6 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,33 @@ +2002-03-26 Michael A. Koziarski + + * Makefile.am: Moved all 4 active Form* dialogs to new Filenames. + * Dialogs.C: Fixes for the Renaming and #include cleanup + * GERT.C + * GERT.h + * GTabularCreate.C + * GTabularCreate.h + * GUrl.C + * GUrl.h + * GError.C + * GError.h: #include Fixes for the renaming. cruft tidyup + * README: Reflect new naming convention + * GnomeBase.C: cleaned up use of dialog_. Fix for bug #169, + Thanks Angus! + * FormCitation.C + * FormCitation.h + * FormCopyright.C + * FormCopyright.h + * FormCredits.C + * FormCredits.h + * FormIndex.C + * FormIndex.h + * FormPrint.C + * FormPrint.h + * FormRef.C + * FormRef.h + * FormToc.C + * FormToc.h: Removed, they're old, unused files. + 2002-03-21 Lars Gullik Bjønnes * most files: ws cleanup diff --git a/src/frontends/gnome/Dialogs.C b/src/frontends/gnome/Dialogs.C index d4ca73b192..99ed8898da 100644 --- a/src/frontends/gnome/Dialogs.C +++ b/src/frontends/gnome/Dialogs.C @@ -17,52 +17,16 @@ #include "gettext.h" #include "Dialogs.h" -#include "BufferView.h" +#include "LyXView.h" #include "gnomeBC.h" #include "Tooltips.h" -#include "ControlBibitem.h" -#include "ControlBibtex.h" -#include "ControlCharacter.h" -#include "ControlCitation.h" -#include "ControlError.h" -#include "ControlInclude.h" -#include "ControlLog.h" -#include "ControlUrl.h" -#include "ControlVCLog.h" -#include "ControlTabularCreate.h" -#include "ControlERT.h" #include "GUI.h" -#include "FormUrl.h" -#include "FormError.h" -#include "FormTabularCreate.h" -#include "FormERT.h" -/* -#include "FormBibitem.h" -#include "FormBibtex.h" -#include "FormCharacter.h" -#include "FormCitation.h" -#include "FormLog.h" -#include "FormVCLog.h" - -#include "FormDocument.h" -#include "FormExternal.h" -#include "FormGraphics.h" -#include "FormInclude.h" -#include "FormIndex.h" -#include "FormMathsPanel.h" -#include "FormParagraph.h" -#include "FormPreamble.h" -#include "FormPreferences.h" -#include "FormPrint.h" -#include "FormRef.h" -#include "FormSearch.h" -#include "FormTabular.h" -#include "FormTabul./arCreate.h" -#include "FormToc.h" -#include "FormUrl.h" -#include "FormMinipage.h" -*/ +#include "GUrl.h" +#include "GError.h" +#include "GTabularCreate.h" +#include "GERT.h" + bool Dialogs::tooltipsEnabled() { return Tooltips::enabled(); @@ -74,36 +38,6 @@ Dialogs::Dialogs(LyXView * lv) add(new GUITabularCreate(*lv, *this)); add(new GUIERT(*lv, *this)); -/* - add(new GUIBibitem(*lv, *this)); - add(new GUIBibtex(*lv, *this)); - add(new GUICharacter(*lv, *this)); - //add(new GUICitation(*lv, *this)); - add(new GUILog(*lv, *this)); - add(new GUIVCLog(*lv, *this)); - - // For now we use the gnome non MVC dialogs - add(new FormCitation(lv, this)); - - add(new FormDocument(lv, this)); - add(new FormExternal(lv, this)); - add(new FormGraphics(lv, this)); - add(new FormInclude(lv, this)); - add(new FormIndex(lv, this)); - add(new FormMathsPanel(lv, this)); - add(new FormParagraph(lv, this)); - add(new FormPreamble(lv, this)); - add(new FormPreferences(lv, this)); - add(new FormPrint(lv, this)); - add(new FormRef(lv, this)); - add(new FormSearch(lv, this)); - add(new FormTabular(lv, this)); - add(new FormTabularCreate(lv, this)); - add(new FormToc(lv, this)); - add(new FormUrl(lv, this)); - add(new FormMinipage(lv, this)); -*/ - // reduce the number of connections needed in // dialogs by a simple connection here. hideAll.connect(hideBufferDependent.slot()); diff --git a/src/frontends/gnome/FormCitation.C b/src/frontends/gnome/FormCitation.C deleted file mode 100644 index 40e4deec4f..0000000000 --- a/src/frontends/gnome/FormCitation.C +++ /dev/null @@ -1,958 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#include - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - - -#include "gettext.h" -#include "Dialogs.h" -#include "FormCitation.h" -#include "LyXView.h" -#include "buffer.h" -#include "lyxfunc.h" -#include "support/filetools.h" -#include "support/LRegex.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pixbutton.h" - -// temporary solution for LyXView -#include "mainapp.h" -extern GLyxAppWin * mainAppWin; - -using std::vector; -using std::pair; -using std::max; -using std::min; -using std::find; - -namespace { - -// configuration keys -string const LOCAL_CONFIGURE_PREFIX("FormCitation"); - -string const CONF_PANE_INFO("paneinfo"); -string const CONF_PANE_INFO_DEFAULT("=300"); - -string const CONF_COLUMN("column"); -string const CONF_COLUMN_DEFAULT("=50"); - -string const CONF_REGEXP("regexp"); -string const CONF_REGEXP_DEFAULT("=0"); - -string const CONF_SEARCH("FormCitation_search"); -string const CONF_TEXTAFTER("FormCitation_textafter"); - -} // namespace anon - - -FormCitation::FormCitation(LyXView * lv, Dialogs * d) - : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showCitation.connect(SigC::slot(this, &FormCitation::showInset)); - d->createCitation.connect(SigC::slot(this, &FormCitation::createInset)); - - cleanupWidgets(); -} - -FormCitation::~FormCitation() -{ - hide(); -} - -void FormCitation::showInset( InsetCommand * const inset ) -{ - if( dialog_!=0 || inset == 0 ) return; - - inset_ = inset; - ih_ = inset_->hideDialog.connect(SigC::slot(this, &FormCitation::hide)); - - u_ = d_->updateBufferDependent.connect(SigC::slot(this, &FormCitation::updateSlot)); - h_ = d_->hideBufferDependent.connect(SigC::slot(this, &FormCitation::hide)); - - params = inset->params(); - - if ( params.getContents().empty() ) showStageSearch(); - else showStageAction(); -} - - -void FormCitation::createInset( string const & arg ) -{ - if( dialog_!=0 ) return; - - u_ = d_->updateBufferDependent.connect(SigC::slot(this, &FormCitation::updateSlot)); - h_ = d_->hideBufferDependent.connect(SigC::slot(this, &FormCitation::hide)); - - params.setFromString( arg ); - showStageSearch(); -} - - -namespace { - -void parseBibTeX(string const & dat, - string const & findkey, - string & keyvalue) -{ - unsigned int i; - string data(dat); - - keyvalue = ""; - - for (i=0; i1) - { - tmp = data.substr(keypos, data.length()-1); - while (tmp.find('{')!=string::npos && - tmp.find('}')!=string::npos && - tmp.find('{') < tmp.find('}') && - tmp.find('{') < tmp.find(enclosing)) - { - keypos += tmp.find('{')+1; - tmp = data.substr(keypos, data.length()-1); - keypos += tmp.find('}')+1; - tmp = data.substr(keypos, data.length()-1); - } - - if (tmp.find(enclosing)==string::npos) return; - else - { - keypos += tmp.find(enclosing); - tmp = data.substr(keypos, data.length()-1); - } - - value = data.substr(1, keypos-1); - - if (keypos+1 data.find(',')) - keypos = data.find(','); - - value = data.substr(0, keypos); - - if (keypos+1set_history_id(CONF_SEARCH); - search_text_->set_max_saved(10); - search_text_->load_history(); - search_text_->set_use_arrows_always(true); - } - - if (text_after_ != 0 ) - { - text_after_->set_history_id(CONF_TEXTAFTER); - text_after_->set_max_saved(10); - text_after_->load_history(); - text_after_->set_use_arrows_always(true); - text_after_->get_entry()->set_text(params.getOptions()); - } - - if (button_regexp_ != 0) - { - string w = path + "/" + CONF_REGEXP + CONF_REGEXP_DEFAULT; - button_regexp_->set_active( (gnome_config_get_int(w.c_str()) > 0) ); - } - - if (paned_info_ != 0) - { - string w = path + "/" + CONF_PANE_INFO + CONF_PANE_INFO_DEFAULT; - paned_info_->set_position( gnome_config_get_int(w.c_str()) ); - } - - if (clist_bib_ != 0) - { - // preferences - clist_bib_->column(0).set_visiblity(false); - clist_bib_->set_selection_mode(GTK_SELECTION_BROWSE); - - // setting up sizes of columns - string w; - int sz = clist_bib_->columns().size(); - for (int i = 0; i < sz; ++i) - { - w = path + "/" + CONF_COLUMN + "_" + tostr(i) + CONF_COLUMN_DEFAULT; - clist_bib_->column(i).set_width( gnome_config_get_int(w.c_str()) ); - } - - // retrieving data - vector > blist = lv_->buffer()->getBibkeyList(); - - sz = blist.size(); - for (int i = 0; i < sz; ++i ) - { - bibkeys.push_back(blist[i].first); - bibkeysInfo.push_back(blist[i].second); - } - - blist.clear(); - - // updating list - search(); - - if (clist_bib_->rows().size() > 0) - { - clist_bib_->rows()[0].select(); - selectionToggled(0, 0, 0, true, false); - } - } - - if (clist_selected_ != 0) - { - clist_selected_->set_selection_mode(GTK_SELECTION_BROWSE); - - // populating clist_selected_ - vector r; - string tmp, keys( params.getContents() ); - keys = frontStrip( split(keys, tmp, ',') ); - while ( !tmp.empty() ) - { - r.clear(); - r.push_back(tmp); - clist_selected_->rows().push_back(r); - - keys = frontStrip( split(keys, tmp, ',') ); - } - - if (clist_selected_->rows().size() > 0) - { - clist_selected_->rows()[0].select(); - selectionToggled(0, 0, 0, true, true); - } - } - - updateButtons(); -} - - -void FormCitation::storeWidgets() -{ - string const path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX; - - if (search_text_ != 0) search_text_->save_history(); - - if (text_after_ != 0) text_after_->save_history(); - - if (button_regexp_ != 0) - { - string w = path + "/" + CONF_REGEXP; - gnome_config_set_int(w.c_str(), button_regexp_->get_active()); - } - - if (paned_info_ != 0) - { - string w = path + "/" + CONF_PANE_INFO; - gnome_config_set_int(w.c_str(), paned_info_->width() - info_->width()); - } - - if (clist_bib_ != 0) - { - string w; - int const sz = clist_bib_->columns().size(); - for (int i = 0; i < sz; ++i) - { - w = path + "/" + CONF_COLUMN + "_" + tostr(i); - gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i)); - } - } - - gnome_config_sync(); -} - - -void FormCitation::showStageAction() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Alignment * mbox = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - - string const addlabel = _("_Add new citation"); - string const editlabel = _("_Edit/remove citation(s)"); - - Gnome::PixButton * b_add = manage(new Gnome::PixButton(addlabel, GNOME_STOCK_PIXMAP_NEW)); - Gnome::PixButton * b_edit = manage(new Gnome::PixButton(editlabel, GNOME_STOCK_PIXMAP_PROPERTIES)); - - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - // set up spacing - bbox->set_spacing(4); - bbox->set_layout(GTK_BUTTONBOX_SPREAD); - - bbox->children().push_back(Element(*b_add, false, false)); - bbox->children().push_back(Element(*b_edit, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - mbox->add(*bbox); - - // accelerators - Gtk::AccelGroup * accel = Gtk::AccelGroup::create(); - - b_add->add_accelerator("clicked", *accel, b_add->get_accelkey(), 0, GTK_ACCEL_VISIBLE); - b_edit->add_accelerator("clicked", *accel, b_edit->get_accelkey(), 0, GTK_ACCEL_VISIBLE); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Citation: Select action "), false, accel); - - initWidgets(); - - // setting focus - gtk_widget_grab_focus (GTK_WIDGET(b_add->gtkobj())); - - // connecting signals - b_add->clicked.connect(slot(this, &FormCitation::moveFromActionToSearch)); - b_edit->clicked.connect(slot(this, &FormCitation::moveFromActionToEdit)); - - b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - - dialog_->destroy.connect(slot(this, &FormCitation::free)); - } -} - - -void FormCitation::moveFromActionToSearch() -{ - // stores configuration and cleans all widgets - storeWidgets(); - cleanupWidgets(); - - // moves to stage "search" - mainAppWin->remove_action(); - showStageSearch(); -} - - -void FormCitation::moveFromActionToEdit() -{ - // stores configuration and cleans all widgets - storeWidgets(); - cleanupWidgets(); - - // moves to stage "edit" - mainAppWin->remove_action(); - showStageEdit(); -} - - -void FormCitation::showStageSearch() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Box * mbox = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - Gtk::Separator * sep = manage( new Gtk::VSeparator() ); - - search_text_ = manage( new Gnome::Entry() ); - - button_regexp_ = manage( new Gtk::CheckButton(_("Use Regular Expression")) ); - - b_ok = manage( new Gtk::Button(_("Search")) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - // set up spacing - mbox->set_spacing(4); - bbox->set_spacing(4); - - // packing - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - mbox->children().push_back(Element(*search_text_, true, true)); - mbox->children().push_back(Element(*button_regexp_, false, false)); - mbox->children().push_back(Element(*sep, false, false)); - mbox->children().push_back(Element(*bbox, false, false)); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Insert Citation: Enter keyword(s) or regular expression ")); - - initWidgets(); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(search_text_->get_entry()->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(search_text_->get_entry()->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(search_text_->get_entry()->gtkobj())); - - // connecting signals - b_ok->clicked.connect(SigC::slot(this, &FormCitation::moveFromSearchToSelect)); - search_text_->get_entry()->activate.connect(SigC::slot(this, &FormCitation::moveFromSearchToSelect)); - - b_cancel->clicked.connect(SigC::slot(mainAppWin, &GLyxAppWin::remove_action)); - dialog_->destroy.connect(SigC::slot(this, &FormCitation::free)); - } -} - -void FormCitation::moveFromSearchToSelect() -{ - search_string_ = search_text_->get_entry()->get_text(); - use_regexp_ = button_regexp_->get_active(); - - // stores configuration and cleans all widgets - storeWidgets(); - cleanupWidgets(); - - // moves to stage "select" - mainAppWin->remove_action(); - showStageSelect(); -} - -void FormCitation::showStageSelect() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Box * mbox = manage( new Gtk::VBox() ); - Gtk::Box * tbox = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - Gtk::Separator * sep = manage( new Gtk::HSeparator() ); - Gtk::ScrolledWindow * sw = manage( new Gtk::ScrolledWindow() ); - - info_ = manage( new Gnome::Less() ); - paned_info_ = manage( new Gtk::HPaned() ); - text_after_ = manage( new Gnome::Entry() ); - - b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - sw->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - // constructing CList - vector colnames; - colnames.push_back("INVISIBLE"); - colnames.push_back(_("Key")); - colnames.push_back(_("Author(s)")); - colnames.push_back(_("Title")); - colnames.push_back(_("Year")); - colnames.push_back(_("Journal")); - clist_bib_ = manage( new Gtk::CList(colnames) ); - - bbox->set_layout(GTK_BUTTONBOX_END); - - // set up spacing - mbox->set_spacing(4); - bbox->set_spacing(4); - tbox->set_spacing(4); - - // packing widgets - sw->add(*clist_bib_); - paned_info_->add1(*sw); - paned_info_->add2(*info_); - - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - tbox->children().push_back(Element(*manage(new Gtk::Label(_("Text after"))), false, false)); - tbox->children().push_back(Element(*text_after_, true, true)); - tbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false)); - tbox->children().push_back(Element(*bbox, false, false)); - - mbox->children().push_back(Element(*paned_info_,true,true)); - mbox->children().push_back(Element(*sep, false, false)); - mbox->children().push_back(Element(*tbox, false, false)); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Insert Citation: Select citation "), true); - - initWidgets(); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(clist_bib_->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(clist_bib_->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj())); - - // connecting signals - b_ok->clicked.connect(SigC::slot(this, &FormCitation::applySelect)); - text_after_->get_entry()->activate.connect(SigC::slot(this, &FormCitation::applySelect)); - - b_cancel->clicked.connect(SigC::slot(mainAppWin, &GLyxAppWin::remove_action)); - - dialog_->destroy.connect(SigC::slot(this, &FormCitation::free)); - - clist_bib_->click_column.connect(SigC::slot(this, &FormCitation::sortBibList)); - clist_bib_->select_row.connect(SigC::bind(SigC::slot(this, &FormCitation::selectionToggled), - true, false)); - clist_bib_->unselect_row.connect(SigC::bind(SigC::slot(this, &FormCitation::selectionToggled), - false, false)); - } -} - -void FormCitation::showStageEdit() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Box * mbox = manage( new Gtk::VBox() ); - Gtk::Box * tbox = manage( new Gtk::HBox() ); - Gtk::Box * t2box = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - Gtk::ButtonBox * actbbox = manage( new Gtk::VButtonBox() ); - Gtk::ScrolledWindow * sw = manage( new Gtk::ScrolledWindow() ); - - vector colnames; - colnames.push_back(" "); - clist_selected_ = manage( new Gtk::CList(colnames) ); - clist_selected_->column_titles_hide(); - - text_after_ = manage( new Gnome::Entry() ); - - button_unselect_ = manage( new Gnome::PixButton( _("_Remove"), GNOME_STOCK_PIXMAP_TRASH ) ); - button_up_ = manage( new Gnome::PixButton( _("_Up"), GNOME_STOCK_PIXMAP_UP ) ); - button_down_ = manage( new Gnome::PixButton( _("_Down"), GNOME_STOCK_PIXMAP_DOWN ) ); - - b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - sw->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - bbox->set_layout(GTK_BUTTONBOX_END); - actbbox->set_layout(GTK_BUTTONBOX_START); - - // set up spacing - mbox->set_spacing(4); - bbox->set_spacing(4); - actbbox->set_spacing(4); - tbox->set_spacing(4); - t2box->set_spacing(4); - - // packing widgets - sw->add(*clist_selected_); - - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - actbbox->children().push_back(Element(*button_unselect_, false, false)); - actbbox->children().push_back(Element(*button_up_, false, false)); - actbbox->children().push_back(Element(*button_down_, false, false)); - - t2box->children().push_back(Element(*sw, true, true)); - t2box->children().push_back(Element(*actbbox, false, false)); - - tbox->children().push_back(Element(*manage(new Gtk::Label(_("Text after"))), false, false)); - tbox->children().push_back(Element(*text_after_, true, true)); - tbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false)); - tbox->children().push_back(Element(*bbox, false, false)); - - mbox->children().push_back(Element(*t2box,true,true)); - mbox->children().push_back(Element(*manage(new Gtk::HSeparator()), false, false)); - mbox->children().push_back(Element(*tbox, false, false)); - - // accelerators - Gtk::AccelGroup * accel = Gtk::AccelGroup::create(); - - button_unselect_->add_accelerator("clicked", *accel, button_unselect_->get_accelkey(), 0, GTK_ACCEL_VISIBLE); - button_up_->add_accelerator("clicked", *accel, button_up_->get_accelkey(), 0, GTK_ACCEL_VISIBLE); - button_down_->add_accelerator("clicked", *accel, button_down_->get_accelkey(), 0, GTK_ACCEL_VISIBLE); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Citation: Edit "), true, accel); - - initWidgets(); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(clist_selected_->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(clist_selected_->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj())); - - // connecting signals - b_ok->clicked.connect(SigC::slot(this, &FormCitation::applyEdit)); - text_after_->get_entry()->activate.connect(SigC::slot(this, &FormCitation::applyEdit)); - - b_cancel->clicked.connect(SigC::slot(mainAppWin, &GLyxAppWin::remove_action)); - - dialog_->destroy.connect(SigC::slot(this, &FormCitation::free)); - - button_unselect_->clicked.connect(SigC::slot(this, &FormCitation::removeCitation)); - button_up_->clicked.connect(SigC::slot(this, &FormCitation::moveCitationUp)); - button_down_->clicked.connect(SigC::slot(this, &FormCitation::moveCitationDown)); - - clist_selected_->select_row.connect(SigC::bind(SigC::slot(this, &FormCitation::selectionToggled), - true, true)); - clist_selected_->unselect_row.connect(SigC::bind(SigC::slot(this, &FormCitation::selectionToggled), - false, true)); - } -} - - -void FormCitation::addItemToBibList(int i) -{ - vector r; - string key, info; - string val; - - key = bibkeys[i]; - info = bibkeysInfo[i]; - - // don't change the order of these first two items: - // callback functions depend on the data stored in the first column (its hided) - // and in the second column (shown to user) - r.push_back( tostr(i) ); - r.push_back( key ); - - // this can be changed (configured by user?) - parseBibTeX( info, "author", val); r.push_back(val); - parseBibTeX( info, "title", val); r.push_back(val); - parseBibTeX( info, "year", val); r.push_back(val); - parseBibTeX( info, "journal", val); r.push_back(val); - - clist_bib_->rows().push_back(r); -} - - -void FormCitation::updateButtons() -{ - if (button_unselect_ != 0) // => button_up_ and button_down_ are != 0 - { - bool sens; - - sens = (clist_selected_->selection().size()>0); - button_unselect_->set_sensitive(sens); - button_up_->set_sensitive(sens && - clist_selected_->selection()[0].get_row_num()>0); - button_down_->set_sensitive(sens && - clist_selected_->selection()[0].get_row_num() < - clist_selected_->rows().size()-1); - } -} - - -void FormCitation::updateSlot(bool buffchanged) -{ - if (buffchanged) hide(); -} - - -void FormCitation::selectionToggled(gint row, - gint ,//column, - GdkEvent * ,//event, - bool selected, - bool citeselected) -{ - if (!citeselected) - { - if (selected) - { - bool keyfound = false; - string info; - - // the first column in clist_bib_ contains the index - keyfound = true; - info = bibkeysInfo[ strToInt(clist_bib_->cell(row,0).get_text()) ]; - - if (keyfound) - info_->show_string(info); - else - info_->show_string(_("--- No such key in the database ---")); - } - else - { - info_->show_string(""); - } - } - - updateButtons(); -} - -void FormCitation::removeCitation() -{ - clist_selected_->rows().remove(clist_selected_->selection()[0]); - updateButtons(); -} - -void FormCitation::moveCitationUp() -{ - int i = clist_selected_->selection()[0].get_row_num(); - clist_selected_->swap_rows( i-1, i ); - clist_selected_->row(i-1).select(); - updateButtons(); -} - -void FormCitation::moveCitationDown() -{ - int i = clist_selected_->selection()[0].get_row_num(); - clist_selected_->swap_rows( i+1, i ); - clist_selected_->row(i+1).select(); - updateButtons(); -} - -void FormCitation::hide() -{ - if (dialog_!=0) mainAppWin->remove_action(); -} - -void FormCitation::free() -{ - if (dialog_!=0) - { - // cleaning up - cleanupWidgets(); - u_.disconnect(); - h_.disconnect(); - inset_ = 0; - ih_.disconnect(); - } -} - -void FormCitation::applySelect() -{ - if( lv_->buffer()->isReadonly() ) return; - - string contents = frontStrip( strip(params.getContents()) ); - if (!contents.empty()) contents += ", "; - - int sz = clist_bib_->selection().size(); - for (int i=0; i < sz; ++i) - { - if (i > 0) contents += ", "; - contents += clist_bib_->selection()[i][1].get_text(); - } - - params.setContents( contents ); - params.setOptions( text_after_->get_entry()->get_text() ); - - if( inset_ != 0 ) - { - // Only update if contents have changed - if( params != inset_->params() ) - { - inset_->setParams( params ); - lv_->view()->updateInset( inset_, true ); - } - } - else - { - lv_->getLyXFunc()->Dispatch( LFUN_CITATION_INSERT, - params.getAsString() ); - } - - // close dialog - storeWidgets(); - hide(); -} - -void FormCitation::applyEdit() -{ - if( lv_->buffer()->isReadonly() ) return; - - string contents; - int const sz = clist_selected_->rows().size(); - for( int i = 0; i < sz; ++i ) - { - if (i > 0) contents += ", "; - contents += clist_selected_->cell(i, 0).get_text(); - } - - params.setContents( contents ); - params.setOptions( text_after_->get_entry()->get_text() ); - - if( inset_ != 0 ) - { - // Only update if contents have changed - if( params != inset_->params() ) - { - inset_->setParams( params ); - lv_->view()->updateInset( inset_, true ); - } - } - else - { - lv_->getLyXFunc()->Dispatch( LFUN_CITATION_INSERT, - params.getAsString() ); - } - - // close dialog - storeWidgets(); - hide(); -} - -void FormCitation::sortBibList(gint col) -{ - clist_bib_->set_sort_column(col); - clist_bib_->sort(); -} - -void FormCitation::search() -{ - if (use_regexp_) searchReg(); - else searchSimple(); -} - -// looking for entries which match regexp -void FormCitation::searchReg() -{ - string rexptxt(search_string_); - rexptxt = frontStrip( strip( rexptxt ) ); - - LRegex reg(rexptxt); - - // populating clist_bib_ - clist_bib_->rows().clear(); - - clist_bib_->freeze(); - - int const sz = bibkeys.size(); - bool additem; - for ( int i = 0; i < sz; ++i ) - { - string const data = bibkeys[i] + bibkeysInfo[i]; - - if (rexptxt.empty()) additem = true; - else additem = (reg.exec(data).size() > 0); - - if ( additem ) addItemToBibList(i); - } - - clist_bib_->sort(); - clist_bib_->thaw(); -} - -// looking for entries which contain all the words specified in search_text entry -void FormCitation::searchSimple() -{ - vector searchwords; - string tmp; - string stext(search_string_); - stext = frontStrip( strip( stext ) ); - stext = frontStrip( split(stext, tmp, ' ') ); - while ( !tmp.empty() ) - { - searchwords.push_back(tmp); - stext = frontStrip( split(stext, tmp, ' ') ); - } - - // populating clist_bib_ - clist_bib_->rows().clear(); - - clist_bib_->freeze(); - - int const sz = bibkeys.size(); - for (int i = 0; i < sz; ++i) { - string const data = bibkeys[i] + bibkeysInfo[i]; - - bool additem = true; - - int const szs = searchwords.size(); - for (int j = 0; additem && j < szs; ++j) - if (data.find(searchwords[j]) == string::npos) - additem = false; - - if (additem) addItemToBibList(i); - } - - clist_bib_->sort(); - clist_bib_->thaw(); -} diff --git a/src/frontends/gnome/FormCitation.h b/src/frontends/gnome/FormCitation.h deleted file mode 100644 index 15cd0212a6..0000000000 --- a/src/frontends/gnome/FormCitation.h +++ /dev/null @@ -1,161 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#ifndef FORMCITATION_H -#define FORMCITATION_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "DialogBase.h" -#include "LString.h" -#include "insets/insetcommand.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "pixbutton.h" - -/** This class provides an Gnome implementation of the FormCitation Dialog. - */ -class FormCitation : public DialogBase { -public: - /// - FormCitation(LyXView *, Dialogs *); - /// - ~FormCitation(); -private: - /// Slot launching dialog to (possibly) create a new inset - void createInset( string const & ); - /// Slot launching dialog to an existing inset - void showInset( InsetCommand * const ); - - virtual void update() { } - virtual void updateSlot(bool = false); - /// The following two methods do nothing in this implementation - virtual void apply() { } - void show() { } - - /// Explicitly free the dialog. - void free(); - /// Hide the dialog. - void hide(); - - /// Apply from dialog (modify or create inset) - void applySelect(); - /// Apply from dialog (modify or create inset) - void applyEdit(); - - /// Ask user for requested action: add new citation or edit the existing ones - void showStageAction(); - /// Ask user for regexp or keyword(s) - void showStageSearch(); - /// Ask user to select the citation in the list - void showStageSelect(); - /// Ask user to edit the citation in the list - void showStageEdit(); - - /// moves from Search to Select "stage" - void moveFromSearchToSelect(); - /// moves from Action to Search "stage" - void moveFromActionToSearch(); - /// moves from Action to Edit "stage" - void moveFromActionToEdit(); - - /// sort biblist - void sortBibList(gint); - /// update state of the buttons - void updateButtons(); - /// clist selection/unselection callback - void selectionToggled(gint row, - gint column, - GdkEvent *event, - bool selected, - bool citeselected); - - /// removes selected citation key - void removeCitation(); - /// moves citation up - void moveCitationUp(); - /// moves citation up - void moveCitationDown(); - - /// searches for entries (calls searchReg or searchSimple) - void search(); - /// searches for entries using regexp - void searchReg(); - /// searches for entries containing keyword(s) - void searchSimple(); - - /// adds item to clist_bib_ - void addItemToBibList(int i); - - /// sets all widget pointers to 0 - void cleanupWidgets(); - /// initializes all non-0 member widgets - void initWidgets(); - /// stores configuration of all non-0 member widgets - void storeWidgets(); - - /** Which LyXFunc do we use? - We could modify Dialogs to have a visible LyXFunc* instead and - save a couple of bytes per dialog. - */ - LyXView * lv_; - /** Which Dialogs do we belong to? - Used so we can get at the signals we have to connect to. - */ - Dialogs * d_; - /// pointer to the inset passed through showInset (if any) - InsetCommand * inset_; - /// the nitty-griity. What is modified and passed back - InsetCommandParams params; - /// Update connection. - SigC::Connection u_; - /// Hide connection. - SigC::Connection h_; - /// inset::hide connection. - SigC::Connection ih_; - - /// Real GUI implementation. - Gtk::Container * dialog_; - Gtk::Button * b_ok; - Gtk::Button * b_cancel; - - Gnome::Entry * search_text_; - string search_string_; - bool use_regexp_; - - Gnome::Less * info_; - Gnome::Entry * text_after_; - - Gnome::PixButton * button_unselect_; - Gnome::PixButton * button_up_; - Gnome::PixButton * button_down_; - Gtk::CheckButton * button_regexp_; - - Gtk::CList * clist_selected_; - Gtk::CList * clist_bib_; - - Gtk::Paned * paned_info_; - - std::vector bibkeys; - /// - std::vector bibkeysInfo; -}; - -#endif diff --git a/src/frontends/gnome/FormCopyright.C b/src/frontends/gnome/FormCopyright.C deleted file mode 100644 index a89e91a9cb..0000000000 --- a/src/frontends/gnome/FormCopyright.C +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of - * ================================================= - * - * LyX, The Document Processor - * Copyright 1995-2000 The LyX Team. - * - * ================================================= - * - * \author Michael Koziarski - */ - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include "debug.h" - -#include "gnomeBC.h" -#include "FormCopyright.h" -#include "gnome_helpers.h" - -#include -#include - - -FormCopyright::FormCopyright(ControlCopyright & c) - : FormCB(c, "diahelpcopyright.glade", "DiaHelpCopyright") -{ -} - - -void FormCopyright::build() -{ - ok()->clicked.connect(SigC::slot(this, &FormCopyright::CancelClicked)); - copyright()->set(controller().getCopyright()); - license()->set(controller().getLicence()); - disclaimer()->set(controller().getDisclaimer()); -} - - -Gtk::Button * FormCopyright::ok() -{ - return getWidget("copyright_button_ok"); -} - -Gtk::Label * FormCopyright::disclaimer() -{ - return getWidget("copyright_disclaimer"); -} - -Gtk::Label * FormCopyright::copyright() -{ - return getWidget("copyright_copyright"); -} - -Gtk::Label * FormCopyright::license() -{ - return getWidget("copyright_license"); -} diff --git a/src/frontends/gnome/FormCopyright.h b/src/frontends/gnome/FormCopyright.h deleted file mode 100644 index c84193033e..0000000000 --- a/src/frontends/gnome/FormCopyright.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ================================================= - * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich. - * Copyright 1995-2000 The LyX Team. - * - * ================================================= - * - * \author Michael Koziarski - * */ - -#ifndef FORMCOPYRIGHT_H -#define FORMCOPYRIGHT_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "ControlCopyright.h" -#include "GnomeBase.h" - -namespace Gtk { -class Button; -class Label; -} - -/** - * This class implements the dialog to show the copyright. - */ -class FormCopyright : public FormCB { -public: - /// - FormCopyright(ControlCopyright & c); - /// - ~FormCopyright() {}; - - void apply() {}; - void update() {}; - -private: - - /// Build the dialog - void build(); - Gtk::Button * ok(); - void CancelClicked() { CancelButton(); } - Gtk::Label * disclaimer(); - Gtk::Label * copyright(); - Gtk::Label * license(); - /// The ok button - -}; - -#endif diff --git a/src/frontends/gnome/FormCredits.C b/src/frontends/gnome/FormCredits.C deleted file mode 100644 index edc80af27d..0000000000 --- a/src/frontends/gnome/FormCredits.C +++ /dev/null @@ -1,104 +0,0 @@ -/* This file is part of - * ================================================= - * - * LyX, The Document Processor - * Copyright 1995-2000 The LyX Team. - * - * ================================================= - * - * \author Michael Koziarski - */ - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include "debug.h" - -#include "gnomeBC.h" -#include "FormCredits.h" -#include "gnome_helpers.h" - -#include -#include -#include - -FormCredits::FormCredits(ControlCredits & c) - : FormCB(c, "diahelpcredits.glade", "DiaHelpCredits") -{ -} - - -void FormCredits::build() -{ - // It is better to show an OK button, but the policy require that we - // get a click on "Cancel" - ok()->clicked.connect(SigC::slot(this, &FormCredits::CancelClicked)); - - // Do not update the dialog when we insert the text - text()->freeze(); - - // Get the credits into the string stream - stringstream ss; - string credits = controller().getCredits(ss).str(); - - // Create the strings that we need to detect. - string const bold("@b"); - string const italic("@i"); - - // Create the drawing contexts. - Gtk::Text_Helpers::Context c_italic; - Gtk::Text_Helpers::Context c_bold; - - { - string bold = get_font_name(text()->get_style()->get_font()); - //lyxerr << "Font name: " << bold << std::endl; - string italic(bold); - - string const medium("Medium-"); - std::string::size_type index = bold.find(medium); - bold.replace(index, medium.size()-1, "bold"); - - string const r("R-"); - index = italic.find(r); - italic.replace(index, r.size()-1, "i"); - - //lyxerr << "Bold: " << bold << "\nItalic: " << italic << std::endl; - c_bold.set_font(Gdk_Font(bold)); - c_italic.set_font(Gdk_Font(italic)); - } - - // Insert it into the text and parse the attributes. - while (!credits.empty()) { - std::string::size_type end = credits.find('\n'); - string const line = credits.substr(0, ++end); - credits = credits.substr(end); - -// lyxerr << "Line got: '" << line << "'\nend = " << end << std::endl; - - string const prefix = line.substr(0, 2); - if (prefix == bold) { - text()->insert(c_bold, line.substr(2)); - } else if (prefix == italic) { - text()->insert(c_italic, line.substr(2)); - } else { - text()->insert(line); - } - } - - // Allow the text area to be drawn. - text()->thaw(); -} - - -Gtk::Text * FormCredits::text() -{ - return getWidget("credits_text"); -} - -Gtk::Button * FormCredits::ok() -{ - return getWidget("credits_button_ok"); -} diff --git a/src/frontends/gnome/FormCredits.h b/src/frontends/gnome/FormCredits.h deleted file mode 100644 index 0c0400aaab..0000000000 --- a/src/frontends/gnome/FormCredits.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ================================================= - * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich. - * Copyright 1995-2000 The LyX Team. - * - * ================================================= - * - * \author Michael Koziarski - * */ - -#ifndef FORMCREDITS_H -#define FORMCREDITS_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "ControlCredits.h" -#include "GnomeBase.h" - -namespace Gtk { -class Button; -class Text; -} - -/** - * This class implements the dialog to show the credits. - */ -class FormCredits : public FormCB { -public: - /// - FormCredits(ControlCredits & c); - /// - ~FormCredits() {}; - - void apply() {}; - void update() {}; - -private: - - /// Build the dialog - void build(); - - void CancelClicked() { CancelButton(); } - - /// The ok button - Gtk::Button * ok(); - - Gtk::Text * text(); -}; - -#endif diff --git a/src/frontends/gnome/FormIndex.C b/src/frontends/gnome/FormIndex.C deleted file mode 100644 index 5392c43fbb..0000000000 --- a/src/frontends/gnome/FormIndex.C +++ /dev/null @@ -1,201 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - - -#include "gettext.h" -#include "Dialogs.h" -#include "FormIndex.h" -#include "LyXView.h" -#include "buffer.h" -#include "lyxfunc.h" -#include "form_index.h" - -#include -#include -#include -#include -#include -#include - -// temporary solution for LyXView -#include "mainapp.h" -extern GLyxAppWin * mainAppWin; - -namespace { - -// configuration keys -string const CONF_ENTRY("FormIndex_entry"); - -} // namespace anon - - -FormIndex::FormIndex(LyXView * lv, Dialogs * d) - : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showIndex.connect(slot(this, &FormIndex::showInset)); - d->createIndex.connect(slot(this, &FormIndex::createInset)); -} - - -FormIndex::~FormIndex() -{ - hide(); -} - -void FormIndex::showInset( InsetCommand * const inset ) -{ - if( dialog_!=0 || inset == 0 ) return; - - inset_ = inset; - ih_ = inset_->hideDialog.connect(slot(this, &FormIndex::hide)); - - params = inset->params(); - show(); -} - -void FormIndex::createInset( string const & arg ) -{ - if( dialog_!=0 ) return; - - params.setFromString( arg ); - show(); -} - -void FormIndex::show() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Label * label = manage( new Gtk::Label(_("Keyword")) ); - Gtk::Box * mbox = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - Gtk::Separator * sep = manage( new Gtk::VSeparator() ); - - keyword_ = manage( new Gnome::Entry() ); - - b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - // set up spacing - mbox->set_spacing(2); - bbox->set_spacing(4); - - keyword_->set_history_id(CONF_ENTRY); - keyword_->set_max_saved(10); - keyword_->load_history(); - keyword_->set_use_arrows_always(true); - - // packing - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - mbox->children().push_back(Element(*label, false, false)); - mbox->children().push_back(Element(*keyword_, true, true)); - mbox->children().push_back(Element(*sep, false, false)); - mbox->children().push_back(Element(*bbox, false, false)); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Index ")); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(keyword_->get_entry()->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(keyword_->get_entry()->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(keyword_->get_entry()->gtkobj())); - - // connecting signals - b_ok->clicked.connect(slot(this, &FormIndex::apply)); - keyword_->get_entry()->activate.connect(slot(this, &FormIndex::apply)); - - b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - - dialog_->destroy.connect(slot(this, &FormIndex::free)); - - u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::updateSlot)); - h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide)); - - updateSlot(); // make sure its up-to-date - } -} - -void FormIndex::updateSlot(bool switched) -{ - if (switched) - { - hide(); - return; - } - - if (dialog_ != 0 && - lv_->view()->available()) - { - keyword_->get_entry()->set_text(params.getContents().c_str()); - - bool sens = (!(lv_->buffer()->isReadonly())); - - keyword_->set_sensitive(sens); - b_ok->set_sensitive(sens); - } -} - -void FormIndex::hide() -{ - if (dialog_!=0) mainAppWin->remove_action(); -} - -void FormIndex::free() -{ - if (dialog_!=0) - { - dialog_ = 0; - u_.disconnect(); - h_.disconnect(); - inset_ = 0; - ih_.disconnect(); - } -} - -void FormIndex::apply() -{ - if( lv_->buffer()->isReadonly() ) return; - - params.setContents( keyword_->get_entry()->get_text() ); - - if( inset_ != 0 ) - { - // Only update if contents have changed - if( params != inset_->params() ) - { - inset_->setParams( params ); - lv_->view()->updateInset( inset_, true ); - } - } - else - { - lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT, - params.getAsString() ); - } - - // save history - keyword_->save_history(); - - // hide the dialog - hide(); -} diff --git a/src/frontends/gnome/FormIndex.h b/src/frontends/gnome/FormIndex.h deleted file mode 100644 index 9820ca40f1..0000000000 --- a/src/frontends/gnome/FormIndex.h +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#ifndef FORMINDEX_H -#define FORMINDEX_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "DialogBase.h" -#include "LString.h" -#include "insets/insetcommand.h" - -#include -#include -#include - -/** This class provides an Gnome implementation of the FormIndex Dialog. - */ -class FormIndex : public DialogBase { -public: - /// - FormIndex(LyXView *, Dialogs *); - /// - ~FormIndex(); -private: - /// Slot launching dialog to (possibly) create a new inset - void createInset( string const & ); - /// Slot launching dialog to an existing inset - void showInset( InsetCommand * const ); - - /// Update dialog before showing it - virtual void update() { } - virtual void updateSlot(bool = false); - /// Apply from dialog (modify or create inset) - virtual void apply(); - /// Explicitly free the dialog. - void free(); - /// Create the dialog if necessary, update it and display it. - void show(); - /// Hide the dialog. - void hide(); - - /** Which LyXFunc do we use? - We could modify Dialogs to have a visible LyXFunc* instead and - save a couple of bytes per dialog. - */ - LyXView * lv_; - /** Which Dialogs do we belong to? - Used so we can get at the signals we have to connect to. - */ - Dialogs * d_; - /// pointer to the inset passed through showInset (if any) - InsetCommand * inset_; - /// the nitty-griity. What is modified and passed back - InsetCommandParams params; - /// Update connection. - SigC::Connection u_; - /// Hide connection. - SigC::Connection h_; - /// inset::hide connection. - SigC::Connection ih_; - - /// Real GUI implementation. - Gtk::Container * dialog_; - Gnome::Entry * keyword_; - Gtk::Button * b_ok; - Gtk::Button * b_cancel; -}; - -#endif diff --git a/src/frontends/gnome/FormPrint.C b/src/frontends/gnome/FormPrint.C deleted file mode 100644 index e1309f0eaa..0000000000 --- a/src/frontends/gnome/FormPrint.C +++ /dev/null @@ -1,206 +0,0 @@ -/* FormPrint.C - * FormPrint Interface Class Implementation - * This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "FormPrint.h" -#include "LyXView.h" -#include "Dialogs.h" -#include "lyxrc.h" -#include "PrinterParams.h" -#include "Liason.h" -#include "debug.h" -#include "BufferView.h" -#include "lyx_gui_misc.h" -#include "gettext.h" - -extern "C" { -#include "diaprint_interface.h" -#include "support.h" -} - -#include -#include - -using Liason::printBuffer; -using Liason::getPrinterParams; - -FormPrint::FormPrint(LyXView * lv, Dialogs * d) - : dialog_(0), lv_(lv), d_(d), u_(0), h_(0) -{ - // let the dialog be shown - // This is a permanent connection so we won't bother - // storing a copy because we won't be disconnecting. - d->showPrint.connect(SigC::slot(this,&FormPrint::show)); -} - - -FormPrint::~FormPrint() -{ - hide(); -} - - -void FormPrint::show() -{ - Gtk::Button * b_ok; - Gtk::Button * b_cancel; - if (!dialog_) - { - GtkWidget * pd = create_DiaPrint(); - - dialog_ = Gtk::wrap(pd); - print_all_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_all") ) ); - print_odd_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_odd") ) ); - print_even_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "print_even") ) ); - - print_pages_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "print_pages") ) ); - - print_from_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "print_from") ) ); - print_to_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "print_to") ) ); - - order_normal_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "order_normal") ) ); - order_reverse_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "order_reverse") ) ); - - copies_unsorted_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "copies_unsorted") ) ); - copies_count_ = Gtk::wrap( GTK_SPIN_BUTTON( lookup_widget(pd, "copies_count") ) ); - - printto_printer_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "printto_printer") ) ); - printto_file_ = Gtk::wrap( GTK_RADIO_BUTTON( lookup_widget(pd, "printto_file") ) ); - - printto_printcommand_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "printto_printcommand") ) ); - printto_fileentry_ = Gtk::wrap( GNOME_FILE_ENTRY( lookup_widget(pd, "printto_fileentry") ) ); - - b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_print") ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) ); - - // setting up connections - b_ok->clicked.connect(SigC::slot(this, &FormPrint::apply)); - b_ok->clicked.connect(dialog_->destroy.slot()); - b_cancel->clicked.connect(dialog_->destroy.slot()); - dialog_->destroy.connect(SigC::slot(this, &FormPrint::free)); - - u_ = d_->updateBufferDependent.connect(SigC::slot(this, - &FormPrint::updateSlot)); - h_ = d_->hideBufferDependent.connect(dialog_->destroy.slot()); - - if (!dialog_->is_visible()) dialog_->show_all(); - - updateSlot(); // make sure its up-to-date - } - else - { - Gdk_Window dialog_win(dialog_->get_window()); - dialog_win.raise(); - } -} - -void FormPrint::hide() -{ - if (dialog_!=0) dialog_->destroy(); -} - -void FormPrint::free() -{ - if (dialog_!=0) - { - dialog_ = 0; - u_.disconnect(); - h_.disconnect(); - } -} - - -void FormPrint::apply() -{ - if (!lv_->view()->available()) return; - - PrinterParams::WhichPages wp(PrinterParams::ALL); - if (print_odd_->get_active()) wp = PrinterParams::ODD; - else if (print_even_->get_active()) wp = PrinterParams::EVEN; - - string from; - int to(0); - if (print_pages_->get_active()) - { - from = print_from_->get_text(); - to = print_to_->get_value_as_int(); - } - - PrinterParams::Target t(PrinterParams::PRINTER); - if (printto_file_->get_active()) t = PrinterParams::FILE; - - // we really should use the return value here I think. - if (!printBuffer(lv_->buffer(), - PrinterParams(t, - printto_printcommand_->get_entry()->get_text(), - printto_fileentry_->get_full_path(false), - wp, from, to, - order_reverse_->get_active(), - copies_unsorted_->get_active(), - copies_count_->get_value_as_int()))) - { - Alert::alert(_("Error:"), - _("Unable to print"), - _("Check that your parameters are correct")); - } -} - - -// we can safely ignore the parameter because we can always update -void FormPrint::updateSlot(bool) -{ - if (dialog_ != 0 && - lv_->view()->available()) - { - PrinterParams pp(getPrinterParams(lv_->buffer())); - - printto_printcommand_->get_entry()->set_text( pp.printer_name.c_str() ); - ((Gtk::Entry *)printto_fileentry_->gtk_entry())->set_text(pp.file_name.c_str()); - - if (pp.target == PrinterParams::PRINTER) printto_printer_->set_active(true); - else printto_file_->set_active(true); - - if (pp.reverse_order) order_reverse_->set_active(true); - else order_normal_->set_active(true); - - switch (pp.which_pages) - { - case PrinterParams::ODD: - print_odd_->set_active(true); - break; - - case PrinterParams::EVEN: - print_even_->set_active(true); - break; - - case PrinterParams::ALL: - default: - print_all_->set_active(true); - break; - } - - // hmmm... maybe a bit weird but maybe not - // we might just be remembering the last - // time this was printed. - if (!pp.from_page.empty()) - { - print_to_->set_value(pp.to_page); - print_from_->set_value(strToInt(pp.from_page)); - } - } -} diff --git a/src/frontends/gnome/FormPrint.h b/src/frontends/gnome/FormPrint.h deleted file mode 100644 index d5be0183de..0000000000 --- a/src/frontends/gnome/FormPrint.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== */ -/* FormPrint.h - * FormPrint Interface Class - */ - -#ifndef FORMPRINT_H -#define FORMPRINT_H - -#include "DialogBase.h" - -#include -#include -#include -#include -#include -#include - - -#ifdef __GNUG__ -#pragma interface -#endif - -class LyXView; -class Dialogs; - -/** This class provides an Gnome implementation of the FormPrint Dialog. - The print dialog allows users to print their documents. - */ -class FormPrint : public DialogBase { -public: - /**@name Constructors and Destructors */ - //@{ - /// #FormPrint x(LyXFunc ..., Dialogs ...);# - FormPrint(LyXView *, Dialogs *); - /// - ~FormPrint(); - //@} - - -private: - /**@name Slot Methods */ - //@{ - /// Create the dialog if necessary, update it and display it. - void show(); - /// Hide the dialog. - void hide(); - /// Update the dialog. - void update() { } - void updateSlot(bool = false); - /// Free memory - void free(); - //@} - - /**@name Dialog internal methods */ - //@{ - /// Apply from dialog - void apply(); - //@} - - /**@name Private Data */ - //@{ - /// Real GUI implementation. - Gtk::Widget * dialog_; - - Gtk::RadioButton * print_all_; - Gtk::RadioButton * print_odd_; - Gtk::RadioButton * print_even_; - - Gtk::CheckButton * print_pages_; - - Gtk::SpinButton * print_from_; - Gtk::SpinButton * print_to_; - - Gtk::RadioButton * order_normal_; - Gtk::RadioButton * order_reverse_; - - Gtk::CheckButton * copies_unsorted_; - Gtk::SpinButton * copies_count_; - - Gtk::RadioButton * printto_printer_; - Gtk::RadioButton * printto_file_; - - Gnome::Entry * printto_printcommand_; - Gnome::FileEntry * printto_fileentry_; - - /// Which LyXView do we belong to? - LyXView * lv_; - Dialogs * d_; - /// Update connection. - SigC::Connection u_; - /// Hide connection. - SigC::Connection h_; - //@} -}; - -#endif diff --git a/src/frontends/gnome/FormRef.C b/src/frontends/gnome/FormRef.C deleted file mode 100644 index e18476ea42..0000000000 --- a/src/frontends/gnome/FormRef.C +++ /dev/null @@ -1,460 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - - -#include "gettext.h" -#include "Dialogs.h" -#include "FormRef.h" -#include "LyXView.h" -#include "buffer.h" -#include "lyxfunc.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// temporary solution for LyXView -#include "mainapp.h" -extern GLyxAppWin * mainAppWin; - -namespace anon { - -// configuration keys -string const CONF_ENTRY_NAME("FormRef_name"); - -// goto button labels -string const GOTO_REF_LABEL(N_("Goto reference")); -string const GOTO_BACK_LABEL(N_("Go back")); - -} // namespace anon - - -FormRef::FormRef(LyXView * lv, Dialogs * d) - : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showRef.connect(slot(this, &FormRef::showInset)); - d->createRef.connect(slot(this, &FormRef::createInset)); -} - - -FormRef::~FormRef() -{ - hide(); -} - -void FormRef::showInset( InsetCommand * const inset ) -{ - if( dialog_!=0 || inset == 0 ) return; - - inset_ = inset; - ih_ = inset_->hideDialog.connect(slot(this, &FormRef::hide)); - - acttype_ = EDIT; - - params = inset->params(); - showStageAction(); -} - - -void FormRef::createInset( string const & arg ) -{ - if( dialog_!=0 ) return; - - acttype_ = INSERT; - - params.setFromString( arg ); - - refs = lv_->buffer()->getLabelList(); - - if (refs.empty()) showStageError(_("*** No labels found in document ***")); - else showStageSelect(); -} - -void FormRef::showStageError(string const & mess) -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Alignment * alig = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) ); - Gtk::Box * box = manage( new Gtk::HBox() ); - - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - box->set_spacing(4); - - box->children().push_back(Element(*manage( new Gtk::Label(mess) ), false, false)); - box->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false)); - box->children().push_back(Element(*b_cancel, false, false)); - - alig->add(*box); - - // packing dialog to main window - dialog_ = alig; - mainAppWin->add_action(*dialog_, _(" Reference ")); - - // setting focus - gtk_widget_grab_focus (GTK_WIDGET(b_cancel->gtkobj())); - - // connecting signals - b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - dialog_->destroy.connect(slot(this, &FormRef::free)); - - u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot)); - h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide)); - } -} - - -void FormRef::showStageSelect() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Box * mbox = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::VButtonBox() ); - Gtk::Alignment * alig = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) ); - Gtk::ScrolledWindow * sw = manage( new Gtk::ScrolledWindow() ); - - // constructing CList - vector colnames; - colnames.push_back("INVISIBLE"); - list_ = manage( new Gtk::CList(colnames) ); - - // populating CList - vector r; - vector::const_iterator end = refs.end(); - for (vector::const_iterator it = refs.begin(); it != end; ++it) - { - r.clear(); - r.push_back(*(it)); - list_->rows().push_back(r); - } - list_->rows()[0].select(); // there is always at least one item. otherwise we go to stateError - - b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - // policy - list_->set_selection_mode(GTK_SELECTION_BROWSE); // this ensures that we have always item selected - list_->column_titles_hide(); - - sw->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - // set up spacing - mbox->set_spacing(2); - bbox->set_spacing(4); - - // pack widgets - sw->add(*list_); - - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - alig->add( *bbox ); - - mbox->children().push_back(Element(*sw, true, true)); - mbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false)); - mbox->children().push_back(Element(*alig, false, false)); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Reference: Select reference "), true); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(list_->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(list_->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj())); - - // connecting signals - b_ok->clicked.connect(slot(this, &FormRef::moveFromSelectToAction)); - b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - - dialog_->destroy.connect(slot(this, &FormRef::free)); - - u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot)); - h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide)); - } -} - -void FormRef::moveFromSelectToAction() -{ - params.setContents( list_->selection()[0][0].get_text() ); - - // moves to stage "search" - mainAppWin->remove_action(); - showStageAction(); -} - -void FormRef::showStageAction() -{ - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Table * table = manage( new Gtk::Table(2, 2, FALSE) ); - Gtk::Box * mbox = manage( new Gtk::HBox() ); - Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); - - b_goto = manage(new Gnome::PixButton(GOTO_REF_LABEL, GNOME_STOCK_PIXMAP_JUMP_TO)); - gototype_ = GOREF; - - name_ = manage( new Gnome::Entry() ); - - choice_ = manage( new Gtk::OptionMenu() ); - - b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) ); - - // set up spacing - table->set_row_spacings(4); - table->set_col_spacings(4); - - mbox->set_spacing(4); - - bbox->set_spacing(4); - bbox->set_layout(GTK_BUTTONBOX_SPREAD); - - // configure entries - name_->set_history_id(CONF_ENTRY_NAME); - name_->set_max_saved(10); - name_->load_history(); - name_->set_use_arrows_always(true); - if( lv_->buffer()->isLatex() ) name_->set_sensitive(false); // Name is irrelevant to LaTeX documents - - // fill choice - Gtk::Menu * menu = manage( new Gtk::Menu() ); - Gtk::MenuItem * e; - - e = manage( new Gtk::MenuItem(_("Ref")) ); - e->activate.connect(bind(slot(this, &FormRef::changeType), REF)); - e->show(); - menu->append( *e ); - - e = manage( new Gtk::MenuItem(_("Page")) ); - e->activate.connect(bind(slot(this, &FormRef::changeType), PAGEREF)); - e->show(); - menu->append( *e ); - - e = manage( new Gtk::MenuItem(_("TextRef")) ); - e->activate.connect(bind(slot(this, &FormRef::changeType), VREF)); - e->show(); - menu->append( *e ); - - e = manage( new Gtk::MenuItem(_("TextPage")) ); - e->activate.connect(bind(slot(this, &FormRef::changeType), VPAGEREF)); - e->show(); - menu->append( *e ); - - e = manage( new Gtk::MenuItem(_("PrettyRef")) ); - e->activate.connect(bind(slot(this, &FormRef::changeType), PRETTYREF)); - e->show(); - menu->append( *e ); - - choice_-> set_menu ( *menu ); - - switch ( getType() ) { - case REF: { choice_-> set_history(0); break; } - case PAGEREF: { choice_-> set_history(1); break; } - case VREF: { choice_-> set_history(2); break; } - case VPAGEREF: { choice_-> set_history(3); break; } - case PRETTYREF: { choice_-> set_history(4); break; } - } - - changeType( getType() ); - - // filling widgets with data - name_->get_entry()->set_text(params.getOptions()); - - - // pack widgets - bbox->children().push_back(Element(*b_goto, false, false)); - bbox->children().push_back(Element(*b_ok, false, false)); - bbox->children().push_back(Element(*b_cancel, false, false)); - - table->attach( *manage( new Gtk::Label(_("Type:")) ), 0, 1, 0, 1, 0, 0 ); - table->attach( *manage( new Gtk::Label(_("Name:")) ), 0, 1, 1, 2, 0, 0 ); - table->attach( *choice_, 1, 2, 0, 1 ); - table->attach( *name_, 1, 2, 1, 2 ); - - mbox->children().push_back(Element(*table, true, true)); - mbox->children().push_back(Element(*manage( new Gtk::VSeparator() ), false, false )); - mbox->children().push_back(Element(*bbox, false, false)); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, string(_(" Reference: ")) + params.getContents() + string(" ")); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_goto->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj())); - gtk_widget_grab_focus (GTK_WIDGET(choice_->gtkobj())); - - // connecting signals - b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - b_ok->clicked.connect(slot(this, &FormRef::apply)); - b_goto->clicked.connect(slot(this, &FormRef::gotoRef)); - - dialog_->destroy.connect(slot(this, &FormRef::free)); - - u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot)); - h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide)); - } -} - -void FormRef::updateSlot(bool buffchanged) -{ - if (buffchanged) hide(); -} - -void FormRef::hide() -{ - if (dialog_!=0) mainAppWin->remove_action(); -} - -void FormRef::free() -{ - if (dialog_!=0) - { - dialog_ = 0; - u_.disconnect(); - h_.disconnect(); - inset_ = 0; - ih_.disconnect(); - } -} - -void FormRef::gotoRef() -{ - switch (gototype_) { - case GOREF: - { - lv_->getLyXFunc()-> Dispatch(LFUN_REF_GOTO, params.getContents()); - - gototype_ = GOBACK; - b_goto->set_text(GOTO_BACK_LABEL); - break; - } - case GOBACK: - { - lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0"); - - gototype_ = GOREF; - b_goto->set_text(GOTO_REF_LABEL); - break; - } - } -} - -void FormRef::apply() -{ - if ( lv_->buffer()->isReadonly() ) - return; - - params.setCmdName(getName(reftype_)); - params.setOptions(name_->get_entry()->get_text()); - - if (inset_ != 0) - { - // Only update if contents have changed - if (params != inset_->params()) - { - inset_->setParams(params); - lv_->view()->updateInset(inset_, true); - } - } - else - { - lv_->getLyXFunc()->Dispatch(LFUN_REF_INSERT, - params.getAsString()); - lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0"); - } - - // save configuration - name_->save_history(); - - // hide the dialog - hide(); -} - -void FormRef::changeType(Type t) -{ - reftype_ = t; -} - -FormRef::Type FormRef::getType() const -{ - Type type; - - if( params.getCmdName() == "ref" ) - type = REF; - - else if( params.getCmdName() == "pageref" ) - type = PAGEREF; - - else if( params.getCmdName() == "vref" ) - type = VREF; - - else if( params.getCmdName() == "vpageref" ) - type = VPAGEREF; - - else - type = PRETTYREF; - - return type; -} - - -string FormRef::getName( Type type ) const -{ - string name; - - switch( type ) { - case REF: - name = "ref"; - break; - case PAGEREF: - name = "pageref"; - break; - case VREF: - name = "vref"; - break; - case VPAGEREF: - name = "vpageref"; - break; - case PRETTYREF: - name = "prettyref"; - break; - } - - return name; -} diff --git a/src/frontends/gnome/FormRef.h b/src/frontends/gnome/FormRef.h deleted file mode 100644 index b0e112f8d8..0000000000 --- a/src/frontends/gnome/FormRef.h +++ /dev/null @@ -1,141 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#ifndef FORMREF_H -#define FORMREF_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "DialogBase.h" -#include "LString.h" -#include "insets/insetcommand.h" - -#include -#include -#include -#include -#include -#include -#include "pixbutton.h" - -/** This class provides an Gnome implementation of the FormRef Dialog. - */ -class FormRef : public DialogBase { -public: - /// - FormRef(LyXView *, Dialogs *); - /// - ~FormRef(); -private: - /// - enum Type{ - /// - REF, - /// - PAGEREF, - /// - VREF, - /// - VPAGEREF, - /// - PRETTYREF - }; - /// - enum Goto{ - /// - GOREF, - /// - GOBACK - }; - /// - enum ActionType { - /// - INSERT, - /// - EDIT - }; - - /// Slot launching dialog to (possibly) create a new inset - void createInset( string const & ); - /// Slot launching dialog to an existing inset - void showInset( InsetCommand * const ); - - /// Update dialog before showing it (not used in this implementation) - virtual void update() { } - virtual void updateSlot(bool = false); - /// Apply from dialog (modify or create inset) - virtual void apply(); - /// Explicitly free the dialog. - void free(); - /// dummy function - virtual void show() { } - /// Show selection of the references - void showStageSelect(); - /// Edit properties - void showStageAction(); - /// Error (no labels) - void showStageError(string const & mess); - /// Hide the dialog. - void hide(); - /// Go to reference or return back - void gotoRef(); - - /// moves from Search to Select "stage" - void moveFromSelectToAction(); - - /// changes the type of the reference - void changeType(Type); - /// - Type getType() const; - /// - string getName( Type type ) const; - - /** Which LyXFunc do we use? - We could modify Dialogs to have a visible LyXFunc* instead and - save a couple of bytes per dialog. - */ - LyXView * lv_; - /** Which Dialogs do we belong to? - Used so we can get at the signals we have to connect to. - */ - Dialogs * d_; - /// pointer to the inset passed through showInset (if any) - InsetCommand * inset_; - /// the nitty-griity. What is modified and passed back - InsetCommandParams params; - /// Update connection. - SigC::Connection u_; - /// Hide connection. - SigC::Connection h_; - /// inset::hide connection. - SigC::Connection ih_; - /// - std::vector refs; - /// - Type reftype_; - /// - Goto gototype_; - /// - ActionType acttype_; - - /// Real GUI implementation. - Gtk::Container * dialog_; - Gtk::CList * list_; - Gtk::Button * b_ok; - Gtk::Button * b_cancel; - Gnome::Entry * name_; - Gtk::OptionMenu * choice_; - Gnome::PixButton * b_goto; -}; - -#endif diff --git a/src/frontends/gnome/FormToc.C b/src/frontends/gnome/FormToc.C deleted file mode 100644 index e694a0c5e1..0000000000 --- a/src/frontends/gnome/FormToc.C +++ /dev/null @@ -1,266 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ - -#include -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - - -#include "gettext.h" -#include "Dialogs.h" -#include "FormToc.h" -#include "LyXView.h" -#include "form_toc.h" -#include "lyxtext.h" -#include "lyxfunc.h" - -extern "C" { -#include "diatoc_interface.h" -#include "support.h" -} - -#include -#include -#include -#include -#include -#include - -FormToc::FormToc(LyXView * lv, Dialogs * d) - : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0), - ignore_callback_(false) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showTOC.connect(SigC::slot(this, &FormToc::showInset)); - d->createTOC.connect(SigC::slot(this, &FormToc::createInset)); -} - - -FormToc::~FormToc() -{ - hide(); -} - -void FormToc::showInset( InsetCommand * const inset ) -{ - if ( dialog_!=0 || inset == 0 ) return; - - inset_ = inset; - ih_ = inset_->hideDialog.connect(SigC::slot(this, &FormToc::hide)); - - params = inset->params(); - show(); -} - - -void FormToc::createInset( string const & arg ) -{ - if( dialog_!=0 ) return; - - params.setFromString( arg ); - show(); -} - - -void FormToc::show() -{ - Gtk::Button * b_refresh; - Gtk::Button * b_close; - Gtk::ScrolledWindow *scrolled_window; - - if (!dialog_) - { - GtkWidget * pd = create_DiaToc(); - - dialog_ = Gtk::wrap( GNOME_DIALOG(pd) ); - choice_ = Gtk::wrap( GTK_OPTION_MENU( lookup_widget(pd, "choice") ) ); - scrolled_window = Gtk::wrap( GTK_SCROLLED_WINDOW( lookup_widget(pd, "scrolledwindow") ) ); - - list_ = manage( new Gtk::List() ); - scrolled_window->add_with_viewport(*list_); - - // fill choice - Gtk::MenuItem * e; - - choice_->get_menu()->items().clear(); - - e = manage( new Gtk::MenuItem(_("Table of Contents")) ); - e->activate.connect(SigC::bind(SigC::slot(this, &FormToc::changeList), Buffer::TOC_TOC)); - choice_->get_menu()->append( *e ); - - e = manage( new Gtk::MenuItem(_("List of Figures")) ); - e->activate.connect(SigC::bind(SigC::slot(this, &FormToc::changeList), Buffer::TOC_LOF)); - choice_->get_menu()->append( *e ); - - e = manage( new Gtk::MenuItem(_("List of Tables")) ); - e->activate.connect(SigC::bind(SigC::slot(this, &FormToc::changeList), Buffer::TOC_LOT)); - choice_->get_menu()->append( *e ); - - e = manage( new Gtk::MenuItem(_("List of Algorithms")) ); - e->activate.connect(SigC::bind(SigC::slot(this, &FormToc::changeList), Buffer::TOC_LOA)); - choice_->get_menu()->append( *e ); - - // wrap buttons and connect slots - b_refresh = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_refresh") ) ); - b_close = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_close") ) ); - - b_refresh->clicked.connect(SigC::bind(SigC::slot(this, &FormToc::updateSlot),false)); - b_close->clicked.connect(dialog_->destroy.slot()); - dialog_->destroy.connect(SigC::slot(this, &FormToc::free)); - - u_ = d_->updateBufferDependent.connect(SigC::slot(this, &FormToc::updateSlot)); - h_ = d_->hideBufferDependent.connect(SigC::slot(this, &FormToc::hide)); - - if (!dialog_->is_visible()) dialog_->show_all(); - - updateSlot(); // make sure its up-to-date - } - else - { - Gdk_Window dialog_win(dialog_->get_window()); - dialog_win.raise(); - } -} - - -// we can safely ignore the parameter because we can always update -void FormToc::updateSlot(bool) -{ - Buffer::TocType type; - string wintitle; - - if (dialog_ != 0 && - !lv_->view()->available()) - { - wintitle = _( "*** No Document ***"); - dialog_->set_title(wintitle); - list_->items().clear(); - - Gtk::ListItem * l = manage( new Gtk::ListItem(wintitle) ); - list_->items().push_back( *l ); - return; - } - - - if (dialog_ != 0 && - lv_->view()->available()) - { - - int selection = 0; - - if( params.getCmdName() == "tableofcontents" ) - { - type = Buffer::TOC_TOC; - wintitle = _("Table of Contents"); - selection = 0; - } - else if( params.getCmdName() == "listoffigures" ) - { - type = Buffer::TOC_LOF; - wintitle = _("List of Figures"); - selection = 1; - } - else if( params.getCmdName() == "listofalgorithms" ) - { - type = Buffer::TOC_LOA; - wintitle = _("List of Algorithms"); - selection = 3; - } - else - { - type = Buffer::TOC_LOT; - wintitle = _("List of Tables"); - selection = 2; - } - - ignore_callback_ = true; - choice_->set_history(selection); - ignore_callback_ = false; - - list_->items().clear(); - - dialog_->set_title(wintitle); - - vector toclist = (lv_->view()->buffer()->getTocList())[type]; - - Gtk::ListItem * item; - - vector::const_iterator end = toclist.end(); - for (vector::const_iterator it = toclist.begin(); - it != end; ++it) - { - item = manage( new Gtk::ListItem(string(4*(*it).depth,' ')+(*it).str) ); - item->select.connect(bind(slot(this,&FormToc::apply), (*it))); - list_->add( *item ); - } - } - - dialog_->show_all(); -} - -void FormToc::apply(Buffer::TocItem tg) -{ -#if 0 - // Doesn't compile anymore... - if (!lv_->view()->available()) return; - - lv_->view()->beforeChange(); - lv_->view()->text->SetCursor( lv_->view(), tg.par, 0 ); - lv_->view()->text->sel_cursor = lv_->view()->text->cursor; - lv_->view()->update(BufferView::SELECT|BufferView::FITCUR); -#endif - - string const str = tg.str; - lv_->getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, str); -} - -void FormToc::changeList(Buffer::TocType type) -{ - if (!ignore_callback_) { - switch (type) { - case Buffer::TOC_TOC : - params.setCmdName("tableofcontents"); - break; - case Buffer::TOC_LOF : - params.setCmdName("listoffigures"); - break; - case Buffer::TOC_LOT : - params.setCmdName("listoftabels"); - break; - case Buffer::TOC_LOA : - params.setCmdName("listofalgorithms"); - break; - }; - - updateSlot(); - } -} - -void FormToc::hide() -{ - if (dialog_!=0) dialog_->destroy(); -} - -void FormToc::free() -{ - if (dialog_!=0) - { - dialog_ = 0; - u_.disconnect(); - h_.disconnect(); - inset_ = 0; - ih_.disconnect(); - } -} diff --git a/src/frontends/gnome/FormToc.h b/src/frontends/gnome/FormToc.h deleted file mode 100644 index 088802af62..0000000000 --- a/src/frontends/gnome/FormToc.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- -// THIS FILE IS NOT IN USE DUE TO API CHANGES. -#include "frontends/xforms/FormToc.h" -// #if 0 -// // -*- C++ -*- -// /* This file is part of -// * ====================================================== -// * -// * LyX, The Document Processor -// * -// * Copyright 2000 The LyX Team. -// * -// * ====================================================== -// */ - -// #ifndef FORMTOC_H -// #define FORMTOC_H - -// #ifdef __GNUG__ -// #pragma interface -// #endif - -// #include "DialogBase.h" -// #include "LString.h" -// #include "insets/insetcommand.h" -// #include "buffer.h" - -// #include -// #include -// #include - -// /** This class provides an Gnome implementation of the FormToc Dialog. -// */ -// class FormToc : public DialogBase { -// public: -// /// -// FormToc(LyXView *, Dialogs *); -// /// -// ~FormToc(); -// private: -// /// Slot launching dialog to (possibly) create a new inset -// void createInset( string const & ); -// /// Slot launching dialog to an existing inset -// void showInset( InsetCommand * const ); - -// /// Update dialog before showing it -// virtual void update() { } -// virtual void updateSlot(bool = false); -// /// Explicitly free the dialog. -// void free(); -// /// Create the dialog if necessary, update it and display it. -// void show(); -// /// Hide the dialog. -// void hide(); -// /// move cursor in LyXView -// void apply(Buffer::TocItem); -// /// change type of the list -// void changeList(Buffer::TocType); - -// /** Which LyXFunc do we use? -// We could modify Dialogs to have a visible LyXFunc* instead and -// save a couple of bytes per dialog. -// */ -// LyXView * lv_; -// /** Which Dialogs do we belong to? -// Used so we can get at the signals we have to connect to. -// */ -// Dialogs * d_; -// /// pointer to the inset passed through showInset (if any) -// InsetCommand * inset_; -// /// the nitty-griity. What is modified and passed back -// InsetCommandParams params; -// /// Update connection. -// Connection u_; -// /// Hide connection. -// Connection h_; -// /// inset::hide connection. -// Connection ih_; - -// /// Real GUI implementation. -// Gnome::Dialog * dialog_; - -// Gtk::OptionMenu * choice_; - -// Gtk::List * list_; - -// bool ignore_callback_; -// }; - -#endif -#endif diff --git a/src/frontends/gnome/FormERT.C b/src/frontends/gnome/GERT.C similarity index 75% rename from src/frontends/gnome/FormERT.C rename to src/frontends/gnome/GERT.C index fe0a69d7e0..078a9df207 100644 --- a/src/frontends/gnome/FormERT.C +++ b/src/frontends/gnome/GERT.C @@ -1,10 +1,10 @@ /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Michael Koziarski */ @@ -16,7 +16,7 @@ #include #include "gnomeBC.h" -#include "FormERT.h" +#include "GERT.h" #include #include @@ -44,7 +44,7 @@ void FormERT::build() // Make sure everything is in the correct state. bc().refresh(); - + // Manage the read-only aware widgets. bc().addReadOnly(open()); bc().addReadOnly(inlined()); @@ -76,7 +76,7 @@ void FormERT::apply() controller().params().status = InsetERT::Open; else if (collapsed()->get_active()) controller().params().status = InsetERT::Collapsed; - else + else controller().params().status = InsetERT::Inlined; } @@ -106,27 +106,27 @@ bool FormERT::validate() const } -Gtk::Button * FormERT::ok_btn() const +Gtk::Button * FormERT::ok_btn() const { - return getWidget("r_ok_btn"); + return getWidget("r_ok_btn"); } -Gtk::Button * FormERT::apply_btn() const +Gtk::Button * FormERT::apply_btn() const { - return getWidget("r_apply_btn"); + return getWidget("r_apply_btn"); } -Gtk::Button * FormERT::cancel_btn() const +Gtk::Button * FormERT::cancel_btn() const { - return getWidget("r_cancel_btn"); + return getWidget("r_cancel_btn"); } -Gtk::RadioButton * FormERT::open() const +Gtk::RadioButton * FormERT::open() const { - return getWidget("r_open"); + return getWidget("r_open"); } -Gtk::RadioButton * FormERT::collapsed() const +Gtk::RadioButton * FormERT::collapsed() const { - return getWidget("r_collapsed"); + return getWidget("r_collapsed"); } -Gtk::RadioButton * FormERT::inlined() const +Gtk::RadioButton * FormERT::inlined() const { - return getWidget("r_inlined"); + return getWidget("r_inlined"); } diff --git a/src/frontends/gnome/FormERT.h b/src/frontends/gnome/GERT.h similarity index 95% rename from src/frontends/gnome/FormERT.h rename to src/frontends/gnome/GERT.h index d56c7f5dbb..a294947f04 100644 --- a/src/frontends/gnome/FormERT.h +++ b/src/frontends/gnome/GERT.h @@ -1,12 +1,12 @@ // -*- C++ -*- /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995 Matthias Ettrich. * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Michael Koziarski * */ @@ -38,7 +38,7 @@ public: void apply(); void update(); - + private: /// Build the dialog void build(); @@ -63,7 +63,7 @@ private: Gtk::RadioButton * collapsed() const; /// generated by accessors.py Gtk::RadioButton * inlined() const; - + /// do input validation SigC::Connection slot_open; diff --git a/src/frontends/gnome/FormError.C b/src/frontends/gnome/GError.C similarity index 73% rename from src/frontends/gnome/FormError.C rename to src/frontends/gnome/GError.C index 3654e5d936..784f82e48e 100644 --- a/src/frontends/gnome/FormError.C +++ b/src/frontends/gnome/GError.C @@ -1,10 +1,10 @@ /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Baruch Even */ @@ -16,7 +16,7 @@ #include #include "gnomeBC.h" -#include "FormError.h" +#include "GError.h" #include #include @@ -44,12 +44,12 @@ void FormError::update() textarea()->insert(controller().params()); } -Gtk::Button * FormError::button_close() const +Gtk::Button * FormError::button_close() const { - return getWidget("r_button_close"); + return getWidget("r_button_close"); } -Gtk::Text * FormError::textarea() const +Gtk::Text * FormError::textarea() const { - return getWidget("r_textarea"); + return getWidget("r_textarea"); } diff --git a/src/frontends/gnome/FormError.h b/src/frontends/gnome/GError.h similarity index 94% rename from src/frontends/gnome/FormError.h rename to src/frontends/gnome/GError.h index d4f10405a9..2a01a1ab54 100644 --- a/src/frontends/gnome/FormError.h +++ b/src/frontends/gnome/GError.h @@ -1,12 +1,12 @@ // -*- C++ -*- /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995 Matthias Ettrich. * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Baruch Even * */ @@ -41,7 +41,7 @@ public: void apply() {} /// void update(); - + private: /// Build the dialog void build(); @@ -51,7 +51,7 @@ private: /// void CloseClicked() { CancelButton(); } - + /// generated by accessors.py Gtk::Button * button_close() const; /// generated by accessors.py diff --git a/src/frontends/gnome/FormTabularCreate.C b/src/frontends/gnome/GTabularCreate.C similarity index 51% rename from src/frontends/gnome/FormTabularCreate.C rename to src/frontends/gnome/GTabularCreate.C index 8c2a97a3ef..035272ed18 100644 --- a/src/frontends/gnome/FormTabularCreate.C +++ b/src/frontends/gnome/GTabularCreate.C @@ -1,10 +1,10 @@ /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Michael Koziarski */ @@ -17,7 +17,7 @@ #include #include "gnomeBC.h" -#include "FormTabularCreate.h" +#include "GTabularCreate.h" #include #include @@ -28,24 +28,19 @@ FormTabularCreate::FormTabularCreate(ControlTabularCreate & c) FormTabularCreate::~FormTabularCreate() -{ - // Note that there is no need to destroy the class itself, it seems - // like everything is managed inside it. Deleting the class itself will - // a crash at the end of the program. - //dialog_->destroy(); -} +{} void FormTabularCreate::build() { // Connect the buttons. - ok_btn()->clicked.connect(SigC::slot(this, - &FormTabularCreate::OKClicked)); - cancel_btn()->clicked.connect(SigC::slot(this, - &FormTabularCreate::CancelClicked)); - apply_btn()->clicked.connect(SigC::slot(this, - &FormTabularCreate::ApplyClicked)); - + ok_btn()->clicked.connect(SigC::slot(this, + &FormTabularCreate::OKClicked)); + cancel_btn()->clicked.connect(SigC::slot(this, + &FormTabularCreate::CancelClicked)); + apply_btn()->clicked.connect(SigC::slot(this, + &FormTabularCreate::ApplyClicked)); + // Manage the buttons state bc().setOK(ok_btn()); bc().setCancel(cancel_btn()); @@ -71,28 +66,29 @@ void FormTabularCreate::update() bool FormTabularCreate::validate() const { - return ( rows()->get_value_as_int() > 0 ) && + return ( rows()->get_value_as_int() > 0 ) && ( cols()->get_value_as_int() > 0 ); } -Gtk::Button * FormTabularCreate::ok_btn() const +Gtk::Button * FormTabularCreate::ok_btn() const { - return getWidget("r_ok_btn"); + return getWidget("r_ok_btn"); } -Gtk::Button * FormTabularCreate::apply_btn() const +Gtk::Button * FormTabularCreate::apply_btn() const { - return getWidget("r_apply_btn"); + return getWidget("r_apply_btn"); } -Gtk::Button * FormTabularCreate::cancel_btn() const +Gtk::Button * FormTabularCreate::cancel_btn() const { - return getWidget("r_cancel_btn"); + return getWidget("r_cancel_btn"); } -Gtk::SpinButton * FormTabularCreate::rows() const +Gtk::SpinButton * FormTabularCreate::rows() const { - return getWidget("r_rows"); + return getWidget("r_rows"); } -Gtk::SpinButton * FormTabularCreate::cols() const +Gtk::SpinButton * FormTabularCreate::cols() const { - return getWidget("r_cols"); + return getWidget("r_cols"); } + diff --git a/src/frontends/gnome/FormTabularCreate.h b/src/frontends/gnome/GTabularCreate.h similarity index 95% rename from src/frontends/gnome/FormTabularCreate.h rename to src/frontends/gnome/GTabularCreate.h index 4142d197a4..eb2d06c033 100644 --- a/src/frontends/gnome/FormTabularCreate.h +++ b/src/frontends/gnome/GTabularCreate.h @@ -1,12 +1,12 @@ // -*- C++ -*- /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995 Matthias Ettrich. * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Michael Koziarski * */ @@ -36,7 +36,7 @@ public: ~FormTabularCreate(); void apply(); - + private: /// Build the dialog void build(); diff --git a/src/frontends/gnome/FormUrl.C b/src/frontends/gnome/GUrl.C similarity index 78% rename from src/frontends/gnome/FormUrl.C rename to src/frontends/gnome/GUrl.C index 0b128ed39b..a1b240c105 100644 --- a/src/frontends/gnome/FormUrl.C +++ b/src/frontends/gnome/GUrl.C @@ -1,10 +1,10 @@ /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Baruch Even */ @@ -16,7 +16,7 @@ #include #include "gnomeBC.h" -#include "FormUrl.h" +#include "GUrl.h" #include #include @@ -49,13 +49,13 @@ void FormUrl::build() bc().setApply(apply_btn()); bc().setRestore(restore_btn()); - // Make sure everything is in the correct state. - bc().refresh(); - // Manage the read-only aware widgets. bc().addReadOnly(html_cb()); bc().addReadOnly(name()); bc().addReadOnly(url()); + + // Make sure everything is in the correct state. + bc().refresh(); } @@ -97,7 +97,7 @@ void FormUrl::update() // This avoids the problem of having the buttons enabled when the dialog // starts. disconnect_signals(); - + url()->set_text(controller().params().getContents()); name()->set_text(controller().params().getOptions()); @@ -113,31 +113,33 @@ bool FormUrl::validate() const return !url()->get_text().empty() && !name()->get_text().empty(); } -Gtk::Button * FormUrl::restore_btn() const +Gtk::Button * FormUrl::restore_btn() const { - return getWidget("r_restore_btn"); + return getWidget("r_restore_btn"); } -Gtk::Button * FormUrl::ok_btn() const +Gtk::Button * FormUrl::ok_btn() const { - return getWidget("r_ok_btn"); + return getWidget("r_ok_btn"); } -Gtk::Button * FormUrl::apply_btn() const +Gtk::Button * FormUrl::apply_btn() const { - return getWidget("r_apply_btn"); + return getWidget("r_apply_btn"); } -Gtk::Button * FormUrl::cancel_btn() const +Gtk::Button * FormUrl::cancel_btn() const { - return getWidget("r_cancel_btn"); + return getWidget("r_cancel_btn"); } -Gtk::Entry * FormUrl::url() const +Gtk::Entry * FormUrl::url() const { - return getWidget("r_url"); + return getWidget("r_url"); } -Gtk::Entry * FormUrl::name() const +Gtk::Entry * FormUrl::name() const { - return getWidget("r_name"); + return getWidget("r_name"); } -Gtk::CheckButton * FormUrl::html_cb() const +Gtk::CheckButton * FormUrl::html_cb() const { - return getWidget("r_html_cb"); + return getWidget("r_html_cb"); } + + diff --git a/src/frontends/gnome/FormUrl.h b/src/frontends/gnome/GUrl.h similarity index 96% rename from src/frontends/gnome/FormUrl.h rename to src/frontends/gnome/GUrl.h index ffdf996ff8..3d25fc5389 100644 --- a/src/frontends/gnome/FormUrl.h +++ b/src/frontends/gnome/GUrl.h @@ -1,12 +1,12 @@ // -*- C++ -*- /* This file is part of * ================================================= - * + * * LyX, The Document Processor * Copyright 1995 Matthias Ettrich. * Copyright 1995-2000 The LyX Team. * - * ================================================= + * ================================================= * * \author Baruch Even * */ @@ -39,7 +39,7 @@ public: void apply(); void update(); - + private: /// Build the dialog void build(); @@ -66,7 +66,7 @@ private: Gtk::Entry * name() const; /// generated by accessors.py Gtk::CheckButton * html_cb() const; - + /// Keeps the connection to the input validator. SigC::Connection slot_url_; SigC::Connection slot_name_; diff --git a/src/frontends/gnome/GnomeBase.C b/src/frontends/gnome/GnomeBase.C index 8bff90e9b7..e7d00f8585 100644 --- a/src/frontends/gnome/GnomeBase.C +++ b/src/frontends/gnome/GnomeBase.C @@ -39,7 +39,7 @@ void GnomeBase::loadXML() const #ifdef WITH_WARNINGS #warning Change this before declaring it production code! (be 20010325) #endif - string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;/home/baruch/prog/lyx/graphics/src/frontends/gnome/dialogs/"); + string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;"); string const file = FileOpenSearch(path, file_, "glade"); if (file.empty()) { @@ -55,20 +55,14 @@ void GnomeBase::loadXML() const void GnomeBase::show() { - if (!dialog_) { - dialog_ = dialog(); - build(); - } - update(); - dialog_->show(); + dialog()->show(); } void GnomeBase::hide() { - if (dialog_) - dialog_->hide(); + dialog()->hide(); } bool GnomeBase::validate() @@ -78,23 +72,26 @@ bool GnomeBase::validate() void GnomeBase::OKClicked() { - lyxerr[Debug::GUI] << "OKClicked()\n"; + lyxerr[Debug::GUI] << "GnomeBase::OKClicked()\n"; OKButton(); } -void GnomeBase::CancelClicked() -{ - CancelButton(); +void GnomeBase::CancelClicked() +{ + lyxerr[Debug::GUI] << "GnomeBase::CancelClicked()\n"; + CancelButton(); } -void GnomeBase::ApplyClicked() -{ - ApplyButton(); +void GnomeBase::ApplyClicked() +{ + lyxerr[Debug::GUI] << "GnomeBase::ApplyClicked()\n"; + ApplyButton(); } -void GnomeBase::RestoreClicked() -{ - RestoreButton(); +void GnomeBase::RestoreClicked() +{ + lyxerr[Debug::GUI] << "GnomeBase::RestoreClicked()\n"; + RestoreButton(); } void GnomeBase::InputChanged() diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index 6c7a11a751..c985376f4e 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -58,14 +58,14 @@ LYXDATADIRS = libgnome_la_SOURCES = \ Dialogs.C \ FileDialog.C \ - FormError.C \ - FormError.h \ - FormTabularCreate.C \ - FormTabularCreate.h \ - FormUrl.C \ - FormUrl.h \ - FormERT.C \ - FormERT.h \ + GError.C \ + GError.h \ + GTabularCreate.C \ + GTabularCreate.h \ + GUrl.C \ + GUrl.h \ + GERT.C \ + GERT.h \ gnome_helpers.C \ gnome_helpers.h \ GnomeBase.C \ diff --git a/src/frontends/gnome/README b/src/frontends/gnome/README index d427144ca9..322cb2e8c9 100644 --- a/src/frontends/gnome/README +++ b/src/frontends/gnome/README @@ -11,7 +11,7 @@ Adding Dialogs The GNOME frontend of LyX uses libglade to draw the dialogs. The base (GnomeBase.C) class handles the drawing and activating of the Dialogs, -for an example of contructing a simple dialog see FormUrl.[Ch] +for an example of contructing a simple dialog see GUrl.[Ch] FormUrl::FormUrl(ControlUrl & c) : FormCB(c, "FormUrl") @@ -28,9 +28,8 @@ automatically generated by accessors.py For accessors.py to work glade files now must adhere to the following conventions: - * The filename should be the same as the .C and .h Files (i.e - FormTabularCreate.glade) - * The root widget should be named similarly (i.e FormTabularCreate) + * The root widget and the file should be named after the form (i.e + FormTabularCreate & FormTabularCreate.glade) * Functional widgets, those actually used rather than the filler widgets like Gtk::HBox etc, should have an r_ as the first two characters of their name. (see below) @@ -38,7 +37,7 @@ conventions: To make the build system include your new dialog edit Makefile.am as follows: 1) make clean in src/frontends/gnome/ - 2) Add FormX.C and FormX.h to libgnome_la_SOURCES + 2) Add GX.C and GX.h to libgnome_la_SOURCES 3) Remove FormX.lo and form_x.lo (if applicable) from xforms_objects 4) make clean && make in src/frontends/ 5) make in src/ @@ -51,6 +50,10 @@ Usage: python accessors.py glade_ui_file DialogClass +e.g + +python accessors.py FormTabularCreate.glade GTabularCreate + Accessors.py will write the helper functions to DialogClass.C_gen and the function declarations to DialogClass.g_gen. To ensure the widgets you're interested in are made available using this method, prefix the diff --git a/src/frontends/gnome/gnomeBC.C b/src/frontends/gnome/gnomeBC.C index 810e8a9d67..e79bb70931 100644 --- a/src/frontends/gnome/gnomeBC.C +++ b/src/frontends/gnome/gnomeBC.C @@ -29,10 +29,4 @@ void gnomeBC::setButtonEnabled(Gtk::Button * btn, bool enabled) void gnomeBC::setButtonLabel(Gtk::Button * obj, string const & label) -{ -#ifdef WITH_WARNINGS -#warning Implement me! (be 20010329) -#endif - // There is no methods set_text! - //obj->set_text(label); -} +{} -- 2.39.2