[gthumb] added other keyboard shortcuts in image viewer mode
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added other keyboard shortcuts in image viewer mode
- Date: Mon, 12 Jul 2010 09:55:19 +0000 (UTC)
commit c48dc4c54fb72374bb727fdeb83703fa7ba18282
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jul 12 11:52:59 2010 +0200
added other keyboard shortcuts in image viewer mode
'h': enhance the image
'l': flip the image
'm': mirror the image
'r': rotate right
'R': rotate left
'i': view/hide the image properties
extensions/file_tools/Makefile.am | 2 +
extensions/file_tools/callbacks.c | 78 ++++++++++++++++++++++++++++++++
extensions/file_tools/callbacks.h | 31 +++++++++++++
extensions/file_tools/main.c | 3 +
gthumb/gth-browser-actions-callbacks.c | 2 +-
gthumb/gth-browser.c | 48 +++++++++++---------
gthumb/gth-sidebar.c | 11 ++++-
gthumb/gth-sidebar.h | 3 +-
gthumb/gth-toolbox.c | 30 +++++++++++-
gthumb/gth-toolbox.h | 4 +-
10 files changed, 183 insertions(+), 29 deletions(-)
---
diff --git a/extensions/file_tools/Makefile.am b/extensions/file_tools/Makefile.am
index 8ec87af..7785eff 100644
--- a/extensions/file_tools/Makefile.am
+++ b/extensions/file_tools/Makefile.am
@@ -48,6 +48,8 @@ enum-types.c: $(HEADER_FILES) enum-types.h
libfile_tools_la_SOURCES = \
$(ENUM_TYPES) \
$(HEADER_FILES) \
+ callbacks.c \
+ callbacks.h \
gth-file-tool-adjust-colors.c \
gth-file-tool-crop.c \
gth-file-tool-desaturate.c \
diff --git a/extensions/file_tools/callbacks.c b/extensions/file_tools/callbacks.c
new file mode 100644
index 0000000..7cf1572
--- /dev/null
+++ b/extensions/file_tools/callbacks.c
@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gdk/gdkkeysyms.h>
+#include <gthumb.h>
+#include "gth-file-tool-enhance.h"
+#include "gth-file-tool-flip.h"
+#include "gth-file-tool-mirror.h"
+#include "gth-file-tool-rotate-left.h"
+#include "gth-file-tool-rotate-right.h"
+
+
+gpointer
+file_tools__gth_browser_file_list_key_press_cb (GthBrowser *browser,
+ GdkEventKey *event)
+{
+ gpointer result = NULL;
+ GtkWidget *sidebar;
+ GtkWidget *toolbox;
+ GthFileTool *tool = NULL;
+
+ if ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_MOD1_MASK))
+ return NULL;
+
+ if (gth_window_get_current_page (GTH_WINDOW (browser)) != GTH_BROWSER_PAGE_VIEWER)
+ return NULL;
+
+ sidebar = gth_browser_get_viewer_sidebar (browser);
+ toolbox = gth_sidebar_get_toolbox (GTH_SIDEBAR (sidebar));
+
+ switch (event->keyval) {
+ case GDK_h:
+ tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_ENHANCE);
+ break;
+ case GDK_l:
+ tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_FLIP);
+ break;
+ case GDK_m:
+ tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_MIRROR);
+ break;
+ case GDK_r:
+ tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_ROTATE_RIGHT);
+ break;
+ case GDK_R:
+ tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_ROTATE_LEFT);
+ break;
+ }
+
+ if (tool != NULL) {
+ gth_file_tool_activate (tool);
+ result = GINT_TO_POINTER (1);
+ }
+
+ return result;
+}
diff --git a/extensions/file_tools/callbacks.h b/extensions/file_tools/callbacks.h
new file mode 100644
index 0000000..f59425a
--- /dev/null
+++ b/extensions/file_tools/callbacks.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CALLBACKS_H
+#define CALLBACKS_H
+
+#include <gthumb.h>
+
+gpointer file_tools__gth_browser_file_list_key_press_cb (GthBrowser *browser,
+ GdkEventKey *event);
+
+#endif /* CALLBACKS_H */
diff --git a/extensions/file_tools/main.c b/extensions/file_tools/main.c
index 4444c3d..302e764 100644
--- a/extensions/file_tools/main.c
+++ b/extensions/file_tools/main.c
@@ -24,6 +24,7 @@
#include <config.h>
#include <gtk/gtk.h>
#include <gthumb.h>
+#include "callbacks.h"
#include "gth-file-tool-adjust-colors.h"
#include "gth-file-tool-crop.h"
#include "gth-file-tool-desaturate.h"
@@ -62,6 +63,8 @@ gthumb_extension_activate (void)
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_RESIZE);
gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_CROP);
+
+ gth_hook_add_callback ("gth-browser-file-list-key-press", 10, G_CALLBACK (file_tools__gth_browser_file_list_key_press_cb), NULL);
}
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index 3ad66eb..af19a7f 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -321,7 +321,7 @@ gth_browser_activate_action_browser_mode (GtkAction *action,
GtkWidget *viewer_sidebar;
viewer_sidebar = gth_browser_get_viewer_sidebar (browser);
- if (gth_sidebar_is_tool_active (GTH_SIDEBAR (viewer_sidebar)))
+ if (gth_sidebar_tool_is_active (GTH_SIDEBAR (viewer_sidebar)))
gth_sidebar_deactivate_tool (GTH_SIDEBAR (viewer_sidebar));
else
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER);
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 05f03a0..4392920 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -4616,32 +4616,38 @@ gth_browser_viewer_key_press_cb (GthBrowser *browser,
{
g_return_val_if_fail (event != NULL, FALSE);
- switch (gdk_keyval_to_lower (event->keyval)) {
- case GDK_Page_Up:
- case GDK_BackSpace:
- gth_browser_show_prev_image (browser, FALSE, FALSE);
- return TRUE;
+ if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_MOD1_MASK)) {
+ switch (event->keyval) {
+ case GDK_Page_Up:
+ case GDK_BackSpace:
+ gth_browser_show_prev_image (browser, FALSE, FALSE);
+ return TRUE;
- case GDK_Page_Down:
- case GDK_space:
- gth_browser_show_next_image (browser, FALSE, FALSE);
- return TRUE;
+ case GDK_Page_Down:
+ case GDK_space:
+ gth_browser_show_next_image (browser, FALSE, FALSE);
+ return TRUE;
- case GDK_Home:
- gth_browser_show_first_image (browser, FALSE, FALSE);
- return TRUE;
+ case GDK_Home:
+ gth_browser_show_first_image (browser, FALSE, FALSE);
+ return TRUE;
- case GDK_End:
- gth_browser_show_last_image (browser, FALSE, FALSE);
- return TRUE;
+ case GDK_End:
+ gth_browser_show_last_image (browser, FALSE, FALSE);
+ return TRUE;
- case GDK_e:
- gth_browser_show_viewer_tools (GTH_BROWSER (browser), ! _gth_browser_get_action_active (browser, "Viewer_Tools"));
- return TRUE;
+ case GDK_e:
+ gth_browser_show_viewer_tools (GTH_BROWSER (browser), ! _gth_browser_get_action_active (browser, "Viewer_Tools"));
+ return TRUE;
- case GDK_f:
- gth_browser_fullscreen (browser);
- break;
+ case GDK_i:
+ gth_browser_show_viewer_properties (GTH_BROWSER (browser), ! _gth_browser_get_action_active (browser, "Viewer_Properties"));
+ return TRUE;
+
+ case GDK_f:
+ gth_browser_fullscreen (browser);
+ break;
+ }
}
return gth_hook_invoke_get ("gth-browser-file-list-key-press", browser, event) != NULL;
diff --git a/gthumb/gth-sidebar.c b/gthumb/gth-sidebar.c
index f3ce934..7e81442 100644
--- a/gthumb/gth-sidebar.c
+++ b/gthumb/gth-sidebar.c
@@ -139,6 +139,13 @@ gth_sidebar_new (const char *name)
}
+GtkWidget *
+gth_sidebar_get_toolbox (GthSidebar *sidebar)
+{
+ return sidebar->priv->toolbox;
+}
+
+
void
gth_sidebar_set_file (GthSidebar *sidebar,
GthFileData *file_data)
@@ -180,9 +187,9 @@ gth_sidebar_show_tools (GthSidebar *sidebar)
gboolean
-gth_sidebar_is_tool_active (GthSidebar *sidebar)
+gth_sidebar_tool_is_active (GthSidebar *sidebar)
{
- return gth_toolbox_is_tool_active (GTH_TOOLBOX (sidebar->priv->toolbox));
+ return gth_toolbox_tool_is_active (GTH_TOOLBOX (sidebar->priv->toolbox));
}
diff --git a/gthumb/gth-sidebar.h b/gthumb/gth-sidebar.h
index a36cab4..e4dada5 100644
--- a/gthumb/gth-sidebar.h
+++ b/gthumb/gth-sidebar.h
@@ -66,11 +66,12 @@ struct _GthPropertyViewIface {
GType gth_sidebar_get_type (void);
GtkWidget * gth_sidebar_new (const char *name);
+GtkWidget * gth_sidebar_get_toolbox (GthSidebar *sidebar);
void gth_sidebar_set_file (GthSidebar *sidebar,
GthFileData *file_data);
void gth_sidebar_show_properties (GthSidebar *sidebar);
void gth_sidebar_show_tools (GthSidebar *sidebar);
-gboolean gth_sidebar_is_tool_active (GthSidebar *sidebar);
+gboolean gth_sidebar_tool_is_active (GthSidebar *sidebar);
void gth_sidebar_deactivate_tool (GthSidebar *sidebar);
void gth_sidebar_update_sensitivity (GthSidebar *sidebar);
diff --git a/gthumb/gth-toolbox.c b/gthumb/gth-toolbox.c
index 2629fb0..ef64fb2 100644
--- a/gthumb/gth-toolbox.c
+++ b/gthumb/gth-toolbox.c
@@ -260,7 +260,7 @@ child_hide_options_cb (GtkWidget *tool,
static void
-_gth_toolbox_add_childs (GthToolbox *toolbox)
+_gth_toolbox_add_children (GthToolbox *toolbox)
{
GArray *children;
int i;
@@ -299,7 +299,7 @@ gth_toolbox_new (const char *name)
GtkWidget *toolbox;
toolbox = g_object_new (GTH_TYPE_TOOLBOX, "name", name, NULL);
- _gth_toolbox_add_childs (GTH_TOOLBOX (toolbox));
+ _gth_toolbox_add_children (GTH_TOOLBOX (toolbox));
return toolbox;
}
@@ -334,7 +334,31 @@ gth_toolbox_deactivate_tool (GthToolbox *toolbox)
gboolean
-gth_toolbox_is_tool_active (GthToolbox *toolbox)
+gth_toolbox_tool_is_active (GthToolbox *toolbox)
{
return toolbox->priv->active_tool != NULL;
}
+
+
+GtkWidget *
+gth_toolbox_get_tool (GthToolbox *toolbox,
+ GType tool_type)
+{
+ GtkWidget *tool = NULL;
+ GList *children;
+ GList *scan;
+
+ children = gtk_container_get_children (GTK_CONTAINER (toolbox->priv->box));
+ for (scan = children; scan; scan = scan->next) {
+ GtkWidget *child = scan->data;
+
+ if (G_OBJECT_TYPE (child) == tool_type) {
+ tool = child;
+ break;
+ }
+ }
+
+ g_list_free (children);
+
+ return tool;
+}
diff --git a/gthumb/gth-toolbox.h b/gthumb/gth-toolbox.h
index 455a67d..f64c1ae 100644
--- a/gthumb/gth-toolbox.h
+++ b/gthumb/gth-toolbox.h
@@ -53,7 +53,9 @@ GType gth_toolbox_get_type (void);
GtkWidget * gth_toolbox_new (const char *name);
void gth_toolbox_update_sensitivity (GthToolbox *toolbox);
void gth_toolbox_deactivate_tool (GthToolbox *toolbox);
-gboolean gth_toolbox_is_tool_active (GthToolbox *toolbox);
+gboolean gth_toolbox_tool_is_active (GthToolbox *toolbox);
+GtkWidget * gth_toolbox_get_tool (GthToolbox *toolbox,
+ GType tool_type);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]