[Xfce4-commits] <xfdesktop:eric/Port-to-GApplication> Workaround g_action_map being too new

Eric Koegel noreply at xfce.org
Sat Sep 21 09:54:01 CEST 2013


Updating branch refs/heads/eric/Port-to-GApplication
         to 1d9dca11efbc9ac7f416d9c9dccb2049be2b5997 (commit)
       from f4fa63b92f0ee07268f0af8b0bccb39a03c0e0e5 (commit)

commit 1d9dca11efbc9ac7f416d9c9dccb2049be2b5997
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sat Sep 21 10:50:39 2013 +0300

    Workaround g_action_map being too new
    
    This adds in code for g_simple_action_group stuff so that it will
    work with glib versions earlier than 2.32.

 src/xfdesktop-application.c |   30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/xfdesktop-application.c b/src/xfdesktop-application.c
index f1b2944..f52c821 100644
--- a/src/xfdesktop-application.c
+++ b/src/xfdesktop-application.c
@@ -99,6 +99,10 @@ struct _XfdesktopApplication
 {
     GApplication parent;
 
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+    GSimpleActionGroup *actions;
+#endif
+
     GtkWidget **desktops;
     XfconfChannel *channel;
     gint nscreens;
@@ -130,33 +134,51 @@ xfdesktop_application_class_init(XfdesktopApplicationClass *klass)
 }
 
 static void
+xfdesktop_application_add_action(XfdesktopApplication *app, GAction *action)
+{
+#if GLIB_CHECK_VERSION (2, 32, 0)
+    g_action_map_add_action(G_ACTION_MAP(app), action);
+#else
+    g_simple_action_group_insert(app->actions, action);
+#endif
+}
+
+static void
 xfdesktop_application_init(XfdesktopApplication *app)
 {
     GSimpleAction *action;
 
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+    app->actions = g_simple_action_group_new();
+#endif
+
     /* reload action */
     action = g_simple_action_new("reload", NULL);
     g_signal_connect(action, "activate", G_CALLBACK(cb_xfdesktop_application_reload), app);
-    g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(action));
+    xfdesktop_application_add_action(app, G_ACTION(action));
     g_object_unref(action);
 
     /* quit action */
     action = g_simple_action_new("quit", NULL);
     g_signal_connect(action, "activate", G_CALLBACK(cb_xfdesktop_application_quit), app);
-    g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(action));
+    xfdesktop_application_add_action(app, G_ACTION(action));
     g_object_unref(action);
 
     /* menu action, parameter pops up primary (TRUE) or windowlist menu */
     action = g_simple_action_new("menu", G_VARIANT_TYPE_BOOLEAN);
     g_signal_connect(action, "activate", G_CALLBACK(cb_xfdesktop_application_menu), app);
-    g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(action));
+    xfdesktop_application_add_action(app, G_ACTION(action));
     g_object_unref(action);
 
     /* arrange action */
     action = g_simple_action_new("arrange", NULL);
     g_signal_connect(action, "activate", G_CALLBACK(cb_xfdesktop_application_arrange), app);
-    g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(action));
+    xfdesktop_application_add_action(app, G_ACTION(action));
     g_object_unref(action);
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+    g_application_set_action_group(G_APPLICATION(app), (GActionGroup*)app->actions);
+#endif
 }
 
 static void


More information about the Xfce4-commits mailing list