Commit 3255347f authored by Paolo Bacchilega's avatar Paolo Bacchilega

selections: add the fixed accelerators as shortcuts

...to check for collisions when the user define a custom shortcut.
parent ac8dd5dd
......@@ -27,8 +27,8 @@
void
gth_browser_activate_show_selection (GthBrowser *browser,
int n_selection)
gth_browser_show_selection (GthBrowser *browser,
int n_selection)
{
char *uri;
GFile *location;
......@@ -51,35 +51,18 @@ gth_browser_activate_show_selection (GthBrowser *browser,
void
gth_browser_activate_go_to_selection_1 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
gth_browser_activate_go_to_selection (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_show_selection (GTH_BROWSER (user_data), 1);
gth_browser_show_selection (GTH_BROWSER (user_data),
g_variant_get_int32 (parameter));
}
void
gth_browser_activate_go_to_selection_2 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_show_selection (GTH_BROWSER (user_data), 2);
}
void
gth_browser_activate_go_to_selection_3 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_show_selection (GTH_BROWSER (user_data), 3);
}
void
gth_browser_activate_add_to_selection (GthBrowser *browser,
int n_selection)
gth_browser_add_to_selection(GthBrowser *browser,
int n_selection)
{
char *uri;
GFile *folder;
......@@ -103,28 +86,12 @@ gth_browser_activate_add_to_selection (GthBrowser *browser,
void
gth_browser_activate_add_to_selection_1 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_add_to_selection (GTH_BROWSER (user_data), 1);
}
void
gth_browser_activate_add_to_selection_2 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_add_to_selection (GTH_BROWSER (user_data), 2);
}
void
gth_browser_activate_add_to_selection_3 (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
gth_browser_activate_add_to_selection (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_activate_add_to_selection (GTH_BROWSER (user_data), 3);
gth_browser_add_to_selection (GTH_BROWSER (user_data),
g_variant_get_int32 (parameter));
}
......@@ -156,8 +123,8 @@ gth_browser_activate_go_to_file_container (GSimpleAction *action,
void
gth_browser_activate_remove_from_selection (GthBrowser *browser,
int n_selection)
gth_browser_remove_from_selection (GthBrowser *browser,
int n_selection)
{
char *uri;
GFile *folder;
......@@ -180,6 +147,16 @@ gth_browser_activate_remove_from_selection (GthBrowser *browser,
}
void
gth_browser_activate_remove_from_selection (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gth_browser_remove_from_selection (GTH_BROWSER (user_data),
g_variant_get_int32 (parameter));
}
void
gth_browser_activate_remove_from_current_selection (GSimpleAction *action,
GVariant *parameter,
......@@ -190,5 +167,5 @@ gth_browser_activate_remove_from_current_selection (GSimpleAction *action,
n_selection = _g_file_get_n_selection (gth_browser_get_location (browser));
if (n_selection >= 0)
gth_browser_activate_remove_from_selection (browser, n_selection);
gth_browser_remove_from_selection (browser, n_selection);
}
......@@ -24,20 +24,17 @@
#include <gthumb.h>
void gth_browser_activate_show_selection (GthBrowser *browser,
int n_selection);
void gth_browser_activate_add_to_selection (GthBrowser *browser,
int n_selection);
void gth_browser_activate_remove_from_selection (GthBrowser *browser,
int n_selection);
void gth_browser_show_selection (GthBrowser *browser,
int n_selection);
void gth_browser_add_to_selection (GthBrowser *browser,
int n_selection);
void gth_browser_remove_from_selection (GthBrowser *browser,
int n_selection);
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_selection_1)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_selection_2)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_selection_3)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_1)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_2)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection_3)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_file_container)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_selection)
DEF_ACTION_CALLBACK (gth_browser_activate_add_to_selection)
DEF_ACTION_CALLBACK (gth_browser_activate_remove_from_selection)
DEF_ACTION_CALLBACK (gth_browser_activate_remove_from_current_selection)
DEF_ACTION_CALLBACK (gth_browser_activate_go_to_file_container)
#endif /* ACTIONS_H */
......@@ -35,17 +35,38 @@
static const GActionEntry actions[] = {
{ "add-to-selection-1", gth_browser_activate_add_to_selection_1 },
{ "add-to-selection-2", gth_browser_activate_add_to_selection_2 },
{ "add-to-selection-3", gth_browser_activate_add_to_selection_3 },
{ "go-to-selection-1", gth_browser_activate_go_to_selection_1 },
{ "go-to-selection-2", gth_browser_activate_go_to_selection_2 },
{ "go-to-selection-3", gth_browser_activate_go_to_selection_3 },
{ "add-to-selection-1", gth_browser_activate_add_to_selection, "i", "1" },
{ "add-to-selection-2", gth_browser_activate_add_to_selection, "i", "2" },
{ "add-to-selection-3", gth_browser_activate_add_to_selection, "i", "3" },
{ "go-to-selection-1", gth_browser_activate_go_to_selection, "i", "1" },
{ "go-to-selection-2", gth_browser_activate_go_to_selection, "i", "2" },
{ "go-to-selection-3", gth_browser_activate_go_to_selection, "i", "3" },
{ "remove-to-selection-1", gth_browser_activate_remove_from_selection, "i", "1" },
{ "remove-to-selection-2", gth_browser_activate_remove_from_selection, "i", "2" },
{ "remove-to-selection-3", gth_browser_activate_remove_from_selection, "i", "3" },
{ "go-to-container-from-selection", gth_browser_activate_go_to_file_container },
{ "remove-from-selection", gth_browser_activate_remove_from_current_selection }
};
static const GthShortcut shortcuts[] = {
{ "add-to-selection-1", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<alt>1" },
{ "add-to-selection-2", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<alt>2" },
{ "add-to-selection-3", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<alt>3" },
{ "remove-from-selection-1", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<shift><alt>1" },
{ "remove-from-selection-2", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<shift><alt>2" },
{ "remove-from-selection-3", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<shift><alt>3" },
{ "go-to-selection-1", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<control>1" },
{ "go-to-selection-2", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<control>2" },
{ "go-to-selection-3", "", GTH_SHORTCUT_CONTEXT_INTERNAL, GTH_SHORTCUT_CATEGORY_HIDDEN, "<control>3" },
};
static const GthMenuEntry file_list_popup_open_entries[] = {
{ N_("Open Folder"), "win.go-to-container-from-selection", "<Alt>end" },
};
......@@ -86,7 +107,7 @@ selection_clicked_cb (GtkWidget *button,
g_return_if_fail (n_selection >= 0 && n_selection <= N_SELECTIONS - 1);
gth_browser_activate_show_selection (data->browser, n_selection + 1);
gth_browser_show_selection (data->browser, n_selection + 1);
}
......@@ -179,6 +200,9 @@ selections__gth_browser_construct_cb (GthBrowser *browser)
actions,
G_N_ELEMENTS (actions),
browser);
gth_window_add_shortcuts (GTH_WINDOW (browser),
shortcuts,
G_N_ELEMENTS (shortcuts));
filter_bar = gth_browser_get_filterbar (browser);
filter_bar_extra_area = gth_filterbar_get_extra_area (GTH_FILTERBAR (filter_bar));
......@@ -256,9 +280,9 @@ selections__gth_browser_file_list_key_press_cb (GthBrowser *browser,
case GDK_KEY_3:
/* Alt+Shift+n => remove from selection n */
if ((event->state & modifiers) == (GDK_SHIFT_MASK|GDK_MOD1_MASK))
gth_browser_activate_remove_from_selection (browser, keyval - GDK_KEY_1 + 1);
gth_browser_remove_from_selection (browser, keyval - GDK_KEY_1 + 1);
else /* Alt+n => add to selection n */
gth_browser_activate_add_to_selection (browser, keyval - GDK_KEY_1 + 1);
gth_browser_add_to_selection (browser, keyval - GDK_KEY_1 + 1);
result = GINT_TO_POINTER (1);
break;
}
......@@ -273,7 +297,7 @@ selections__gth_browser_file_list_key_press_cb (GthBrowser *browser,
case GDK_KEY_2:
case GDK_KEY_3:
/* Control+n => go to selection n */
gth_browser_activate_show_selection (browser, keyval - GDK_KEY_1 + 1);
gth_browser_show_selection (browser, keyval - GDK_KEY_1 + 1);
result = GINT_TO_POINTER (1);
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment