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"
17 namespace Inkscape {
18 namespace Extension {
20 /** \brief Creates a new preference dialog for extension preferences
21 \param name Name of the Extension who's dialog this is
22 \param help The help string for the extension (NULL if none)
23 \param controls The extension specific widgets in the dialog
25 This function initializes the dialog with the name of the extension
26 in the title. It adds a few buttons and sets up handlers for
27 them. It also places the passed in widgets into the dialog.
28 */
29 PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls) :
30 Gtk::Dialog::Dialog(_(name.c_str()), true, true), _help(help), _name(name)
31 {
32 // I'm leaving the following in here as I'm perhaps missing something
33 /* A hack to internationalize the title properly */
34 //gchar * title = g_strdup_printf("%s", name.c_str());
35 //this->set_title(title);
36 //g_free(title);
38 Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
39 hbox->pack_start(*controls, true, true, 6);
40 hbox->show();
41 this->get_vbox()->pack_start(*hbox, true, true, 6);
44 /*
45 Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
46 if (_help == NULL)
47 help_button->set_sensitive(false);
48 */
49 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
51 Gtk::Button * ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
52 set_default_response(Gtk::RESPONSE_OK);
53 ok->grab_focus();
55 GtkWidget *dlg = GTK_WIDGET(gobj());
56 sp_transientize(dlg);
58 return;
59 }
61 /** \brief Runs the dialog
62 \return The response to the dialog
64 This function overrides the run function in the GTKmm dialog
65 class, but basically it only calls it. This function only
66 handles the \c Gtk::RESPONSE_HELP return, and in that case it
67 brings up the help window. All other return values are returned
68 to the calling function.
69 */
70 int
71 PrefDialog::run (void) {
72 int resp = Gtk::RESPONSE_HELP;
73 while (resp == Gtk::RESPONSE_HELP) {
74 resp = Gtk::Dialog::run();
75 if (resp == Gtk::RESPONSE_HELP) {
77 }
78 }
79 return resp;
80 }
82 }; }; /* namespace Inkscape, Extension */
84 /*
85 Local Variables:
86 mode:c++
87 c-file-style:"stroustrup"
88 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
89 indent-tabs-mode:nil
90 fill-column:99
91 End:
92 */
93 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :