From: Jürgen Vigna Date: Tue, 19 Sep 2000 13:50:47 +0000 (+0000) Subject: Fixes to insettabular/text + GNOME patch + KDE patch X-Git-Tag: 1.6.10~21984 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=783c043a7e2cde3dac318f819894d4e312fe30c1;p=features.git Fixes to insettabular/text + GNOME patch + KDE patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1029 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 0ba6a70bb9..c9ea76ce41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,63 @@ +2000-09-18 Juergen Vigna + + * src/insets/insettext.C (LocalDispatch): fixed Backspace/Delete + problems with selection. Inserted new LFUN_PASTESELECTION. + (InsetButtonPress): inserted handling of middle mouse-button paste. + + * src/spellchecker.C: changed word to word.c_str(). + +2000-09-16 Kayvan A. Sylvan + + * src/Makefile.am: Add sources to lyx_SOURCES so they will be + included in the ``make dist'' tarball. + +2000-09-15 Juergen Vigna + + * src/CutAndPaste.C (cutSelection): small fix return the right + end position after cut inside one paragraph only. + + * src/insets/insettext.C (resizeLyXText): only reset the cursor if + we are locked as otherwise we don't have a valid cursor position! + + * src/insets/figinset.C (draw): small bugfix but why is this needed??? + +2000-09-19 Angus Leeming + + * src/frontends/kde/FormRef.C: added using directive. + * src/frontends/kde/FormToc.C: ditto + + * src/frontends/kde/formtocdialog.h: changed endl to std::endl. + + * src/frontends/kde/FormRef.h: removed trailing comma from enums. + + +2000-09-19 Marko Vendelin + + * src/frontends/gnome/Menubar_pimpl.C + * src/frontends/gnome/Menubar_pimpl.h: Gnome menus show now + Toc, ViewFormats, UpdateFormats, and ExportFormats. + + * src/frontends/gnome/mainapp.C + * src/frontends/gnome/mainapp.h: support for menu update used + by Toc menu. + + * src/frontends/gnome/mainapp.C + * src/frontends/gnome/mainapp.h: support for "action" area in the + main window. This area is used by small simple dialogs, such as + FormUrl. + + * src/frontends/gnome/FormIndex.C + * src/frontends/gnome/FormIndex.h + * src/frontends/gnome/FormUrl.C + * src/frontends/gnome/FormUrl.h: rewrite to use main window action + area + + * src/frontends/gnome/FormCitation.C + * src/frontends/gnome/FormCitation.h: rewrite to use main window + action area. Only "Insert new citation" is implemented. + + + 2000-09-19 Lars Gullik Bjønnes * src/buffer.C (Dispatch): fix call to Dispatch diff --git a/po/POTFILES.in b/po/POTFILES.in index 70efb80a26..901ef1d56b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,6 +31,8 @@ src/form1.C src/frontends/gnome/FormCitation.C src/frontends/gnome/FormPrint.C src/frontends/gnome/FormToc.C +src/frontends/kde/dlg/FormIndex.C +src/frontends/kde/dlg/formindexdialog.C src/frontends/kde/FormCitation.C src/frontends/kde/formcitationdialog.C src/frontends/kde/FormCopyright.C diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index de95af7932..c56ff81dfe 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -107,6 +107,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, #endif buf->InsertFromMinibuffer(buf->Last()); } + end = start-1; } else { // more than one paragraph (*endpar)->BreakParagraphConservative(current_view->buffer()->params, diff --git a/src/Makefile.am b/src/Makefile.am index 83ef229a09..935c13d410 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -207,6 +207,8 @@ lyx_SOURCES = \ spellchecker.C \ spellchecker.h \ stl_string_fwd.h \ + table.h \ + table.C \ tabular.C \ tabular.h \ tex-accent.C \ diff --git a/src/frontends/gnome/FormCitation.C b/src/frontends/gnome/FormCitation.C index 9127069e72..f9defca490 100644 --- a/src/frontends/gnome/FormCitation.C +++ b/src/frontends/gnome/FormCitation.C @@ -27,13 +27,19 @@ #include "support/filetools.h" #include "support/LRegex.h" -extern "C" { -#include "diainsertcitation_interface.h" -#include "support.h" -} - #include #include +#include +#include +#include +#include +#include +#include +#include + +// temporary solution for LyXView +#include "mainapp.h" +extern GLyxAppWin * mainAppWin; using std::vector; using std::pair; @@ -46,27 +52,30 @@ using SigC::slot; using SigC::bind; #endif -// gnome configuration file keys -#define LOCAL_CONFIGURE_PREFIX "FormCitation" -#define CONF_DIALOG_WIDTH "width" -#define CONF_DIALOG_WIDTH_DEFAULT "=550" +// configuration keys +static string const LOCAL_CONFIGURE_PREFIX("FormCitation"); + +static string const CONF_DIALOG_WIDTH("width"); +static string const CONF_DIALOG_WIDTH_DEFAULT("=550"); -#define CONF_DIALOG_HEIGTH "heigth" -#define CONF_DIALOG_HEIGTH_DEFAULT "=550" +static string const CONF_DIALOG_HEIGTH("heigth"); +static string const CONF_DIALOG_HEIGTH_DEFAULT("=550"); -#define CONF_PANE_INFO "paneinfo" -#define CONF_PANE_INFO_DEFAULT "=300" +static string const CONF_PANE_INFO("paneinfo"); +static string const CONF_PANE_INFO_DEFAULT("=300"); -#define CONF_PANE_KEY "panekey" -#define CONF_PANE_KEY_DEFAULT "=225" +static string const CONF_PANE_KEY("panekey"); +static string const CONF_PANE_KEY_DEFAULT("=225"); -#define CONF_COLUMN "column" -#define CONF_COLUMN_DEFAULT "=50" +static string const CONF_COLUMN("column"); +static string const CONF_COLUMN_DEFAULT("=50"); -#define CONF_REGEXP "regexp" -#define CONF_REGEXP_DEFAULT "=0" +static string const CONF_REGEXP("regexp"); +static string const CONF_REGEXP_DEFAULT("=0"); +static string const CONF_SEARCH("FormCitation_search"); +static string const CONF_TEXTAFTER("FormCitation_textafter"); FormCitation::FormCitation(LyXView * lv, Dialogs * d) : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL) @@ -90,9 +99,12 @@ void FormCitation::showInset( InsetCommand * const inset ) inset_ = inset; ih_ = inset_->hide.connect(slot(this, &FormCitation::hide)); + + u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update)); + h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide)); params = inset->params(); - show(); + //showStageEdit(); } @@ -100,10 +112,14 @@ void FormCitation::createInset( string const & arg ) { if( dialog_!=NULL ) return; + u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update)); + h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide)); + params.setFromString( arg ); - show(); + showStageSearch(); } + static void parseBibTeX(string data, string const & findkey, @@ -195,7 +211,202 @@ void parseBibTeX(string data, } } -void FormCitation::show() +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(N_("Use Regular Expression")) ); + + b_ok = manage( new Gtk::Button(N_("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); + + search_text_->set_history_id(CONF_SEARCH); + search_text_->set_max_saved(10); + search_text_->load_history(); + search_text_->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(*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_, N_(" Insert Citation: Enter keyword(s) or regular expression ")); + + // 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())); + + // restoring regexp setting + string path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX; + string w; + w = path + "/" + CONF_REGEXP + CONF_REGEXP_DEFAULT; + button_regexp_->set_active( (gnome_config_get_int(w.c_str()) > 0) ); + + // connecting signals + b_ok->clicked.connect(slot(this, &FormCitation::moveFromSearchToSelect)); + search_text_->get_entry()->activate.connect(slot(this, &FormCitation::moveFromSearchToSelect)); + + b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); + + dialog_->destroy.connect(slot(this, &FormCitation::free)); + } +} + +void FormCitation::moveFromSearchToSelect() +{ + search_string_ = search_text_->get_entry()->get_text(); + use_regexp_ = button_regexp_->get_active(); + + // saving configuration + search_text_->save_history(); + + string path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX; + string w; + w = path + "/" + CONF_REGEXP; + gnome_config_set_int(w.c_str(), button_regexp_->get_active()); + gnome_config_sync(); + + // moves to stage "select" + dialog_ = NULL; + 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) ) ); + + // setup text_after_ + text_after_->set_history_id(CONF_TEXTAFTER); + text_after_->set_max_saved(10); + text_after_->load_history(); + text_after_->set_use_arrows_always(true); + + sw->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + // constructing CList + vector colnames; + colnames.push_back("INVISIBLE"); + colnames.push_back(N_("Key")); + colnames.push_back(N_("Author(s)")); + colnames.push_back(N_("Title")); + colnames.push_back(N_("Year")); + colnames.push_back(N_("Journal")); + clist_bib_ = manage( new Gtk::CList(colnames) ); + clist_bib_->column(0).set_visiblity(false); + + 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(N_("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_, N_(" Insert Citation: Select citation "), 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(clist_bib_->gtkobj()), GTK_CAN_DEFAULT); + gtk_widget_grab_focus (GTK_WIDGET(clist_bib_->gtkobj())); + gtk_widget_grab_default (GTK_WIDGET(b_ok->gtkobj())); + + // setting sizes of the widgets + string path; + string w, h; + path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX; + + w = path + "/" + CONF_PANE_INFO + CONF_PANE_INFO_DEFAULT; + paned_info_->set_position( gnome_config_get_int(w.c_str()) ); + + int i, sz; + for (i = 0, sz = clist_bib_->columns().size(); 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()) ); + } + + // connecting signals + b_ok->clicked.connect(slot(this, &FormCitation::applySelect)); + b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); + + dialog_->destroy.connect(slot(this, &FormCitation::free)); + + clist_bib_->click_column.connect(slot(this, &FormCitation::sortBibList)); + clist_bib_->select_row.connect(bind(slot(this, &FormCitation::selection_toggled), + true, false)); + clist_bib_->unselect_row.connect(bind(slot(this, &FormCitation::selection_toggled), + false, false)); + // retrieving data + vector > blist = lv_->buffer()->getBibkeyList(); + + for ( i = 0, sz = blist.size(); i < sz; ++i ) + { + bibkeys.push_back(blist[i].first); + bibkeysInfo.push_back(blist[i].second); + } + + blist.clear(); + + // updating list + search(); + } +} + +/*void FormCitation::show() { if (!dialog_) { @@ -313,6 +524,7 @@ void FormCitation::show() dialog_win.raise(); } } +*/ void FormCitation::addItemToBibList(int i) { @@ -340,6 +552,8 @@ void FormCitation::addItemToBibList(int i) void FormCitation::update() { + return; + bibkeys.clear(); bibkeysInfo.clear(); @@ -442,7 +656,6 @@ void FormCitation::selection_toggled(gint row, { info_->show_string(""); } - updateButtons(); } void FormCitation::removeCitation() @@ -479,7 +692,7 @@ void FormCitation::newCitation() void FormCitation::hide() { - if (dialog_!=NULL) dialog_->destroy(); + if (dialog_!=NULL) mainAppWin->remove_action(); } void FormCitation::free() @@ -487,32 +700,32 @@ void FormCitation::free() if (dialog_!=NULL) { // storing configuration - string path; - string w, h; - path = PACKAGE "/" LOCAL_CONFIGURE_PREFIX; - w = path + "/" + CONF_DIALOG_WIDTH; - h = path + "/" + CONF_DIALOG_HEIGTH; +// string path; +// string w, h; +// path = PACKAGE "/" LOCAL_CONFIGURE_PREFIX; +// w = path + "/" + CONF_DIALOG_WIDTH; +// h = path + "/" + CONF_DIALOG_HEIGTH; - gnome_config_set_int(w.c_str(), dialog_->width()); - gnome_config_set_int(h.c_str(), dialog_->height()); +// gnome_config_set_int(w.c_str(), dialog_->width()); +// gnome_config_set_int(h.c_str(), dialog_->height()); - w = path + "/" + CONF_PANE_INFO; - gnome_config_set_int(w.c_str(), paned_key_->height()); +// w = path + "/" + CONF_PANE_INFO; +// gnome_config_set_int(w.c_str(), paned_key_->height()); - w = path + "/" + CONF_PANE_KEY; - gnome_config_set_int(w.c_str(), box_keys_->width()); +// w = path + "/" + CONF_PANE_KEY; +// gnome_config_set_int(w.c_str(), box_keys_->width()); - int i, sz; - for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i) - { - w = path + "/" + CONF_COLUMN + "_" + tostr(i); - gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i)); - } +// int i, sz; +// for (i = 0, sz = clist_bib_->columns().size(); i < sz; ++i) +// { +// w = path + "/" + CONF_COLUMN + "_" + tostr(i); +// gnome_config_set_int(w.c_str(), clist_bib_->get_column_width(i)); +// } - w = path + "/" + CONF_REGEXP; - gnome_config_set_int(w.c_str(), button_regexp_->get_active()); +// w = path + "/" + CONF_REGEXP; +// gnome_config_set_int(w.c_str(), button_regexp_->get_active()); - gnome_config_sync(); +// gnome_config_sync(); // cleaning up dialog_ = NULL; @@ -523,6 +736,63 @@ void FormCitation::free() } } +void FormCitation::applySelect() +{ + if( lv_->buffer()->isReadonly() ) return; + + string contents; + int i, sz; + + contents = frontStrip( strip(params.getContents()) ); + if (!contents.empty()) contents += ", "; + + sz = clist_bib_->selection().size(); + for (i=0; i < sz; ++i) + { + if (i > 0) contents += ", "; + contents += clist_bib_->selection().operator[](i).operator[](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().c_str() ); + } + + // save config + text_after_->save_history(); + + string path; + string w, h; + path = PACKAGE "/" + LOCAL_CONFIGURE_PREFIX; + + w = path + "/" + CONF_PANE_INFO; + gnome_config_set_int(w.c_str(), paned_info_->width() - info_->width()); + + for (i = 0, sz = clist_bib_->columns().size(); 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(); + + // close dialog + hide(); +} + void FormCitation::apply() { if( lv_->buffer()->isReadonly() ) return; @@ -561,14 +831,14 @@ void FormCitation::sortBibList(gint col) void FormCitation::search() { - if (button_regexp_->get_active()) searchReg(); + if (use_regexp_) searchReg(); else searchSimple(); } // looking for entries which match regexp void FormCitation::searchReg() { - string tmp, rexptxt( search_text_->get_entry()->get_text() ); + string tmp, rexptxt( search_string_ ); rexptxt = frontStrip( strip( rexptxt ) ); LRegex reg(rexptxt); @@ -592,15 +862,13 @@ void FormCitation::searchReg() clist_bib_->sort(); clist_bib_->thaw(); - // clist_bib_: done - updateButtons(); } // looking for entries which contain all the words specified in search_text entry void FormCitation::searchSimple() { vector searchwords; - string tmp, stext( search_text_->get_entry()->get_text() ); + string tmp, stext( search_string_ ); stext = frontStrip( strip( stext ) ); stext = frontStrip( split(stext, tmp, ' ') ); while( !tmp.empty() ) @@ -633,6 +901,4 @@ void FormCitation::searchSimple() clist_bib_->sort(); clist_bib_->thaw(); - // clist_bib_: done - updateButtons(); } diff --git a/src/frontends/gnome/FormCitation.h b/src/frontends/gnome/FormCitation.h index 96cd4d0773..f9234364b1 100644 --- a/src/frontends/gnome/FormCitation.h +++ b/src/frontends/gnome/FormCitation.h @@ -21,7 +21,7 @@ #include "support/utility.hpp" #include "insets/insetcommand.h" -#include +#include #include #include #include @@ -48,13 +48,21 @@ private: virtual void update(); /// Apply from dialog (modify or create inset) virtual void apply(); + /// Apply from dialog (modify or create inset) + virtual void applySelect(); /// Explicitly free the dialog. void free(); - /// Create the dialog if necessary, update it and display it. - void show(); /// Hide the dialog. void hide(); - + /// Create the dialog if necessary, update it and display it. Not used in this dialog + void show() { } + /// Ask user for regexp or keyword(s) + void showStageSearch(); + /// Ask user to select the citation in the list + void showStageSelect(); + /// moves from Search to Select "stage" + void moveFromSearchToSelect(); + /// sort biblist void sortBibList(gint); /// update state of the buttons @@ -102,20 +110,21 @@ private: Connection ih_; /// Real GUI implementation. - Gtk::Widget * dialog_; + 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::Entry * search_text_; - Gtk::Button * button_select_; Gtk::Button * button_unselect_; Gtk::Button * button_up_; Gtk::Button * button_down_; - Gtk::Button * button_search_; Gtk::CheckButton * button_regexp_; Gtk::CList * clist_selected_; diff --git a/src/frontends/gnome/FormIndex.C b/src/frontends/gnome/FormIndex.C index f99b2a5af2..a4937692e7 100644 --- a/src/frontends/gnome/FormIndex.C +++ b/src/frontends/gnome/FormIndex.C @@ -23,13 +23,6 @@ #include "buffer.h" #include "lyxfunc.h" -extern "C" { -#include "diainsertindex_interface.h" -#include "support.h" -} - -#include - #include "gettext.h" #include "Dialogs.h" #include "FormIndex.h" @@ -38,6 +31,20 @@ extern "C" { #include "form_index.h" #include "lyxfunc.h" +#include +#include +#include +#include +#include +#include + +// temporary solution for LyXView +#include "mainapp.h" +extern GLyxAppWin * mainAppWin; + +// configuration keys +static string const CONF_ENTRY("FormIndex_entry"); + FormIndex::FormIndex(LyXView * lv, Dialogs * d) : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL) { @@ -77,31 +84,58 @@ void FormIndex::show() { if (!dialog_) { - GtkWidget * pd = create_DiaInsertIndex(); + using namespace Gtk::Box_Helpers; + + Gtk::Label * label = manage( new Gtk::Label(N_("Keyword")) ); + Gtk::Box * mbox = manage( new Gtk::HBox() ); + Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() ); + Gtk::Separator * sep = manage( new Gtk::VSeparator() ); - dialog_ = Gtk::wrap(pd); - keyword_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "keyword") ) ); + 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); - b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_ok") ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) ); + // 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_, N_(" 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)); - b_ok->clicked.connect(dialog_->destroy.slot()); - b_cancel->clicked.connect(dialog_->destroy.slot()); + 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::update)); h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide)); - if (!dialog_->is_visible()) dialog_->show_all(); - update(); // make sure its up-to-date } - else - { - Gdk_Window dialog_win(dialog_->get_window()); - dialog_win.raise(); - } } void FormIndex::update() @@ -120,7 +154,7 @@ void FormIndex::update() void FormIndex::hide() { - if (dialog_!=NULL) dialog_->destroy(); + if (dialog_!=NULL) mainAppWin->remove_action(); } void FormIndex::free() @@ -155,4 +189,11 @@ void FormIndex::apply() lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT, params.getAsString().c_str() ); } + + // save history + keyword_->save_history(); + + // hide the dialog + hide(); } + diff --git a/src/frontends/gnome/FormIndex.h b/src/frontends/gnome/FormIndex.h index e246806b38..864605033f 100644 --- a/src/frontends/gnome/FormIndex.h +++ b/src/frontends/gnome/FormIndex.h @@ -21,7 +21,7 @@ #include "support/utility.hpp" #include "insets/insetcommand.h" -#include +#include #include #include @@ -71,7 +71,7 @@ private: Connection ih_; /// Real GUI implementation. - Gtk::Widget * dialog_; + Gtk::Container * dialog_; Gnome::Entry * keyword_; Gtk::Button * b_ok; Gtk::Button * b_cancel; diff --git a/src/frontends/gnome/FormUrl.C b/src/frontends/gnome/FormUrl.C index afd39f614c..eadf7ef4b9 100644 --- a/src/frontends/gnome/FormUrl.C +++ b/src/frontends/gnome/FormUrl.C @@ -23,12 +23,20 @@ #include "buffer.h" #include "lyxfunc.h" -extern "C" { -#include "diainserturl_interface.h" -#include "support.h" -} - +#include +#include +#include +#include #include +#include + +// temporary solution for LyXView +#include "mainapp.h" +extern GLyxAppWin * mainAppWin; + +// configuration keys +static string const CONF_ENTRY_URL("FormUrl_url"); +static string const CONF_ENTRY_NAME("FormUrl_name"); FormUrl::FormUrl(LyXView * lv, Dialogs * d) : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL) @@ -70,33 +78,76 @@ void FormUrl::show() { if (!dialog_) { - GtkWidget * pd = create_DiaInsertUrl(); + using namespace Gtk::Box_Helpers; + + Gtk::Label * label; + Gtk::Table * table = manage( new Gtk::Table(2, 2, FALSE) ); + Gtk::Box * mbox = manage( new Gtk::HBox() ); + Gtk::ButtonBox * bbox = manage( new Gtk::VButtonBox() ); + Gtk::Separator * sep = manage( new Gtk::VSeparator() ); - dialog_ = Gtk::wrap(pd); - url_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "url") ) ); - name_ = Gtk::wrap( GNOME_ENTRY( lookup_widget(pd, "name") ) ); - html_type_ = Gtk::wrap( GTK_CHECK_BUTTON( lookup_widget(pd, "html_type") ) ); + url_ = manage( new Gnome::Entry() ); + name_ = manage( new Gnome::Entry() ); + html_type_ = manage( new Gtk::CheckButton(N_("HTML type")) ); + + 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(2); + table->set_col_spacings(2); + mbox->set_spacing(2); + bbox->set_spacing(4); + + // configure entries + url_->set_history_id(CONF_ENTRY_URL); + url_->set_max_saved(10); + url_->load_history(); + url_->set_use_arrows_always(true); + + name_->set_history_id(CONF_ENTRY_NAME); + name_->set_max_saved(10); + name_->load_history(); + name_->set_use_arrows_always(true); + + // pack widgets + bbox->children().push_back(Element(*b_ok, false, false)); + bbox->children().push_back(Element(*b_cancel, false, false)); + + label = manage( new Gtk::Label(N_("URL")) ); + table->attach( *label, 0, 1, 0, 1, 0, 0 ); + label = manage( new Gtk::Label(N_("Name")) ); + table->attach( *label, 0, 1, 1, 2, 0, 0 ); + table->attach( *url_, 1, 2, 0, 1 ); + table->attach( *name_, 1, 2, 1, 2 ); + + mbox->children().push_back(Element(*table)); + mbox->children().push_back(Element(*html_type_, false, false)); + mbox->children().push_back(Element(*sep, false, false)); + mbox->children().push_back(Element(*bbox, false, false)); - b_ok = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_ok") ) ); - b_cancel = Gtk::wrap( GTK_BUTTON( lookup_widget(pd, "button_cancel") ) ); + // packing dialog to main window + dialog_ = mbox; + mainAppWin->add_action(*dialog_, N_(" URL ")); + // setting focus + GTK_WIDGET_SET_FLAGS (GTK_WIDGET(url_->get_entry()->gtkobj()), GTK_CAN_DEFAULT); + gtk_widget_grab_focus (GTK_WIDGET(url_->get_entry()->gtkobj())); + gtk_widget_grab_default (GTK_WIDGET(url_->get_entry()->gtkobj())); + + // connecting signals b_ok->clicked.connect(slot(this, &FormUrl::apply)); - b_ok->clicked.connect(dialog_->destroy.slot()); - b_cancel->clicked.connect(dialog_->destroy.slot()); + name_->get_entry()->activate.connect(slot(this, &FormUrl::apply)); + + b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); + dialog_->destroy.connect(slot(this, &FormUrl::free)); u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::update)); h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide)); - if (!dialog_->is_visible()) dialog_->show_all(); - update(); // make sure its up-to-date } - else - { - Gdk_Window dialog_win(dialog_->get_window()); - dialog_win.raise(); - } } void FormUrl::update() @@ -120,7 +171,7 @@ void FormUrl::update() void FormUrl::hide() { - if (dialog_!=NULL) dialog_->destroy(); + if (dialog_!=NULL) mainAppWin->remove_action(); } void FormUrl::free() @@ -160,4 +211,11 @@ void FormUrl::apply() lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL, params.getAsString().c_str() ); } + + // save history + url_->save_history(); + name_->save_history(); + + // hide the dialog + hide(); } diff --git a/src/frontends/gnome/FormUrl.h b/src/frontends/gnome/FormUrl.h index 4f0729d0c4..572a8dd816 100644 --- a/src/frontends/gnome/FormUrl.h +++ b/src/frontends/gnome/FormUrl.h @@ -21,7 +21,7 @@ #include "support/utility.hpp" #include "insets/insetcommand.h" -#include +#include #include #include #include @@ -76,7 +76,7 @@ private: Connection ih_; /// Real GUI implementation. - Gtk::Widget * dialog_; + Gtk::Container * dialog_; Gtk::CheckButton * html_type_; diff --git a/src/frontends/gnome/Menubar_pimpl.C b/src/frontends/gnome/Menubar_pimpl.C index 9c12a0bc7d..ef20ded2bb 100644 --- a/src/frontends/gnome/Menubar_pimpl.C +++ b/src/frontends/gnome/Menubar_pimpl.C @@ -29,9 +29,13 @@ #include "LyXView.h" #include "MenuBackend.h" #include "Menubar_pimpl.h" +#include "lyxtext.h" +#include "exporter.h" #include "mainapp.h" +#include + using SigC::slot; using SigC::bind; @@ -51,12 +55,12 @@ extern LastFiles * lastfiles; Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) : owner_(view), menubackend_(&mb), ignore_action_(false) { - // Should we do something here? + } Menubar::Pimpl::~Pimpl() { - // Should we do something here? + if (utoc_.connected()) utoc_.disconnect(); } void Menubar::Pimpl::set(string const & menu_name) @@ -64,9 +68,14 @@ void Menubar::Pimpl::set(string const & menu_name) // if (current_menu_name_ != menu_name) // disabled until Lastfiles and Documents are added dynamically to menu { current_menu_name_ = menu_name; + + // clean up the lists + toc_.clear(); + if (utoc_.connected()) utoc_.disconnect(); + // compose new menu vector menus; - composeUIInfo(current_menu_name_, menus); + composeUIInfo(current_menu_name_, menus, ""); // set menu Menu_ = menus; @@ -80,6 +89,48 @@ void Menubar::Pimpl::set(string const & menu_name) // update state of the items update(); + updateAllLists(); + } +} + +void Menubar::Pimpl::updateAllLists() +{ + // update lists + if (toc_.size() > 0) + { + vector toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC]; + updateList(&toclist, &toc_); + } +} + +void Menubar::Pimpl::updateList(vector * toclist, vector * pgui) +{ + vector & gui = *pgui; + int szGui = gui.size(); + int i; + for (i=0; i < szGui; ++i) + { + int oldsz = gui[i].lst.size(); + vector menu; + string label; + + menu.push_back(Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_REFRESH), + N_("Refresh"), slot(this, &Menubar::Pimpl::updateAllLists))); + + vector::const_iterator end = toclist->end(); + for (vector::const_iterator it = toclist->begin(); + it != end; ++it) + + { + label = string(4*(*it).depth,' ')+(*it).str; + + menu.push_back(Gnome::UI::Item(label, + bind(slot(this, &Menubar::Pimpl::callbackToc), (*it)), + label)); + } + + gui[i].lst = menu; + mainAppWin->update_menu(gui[i].path, oldsz, gui[i].lst); } } @@ -93,8 +144,20 @@ void Menubar::Pimpl::callback(int action) action_ = action; } -void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector & Menus) +void Menubar::Pimpl::callbackToc(Buffer::TocItem tg) { + if (!owner_->view()->available()) return; + + owner_->view()->beforeChange(); + owner_->view()->text->SetCursor( owner_->view(), tg.par, 0 ); + owner_->view()->text->sel_cursor = owner_->view()->text->cursor; + owner_->view()->update(BufferView::SELECT|BufferView::FITCUR); +} + +void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector & Menus, string rootpath) +{ + string path = rootpath; + if (!menubackend_->hasMenu(menu_name)) { cout << "ERROR:composeUIInfo: Unknown menu `" << menu_name @@ -111,6 +174,9 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector submenu; string label = item.label(); + + path = rootpath + label; + if (label.find(item.shortcut()) != string::npos) label.insert(label.find(item.shortcut()), "_"); - composeUIInfo(item.submenu(), submenu); + composeUIInfo(item.submenu(), submenu, path + "/"); Menus.push_back(Gnome::UI::Menu(label,submenu,label)); break; } case MenuItem::Separator: { + + path = rootpath + ""; + Menus.push_back(Gnome::UI::Separator()); break; } @@ -222,8 +294,11 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vectorend() && ii < 10; ++cit, ++ii) { int action = lyxaction.getPseudoAction(LFUN_FILE_OPEN, (*cit)); - string label = "_" + tostr(ii) + ". " + MakeDisplayPath((*cit),30); + string label = tostr(ii) + ". " + MakeDisplayPath((*cit),30); + path = rootpath + label; + label = "_" + label; + Menus.push_back(Gnome::UI::Item(label, bind(slot(this, &Menubar::Pimpl::callback), action), label)); @@ -240,6 +315,8 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector(slot(this, &Menubar::Pimpl::callback), action), label)); @@ -247,16 +324,57 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector & Menus, kb_action action, bool viewable) +{ + vector > names = + viewable + ? Exporter::GetViewableFormats(owner_->buffer()) + : Exporter::GetExportableFormats(owner_->buffer()); + + for (vector >::const_iterator cit = names.begin(); + cit != names.end() ; ++cit) { + int action2 = lyxaction.getPseudoAction(action, (*cit).first); + string label = (*cit).second; + + Menus.push_back(Gnome::UI::Item(label, + bind(slot(this, &Menubar::Pimpl::callback), action2), + label)); + } +} + void Menubar::Pimpl::connectWidgetToAction(GnomeUIInfo * guinfo) { for (; guinfo->type != GnomeUIInfoType(GNOME_APP_UI_ENDOFINFO); ++guinfo) { - if ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) || - guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) ) + if ( ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) || + guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) ) && + guinfo->moreinfo != NULL ) { (*((void(*)(void *, void *))(guinfo->moreinfo)))(NULL, guinfo->user_data); wid_act_.push_back( GtkWidgetToAction( guinfo->widget, action_ ) ); diff --git a/src/frontends/gnome/Menubar_pimpl.h b/src/frontends/gnome/Menubar_pimpl.h index 14f4512b73..fdcdb665f5 100644 --- a/src/frontends/gnome/Menubar_pimpl.h +++ b/src/frontends/gnome/Menubar_pimpl.h @@ -19,12 +19,18 @@ #include "LString.h" #include #include "frontends/Menubar.h" +#include "commandtags.h" +#include "buffer.h" class LyXView; class MenuBackend; class MenuItem; class StrPool; +#ifdef SIGC_CXX_NAMESPACES +using SigC::Connection; +#endif + #include "debug.h" /* @@ -55,14 +61,31 @@ public: void openByName(string const &); /// update the state of menuitems void update(); + /// update TOC, LOF, ... on user' request + void updateAllLists(); protected: /// callback function void callback(int action); + /// callback function used by lists + void callbackToc(Buffer::TocItem tg); /// compose Gnome::UI::Array object describing the menu - void composeUIInfo(string const & menu_name, vector & Menus); + void composeUIInfo(string const & menu_name, vector & Menus, string path); /// populate wid_act_ vector with all widgets and corresponding actions void connectWidgetToAction(GnomeUIInfo * guinfo); + + /// lists (toc, lof, lot, loa) + struct ListsHolder { + string path; + Gnome::UI::Array lst; + + ListsHolder () { } + ListsHolder (const ListsHolder & a) { path = a.path; lst = a.lst; } + }; + /// populate lists + void updateList(vector *, vector *); + /// Add to "Menus" the list of exportable/viewable formats + void add_formats(vector & Menus, kb_action action, bool viewable); private: /// @@ -77,5 +100,9 @@ private: bool ignore_action_; int action_; vector wid_act_; + + /// toc + Connection utoc_; + vector toc_; }; #endif diff --git a/src/frontends/gnome/mainapp.C b/src/frontends/gnome/mainapp.C index 3273460607..7dd176e5ed 100644 --- a/src/frontends/gnome/mainapp.C +++ b/src/frontends/gnome/mainapp.C @@ -9,8 +9,14 @@ * ====================================================== */ #include + #include #include +#include +#include +#include +#include + #include #include @@ -21,7 +27,8 @@ using SigC::slot; GLyxAppWin::GLyxAppWin() : Gnome::App(PACKAGE,"LyX Gnomified"), - status_(false, true, GNOME_PREFERENCES_NEVER) + status_(false, true, GNOME_PREFERENCES_NEVER), + action_mode(false) { init(); show_all(); @@ -38,10 +45,6 @@ void GLyxAppWin::init() set_default_size(250, 350); set_wmclass(PACKAGE, "GnomeLyX"); - frame_.set_shadow_type(GTK_SHADOW_IN); - - set_contents(frame_); - set_statusbar(status_); // initial (dummy) menu @@ -54,6 +57,31 @@ void GLyxAppWin::init() menu.gtkobj()); menusize_ = menu.size(); + + // packing widgets + + // temporary main widget + Gtk::HBox * h = manage( new Gtk::HBox() ); + Gnome::Pixmap * p; + p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_ABOUT) ) ); + + h->children().push_back( Gtk::Box_Helpers::Element( *p ) ); + h->children().push_back( *(manage(new Gtk::Label("Waiting for LyXView port"))) ); + + view_ = h; + // temporary main widget: done + + // packing main widget and separator + Gtk::Separator * sep = manage( new Gtk::HSeparator() ); + + box_.children().push_back( Gtk::Box_Helpers::Element(*view_) ); + box_.children().push_back( Gtk::Box_Helpers::Element(*sep, false) ); + + box_.show_all(); + + set_contents(box_); + + key_press_event.connect(slot(this, &GLyxAppWin::key_pressed)); } @@ -66,4 +94,50 @@ void GLyxAppWin::set_menu(Gnome::UI::Array &menu) menusize_ = menu.size(); } +void GLyxAppWin::update_menu(string path, int noelms, Gnome::UI::Array &menu) +{ + // remove "noelms" items and install new items from "menu" + gnome_app_remove_menus(this->gtkobj(),path.c_str(),noelms); + gnome_app_insert_menus(this->gtkobj(),path.c_str(),menu.gtkobj()); + gnome_app_install_menu_hints(this->gtkobj(),menu.gtkobj()); +} + +// clean up first, then add new action widget and finally, disable main view +void GLyxAppWin::add_action(Gtk::Container &action, string title, bool expand) +{ + remove_action(); + + Gtk::Frame * frame = manage( new Gtk::Frame(title) ); + frame->set_border_width(2); + action.set_border_width(2); + frame->add(action); + + box_.children().push_back( Gtk::Box_Helpers::Element( *frame, expand ) ); + box_.show_all(); + + view_->set_sensitive(false); + action_mode = true; +} + +void GLyxAppWin::remove_action() +{ + while ( box_.children().size() > 2 ) + { + box_.children().pop_back(); + } + + view_->set_sensitive(true); + action_mode = false; +} + +gint GLyxAppWin::key_pressed(GdkEventKey * e) +{ + if (action_mode && + e->keyval == GDK_Escape) + { + remove_action(); + return TRUE; + } + return FALSE; +} diff --git a/src/frontends/gnome/mainapp.h b/src/frontends/gnome/mainapp.h index 5e6716f6f3..b0d740071d 100644 --- a/src/frontends/gnome/mainapp.h +++ b/src/frontends/gnome/mainapp.h @@ -30,6 +30,16 @@ class GLyxAppWin: public Gnome::App /// set menu of the window void set_menu(Gnome::UI::Array &); + /// update menu + void update_menu(string path, + int noelms, + Gnome::UI::Array &); + /// add action area + void add_action(Gtk::Container &, string title, bool expand=false); + /// remove action area + void remove_action(); + /// clears action area if Escape is pressed + gint key_pressed(GdkEventKey * e); protected: /// init window widgets @@ -38,8 +48,11 @@ class GLyxAppWin: public Gnome::App protected: // widgets Gnome::AppBar status_; - Gtk::Frame frame_; + Gtk::VBox box_; + Gtk::Widget *view_; + bool action_mode; + // menu size int menusize_; }; diff --git a/src/frontends/kde/FormRef.C b/src/frontends/kde/FormRef.C index 0b49bec036..ab77dad676 100644 --- a/src/frontends/kde/FormRef.C +++ b/src/frontends/kde/FormRef.C @@ -24,6 +24,8 @@ #include "formrefdialog.h" #include "debug.h" +using std::endl; + FormRef::FormRef(LyXView *v, Dialogs *d) : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), sort(0), gotowhere(GOTOREF), type(REF), refs(0) diff --git a/src/frontends/kde/FormRef.h b/src/frontends/kde/FormRef.h index e3049b27c8..f75fdf1e74 100644 --- a/src/frontends/kde/FormRef.h +++ b/src/frontends/kde/FormRef.h @@ -53,11 +53,11 @@ public: private: enum Type { - REF, PAGEREF, VREF, VPAGEREF, PRETTYREF, + REF, PAGEREF, VREF, VPAGEREF, PRETTYREF }; enum GotoType { - GOTOREF, GOTOBACK, + GOTOREF, GOTOBACK }; /// Create the dialog if necessary, update it and display it. diff --git a/src/frontends/kde/FormToc.C b/src/frontends/kde/FormToc.C index 3b89858ccc..bba790ea11 100644 --- a/src/frontends/kde/FormToc.C +++ b/src/frontends/kde/FormToc.C @@ -31,7 +31,8 @@ using std::vector; using std::pair; using std::stack; - +using std::endl; + FormToc::FormToc(LyXView *v, Dialogs *d) : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), toclist(0), type(Buffer::TOC_TOC), depth(1) diff --git a/src/frontends/kde/formtocdialog.h b/src/frontends/kde/formtocdialog.h index 68f6799538..5ce697ad21 100644 --- a/src/frontends/kde/formtocdialog.h +++ b/src/frontends/kde/formtocdialog.h @@ -90,7 +90,7 @@ private slots: form_->set_type(Buffer::TOC_LOA); break; default: - lyxerr[Debug::GUI] << "Unknown TOC combo selection." << endl; + lyxerr[Debug::GUI] << "Unknown TOC combo selection." << std::endl; break; } } diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 5511d850b2..b059aea40f 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -336,7 +336,7 @@ bool FormDocument::class_apply() params.pagestyle = fl_get_choice_text(class_->choice_doc_pagestyle); #ifdef USE_CLASS_COMBO - unsigned int new_class = combo_doc_class->get(); + unsigned int new_class = combo_doc_class->get() - 1; #else unsigned int new_class = fl_get_choice(class_->choice_doc_class) - 1; #endif @@ -369,7 +369,7 @@ bool FormDocument::class_apply() _("Errors loading new document class."), _("Reverting to original document class.")); #ifdef USE_CLASS_COMBO - combo_doc_class->select(params.textclass); + combo_doc_class->select(params.textclass + 1); #else fl_set_choice(class_->choice_doc_class, params.textclass + 1); @@ -1168,7 +1168,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) string tct; #ifdef USE_CLASS_COMBO - tc = combo_doc_class->get(); + tc = combo_doc_class->get() - 1; tct = combo_doc_class->getline(); #else tc = fl_get_choice(ob) - 1; @@ -1189,7 +1189,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) _("Unable to switch to new document class."), _("Reverting to original document class.")); #ifdef USE_CLASS_COMBO - combo_doc_class->select(lv_->buffer()->params.textclass); + combo_doc_class->select(lv_->buffer()->params.textclass + 1); #else fl_set_choice(class_->choice_doc_class, lv_->buffer()->params.textclass + 1); diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 37c8c72e40..9ece103b1a 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -1010,7 +1010,7 @@ void InsetFig::draw(BufferView * bv, LyXFont const & f, } else { char * msg = 0; string lfname = fname; - if (GetExtension(fname).empty()) + if (!fname.empty() && GetExtension(fname).empty()) lfname += ".eps"; // draw frame pain.rectangle(int(x), baseline - hgh - 1, wid + 1, hgh + 1); diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 8b07c7885f..eaa053afae 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -38,6 +38,12 @@ const int ADD_TO_HEIGHT = 2; const int ADD_TO_TABULAR_WIDTH = 2; +/// +static LyXTabular * paste_tabular = 0; +bool InsetTabular::hasPasteBuffer() const +{ + return (paste_tabular != 0); +} using std::ostream; using std::ifstream; @@ -128,7 +134,6 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) cursor.pos(0); sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0; dialogs_ = 0; - paste_tabular = 0; need_update = INIT; } @@ -145,7 +150,6 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf) cursor.pos(0); sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0; dialogs_ = 0; - paste_tabular = 0; need_update = INIT; } @@ -590,8 +594,9 @@ void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button) } the_locking_inset = 0; if (inset_hit && bv->the_locking_inset) { - ActivateCellInset(bv, x, y, button); - the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button); + if (ActivateCellInset(bv, x, y, button)) + the_locking_inset->InsetButtonPress(bv, x-inset_x, + y-inset_y, button); return; } ShowInsetCursor(bv); @@ -1532,7 +1537,7 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button, if (!the_locking_inset) return false; UpdateLocal(bv, CELL, false); - return true; + return (the_locking_inset != 0); } @@ -1913,8 +1918,36 @@ bool InsetTabular::cutSelection() { if (!hasSelection()) return false; - for(int i=sel_cell_start; i < sel_cell_end; ++i) { - tabular->GetCellInset(i)->clear(); + + int sel_col_start, sel_col_end; + int sel_row_start, sel_row_end; + + sel_col_start = tabular->column_of_cell(sel_cell_start); + sel_col_end = tabular->column_of_cell(sel_cell_end); + if (sel_col_start > sel_col_end) { + sel_col_start = sel_col_end; + sel_col_end = tabular->right_column_of_cell(sel_cell_start); + } else { + sel_col_end = tabular->right_column_of_cell(sel_cell_end); + } + sel_row_start = tabular->row_of_cell(sel_cell_start); + sel_row_end = tabular->row_of_cell(sel_cell_end); + if (sel_row_start > sel_row_end) { + int tmp; + tmp = sel_row_start; + sel_row_start = sel_row_end; + sel_row_end = tmp; + } + if (sel_cell_start > sel_cell_end) { + int tmp = sel_cell_start; + sel_cell_start = sel_cell_end; + sel_cell_end = tmp; + } + int i, j; + for(i=sel_row_start; i <= sel_row_end; ++i) { + for(j=sel_col_start; j <= sel_col_end; ++j) { + tabular->GetCellInset(tabular->GetCellNumber(i, j))->clear(); + } } return true; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 46e0ed4b19..b37a13e404 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -218,7 +218,7 @@ private: /// int GetMaxWidthOfCell(Painter &, int cell) const; /// - bool hasPasteBuffer() const { return (paste_tabular != 0); } + bool hasPasteBuffer() const; /// bool copySelection(); /// @@ -266,7 +266,5 @@ private: mutable UpdateCodes need_update; /// mutable Dialogs * dialogs_; - /// - LyXTabular * paste_tabular; }; #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ada7416a98..7a39764995 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -46,6 +46,7 @@ #include "intl.h" #include "trans_mgr.h" #include "lyxscreen.h" +#include "WorkArea.h" using std::ostream; using std::ifstream; @@ -596,12 +597,26 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) } } if (!inset) { + bool paste_internally = false; + if ((button == 2) && TEXT(bv)->selection) { + LocalDispatch(bv, LFUN_COPY, ""); + paste_internally = true; + } TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, y+TEXT(bv)->first+insetAscent); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); bv->owner()->setLayout(cpar(bv)->GetLayout()); old_par = cpar(bv); + // Insert primary selection with middle mouse + // if there is a local selection in the current buffer, + // insert this + if (button == 2) { + if (paste_internally) + LocalDispatch(bv, LFUN_PASTE, ""); + else + LocalDispatch(bv, LFUN_PASTESELECTION, "paragraph"); + } } ShowInsetCursor(bv); } @@ -800,7 +815,10 @@ InsetText::LocalDispatch(BufferView * bv, bv->text->cursor.par()->next #endif ); - TEXT(bv)->Backspace(bv); + if (TEXT(bv)->selection) + TEXT(bv)->CutSelection(bv); + else + TEXT(bv)->Backspace(bv); UpdateLocal(bv, CURSOR_PAR, true); break; case LFUN_DELETE: @@ -813,7 +831,10 @@ InsetText::LocalDispatch(BufferView * bv, bv->text->cursor.par()->next #endif ); - TEXT(bv)->Delete(bv); + if (TEXT(bv)->selection) + TEXT(bv)->CutSelection(bv); + else + TEXT(bv)->Delete(bv); UpdateLocal(bv, CURSOR_PAR, true); break; case LFUN_CUT: @@ -834,6 +855,20 @@ InsetText::LocalDispatch(BufferView * bv, TEXT(bv)->CopySelection(bv); UpdateLocal(bv, CURSOR_PAR, false); break; + case LFUN_PASTESELECTION: + { + string clip(bv->workarea()->getClipboard()); + + if (clip.empty()) + break; + if (arg == "paragraph") { + TEXT(bv)->InsertStringB(bv, clip); + } else { + TEXT(bv)->InsertStringA(bv, clip); + } + UpdateLocal(bv, CURSOR_PAR, true); + break; + } case LFUN_PASTE: if (!autoBreakRows) { CutAndPaste cap; @@ -1368,14 +1403,16 @@ void InsetText::resizeLyXText(BufferView * bv) const // ProhibitInput(bv); - lpar = TEXT(bv)->cursor.par(); - pos = TEXT(bv)->cursor.pos(); - selstartpar = TEXT(bv)->sel_start_cursor.par(); - selstartpos = TEXT(bv)->sel_start_cursor.pos(); - selendpar = TEXT(bv)->sel_end_cursor.par(); - selendpos = TEXT(bv)->sel_end_cursor.pos(); - selection = TEXT(bv)->selection; - mark_set = TEXT(bv)->mark_set; + if (locked) { + lpar = TEXT(bv)->cursor.par(); + pos = TEXT(bv)->cursor.pos(); + selstartpar = TEXT(bv)->sel_start_cursor.par(); + selstartpos = TEXT(bv)->sel_start_cursor.pos(); + selendpar = TEXT(bv)->sel_end_cursor.par(); + selendpos = TEXT(bv)->sel_end_cursor.pos(); + selection = TEXT(bv)->selection; + mark_set = TEXT(bv)->mark_set; + } deleteLyXText(bv, (the_locking_inset == 0)); if (lpar) { diff --git a/src/spellchecker.C b/src/spellchecker.C index 451baa54c8..b381cda727 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -593,7 +593,7 @@ void sc_store_replacement(string const & mis, string const & cor) { PspellCanHaveError * spell_error_object; static -void init_spell_checker(BufferParams const &, string const & lang) +void init_spell_checker(BufferParams const &, string const & /* lang */) { PspellConfig * config = new_pspell_config(); spell_error_object = new_pspell_manager(config); @@ -630,7 +630,6 @@ isp_result * sc_check_word(string const & word) if (word_ok) { result->flag = ISP_OK; } else { - PspellWordList const * sugs = pspell_manager_suggest(sc, word.c_str()); Assert(sugs != 0); diff --git a/src/table.C b/src/table.C index 2ed7027547..6de4bf98f3 100644 --- a/src/table.C +++ b/src/table.C @@ -787,7 +787,7 @@ char LyXTable::GetAlignment(int cell) return column_info[column_of_cell(cell)].alignment; } -string LyXTable::GetPWidth(int cell) +string const LyXTable::GetPWidth(int cell) { int fvcell = FirstVirtualCell(cell); @@ -796,7 +796,7 @@ string LyXTable::GetPWidth(int cell) return column_info[column_of_cell(fvcell)].p_width; } -string LyXTable::GetAlignSpecial(int cell, int what) +string const LyXTable::GetAlignSpecial(int cell, int what) { if (what == SET_SPECIAL_MULTI) return cellinfo_of_cell(cell)->align_special;