Commit 8115cd5e authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

shortcuts: use a shortcuts window to show the shortcuts

Shortcuts are dynamic now, the help page is static.
parent 70ec2d72
......@@ -33,6 +33,7 @@
#include "gth-folder-tree.h"
#include "gth-main.h"
#include "gth-preferences.h"
#include "gth-shortcuts-window.h"
#include "gth-sidebar.h"
#include "gtk-utils.h"
#include "gth-viewer-page.h"
......@@ -102,7 +103,7 @@ gth_application_activate_show_shortcuts (GSimpleAction *action,
GtkWidget *browser;
browser = _gth_application_get_current_window (application);
show_help_dialog (GTK_WINDOW (browser), "gthumb-shortcuts");
gth_shortcuts_window_new (GTH_WINDOW (browser));
}
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2019 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <gtk/gtk.h>
#include "gth-main.h"
#include "gth-shortcuts-window.h"
#include "typedefs.h"
typedef struct {
int id;
char *name;
char *title;
} ContextInfo;
static ContextInfo contexts[] = {
{ GTH_SHORTCUT_CONTEXT_BROWSER, "browser", N_("Browser") },
{ GTH_SHORTCUT_CONTEXT_VIEWER, "viewer", N_("Viewer") },
//{ GTH_SHORTCUT_CONTEXT_SLIDESHOW, "slideshow", N_("Slideshow") }
};
void
gth_shortcuts_window_new (GthWindow *app_window)
{
GtkWidget *window;
GPtrArray *shortcuts_v;
int ctx;
window = g_object_new (GTK_TYPE_SHORTCUTS_WINDOW,
"transient-for", GTK_WINDOW (app_window),
NULL);
shortcuts_v = gth_window_get_shortcuts_by_category (app_window);
for (ctx = 0; ctx < G_N_ELEMENTS (contexts); ctx++) {
ContextInfo *context = &contexts[ctx];
GtkWidget *section;
GtkWidget *group;
const char *last_category;
int i;
section = g_object_new (GTK_TYPE_SHORTCUTS_SECTION,
"section-name", context->name,
"title", _(context->title),
NULL);
gtk_widget_show (section);
gtk_container_add (GTK_CONTAINER (window), section);
group = NULL;
last_category = NULL;
for (i = 0; i < shortcuts_v->len; i++) {
GthShortcut *shortcut_info = g_ptr_array_index (shortcuts_v, i);
GtkWidget *shortcut;
/* FIXME: document internal shortcuts as well */
if (shortcut_info->context == GTH_SHORTCUT_CONTEXT_INTERNAL)
continue;
if ((shortcut_info->context & context->id) == 0)
continue;
if (shortcut_info->keyval == 0)
continue;
if (g_strcmp0 (shortcut_info->category, last_category) != 0) {
GthShortcutCategory *category_info;
last_category = shortcut_info->category;
category_info = gth_main_get_shortcut_category (shortcut_info->category);
group = g_object_new (GTK_TYPE_SHORTCUTS_GROUP,
"title", ((category_info != NULL) && (category_info->display_name != NULL)) ? _(category_info->display_name) : _("Other"),
NULL);
gtk_widget_show (group);
gtk_container_add (GTK_CONTAINER (section), group);
}
shortcut = g_object_new (GTK_TYPE_SHORTCUTS_SHORTCUT,
"title", shortcut_info->description,
"accelerator", shortcut_info->accelerator,
NULL);
gtk_widget_show (shortcut);
gtk_container_add (GTK_CONTAINER (group), shortcut);
}
}
gtk_widget_show (window);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2019 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef GTH_SHORTCUTS_WINDOW_H
#define GTH_SHORTCUTS_WINDOW_H
#include "gth-window.h"
G_BEGIN_DECLS
void gth_shortcuts_window_new (GthWindow *window);
G_END_DECLS
#endif /* GTH_SHORTCUTS_WINDOW_H */
......@@ -249,6 +249,7 @@ source_files = files(
'gth-save-image-task.c',
'gth-screensaver.c',
'gth-shortcut.c',
'gth-shortcuts-window.c',
'gth-sidebar.c',
'gth-sidebar-section.c',
'gth-statusbar.c',
......
<page xmlns="http://projectmallard.org/1.0/" type="topic"
id="gthumb-shortcuts">
<info>
<link type="guide" xref="index#reference" />
</info>
<title>Keyboard Shortcuts</title>
<section id="view-hide-ui">
<title>Viewing and hiding parts of the user interface</title>
<table frame="all" rules="all">
<tr>
<td>
<p>Keyboard Shortcut</p>
</td>
<td>
<p>Description</p>
</td>
</tr>
<tr>
<td>
<p>
<key>F9</key>
</p>
</td>
<td>
<p>Show/Hide the sidebar in the browser mode. The sidebar contains the folder tree
and the file properties summary (if enabled).</p>
</td>
</tr>
<tr>
<td>
<p>
<key>i</key>
</p>
</td>
<td>
<p>Show the file properties summary.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>F8</key>
</p>
</td>
<td>
<p>Shows/hides the thumbnail pane in the viewer mode.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>F11</key> or <key>f</key>
</p>
</td>
<td>
<p>Toggles the fullscreen mode.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Esc</key>
</p>
</td>
<td>
<p>Closes the viewer or fullscreen mode.</p>
</td>
</tr>
</table>
</section>
<section id="browser-viewer">
<title>Editing shortcuts for the browser and viewer</title>
<table frame="all" rules="all">
<tr>
<td>
<p>Keyboard Shortcut</p>
</td>
<td>
<p>Description</p>
</td>
</tr>
<tr>
<td>
<p>
<key>e</key>
</p>
</td>
<td>
<p>Edit the image. Opens the viewer and shows the editing tools.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>g</key>
</p>
</td>
<td>
<p>Open the image with the GNU Image Manipulation Program (GIMP).</p>
</td>
</tr>
<tr>
<td>
<p>
<key>F2</key>
</p>
</td>
<td>
<p>Rename the image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>c</key>
</p>
</td>
<td>
<p>Add comments or metadata to the selected images.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>t</key>
</p>
</td>
<td>
<p>Add tags to the selected images.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>]</key>
</p>
</td>
<td>
<p>Rotate right, losslessly if possible. The file is saved automatically.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>[</key>
</p>
</td>
<td>
<p>Rotate left, losslessly if possible. The file is saved automatically.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Delete</key>
</p>
</td>
<td>
<p>Move the selected files to the Trash.</p>
</td>
</tr>
<tr>
<td>
<p>
<keyseq><key>Shift</key><key>Delete</key></keyseq>
</p>
</td>
<td>
<p>Delete the selected files permanently.</p>
</td>
</tr>
</table>
</section>
<section id="viewer-mode">
<title>Editing shortcuts for the viewer mode only</title>
<table frame="all" rules="all">
<tr>
<td>
<p>Keyboard Shortcut (Case Sensitive)</p>
</td>
<td>
<p>Description</p>
</td>
</tr>
<tr>
<td>
<p>
<key>a</key>
</p>
</td>
<td>
<p>Adjust contrast.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>l</key>
</p>
</td>
<td>
<p>Flip image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>m</key>
</p>
</td>
<td>
<p>Mirror image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>r</key>
</p>
</td>
<td>
<p>Rotate right.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>R</key>
</p>
</td>
<td>
<p>Rotate left.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>C</key>
</p>
</td>
<td>
<p>Crop image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>S</key>
</p>
</td>
<td>
<p>Resize image.</p>
</td>
</tr>
</table>
</section>
<section id="viewer">
<title>Viewer shortcuts</title>
<table frame="all" rules="all">
<tr>
<td>
<p>Keyboard Shortcut</p>
</td>
<td>
<p>Description</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Space</key> or
<key>Page Down</key></p>
</td>
<td>
<p>View the next image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Backspace</key> or
<key>Page Up</key></p>
</td>
<td>
<p>View the previous image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Home</key>
</p>
</td>
<td>
<p>View the first image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>End</key>
</p>
</td>
<td>
<p>View the last image.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>+</key> or
<key>=</key></p>
</td>
<td>
<p>Zoom in.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>-</key>
</p>
</td>
<td>
<p>Zoom out.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>1</key> or
<key>z</key> or
<key>/ (numeric keypad)</key></p>
</td>
<td>
<p>Actual size.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>x</key> or
<key>* (numeric keypad)</key></p>
</td>
<td>
<p>Zoom to fit (scales down only, does not magnify)</p>
</td>
</tr>
<tr>
<td>
<p>
<keyseq>
<key>Shift</key>
<key>x</key>
</keyseq>
</p>
</td>
<td>
<p>Zoom to fit (scale down or magnify, as required)</p>
</td>
</tr>
<tr>
<td>
<p>
<key>w</key></p>
</td>
<td>
<p>Zoom to fit width (scales down only, does not magnify)</p>
</td>
</tr>
<tr>
<td>
<p>
<keyseq>
<key>Shift</key>
<key>w</key>
</keyseq>
</p>
</td>
<td>
<p>Zoom to fit width (scale down or magnify, as required)</p>
</td>
</tr>
<tr>
<td>
<p>
<key>h</key></p>
</td>
<td>
<p>Zoom to fit height (scales down only, does not magnify)</p>
</td>
</tr>
<tr>
<td>
<p>
<keyseq>
<key>Shift</key>
<key>h</key>
</keyseq>
</p>
</td>
<td>
<p>Zoom to fit height (scale down or magnify, as required)</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Arrows</key>
</p>
</td>
<td>
<p>Scroll the image.</p>
</td>
</tr>
<tr>
<td>
<p>
<keyseq>
<key>Shift</key>
<key>Arrows</key>
</keyseq>
</p>
</td>
<td>
<p>Scroll the image faster.</p>
</td>
</tr>
</table>
</section>
<section id="browser-navigation">
<title>Browser Navigation</title>
<table frame="all" rules="all">
<tr>
<td>
<p>
<key>Home</key>
</p>
</td>
<td>
<p>Go to the first file in the browser view.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>End</key>
</p>
</td>
<td>
<p>Go to the last file in the browser view.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Down Arrow</key> or <key>Page Down</key>
</p>
</td>
<td>
<p>Scroll downwards through the thumbnails.</p>
</td>
</tr>
<tr>
<td>
<p>
<key>Up Arrow</key> or <key>Page Up</key>
</p>
</td>
<td>
<p>Scroll upwards through the thumbnails.</p>