gthumb r2191 - in trunk: . libgthumb src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2191 - in trunk: . libgthumb src
- Date: Tue, 15 Jan 2008 20:20:40 +0000 (GMT)
Author: mjc
Date: Tue Jan 15 20:20:40 2008
New Revision: 2191
URL: http://svn.gnome.org/viewvc/gthumb?rev=2191&view=rev
Log:
2008-01-15 Michael J. Chudobiak <mjc svn gnome org>
* libgthumb/preferences.h:
* src/dlg-scripts.c: (gconf_script_path), (gconf_script_name_path),
(gconf_get_script), (exec_script), (setup_script_struct),
(add_scripts), (save_cb), (add_menu_item_and_action),
(generate_script_menu):
* src/dlg-scripts.h:
* src/gth-browser.c: (key_press_cb):
Tweaked version of Adrien Bustany's ghop patch.
http://code.google.com/p/google-highly-open-participation-gnome/issues/detail?id=94.
Applies meaningful script names to the default scripts, even if they
imported from 2.10.x. Collapsed the script code into loops, allowing
future expansion of the number of scripts.
Modified:
trunk/ChangeLog
trunk/libgthumb/preferences.h
trunk/src/dlg-scripts.c
trunk/src/dlg-scripts.h
trunk/src/gth-browser.c
Modified: trunk/libgthumb/preferences.h
==============================================================================
--- trunk/libgthumb/preferences.h (original)
+++ trunk/libgthumb/preferences.h Tue Jan 15 20:20:40 2008
@@ -75,27 +75,7 @@
#define PREF_SLIDESHOW_WRAP_AROUND "/apps/gthumb/slideshow/wrap_around"
#define PREF_SLIDESHOW_FADING "/apps/gthumb/slideshow/fading"
-#define PREF_HOTKEY0 "/apps/gthumb/hotkeys/hotkey0"
-#define PREF_HOTKEY1 "/apps/gthumb/hotkeys/hotkey1"
-#define PREF_HOTKEY2 "/apps/gthumb/hotkeys/hotkey2"
-#define PREF_HOTKEY3 "/apps/gthumb/hotkeys/hotkey3"
-#define PREF_HOTKEY4 "/apps/gthumb/hotkeys/hotkey4"
-#define PREF_HOTKEY5 "/apps/gthumb/hotkeys/hotkey5"
-#define PREF_HOTKEY6 "/apps/gthumb/hotkeys/hotkey6"
-#define PREF_HOTKEY7 "/apps/gthumb/hotkeys/hotkey7"
-#define PREF_HOTKEY8 "/apps/gthumb/hotkeys/hotkey8"
-#define PREF_HOTKEY9 "/apps/gthumb/hotkeys/hotkey9"
-
-#define PREF_HOTKEY0_NAME "/apps/gthumb/hotkeys/hotkey0_name"
-#define PREF_HOTKEY1_NAME "/apps/gthumb/hotkeys/hotkey1_name"
-#define PREF_HOTKEY2_NAME "/apps/gthumb/hotkeys/hotkey2_name"
-#define PREF_HOTKEY3_NAME "/apps/gthumb/hotkeys/hotkey3_name"
-#define PREF_HOTKEY4_NAME "/apps/gthumb/hotkeys/hotkey4_name"
-#define PREF_HOTKEY5_NAME "/apps/gthumb/hotkeys/hotkey5_name"
-#define PREF_HOTKEY6_NAME "/apps/gthumb/hotkeys/hotkey6_name"
-#define PREF_HOTKEY7_NAME "/apps/gthumb/hotkeys/hotkey7_name"
-#define PREF_HOTKEY8_NAME "/apps/gthumb/hotkeys/hotkey8_name"
-#define PREF_HOTKEY9_NAME "/apps/gthumb/hotkeys/hotkey9_name"
+#define PREF_HOTKEY_PREFIX "/apps/gthumb/hotkeys/hotkey"
#define PREF_UI_LAYOUT "/apps/gthumb/ui/layout"
#define PREF_UI_TOOLBAR_STYLE "/apps/gthumb/ui/toolbar_style"
Modified: trunk/src/dlg-scripts.c
==============================================================================
--- trunk/src/dlg-scripts.c (original)
+++ trunk/src/dlg-scripts.c Tue Jan 15 20:20:40 2008
@@ -34,7 +34,6 @@
#include "file-utils.h"
#include "gth-utils.h"
-#include "gth-window.h"
#include "gtk-utils.h"
#include "glib-utils.h"
#include "main.h"
@@ -42,6 +41,10 @@
#include "gconf-utils.h"
#include "thumb-loader.h"
+
+#include "dlg-scripts.h"
+
+
#define SCRIPT_GLADE_FILE "gthumb_tools.glade"
#define DEF_THUMB_SIZE 128
#define MAX_SCRIPTS 10
@@ -72,6 +75,24 @@
gchar *script_text;
} ScriptStruct;
+typedef struct {
+ /* Name of the script */
+ char *name;
+
+ /* Command to run */
+ char *command;
+} ScriptCommand;
+
+
+static ScriptCommand script_commands[] = {
+ {N_("Edit with GIMP"), "gimp-remote %F"},
+ {N_("Add copyright"), "convert %f -font Helvetica -pointsize 20 -fill white -box '#00000080' -gravity South -annotate +0+5 ' Copyright 2007, Your Name Here ' %n-copyright%e"},
+ {N_("Copy to \"approved\" folder"), "mkdir -p %p/approved ; cp %f %p/approved/"},
+ {N_("Send by email"), "uuencode %f %f | mail -s Photos your emailaddress com"},
+ {N_("Make a zip file"), "rm ~/myarchive.zip; zip -j ~/myarchive %F"},
+ {N_("Make a zip file and email it"), "rm ~/myarchive.zip; zip -j ~/myarchive %F; uuencode ~/myarchive.zip ~/myarchive.zip | mail -s Photos your emailaddress com"}
+};
+
enum {
COLUMN_SCRIPT_NUMBER,
@@ -692,116 +713,91 @@
}
-void exec_script0 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY0, NULL),
- eel_gconf_get_string (PREF_HOTKEY0_NAME, NULL),
- list);
- path_list_free (list);
- }
+char*
+gconf_script_path (unsigned int script_number)
+{
+ return g_strdup_printf (PREF_HOTKEY_PREFIX "%d", script_number);
}
-void exec_script1 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY1, NULL),
- eel_gconf_get_string (PREF_HOTKEY1_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
-void exec_script2 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY2, NULL),
- eel_gconf_get_string (PREF_HOTKEY2_NAME, NULL),
- list);
- path_list_free (list);
- }
+char*
+gconf_script_name_path (unsigned int script_number)
+{
+ return g_strdup_printf (PREF_HOTKEY_PREFIX "%d_name", script_number);
}
-void exec_script3 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY3, NULL),
- eel_gconf_get_string (PREF_HOTKEY3_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
-void exec_script4 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY4, NULL),
- eel_gconf_get_string (PREF_HOTKEY4_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
+void
+gconf_get_script (unsigned int number, char **name, char **command) {
-void exec_script5 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY5, NULL),
- eel_gconf_get_string (PREF_HOTKEY5_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
+ char *user_name, *current_command, *default_name, *default_command;
+ char *script_name, *script_command;
+ char *dummy_name = g_strdup_printf (_("Script %d"), number);
+
+ if (number < sizeof (script_commands) / sizeof (ScriptCommand)) {
+ default_name = _(script_commands[number].name);
+ default_command = script_commands[number].command;
+ } else {
+ default_name = dummy_name;
+ default_command = "";
+ }
-void exec_script6 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY6, NULL),
- eel_gconf_get_string (PREF_HOTKEY6_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
+ /* First check if the user has specified a name for the script (gthumb >= 2.11) */
+ user_name = eel_gconf_get_string (gconf_script_name_path (number), "");
-void exec_script7 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY7, NULL),
- eel_gconf_get_string (PREF_HOTKEY7_NAME, NULL),
- list);
- path_list_free (list);
- }
-}
+ /* Check if the script's command is the default one */
+ current_command = eel_gconf_get_string (gconf_script_path (number), "");
+
+ if (!strcmp (user_name, "") || !strcmp (user_name, dummy_name)) {
+ if (!strcmp (current_command, default_command) || !strcmp (current_command, "")) {
+ /* The user did not define a custom command */
+ script_name = g_strdup ((char*) default_name);
+ script_command = g_strdup ((char*) default_command);
+ } else {
+ /* The user did define a custom command but no name (gthumb < 2.11) */
+ script_name = g_strdup ((char*) dummy_name);
+ script_command = g_strdup (current_command);
+ }
+ } else {
+ /* There was a non-default value stored in gconf, so return it */
+ script_name = g_strdup (user_name);
+ /* Not sure of that : can there be a name but no command ? Better check... */
+ if (!strcmp (current_command, ""))
+ script_command = g_strdup ((char*) default_command);
+ else
+ script_command = g_strdup ((char*) current_command);
+ }
+
+ g_free (user_name);
+ g_free (current_command);
+ g_free (dummy_name);
+
+ if (name) *name = script_name;
+ if (command) *command = script_command;
-void exec_script8 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
- if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY8, NULL),
- eel_gconf_get_string (PREF_HOTKEY8_NAME, NULL),
- list);
- path_list_free (list);
- }
}
-void exec_script9 (GtkAction *action, GthWindow *window) {
- GList *list = gth_window_get_file_list_selection (window);
+
+void exec_script (GtkAction *action, ScriptCallbackData *cb_data) {
+
+ GList *list = gth_window_get_file_list_selection (cb_data->window);
+
if (list != NULL) {
- exec_shell_script ( GTK_WINDOW (window),
- eel_gconf_get_string (PREF_HOTKEY9, NULL),
- eel_gconf_get_string (PREF_HOTKEY9_NAME, NULL),
- list);
+ char *name, *command;
+ gconf_get_script (cb_data->number, &name, &command);
+ exec_shell_script ( GTK_WINDOW (cb_data->window),
+ command,
+ name,
+ list);
path_list_free (list);
- }
+ /* We don't need the callback data anymore */
+ g_free (cb_data);
+ g_free (name);
+ g_free (command);
+ }
}
+
void exec_upload_flickr (GtkAction *action, GthWindow *window) {
GList *list = gth_window_get_file_list_selection (window);
if (list != NULL) {
@@ -817,62 +813,33 @@
}
}
+
+void
+setup_script_struct (ScriptStruct *s,
+ int number)
+{
+ char *name, *command;
+ gconf_get_script (number, &name, &command);
+
+ s->number = number;
+ s->short_name = name;
+ s->script_text = command;
+}
+
+
static void
add_scripts (void)
{
ScriptStruct new_entry;
+ int i;
g_return_if_fail (script_array != NULL);
- new_entry.number = 0;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY0_NAME, _("Script 0"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY0, "gimp-remote %F");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 1;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY1_NAME, _("Script 1"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY1, "convert %f -font Helvetica -pointsize 20 -fill white -box '#00000080' -gravity South -annotate +0+5 ' Copyright 2007, Your Name Here ' %n-copyright%e");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 2;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY2_NAME, _("Script 2"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY2, "mkdir -p %p/approved ; cp %f %p/approved/");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 3;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY3_NAME, _("Script 3"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY3, "uuencode %f %f | mail -s Photos your emailaddress com");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 4;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY4_NAME, _("Script 4"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY4, "rm ~/myarchive.zip; zip -j ~/myarchive %F");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 5;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY5_NAME, _("Script 5"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY5, "rm ~/myarchive.zip; zip -j ~/myarchive %F; uuencode ~/myarchive.zip ~/myarchive.zip | mail -s Photos your emailaddress com");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 6;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY6_NAME, _("Script 6"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY6, "");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 7;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY7_NAME, _("Script 7"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY7, "");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 8;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY8_NAME, _("Script 8"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY8, "");
- g_array_append_vals (script_array, &new_entry, 1);
-
- new_entry.number = 9;
- new_entry.short_name = eel_gconf_get_string (PREF_HOTKEY9_NAME, _("Script 9"));
- new_entry.script_text = eel_gconf_get_string (PREF_HOTKEY9, "");
- g_array_append_vals (script_array, &new_entry, 1);
+ for (i = 0 ; i < MAX_SCRIPTS ; i++) {
+ setup_script_struct (&new_entry, i);
+ g_array_append_vals (script_array, &new_entry, 1);
+ }
+
}
@@ -1066,27 +1033,16 @@
save_cb (GtkWidget *widget,
DialogData *data)
{
- eel_gconf_set_string (PREF_HOTKEY0, g_array_index (script_array, ScriptStruct, 0).script_text);
- eel_gconf_set_string (PREF_HOTKEY1, g_array_index (script_array, ScriptStruct, 1).script_text);
- eel_gconf_set_string (PREF_HOTKEY2, g_array_index (script_array, ScriptStruct, 2).script_text);
- eel_gconf_set_string (PREF_HOTKEY3, g_array_index (script_array, ScriptStruct, 3).script_text);
- eel_gconf_set_string (PREF_HOTKEY4, g_array_index (script_array, ScriptStruct, 4).script_text);
- eel_gconf_set_string (PREF_HOTKEY5, g_array_index (script_array, ScriptStruct, 5).script_text);
- eel_gconf_set_string (PREF_HOTKEY6, g_array_index (script_array, ScriptStruct, 6).script_text);
- eel_gconf_set_string (PREF_HOTKEY7, g_array_index (script_array, ScriptStruct, 7).script_text);
- eel_gconf_set_string (PREF_HOTKEY8, g_array_index (script_array, ScriptStruct, 8).script_text);
- eel_gconf_set_string (PREF_HOTKEY9, g_array_index (script_array, ScriptStruct, 9).script_text);
-
- eel_gconf_set_string (PREF_HOTKEY0_NAME, g_array_index (script_array, ScriptStruct, 0).short_name);
- eel_gconf_set_string (PREF_HOTKEY1_NAME, g_array_index (script_array, ScriptStruct, 1).short_name);
- eel_gconf_set_string (PREF_HOTKEY2_NAME, g_array_index (script_array, ScriptStruct, 2).short_name);
- eel_gconf_set_string (PREF_HOTKEY3_NAME, g_array_index (script_array, ScriptStruct, 3).short_name);
- eel_gconf_set_string (PREF_HOTKEY4_NAME, g_array_index (script_array, ScriptStruct, 4).short_name);
- eel_gconf_set_string (PREF_HOTKEY5_NAME, g_array_index (script_array, ScriptStruct, 5).short_name);
- eel_gconf_set_string (PREF_HOTKEY6_NAME, g_array_index (script_array, ScriptStruct, 6).short_name);
- eel_gconf_set_string (PREF_HOTKEY7_NAME, g_array_index (script_array, ScriptStruct, 7).short_name);
- eel_gconf_set_string (PREF_HOTKEY8_NAME, g_array_index (script_array, ScriptStruct, 8).short_name);
- eel_gconf_set_string (PREF_HOTKEY9_NAME, g_array_index (script_array, ScriptStruct, 9).short_name);
+ unsigned int i;
+ char *pref_key_path = NULL, *pref_key_name = NULL;
+ for (i = 0 ; i < MAX_SCRIPTS ; i++) {
+ pref_key_path = gconf_script_path (i);
+ pref_key_name = gconf_script_name_path (i);
+ eel_gconf_set_string (pref_key_path, g_array_index (script_array, ScriptStruct, i).script_text);
+ eel_gconf_set_string (pref_key_name, g_array_index (script_array, ScriptStruct, i).short_name);
+ g_free (pref_key_path);
+ g_free (pref_key_name);
+ }
data->done_func (data->done_data);
gtk_widget_destroy (data->dialog);
@@ -1190,30 +1146,32 @@
GtkActionGroup *action_group,
GthWindow *window,
guint merge_id,
- int hotkey,
- char *pref_string,
- GCallback callback_func)
+ int script_number)
{
GtkAction *action;
char *full_label;
- char *label_from_pref;
- char *default_label;
- char *name;
-
- name = g_strdup_printf ("Script_%d",hotkey);
-
- default_label = g_strdup_printf (_("Script %d"), hotkey);
- label_from_pref = eel_gconf_get_string (pref_string, default_label);
- full_label = g_strdup_printf ("%d: %s", hotkey, label_from_pref);
+ char *label;
+ char *name, *command;
+
+ name = g_strdup_printf ("Script_%d",script_number);
+
+ gconf_get_script (script_number, &label, &command);
+
+ full_label = g_strdup_printf ("%d: %s", script_number, label);
action = g_object_new (GTK_TYPE_ACTION,
"name", name,
"label", full_label,
"stock_id", GTK_STOCK_EXECUTE,
NULL);
+ ScriptCallbackData *cb_data = g_new0 (ScriptCallbackData, 1);
+ cb_data->number = script_number;
+ cb_data->window = window;
+
g_signal_connect (action, "activate",
- G_CALLBACK (callback_func),
- window);
+ G_CALLBACK (exec_script),
+ cb_data);
+
gtk_action_group_add_action (action_group, action);
g_object_unref (action);
gtk_ui_manager_add_ui (ui,
@@ -1225,9 +1183,9 @@
FALSE);
g_free (full_label);
- g_free (label_from_pref);
- g_free (default_label);
+ g_free (label);
g_free (name);
+ g_free (command);
}
@@ -1255,46 +1213,11 @@
/* Identify this batch of menu additions (for later removal, if required) */
merge_id = gtk_ui_manager_new_merge_id (ui);
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 0,
- PREF_HOTKEY0_NAME,
- G_CALLBACK (exec_script0));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 1,
- PREF_HOTKEY1_NAME,
- G_CALLBACK (exec_script1));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 2,
- PREF_HOTKEY2_NAME,
- G_CALLBACK (exec_script2));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 3,
- PREF_HOTKEY3_NAME,
- G_CALLBACK (exec_script3));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 4,
- PREF_HOTKEY4_NAME,
- G_CALLBACK (exec_script4));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 5,
- PREF_HOTKEY5_NAME,
- G_CALLBACK (exec_script5));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 6,
- PREF_HOTKEY6_NAME,
- G_CALLBACK (exec_script6));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 7,
- PREF_HOTKEY7_NAME,
- G_CALLBACK (exec_script7));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 8,
- PREF_HOTKEY8_NAME,
- G_CALLBACK (exec_script8));
- add_menu_item_and_action (ui, action_group, window, merge_id,
- 9,
- PREF_HOTKEY9_NAME,
- G_CALLBACK (exec_script9));
+ unsigned int i;
+
+ for (i = 0 ; i < MAX_SCRIPTS ; i++) {
+ add_menu_item_and_action (ui, action_group, window, merge_id, i);
+ }
return merge_id;
}
Modified: trunk/src/dlg-scripts.h
==============================================================================
--- trunk/src/dlg-scripts.h (original)
+++ trunk/src/dlg-scripts.h Tue Jan 15 20:20:40 2008
@@ -23,26 +23,18 @@
#ifndef DLG_SCRIPTS_H
#define DLG_SCRIPTS_H
-void exec_script0 (GtkAction *action,
- GthWindow *window);
-void exec_script1 (GtkAction *action,
- GthWindow *window);
-void exec_script2 (GtkAction *action,
- GthWindow *window);
-void exec_script3 (GtkAction *action,
- GthWindow *window);
-void exec_script4 (GtkAction *action,
- GthWindow *window);
-void exec_script5 (GtkAction *action,
- GthWindow *window);
-void exec_script6 (GtkAction *action,
- GthWindow *window);
-void exec_script7 (GtkAction *action,
- GthWindow *window);
-void exec_script8 (GtkAction *action,
- GthWindow *window);
-void exec_script9 (GtkAction *action,
- GthWindow *window);
+#include "gth-window.h"
+
+typedef struct {
+ /* The number of the script */
+ unsigned int number;
+
+ /* Associated GThumb window */
+ GthWindow* window;
+} ScriptCallbackData;
+
+void exec_script (GtkAction *action,
+ ScriptCallbackData *cb_data);
void dlg_scripts (GthWindow *window,
DoneFunc done_func,
Modified: trunk/src/gth-browser.c
==============================================================================
--- trunk/src/gth-browser.c (original)
+++ trunk/src/gth-browser.c Tue Jan 15 20:20:40 2008
@@ -3105,6 +3105,9 @@
sel_not_null = gth_file_view_get_n_selected (priv->file_list->view) > 0;
image_is_void = image_viewer_is_void (IMAGE_VIEWER (priv->viewer));
+ ScriptCallbackData *cb_data = g_new0(ScriptCallbackData, 1);
+ cb_data->window = window;
+
switch (gdk_keyval_to_lower (event->keyval)) {
/* Hide/Show sidebar. */
case GDK_Return:
@@ -3257,51 +3260,61 @@
/* hot keys */
case GDK_KP_0:
case GDK_KP_Insert:
- exec_script0 (NULL, window);
+ cb_data->number = 0;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_1:
case GDK_KP_End:
- exec_script1 (NULL, window);
+ cb_data->number = 1;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_2:
case GDK_KP_Down:
- exec_script2 (NULL, window);
+ cb_data->number = 1;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_3:
case GDK_KP_Page_Down:
- exec_script3 (NULL, window);
+ cb_data->number = 3;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_4:
case GDK_KP_Left:
- exec_script4 (NULL, window);
+ cb_data->number = 4;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_5:
- exec_script5 (NULL, window);
+ cb_data->number = 5;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_6:
case GDK_KP_Right:
- exec_script6 (NULL, window);
+ cb_data->number = 6;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_7:
case GDK_KP_Home:
- exec_script7 (NULL, window);
+ cb_data->number = 7;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_8:
case GDK_KP_Up:
- exec_script8 (NULL, window);
+ cb_data->number = 8;
+ exec_script (NULL, cb_data);
return TRUE;
case GDK_KP_9:
case GDK_KP_Page_Up:
- exec_script9 (NULL, window);
+ cb_data->number = 9;
+ exec_script (NULL, cb_data);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]