summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-02-17 08:05:08 +0000
committerJohn Smith <removethis.john.q.public@bigmail.com>2012-02-17 08:05:08 +0000
commitafb80368d6bf4dc2a55b011c9a14fa4288d2fe84 (patch)
tree6ec54c830a6537271186388726542ca873ff7830 /src/ui
parentDocumentation of the Text and Font dialog (diff)
downloadinkscape-afb80368d6bf4dc2a55b011c9a14fa4288d2fe84.tar.gz
inkscape-afb80368d6bf4dc2a55b011c9a14fa4288d2fe84.zip
Fix for 171579 : Make inkscape remember dialogs window status
(bzr r10992)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/dialog.cpp26
-rw-r--r--src/ui/dialog/dialog.h3
-rw-r--r--src/ui/dialog/dock-behavior.cpp23
-rw-r--r--src/ui/dialog/dock-behavior.h1
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp9
-rw-r--r--src/ui/dialog/inkscape-preferences.h2
-rw-r--r--src/ui/widget/dock-item.cpp51
-rw-r--r--src/ui/widget/dock-item.h13
-rw-r--r--src/ui/widget/dock.cpp4
-rw-r--r--src/ui/widget/imagetoggler.cpp11
10 files changed, 117 insertions, 26 deletions
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 43c9493b3..3e53dcb53 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -83,11 +83,12 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
: _user_hidden(false),
_hiddenF12(false),
retransientize_suppress(false),
- //
_prefs_path(prefs_path),
_verb_num(verb_num),
_title(),
_apply_label(apply_label),
+ _desktop(NULL),
+ _is_active_desktop(true),
_behavior(0)
{
gchar title[500];
@@ -97,8 +98,8 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
}
_title = title;
-
_behavior = behavior_factory(*this);
+ _desktop = SP_ACTIVE_DESKTOP;
g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this);
g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
@@ -124,13 +125,14 @@ Dialog::~Dialog()
void Dialog::onDesktopActivated(SPDesktop *desktop)
{
+ _is_active_desktop = (desktop == _desktop);
_behavior->onDesktopActivated(desktop);
}
void Dialog::onShutdown()
{
save_geometry();
- _user_hidden = true;
+ //_user_hidden = true;
_behavior->onShutdown();
}
@@ -224,6 +226,24 @@ void Dialog::save_geometry()
}
+void
+Dialog::save_status(int visible, int state, int placement)
+{
+ // Only save dialog status for dialogs on the "last document"
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop != NULL || !_is_active_desktop ) {
+ return;
+ }
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs) {
+ prefs->setInt(_prefs_path + "/visible", visible);
+ prefs->setInt(_prefs_path + "/state", state);
+ prefs->setInt(_prefs_path + "/placement", placement);
+ }
+}
+
+
void Dialog::_handleResponse(int response_id)
{
switch (response_id) {
diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h
index 3bd4f9d65..43e7dda3b 100644
--- a/src/ui/dialog/dialog.h
+++ b/src/ui/dialog/dialog.h
@@ -108,6 +108,7 @@ public:
* Save window position to preferences.
*/
void save_geometry();
+ void save_status(int visible, int state, int placement);
bool retransientize_suppress; // when true, do not retransientize (prevents races when switching new windows too fast)
@@ -116,6 +117,8 @@ protected:
int _verb_num;
Glib::ustring _title;
Glib::ustring _apply_label;
+ SPDesktop * _desktop;
+ bool _is_active_desktop;
virtual void _handleResponse(int response_id);
diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp
index cf4d36cff..9b216e841 100644
--- a/src/ui/dialog/dock-behavior.cpp
+++ b/src/ui/dialog/dock-behavior.cpp
@@ -46,16 +46,22 @@ DockBehavior::DockBehavior(Dialog &dialog) :
Inkscape::Verb::get(dialog._verb_num)->get_image() : ""),
static_cast<Widget::DockItem::State>(
Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/state",
- UI::Widget::DockItem::DOCKED_STATE)))
+ UI::Widget::DockItem::DOCKED_STATE)),
+ static_cast<Widget::DockItem::Placement>(
+ Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/placement",
+ UI::Widget::DockItem::TOP)))
+
{
// Connect signals
_signal_hide_connection = signal_hide().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::Behavior::DockBehavior::_onHide));
+ signal_show().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::Behavior::DockBehavior::_onShow));
_dock_item.signal_state_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Dialog::Behavior::DockBehavior::_onStateChanged));
if (_dock_item.getState() == Widget::DockItem::FLOATING_STATE) {
if (Gtk::Window *floating_win = _dock_item.getWindow())
sp_transientize(GTK_WIDGET(floating_win->gobj()));
}
+
}
DockBehavior::~DockBehavior()
@@ -178,8 +184,12 @@ DockBehavior::_onHide()
{
_dialog.save_geometry();
_dialog._user_hidden = true;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(_dialog._prefs_path + "/state", _dock_item.getPrevState());
+}
+
+void
+DockBehavior::_onShow()
+{
+ _dialog._user_hidden = false;
}
void
@@ -187,8 +197,6 @@ DockBehavior::_onStateChanged(Widget::DockItem::State /*prev_state*/,
Widget::DockItem::State new_state)
{
// TODO probably need to avoid window calls unless the state is different. Check.
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(_dialog._prefs_path + "/state", new_state);
if (new_state == Widget::DockItem::FLOATING_STATE) {
if (Gtk::Window *floating_win = _dock_item.getWindow())
@@ -212,8 +220,9 @@ DockBehavior::onShowF12()
void
DockBehavior::onShutdown()
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(_dialog._prefs_path + "/state", _dock_item.getPrevState());
+ int visible = _dock_item.isIconified() || !_dialog._user_hidden;
+ int status = (_dock_item.getState() == Inkscape::UI::Widget::DockItem::UNATTACHED) ? _dock_item.getPrevState() : _dock_item.getState();
+ _dialog.save_status( visible, status, _dock_item.getPlacement() );
}
void
diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h
index cc599286f..de7386ad9 100644
--- a/src/ui/dialog/dock-behavior.h
+++ b/src/ui/dialog/dock-behavior.h
@@ -74,6 +74,7 @@ private:
/** Internal signal handlers */
void _onHide();
+ void _onShow();
bool _onDeleteEvent(GdkEventAny *event);
void _onStateChanged(Widget::DockItem::State prev_state, Widget::DockItem::State new_state);
bool _onKeyPress(GdkEventKey *event);
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index dc6543c92..9f63f4654 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -573,6 +573,9 @@ void InkscapePreferences::initPageUI()
_win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "/options/savewindowgeometry/value", 2, false, &_win_save_geom);
_win_save_geom_off.init ( _("Don't save window geometry"), "/options/savewindowgeometry/value", 0, false, &_win_save_geom);
+ _win_save_dialog_pos_on.init ( _("Save and restore dialogs status"), "/options/savedialogposition/value", 1, true, 0);
+ _win_save_dialog_pos_off.init ( _("Don't save dialogs status"), "/options/savedialogposition/value", 0, false, &_win_save_dialog_pos_on);
+
_win_dockable.init ( _("Dockable"), "/options/dialogtype/value", 1, true, 0);
_win_floating.init ( _("Floating"), "/options/dialogtype/value", 0, false, &_win_dockable);
@@ -591,6 +594,12 @@ void InkscapePreferences::initPageUI()
_page_windows.add_line( true, "", _win_save_geom, "",
_("Save and restore window geometry for each document (saves geometry in the document)"));
+ _page_windows.add_group_header( _("Saving dialogs status"));
+ _page_windows.add_line( true, "", _win_save_dialog_pos_off, "",
+ _("Don't save dialogs status"));
+ _page_windows.add_line( true, "", _win_save_dialog_pos_on, "",
+ _("Save and restore dialogs status (the last open windows dialogs are saved when it closes)"));
+
_page_windows.add_group_header( _("Dialog behavior (requires restart)"));
_page_windows.add_line( true, "", _win_dockable, "",
_("Dockable"));
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 7da51e190..6a46ef83c 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -219,6 +219,8 @@ protected:
UI::Widget::PrefRadioButton _win_dockable;
UI::Widget::PrefRadioButton _win_floating;
+ UI::Widget::PrefRadioButton _win_save_dialog_pos_on;
+ UI::Widget::PrefRadioButton _win_save_dialog_pos_off;
UI::Widget::PrefRadioButton _win_ontop_none;
UI::Widget::PrefRadioButton _win_ontop_normal;
UI::Widget::PrefRadioButton _win_ontop_agressive;
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp
index 34c68284e..07098fa11 100644
--- a/src/ui/widget/dock-item.cpp
+++ b/src/ui/widget/dock-item.cpp
@@ -14,6 +14,7 @@
#include "inkscape.h"
#include "preferences.h"
#include "ui/widget/dock.h"
+#include "ui/icon-names.h"
#include "widgets/icon.h"
#include <gtkmm/icontheme.h>
@@ -24,7 +25,7 @@ namespace UI {
namespace Widget {
DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
- const Glib::ustring& icon_name, State state) :
+ const Glib::ustring& icon_name, State state, Placement placement) :
_dock(dock),
_prev_state(state),
_prev_position(0),
@@ -41,8 +42,13 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
GDL_DOCK_ITEM_BEH_NORMAL :
GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER);
+
if (!icon_name.empty()) {
Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();
+
+ if (!iconTheme->has_icon(icon_name)) {
+ Inkscape::queueIconPrerender( INKSCAPE_ICON(icon_name.data()), Inkscape::ICON_SIZE_MENU );
+ }
// Icon might be in the icon theme, or might be a stock item. Check the proper source:
if ( iconTheme->has_icon(icon_name) ) {
int width = 0;
@@ -78,9 +84,14 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
signal_delete_event().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onDeleteEvent));
signal_realize().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onRealize));
- _dock.addItem(*this, (_prev_state == FLOATING_STATE ? FLOATING : TOP));
+ _dock.addItem(*this, ( _prev_state == FLOATING_STATE || _prev_state == ICONIFIED_FLOATING_STATE ) ? FLOATING : placement);
+
+ if (_prev_state == ICONIFIED_FLOATING_STATE || _prev_state == ICONIFIED_DOCKED_STATE) {
+ iconify();
+ }
show_all();
+
}
DockItem::~DockItem()
@@ -198,7 +209,17 @@ DockItem::isIconified() const
DockItem::State
DockItem::getState() const
{
- return (isAttached() ? (isFloating() ? FLOATING_STATE : DOCKED_STATE) : UNATTACHED);
+ if (isIconified() && _prev_state == FLOATING_STATE) {
+ return ICONIFIED_FLOATING_STATE;
+ } else if (isIconified()) {
+ return ICONIFIED_DOCKED_STATE;
+ } else if (isFloating() && isAttached()) {
+ return FLOATING_STATE;
+ } else if (isAttached()) {
+ return DOCKED_STATE;
+ }
+
+ return UNATTACHED;
}
DockItem::State
@@ -210,10 +231,12 @@ DockItem::getPrevState() const
DockItem::Placement
DockItem::getPlacement() const
{
- GdlDockPlacement placement = (GdlDockPlacement)NONE;
- gdl_dock_object_child_placement(gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT(_gdl_dock_item)),
- GDL_DOCK_OBJECT(_gdl_dock_item),
- &placement);
+ GdlDockPlacement placement = (GdlDockPlacement)TOP;
+ GdlDockObject *parent = gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT(_gdl_dock_item));
+ if (parent) {
+ gdl_dock_object_child_placement(parent, GDL_DOCK_OBJECT(_gdl_dock_item), &placement);
+ }
+
return (Placement)placement;
}
@@ -230,6 +253,12 @@ DockItem::show()
}
void
+DockItem::iconify()
+{
+ gdl_dock_item_iconify_item (GDL_DOCK_ITEM(_gdl_dock_item));
+}
+
+void
DockItem::show_all()
{
gtk_widget_show_all(_gdl_dock_item);
@@ -239,10 +268,9 @@ void
DockItem::present()
{
- if (isIconified() || !isAttached()) {
+ if (!isIconified() && !isAttached()) {
show();
}
-
// tabbed
else if (getPlacement() == CENTER) {
int i = gtk_notebook_page_num(GTK_NOTEBOOK(gtk_widget_get_parent(_gdl_dock_item)),
@@ -338,6 +366,11 @@ DockItem::_onHideWindow()
void
DockItem::_onHide()
{
+ if (_prev_state == ICONIFIED_DOCKED_STATE)
+ _prev_state = DOCKED_STATE;
+ else if (_prev_state == ICONIFIED_FLOATING_STATE)
+ _prev_state = FLOATING_STATE;
+
_signal_state_changed.emit(UNATTACHED, getState());
}
diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h
index 573307452..75ffea1a0 100644
--- a/src/ui/widget/dock-item.h
+++ b/src/ui/widget/dock-item.h
@@ -34,10 +34,12 @@ class DockItem {
public:
- enum State { UNATTACHED, // item not bound to the dock (a temporary state)
- FLOATING_STATE, // item not in its dock (but can be docked in other,
- // e.g. floating, docks)
- DOCKED_STATE }; // item in its assigned dock
+ enum State { UNATTACHED, // item not bound to the dock (a temporary state)
+ FLOATING_STATE, // item not in its dock (but can be docked in other,
+ // e.g. floating, docks)
+ DOCKED_STATE, // item in its assigned dock
+ ICONIFIED_DOCKED_STATE, // item iconified in its assigned dock from dock
+ ICONIFIED_FLOATING_STATE}; // item iconified in its assigned dock from float
enum Placement {
NONE = GDL_DOCK_NONE,
@@ -50,7 +52,7 @@ public:
};
DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
- const Glib::ustring& icon_name, State state);
+ const Glib::ustring& icon_name, State state, Placement placement);
~DockItem();
@@ -80,6 +82,7 @@ public:
void hide();
void show();
+ void iconify();
void show_all();
void present();
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index 62682b9dc..a6e983304 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -229,12 +229,14 @@ void Dock::_onLayoutChanged()
{
if (isEmpty()) {
if (hasIconifiedItems()) {
+ _paned->get_child1()->set_size_request(-1, -1);
_scrolled_window->set_size_request(_default_dock_bar_width);
} else {
+ _paned->get_child1()->set_size_request(-1, -1);
_scrolled_window->set_size_request(_default_empty_width);
}
-
getParentPaned()->set_position(INT_MAX);
+
} else {
// unset any forced size requests
_paned->get_child1()->set_size_request(-1, -1);
diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp
index 073e071af..6517219f2 100644
--- a/src/ui/widget/imagetoggler.cpp
+++ b/src/ui/widget/imagetoggler.cpp
@@ -14,6 +14,8 @@
#include <gtkmm/icontheme.h>
#include "widgets/icon.h"
+#include "widgets/toolbox.h"
+#include "ui/icon-names.h"
namespace Inkscape {
namespace UI {
@@ -33,10 +35,17 @@ ImageToggler::ImageToggler( char const* on, char const* off) :
int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
+ if (!icon_theme->has_icon(_pixOnName)) {
+ Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOnName.data()), Inkscape::ICON_SIZE_DECORATION );
+ }
+ if (!icon_theme->has_icon(_pixOffName)) {
+ Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixOffName.data()), Inkscape::ICON_SIZE_DECORATION );
+ }
+
+
if (icon_theme->has_icon(_pixOnName)) {
_property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0);
}
-
if (icon_theme->has_icon(_pixOffName)) {
_property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0);
}