diff --git a/ChangeLog b/ChangeLog index f45e6cd608..eba8ce2cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2000-09-05 Juergen Vigna + + * config/pspell.m4: added entry to lyx-flags + + * src/spellchecker.C: modified version from Kevin for using pspell + +2000-09-01 Marko Vendelin + * src/frontends/gnome/Makefile.am + * src/frontends/gnome/FormCitation.C + * src/frontends/gnome/FormCitation.h + * src/frontends/gnome/diainsertcitation_callbacks.c + * src/frontends/gnome/diainsertcitation_callbacks.h + * src/frontends/gnome/diainsertcitation_interface.c + * src/frontends/gnome/diainsertcitation_interface.h + * src/frontends/gnome/dialogs/diainsertcitation.glade: Insert Citation + dialog for Gnome frontend + + * src/main.C: Gnome libraries require keeping application name + and its version as strings + + * src/frontends/gnome/mainapp.C: Change the name of the main window + from GnomeLyX to PACKAGE + 2000-09-05 Jean-Marc Lasgouttes * src/frontends/Liason.C: add "using: declaration. diff --git a/config/pspell.m4 b/config/pspell.m4 index 12e7623076..29a322be1c 100644 --- a/config/pspell.m4 +++ b/config/pspell.m4 @@ -49,6 +49,7 @@ AC_DEFUN(CHECK_WITH_PSPELL, USE_PSPELL="yes ($pspell_use_include $pspell_use_lib)" AC_SUBST(PSPELL_INCLUDES) AC_SUBST(PSPELL_LIBS) + lyx_flags="$lyx_flags use-pspell" fi AC_MSG_RESULT($USE_PSPELL) ]) diff --git a/po/POTFILES.in b/po/POTFILES.in index d1e99e609a..cbb285bdd0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -28,6 +28,7 @@ src/ext_l10n.h src/filedlg.C src/FontLoader.C src/form1.C +src/frontends/gnome/FormCitation.C src/frontends/gnome/FormPrint.C src/frontends/gnome/FormToc.C src/frontends/kde/FormCopyright.C diff --git a/src/ext_l10n.h b/src/ext_l10n.h index 254529e6ff..9f82efc742 100644 --- a/src/ext_l10n.h +++ b/src/ext_l10n.h @@ -1,5 +1,7 @@ _("File|F"); _("Edit|E"); +_("Toc|T"); +_("Refs|R"); _("Layout|L"); _("Insert|I"); _("Math|M"); @@ -84,6 +86,7 @@ _("Check Out for Edit|O"); _("Revert to last version|l"); _("Undo last check in|U"); _("Show History|H"); +_("Go Back|B"); _("Character...|C"); _("Paragraph...|P"); _("Document...|D"); @@ -167,17 +170,18 @@ _("Credits...|e"); _("Version...|V"); _(""); _("A&A"); +_("ACT"); +_("AT_RISE:"); _("Abstract"); _("Accepted"); _("Acknowledgement"); +_("Acknowledgement(s)"); _("Acknowledgement*"); _("Acknowledgement-numbered"); -_("Acknowledgement(s)"); -_("Acknowledgements"); _("Acknowledgement-unnumbered"); +_("Acknowledgements"); _("Acknowledgments"); _("Acnowledgement"); -_("ACT"); _("Addchap"); _("Addchap*"); _("Addition"); @@ -195,15 +199,15 @@ _("Anlagen"); _("Anrede"); _("Appendices"); _("Appendix"); -_("AT_RISE:"); _("Author"); +_("AuthorRunning"); _("Author_Email"); _("Author_Running"); -_("AuthorRunning"); _("Author_URL"); _("Axiom"); _("Axiom-numbered"); _("Axiom-plain"); +_("BLZ"); _("Backaddress"); _("Bank"); _("BankAccount"); @@ -211,13 +215,12 @@ _("BankCode"); _("Betreff"); _("Bibliography"); _("Biography"); -_("BLZ"); _("Brieftext"); +_("CC"); +_("CURTAIN"); _("Caption"); _("Case"); _("Case-numbered"); -_("CC"); -_("cc"); _("CenteredCaption"); _("Chapter"); _("Chapter*"); @@ -257,7 +260,6 @@ _("Criterion-plain"); _("CrossList"); _("Current"); _("Current_Address"); -_("CURTAIN"); _("Customer"); _("Data"); _("Date"); @@ -272,10 +274,10 @@ _("Definition-unnumbered"); _("Description"); _("Dialogue"); _("EMail"); +_("EXT."); _("Email"); _("Encl"); _("Encl."); -_("encl"); _("End_All_Slides"); _("Enumerate"); _("Example"); @@ -286,48 +288,43 @@ _("Example-unnumbered"); _("Exercise"); _("Exercise-numbered"); _("Exercise-plain"); -_("EXT."); _("Extratitle"); +_("FADE_IN:"); +_("FADE_OUT:"); _("Fact"); _("Fact*"); _("Fact-numbered"); _("Fact-plain"); _("Fact-unnumbered"); -_("FADE_IN:"); -_("FADE_OUT:"); _("FigCaption"); -_("first"); _("FirstAuthor"); _("FirstName"); _("FitBitmap"); _("FitFigure"); _("Foilhead"); -_("foilhead"); _("Footernote"); _("FourAffiliations"); _("FourAuthors"); _("Gruss"); -_("Headnote"); _("HTTP"); +_("Headnote"); +_("INT."); _("Idea"); _("IhrSchreiben"); _("IhrZeichen"); _("Institute"); _("Institution"); -_("INT."); _("InvisibleText"); _("Invoice"); _("Itemize"); _("Journal"); -_("journal"); _("Keywords"); _("Konto"); -_("Labeling"); -_("Land"); -_("landscape"); -_("LandscapeSlide"); _("LaTeX"); _("LaTeX_Title"); +_("Labeling"); +_("Land"); +_("LandscapeSlide"); _("Lemma"); _("Lemma*"); _("Lemma-numbered"); @@ -346,10 +343,8 @@ _("MarkBoth"); _("MathLetters"); _("MeinZeichen"); _("Minisec"); -_("modying"); -_("msnumber"); -_("My_Address"); _("MyRef"); +_("My_Address"); _("Myref"); _("Name"); _("Narrative"); @@ -359,18 +354,18 @@ _("Note"); _("Note*"); _("Note-numbered"); _("Note-plain"); +_("Note-unnumbered"); _("NoteToEditor"); _("Notetoeditor"); -_("Note-unnumbered"); _("Offprint"); _("Offprints"); _("Offsets"); -_("offsets"); _("Oggetto"); _("Opening"); _("Ort"); _("Overlay"); _("PACS"); +_("PS"); _("Paragraph"); _("Paragraph*"); _("Paragraph-numbered"); @@ -381,8 +376,8 @@ _("Petit"); _("Phone"); _("Place"); _("PlaceFigure"); -_("Placefigure"); _("PlaceTable"); +_("Placefigure"); _("Placetable"); _("PortraitSlide"); _("PostalCommend"); @@ -399,12 +394,11 @@ _("Proposition*"); _("Proposition-numbered"); _("Proposition-plain"); _("Proposition-unnumbered"); -_("PS"); -_("ps"); _("Publishers"); _("Question"); _("Quotation"); _("Quote"); +_("REVTEX_Title"); _("Received"); _("Recieved"); _("Recieved/Accepted"); @@ -414,17 +408,17 @@ _("Remark"); _("Remark*"); _("Remark-numbered"); _("Remark-plain"); -_("Remarks"); _("Remark-unnumbered"); +_("Remarks"); _("RetourAdresse"); _("ReturnAddress"); -_("REVTEX_Title"); -_("Right_Address"); _("RightHeader"); +_("Right_Address"); _("Rotatefoilhead"); _("Running_LaTeX_Title"); _("SCENE"); _("SCENE*"); +_("SGML"); _("Scrap"); _("Section"); _("Section*"); @@ -432,11 +426,10 @@ _("Section-numbered"); _("Send"); _("Send_To_Address"); _("Seriate"); -_("SGML"); _("ShortFoilhead"); -_("Shortfoilhead"); _("ShortRotatefoilhead"); _("ShortTitle"); +_("Shortfoilhead"); _("Signature"); _("Slide"); _("Slide*"); @@ -452,26 +445,26 @@ _("State"); _("Strasse"); _("Street"); _("Style"); -_("style"); +_("SubSection"); +_("SubTitle"); _("Subitle"); _("Subject"); _("Subjectclass"); _("Subparagraph"); _("Subparagraph*"); -_("SubSection"); _("Subsection"); _("Subsection*"); _("Subsection-numbered"); _("Subsubsection"); _("Subsubsection*"); _("Subsubsection-numbered"); -_("SubTitle"); _("Subtitle"); _("Suggested"); _("Summary"); _("Summary-numbered"); _("Surname"); -_("surname"); +_("TOC_Author"); +_("TOC_Title"); _("TableComments"); _("TableRefs"); _("Telefax"); @@ -483,8 +476,8 @@ _("Theorem"); _("Theorem*"); _("Theorem-numbered"); _("Theorem-plain"); -_("TheoremTemplate"); _("Theorem-unnumbered"); +_("TheoremTemplate"); _("Thesaurus"); _("ThickLine"); _("This"); @@ -492,29 +485,39 @@ _("ThreeAffiliations"); _("ThreeAuthors"); _("TickList"); _("Title"); -_("Titlehead"); _("Title_Running"); -_("TOC_Author"); -_("TOC_Title"); +_("Titlehead"); _("Town"); -_("Transition"); _("Trans_Keywords"); +_("Transition"); _("Translated"); _("TranslatedAbstract"); _("Translated_Title"); _("Translator"); _("TwoAffiliations"); _("TwoAuthors"); +_("URL"); _("Unterschrift"); _("Uppertitleback"); -_("URL"); _("Use"); _("Verbatim"); _("Verse"); _("Verteiler"); _("VisibleText"); _("YourMail"); -_("Yourmail"); _("YourRef"); +_("Yourmail"); _("Yourref"); _("Zusatz"); +_("cc"); +_("encl"); +_("first"); +_("foilhead"); +_("journal"); +_("landscape"); +_("modying"); +_("msnumber"); +_("offsets"); +_("ps"); +_("style"); +_("surname"); diff --git a/src/frontends/gnome/FormCitation.C b/src/frontends/gnome/FormCitation.C new file mode 100644 index 0000000000..6056cf68d0 --- /dev/null +++ b/src/frontends/gnome/FormCitation.C @@ -0,0 +1,588 @@ +// -*- C++ -*- +/* 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" + +extern "C" { +#include "diainsertcitation_interface.h" +#include "support.h" +} + +#include +#include + +using std::vector; +using std::pair; +using std::max; +using std::min; +using std::find; + +#ifdef SIGC_CXX_NAMESPACES +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" + +#define CONF_DIALOG_HEIGTH "heigth" +#define CONF_DIALOG_HEIGTH_DEFAULT "=550" + +#define CONF_PANE_INFO "paneinfo" +#define CONF_PANE_INFO_DEFAULT "=300" + +#define CONF_PANE_KEY "panekey" +#define CONF_PANE_KEY_DEFAULT "=225" + +#define CONF_COLUMN "column" +#define CONF_COLUMN_DEFAULT "=50" + + +FormCitation::FormCitation(LyXView * lv, Dialogs * d) + : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(0), dialog_(NULL) +{ + // 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(slot(this, &FormCitation::showInset)); + d->createCitation.connect(slot(this, &FormCitation::createInset)); +} + + +FormCitation::~FormCitation() +{ + hide(); +} + +void FormCitation::showInset( InsetCommand * const inset ) +{ + if( dialog_!=NULL || inset == 0 ) return; + + inset_ = inset; + ih_ = inset_->hide.connect(slot(this, &FormCitation::hide)); + + params = inset->params(); + show(); +} + + +void FormCitation::createInset( string const & arg ) +{ + if( dialog_!=NULL ) return; + + params.setFromString( arg ); + show(); +} + +static +void parseBibTeX(string data, + string const & findkey, + string & keyvalue) +{ + unsigned int i; + + 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+1 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); + + Gtk::ScrolledWindow * sw_ = Gtk::wrap( GTK_SCROLLED_WINDOW( lookup_widget(pd, "scrolledwindow_bib") ) ); + sw_->add(*clist_bib_); + + // populating buttons with icons + Gnome::Pixmap * p; + p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_BACK) ) ); + button_select_->add(*p); + p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_TRASH) ) ); + button_unselect_->add(*p); + p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_UP) ) ); + button_up_->add(*p); + p = Gtk::wrap( GNOME_PIXMAP( gnome_stock_pixmap_widget(NULL, GNOME_STOCK_PIXMAP_DOWN) ) ); + button_down_->add(*p); + + + // connecting signals + clist_bib_->click_column.connect(slot(this, &FormCitation::sortBibList)); + + clist_selected_->select_row.connect(bind(slot(this, &FormCitation::selection_toggled), + true, true)); + clist_bib_->select_row.connect(bind(slot(this, &FormCitation::selection_toggled), + true, false)); + clist_selected_->unselect_row.connect(bind(slot(this, &FormCitation::selection_toggled), + false, true)); + clist_bib_->unselect_row.connect(bind(slot(this, &FormCitation::selection_toggled), + false, false)); + + button_select_->clicked.connect(slot(this, &FormCitation::newCitation)); + button_unselect_->clicked.connect(slot(this, &FormCitation::removeCitation)); + button_up_->clicked.connect(slot(this, &FormCitation::moveCitationUp)); + button_down_->clicked.connect(slot(this, &FormCitation::moveCitationDown)); + + search_text_->get_entry()->activate.connect(slot(this, &FormCitation::search)); + button_search_->clicked.connect(slot(this, &FormCitation::search)); + + b_ok->clicked.connect(slot(this, &FormCitation::apply)); + b_ok->clicked.connect(dialog_->destroy.slot()); + b_cancel->clicked.connect(dialog_->destroy.slot()); + dialog_->destroy.connect(slot(this, &FormCitation::free)); + + u_ = d_->updateBufferDependent.connect(slot(this, &FormCitation::update)); + h_ = d_->hideBufferDependent.connect(slot(this, &FormCitation::hide)); + + // setting sizes of the widgets + string path; + string w, h; + path += PACKAGE "/" LOCAL_CONFIGURE_PREFIX; + w = path + "/" + CONF_DIALOG_WIDTH + CONF_DIALOG_WIDTH_DEFAULT; + h = path + "/" + CONF_DIALOG_HEIGTH + CONF_DIALOG_HEIGTH_DEFAULT; + dialog_->set_usize(gnome_config_get_int(w.c_str()), + gnome_config_get_int(h.c_str())); + + w = path + "/" + CONF_PANE_INFO + CONF_PANE_INFO_DEFAULT; + paned_info_->set_position( gnome_config_get_int(w.c_str()) ); + + w = path + "/" + CONF_PANE_KEY + CONF_PANE_KEY_DEFAULT; + paned_key_->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()) ); + } + + // ready to go... + 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 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::update() +{ + bibkeys.clear(); + bibkeysInfo.clear(); + + clist_selected_->rows().clear(); + clist_bib_->rows().clear(); + + // populating clist_bib_ + clist_bib_->freeze(); + + vector > blist = + lv_->buffer()->getBibkeyList(); + + int i, sz; + for ( i = 0, sz = blist.size(); i < sz; ++i ) + { + bibkeys.push_back(blist[i].first); + bibkeysInfo.push_back(blist[i].second); + } + + blist.clear(); + + for ( i = 0, sz = bibkeys.size(); i < sz; ++i ) + addItemToBibList(i); + + clist_bib_->sort(); + clist_bib_->thaw(); + // clist_bib_: done + + // 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, ',') ); + } + // clist_selected_: done + + text_after_->get_entry()->set_text(params.getOptions()); + + updateButtons(); +} + +void FormCitation::updateButtons() +{ + bool sens; + + sens = (clist_selected_->selection().size()>0); + button_unselect_->set_sensitive(sens); + button_up_->set_sensitive(sens && + clist_selected_->selection().operator[](0).get_row_num()>0); + button_down_->set_sensitive(sens && + clist_selected_->selection().operator[](0).get_row_num() < + clist_selected_->rows().size()-1); + + sens = (clist_bib_->selection().size()>0); + button_select_->set_sensitive( (clist_bib_->selection().size()>0) ); +} + +void FormCitation::selection_toggled(gint row, + gint ,//column, + GdkEvent * ,//event, + bool selected, + bool citeselected) +{ + if (selected) + { + bool keyfound = false; + string info; + if (citeselected) + { + // lookup the record with the same key in bibkeys and show additional Info + int i; + int sz = bibkeys.size(); + string key = clist_selected_->cell(row,0).get_text(); + for (i=0; !keyfound && icell(row,0).get_text()) ]; + } + + if (keyfound) + info_->show_string(info); + else + info_->show_string(N_("--- No such key in the database ---")); + } + else + { + info_->show_string(""); + } + updateButtons(); +} + +void FormCitation::removeCitation() +{ + clist_selected_->rows().remove(clist_selected_->selection().operator[](0)); + updateButtons(); +} + +void FormCitation::moveCitationUp() +{ + int i = clist_selected_->selection().operator[](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().operator[](0).get_row_num(); + clist_selected_->swap_rows( i+1, i ); + clist_selected_->row(i+1).select(); + updateButtons(); +} + +void FormCitation::newCitation() +{ + // citation key is in the first column of clist_bib_ list + vector r; + r.push_back( clist_bib_->selection().operator[](0).operator[](1).get_text() ); + clist_selected_->rows().push_back(r); + clist_selected_->row( clist_selected_->rows().size()-1 ).select(); + updateButtons(); +} + +void FormCitation::hide() +{ + if (dialog_!=NULL) dialog_->destroy(); +} + +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; + + 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_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)); + } + + gnome_config_sync(); + + // cleaning up + dialog_ = NULL; + u_.disconnect(); + h_.disconnect(); + inset_ = 0; + ih_.disconnect(); + } +} + +void FormCitation::apply() +{ + if( lv_->buffer()->isReadonly() ) return; + + string contents; + for( unsigned int i = 0; i < clist_selected_->rows().size(); ++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().c_str() ); + } +} + +void FormCitation::sortBibList(gint col) +{ + clist_bib_->set_sort_column(col); + clist_bib_->sort(); +} + +// looking for entries which contain all the words specified in search_text entry +void FormCitation::search() +{ + vector searchwords; + string tmp, stext( search_text_->get_entry()->get_text() ); + 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 i, sz; + bool additem; + for ( i = 0, sz = bibkeys.size(); i < sz; ++i ) + { + string data = bibkeys[i] + bibkeysInfo[i]; + + additem = true; + + int j, szs; + for (j = 0, szs = searchwords.size(); + additem && j < szs; ++j ) + if ( data.find(searchwords[j]) == string::npos ) + additem = false; + + if ( additem ) addItemToBibList(i); + } + + clist_bib_->sort(); + clist_bib_->thaw(); + // clist_bib_: done + updateButtons(); +} diff --git a/src/frontends/gnome/FormCitation.h b/src/frontends/gnome/FormCitation.h new file mode 100644 index 0000000000..c55838aada --- /dev/null +++ b/src/frontends/gnome/FormCitation.h @@ -0,0 +1,129 @@ +// -*- 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 "support/utility.hpp" +#include "insets/insetcommand.h" + +#include +#include +#include +#include +#include +#include +#include + +/** This class provides an Gnome implementation of the FormCitation Dialog. + */ +class FormCitation : public DialogBase, public noncopyable { +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 ); + + /// Update dialog before showing it + virtual void update(); + /// 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(); + + /// sort biblist + void sortBibList(gint); + /// update state of the buttons + void updateButtons(); + /// clist selection/unselection callback + void selection_toggled(gint row, + gint column, + GdkEvent *event, + bool selected, + bool citeselected); + /// adds new citation key + void newCitation(); + /// removes selected citation key + void removeCitation(); + /// moves citation up + void moveCitationUp(); + /// moves citation up + void moveCitationDown(); + /// searches for entries + void search(); + + /// add item to the list + void addItemToBibList(int i); + + /** 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. + Gtk::Widget * dialog_; + Gtk::Button * b_ok; + Gtk::Button * b_cancel; + + 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::CList * clist_selected_; + Gtk::CList * clist_bib_; + + Gtk::Paned * paned_info_; + Gtk::Paned * paned_key_; + Gtk::Box * box_keys_; + + std::vector bibkeys; + /// + std::vector bibkeysInfo; +}; + +#endif diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index b15999872a..16d5709f97 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -33,6 +33,8 @@ LYXDATADIRS = libgnome_la_SOURCES = \ Dialogs.C \ GUIRunTime.C \ + FormCitation.C \ + FormCitation.h \ FormCopyright.C \ FormCopyright.h \ FormPrint.C \ @@ -64,7 +66,11 @@ libgnome_la_SOURCES = \ diatoc_callbacks.c \ diatoc_interface.c \ diatoc_callbacks.h \ - diatoc_interface.h + diatoc_interface.h \ + diainsertcitation_interface.c \ + diainsertcitation_interface.h \ + diainsertcitation_callbacks.c \ + diainsertcitation_callbacks.h # These still have to be added. Sooner or later. ARRae-20000411 # GUI_defaults.C \ diff --git a/src/frontends/gnome/diainsertcitation_callbacks.c b/src/frontends/gnome/diainsertcitation_callbacks.c new file mode 100644 index 0000000000..64a5f07df7 --- /dev/null +++ b/src/frontends/gnome/diainsertcitation_callbacks.c @@ -0,0 +1,10 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "diainsertcitation_callbacks.h" +#include "diainsertcitation_interface.h" +#include "support.h" + diff --git a/src/frontends/gnome/diainsertcitation_callbacks.h b/src/frontends/gnome/diainsertcitation_callbacks.h new file mode 100644 index 0000000000..18fbd94839 --- /dev/null +++ b/src/frontends/gnome/diainsertcitation_callbacks.h @@ -0,0 +1,2 @@ +#include + diff --git a/src/frontends/gnome/diainsertcitation_interface.c b/src/frontends/gnome/diainsertcitation_interface.c new file mode 100644 index 0000000000..5a810ab0cc --- /dev/null +++ b/src/frontends/gnome/diainsertcitation_interface.c @@ -0,0 +1,325 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include + +#include "diainsertcitation_callbacks.h" +#include "diainsertcitation_interface.h" +#include "support.h" + +GtkWidget* +create_DiaInsertCitation (void) +{ + GtkWidget *DiaInsertCitation; + GtkWidget *dialog_vbox2; + GtkWidget *vbox4; + GtkWidget *vpaned_info; + GtkWidget *hpaned_key; + GtkWidget *vbox_keys; + GtkWidget *label17; + GtkWidget *scrolledwindow2; + GtkWidget *clist_selected; + GtkWidget *label18; + GtkWidget *table2; + GtkWidget *label19; + GtkWidget *vbuttonbox2; + GtkWidget *button_select; + GtkWidget *button_unselect; + GtkWidget *button_up; + GtkWidget *button_down; + GtkWidget *scrolledwindow_bib; + GtkWidget *hbox3; + GtkWidget *search_text; + GtkWidget *combo_entry1; + GtkWidget *button_search; + GtkWidget *vbox5; + GtkWidget *alignment2; + GtkWidget *label16; + GtkWidget *info; + GtkWidget *hbox2; + GtkWidget *label15; + GtkWidget *text_after; + GtkWidget *entry3; + GtkWidget *dialog_action_area2; + GtkWidget *button_ok; + GtkWidget *button_cancel; + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new (); + + DiaInsertCitation = gnome_dialog_new (_("Insert Citation"), NULL); + gtk_object_set_data (GTK_OBJECT (DiaInsertCitation), "DiaInsertCitation", DiaInsertCitation); + GTK_WINDOW (DiaInsertCitation)->type = GTK_WINDOW_DIALOG; + gtk_window_set_policy (GTK_WINDOW (DiaInsertCitation), TRUE, TRUE, FALSE); + + dialog_vbox2 = GNOME_DIALOG (DiaInsertCitation)->vbox; + gtk_object_set_data (GTK_OBJECT (DiaInsertCitation), "dialog_vbox2", dialog_vbox2); + gtk_widget_show (dialog_vbox2); + + vbox4 = gtk_vbox_new (FALSE, 4); + gtk_widget_ref (vbox4); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vbox4", vbox4, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox4); + gtk_box_pack_start (GTK_BOX (dialog_vbox2), vbox4, TRUE, TRUE, 0); + + vpaned_info = gtk_vpaned_new (); + gtk_widget_ref (vpaned_info); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vpaned_info", vpaned_info, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vpaned_info); + gtk_box_pack_start (GTK_BOX (vbox4), vpaned_info, TRUE, TRUE, 0); + gtk_paned_set_gutter_size (GTK_PANED (vpaned_info), 10); + gtk_paned_set_position (GTK_PANED (vpaned_info), 245); + + hpaned_key = gtk_hpaned_new (); + gtk_widget_ref (hpaned_key); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "hpaned_key", hpaned_key, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hpaned_key); + gtk_paned_pack1 (GTK_PANED (vpaned_info), hpaned_key, FALSE, TRUE); + gtk_paned_set_gutter_size (GTK_PANED (hpaned_key), 10); + gtk_paned_set_position (GTK_PANED (hpaned_key), 250); + + vbox_keys = gtk_vbox_new (FALSE, 3); + gtk_widget_ref (vbox_keys); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vbox_keys", vbox_keys, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox_keys); + gtk_paned_pack1 (GTK_PANED (hpaned_key), vbox_keys, FALSE, TRUE); + + label17 = gtk_label_new (_("Insert keys:")); + gtk_widget_ref (label17); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "label17", label17, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label17); + gtk_box_pack_start (GTK_BOX (vbox_keys), label17, FALSE, FALSE, 0); + + scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_ref (scrolledwindow2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "scrolledwindow2", scrolledwindow2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow2); + gtk_box_pack_start (GTK_BOX (vbox_keys), scrolledwindow2, TRUE, TRUE, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + clist_selected = gtk_clist_new (1); + gtk_widget_ref (clist_selected); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "clist_selected", clist_selected, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (clist_selected); + gtk_container_add (GTK_CONTAINER (scrolledwindow2), clist_selected); + gtk_clist_set_column_width (GTK_CLIST (clist_selected), 0, 80); + gtk_clist_column_titles_hide (GTK_CLIST (clist_selected)); + + label18 = gtk_label_new (""); + gtk_widget_ref (label18); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "label18", label18, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label18); + gtk_clist_set_column_widget (GTK_CLIST (clist_selected), 0, label18); + + table2 = gtk_table_new (3, 2, FALSE); + gtk_widget_ref (table2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "table2", table2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (table2); + gtk_paned_pack2 (GTK_PANED (hpaned_key), table2, TRUE, TRUE); + gtk_table_set_row_spacings (GTK_TABLE (table2), 3); + gtk_table_set_col_spacings (GTK_TABLE (table2), 3); + + label19 = gtk_label_new (_("Bibliography keys: ")); + gtk_widget_ref (label19); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "label19", label19, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label19); + gtk_table_attach (GTK_TABLE (table2), label19, 1, 2, 0, 1, + (GtkAttachOptions) (0), + (GtkAttachOptions) (0), 0, 0); + + vbuttonbox2 = gtk_vbutton_box_new (); + gtk_widget_ref (vbuttonbox2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vbuttonbox2", vbuttonbox2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbuttonbox2); + gtk_table_attach (GTK_TABLE (table2), vbuttonbox2, 0, 1, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (GTK_FILL), 0, 0); + gtk_button_box_set_layout (GTK_BUTTON_BOX (vbuttonbox2), GTK_BUTTONBOX_START); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (vbuttonbox2), 0); + gtk_button_box_set_child_size (GTK_BUTTON_BOX (vbuttonbox2), 0, 27); + + button_select = gtk_button_new (); + gtk_widget_ref (button_select); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_select", button_select, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_select); + gtk_container_add (GTK_CONTAINER (vbuttonbox2), button_select); + GTK_WIDGET_SET_FLAGS (button_select, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, button_select, _("Select"), NULL); + + button_unselect = gtk_button_new (); + gtk_widget_ref (button_unselect); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_unselect", button_unselect, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_unselect); + gtk_container_add (GTK_CONTAINER (vbuttonbox2), button_unselect); + GTK_WIDGET_SET_FLAGS (button_unselect, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, button_unselect, _("Remove"), NULL); + + button_up = gtk_button_new (); + gtk_widget_ref (button_up); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_up", button_up, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_up); + gtk_container_add (GTK_CONTAINER (vbuttonbox2), button_up); + GTK_WIDGET_SET_FLAGS (button_up, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, button_up, _("Up"), NULL); + + button_down = gtk_button_new (); + gtk_widget_ref (button_down); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_down", button_down, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_down); + gtk_container_add (GTK_CONTAINER (vbuttonbox2), button_down); + GTK_WIDGET_SET_FLAGS (button_down, GTK_CAN_DEFAULT); + gtk_tooltips_set_tip (tooltips, button_down, _("Down"), NULL); + + scrolledwindow_bib = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_ref (scrolledwindow_bib); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "scrolledwindow_bib", scrolledwindow_bib, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (scrolledwindow_bib); + gtk_table_attach (GTK_TABLE (table2), scrolledwindow_bib, 1, 2, 1, 2, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_bib), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + hbox3 = gtk_hbox_new (FALSE, 3); + gtk_widget_ref (hbox3); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "hbox3", hbox3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox3); + gtk_table_attach (GTK_TABLE (table2), hbox3, 1, 2, 2, 3, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (GTK_FILL), 0, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox3), 3); + + search_text = gnome_entry_new ("diainsertcitation_search"); + gtk_widget_ref (search_text); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "search_text", search_text, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (search_text); + gtk_box_pack_start (GTK_BOX (hbox3), search_text, TRUE, TRUE, 0); + + combo_entry1 = gnome_entry_gtk_entry (GNOME_ENTRY (search_text)); + gtk_widget_ref (combo_entry1); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "combo_entry1", combo_entry1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (combo_entry1); + + button_search = gtk_button_new_with_label (_("Search")); + gtk_widget_ref (button_search); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_search", button_search, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_search); + gtk_box_pack_start (GTK_BOX (hbox3), button_search, FALSE, FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (button_search), 2); + + vbox5 = gtk_vbox_new (FALSE, 1); + gtk_widget_ref (vbox5); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "vbox5", vbox5, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (vbox5); + gtk_paned_pack2 (GTK_PANED (vpaned_info), vbox5, TRUE, TRUE); + + alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_widget_ref (alignment2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "alignment2", alignment2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (alignment2); + gtk_box_pack_start (GTK_BOX (vbox5), alignment2, FALSE, TRUE, 0); + + label16 = gtk_label_new (_("Info:")); + gtk_widget_ref (label16); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "label16", label16, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label16); + gtk_container_add (GTK_CONTAINER (alignment2), label16); + gtk_label_set_justify (GTK_LABEL (label16), GTK_JUSTIFY_LEFT); + gtk_misc_set_alignment (GTK_MISC (label16), 1.08033e-07, 1); + + info = gnome_less_new (); + gtk_widget_ref (info); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "info", info, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (info); + gtk_box_pack_start (GTK_BOX (vbox5), info, TRUE, TRUE, 0); + gtk_widget_set_usize (info, -2, 120); + + hbox2 = gtk_hbox_new (FALSE, 3); + gtk_widget_ref (hbox2); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "hbox2", hbox2, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (hbox2); + gtk_box_pack_start (GTK_BOX (vbox4), hbox2, FALSE, FALSE, 0); + + label15 = gtk_label_new (_("Text after: ")); + gtk_widget_ref (label15); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "label15", label15, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (label15); + gtk_box_pack_start (GTK_BOX (hbox2), label15, FALSE, FALSE, 0); + + text_after = gnome_entry_new ("diainsertcitation_textafter"); + gtk_widget_ref (text_after); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "text_after", text_after, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (text_after); + gtk_box_pack_start (GTK_BOX (hbox2), text_after, TRUE, TRUE, 0); + + entry3 = gnome_entry_gtk_entry (GNOME_ENTRY (text_after)); + gtk_widget_ref (entry3); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "entry3", entry3, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (entry3); + + dialog_action_area2 = GNOME_DIALOG (DiaInsertCitation)->action_area; + gtk_object_set_data (GTK_OBJECT (DiaInsertCitation), "dialog_action_area2", dialog_action_area2); + gtk_widget_show (dialog_action_area2); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area2), 8); + + gnome_dialog_append_button (GNOME_DIALOG (DiaInsertCitation), GNOME_STOCK_BUTTON_OK); + button_ok = g_list_last (GNOME_DIALOG (DiaInsertCitation)->buttons)->data; + gtk_widget_ref (button_ok); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_ok", button_ok, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_ok); + GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); + + gnome_dialog_append_button (GNOME_DIALOG (DiaInsertCitation), GNOME_STOCK_BUTTON_CANCEL); + button_cancel = g_list_last (GNOME_DIALOG (DiaInsertCitation)->buttons)->data; + gtk_widget_ref (button_cancel); + gtk_object_set_data_full (GTK_OBJECT (DiaInsertCitation), "button_cancel", button_cancel, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show (button_cancel); + GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); + + gtk_widget_grab_focus (button_ok); + gtk_widget_grab_default (button_ok); + gtk_object_set_data (GTK_OBJECT (DiaInsertCitation), "tooltips", tooltips); + + return DiaInsertCitation; +} + diff --git a/src/frontends/gnome/diainsertcitation_interface.h b/src/frontends/gnome/diainsertcitation_interface.h new file mode 100644 index 0000000000..f0c8df18f0 --- /dev/null +++ b/src/frontends/gnome/diainsertcitation_interface.h @@ -0,0 +1,5 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +GtkWidget* create_DiaInsertCitation (void); diff --git a/src/frontends/gnome/dialogs/diainsertcitation.glade b/src/frontends/gnome/dialogs/diainsertcitation.glade new file mode 100644 index 0000000000..783b571e57 --- /dev/null +++ b/src/frontends/gnome/dialogs/diainsertcitation.glade @@ -0,0 +1,486 @@ + + + + + diainsertcitation + diainsertcitation + + src + pixmaps + C + True + True + False + False + False + diainsertcitation_interface.c + diainsertcitation_interface.h + diainsertcitation_callbacks.c + diainsertcitation_callbacks.h + + + + GnomeDialog + DiaInsertCitation + Insert Citation + GTK_WINDOW_DIALOG + GTK_WIN_POS_NONE + False + True + True + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox2 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area2 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button_ok + True + True + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + button_cancel + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkVBox + vbox4 + False + 4 + + 0 + True + True + + + + GtkVPaned + vpaned_info + 10 + 10 + 245 + + 0 + True + True + + + + GtkHPaned + hpaned_key + 10 + 10 + 250 + + True + False + + + + GtkVBox + vbox_keys + False + 3 + + True + False + + + + GtkLabel + label17 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkScrolledWindow + scrolledwindow2 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + clist_selected + True + 1 + 80 + GTK_SELECTION_SINGLE + False + GTK_SHADOW_IN + + + GtkLabel + CList:title + label18 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkTable + table2 + 3 + 2 + False + 3 + 3 + + True + True + + + + GtkLabel + label19 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + False + False + False + False + False + False + + + + + GtkVButtonBox + vbuttonbox2 + GTK_BUTTONBOX_START + 0 + 0 + 27 + 7 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + GtkButton + button_select + Select + True + True + + + Placeholder + + + + + GtkButton + button_unselect + Remove + True + True + + + Placeholder + + + + + GtkButton + button_up + Up + True + True + + + Placeholder + + + + + GtkButton + button_down + Down + True + True + + + Placeholder + + + + + + GtkScrolledWindow + scrolledwindow_bib + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 1 + 2 + 1 + 2 + 0 + 0 + True + True + False + False + True + True + + + + Placeholder + + + + + GtkHBox + hbox3 + 3 + False + 3 + + 1 + 2 + 2 + 3 + 0 + 0 + True + False + False + False + True + True + + + + GnomeEntry + search_text + diainsertcitation_search + 10 + + 0 + True + True + + + + GtkEntry + GnomeEntry:entry + combo-entry1 + True + True + True + 0 + + + + + + GtkButton + button_search + 2 + True + + + 0 + False + False + + + + + + + + GtkVBox + vbox5 + False + 1 + + True + True + + + + GtkAlignment + alignment2 + 0.5 + 0.5 + 1 + 1 + + 0 + False + True + + + + GtkLabel + label16 + + GTK_JUSTIFY_LEFT + False + 1.08033e-07 + 1 + 0 + 0 + + + + + GnomeLess + info + 120 + + 0 + True + True + + + + + + + GtkHBox + hbox2 + False + 3 + + 0 + False + False + + + + GtkLabel + label15 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GnomeEntry + text_after + diainsertcitation_textafter + 10 + + 0 + True + True + + + + GtkEntry + GnomeEntry:entry + entry3 + True + True + True + 0 + + + + + + + + + diff --git a/src/frontends/gnome/mainapp.C b/src/frontends/gnome/mainapp.C index c0273a9e37..3273460607 100644 --- a/src/frontends/gnome/mainapp.C +++ b/src/frontends/gnome/mainapp.C @@ -20,7 +20,7 @@ using SigC::bind; using SigC::slot; GLyxAppWin::GLyxAppWin() : - Gnome::App("GnomeLyX","LyX Gnomified"), + Gnome::App(PACKAGE,"LyX Gnomified"), status_(false, true, GNOME_PREFERENCES_NEVER) { init(); @@ -36,7 +36,7 @@ void GLyxAppWin::init() // set defaults set_policy(false, true, false); set_default_size(250, 350); - set_wmclass("lyx", "GnomeLyX"); + set_wmclass(PACKAGE, "GnomeLyX"); frame_.set_shadow_type(GTK_SHADOW_IN); diff --git a/src/main.C b/src/main.C index e1b01f06bb..1cc999e1ef 100644 --- a/src/main.C +++ b/src/main.C @@ -72,7 +72,9 @@ int main(int argc, char * argv[]) KApplication a( argc, argv ); #endif #ifdef GTKGUI - Gnome::Main a(PACKAGE,VERSION,1,argv); //argc, argv ); + string app_id(PACKAGE); + string app_version(VERSION); + Gnome::Main a(app_id, app_version, 1, argv); //argc, argv ); GLyxAppWin appWin; mainAppWin = &appWin; #endif diff --git a/src/spellchecker.C b/src/spellchecker.C index f8d9811f41..022cdce54d 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -61,8 +61,11 @@ #include "encoding.h" //#define USE_PSPELL 1 + #ifdef USE_PSPELL + #include + #endif using std::reverse; @@ -111,19 +114,27 @@ extern void sigchldchecker(pid_t pid, int *status); struct isp_result { int flag; - int count; - string str; - char ** misses; + char * str; + char * b; + char * e; + const char * next_miss(); isp_result() { flag = ISP_UNKNOWN; - count = 0; - misses = static_cast(0); + str = 0; } ~isp_result() { - delete[] misses; + delete[] str; } }; +const char * isp_result::next_miss() { + if (str == 0 || *(e+1) == '\0') return 0; + b = e + 2; + e = strpbrk(b, ",\n"); + *e = '\0'; + return b; +} + #else struct isp_result { @@ -150,7 +161,6 @@ const char * isp_result::next_miss() const char * spell_error; - /***** Spellchecker options *****/ // Rewritten to use ordinary LyX xforms loop and OK, Apply and Cancel set, @@ -270,7 +280,6 @@ void SpellCheckerOptions() } } - #ifndef USE_PSPELL /***** Spellchecker *****/ @@ -278,7 +287,7 @@ void SpellCheckerOptions() // Could also use a clean up. (Asger Alstrup) static -void create_ispell_pipe(BufferParams const & params, string const & lang) +void init_spell_checker(BufferParams const & params, string const & lang) { static char o_buf[BUFSIZ]; // jc: it could be smaller int pipein[2], pipeout[2]; @@ -289,19 +298,19 @@ void create_ispell_pipe(BufferParams const & params, string const & lang) if(pipe(pipein) == -1 || pipe(pipeout) == -1) { lyxerr << "LyX: Can't create pipe for spellchecker!" << endl; - return; + goto END; } if ((out = fdopen(pipein[1], "w")) == 0) { lyxerr << "LyX: Can't create stream for pipe for spellchecker!" << endl; - return; + goto END; } if ((in = fdopen(pipeout[0], "r")) == 0) { lyxerr <<"LyX: Can't create stream for pipe for spellchecker!" << endl; - return; + goto END; } setvbuf(out, o_buf, _IOLBF, BUFSIZ); @@ -313,9 +322,9 @@ void create_ispell_pipe(BufferParams const & params, string const & lang) if(isp_pid == -1) { lyxerr << "LyX: Can't create child process for spellchecker!" << endl; - return; + goto END; } - + if(isp_pid == 0) { /* child process */ dup2(pipein[0], STDIN_FILENO); @@ -405,7 +414,7 @@ void create_ispell_pipe(BufferParams const & params, string const & lang) lyxerr << "LyX: Failed to start ispell!" << endl; _exit(0); } - + { /* Parent process: Read ispells identification message */ // Hmm...what are we using this id msg for? Nothing? (Lgb) // Actually I used it to tell if it's truly Ispell or if it's @@ -438,6 +447,9 @@ void create_ispell_pipe(BufferParams const & params, string const & lang) actual_spell_checker = ASC_ASPELL; else actual_spell_checker = ASC_ISPELL; + + fputs("!\n", out); // Set terse mode (silently accept correct words) + } else if (retval == 0) { // timeout. Give nice message to user. @@ -451,17 +463,39 @@ void create_ispell_pipe(BufferParams const & params, string const & lang) // Select returned error lyxerr << "Select on ispell returned error, what now?" << endl; } + } + END: + if (isp_pid == -1) { + spell_error = + "\n\n" + "The ispell-process has died for some reason. *One* possible reason\n" + "could be that you do not have a dictionary file\n" + "for the language of this document installed.\n" + "Check /usr/lib/ispell or set another\n" + "dictionary in the Spellchecker Options menu."; + } else { + spell_error = 0; + } } +static +bool sc_still_alive() { + return isp_pid != -1; +} + +static +void sc_clean_up_after_error() +{ + fclose(out); +} // Send word to ispell and get reply static -isp_result *ispell_check_word(char *word) +isp_result * sc_check_word(char *word) { //Please rewrite to use string. isp_result *result; - char buf[1024], *p; - int count, i; + char buf[1024]; fputs(word, out); fputc('\n', out); @@ -494,25 +528,10 @@ isp_result *ispell_check_word(char *word) case '&': // Not found, but we have near misses { result->flag = ISP_MISSED; - result->str = buf; - // nb is leaked! where should it be freed? I have to - // admit I do not understand the intent of the code :( - // (JMarc) - char * nb = new char[result->str.length() + 1]; - result->str.copy(nb, result->str.length()); - nb[result->str.length()]= '\0'; - p = strpbrk(nb+2, " "); - sscanf(p, "%d", &count); // Get near misses count - result->count = count; - if (count) result->misses = new char*[count]; - p = strpbrk(nb, ":"); - p += 2; - for (i = 0; i < count; ++i) { - result->misses[i] = p; - p = strpbrk(p, ",\n"); - *p = 0; - p += 2; - } + char * p = strpbrk(buf, ":"); + result->str = new char[strlen(p) + 1]; + result->e = result->str; + strcpy(result->str, p); break; } default: // This shouldn't happend, but you know Murphy @@ -527,8 +546,8 @@ isp_result *ispell_check_word(char *word) } -static inline -void ispell_terminate() +static inline +void close_spell_checker() { // Note: If you decide to optimize this out when it is not // needed please note that when Aspell is used this command @@ -542,15 +561,8 @@ void ispell_terminate() } -static inline -void ispell_terse_mode() -{ - fputs("!\n", out); // Set terse mode (silently accept correct words) -} - - -static inline -void ispell_insert_word(char const *word) +static inline +void sc_insert_word(char const *word) { fputc('*', out); // Insert word in personal dictionary fputs(word, out); @@ -558,8 +570,8 @@ void ispell_insert_word(char const *word) } -static inline -void ispell_accept_word(char const *word) +static inline +void sc_accept_word(char const *word) { fputc('@', out); // Accept in this session fputs(word, out); @@ -567,7 +579,7 @@ void ispell_accept_word(char const *word) } static inline -void ispell_store_replacement(char const *mis, string const & cor) { +void sc_store_replacement(char const *mis, string const & cor) { if(actual_spell_checker == ASC_ASPELL) { fputs("$$ra ", out); fputs(mis, out); @@ -582,7 +594,7 @@ void ispell_store_replacement(char const *mis, string const & cor) { PspellCanHaveError * spell_error_object; static -void init_spell_checker(string const & /* lang */) +void init_spell_checker(BufferParams const &, string const & lang) { PspellConfig * config = new_pspell_config(); spell_error_object = new_pspell_manager(config); @@ -635,28 +647,27 @@ isp_result * sc_check_word(char *word) } -static -inline void close_spell_checker() +static inline +void close_spell_checker() { pspell_manager_save_all_word_lists(sc); } - -static -inline void sc_insert_word(char const *word) +static inline +void sc_insert_word(char const *word) { pspell_manager_add_to_personal(sc, word); } -static -inline void sc_accept_word(char const *word) +static inline +void sc_accept_word(char const *word) { pspell_manager_add_to_personal(sc, word); } -static -inline void sc_store_replacement(char const *mis, string const & cor) { +static inline +void sc_store_replacement(char const *mis, string const & cor) { pspell_manager_store_replacement(sc, mis, cor.c_str()); } @@ -792,33 +803,16 @@ bool RunSpellChecker(BufferView * bv) float newval = 0.0; /* create ispell process */ + init_spell_checker(bv->buffer()->params, tmp); -#ifndef USE_PSPELL - - create_ispell_pipe(bv->buffer()->params, tmp); - if (isp_pid == -1) { - fl_show_message( - _("\n\n" - "The ispell-process has died for some reason. *One* possible reason\n" - "could be that you do not have a dictionary file\n" - "for the language of this document installed.\n" - "Check /usr/lib/ispell or set another\n" - "dictionary in the Spellchecker Options menu."), "", ""); - fclose(out); - return false; - } - // Put ispell in terse mode to improve speed - ispell_terse_mode(); -#else - init_spell_checker(tmp); if (spell_error != 0) { fl_show_message(_(spell_error), "", ""); sc_clean_up_after_error(); - return true; - } -#endif + return false; + } unsigned int word_count = 0; + while (true) { char * word = bv->nextWord(newval); if (word == 0) break; @@ -829,39 +823,24 @@ bool RunSpellChecker(BufferView * bv) if(newvalue!= oldval) { oldval = newvalue; fl_set_slider_value(fd_form_spell_check->slider, oldval); - } + } if (word_count%1000 == 0) { obj = fl_check_forms(); if (obj == fd_form_spell_check->stop) { delete[] word; -#ifndef USE_PSPELL - ispell_terminate(); -#else close_spell_checker(); -#endif return true; } if (obj == fd_form_spell_check->done) { delete[] word; -#ifndef USE_PSPELL - ispell_terminate(); -#else close_spell_checker(); -#endif return false; } } -#ifndef USE_PSPELL - result = ispell_check_word(word); - if (isp_pid == -1) -#else result = sc_check_word(word); - if (!sc_still_alive()) -#endif - { - + if (!sc_still_alive()) { delete result; delete[] word; break; @@ -880,40 +859,25 @@ bool RunSpellChecker(BufferView * bv) fl_set_object_label(fd_form_spell_check->text, word); fl_set_input(fd_form_spell_check->input, word); fl_clear_browser(fd_form_spell_check->browser); -#ifndef USE_PSPELL - int i; - for (i = 0; i < result->count; ++i) { + const char * w; + while ((w = result->next_miss()) != 0) { if (rtl) { - string tmp = result->misses[i]; + string tmp = w; reverse(tmp.begin(),tmp.end()); fl_add_browser_line(fd_form_spell_check->browser, tmp.c_str()); } else - fl_add_browser_line(fd_form_spell_check->browser, result->misses[i]); + fl_add_browser_line(fd_form_spell_check->browser, w); } -#else - const char * w; - while ((w = result->next_miss()) != 0) { - fl_add_browser_line(fd_form_spell_check->browser, w); - } -#endif int clickline = -1; while (true) { obj = fl_do_forms(); if (obj == fd_form_spell_check->insert) { -#ifndef USE_PSPELL - ispell_insert_word(word); -#else sc_insert_word(word); -#endif break; } if (obj == fd_form_spell_check->accept) { -#ifndef USE_PSPELL - ispell_accept_word(word); -#else sc_accept_word(word); -#endif break; } if (obj == fd_form_spell_check->ignore) { @@ -921,11 +885,7 @@ bool RunSpellChecker(BufferView * bv) } if (obj == fd_form_spell_check->replace || obj == fd_form_spell_check->input) { -#ifndef USE_PSPELL - ispell_store_replacement(word, fl_get_input(fd_form_spell_check->input)); -#else sc_store_replacement(word, fl_get_input(fd_form_spell_check->input)); -#endif bv->replaceWord(fl_get_input(fd_form_spell_check->input)); break; } @@ -934,11 +894,7 @@ bool RunSpellChecker(BufferView * bv) // sent to lyx@via by Mark Burton if (clickline == fl_get_browser(fd_form_spell_check->browser)) { -#ifndef USE_PSPELL - ispell_store_replacement(word, fl_get_input(fd_form_spell_check->input)); -#else sc_store_replacement(word, fl_get_input(fd_form_spell_check->input)); -#endif bv->replaceWord(fl_get_input(fd_form_spell_check->input)); break; } @@ -958,22 +914,14 @@ bool RunSpellChecker(BufferView * bv) if (obj == fd_form_spell_check->stop) { delete result; delete[] word; -#ifndef USE_PSPELL - ispell_terminate(); -#else close_spell_checker(); -#endif return true; } if (obj == fd_form_spell_check->done) { delete result; delete[] word; -#ifndef USE_PSPELL - ispell_terminate(); -#else close_spell_checker(); -#endif return false; } } @@ -983,14 +931,9 @@ bool RunSpellChecker(BufferView * bv) delete[] word; } } - -#ifndef USE_PSPELL - if(isp_pid!= -1) { - ispell_terminate(); -#else + if(sc_still_alive()) { close_spell_checker(); -#endif string word_msg(tostr(word_count)); if (word_count != 1) { word_msg += _(" words checked."); @@ -1001,15 +944,9 @@ bool RunSpellChecker(BufferView * bv) word_msg.c_str()); return false; } else { -#ifndef USE_PSPELL - fl_show_message(_("The ispell-process has died for some reason.\n" - "Maybe it has been killed."), "", ""); - fclose(out); -#else fl_show_message(_("The spell checker has died for some reason.\n" "Maybe it has been killed."), "", ""); sc_clean_up_after_error(); -#endif return true; } } @@ -1031,7 +968,7 @@ void sigchldhandler(pid_t pid, int * status) #else -void sigchldhandler(pid_t /* pid */, int * /* status */) +void sigchldhandler(pid_t, int *) { // do nothing }