1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2005-2006 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
10 #include <gtkmm/stock.h>
11 #include <glibmm/i18n.h>
13 #include "../dialogs/dialog-events.h"
15 #include "prefdialog.h"
16 #include "helpdialog.h"
18 namespace Inkscape {
19 namespace Extension {
21 /** \brief Creates a new preference dialog for extension preferences
22 \param name Name of the Extension who's dialog this is
23 \param help The help string for the extension (NULL if none)
24 \param controls The extension specific widgets in the dialog
26 This function initializes the dialog with the name of the extension
27 in the title. It adds a few buttons and sets up handlers for
28 them. It also places the passed in widgets into the dialog.
29 */
30 PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls) :
31 Gtk::Dialog::Dialog(name + _(" Preferences"), true, true), _help(help), _name(name)
32 {
33 Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
34 hbox->pack_start(*controls, true, true, 6);
35 hbox->show();
36 this->get_vbox()->pack_start(*hbox, true, true, 6);
38 /*
39 Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
40 if (_help == NULL)
41 help_button->set_sensitive(false);
42 */
43 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
45 Gtk::Button * ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
46 set_default_response(Gtk::RESPONSE_OK);
47 ok->grab_focus();
49 GtkWidget *dlg = GTK_WIDGET(gobj());
50 sp_transientize(dlg);
52 return;
53 }
55 /** \brief Runs the dialog
56 \return The response to the dialog
58 This function overrides the run function in the GTKmm dialog
59 class, but basically it only calls it. This function only
60 handles the \c Gtk::RESPONSE_HELP return, and in that case it
61 brings up the help window. All other return values are returned
62 to the calling function.
63 */
64 int
65 PrefDialog::run (void) {
66 int resp = Gtk::RESPONSE_HELP;
67 while (resp == Gtk::RESPONSE_HELP) {
68 resp = Gtk::Dialog::run();
69 if (resp == Gtk::RESPONSE_HELP) {
70 HelpDialog help(_name, _help);
71 help.run();
72 help.hide();
73 }
74 }
75 return resp;
76 }
78 }; }; /* namespace Inkscape, Extension */
80 /*
81 Local Variables:
82 mode:c++
83 c-file-style:"stroustrup"
84 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
85 indent-tabs-mode:nil
86 fill-column:99
87 End:
88 */
89 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :