[gthumb/ext: 79/79] made the keyword shortcuts extensible
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 79/79] made the keyword shortcuts extensible
- Date: Sun, 2 Aug 2009 20:34:53 +0000 (UTC)
commit efb72fd1a6e8312561c94d36541e6ca7b3f294a9
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Aug 2 20:56:23 2009 +0200
made the keyword shortcuts extensible
extensions/file_manager/callbacks.c | 31 ++++++++++++
extensions/file_manager/callbacks.h | 26 ++++++-----
extensions/file_manager/main.c | 1 +
extensions/image_viewer/gth-image-viewer-page.c | 2 +-
gthumb/gth-browser.c | 57 +++++++++++++++++++++++
gthumb/gth-main-default-hooks.c | 8 +++
gthumb/gtk-utils.c | 28 +++++++++++
gthumb/gtk-utils.h | 4 ++
8 files changed, 144 insertions(+), 13 deletions(-)
---
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index 57bd5fc..387af9c 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -24,6 +24,7 @@
#include <config.h>
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <gdk/gdkkeysyms.h>
#include <gthumb.h>
#include "actions.h"
@@ -608,3 +609,33 @@ fm__gth_browser_unrealize_cb (GthBrowser *browser)
G_CALLBACK (clipboard_owner_change_cb),
browser);
}
+
+
+gpointer
+fm__gth_browser_file_list_key_press_cb (GthBrowser *browser,
+ GdkEventKey *event)
+{
+ gpointer result = NULL;
+ GList *items;
+ GList *file_data_list;
+ GList *file_list;
+
+ if ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_MOD1_MASK))
+ return NULL;
+
+ switch (gdk_keyval_to_lower (event->keyval)) {
+ case GDK_g:
+ items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+ file_data_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+ file_list = gth_file_data_list_to_file_list (file_data_list);
+ _g_launch_command (GTK_WIDGET (browser), "gimp", "Gimp", file_list);
+
+ _g_object_list_unref (file_list);
+ _g_object_list_unref (file_data_list);
+ _gtk_tree_path_list_free (items);
+ result = GINT_TO_POINTER (1);
+ break;
+ }
+
+ return result;
+}
diff --git a/extensions/file_manager/callbacks.h b/extensions/file_manager/callbacks.h
index bf8bc01..d891600 100644
--- a/extensions/file_manager/callbacks.h
+++ b/extensions/file_manager/callbacks.h
@@ -25,17 +25,19 @@
#include <gthumb.h>
-void fm__gth_browser_construct_cb (GthBrowser *browser);
-void fm__gth_browser_update_sensitivity_cb (GthBrowser *browser);
-void fm__gth_browser_set_current_page_cb (GthBrowser *browser);
-void fm__gth_browser_load_location_after_cb (GthBrowser *browser,
- GFile *location,
- GError *error);
-void fm__gth_browser_folder_tree_popup_before_cb (GthBrowser *browser,
- GthFileSource *file_source,
- GFile *folder);
-void fm__gth_browser_selection_changed_cb (GthBrowser *browser);
-void fm__gth_browser_realize_cb (GthBrowser *browser);
-void fm__gth_browser_unrealize_cb (GthBrowser *browser);
+void fm__gth_browser_construct_cb (GthBrowser *browser);
+void fm__gth_browser_update_sensitivity_cb (GthBrowser *browser);
+void fm__gth_browser_set_current_page_cb (GthBrowser *browser);
+void fm__gth_browser_load_location_after_cb (GthBrowser *browser,
+ GFile *location,
+ GError *error);
+void fm__gth_browser_folder_tree_popup_before_cb (GthBrowser *browser,
+ GthFileSource *file_source,
+ GFile *folder);
+void fm__gth_browser_selection_changed_cb (GthBrowser *browser);
+void fm__gth_browser_realize_cb (GthBrowser *browser);
+void fm__gth_browser_unrealize_cb (GthBrowser *browser);
+gpointer fm__gth_browser_file_list_key_press_cb (GthBrowser *browser,
+ GdkEventKey *event);
#endif /* CALLBACKS_H */
diff --git a/extensions/file_manager/main.c b/extensions/file_manager/main.c
index 259a9b5..a2a6d2d 100644
--- a/extensions/file_manager/main.c
+++ b/extensions/file_manager/main.c
@@ -38,6 +38,7 @@ gthumb_extension_activate (void)
gth_hook_add_callback ("gth-browser-realize", 10, G_CALLBACK (fm__gth_browser_realize_cb), NULL);
gth_hook_add_callback ("gth-browser-unrealize", 10, G_CALLBACK (fm__gth_browser_unrealize_cb), NULL);
gth_hook_add_callback ("gth-browser-selection-changed", 10, G_CALLBACK (fm__gth_browser_selection_changed_cb), NULL);
+ gth_hook_add_callback ("gth-browser-file-list-key-press", 10, G_CALLBACK (fm__gth_browser_file_list_key_press_cb), NULL);
}
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index b385b6e..3c875f2 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -262,7 +262,7 @@ viewer_key_press_cb (GtkWidget *widget,
return TRUE;
}
- return FALSE;
+ return gth_hook_invoke_get ("gth-browser-file-list-key-press", self->priv->browser, event) != NULL;
}
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 77f7dd6..1f3b28f 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include "dlg-personalize-filters.h"
#include "gconf-utils.h"
#include "glib-utils.h"
@@ -2633,6 +2634,58 @@ gth_file_view_item_activated_cb (GtkIconView *iconview,
}
+static gboolean
+gth_file_list_key_press_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer user_data)
+{
+ GthBrowser *browser = user_data;
+ gboolean result = FALSE;
+
+ if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_MOD1_MASK)) {
+ switch (gdk_keyval_to_lower (event->keyval)) {
+ case GDK_f:
+ gth_browser_fullscreen (browser);
+ result = TRUE;
+ break;
+
+ /* FIXME: add these to the image viewer
+ case GDK_b:
+ case GDK_BackSpace:
+ gth_browser_show_prev_image (browser, FALSE, FALSE);
+ result = TRUE;
+ break;
+
+ case GDK_n:
+ gth_browser_show_next_image (browser, FALSE, FALSE);
+ result = TRUE;
+ break;
+ */
+
+ /* FIXME: add these to the rotate extension
+ case GDK_bracketright:
+ gth_window_activate_action_tools_jpeg_rotate_right (NULL, window);
+ result = TRUE;
+ break;
+
+ case GDK_bracketleft:
+ gth_window_activate_action_tools_jpeg_rotate_left (NULL, window);
+ result = TRUE;
+ break;
+ */
+
+ default:
+ break;
+ }
+ }
+
+ if (! result)
+ result = gth_hook_invoke_get ("gth-browser-file-list-key-press", browser, event) != NULL;
+
+ return result;
+}
+
+
static void
add_browser_toolbar_menu_buttons (GthBrowser *browser)
{
@@ -3136,6 +3189,10 @@ _gth_browser_construct (GthBrowser *browser)
"item_activated",
G_CALLBACK (gth_file_view_item_activated_cb),
browser);
+ g_signal_connect (G_OBJECT (browser->priv->file_list),
+ "key_press_event",
+ G_CALLBACK (gth_file_list_key_press_cb),
+ browser);
browser->priv->file_list_popup = gtk_ui_manager_get_widget (browser->priv->ui, "/FileListPopup");
diff --git a/gthumb/gth-main-default-hooks.c b/gthumb/gth-main-default-hooks.c
index 895da30..7d3a73c 100644
--- a/gthumb/gth-main-default-hooks.c
+++ b/gthumb/gth-main-default-hooks.c
@@ -127,6 +127,14 @@ gth_main_register_default_hooks (void)
gth_hook_register ("gth-browser-selection-changed", 1);
/**
+ * Called after a key press in the file list
+ *
+ * @browser (GthBrowser*): the relative window.
+ * @event (GdkEventKey *); the key event.
+ */
+ gth_hook_register ("gth-browser-file-list-key-press", 2);
+
+ /**
* Called in _gdk_pixbuf_save_async
*
* @data (SavePixbufData*):
diff --git a/gthumb/gtk-utils.c b/gthumb/gtk-utils.c
index f1d1d1c..8ce64f0 100644
--- a/gthumb/gtk-utils.c
+++ b/gthumb/gtk-utils.c
@@ -1049,3 +1049,31 @@ _gtk_paned_set_position2 (GtkPaned *paned,
if (pos > 0)
gtk_paned_set_position (paned, size - pos);
}
+
+
+void
+_g_launch_command (GtkWidget *parent,
+ const char *command,
+ const char *name,
+ GList *files)
+{
+ GError *error = NULL;
+ GAppInfo *app_info;
+ GdkAppLaunchContext *launch_context;
+
+ app_info = g_app_info_create_from_commandline (command, name, G_APP_INFO_CREATE_SUPPORTS_URIS, &error);
+ if (app_info == NULL) {
+ _gtk_error_dialog_from_gerror_show(GTK_WINDOW (parent), _("Could not launch the application"), &error);
+ return;
+ }
+
+ launch_context = gdk_app_launch_context_new ();
+ gdk_app_launch_context_set_screen (launch_context, gtk_widget_get_screen (parent));
+
+ if (! g_app_info_launch (app_info, files, G_APP_LAUNCH_CONTEXT (launch_context), &error)) {
+ _gtk_error_dialog_from_gerror_show(GTK_WINDOW (parent), _("Could not launch the application"), &error);
+ return;
+ }
+
+ g_object_unref (app_info);
+}
diff --git a/gthumb/gtk-utils.h b/gthumb/gtk-utils.h
index 7eecc74..83716e4 100644
--- a/gthumb/gtk-utils.h
+++ b/gthumb/gtk-utils.h
@@ -117,6 +117,10 @@ void _gtk_tree_path_list_free (GList *list);
int _gtk_paned_get_position2 (GtkPaned *paned);
void _gtk_paned_set_position2 (GtkPaned *paned,
int pos);
+void _g_launch_command (GtkWidget *parent,
+ const char *command,
+ const char *name,
+ GList *files);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]