diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2012-01-08 18:44:57 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2012-01-08 18:44:57 +0000 |
| commit | 76f22d76e691070e082914b61ff2b2f478350587 (patch) | |
| tree | aa28f63602107c3d4576acb08997e713f0a6233f /src | |
| parent | Unweirdification of Preferences dialog's menu (Bug #259480). (diff) | |
| download | inkscape-76f22d76e691070e082914b61ff2b2f478350587.tar.gz inkscape-76f22d76e691070e082914b61ff2b2f478350587.zip | |
Object properties dialog now dockable (derived from Inkscape::UI:Widget::Panel as opposed to Gtk::Widget)
(bzr r10862)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dialogs/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/dialogs/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/ui/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/ui/context-menu.cpp | 5 | ||||
| -rw-r--r-- | src/ui/dialog/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/ui/dialog/dialog-manager.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/object-properties.cpp (renamed from src/dialogs/item-properties.cpp) | 208 | ||||
| -rw-r--r-- | src/ui/dialog/object-properties.h (renamed from src/dialogs/item-properties.h) | 35 | ||||
| -rw-r--r-- | src/verbs.cpp | 5 |
9 files changed, 74 insertions, 189 deletions
diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index 6586b78af..1f2efecc3 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -4,7 +4,6 @@ set(dialogs_SRC dialog-events.cpp export.cpp find.cpp - item-properties.cpp object-attributes.cpp spellcheck.cpp text-edit.cpp diff --git a/src/dialogs/Makefile_insert b/src/dialogs/Makefile_insert index 8d7d3f21d..c55b03775 100644 --- a/src/dialogs/Makefile_insert +++ b/src/dialogs/Makefile_insert @@ -9,8 +9,6 @@ ink_common_sources += \ dialogs/export.h \ dialogs/find.cpp \ dialogs/find.h \ - dialogs/item-properties.cpp \ - dialogs/item-properties.h \ dialogs/object-attributes.cpp \ dialogs/object-attributes.h \ dialogs/spellcheck.cpp \ diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index e697fba99..74802cab3 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -48,6 +48,7 @@ set(ui_SRC dialog/layer-properties.cpp dialog/layers.cpp dialog/livepatheffect-editor.cpp + dialog/object-properties.cpp dialog/memory.cpp dialog/messages.cpp dialog/ocaldialogs.cpp diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 331026aac..f8ec1eed1 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -52,10 +52,10 @@ void sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) #include "desktop-handles.h" #include "selection.h" #include "selection-chemistry.h" -#include "dialogs/item-properties.h" #include "dialogs/object-attributes.h" #include "dialogs/text-edit.h" #include "dialogs/spellcheck.h" +#include "ui/dialog/object-properties.h" #include "sp-path.h" #include "sp-clippath.h" @@ -189,7 +189,8 @@ static void sp_item_properties(GtkMenuItem *menuitem, SPItem *item) sp_desktop_selection(desktop)->set(item); - sp_item_dialog(); + // sp_item_dialog(); + desktop->_dlg_mgr->showDialog("ObjectProperties"); } diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 5d6592897..701066b20 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -64,6 +64,8 @@ ink_common_sources += \ ui/dialog/messages.h \ ui/dialog/ocaldialogs.cpp \ ui/dialog/ocaldialogs.h \ + ui/dialog/object-properties.cpp \ + ui/dialog/object-properties.h \ ui/dialog/panel-dialog.h \ ui/dialog/print.cpp \ ui/dialog/print.h \ diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index cba0cf508..95486c5e3 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -45,6 +45,8 @@ //#include "ui/dialog/print-colors-preview-dialog.h" #include "util/ege-appear-time-tracker.h" #include "preferences.h" +#include "ui/dialog/object-properties.h" + #ifdef ENABLE_SVG_FONTS #include "ui/dialog/svg-fonts-dialog.h" @@ -106,6 +108,7 @@ DialogManager::DialogManager() { registerFactory("LivePathEffect", &create<LivePathEffectEditor, FloatingBehavior>); registerFactory("Memory", &create<Memory, FloatingBehavior>); registerFactory("Messages", &create<Messages, FloatingBehavior>); + registerFactory("ObjectProperties", &create<ObjectProperties, FloatingBehavior>); // registerFactory("PrintColorsPreviewDialog", &create<PrintColorsPreviewDialog, FloatingBehavior>); registerFactory("Script", &create<ScriptDialog, FloatingBehavior>); #ifdef ENABLE_SVG_FONTS @@ -134,6 +137,7 @@ DialogManager::DialogManager() { registerFactory("LivePathEffect", &create<LivePathEffectEditor, DockBehavior>); registerFactory("Memory", &create<Memory, DockBehavior>); registerFactory("Messages", &create<Messages, DockBehavior>); + registerFactory("ObjectProperties", &create<ObjectProperties, DockBehavior>); // registerFactory("PrintColorsPreviewDialog", &create<PrintColorsPreviewDialog, DockBehavior>); registerFactory("Script", &create<ScriptDialog, DockBehavior>); #ifdef ENABLE_SVG_FONTS diff --git a/src/dialogs/item-properties.cpp b/src/ui/dialog/object-properties.cpp index 9e10675a2..773906174 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -21,85 +21,21 @@ #include "../desktop-handles.h" #include "../document.h" -#include "../helper/window.h" -#include "../inkscape.h" -#include "../interface.h" -#include "../macros.h" -#include "../preferences.h" -#include "../selection.h" -#include "../sp-item.h" -#include "../verbs.h" -#include "../widgets/sp-widget.h" -#include "item-properties.h" +#include "object-properties.h" -using Inkscape::DocumentUndo; -#define MIN_ONSCREEN_DISTANCE 50 +namespace Inkscape { +namespace UI { +namespace Dialog { -static SPItemDialog *spid = NULL; - -static void sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ); -static void sp_item_widget_modify_selection (SPWidget *spw, Inkscape::Selection *selection, guint flags, GtkWidget *itemw); -static void sp_item_widget_change_selection (SPWidget *spw, Inkscape::Selection *selection, GtkWidget *itemw); - -/** - * SPItemDialog callback for closing the dialog. - */ -static void sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/ ) -{ - if (spid) - { - delete spid; - spid = NULL; - } -} +void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, ObjectProperties *dial); /** - * SPItemDialog callback for a modification of the selected object (e.g. size, color, fill, etc.). + * Create a new static instance of the object properties dialog. */ -static void sp_item_widget_modify_selection( SPWidget */*spw*/, - Inkscape::Selection */*selection*/, - guint /*flags*/, - GtkWidget */*itemw*/ ) -{ - if (spid) - { - spid->widget_setup(); - } -} - -/** - * SPItemDialog callback for the selection of an other object. - */ -static void sp_item_widget_change_selection ( SPWidget */*spw*/, - Inkscape::Selection */*selection*/, - GtkWidget */*itemw*/ ) -{ - if (spid) - { - spid->widget_setup(); - } -} - - -/** - * Create a new static instance of the items dialog. - */ -void sp_item_dialog(void) -{ - if (spid == NULL) { - spid = new SPItemDialog(); - } -} - -SPItemDialog::SPItemDialog (void) : - prefs_path("/dialogs/object/"), - x(-1000),// impossible original value to make sure they are read from prefs - y(-1000),// impossible original value to make sure they are read from prefs - w(0), - h(0), +ObjectProperties::ObjectProperties (void) : + UI::Widget::Panel ("", "/dialogs/object/", SP_VERB_DIALOG_ITEM), blocked (false), - closing (false), TopTable (3, 4, false), LabelID(_("_ID:"), 1), LabelLabel(_("_Label:"), 1), @@ -114,45 +50,6 @@ SPItemDialog::SPItemDialog (void) : attrTable(), CurrentItem(0) { - //intializing dialog - gchar title[500]; - sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_ITEM), title); - window = Inkscape::UI::window_new (title, true); - GtkWidget *dlg; - dlg = (GtkWidget*)window->gobj(); - - //reading dialog position from preferences - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (x == -1000 || y == -1000) { - x = prefs->getInt(prefs_path + "x", -1000); - y = prefs->getInt(prefs_path + "y", -1000); - } - if (w ==0 || h == 0) { - w = prefs->getInt(prefs_path + "w", 0); - h = prefs->getInt(prefs_path + "h", 0); - } - if (w && h) { - gtk_window_resize ((GtkWindow *) dlg, w, h); - } - if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) { - gtk_window_move ((GtkWindow *) dlg, x, y); - } else { - gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); - } - - sp_transientize (dlg); - wd.win = dlg; - wd.stop = 0; - - //set callback for the new dialog - g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); - // g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_item_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); - //initialize labels for the table at the bottom of the dialog int_labels.push_back("onclick"); int_labels.push_back("onmouseover"); @@ -168,50 +65,23 @@ SPItemDialog::SPItemDialog (void) : MakeWidget(); } -SPItemDialog::~SPItemDialog (void) +ObjectProperties::~ObjectProperties (void) { - if (closing) - { - return; - } - blocked = true; - closing = true; - gtk_window_get_position ((GtkWindow *) wd.win, &x, &y); - gtk_window_get_size ((GtkWindow *) wd.win, &w, &h); - - if (x<0) x=0; - if (y<0) y=0; - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt(prefs_path + "x", x); - prefs->setInt(prefs_path + "y", y); - prefs->setInt(prefs_path + "w", w); - prefs->setInt(prefs_path + "h", h); - - sp_signal_disconnect_by_data (INKSCAPE, wd.win); - sp_signal_disconnect_by_data (INKSCAPE, &wd); - if (window) - { - //should actually always be true, but for safety check - delete window; - window = NULL; - wd.win = NULL; - } } -void SPItemDialog::MakeWidget(void) +void ObjectProperties::MakeWidget(void) { - // if (gtk_widget_get_visible (GTK_WIDGET(spw))) { - g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (sp_item_widget_modify_selection), wd.win); - g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (sp_item_widget_change_selection), wd.win); - g_signal_connect (G_OBJECT (INKSCAPE), "set_selection", G_CALLBACK (sp_item_widget_change_selection), wd.win); - // } - - window->add(vb); + // g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (sp_item_widget_modify_selection), wd.win); + // g_signal_connect (G_OBJECT (INKSCAPE), "set_selection", G_CALLBACK (sp_item_widget_change_selection), wd.win); + g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); + + Gtk::Box *contents = _getContents(); + contents->set_spacing(0); + TopTable.set_border_width(4); TopTable.set_row_spacings(4); TopTable.set_col_spacings(4); - vb.pack_start (TopTable, true, true, 0); + contents->pack_start (TopTable, true, true, 0); /* Create the label for the object id */ LabelID.set_alignment (1, 0.5); @@ -228,7 +98,7 @@ void SPItemDialog::MakeWidget(void) LabelID.set_mnemonic_widget (EntryID); // pressing enter in the id field is the same as clicking Set: - EntryID.signal_activate().connect(sigc::mem_fun(this, &SPItemDialog::label_changed)); + EntryID.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); // focus is in the id field initially: EntryID.grab_focus(); @@ -247,7 +117,7 @@ void SPItemDialog::MakeWidget(void) LabelLabel.set_mnemonic_widget (EntryLabel); // pressing enter in the label field is the same as clicking Set: - EntryLabel.signal_activate().connect(sigc::mem_fun(this, &SPItemDialog::label_changed)); + EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the label for the object title */ LabelTitle.set_alignment (1, 0.5); @@ -281,7 +151,7 @@ void SPItemDialog::MakeWidget(void) TextViewDescription.add_mnemonic_label(LabelDescription); /* Check boxes */ - vb.pack_start (HBoxCheck, FALSE, FALSE, 0); + contents->pack_start (HBoxCheck, FALSE, FALSE, 0); CheckTable.set_border_width(0); HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 10); @@ -290,7 +160,7 @@ void SPItemDialog::MakeWidget(void) CheckTable.attach (CBHide, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); - CBHide.signal_toggled().connect(sigc::mem_fun(this, &SPItemDialog::hidden_toggled)); + CBHide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::hidden_toggled)); /* Lock */ // TRANSLATORS: "Lock" is a verb here @@ -298,21 +168,21 @@ void SPItemDialog::MakeWidget(void) CheckTable.attach (CBLock, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); - CBLock.signal_toggled().connect(sigc::mem_fun(this, &SPItemDialog::sensitivity_toggled)); + CBLock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::sensitivity_toggled)); /* Button for setting the object's id, label, title and description. */ HBoxCheck.pack_start (BSet, TRUE, TRUE, 10); - BSet.signal_clicked().connect(sigc::mem_fun(this, &SPItemDialog::label_changed)); + BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the frame for interactivity options */ EInteractivity.set_label_widget (LabelInteractivity); - vb.pack_start (EInteractivity, FALSE, FALSE, 0); - window->show_all (); + contents->pack_start (EInteractivity, FALSE, FALSE, 0); + show_all (); widget_setup(); } -void SPItemDialog::widget_setup(void) +void ObjectProperties::widget_setup(void) { if (blocked) { @@ -320,16 +190,17 @@ void SPItemDialog::widget_setup(void) } Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP); + Gtk::Box *contents = _getContents(); if (!selection->singleItem()) { - vb.set_sensitive (false); + contents->set_sensitive (false); CurrentItem = NULL; //no selection anymore or multiple objects selected, means that we need //to close the connections to the previously selected object attrTable.clear(); return; } else { - vb.set_sensitive (true); + contents->set_sensitive (true); } SPItem *item = selection->singleItem(); @@ -402,7 +273,7 @@ void SPItemDialog::widget_setup(void) blocked = false; } -void SPItemDialog::label_changed(void) +void ObjectProperties::label_changed(void) { if (blocked) { @@ -462,7 +333,7 @@ void SPItemDialog::label_changed(void) blocked = false; } -void SPItemDialog::sensitivity_toggled (void) +void ObjectProperties::sensitivity_toggled (void) { if (blocked) { @@ -479,7 +350,7 @@ void SPItemDialog::sensitivity_toggled (void) blocked = false; } -void SPItemDialog::hidden_toggled(void) +void ObjectProperties::hidden_toggled(void) { if (blocked) { @@ -495,6 +366,19 @@ void SPItemDialog::hidden_toggled(void) CBHide.get_active()? _("Hide object") : _("Unhide object")); blocked = false; } + +/** + * ObjectProperties callback for the selection of an other object. + */ +void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, ObjectProperties *dial) +{ + dial->widget_setup(); +} + +} +} +} + /* Local Variables: mode:c++ diff --git a/src/dialogs/item-properties.h b/src/ui/dialog/object-properties.h index c41c4bd6a..2f64e9158 100644 --- a/src/dialogs/item-properties.h +++ b/src/ui/dialog/object-properties.h @@ -16,11 +16,13 @@ #include <gtk/gtk.h> #include <gtkmm.h> #include <glibmm/i18n.h> -#include "dialog-events.h" +#include "ui/widget/panel.h" #include "../widgets/sp-attribute-widget.h" -void sp_item_dialog(void); +namespace Inkscape { +namespace UI { +namespace Dialog { /** * A dialog widget to show object properties. @@ -28,10 +30,12 @@ void sp_item_dialog(void); * A widget to enter an ID, label, title and description for an object. * In addition it allows to edit the properties of an object. */ -class SPItemDialog : public Gtk::Widget { +class ObjectProperties : public Widget::Panel { public: - SPItemDialog (); - ~SPItemDialog (); + ObjectProperties (); + ~ObjectProperties (); + + static ObjectProperties &getInstance() { return *new ObjectProperties(); } /** * Updates entries and other child widgets on selection change, object modification, etc. @@ -39,20 +43,9 @@ public: void widget_setup(void); private: - Glib::ustring const prefs_path; - gint x; - gint y; - gint w; - gint h; - std::vector<Glib::ustring> int_labels; - bool blocked; - bool closing; - - Gtk::Window* window; // the window - win_data wd; - - Gtk::VBox vb; //the VBox + SPItem *CurrentItem; //to store the current item, for not wasting resources + std::vector<Glib::ustring> int_labels; Gtk::Table TopTable; //the table with the object properties Gtk::Label LabelID; //the label for the object ID @@ -75,10 +68,8 @@ private: Gtk::Label LabelInteractivity; //the label for interactivity Gtk::Expander EInteractivity; //the label for interactivity - SPAttributeTable attrTable; //the widget for showing the on... names at the bottom - SPItem *CurrentItem; //to store the current item, for not wasting resources /** * Constructor auxiliary function creating the child widgets. @@ -101,6 +92,10 @@ private: void hidden_toggled(void); }; +} +} +} + #endif /* diff --git a/src/verbs.cpp b/src/verbs.cpp index c1b1aef41..c3a2f0897 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -40,7 +40,6 @@ #include "desktop-handles.h" #include "dialogs/clonetiler.h" #include "dialogs/find.h" -#include "dialogs/item-properties.h" #include "dialogs/spellcheck.h" #include "dialogs/text-edit.h" #include "dialogs/xml-tree.h" @@ -78,6 +77,7 @@ #include "ui/dialog/inkscape-preferences.h" #include "ui/dialog/layer-properties.h" #include "ui/dialog/layers.h" +#include "ui/dialog/object-properties.h" #include "ui/dialog/swatches.h" #include "ui/icon-names.h" #include "ui/tool/node-tool.h" @@ -1845,7 +1845,8 @@ void DialogVerb::perform(SPAction *action, void *data) clonetiler_dialog(); break; case SP_VERB_DIALOG_ITEM: - sp_item_dialog(); + //sp_item_dialog(); + dt->_dlg_mgr->showDialog("ObjectProperties"); break; /*#ifdef WITH_INKBOARD case SP_VERB_XMPP_CLIENT: |
