Code

r11140@tres: ted | 2006-03-27 21:37:00 -0800
[inkscape.git] / src / extension / prefdialog.cpp
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
24     
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 + _(" Preferences"), true, true), _help(help), _name(name)
31 {
32     Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
33     hbox->pack_start(*controls, true, true, 6);
34     hbox->show();
35     this->get_vbox()->pack_start(*hbox, true, true, 6);
37     /*
38     Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
39     if (_help == NULL)
40         help_button->set_sensitive(false);
41     */
42     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
44     Gtk::Button * ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
45     set_default_response(Gtk::RESPONSE_OK);
46     ok->grab_focus();
47     
48     GtkWidget *dlg = GTK_WIDGET(gobj());
49     sp_transientize(dlg);
51     return;
52 }
54 /** \brief  Runs the dialog
55     \return The response to the dialog
57     This function overrides the run function in the GTKmm dialog
58     class, but basically it only calls it.  This function only
59     handles the \c Gtk::RESPONSE_HELP return, and in that case it
60     brings up the help window.  All other return values are returned
61     to the calling function.
62 */
63 int
64 PrefDialog::run (void) {
65     int resp = Gtk::RESPONSE_HELP;
66     while (resp == Gtk::RESPONSE_HELP) {
67         resp = Gtk::Dialog::run();
68         if (resp == Gtk::RESPONSE_HELP) {
70         }
71     }
72     return resp;
73 }
75 }; }; /* namespace Inkscape, Extension */
77 /*
78   Local Variables:
79   mode:c++
80   c-file-style:"stroustrup"
81   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82   indent-tabs-mode:nil
83   fill-column:99
84   End:
85 */
86 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :