From: gouldtj Date: Sat, 1 Sep 2007 04:30:40 +0000 (+0000) Subject: r16267@tres: ted | 2007-08-16 23:04:38 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=597994bcb1845cfdb124a40c4a5493be413b8432;p=inkscape.git r16267@tres: ted | 2007-08-16 23:04:38 -0700 Basic functionality. Still doesn't cancel all of the execution environment stuff. But the other parts are working. Good checkin point. --- diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 547eb5a30..b21d7a0f5 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -92,7 +92,7 @@ ExecutionEnv::createPrefsDialog (Gtk::Widget * controls) { delete _visibleDialog; } - _visibleDialog = new PrefDialog(_effect->get_name(), _effect->get_help(), controls, this); + _visibleDialog = new PrefDialog(_effect->get_name(), _effect->get_help(), controls, this, _effect); _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::preferencesResponse)); _visibleDialog->show(); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 38f5be4a6..c9c218b4d 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -15,6 +15,10 @@ #include "../dialogs/dialog-events.h" #include "xml/repr.h" +// Used to get SP_ACTIVE_DESKTOP +#include "inkscape.h" +#include "desktop.h" + #include "preferences.h" #include "effect.h" @@ -34,7 +38,7 @@ namespace Extension { in the title. It adds a few buttons and sets up handlers for them. It also places the passed in widgets into the dialog. */ -PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv) : +PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, ExecutionEnv * exEnv, Effect * effect) : Gtk::Dialog::Dialog(_(name.c_str()), true, true), _help(help), _name(name), @@ -42,13 +46,31 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _button_ok(NULL), _button_cancel(NULL), _button_preview(NULL), - _button_pinned(NULL) + _button_pinned(NULL), + _param_preview(NULL), + _param_pinned(NULL), + _effect(effect) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); hbox->pack_start(*controls, true, true, 6); hbox->show(); this->get_vbox()->pack_start(*hbox, true, true, 6); + /* + Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP); + if (_help == NULL) + help_button->set_sensitive(false); + */ + _button_cancel = add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + _button_cancel->set_use_stock(true); + + _button_ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); + _button_ok->set_use_stock(true); + set_default_response(Gtk::RESPONSE_OK); + _button_ok->grab_focus(); + + // If we're working with an effect that can be live and + // the dialog can be pinned, put those options in too if (_exEnv != NULL) { Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator()); sep->show(); @@ -63,19 +85,13 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co hbox->pack_start(*_button_pinned, true, true,6); hbox->show(); this->get_vbox()->pack_start(*hbox, true, true, 6); - } - /* - Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP); - if (_help == NULL) - help_button->set_sensitive(false); - */ - _button_cancel = add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + preview_toggle(); + pinned_toggle(); + _signal_preview.connect(sigc::mem_fun(this, &PrefDialog::preview_toggle)); + _signal_pinned.connect(sigc::mem_fun(this, &PrefDialog::pinned_toggle)); + } - _button_ok = add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); - set_default_response(Gtk::RESPONSE_OK); - _button_ok->grab_focus(); - GtkWidget *dlg = GTK_WIDGET(gobj()); sp_transientize(dlg); @@ -125,8 +141,46 @@ PrefDialog::setPreviewState (Glib::ustring state) { } void -PrefDialog::setPinned (bool in_pin) { - set_modal(!in_pin); +PrefDialog::preview_toggle (void) { + if(_param_preview->get_bool(NULL, NULL) && !_param_pinned->get_bool(NULL, NULL)) { + //std::cout << "Live Preview" << std::endl; + } else { + //std::cout << "No Preview" << std::endl; + } +} + +void +PrefDialog::pinned_toggle (void) { + if (_param_pinned->get_bool(NULL, NULL)) { + _button_preview->set_sensitive(false); + preview_toggle(); + set_modal(false); + + _button_ok->set_label(Gtk::Stock::EXECUTE.id); + _button_cancel->set_label(Gtk::Stock::CLOSE.id); + } else { + _button_preview->set_sensitive(true); + set_modal(true); + + _button_ok->set_label(Gtk::Stock::OK.id); + _button_cancel->set_label(Gtk::Stock::CANCEL.id); + } +} + +void +PrefDialog::on_response (int signal) { + if (!_param_pinned->get_bool(NULL, NULL)) { + // Not my job if we're not pinned + // It's the execution environment's job + return; + } + + if (signal == Gtk::RESPONSE_OK) { + _effect->effect(SP_ACTIVE_DESKTOP); + } + + this->hide(); + delete this; } #include "internal/clear-n_.h" diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h index 1965b7e96..90dcb14ae 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog.h @@ -47,15 +47,22 @@ class PrefDialog : public Gtk::Dialog { /** \brief XML to define the live effects parameter on the dialog */ static const char * live_param_xml; + Effect * _effect; + + void preview_toggle(void); + void pinned_toggle(void); + + void on_response (int signal); + public: PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, - ExecutionEnv * exEnv = NULL); + ExecutionEnv * exEnv = NULL, + Effect * effect = NULL); int run (void); void setPreviewState (Glib::ustring state); - void setPinned (bool in_pin); };