[gthumb] save and restore the viewer sidebar state
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] save and restore the viewer sidebar state
- Date: Wed, 19 Sep 2012 12:58:35 +0000 (UTC)
commit eb9a0c80920c72dbfebc7957fb9d3e281be13fd1
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Sep 19 12:19:04 2012 +0200
save and restore the viewer sidebar state
[new feature]
data/org.gnome.gthumb.gschema.xml.in | 3 +
extensions/file_tools/callbacks.c | 4 +-
extensions/image_viewer/gth-image-viewer-page.c | 2 +
gthumb/gth-browser-actions-callbacks.c | 18 +++-
gthumb/gth-browser-actions-callbacks.h | 1 +
gthumb/gth-browser-actions-entries.h | 6 +
gthumb/gth-browser-ui.h | 2 +-
gthumb/gth-browser.c | 138 +++++++++++++----------
gthumb/gth-browser.h | 7 +-
gthumb/gth-preferences.h | 1 +
gthumb/gth-sidebar.h | 6 +
11 files changed, 120 insertions(+), 68 deletions(-)
---
diff --git a/data/org.gnome.gthumb.gschema.xml.in b/data/org.gnome.gthumb.gschema.xml.in
index c2cbb3c..89fea70 100644
--- a/data/org.gnome.gthumb.gschema.xml.in
+++ b/data/org.gnome.gthumb.gschema.xml.in
@@ -128,6 +128,9 @@
<key name="browser-sidebar-width" type="i">
<default>285</default>
</key>
+ <key name="viewer-sidebar" enum="org.gnome.gthumb.GthSidebarState">
+ <default>'hidden'</default>
+ </key>
<key name="viewer-sidebar-width" type="i">
<default>285</default>
</key>
diff --git a/extensions/file_tools/callbacks.c b/extensions/file_tools/callbacks.c
index c3d222b..68d11c4 100644
--- a/extensions/file_tools/callbacks.c
+++ b/extensions/file_tools/callbacks.c
@@ -82,11 +82,11 @@ file_tools__gth_browser_file_list_key_press_cb (GthBrowser *browser,
tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_ROTATE_LEFT);
break;
case GDK_KEY_C:
- gth_browser_show_viewer_tools (browser, TRUE);
+ gth_browser_show_viewer_tools (browser);
tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_CROP);
break;
case GDK_KEY_S:
- gth_browser_show_viewer_tools (browser, TRUE);
+ gth_browser_show_viewer_tools (browser);
tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_RESIZE);
break;
}
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 7c35570..74b0de0 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -709,6 +709,8 @@ gth_image_viewer_page_real_activate (GthViewerPage *base,
action = gtk_action_group_get_action (gth_browser_get_actions (browser), "Viewer_Tools");
g_object_set (action, "sensitive", TRUE, NULL);
+ action = gtk_action_group_get_action (gth_browser_get_actions (browser), "Browser_Tools");
+ g_object_set (action, "sensitive", TRUE, NULL);
self->priv->preloader = gth_browser_get_image_preloader (browser);
self->priv->requested_ready_id = g_signal_connect (G_OBJECT (self->priv->preloader),
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index c569138..599faad 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -353,7 +353,18 @@ void
gth_browser_activate_action_viewer_properties (GtkAction *action,
GthBrowser *browser)
{
- gth_browser_show_file_properties (GTH_BROWSER (browser), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gth_browser_show_file_properties (GTH_BROWSER (browser));
+ else
+ gth_browser_hide_sidebar (GTH_BROWSER (browser));
+}
+
+
+void
+gth_browser_activate_action_browser_tools (GtkAction *action,
+ GthBrowser *browser)
+{
+ gth_browser_show_viewer_tools (GTH_BROWSER (browser));
}
@@ -361,7 +372,10 @@ void
gth_browser_activate_action_viewer_tools (GtkAction *action,
GthBrowser *browser)
{
- gth_browser_show_viewer_tools (GTH_BROWSER (browser), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gth_browser_show_viewer_tools (GTH_BROWSER (browser));
+ else
+ gth_browser_hide_sidebar (GTH_BROWSER (browser));
}
diff --git a/gthumb/gth-browser-actions-callbacks.h b/gthumb/gth-browser-actions-callbacks.h
index da23eb1..5f18b5b 100644
--- a/gthumb/gth-browser-actions-callbacks.h
+++ b/gthumb/gth-browser-actions-callbacks.h
@@ -64,6 +64,7 @@ DEFINE_ACTION(gth_browser_activate_action_view_reload)
DEFINE_ACTION(gth_browser_activate_action_view_next)
DEFINE_ACTION(gth_browser_activate_action_view_prev)
DEFINE_ACTION(gth_browser_activate_action_viewer_properties)
+DEFINE_ACTION(gth_browser_activate_action_browser_tools)
DEFINE_ACTION(gth_browser_activate_action_viewer_tools)
DEFINE_ACTION(gth_browser_activate_action_view_shrink_wrap)
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index dbb7399..51d245c 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -198,6 +198,12 @@ static GthActionEntryExt gth_browser_action_entries[] = {
" ",
GTH_ACTION_FLAG_NONE,
G_CALLBACK (gth_browser_activate_action_help_shortcuts) },
+
+ { "Browser_Tools", "palette",
+ N_("Edit"), NULL,
+ N_("Edit file"),
+ GTH_ACTION_FLAG_NONE,
+ G_CALLBACK (gth_browser_activate_action_browser_tools) },
};
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index 1d2c7a0..b601635 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -124,7 +124,7 @@ static const char *fixed_ui_info =
" <placeholder name='Edit_Actions_2'/>"
" <separator expand='true'/>"
" <placeholder name='BrowserCommandsSecondary'/>"
-" <toolitem action='Viewer_Tools'/>"
+" <toolitem action='Browser_Tools'/>"
" <toolitem action='Browser_Properties'/>"
" </toolbar>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index a55b37d..8b6cba5 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -84,6 +84,7 @@ enum {
LAST_SIGNAL
};
+
struct _GthBrowserPrivate {
/* UI staff */
@@ -166,6 +167,7 @@ struct _GthBrowserPrivate {
gboolean recalc_location_free_space;
gboolean shrink_wrap_viewer;
gboolean file_properties_on_the_right;
+ GthSidebarState viewer_sidebar;
/* settings */
@@ -2173,6 +2175,7 @@ _gth_browser_deactivate_viewer_page (GthBrowser *browser)
gtk_ui_manager_ensure_update (browser->priv->ui);
gth_browser_set_viewer_widget (browser, NULL);
_gth_browser_set_action_sensitive (browser, "Viewer_Tools", FALSE);
+ _gth_browser_set_action_sensitive (browser, "Browser_Tools", FALSE);
g_object_unref (browser->priv->viewer_page);
browser->priv->viewer_page = NULL;
}
@@ -2225,6 +2228,8 @@ _gth_browser_close_final_step (gpointer user_data)
gtk_widget_get_allocation (browser->priv->viewer_sidebar_alignment, &allocation);
if (allocation.width > MIN_SIDEBAR_SIZE)
g_settings_set_int (browser->priv->browser_settings, PREF_BROWSER_VIEWER_SIDEBAR_WIDTH, allocation.width);
+
+ g_settings_set_enum (browser->priv->browser_settings, PREF_BROWSER_VIEWER_SIDEBAR, browser->priv->viewer_sidebar);
}
/**/
@@ -2496,21 +2501,19 @@ _gth_browser_real_set_current_page (GthWindow *window,
/* update the sidebar state depending on the current visible page */
if (page == GTH_BROWSER_PAGE_BROWSER) {
- gth_browser_show_viewer_tools (browser, FALSE);
gth_sidebar_show_properties (GTH_SIDEBAR (browser->priv->file_properties));
- gth_browser_show_file_properties (browser, _gth_browser_get_action_active (browser, "Browser_Properties"));
+ if (_gth_browser_get_action_active (browser, "Browser_Properties"))
+ gth_browser_show_file_properties (browser);
+ else
+ gth_browser_hide_sidebar (browser);
}
else if (page == GTH_BROWSER_PAGE_VIEWER) {
- if (_gth_browser_get_action_active (browser, "Viewer_Properties")) {
- gth_sidebar_show_properties (GTH_SIDEBAR (browser->priv->file_properties));
- gtk_widget_show (browser->priv->file_properties);
- }
- else if (_gth_browser_get_action_active (browser, "Viewer_Tools")) {
- gth_sidebar_show_tools (GTH_SIDEBAR (browser->priv->file_properties));
- gtk_widget_show (browser->priv->file_properties);
- }
+ if (browser->priv->viewer_sidebar == GTH_SIDEBAR_STATE_PROPERTIES)
+ gth_browser_show_file_properties (browser);
+ else if (browser->priv->viewer_sidebar == GTH_SIDEBAR_STATE_TOOLS)
+ gth_browser_show_viewer_tools (browser);
else
- gth_browser_show_file_properties (browser, FALSE);
+ gth_browser_hide_sidebar (browser);
}
/* save the browser window size */
@@ -3709,12 +3712,15 @@ gth_file_list_key_press_cb (GtkWidget *widget,
case GDK_KEY_e:
if (browser->priv->viewer_page != NULL)
- gth_browser_show_viewer_tools (GTH_BROWSER (browser), TRUE);
+ gth_browser_show_viewer_tools (GTH_BROWSER (browser));
result = TRUE;
break;
case GDK_KEY_i:
- gth_browser_show_file_properties (GTH_BROWSER (browser), ! _gth_browser_get_action_active (browser, "Browser_Properties"));
+ if (_gth_browser_get_action_active (browser, "Browser_Properties"))
+ gth_browser_hide_sidebar (browser);
+ else
+ gth_browser_show_file_properties (browser);
result = TRUE;
break;
@@ -4684,8 +4690,15 @@ gth_browser_init (GthBrowser *browser)
browser->priv->shrink_wrap_viewer = g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_SHRINK_WRAP_VIEWER);
_gth_browser_set_action_active (browser, "View_ShrinkWrap", browser->priv->shrink_wrap_viewer);
+ _gth_browser_set_action_sensitive (browser, "Browser_Tools", FALSE);
_gth_browser_set_action_sensitive (browser, "Viewer_Tools", FALSE);
- gth_browser_show_file_properties (browser, g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_VISIBLE));
+
+ if (g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_VISIBLE))
+ gth_browser_show_file_properties (browser);
+ else
+ gth_browser_hide_sidebar (browser);
+
+ browser->priv->viewer_sidebar = g_settings_get_enum (browser->priv->browser_settings, PREF_BROWSER_VIEWER_SIDEBAR);
browser->priv->fast_file_type = g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_FAST_FILE_TYPE);
@@ -5263,8 +5276,10 @@ gth_browser_toggle_properties_on_screen (GthBrowser *browser)
browser->priv->properties_on_screen = ! browser->priv->properties_on_screen;
gth_viewer_page_show_properties (browser->priv->viewer_page, browser->priv->properties_on_screen);
}
+ else if (browser->priv->viewer_sidebar != GTH_SIDEBAR_STATE_PROPERTIES)
+ gth_browser_show_file_properties (browser);
else
- gth_browser_show_file_properties (browser, ! _gth_browser_get_action_active (browser, "Viewer_Properties"));
+ gth_browser_hide_sidebar (browser);
}
@@ -5298,11 +5313,14 @@ gth_browser_viewer_key_press_cb (GthBrowser *browser,
return TRUE;
case GDK_KEY_e:
- gth_browser_show_viewer_tools (GTH_BROWSER (browser), ! _gth_browser_get_action_active (browser, "Viewer_Tools"));
+ if (browser->priv->viewer_sidebar != GTH_SIDEBAR_STATE_TOOLS)
+ gth_browser_show_viewer_tools (browser);
+ else
+ gth_browser_hide_sidebar (browser);
return TRUE;
case GDK_KEY_i:
- gth_browser_toggle_properties_on_screen (GTH_BROWSER (browser));
+ gth_browser_toggle_properties_on_screen (browser);
return TRUE;
case GDK_KEY_f:
@@ -5328,7 +5346,7 @@ gth_browser_set_viewer_widget (GthBrowser *browser,
/* deactivate the tools which are not available for every viewer */
- if (_gth_browser_get_action_active (browser, "Viewer_Tools"))
+ if (browser->priv->viewer_sidebar == GTH_SIDEBAR_STATE_TOOLS)
_gth_browser_set_action_active (browser, "Viewer_Tools", FALSE);
}
@@ -5889,56 +5907,61 @@ gth_browser_load_file (GthBrowser *browser,
void
-gth_browser_show_file_properties (GthBrowser *browser,
- gboolean show)
+gth_browser_show_file_properties (GthBrowser *browser)
{
switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
case GTH_BROWSER_PAGE_BROWSER:
case GTH_WINDOW_PAGE_UNDEFINED: /* when called from gth_browser_init */
- g_settings_set_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_VISIBLE, show);
- _gth_browser_set_action_active (browser, "Browser_Properties", show);
- if (show) {
- if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_WINDOW_PAGE_UNDEFINED)
- gtk_widget_show (browser->priv->file_properties);
- }
- else
- gtk_widget_hide (browser->priv->file_properties);
+ g_settings_set_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_VISIBLE, TRUE);
+ _gth_browser_set_action_active (browser, "Browser_Properties", TRUE);
+ if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_WINDOW_PAGE_UNDEFINED)
+ gtk_widget_show (browser->priv->file_properties);
break;
case GTH_BROWSER_PAGE_VIEWER:
- _gth_browser_set_action_active (browser, "Viewer_Properties", show);
- if (show) {
- _gth_browser_set_action_active (browser, "Viewer_Tools", FALSE);
- gtk_widget_show (browser->priv->viewer_sidebar_alignment);
- gtk_widget_show (browser->priv->file_properties);
- gth_sidebar_show_properties (GTH_SIDEBAR (browser->priv->file_properties));
- }
- else
- gtk_widget_hide (browser->priv->viewer_sidebar_alignment);
+ _gth_browser_set_action_active (browser, "Viewer_Tools", FALSE);
+ browser->priv->viewer_sidebar = GTH_SIDEBAR_STATE_PROPERTIES;
+ _gth_browser_set_action_active (browser, "Viewer_Properties", TRUE);
+ gtk_widget_show (browser->priv->viewer_sidebar_alignment);
+ gtk_widget_show (browser->priv->file_properties);
+ gth_sidebar_show_properties (GTH_SIDEBAR (browser->priv->file_properties));
break;
}
}
void
-gth_browser_show_viewer_tools (GthBrowser *browser,
- gboolean show)
+gth_browser_show_viewer_tools (GthBrowser *browser)
{
- if (show)
- gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER);
- _gth_browser_set_action_active (browser, "Viewer_Tools", show);
+ gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER);
- if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_BROWSER_PAGE_VIEWER)
- return;
+ _gth_browser_set_action_active (browser, "Viewer_Properties", FALSE);
+ browser->priv->viewer_sidebar = GTH_SIDEBAR_STATE_TOOLS;
+ _gth_browser_set_action_active (browser, "Viewer_Tools", TRUE);
+ gtk_widget_show (browser->priv->viewer_sidebar_alignment);
+ gtk_widget_show (browser->priv->file_properties);
+ gth_sidebar_show_tools (GTH_SIDEBAR (browser->priv->file_properties));
+}
- if (show) {
- _gth_browser_set_action_active (browser, "Viewer_Properties", FALSE);
- gtk_widget_show (browser->priv->viewer_sidebar_alignment);
- gtk_widget_show (browser->priv->file_properties);
- gth_sidebar_show_tools (GTH_SIDEBAR (browser->priv->file_properties));
- }
- else
+
+void
+gth_browser_hide_sidebar (GthBrowser *browser)
+{
+ switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
+ case GTH_BROWSER_PAGE_BROWSER:
+ _gth_browser_set_action_active (browser, "Browser_Properties", FALSE);
+ gtk_widget_hide (browser->priv->file_properties);
+ break;
+
+ case GTH_BROWSER_PAGE_VIEWER:
+ if (browser->priv->viewer_sidebar == GTH_SIDEBAR_STATE_PROPERTIES)
+ _gth_browser_set_action_active (browser, "Viewer_Properties", FALSE);
+ else if (browser->priv->viewer_sidebar == GTH_SIDEBAR_STATE_TOOLS)
+ _gth_browser_set_action_active (browser, "Viewer_Tools", FALSE);
+ browser->priv->viewer_sidebar = GTH_SIDEBAR_STATE_HIDDEN;
gtk_widget_hide (browser->priv->viewer_sidebar_alignment);
+ break;
+ }
}
@@ -6443,8 +6466,7 @@ gth_browser_fullscreen (GthBrowser *browser)
browser->priv->before_fullscreen.viewer_tools = _gth_browser_get_action_active (browser, "Viewer_Tools");
browser->priv->before_fullscreen.thumbnail_list = _gth_browser_get_action_active (browser, "View_Thumbnail_List");
- gth_browser_show_file_properties (browser, FALSE);
- gth_browser_show_viewer_tools (browser, FALSE);
+ gth_browser_hide_sidebar (browser);
_gth_browser_set_thumbnail_list_visibility (browser, FALSE);
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER);
gth_window_show_only_content (GTH_WINDOW (browser), TRUE);
@@ -6487,13 +6509,11 @@ gth_browser_unfullscreen (GthBrowser *browser)
_gth_browser_set_thumbnail_list_visibility (browser, browser->priv->before_fullscreen.thumbnail_list);
if (browser->priv->before_fullscreen.viewer_properties)
- gth_browser_show_file_properties (browser, TRUE);
+ gth_browser_show_file_properties (browser);
else if (browser->priv->before_fullscreen.viewer_tools)
- gth_browser_show_viewer_tools (browser, TRUE);
- else {
- gth_browser_show_file_properties (browser, FALSE);
- gth_browser_show_viewer_tools (browser, FALSE);
- }
+ gth_browser_show_viewer_tools (browser);
+ else
+ gth_browser_hide_sidebar (browser);
browser->priv->properties_on_screen = FALSE;
if (GTH_VIEWER_PAGE_GET_INTERFACE (browser->priv->viewer_page)->show_properties != NULL)
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 93ab12d..0a2138b 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -160,10 +160,9 @@ void gth_browser_update_sensitivity (GthBrowser *browser);
void gth_browser_update_extra_widget (GthBrowser *browser);
void gth_browser_update_statusbar_file_info
(GthBrowser *browser);
-void gth_browser_show_file_properties (GthBrowser *browser,
- gboolean show);
-void gth_browser_show_viewer_tools (GthBrowser *browser,
- gboolean show);
+void gth_browser_show_file_properties (GthBrowser *browser);
+void gth_browser_show_viewer_tools (GthBrowser *browser);
+void gth_browser_hide_sidebar (GthBrowser *browser);
void gth_browser_set_shrink_wrap_viewer (GthBrowser *browser,
gboolean value);
gboolean gth_browser_get_shrink_wrap_viewer (GthBrowser *browser);
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index f959e3c..2db8dd5 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -77,6 +77,7 @@ G_BEGIN_DECLS
#define PREF_BROWSER_PROPERTIES_ON_THE_RIGHT "properties-on-the-right"
#define PREF_BROWSER_THUMBNAIL_LIST_VISIBLE "thumbnail-list-visible"
#define PREF_BROWSER_BROWSER_SIDEBAR_WIDTH "browser-sidebar-width"
+#define PREF_BROWSER_VIEWER_SIDEBAR "viewer-sidebar"
#define PREF_BROWSER_VIEWER_SIDEBAR_WIDTH "viewer-sidebar-width"
#define PREF_BROWSER_VIEWER_THUMBNAILS_ORIENT "viewer-thumbnails-orientation"
#define PREF_BROWSER_SHRINK_WRAP_VIEWER "shrink-wrap-viewer"
diff --git a/gthumb/gth-sidebar.h b/gthumb/gth-sidebar.h
index 148061f..cacf0ba 100644
--- a/gthumb/gth-sidebar.h
+++ b/gthumb/gth-sidebar.h
@@ -39,6 +39,12 @@ G_BEGIN_DECLS
#define GTH_IS_PROPERTY_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_PROPERTY_VIEW))
#define GTH_PROPERTY_VIEW_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTH_TYPE_PROPERTY_VIEW, GthPropertyViewInterface))
+typedef enum {
+ GTH_SIDEBAR_STATE_HIDDEN,
+ GTH_SIDEBAR_STATE_PROPERTIES,
+ GTH_SIDEBAR_STATE_TOOLS
+} GthSidebarState;
+
typedef struct _GthSidebar GthSidebar;
typedef struct _GthSidebarClass GthSidebarClass;
typedef struct _GthSidebarPrivate GthSidebarPrivate;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]