summaryrefslogtreecommitdiffstats
path: root/src/extension/prefdialog.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-07-21 13:24:05 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-08-31 14:50:38 +0000
commit7311f3ac5161a4d53cf2ed7e0a5a97993f646321 (patch)
tree050dd572bffca377fd2d510597a28ccb8080fb1c /src/extension/prefdialog.cpp
parentOnly register desktop on Dbus once (diff)
downloadinkscape-7311f3ac5161a4d53cf2ed7e0a5a97993f646321.tar.gz
inkscape-7311f3ac5161a4d53cf2ed7e0a5a97993f646321.zip
Move prefdialog to own directory
Diffstat (limited to 'src/extension/prefdialog.cpp')
-rw-r--r--src/extension/prefdialog.cpp276
1 files changed, 0 insertions, 276 deletions
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
deleted file mode 100644
index de58545fb..000000000
--- a/src/extension/prefdialog.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Authors:
- * Ted Gould <ted@gould.cx>
- *
- * Copyright (C) 2005-2008 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#include "prefdialog.h"
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/separator.h>
-#include <glibmm/i18n.h>
-
-#include "ui/dialog-events.h"
-#include "xml/repr.h"
-
-// Used to get SP_ACTIVE_DESKTOP
-#include "inkscape.h"
-#include "desktop.h"
-#include "document.h"
-#include "document-undo.h"
-
-#include "effect.h"
-#include "implementation/implementation.h"
-
-#include "execution-env.h"
-#include "param/parameter.h"
-
-
-namespace Inkscape {
-namespace Extension {
-
-
-/** \brief Creates a new preference dialog for extension preferences
- \param name Name of the Extension whose dialog this is
- \param help The help string for the extension (NULL if none)
- \param controls The extension specific widgets in the dialog
-
- This function initializes the dialog with the name of the 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, Effect * effect) :
- Gtk::Dialog(_(name.c_str()), true),
- _help(help),
- _name(name),
- _button_ok(nullptr),
- _button_cancel(nullptr),
- _button_preview(nullptr),
- _param_preview(nullptr),
- _effect(effect),
- _exEnv(nullptr)
-{
- this->set_default_size(0,0); // we want the window to be as small as possible instead of clobbering up space
-
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
- if (controls == nullptr) {
- if (_effect == nullptr) {
- std::cout << "AH!!! No controls and no effect!!!" << std::endl;
- return;
- }
- controls = _effect->get_imp()->prefs_effect(_effect, SP_ACTIVE_DESKTOP, &_signal_param_change, nullptr);
- _signal_param_change.connect(sigc::mem_fun(this, &PrefDialog::param_change));
- }
-
- hbox->pack_start(*controls, true, true, 0);
- hbox->show();
-
- this->get_content_area()->pack_start(*hbox, true, true, 0);
-
- /*
- Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
- if (_help == NULL)
- help_button->set_sensitive(false);
- */
- _button_cancel = add_button(_effect == nullptr ? _("_Cancel") : _("_Close"), Gtk::RESPONSE_CANCEL);
- _button_ok = add_button(_effect == nullptr ? _("_OK") : _("_Apply"), Gtk::RESPONSE_OK);
- set_default_response(Gtk::RESPONSE_OK);
- _button_ok->grab_focus();
-
- if (_effect != nullptr && !_effect->no_live_preview) {
- if (_param_preview == nullptr) {
- XML::Document * doc = sp_repr_read_mem(live_param_xml, strlen(live_param_xml), nullptr);
- if (doc == nullptr) {
- std::cout << "Error encountered loading live parameter XML !!!" << std::endl;
- return;
- }
- _param_preview = Parameter::make(doc->root(), _effect);
- }
-
- auto sep = Gtk::manage(new Gtk::Separator());
- sep->show();
-
- this->get_content_area()->pack_start(*sep, false, false, Parameter::GUI_BOX_SPACING);
-
- hbox = Gtk::manage(new Gtk::HBox());
- hbox->set_border_width(Parameter::GUI_BOX_MARGIN);
- _button_preview = _param_preview->get_widget(nullptr, nullptr, &_signal_preview);
- _button_preview->show();
- hbox->pack_start(*_button_preview, true, true, 0);
- hbox->show();
-
- this->get_content_area()->pack_start(*hbox, false, false, 0);
-
- Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview);
- if (hbox != nullptr) {
- _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front());
- }
-
- preview_toggle();
- _signal_preview.connect(sigc::mem_fun(this, &PrefDialog::preview_toggle));
- }
-
- // Set window modality for effects that don't use live preview
- if (_effect != nullptr && _effect->no_live_preview) {
- set_modal(false);
- }
-
- GtkWidget *dlg = GTK_WIDGET(gobj());
- sp_transientize(dlg);
-
- return;
-}
-
-PrefDialog::~PrefDialog ( )
-{
- if (_param_preview != nullptr) {
- delete _param_preview;
- _param_preview = nullptr;
- }
-
- if (_exEnv != nullptr) {
- _exEnv->cancel();
- delete _exEnv;
- _exEnv = nullptr;
- _effect->set_execution_env(_exEnv);
- }
-
- if (_effect != nullptr) {
- _effect->set_pref_dialog(nullptr);
- }
-
- return;
-}
-
-#if 0
-/** \brief Runs the dialog
- \return The response to the dialog
-
- This function overrides the run function in the GTKmm dialog
- class, but basically it only calls it. This function only
- handles the \c Gtk::RESPONSE_HELP return, and in that case it
- brings up the help window. All other return values are returned
- to the calling function.
-*/
-int
-PrefDialog::run (void) {
- int resp = Gtk::RESPONSE_HELP;
- while (resp == Gtk::RESPONSE_HELP) {
- resp = Gtk::Dialog::run();
- if (resp == Gtk::RESPONSE_HELP) {
- /*
- if (_helpDialog == NULL) {
- _helpDialog = new HelpDialog(_help);
- }
- */
- }
- }
- return resp;
-}
-#endif
-
-void
-PrefDialog::preview_toggle () {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- SPDocument *document = SP_ACTIVE_DOCUMENT;
- bool modified = document->isModifiedSinceSave();
- if(_param_preview->get_bool(nullptr, nullptr)) {
- if (_exEnv == nullptr) {
- set_modal(true);
- _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, nullptr, false, false);
- _effect->set_execution_env(_exEnv);
- _exEnv->run();
- }
- } else {
- set_modal(false);
- if (_exEnv != nullptr) {
- _exEnv->cancel();
- _exEnv->undo();
- _exEnv->reselect();
- delete _exEnv;
- _exEnv = nullptr;
- _effect->set_execution_env(_exEnv);
- }
- }
- document->setModifiedSinceSave(modified);
-}
-
-void
-PrefDialog::param_change () {
- if (_exEnv != nullptr) {
- if (!_effect->loaded()) {
- _effect->set_state(Extension::STATE_LOADED);
- }
- _timersig.disconnect();
- _timersig = Glib::signal_timeout().connect(sigc::mem_fun(this, &PrefDialog::param_timer_expire),
- 250, /* ms */
- Glib::PRIORITY_DEFAULT_IDLE);
- }
-
- return;
-}
-
-bool
-PrefDialog::param_timer_expire () {
- if (_exEnv != nullptr) {
- _exEnv->cancel();
- _exEnv->undo();
- _exEnv->reselect();
- _exEnv->run();
- }
-
- return false;
-}
-
-void
-PrefDialog::on_response (int signal) {
- if (signal == Gtk::RESPONSE_OK) {
- if (_exEnv == nullptr) {
- if (_effect != nullptr) {
- _effect->effect(SP_ACTIVE_DESKTOP);
- } else {
- // Shutdown run()
- return;
- }
- } else {
- if (_exEnv->wait()) {
- _exEnv->commit();
- } else {
- _exEnv->undo();
- _exEnv->reselect();
- }
- delete _exEnv;
- _exEnv = nullptr;
- _effect->set_execution_env(_exEnv);
- }
- }
-
- if (_param_preview != nullptr) {
- _checkbox_preview->set_active(false);
- }
-
- if ((signal == Gtk::RESPONSE_CANCEL || signal == Gtk::RESPONSE_DELETE_EVENT) && _effect != nullptr) {
- delete this;
- }
- return;
-}
-
-#include "internal/clear-n_.h"
-
-const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"boolean\" _gui-text=\"" N_("Live preview") "\" gui-description=\"" N_("Is the effect previewed live on canvas?") "\">false</param>";
-
-}; }; /* namespace Inkscape, Extension */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :