[gthumb] shortcuts: use a shortcuts window to show the shortcuts
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] shortcuts: use a shortcuts window to show the shortcuts
- Date: Sun, 24 Nov 2019 12:31:17 +0000 (UTC)
commit 8115cd5e9e37a55cf8c3e30e5287da032a281c0b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Nov 12 17:01:13 2019 +0100
shortcuts: use a shortcuts window to show the shortcuts
Shortcuts are dynamic now, the help page is static.
gthumb/gth-browser-actions-callbacks.c | 3 +-
gthumb/gth-shortcuts-window.c | 109 ++++++
gthumb/gth-shortcuts-window.h | 33 ++
gthumb/meson.build | 1 +
help/C/shortcuts.page | 594 ---------------------------------
help/meson.build | 1 -
6 files changed, 145 insertions(+), 596 deletions(-)
---
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index 21c2c6e9..f6bb5c40 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -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));
}
diff --git a/gthumb/gth-shortcuts-window.c b/gthumb/gth-shortcuts-window.c
new file mode 100644
index 00000000..3ec609ea
--- /dev/null
+++ b/gthumb/gth-shortcuts-window.c
@@ -0,0 +1,109 @@
+/* -*- 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);
+}
diff --git a/gthumb/gth-shortcuts-window.h b/gthumb/gth-shortcuts-window.h
new file mode 100644
index 00000000..5a19e253
--- /dev/null
+++ b/gthumb/gth-shortcuts-window.h
@@ -0,0 +1,33 @@
+/* -*- 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 */
diff --git a/gthumb/meson.build b/gthumb/meson.build
index 761446aa..c1bc054a 100644
--- a/gthumb/meson.build
+++ b/gthumb/meson.build
@@ -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',
diff --git a/help/meson.build b/help/meson.build
index 67f7c9d9..5110dfa7 100644
--- a/help/meson.build
+++ b/help/meson.build
@@ -25,7 +25,6 @@ gnome.yelp('gthumb',
'sorting.page',
'filtering.page',
'printing.page',
- 'shortcuts.page',
'sharing-disc.page',
'sharing-social.page',
'wallpaper.page',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]