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("Temp Title", true, true), _help(help), _name(name)
31 {
32 /* A hack to internationalize the title properly */
33 gchar * title = g_strdup_printf(_("%s Preferences"), name.c_str());
34 this->set_title(title);
35 g_free(title);
37 Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
38 hbox->pack_start(*controls, true, true, 6);
39 hbox->show();
40 this->get_vbox()->pack_start(*hbox, true, true, 6);
43 /*
44 Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
45 if (_help == NULL)
46 help_button->set_sensitive(false);
47 */
48 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
50 Gtk::Button * ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
51 set_default_response(Gtk::RESPONSE_OK);
52 ok->grab_focus();
54 GtkWidget *dlg = GTK_WIDGET(gobj());
55 sp_transientize(dlg);
57 return;
58 }
60 /** \brief Runs the dialog
61 \return The response to the dialog
63 This function overrides the run function in the GTKmm dialog
64 class, but basically it only calls it. This function only
65 handles the \c Gtk::RESPONSE_HELP return, and in that case it
66 brings up the help window. All other return values are returned
67 to the calling function.
68 */
69 int
70 PrefDialog::run (void) {
71 int resp = Gtk::RESPONSE_HELP;
72 while (resp == Gtk::RESPONSE_HELP) {
73 resp = Gtk::Dialog::run();
74 if (resp == Gtk::RESPONSE_HELP) {
76 }
77 }
78 return resp;
79 }
81 }; }; /* namespace Inkscape, Extension */
83 /*
84 Local Variables:
85 mode:c++
86 c-file-style:"stroustrup"
87 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
88 indent-tabs-mode:nil
89 fill-column:99
90 End:
91 */
92 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :