[gthumb/ext: 49/79] added a generic file popup menu, used in all the viewers
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 49/79] added a generic file popup menu, used in all the viewers
- Date: Sun, 2 Aug 2009 20:30:13 +0000 (UTC)
commit 43e2e2d00fb66273cb2df2a8a30e33dd86627345
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 14 19:57:21 2009 +0200
added a generic file popup menu, used in all the viewers
extensions/catalogs/callbacks.c | 10 +++++++
extensions/file_manager/callbacks.c | 33 ++++++++++++++++-------
extensions/file_viewer/gth-file-viewer-page.c | 18 ++++++++++++
extensions/image_viewer/gth-image-viewer-page.c | 9 +-----
gthumb/gth-browser-actions-callbacks.c | 22 +++++++++++++++
gthumb/gth-browser-actions-callbacks.h | 1 +
gthumb/gth-browser-actions-entries.h | 5 +++
gthumb/gth-browser-ui.h | 15 ++++++++++
gthumb/gth-browser.c | 20 ++++++++++++++
gthumb/gth-browser.h | 2 +
10 files changed, 117 insertions(+), 18 deletions(-)
---
diff --git a/extensions/catalogs/callbacks.c b/extensions/catalogs/callbacks.c
index ea2851c..e65e01a 100644
--- a/extensions/catalogs/callbacks.c
+++ b/extensions/catalogs/callbacks.c
@@ -39,6 +39,11 @@ static const char *fixed_ui_info =
" <menuitem action='Edit_AddToCatalog'/>"
" </placeholder>"
" </popup>"
+" <popup name='FilePopup'>"
+" <placeholder name='Folder_Actions2'>"
+" <menuitem action='Edit_AddToCatalog'/>"
+" </placeholder>"
+" </popup>"
"</ui>";
@@ -49,6 +54,11 @@ static const char *vfs_ui_info =
" <menuitem action='Edit_RemoveFromCatalog'/>"
" </placeholder>"
" </popup>"
+" <popup name='FilePopup'>"
+" <placeholder name='Folder_Actions2'>"
+" <menuitem action='Edit_RemoveFromCatalog'/>"
+" </placeholder>"
+" </popup>"
"</ui>";
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index 88c85dc..8a6de8e 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -44,6 +44,24 @@ static const char *vfs_ui_info =
" </placeholder>"
" </menu>"
" </menubar>"
+" <popup name='FileListPopup'>"
+" <placeholder name='File_Actions'>"
+" <menuitem action='Edit_CutFiles'/>"
+" <menuitem action='Edit_CopyFiles'/>"
+" <menuitem action='Edit_PasteInFolder'/>"
+" </placeholder>"
+" </popup>"
+" <popup name='FilePopup'>"
+" <placeholder name='File_Actions'>"
+" <menuitem action='Edit_CutFiles'/>"
+" <menuitem action='Edit_CopyFiles'/>"
+" <menuitem action='Edit_PasteInFolder'/>"
+" </placeholder>"
+" <placeholder name='Folder_Actions'>"
+" <menuitem action='Edit_Trash'/>"
+" <menuitem action='Edit_Delete'/>"
+" </placeholder>"
+" </popup>"
"</ui>";
@@ -58,13 +76,6 @@ static const char *browser_ui_info =
" </placeholder>"
" </menu>"
" </menubar>"
-" <popup name='FileListPopup'>"
-" <placeholder name='File_Actions'>"
-" <menuitem action='Edit_CutFiles'/>"
-" <menuitem action='Edit_CopyFiles'/>"
-" <menuitem action='Edit_PasteInFolder'/>"
-" </placeholder>"
-" </popup>"
"</ui>";
@@ -466,7 +477,8 @@ activate_open_with_application_item (GtkMenuItem *menuitem,
static void
-_gth_browser_update_open_menu (GthBrowser *browser)
+_gth_browser_update_open_menu (GthBrowser *browser,
+ const char *path)
{
GtkWidget *openwith_item;
GtkWidget *menu;
@@ -477,7 +489,7 @@ _gth_browser_update_open_menu (GthBrowser *browser)
GthIconCache *icon_cache;
GHashTable *used_apps;
- openwith_item = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/FileListPopup/OpenWith");
+ openwith_item = gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), path);
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (openwith_item));
_gtk_container_remove_children (GTK_CONTAINER (menu), NULL, NULL);
@@ -558,7 +570,8 @@ _gth_browser_update_open_menu (GthBrowser *browser)
void
fm__gth_browser_selection_changed_cb (GthBrowser *browser)
{
- _gth_browser_update_open_menu (browser);
+ _gth_browser_update_open_menu (browser, "/FileListPopup/OpenWith");
+ _gth_browser_update_open_menu (browser, "/FilePopup/OpenWith");
}
diff --git a/extensions/file_viewer/gth-file-viewer-page.c b/extensions/file_viewer/gth-file-viewer-page.c
index 8517b25..51a54f9 100644
--- a/extensions/file_viewer/gth-file-viewer-page.c
+++ b/extensions/file_viewer/gth-file-viewer-page.c
@@ -77,6 +77,20 @@ thumb_loader_ready_cb (GthThumbLoader *il,
}
+static gboolean
+viewer_button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ GthFileViewerPage *self)
+{
+ if (event->button == 3) {
+ gth_browser_file_menu_popup (self->priv->browser, event);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
static void
gth_file_viewer_page_real_activate (GthViewerPage *base,
GthBrowser *browser)
@@ -126,6 +140,10 @@ gth_file_viewer_page_real_activate (GthViewerPage *base,
"scroll-event",
G_CALLBACK (viewer_scroll_event_cb),
self);
+ g_signal_connect (G_OBJECT (self->priv->viewer),
+ "button_press_event",
+ G_CALLBACK (viewer_button_press_cb),
+ self);
gth_browser_set_viewer_widget (browser, self->priv->viewer);
gtk_widget_grab_focus (self->priv->viewer);
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 0f6f8b9..1dd01c6 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -217,15 +217,8 @@ image_button_press_cb (GtkWidget *widget,
GthImageViewerPage *self)
{
if (event->button == 3) {
- /*gtk_menu_popup (GTK_MENU (self->priv->image_popup_menu),
- NULL,
- NULL,
- NULL,
- NULL,
- 3,
- event->time);
+ gth_browser_file_menu_popup (self->priv->browser, event);
return TRUE;
- */
}
return FALSE;
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index bdf52c3..dfbe6f6 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -327,6 +327,28 @@ gth_browser_activate_action_folder_open_in_new_window (GtkAction *action,
void
+gth_browser_activate_action_folder_open_in_file_manager (GtkAction *action,
+ GthBrowser *browser)
+{
+ GFile *location;
+ char *uri;
+ GError *error = NULL;
+
+ location = gth_browser_get_location (browser);
+ uri = g_file_get_uri (location);
+ if (! gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (browser)),
+ uri,
+ gtk_get_current_event_time (),
+ &error))
+ {
+ _gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), _("Could not open location"), &error);
+ }
+
+ g_free (uri);
+}
+
+
+void
gth_browser_activate_action_browser_mode (GtkAction *action,
GthBrowser *browser)
{
diff --git a/gthumb/gth-browser-actions-callbacks.h b/gthumb/gth-browser-actions-callbacks.h
index 515c34c..f1caabb 100644
--- a/gthumb/gth-browser-actions-callbacks.h
+++ b/gthumb/gth-browser-actions-callbacks.h
@@ -41,6 +41,7 @@ DEFINE_ACTION(gth_browser_activate_action_file_save)
DEFINE_ACTION(gth_browser_activate_action_file_save_as)
DEFINE_ACTION(gth_browser_activate_action_folder_open)
DEFINE_ACTION(gth_browser_activate_action_folder_open_in_new_window)
+DEFINE_ACTION(gth_browser_activate_action_folder_open_in_file_manager)
DEFINE_ACTION(gth_browser_activate_action_go_back)
DEFINE_ACTION(gth_browser_activate_action_go_forward)
DEFINE_ACTION(gth_browser_activate_action_go_up)
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index eabd204..4238176 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -71,6 +71,11 @@ static GtkActionEntry gth_browser_action_entries[] = {
NULL,
G_CALLBACK (gth_browser_activate_action_folder_open_in_new_window) },
+ { "Folder_OpenInFileManager", NULL,
+ N_("Open with the _File Manager"), "",
+ NULL,
+ G_CALLBACK (gth_browser_activate_action_folder_open_in_file_manager) },
+
{ "Edit_Preferences", GTK_STOCK_PREFERENCES,
NULL, NULL,
N_("Edit various preferences"),
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index 336440b..3dcea91 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -163,9 +163,24 @@ static const char *fixed_ui_info =
" <menuitem action='Edit_Metadata'/>"
" </popup>"
+" <popup name='FilePopup'>"
+" <menu name='OpenWith' action='OpenWithMenu'>"
+" </menu>"
+" <placeholder name='Open_Actions'/>"
+" <separator/>"
+" <placeholder name='File_Actions'/>"
+" <separator/>"
+" <placeholder name='Folder_Actions'/>"
+" <separator/>"
+" <placeholder name='Folder_Actions2'/>"
+" <separator/>"
+" <menuitem action='Edit_Metadata'/>"
+" </popup>"
+
" <popup name='FolderListPopup'>"
" <menuitem action='Folder_Open'/>"
" <menuitem action='Folder_OpenInNewWindow'/>"
+" <menuitem action='Folder_OpenInFileManager'/>"
" <separator/>"
" <placeholder name='SourceCommands'/>"
" </popup>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index a6d9d13..ce1a02b 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -100,6 +100,7 @@ struct _GthBrowserPrivateData {
GtkWidget *history_list_popup_menu;
GtkWidget *folder_popup;
GtkWidget *file_list_popup;
+ GtkWidget *file_popup;
GtkWidget *filterbar;
GtkWidget *file_list;
GtkWidget *list_extra_widget_container;
@@ -1560,6 +1561,8 @@ _gth_browser_close_final_step (gpointer user_data)
gtk_widget_destroy (browser->priv->folder_popup);
if (browser->priv->file_list_popup != NULL)
gtk_widget_destroy (browser->priv->file_list_popup);
+ if (browser->priv->file_popup != NULL)
+ gtk_widget_destroy (browser->priv->file_popup);
gtk_widget_destroy (GTK_WIDGET (browser));
}
@@ -2946,6 +2949,8 @@ _gth_browser_construct (GthBrowser *browser)
/* init browser data */
+ browser->priv->file_popup = gtk_ui_manager_get_widget (browser->priv->ui, "/FilePopup");
+
_gtk_paned_set_position2 (GTK_PANED (browser->priv->viewer_pane), eel_gconf_get_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, DEFAULT_UI_WINDOW_WIDTH - DEF_SIDEBAR_WIDTH));
_gtk_paned_set_position2 (GTK_PANED (browser->priv->browser_sidebar), eel_gconf_get_integer (PREF_UI_PROPERTIES_HEIGHT, DEF_PROPERTIES_HEIGHT));
@@ -3600,6 +3605,7 @@ _gth_browser_make_file_visible (GthBrowser *browser,
gth_file_selection_unselect_all (GTH_FILE_SELECTION (view));
gth_file_selection_select (GTH_FILE_SELECTION (view), file_pos);
gth_file_view_set_cursor (GTH_FILE_VIEW (view), file_pos);
+ gth_hook_invoke ("gth-browser-selection-changed", browser);
g_signal_handlers_unblock_by_func (gth_browser_get_file_list_view (browser), gth_file_view_selection_changed_cb, browser);
visibility = gth_file_view_get_visibility (GTH_FILE_VIEW (view), file_pos);
@@ -4115,3 +4121,17 @@ gth_browser_unfullscreen (GthBrowser *browser)
}
gth_browser_update_sensitivity (browser);
}
+
+
+void
+gth_browser_file_menu_popup (GthBrowser *browser,
+ GdkEventButton *event)
+{
+ gtk_menu_popup (GTK_MENU (browser->priv->file_popup),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 3,
+ event->time);
+}
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index f97701d..9c412d4 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -148,6 +148,8 @@ void gth_browser_show_filterbar (GthBrowser *browser,
gpointer gth_browser_get_image_preloader (GthBrowser *browser);
void gth_browser_fullscreen (GthBrowser *browser);
void gth_browser_unfullscreen (GthBrowser *browser);
+void gth_browser_file_menu_popup (GthBrowser *browser,
+ GdkEventButton *event);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]