Code

r11512@tres: ted | 2006-04-24 21:36:08 -0700
[inkscape.git] / src / extension / prefdialog.cpp
index 40eb037b6712e8d87c2c616770f2d705e4a3fe89..3058b939f5df0e66a347a4c09dc83d2e87709641 100644 (file)
@@ -2,7 +2,7 @@
  * Authors:
  *   Ted Gould <ted@gould.cx>
  *
- * Copyright (C) 2005 Authors
+ * Copyright (C) 2005-2006 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 namespace Inkscape {
 namespace Extension {
 
-PrefDialog::PrefDialog (Glib::ustring name, Gtk::Widget * controls) :
-    Gtk::Dialog::Dialog(name + _(" Preferences"), true, true)
+/** \brief  Creates a new preference dialog for extension preferences
+    \param  name  Name of the Extension who's dialog this is
+    \param  help  The help string for the extension (NULL if none)
+    \param  controls  The extension specific widgets in the dialog
+    
+    This function initializes the dialog with the name of the extension
+    in the title.  It adds a few buttons and sets up handlers for
+    them.  It also places the passed in widgets into the dialog.
+*/
+PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls) :
+    Gtk::Dialog::Dialog("Temp Title", true, true), _help(help), _name(name)
 {
-    this->get_vbox()->pack_start(*controls, true, true, 5);
+    /* A hack to internationalize the title properly */
+    gchar * title = g_strdup_printf(_("%s Preferences"), name.c_str());
+    this->set_title(title);
+    g_free(title);
+
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
+    hbox->pack_start(*controls, true, true, 6);
+    hbox->show();
+    this->get_vbox()->pack_start(*hbox, true, true, 6);
 
+
+    /*
+    Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
+    if (_help == NULL)
+        help_button->set_sensitive(false);
+    */
     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
 
     Gtk::Button * ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
@@ -34,6 +57,27 @@ PrefDialog::PrefDialog (Glib::ustring name, Gtk::Widget * controls) :
     return;
 }
 
+/** \brief  Runs the dialog
+    \return The response to the dialog
+
+    This function overrides the run function in the GTKmm dialog
+    class, but basically it only calls it.  This function only
+    handles the \c Gtk::RESPONSE_HELP return, and in that case it
+    brings up the help window.  All other return values are returned
+    to the calling function.
+*/
+int
+PrefDialog::run (void) {
+    int resp = Gtk::RESPONSE_HELP;
+    while (resp == Gtk::RESPONSE_HELP) {
+        resp = Gtk::Dialog::run();
+        if (resp == Gtk::RESPONSE_HELP) {
+
+        }
+    }
+    return resp;
+}
+
 }; }; /* namespace Inkscape, Extension */
 
 /*