]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gnome/FormRef.C
fix problem with nroff detection, remove dead code with old floats, bogus message...
[lyx.git] / src / frontends / gnome / FormRef.C
index 6616e6e2d51984ef608532037f4725a2ef5d0c74..6cacca2e990abb128b871ea2291dfca98f2de9c7 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
 #include "mainapp.h"
 extern GLyxAppWin * mainAppWin;
 
-using SigC::bind;
+namespace anon {
 
 // configuration keys
-static string const CONF_ENTRY_NAME("FormRef_name");
+string const CONF_ENTRY_NAME("FormRef_name");
 
 // goto button labels
-static string const GOTO_REF_LABEL(N_("Goto reference"));
-static string const GOTO_BACK_LABEL(N_("Go back"));
+string const GOTO_REF_LABEL(N_("Goto reference"));
+string const GOTO_BACK_LABEL(N_("Go back"));
+
+} // namespace anon
+
 
 FormRef::FormRef(LyXView * lv, Dialogs * d)
-       : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(NULL)
+       : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0)
 {
   // let the dialog be shown
   // These are permanent connections so we won't bother
@@ -66,10 +68,10 @@ FormRef::~FormRef()
 
 void FormRef::showInset( InsetCommand * const inset )
 {
-  if( dialog_!=NULL || inset == 0 ) return;
+  if( dialog_!=0 || inset == 0 ) return;
   
   inset_ = inset;
-  ih_ = inset_->hide.connect(slot(this, &FormRef::hide));
+  ih_ = inset_->hideDialog.connect(slot(this, &FormRef::hide));
 
   acttype_ = EDIT;
   
@@ -80,7 +82,7 @@ void FormRef::showInset( InsetCommand * const inset )
 
 void FormRef::createInset( string const & arg )
 {
-  if( dialog_!=NULL ) return;
+  if( dialog_!=0 ) return;
   
   acttype_ = INSERT;
 
@@ -113,7 +115,7 @@ void FormRef::showStageError(string const & mess)
 
       // packing dialog to main window
       dialog_ = alig;
-      mainAppWin->add_action(*dialog_, N_(" Reference "));
+      mainAppWin->add_action(*dialog_, _(" Reference "));
 
       // setting focus
       gtk_widget_grab_focus (GTK_WIDGET(b_cancel->gtkobj()));
@@ -122,7 +124,7 @@ void FormRef::showStageError(string const & mess)
       b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
       dialog_->destroy.connect(slot(this, &FormRef::free));
 
-      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::update));
+      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot));
       h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide));
     }
 }
@@ -182,7 +184,7 @@ void FormRef::showStageSelect()
       
       // packing dialog to main window
       dialog_ = mbox;
-      mainAppWin->add_action(*dialog_, N_(" Reference: Select reference "), true);
+      mainAppWin->add_action(*dialog_, _(" Reference: Select reference "), true);
 
       // setting focus
       GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_ok->gtkobj()), GTK_CAN_DEFAULT);
@@ -197,7 +199,7 @@ void FormRef::showStageSelect()
 
       dialog_->destroy.connect(slot(this, &FormRef::free));
 
-      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::update));
+      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot));
       h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide));
     }
 }
@@ -251,27 +253,27 @@ void FormRef::showStageAction()
       Gtk::Menu * menu = manage( new Gtk::Menu() );
       Gtk::MenuItem * e;
       
-      e = manage( new Gtk::MenuItem(N_("Ref")) );
+      e = manage( new Gtk::MenuItem(_("Ref")) );
       e->activate.connect(bind<Type>(slot(this, &FormRef::changeType), REF));
       e->show();
       menu->append( *e );
 
-      e = manage( new Gtk::MenuItem(N_("Page")) );
+      e = manage( new Gtk::MenuItem(_("Page")) );
       e->activate.connect(bind<Type>(slot(this, &FormRef::changeType), PAGEREF));
       e->show();
       menu->append( *e );
 
-      e = manage( new Gtk::MenuItem(N_("TextRef")) );
+      e = manage( new Gtk::MenuItem(_("TextRef")) );
       e->activate.connect(bind<Type>(slot(this, &FormRef::changeType), VREF));
       e->show();
       menu->append( *e );
 
-      e = manage( new Gtk::MenuItem(N_("TextPage")) );
+      e = manage( new Gtk::MenuItem(_("TextPage")) );
       e->activate.connect(bind<Type>(slot(this, &FormRef::changeType), VPAGEREF));
       e->show();
       menu->append( *e );
 
-      e = manage( new Gtk::MenuItem(N_("PrettyRef")) );
+      e = manage( new Gtk::MenuItem(_("PrettyRef")) );
       e->activate.connect(bind<Type>(slot(this, &FormRef::changeType), PRETTYREF));
       e->show();
       menu->append( *e );
@@ -297,8 +299,8 @@ void FormRef::showStageAction()
       bbox->children().push_back(Element(*b_ok, false, false));
       bbox->children().push_back(Element(*b_cancel, false, false));
       
-      table->attach( *manage( new Gtk::Label(N_("Type:")) ), 0, 1, 0, 1, 0, 0 );
-      table->attach( *manage( new Gtk::Label(N_("Name:")) ), 0, 1, 1, 2, 0, 0 );
+      table->attach( *manage( new Gtk::Label(_("Type:")) ), 0, 1, 0, 1, 0, 0 );
+      table->attach( *manage( new Gtk::Label(_("Name:")) ), 0, 1, 1, 2, 0, 0 );
       table->attach( *choice_, 1, 2, 0, 1 );
       table->attach( *name_, 1, 2, 1, 2 );
 
@@ -308,7 +310,7 @@ void FormRef::showStageAction()
 
       // packing dialog to main window
       dialog_ = mbox;
-      mainAppWin->add_action(*dialog_, string(N_(" Reference: ")) + params.getContents() + string(" "));
+      mainAppWin->add_action(*dialog_, string(_(" Reference: ")) + params.getContents() + string(" "));
 
       // setting focus
       GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_cancel->gtkobj()), GTK_CAN_DEFAULT);
@@ -324,21 +326,26 @@ void FormRef::showStageAction()
 
       dialog_->destroy.connect(slot(this, &FormRef::free));
 
-      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::update));
+      u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::updateSlot));
       h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide));
     }
 }
 
+void FormRef::updateSlot(bool buffchanged)
+{
+  if (buffchanged) hide();
+}
+
 void FormRef::hide()
 {
-  if (dialog_!=NULL) mainAppWin->remove_action();
+  if (dialog_!=0) mainAppWin->remove_action();
 }
 
 void FormRef::free()
 {
-  if (dialog_!=NULL)
+  if (dialog_!=0)
     {
-      dialog_ = NULL;
+      dialog_ = 0;
       u_.disconnect();
       h_.disconnect();
       inset_ = 0;
@@ -359,7 +366,7 @@ void FormRef::gotoRef()
     }
   case GOBACK:
     {
-      lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
+      lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
 
       gototype_ = GOREF;
       b_goto->set_text(GOTO_REF_LABEL);
@@ -389,6 +396,7 @@ void FormRef::apply()
     {
       lv_->getLyXFunc()->Dispatch(LFUN_REF_INSERT,
                                  params.getAsString());
+      lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
     }
 
   // save configuration