1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2005-2007 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
10 #include <gtkmm/stock.h>
11 #include <gtkmm/checkbutton.h>
12 #include <gtkmm/separator.h>
13 #include <glibmm/i18n.h>
15 #include "../dialogs/dialog-events.h"
17 #include "prefdialog.h"
19 namespace Inkscape {
20 namespace Extension {
23 /** \brief Creates a new preference dialog for extension preferences
24 \param name Name of the Extension who's dialog this is
25 \param help The help string for the extension (NULL if none)
26 \param controls The extension specific widgets in the dialog
28 This function initializes the dialog with the name of the extension
29 in the title. It adds a few buttons and sets up handlers for
30 them. It also places the passed in widgets into the dialog.
31 */
32 PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv) :
33 Gtk::Dialog::Dialog(_(name.c_str()), true, true),
34 _help(help),
35 _name(name),
36 _exEnv(exEnv),
37 _button_ok(NULL),
38 _button_cancel(NULL),
39 _button_preview(NULL),
40 _button_pinned(NULL)
41 {
42 Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
43 hbox->pack_start(*controls, true, true, 6);
44 hbox->show();
45 this->get_vbox()->pack_start(*hbox, true, true, 6);
47 if (_exEnv != NULL) {
48 Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator());
49 sep->show();
50 this->get_vbox()->pack_start(*sep, true, true, 4);
52 hbox = Gtk::manage(new Gtk::HBox());
53 _button_preview = Gtk::manage(new Gtk::CheckButton(_("Live Preview")));
54 _button_preview->show();
55 _button_pinned = Gtk::manage(new Gtk::CheckButton(_("Pin Dialog")));
56 _button_pinned->show();
57 hbox->pack_start(*_button_preview, true, true,6);
58 hbox->pack_start(*_button_pinned, true, true,6);
59 hbox->show();
60 this->get_vbox()->pack_start(*hbox, true, true, 6);
61 }
63 /*
64 Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
65 if (_help == NULL)
66 help_button->set_sensitive(false);
67 */
68 _button_cancel = add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
70 _button_ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
71 set_default_response(Gtk::RESPONSE_OK);
72 _button_ok->grab_focus();
74 GtkWidget *dlg = GTK_WIDGET(gobj());
75 sp_transientize(dlg);
77 return;
78 }
80 /** \brief Runs the dialog
81 \return The response to the dialog
83 This function overrides the run function in the GTKmm dialog
84 class, but basically it only calls it. This function only
85 handles the \c Gtk::RESPONSE_HELP return, and in that case it
86 brings up the help window. All other return values are returned
87 to the calling function.
88 */
89 int
90 PrefDialog::run (void) {
91 int resp = Gtk::RESPONSE_HELP;
92 while (resp == Gtk::RESPONSE_HELP) {
93 resp = Gtk::Dialog::run();
94 if (resp == Gtk::RESPONSE_HELP) {
95 /*
96 if (_helpDialog == NULL) {
97 _helpDialog = new HelpDialog(_help);
98 }
99 */
100 }
101 }
102 return resp;
103 }
105 void
106 PrefDialog::setPreviewState (Glib::ustring state) {
108 }
110 void
111 PrefDialog::setPinned (bool in_pin) {
112 set_modal(!in_pin);
113 }
115 #include "internal/clear-n_.h"
117 const char * PrefDialog::pinned_param_xml = "<param name=\"__pinned__\" type=\"boolean\" gui-text=\"" N_("Pin Dialog") "\" gui-description=\"" N_("Toggles whether the dialog stays for multiple executions or disappears after one") "\" scope=\"user\">false</param>";
118 const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"boolean\" gui-text=\"" N_("Live Preview") "\" gui-description=\"" N_("Controls whether the effect settings are rendered live on canvas") "\" scope=\"user\">false</param>";
120 }; }; /* namespace Inkscape, Extension */
122 /*
123 Local Variables:
124 mode:c++
125 c-file-style:"stroustrup"
126 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
127 indent-tabs-mode:nil
128 fill-column:99
129 End:
130 */
131 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :