]> git.lyx.org Git - features.git/commitdiff
Fixes to insettabular/text + GNOME patch + KDE patch
authorJürgen Vigna <jug@sad.it>
Tue, 19 Sep 2000 13:50:47 +0000 (13:50 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 19 Sep 2000 13:50:47 +0000 (13:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1029 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
ChangeLog
po/POTFILES.in
src/CutAndPaste.C
src/Makefile.am
src/frontends/gnome/FormCitation.C
src/frontends/gnome/FormCitation.h
src/frontends/gnome/FormIndex.C
src/frontends/gnome/FormIndex.h
src/frontends/gnome/FormUrl.C
src/frontends/gnome/FormUrl.h
src/frontends/gnome/Menubar_pimpl.C
src/frontends/gnome/Menubar_pimpl.h
src/frontends/gnome/mainapp.C
src/frontends/gnome/mainapp.h
src/frontends/kde/FormRef.C
src/frontends/kde/FormRef.h
src/frontends/kde/FormToc.C
src/frontends/kde/formtocdialog.h
src/frontends/xforms/FormDocument.C
src/insets/figinset.C
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/spellchecker.C
src/table.C

index 0ba6a70bb9cdbdbbc3771c8dbfcfb6233edbf992..c9ea76ce41072752d5ac1668b3078282f97a1017 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,63 @@
+2000-09-18  Juergen Vigna  <jug@sad.it>
+
+       * 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  <kayvan@sylvan.com>
+
+       * src/Makefile.am: Add sources to lyx_SOURCES so they will be
+         included in the ``make dist'' tarball.
+
+2000-09-15  Juergen Vigna  <jug@sad.it>
+
+       * 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 <a.leeming@ic.ac.uk>
+
+       * 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 <markov@ioc.ee>
+       
+       * 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  <larsbj@lyx.org>
 
        * src/buffer.C (Dispatch): fix call to Dispatch
index 70efb80a26b9d5b8cfd57f7e54f15ac9d1215a54..901ef1d56b14ad27eb63d3092f6ac5f7fc8016df 100644 (file)
@@ -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
index de95af7932e5d9fba35b486d83f92ac33ce38059..c56ff81dfe5cfeae3d0cd73ef124a3e6999bce7c 100644 (file)
@@ -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,
index 83ef229a09e7e47d7e8edd9ce7de5a77f5344124..935c13d41016d2d99fccdba21ae5dcc805489314 100644 (file)
@@ -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 \
index 9127069e72579e0f328dc558305a2ba152cb2cae..f9defca4906a291349ac6cec9802b865aaaf30e6 100644 (file)
 #include "support/filetools.h"
 #include "support/LRegex.h"
 
-extern "C" {
-#include "diainsertcitation_interface.h"
-#include "support.h"
-}
-
 #include <gtk--/scrolledwindow.h>
 #include <gnome--/pixmap.h>
+#include <gtk--/label.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
+#include <gnome--/entry.h>
+#include <gnome--/stock.h>
+#include <gtk--/separator.h>
+#include <libgnome/gnome-config.h>
+
+// 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<string> 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<pair<string,string> > 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<string> 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();
 }
index 96cd4d0773635daf92079f4458e44a4f17bf45dd..f9234364b15fd61786e1c7a2c394a2720538bb58 100644 (file)
@@ -21,7 +21,7 @@
 #include "support/utility.hpp"
 #include "insets/insetcommand.h"
 
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
 #include <gtk--/clist.h>
 #include <gnome--/entry.h>
 #include <gnome--/less.h>
@@ -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_;
index f99b2a5af28a4ff4bbc61b061fd558682f3275d8..a4937692e7418ef6cb7ee2ea7686f4cc874ea1d3 100644 (file)
 #include "buffer.h"
 #include "lyxfunc.h"
 
-extern "C" {
-#include "diainsertindex_interface.h"
-#include "support.h"
-}
-
-#include <gtk--/base.h>
-
 #include "gettext.h"
 #include "Dialogs.h"
 #include "FormIndex.h"
@@ -38,6 +31,20 @@ extern "C" {
 #include "form_index.h"
 #include "lyxfunc.h"
 
+#include <gtk--/label.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
+#include <gnome--/entry.h>
+#include <gnome--/stock.h>
+#include <gtk--/separator.h>
+
+// 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();
 }
+
index e246806b38e1cefbef5063999b724d1e6c73898d..864605033fc72bc601c538e0a1903061e358bea3 100644 (file)
@@ -21,7 +21,7 @@
 #include "support/utility.hpp"
 #include "insets/insetcommand.h"
 
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
 #include <gnome--/entry.h>
 #include <gtk--/label.h>
 
@@ -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;
index afd39f614c49d0c949e5e658e76acb13b21a2813..eadf7ef4b9736c876dedc2b8b18ca4a950974943 100644 (file)
 #include "buffer.h"
 #include "lyxfunc.h"
 
-extern "C" {
-#include "diainserturl_interface.h"
-#include "support.h"
-}
-
+#include <gtk--/label.h>
+#include <gtk--/table.h>
+#include <gtk--/box.h>
+#include <gtk--/buttonbox.h>
 #include <gtk--/base.h>
+#include <gtk--/separator.h>
+
+// 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();
 }
