]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gnome/FormIndex.C
Clean-up of the button controller.
[lyx.git] / src / frontends / gnome / FormIndex.C
index a4937692e7418ef6cb7ee2ea7686f4cc874ea1d3..7e787bc015edde8b09558c40af956bd2f3f439ed 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
 #include "LyXView.h"
 #include "buffer.h"
 #include "lyxfunc.h"
-
-#include "gettext.h"
-#include "Dialogs.h"
-#include "FormIndex.h"
-#include "LyXView.h"
-#include "buffer.h"
 #include "form_index.h"
-#include "lyxfunc.h"
 
 #include <gtk--/label.h>
 #include <gtk--/box.h>
 #include "mainapp.h"
 extern GLyxAppWin * mainAppWin;
 
+namespace {
+
 // configuration keys
-static string const CONF_ENTRY("FormIndex_entry");
+string const CONF_ENTRY("FormIndex_entry");
+
+} // namespace anon
+
 
 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
-       : lv_(lv), d_(d), u_(0), h_(0), ih_(0), inset_(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
@@ -63,10 +60,10 @@ FormIndex::~FormIndex()
 
 void FormIndex::showInset( InsetCommand * const inset )
 {
-  if( dialog_!=NULL || inset == 0 ) return;
+  if( dialog_!=0 || inset == 0 ) return;
   
   inset_ = inset;
-  ih_ = inset_->hide.connect(slot(this, &FormIndex::hide));
+  ih_ = inset_->hideDialog.connect(slot(this, &FormIndex::hide));
   
   params = inset->params();
   show();
@@ -74,7 +71,7 @@ void FormIndex::showInset( InsetCommand * const inset )
 
 void FormIndex::createInset( string const & arg )
 {
-  if( dialog_!=NULL ) return;
+  if( dialog_!=0 ) return;
   
   params.setFromString( arg );
   show();
@@ -86,7 +83,7 @@ void FormIndex::show()
     {
       using namespace Gtk::Box_Helpers;
       
-      Gtk::Label * label = manage( new Gtk::Label(N_("Keyword")) );
+      Gtk::Label * label = manage( new Gtk::Label(_("Keyword")) );
       Gtk::Box * mbox = manage( new Gtk::HBox() );
       Gtk::ButtonBox * bbox = manage( new Gtk::HButtonBox() );
       Gtk::Separator * sep = manage( new Gtk::VSeparator() );
@@ -116,7 +113,7 @@ void FormIndex::show()
 
       // packing dialog to main window
       dialog_ = mbox;
-      mainAppWin->add_action(*dialog_, N_(" Index "));
+      mainAppWin->add_action(*dialog_, _(" Index "));
 
       // setting focus
       GTK_WIDGET_SET_FLAGS (GTK_WIDGET(keyword_->get_entry()->gtkobj()), GTK_CAN_DEFAULT);
@@ -131,37 +128,43 @@ void FormIndex::show()
 
       dialog_->destroy.connect(slot(this, &FormIndex::free));
 
-      u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update));
+      u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::updateSlot));
       h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide));
 
-      update();  // make sure its up-to-date
+      updateSlot();  // make sure its up-to-date
     }
 }
-      
-void FormIndex::update()
+
+void FormIndex::updateSlot(bool switched)
 {
-  if (dialog_ != NULL &&
+  if (switched)
+    {
+      hide();
+      return;
+    }
+  
+  if (dialog_ != 0 &&
       lv_->view()->available())
     {
       keyword_->get_entry()->set_text(params.getContents().c_str());
-  
+      
       bool sens = (!(lv_->buffer()->isReadonly()));
-
+      
       keyword_->set_sensitive(sens);
       b_ok->set_sensitive(sens);
     }
 }
-
+      
 void FormIndex::hide()
 {
-  if (dialog_!=NULL) mainAppWin->remove_action();
+  if (dialog_!=0) mainAppWin->remove_action();
 }
 
 void FormIndex::free()
 {
-  if (dialog_!=NULL)
+  if (dialog_!=0)
     {
-      dialog_ = NULL;
+      dialog_ = 0;
       u_.disconnect();
       h_.disconnect();
       inset_ = 0;
@@ -187,7 +190,7 @@ void FormIndex::apply()
   else
     {
       lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
-                                  params.getAsString().c_str() );
+                                  params.getAsString() );
     }
 
   // save history