[gthumb] Show the Edit button in browser mode as well
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Show the Edit button in browser mode as well
- Date: Tue, 8 Nov 2011 13:36:45 +0000 (UTC)
commit e1d5cb475b98bfeb159cc96ea75f430a0056b825
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Nov 8 09:53:51 2011 +0100
Show the Edit button in browser mode as well
extensions/image_viewer/gth-image-viewer-page.c | 36 +++++++----
gthumb/gth-browser-actions-callbacks.c | 2 +-
gthumb/gth-browser-actions-entries.h | 5 ++
gthumb/gth-browser-ui.h | 6 ++
gthumb/gth-browser.c | 81 ++++++++++++++--------
gthumb/gth-browser.h | 3 +-
6 files changed, 88 insertions(+), 45 deletions(-)
---
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index ee001fa..f1b684e 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -46,7 +46,8 @@ struct _GthImageViewerPagePrivate {
GtkWidget *viewer;
GthImagePreloader *preloader;
GtkActionGroup *actions;
- guint merge_id;
+ guint viewer_merge_id;
+ guint browser_merge_id;
GthImageHistory *history;
GthFileData *file_data;
gulong requested_ready_id;
@@ -81,9 +82,6 @@ static const char *image_viewer_ui_info =
" <toolitem action='ImageViewer_View_ZoomFit'/>"
" <toolitem action='ImageViewer_View_ZoomFitWidth'/>"
" </placeholder>"
-" <placeholder name='ViewerCommandsSecondary'>"
-" <toolitem action='Viewer_Tools'/>"
-" </placeholder>"
" </toolbar>"
" <toolbar name='Fullscreen_ToolBar'>"
" <placeholder name='ViewerCommands'>"
@@ -93,9 +91,6 @@ static const char *image_viewer_ui_info =
" <toolitem action='ImageViewer_View_ZoomFit'/>"
" <toolitem action='ImageViewer_View_ZoomFitWidth'/>"
" </placeholder>"
-" <placeholder name='ViewerCommandsSecondary'>"
-" <toolitem action='Viewer_Tools'/>"
-" </placeholder>"
" </toolbar>"
"</ui>";
@@ -701,6 +696,7 @@ gth_image_viewer_page_real_activate (GthViewerPage *base,
GthBrowser *browser)
{
GthImageViewerPage *self;
+ GtkAction *action;
int i;
self = (GthImageViewerPage*) base;
@@ -715,6 +711,9 @@ gth_image_viewer_page_real_activate (GthViewerPage *base,
self);
gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), self->priv->actions, 0);
+ action = gtk_action_group_get_action (gth_browser_get_actions (browser), "Viewer_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),
"requested_ready",
@@ -822,6 +821,7 @@ static void
gth_image_viewer_page_real_deactivate (GthViewerPage *base)
{
GthImageViewerPage *self;
+ GtkAction *action;
int i;
self = (GthImageViewerPage*) base;
@@ -834,6 +834,14 @@ gth_image_viewer_page_real_deactivate (GthViewerPage *base)
/**/
+ action = gtk_action_group_get_action (gth_browser_get_actions (self->priv->browser), "Viewer_Tools");
+ g_object_set (action, "sensitive", FALSE, NULL);
+
+ if (self->priv->browser_merge_id != 0) {
+ gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (self->priv->browser), self->priv->browser_merge_id);
+ self->priv->browser_merge_id = 0;
+ }
+
gtk_ui_manager_remove_action_group (gth_browser_get_ui_manager (self->priv->browser), self->priv->actions);
g_object_unref (self->priv->actions);
self->priv->actions = NULL;
@@ -858,11 +866,11 @@ gth_image_viewer_page_real_show (GthViewerPage *base)
self = (GthImageViewerPage*) base;
- if (self->priv->merge_id != 0)
+ if (self->priv->viewer_merge_id != 0)
return;
- self->priv->merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (self->priv->browser), image_viewer_ui_info, -1, &error);
- if (self->priv->merge_id == 0) {
+ self->priv->viewer_merge_id = gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (self->priv->browser), image_viewer_ui_info, -1, &error);
+ if (self->priv->viewer_merge_id == 0) {
g_warning ("ui building failed: %s", error->message);
g_error_free (error);
}
@@ -878,9 +886,9 @@ gth_image_viewer_page_real_hide (GthViewerPage *base)
self = (GthImageViewerPage*) base;
- if (self->priv->merge_id != 0) {
- gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (self->priv->browser), self->priv->merge_id);
- self->priv->merge_id = 0;
+ if (self->priv->viewer_merge_id != 0) {
+ gtk_ui_manager_remove_ui (gth_browser_get_ui_manager (self->priv->browser), self->priv->viewer_merge_id);
+ self->priv->viewer_merge_id = 0;
}
}
@@ -1405,6 +1413,8 @@ gth_image_viewer_page_init (GthImageViewerPage *self)
self->priv->last_loaded = NULL;
self->priv->image_changed = FALSE;
self->priv->can_paste = FALSE;
+ self->priv->viewer_merge_id = 0;
+ self->priv->browser_merge_id = 0;
}
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index 167eb9f..5cf01c7 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -320,7 +320,7 @@ void
gth_browser_activate_action_viewer_properties (GtkAction *action,
GthBrowser *browser)
{
- gth_browser_show_viewer_properties (GTH_BROWSER (browser), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ gth_browser_show_file_properties (GTH_BROWSER (browser), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index a3e79ec..89e91e9 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -236,6 +236,11 @@ static GtkToggleActionEntry gth_browser_action_toggle_entries[] = {
N_("View file properties"),
G_CALLBACK (gth_browser_activate_action_viewer_properties),
FALSE },
+ { "Browser_Properties", GTK_STOCK_PROPERTIES,
+ NULL, NULL,
+ N_("View file properties"),
+ G_CALLBACK (gth_browser_activate_action_viewer_properties),
+ FALSE },
{ "Viewer_Tools", "palette",
N_("Edit"), NULL,
N_("Edit file"),
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index 1a5e919..3c6077b 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -121,6 +121,10 @@ static const char *fixed_ui_info =
" <separator/>"
" <placeholder name='Edit_Actions'/>"
" <placeholder name='Edit_Actions_2'/>"
+" <separator expand='true'/>"
+" <placeholder name='BrowserCommandsSecondary'/>"
+" <toolitem action='Viewer_Tools'/>"
+" <toolitem action='Browser_Properties'/>"
" </toolbar>"
" <toolbar name='ViewerToolBar'>"
@@ -135,6 +139,7 @@ static const char *fixed_ui_info =
" <placeholder name='Edit_Actions_2'/>"
" <separator expand='true'/>"
" <placeholder name='ViewerCommandsSecondary'/>"
+" <toolitem action='Viewer_Tools'/>"
" <toolitem action='Viewer_Properties'/>"
" </toolbar>"
@@ -150,6 +155,7 @@ static const char *fixed_ui_info =
" <placeholder name='Edit_Actions_2'/>"
" <separator expand='true'/>"
" <placeholder name='ViewerCommandsSecondary'/>"
+" <toolitem action='Viewer_Tools'/>"
" <toolitem action='Viewer_Properties'/>"
" </toolbar>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 80f0288..7513abc 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1675,11 +1675,11 @@ load_data_continue (LoadData *load_data,
}
else if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER) {
if (changed_current_location && ! _gth_browser_make_file_visible (browser, browser->priv->current_file))
- gtk_widget_hide (browser->priv->file_properties);
+ gth_browser_show_file_properties (browser, FALSE);
}
}
else if (changed_current_location)
- gtk_widget_hide (browser->priv->file_properties);
+ gth_browser_show_file_properties (browser, FALSE);
if (StartSlideshow) {
StartSlideshow = FALSE;
@@ -2088,6 +2088,7 @@ _gth_browser_deactivate_viewer_page (GthBrowser *browser)
gth_viewer_page_deactivate (browser->priv->viewer_page);
gtk_ui_manager_ensure_update (browser->priv->ui);
gth_browser_set_viewer_widget (browser, NULL);
+ _gth_browser_set_action_sensitive (browser, "Viewer_Tools", FALSE);
g_object_unref (browser->priv->viewer_page);
browser->priv->viewer_page = NULL;
}
@@ -2358,17 +2359,6 @@ _gth_browser_update_browser_ui (GthBrowser *browser,
static void
-_gth_browser_show_properties_in_browser_mode (GthBrowser *browser)
-{
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (browser->priv->browser_sidebar, &allocation);
- gtk_paned_set_position (GTK_PANED (browser->priv->browser_sidebar), allocation.height / 2);
- gtk_widget_show (browser->priv->file_properties);
-}
-
-
-static void
_gth_browser_real_set_current_page (GthWindow *window,
int page)
{
@@ -2400,12 +2390,13 @@ _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));
if (browser->priv->current_file != NULL)
- _gth_browser_show_properties_in_browser_mode (browser);
+ gth_browser_show_file_properties (browser, TRUE);
else {
gth_sidebar_set_file (GTH_SIDEBAR (browser->priv->file_properties), NULL);
- gtk_widget_hide (browser->priv->file_properties);
+ gth_browser_show_file_properties (browser, FALSE);
}
}
else if (page == GTH_BROWSER_PAGE_VIEWER) {
@@ -2418,7 +2409,7 @@ _gth_browser_real_set_current_page (GthWindow *window,
gtk_widget_show (browser->priv->file_properties);
}
else
- gtk_widget_hide (browser->priv->file_properties);
+ gth_browser_show_file_properties (browser, FALSE);
}
/* save the browser window size */
@@ -4573,6 +4564,8 @@ gth_browser_init (GthBrowser *browser)
browser->priv->shrink_wrap_viewer = eel_gconf_get_boolean (PREF_SHRINK_WRAP_VIEWER, FALSE);
_gth_browser_set_action_active (browser, "View_ShrinkWrap", browser->priv->shrink_wrap_viewer);
+ _gth_browser_set_action_sensitive (browser, "Viewer_Tools", FALSE);
+
browser->priv->fast_file_type = eel_gconf_get_boolean (PREF_FAST_FILE_TYPE, TRUE);
gth_hook_invoke ("gth-browser-construct", browser);
@@ -4807,6 +4800,13 @@ gth_browser_get_ui_manager (GthBrowser *browser)
}
+GtkActionGroup *
+gth_browser_get_actions (GthBrowser *browser)
+{
+ return browser->priv->actions;
+}
+
+
GthIconCache *
gth_browser_get_menu_icon_cache (GthBrowser *browser)
{
@@ -5129,7 +5129,7 @@ gth_browser_toggle_properties_on_screen (GthBrowser *browser)
gth_viewer_page_show_properties (browser->priv->viewer_page, browser->priv->properties_on_screen);
}
else
- gth_browser_show_viewer_properties (browser, ! _gth_browser_get_action_active (browser, "Viewer_Properties"));
+ gth_browser_show_file_properties (browser, ! _gth_browser_get_action_active (browser, "Viewer_Properties"));
}
@@ -5502,7 +5502,7 @@ file_metadata_ready_cb (GList *files,
if ((gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER)
&& ! gtk_widget_get_visible (browser->priv->file_properties))
{
- _gth_browser_show_properties_in_browser_mode (browser);
+ gth_browser_show_file_properties (browser, TRUE);
if (browser->priv->location != NULL) {
GtkTreePath *path;
@@ -5753,19 +5753,35 @@ gth_browser_load_file (GthBrowser *browser,
void
-gth_browser_show_viewer_properties (GthBrowser *browser,
+gth_browser_show_file_properties (GthBrowser *browser,
gboolean show)
{
- _gth_browser_set_action_active (browser, "Viewer_Properties", show);
+ switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
+ case GTH_BROWSER_PAGE_BROWSER:
+ _gth_browser_set_action_active (browser, "Browser_Properties", show);
+ if (show) {
+ GtkAllocation allocation;
- 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));
+ gtk_widget_get_allocation (browser->priv->browser_sidebar, &allocation);
+ gtk_paned_set_position (GTK_PANED (browser->priv->browser_sidebar), allocation.height / 2);
+ gtk_widget_show (browser->priv->file_properties);
+ }
+ else
+ gtk_widget_hide (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);
+ break;
}
- else
- gtk_widget_hide (browser->priv->viewer_sidebar_alignment);
}
@@ -5773,8 +5789,13 @@ void
gth_browser_show_viewer_tools (GthBrowser *browser,
gboolean show)
{
+ if (show)
+ gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER);
_gth_browser_set_action_active (browser, "Viewer_Tools", show);
+ if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_BROWSER_PAGE_VIEWER)
+ return;
+
if (show) {
_gth_browser_set_action_active (browser, "Viewer_Properties", FALSE);
gtk_widget_show (browser->priv->viewer_sidebar_alignment);
@@ -6252,7 +6273,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_viewer_properties (browser, FALSE);
+ gth_browser_show_file_properties (browser, FALSE);
gth_browser_show_viewer_tools (browser, FALSE);
_gth_browser_set_thumbnail_list_visibility (browser, FALSE);
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_VIEWER);
@@ -6295,11 +6316,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_viewer_properties (browser, TRUE);
+ gth_browser_show_file_properties (browser, TRUE);
else if (browser->priv->before_fullscreen.viewer_tools)
gth_browser_show_viewer_tools (browser, TRUE);
else {
- gth_browser_show_viewer_properties (browser, FALSE);
+ gth_browser_show_file_properties (browser, FALSE);
gth_browser_show_viewer_tools (browser, FALSE);
}
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 6b622bb..556e8db 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -101,6 +101,7 @@ void gth_browser_set_dialog (GthBrowser *browser,
GtkWidget * gth_browser_get_dialog (GthBrowser *browser,
const char *dialog_name);
GtkUIManager * gth_browser_get_ui_manager (GthBrowser *browser);
+GtkActionGroup * gth_browser_get_actions (GthBrowser *browser);
GthIconCache * gth_browser_get_menu_icon_cache (GthBrowser *browser);
GtkWidget * gth_browser_get_browser_toolbar (GthBrowser *browser);
GtkWidget * gth_browser_get_infobar (GthBrowser *browser);
@@ -160,7 +161,7 @@ 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_viewer_properties (GthBrowser *browser,
+void gth_browser_show_file_properties (GthBrowser *browser,
gboolean show);
void gth_browser_show_viewer_tools (GthBrowser *browser,
gboolean show);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]