Commit 102b69bd authored by Paolo Bacchilega's avatar Paolo Bacchilega

browser window: converted accelerators to customizable shortcuts

parent ca2392a8
......@@ -377,6 +377,26 @@ gth_browser_activate_save_as (GSimpleAction *action,
}
void
gth_browser_activate_toggle_edit_file (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GthBrowser *browser = user_data;
gth_browser_toggle_viewer_tools (browser);
}
void
gth_browser_activate_toggle_file_properties (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GthBrowser *browser = user_data;
gth_browser_toggle_file_properties (browser);
}
void
gth_browser_activate_viewer_edit_file (GSimpleAction *action,
GVariant *state,
......@@ -505,6 +525,26 @@ gth_browser_activate_show_thumbnail_list (GSimpleAction *action,
}
void
gth_browser_activate_show_first_image (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GthBrowser *browser = GTH_BROWSER (user_data);
gth_browser_show_first_image (browser, FALSE, FALSE);
}
void
gth_browser_activate_show_last_image (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GthBrowser *browser = GTH_BROWSER (user_data);
gth_browser_show_last_image (browser, FALSE, FALSE);
}
void
gth_browser_activate_show_previous_image (GSimpleAction *action,
GVariant *state,
......
......@@ -48,6 +48,8 @@ DEF_ACTION_CALLBACK (gth_browser_activate_open_location)
DEF_ACTION_CALLBACK (gth_browser_activate_revert_to_saved)
DEF_ACTION_CALLBACK (gth_browser_activate_save)
DEF_ACTION_CALLBACK (gth_browser_activate_save_as)
DEF_ACTION_CALLBACK (gth_browser_activate_toggle_edit_file)
DEF_ACTION_CALLBACK (gth_browser_activate_toggle_file_properties)
DEF_ACTION_CALLBACK (gth_browser_activate_viewer_edit_file)
DEF_ACTION_CALLBACK (gth_browser_activate_viewer_properties)
DEF_ACTION_CALLBACK (gth_browser_activate_unfullscreen)
......@@ -57,6 +59,8 @@ DEF_ACTION_CALLBACK (gth_browser_activate_sort_by)
DEF_ACTION_CALLBACK (gth_browser_activate_show_statusbar)
DEF_ACTION_CALLBACK (gth_browser_activate_show_sidebar)
DEF_ACTION_CALLBACK (gth_browser_activate_show_thumbnail_list)
DEF_ACTION_CALLBACK (gth_browser_activate_show_first_image)
DEF_ACTION_CALLBACK (gth_browser_activate_show_last_image)
DEF_ACTION_CALLBACK (gth_browser_activate_show_previous_image)
DEF_ACTION_CALLBACK (gth_browser_activate_show_next_image)
DEF_ACTION_CALLBACK (gth_browser_activate_apply_editor_changes)
......
......@@ -25,6 +25,7 @@
#include <config.h>
#include <glib/gi18n.h>
#include "gtk-utils.h"
#include "typedefs.h"
static const GActionEntry gth_browser_actions[] = {
......@@ -45,6 +46,8 @@ static const GActionEntry gth_browser_actions[] = {
{ "revert-to-saved", gth_browser_activate_revert_to_saved },
{ "save", gth_browser_activate_save },
{ "save-as", gth_browser_activate_save_as },
{ "toggle-edit-file", gth_browser_activate_toggle_edit_file },
{ "toggle-file-properties", gth_browser_activate_toggle_file_properties },
{ "viewer-edit-file", toggle_action_activated, NULL, "false", gth_browser_activate_viewer_edit_file },
{ "viewer-properties", toggle_action_activated, NULL, "false", gth_browser_activate_viewer_properties },
{ "unfullscreen", gth_browser_activate_unfullscreen },
......@@ -57,6 +60,8 @@ static const GActionEntry gth_browser_actions[] = {
{ "show-sidebar", toggle_action_activated, NULL, "false", gth_browser_activate_show_sidebar },
{ "show-thumbnail-list", toggle_action_activated, NULL, "false", gth_browser_activate_show_thumbnail_list },
{ "show-first-image", gth_browser_activate_show_first_image },
{ "show-last-image", gth_browser_activate_show_last_image },
{ "show-previous-image", gth_browser_activate_show_previous_image },
{ "show-next-image", gth_browser_activate_show_next_image },
......@@ -66,18 +71,34 @@ static const GActionEntry gth_browser_actions[] = {
static const GthAccelerator gth_browser_accelerators[] = {
{ "browser-mode", "Escape" },
{ "browser-properties", "<Control>i" },
{ "close", "<Control>w" },
{ "open-location", "<Control>o" },
{ "fullscreen", "F11" },
{ "revert-to-saved", "F4" },
{ "show-sidebar", "F9" },
{ "show-thumbnail-list", "F8" },
{ "go-back", "<Alt>Left" },
{ "go-forward", "<Alt>Right" },
{ "go-up", "<Alt>Up" },
{ "go-home", "<Alt>Home" },
{ "reload", "<Control>r" }
};
static const GthShortcut gth_browser_shortcuts[] = {
{ "close", N_("Close Window"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "" },
{ "open-location", N_("Open Location"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "O" },
{ "fullscreen", N_("Fullscreen"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_IMAGE_VIEW, "F" },
{ "revert-to-saved", N_("Revert Image to Saved"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_EDIT, "F4" },
{ "show-sidebar", N_("Sidebar"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "F9" },
{ "show-statusbar", N_("Statusbar"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "F7" },
{ "show-thumbnail-list", N_("Thumbnails List"), GTH_SHORTCUT_CONTEXT_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "F8" },
{ "go-back", N_("Load Previuos Location"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "<Alt>Left" },
{ "go-forward", N_("Load Next Location"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "<Alt>Right" },
{ "go-up", N_("Load Parent Folder"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "<Alt>Up" },
{ "go-home", N_("Load Home"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "<Alt>Home" },
{ "reload", N_("Reload Location"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "R" },
{ "show-hidden-files", N_("Show/Hide Hidden Files"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "H" },
{ "sort-by", N_("Change Sorting Order"), GTH_SHORTCUT_CONTEXT_BROWSER, GTH_SHORTCUT_CATEGORY_FILE_NAVIGATION, "S" },
{ "show-previous-image", N_("Show Previous Image"), GTH_SHORTCUT_CONTEXT_VIEWER, GTH_SHORTCUT_CATEGORY_IMAGE_VIEW, "BackSpace" },
{ "show-next-image", N_("Show Next Image"), GTH_SHORTCUT_CONTEXT_VIEWER, GTH_SHORTCUT_CATEGORY_IMAGE_VIEW, "space" },
{ "show-first-image", N_("Show First Image"), GTH_SHORTCUT_CONTEXT_VIEWER, GTH_SHORTCUT_CATEGORY_IMAGE_VIEW, "Home" },
{ "show-last-image", N_("Show Last Image"), GTH_SHORTCUT_CONTEXT_VIEWER, GTH_SHORTCUT_CATEGORY_IMAGE_VIEW, "End" },
{ "toggle-edit-file", N_("Edit Image"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "E" },
{ "toggle-file-properties", N_("File Properties"), GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER, GTH_SHORTCUT_CATEGORY_UI, "I" },
};
......
......@@ -4112,11 +4112,13 @@ browser_key_press_cb (GthBrowser *browser,
if (! _gth_browser_file_tool_is_active (browser))
return gth_browser_viewer_key_press_cb (browser, event);
break;
case GTH_BROWSER_PAGE_BROWSER:
focus_widget = gtk_window_get_focus (GTK_WINDOW (browser));
if (! GTK_IS_ENTRY (focus_widget) && ! GTK_IS_TREE_VIEW (focus_widget))
return gth_browser_file_list_key_press_cb (browser, event);
break;
default:
break;
}
......@@ -4265,6 +4267,10 @@ gth_browser_init (GthBrowser *browser)
gth_browser_accelerators,
G_N_ELEMENTS (gth_browser_accelerators));
gth_window_add_shortcuts (GTH_WINDOW (browser),
gth_browser_shortcuts,
G_N_ELEMENTS (gth_browser_shortcuts));
/* -- image page -- */
/* content */
......@@ -6313,6 +6319,53 @@ gth_browser_show_viewer_tools (GthBrowser *browser)
}
void
gth_browser_toggle_file_properties (GthBrowser *browser)
{
g_return_if_fail (GTH_IS_BROWSER (browser));
switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
case GTH_BROWSER_PAGE_BROWSER:
if (gth_window_get_action_state (GTH_WINDOW (browser), "browser-properties"))
gth_browser_hide_sidebar (browser);
else
gth_browser_show_file_properties (browser);
break;
case GTH_BROWSER_PAGE_VIEWER:
gth_browser_toggle_properties_on_screen (browser);
break;
default:
break;
}
}
void
gth_browser_toggle_viewer_tools (GthBrowser *browser)
{
g_return_if_fail (GTH_IS_BROWSER (browser));
switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
case GTH_BROWSER_PAGE_BROWSER:
if (browser->priv->viewer_page != NULL)
gth_browser_show_viewer_tools (GTH_BROWSER (browser));
break;
case GTH_BROWSER_PAGE_VIEWER:
if (browser->priv->viewer_sidebar != GTH_SIDEBAR_STATE_TOOLS)
gth_browser_show_viewer_tools (browser);
else
gth_browser_hide_sidebar (browser);
break;
default:
break;
}
}
void
gth_browser_hide_sidebar (GthBrowser *browser)
{
......
......@@ -248,6 +248,8 @@ void gth_browser_update_statusbar_file_info
(GthBrowser *browser);
void gth_browser_show_file_properties (GthBrowser *browser);
void gth_browser_show_viewer_tools (GthBrowser *browser);
void gth_browser_toggle_file_properties (GthBrowser *browser);
void gth_browser_toggle_viewer_tools (GthBrowser *browser);
void gth_browser_hide_sidebar (GthBrowser *browser);
void gth_browser_load_location (GthBrowser *browser,
GFile *location);
......
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