index 4f0729d0c4e03e33fb829da9c2f8237bd3c8f075..572a8dd8161f3196dec3774d74cef51f414f3c49 100644 (file)
@@ -21,7 +21,7 @@
 #include "support/utility.hpp"
 #include "insets/insetcommand.h"
 
-#include <gtk--/widget.h>
+#include <gtk--/container.h>
 #include <gtk--/checkbutton.h>
 #include <gnome--/entry.h>
 #include <gtk--/button.h>
@@ -76,7 +76,7 @@ private:
   Connection ih_;
 
   /// Real GUI implementation.
-  Gtk::Widget * dialog_;
+  Gtk::Container * dialog_;
 
   Gtk::CheckButton * html_type_;
 
index 9c12a0bc7d61dee4564694b81ee17a3e70cb0d73..ef20ded2bb51b5f2615c323bfdf9dbdb058dafe5 100644 (file)
 #include "LyXView.h"
 #include "MenuBackend.h"
 #include "Menubar_pimpl.h"
+#include "lyxtext.h"
+#include "exporter.h"
 
 #include "mainapp.h"
 
+#include <gtk--/menu.h>
+
 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<Gnome::UI::Info> 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<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC];
+      updateList(&toclist, &toc_);
+    }
+}
+
+void Menubar::Pimpl::updateList(vector<Buffer::TocItem> * toclist, vector<ListsHolder> * pgui) 
+{
+  vector<ListsHolder> & gui = *pgui;
+  int szGui = gui.size();
+  int i;
+  for (i=0; i < szGui; ++i)
+    {
+      int oldsz = gui[i].lst.size();
+      vector<Gnome::UI::Info> menu;
+      string label;
+
+      menu.push_back(Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_REFRESH),
+                                    N_("Refresh"), slot(this, &Menubar::Pimpl::updateAllLists)));
+      
+      vector<Buffer::TocItem>::const_iterator end = toclist->end();
+      for (vector<Buffer::TocItem>::const_iterator it = toclist->begin();
+          it != end; ++it)
+
+       {
+         label = string(4*(*it).depth,' ')+(*it).str;
+         
+         menu.push_back(Gnome::UI::Item(label,
+                                        bind<Buffer::TocItem>(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<Gnome::UI::Info> & 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<Gnome::UI::Info> & 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<Gnome::UI::I
 
       case MenuItem::Command: {
        string label = item.label();
+
+       path = rootpath + label;
+       
        if (label.find(item.shortcut()) != string::npos)
          label.insert(label.find(item.shortcut()), "_");
 
@@ -204,14 +270,20 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::I
       case MenuItem::Submenu: {
        vector<Gnome::UI::Info> 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 + "<Separator>";
+       
        Menus.push_back(Gnome::UI::Separator());
        break;
       }
@@ -222,8 +294,11 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::I
             cit != lastfiles->end() && 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<int>(slot(this, &Menubar::Pimpl::callback), action),
                                            label));
@@ -240,6 +315,8 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::I
            int action = lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *cit);
            string label = MakeDisplayPath(*cit, 30);
 
+           path = rootpath + label;
+           
            Menus.push_back(Gnome::UI::Item(label,
                                            bind<int>(slot(this, &Menubar::Pimpl::callback), action),
                                            label));
@@ -247,16 +324,57 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::I
          }
        break;
       }
+
+      case MenuItem::Toc: {
+       ListsHolder t;
+       t.path = path;
+       toc_.push_back(t);
+       break;
+      }
+      
+      case MenuItem::ViewFormats: {
+       add_formats(Menus, LFUN_PREVIEW, true);
+       break;
+      }
+       
+      case MenuItem::UpdateFormats: {
+       add_formats(Menus, LFUN_UPDATE, true);
+       break;  
+      }
+       
+      case MenuItem::ExportFormats: {
+       add_formats(Menus, LFUN_EXPORT, false);
+       break;
+      }
       }
     }
 }
 
+void Menubar::Pimpl::add_formats(vector<Gnome::UI::Info> & Menus, kb_action action, bool viewable)
+{
+  vector<pair<string,string> > names = 
+    viewable
+    ? Exporter::GetViewableFormats(owner_->buffer())
+    : Exporter::GetExportableFormats(owner_->buffer());
+  
+  for (vector<pair<string,string> >::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<int>(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_ ) );
index 14f4512b73b87a022f8621611f6678c4336b1b00..fdcdb665f52822b9fa7e19854abf289e7435742a 100644 (file)
 #include "LString.h"
 #include <gnome--/app.h>
 #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<Gnome::UI::Info> & Menus);
+  void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & 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<Buffer::TocItem> *, vector<ListsHolder> *);
+  /// Add to "Menus" the list of exportable/viewable formats
+  void add_formats(vector<Gnome::UI::Info> & Menus, kb_action action, bool viewable);
   
 private:
   /// 
@@ -77,5 +100,9 @@ private:
   bool ignore_action_;
   int  action_;
   vector<GtkWidgetToAction> wid_act_;
+
+  /// toc
+  Connection utoc_;
+  vector<ListsHolder> toc_;
 };
 #endif
index 32734606074e93d8c8e810ac37699cce6d56ba4b..7dd176e5ed0f870ebaaeea8e38525718ccbb08bf 100644 (file)
@@ -9,8 +9,14 @@
  * ====================================================== */
 
 #include <config.h>
+
 #include <gnome--/main.h>
 #include <gtk--/accelgroup.h>
+#include <gnome--/pixmap.h>
+#include <gtk--/separator.h>
+#include <gtk--/frame.h>
+#include <gtk--/label.h>
+
 #include <vector>
 #include <algorithm>
 
@@ -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;
+}
 
index 5e6716f6f3a140722436a843130065686b87926d..b0d740071d65430c5c24fbe2395aca4df6b8d4da 100644 (file)
@@ -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_;
 };
index 0b49bec03684a5fef2d2305f2c55b7166cc7c22d..ab77dad6769d21521f9d8e2d817c6e54f0455cdd 100644 (file)
@@ -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)
index e3049b27c80ebaf7b16cf18075042fa2164fe778..f75fdf1e74d3efc8307ba308bb41799f55818e6a 100644 (file)
@@ -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.
index 3b89858ccc7e6cf87002e20043b6b1f2324b3261..bba790ea114a263b41b02ba3f58b0418a399e06f 100644 (file)
@@ -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)
index 68f67995384becf6384998501809271c8188983e..5ce697ad214e26d2f44a67cf524e11f1dc633480 100644 (file)
@@ -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;
                }
        }
index 5511d850b2fa243c8e5561a8edab2dd6c9d81567..b059aea40f62852e0d47e3f95195c17aeaf9f6ed 100644 (file)
@@ -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);
index 37c8c72e40f61b45465e29e5529e4018a654317d..9ece103b1a14c34d063bd983a9fd66a5561941f3 100644 (file)
@@ -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);
index 8b07c7885f7a163a87fa1e393757211c571623ad..eaa053afaeaa35c472bcc5d0a427a603ef5af040 100644 (file)
 
 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;
 }
index 46e0ed4b19188c9ece5eb0b3ca4eb1cba335c9f6..b37a13e404ec4543a585e8bf4a4fdf625cf5bb1c 100644 (file)
@@ -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
index ada7416a98f680e424f06ca7490a9b373e88ec89..7a397649951b4a2b44f7d380f8bfe7fb23cdcf9b 100644 (file)
@@ -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) {
index 451baa54c8ac7d4fc86396f35079d9c81623834e..b381cda727acf06b2f361c5619ac40c9183cc91c 100644 (file)
@@ -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);
index 2ed70275471e1b484358a818cdb2fff016585208..6de4bf98f307c2bffa627feeed095f8b5a285bd7 100644 (file)
@@ -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;