[devhelp] amtk: create AmtkActionInfo's



commit c1cdc247e1b5f0bd7da607497e988bde59219cff
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Apr 12 20:41:58 2018 +0200

    amtk: create AmtkActionInfo's
    
    Amtk will permit to avoid GAction information duplication, and can
    permit to have a higher-level libdevhelp API in the future.
    
    The accels will be set later.

 README       |    1 +
 meson.build  |    1 +
 src/dh-app.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/dh-app.h |    2 ++
 4 files changed, 58 insertions(+), 1 deletions(-)
---
diff --git a/README b/README
index 033afef..6ee06e4 100644
--- a/README
+++ b/README
@@ -11,6 +11,7 @@ Dependencies
 - glib >= 2.56
 - gtk+ >= 3.22
 - webkit2gtk-4.0 >= 2.20
+- Amtk >= 4.99.0 - https://wiki.gnome.org/Projects/Amtk
 - gsettings-desktop-schemas
 
 Description
diff --git a/meson.build b/meson.build
index d53ad75..ea62681 100644
--- a/meson.build
+++ b/meson.build
@@ -48,6 +48,7 @@ endforeach
 
 DEVHELP_APP_DEPS = [
         LIBDEVHELP_DEPS,
+        dependency('amtk-5', version : '>= 4.99.0'),
         dependency('gsettings-desktop-schemas'),
         meson.get_compiler('c').find_library('m')
 ]
diff --git a/src/dh-app.c b/src/dh-app.c
index 2cf820f..d1fb8b8 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -25,12 +25,49 @@
 #include "config.h"
 #include "dh-app.h"
 #include <glib/gi18n.h>
+#include <amtk/amtk.h>
 #include "dh-assistant.h"
 #include "dh-preferences.h"
 #include "dh-settings-app.h"
 #include "dh-util-app.h"
 
-G_DEFINE_TYPE (DhApp, dh_app, GTK_TYPE_APPLICATION);
+struct _DhAppPrivate {
+        AmtkActionInfoStore *action_info_store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (DhApp, dh_app, GTK_TYPE_APPLICATION);
+
+static void
+add_action_infos (DhApp *app)
+{
+        const AmtkActionInfoEntry entries[] = {
+                /* action, icon, label, accel */
+
+                /* App menu */
+                { "app.new-window", NULL, N_("New _Window") },
+                { "app.preferences", NULL, N_("_Preferences") },
+                { "win.show-help-overlay", NULL, N_("_Keyboard Shortcuts") },
+                { "app.help", NULL, N_("_Help") },
+                { "app.about", NULL, N_("_About") },
+                { "app.quit", NULL, N_("_Quit") },
+
+                /* Window menu */
+                { "win.show-sidebar", NULL, N_("_Side Panel") },
+                { "win.print", NULL, N_("_Print") },
+                { "win.find", NULL, N_("_Find") },
+                { "win.zoom-in", NULL, N_("_Larger Text") },
+                { "win.zoom-out", NULL, N_("S_maller Text") },
+                { "win.zoom-default", NULL, N_("_Normal Size") },
+                { NULL }
+        };
+
+        g_assert (app->priv->action_info_store == NULL);
+        app->priv->action_info_store = amtk_action_info_store_new ();
+
+        amtk_action_info_store_add_entries (app->priv->action_info_store,
+                                            entries, -1,
+                                            GETTEXT_PACKAGE);
+}
 
 static DhAssistant *
 get_active_assistant_window (DhApp *app)
@@ -384,6 +421,7 @@ dh_app_startup (GApplication *application)
         if (G_APPLICATION_CLASS (dh_app_parent_class)->startup != NULL)
                 G_APPLICATION_CLASS (dh_app_parent_class)->startup (application);
 
+        add_action_infos (app);
         add_action_entries (app);
         setup_accelerators (GTK_APPLICATION (app));
         set_app_menu_if_needed (GTK_APPLICATION (app));
@@ -480,10 +518,23 @@ dh_app_command_line (GApplication            *g_app,
 }
 
 static void
+dh_app_dispose (GObject *object)
+{
+        DhApp *app = DH_APP (object);
+
+        g_clear_object (&app->priv->action_info_store);
+
+        G_OBJECT_CLASS (dh_app_parent_class)->dispose (object);
+}
+
+static void
 dh_app_class_init (DhAppClass *klass)
 {
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
         GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
 
+        object_class->dispose = dh_app_dispose;
+
         application_class->startup = dh_app_startup;
         application_class->activate = dh_app_activate;
         application_class->handle_local_options = dh_app_handle_local_options;
@@ -493,6 +544,8 @@ dh_app_class_init (DhAppClass *klass)
 static void
 dh_app_init (DhApp *app)
 {
+        app->priv = dh_app_get_instance_private (app);
+
         /* Translators: please don't translate "Devhelp" (it's marked as
          * translatable for transliteration only).
          */
diff --git a/src/dh-app.h b/src/dh-app.h
index 1d60918..986b55e 100644
--- a/src/dh-app.h
+++ b/src/dh-app.h
@@ -36,9 +36,11 @@ G_BEGIN_DECLS
 
 typedef struct _DhApp        DhApp;
 typedef struct _DhAppClass   DhAppClass;
+typedef struct _DhAppPrivate DhAppPrivate;
 
 struct _DhApp {
         GtkApplication parent_instance;
+        DhAppPrivate *priv;
 };
 
 struct _DhAppClass {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]