#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"
#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)
+ : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(NULL)
{
// let the dialog be shown
// These are permanent connections so we won't bother
{
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()
void FormIndex::hide()
{
- if (dialog_!=NULL) dialog_->destroy();
+ if (dialog_!=NULL) mainAppWin->remove_action();
}
void FormIndex::free()
else
{
lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
- params.getAsString().c_str() );
+ params.getAsString() );
}
+
+ // save history
+ keyword_->save_history();
+
+ // hide the dialog
+ hide();
}
+