[gthumb] use gtk_accelerator_get_default_mod_mask to test for modifier keys
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] use gtk_accelerator_get_default_mod_mask to test for modifier keys
- Date: Sun, 18 Jul 2010 15:42:07 +0000 (UTC)
commit e2d716b3dd6ceaed6192dabd2848eca44ef87c5b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Jul 18 17:41:35 2010 +0200
use gtk_accelerator_get_default_mod_mask to test for modifier keys
extensions/edit_metadata/callbacks.c | 4 +++-
extensions/file_manager/callbacks.c | 11 +++++++----
extensions/file_tools/callbacks.c | 9 +++++----
extensions/image_rotation/callbacks.c | 30 ++++++++++++++----------------
extensions/list_tools/callbacks.c | 5 +----
gthumb/gth-browser.c | 12 +++++++++---
6 files changed, 39 insertions(+), 32 deletions(-)
---
diff --git a/extensions/edit_metadata/callbacks.c b/extensions/edit_metadata/callbacks.c
index 5385fa1..9dbd10b 100644
--- a/extensions/edit_metadata/callbacks.c
+++ b/extensions/edit_metadata/callbacks.c
@@ -358,8 +358,10 @@ edit_metadata__gth_browser_file_list_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
{
gpointer result = NULL;
+ guint modifiers;
- if ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_MOD1_MASK))
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ if ((event->state & modifiers) != 0)
return NULL;
switch (gdk_keyval_to_lower (event->keyval)) {
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index 919ecaa..98e5525 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -995,13 +995,16 @@ fm__gth_browser_file_list_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
{
gpointer result = NULL;
+ guint modifiers;
GList *items;
GList *file_data_list;
GList *file_list;
- switch (gdk_keyval_to_lower (event->keyval)) {
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+
+ switch (event->keyval) {
case GDK_g:
- if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_SHIFT_MASK)) {
+ if ((event->state & modifiers) == 0) {
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);
@@ -1015,11 +1018,11 @@ fm__gth_browser_file_list_key_press_cb (GthBrowser *browser,
break;
case GDK_Delete:
- if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_SHIFT_MASK)) {
+ if ((event->state & modifiers) == 0) {
gth_browser_activate_action_edit_trash (NULL, browser);
result = GINT_TO_POINTER (1);
}
- else if (! (event->state & GDK_CONTROL_MASK) && (event->state & GDK_SHIFT_MASK)) {
+ else if ((event->state & modifiers) == GDK_SHIFT_MASK) {
gth_browser_activate_action_edit_delete (NULL, browser);
result = GINT_TO_POINTER (1);
}
diff --git a/extensions/file_tools/callbacks.c b/extensions/file_tools/callbacks.c
index 6a091f6..8547862 100644
--- a/extensions/file_tools/callbacks.c
+++ b/extensions/file_tools/callbacks.c
@@ -40,22 +40,23 @@ file_tools__gth_browser_file_list_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
{
gpointer result = NULL;
+ guint modifiers;
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));
-
if (gth_toolbox_tool_is_active (GTH_TOOLBOX (toolbox)))
return NULL;
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ if (((event->state & modifiers) != 0) && ((event->state & modifiers) != GDK_SHIFT_MASK))
+ return NULL;
+
switch (event->keyval) {
case GDK_h:
tool = (GthFileTool *) gth_toolbox_get_tool (GTH_TOOLBOX (toolbox), GTH_TYPE_FILE_TOOL_ENHANCE);
diff --git a/extensions/image_rotation/callbacks.c b/extensions/image_rotation/callbacks.c
index 1777540..6c70f97 100644
--- a/extensions/image_rotation/callbacks.c
+++ b/extensions/image_rotation/callbacks.c
@@ -124,22 +124,20 @@ ir__gth_browser_file_list_key_press_cb (GthBrowser *browser,
{
gpointer result = NULL;
- if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_MOD1_MASK)) {
- switch (gdk_keyval_to_lower (event->keyval)) {
- case GDK_bracketright:
- gth_browser_activate_action_tool_rotate_right (NULL, browser);
- result = GINT_TO_POINTER (1);
- break;
-
- case GDK_bracketleft:
- gth_browser_activate_action_tool_rotate_left (NULL, browser);
- result = GINT_TO_POINTER (1);
- break;
-
- default:
- break;
- }
- }
+ switch (event->keyval) {
+ case GDK_bracketright:
+ gth_browser_activate_action_tool_rotate_right (NULL, browser);
+ result = GINT_TO_POINTER (1);
+ break;
+
+ case GDK_bracketleft:
+ gth_browser_activate_action_tool_rotate_left (NULL, browser);
+ result = GINT_TO_POINTER (1);
+ break;
+
+ default:
+ break;
+ }
return result;
}
diff --git a/extensions/list_tools/callbacks.c b/extensions/list_tools/callbacks.c
index 3ed2c84..dce0227 100644
--- a/extensions/list_tools/callbacks.c
+++ b/extensions/list_tools/callbacks.c
@@ -320,17 +320,14 @@ list_tools__gth_browser_file_list_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
{
gpointer result = NULL;
- guint keyval;
GList *script_list;
GList *scan;
- keyval = gdk_keyval_to_lower (event->keyval);
-
script_list = gth_script_file_get_scripts (gth_script_file_get ());
for (scan = script_list; scan; scan = scan->next) {
GthScript *script = scan->data;
- if (gth_script_get_shortcut (script) == keyval) {
+ if (gth_script_get_shortcut (script) == event->keyval) {
exec_script (browser, script);
result = GINT_TO_POINTER (1);
break;
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 6d3951c..24e5933 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -3223,9 +3223,12 @@ gth_file_list_key_press_cb (GtkWidget *widget,
{
GthBrowser *browser = user_data;
gboolean result = FALSE;
+ guint modifiers;
- if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_MOD1_MASK)) {
- switch (gdk_keyval_to_lower (event->keyval)) {
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+
+ if ((event->state & modifiers) == 0) {
+ switch (event->keyval) {
case GDK_f:
gth_browser_fullscreen (browser);
result = TRUE;
@@ -4674,9 +4677,12 @@ gboolean
gth_browser_viewer_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
{
+ guint modifiers;
+
g_return_val_if_fail (event != NULL, FALSE);
- if (! (event->state & GDK_CONTROL_MASK) && ! (event->state & GDK_MOD1_MASK)) {
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ if ((event->state & modifiers) == 0) {
switch (event->keyval) {
case GDK_Page_Up:
case GDK_BackSpace:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]