[Xfce4-commits] [xfce/xfdesktop] 32/34: xfdesktop-application.c: remove screen count deprecations

noreply at xfce.org noreply at xfce.org
Sun Apr 16 07:07:06 CEST 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 62ec4c11ec7d27834064dca0b65a5d5951872a43
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Apr 16 07:02:34 2017 +0300

    xfdesktop-application.c: remove screen count deprecations
    
    Since the Gtk3 toolkit doesn't support multi-screen, Zaphod mode,
    anymore we can assume there's only one desktop now.
---
 src/xfdesktop-application.c | 134 +++++++++++---------------------------------
 1 file changed, 33 insertions(+), 101 deletions(-)

diff --git a/src/xfdesktop-application.c b/src/xfdesktop-application.c
index 226fca8..77935c7 100644
--- a/src/xfdesktop-application.c
+++ b/src/xfdesktop-application.c
@@ -82,8 +82,6 @@ static void cb_xfdesktop_application_quit(GAction  *action,
                                           GVariant *parameter,
                                           gpointer  data);
 
-static gint xfdesktop_application_get_current_screen_number(XfdesktopApplication *app);
-
 static void cb_xfdesktop_application_menu(GAction  *action,
                                           GVariant *parameter,
                                           gpointer  data);
@@ -125,13 +123,8 @@ struct _XfdesktopApplication
 {
     GApplication parent;
 
-#if !GLIB_CHECK_VERSION (2, 32, 0)
-    GSimpleActionGroup *actions;
-#endif
-
-    GtkWidget **desktops;
+    GtkWidget *desktop;
     XfconfChannel *channel;
-    gint nscreens;
     guint wait_for_wm_timeout_id;
     XfceSMClient *sm_client;
     GCancellable *cancel;
@@ -166,11 +159,7 @@ 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
@@ -180,10 +169,6 @@ xfdesktop_application_init(XfdesktopApplication *app)
 
     app->cancel = g_cancellable_new();
 
-#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);
@@ -219,10 +204,6 @@ xfdesktop_application_init(XfdesktopApplication *app)
     g_signal_connect(action, "activate", G_CALLBACK(cb_xfdesktop_application_debug), app);
     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
@@ -281,11 +262,7 @@ session_die(gpointer user_data)
     for(main_level = gtk_main_level(); main_level > 0; --main_level)
         gtk_main_quit();
 
-#if GLIB_CHECK_VERSION(2, 32, 0)
     g_application_quit(G_APPLICATION(app));
-#else
-    xfdesktop_application_shutdown(G_APPLICATION(app));
-#endif
 }
 
 static void
@@ -365,20 +342,17 @@ static gboolean
 reload_idle_cb(gpointer data)
 {
     XfdesktopApplication *app = XFDESKTOP_APPLICATION(data);
-    gint i;
 
     TRACE("entering");
 
     /* If xfdesktop never started there's nothing to reload, xfdesktop will
      * now startup */
-    if(!app->desktops)
+    if(!app->desktop)
         return FALSE;
 
-    /* reload all the desktops */
-    for(i = 0; i < app->nscreens; ++i) {
-        if(app->desktops[i])
-            xfce_desktop_refresh(XFCE_DESKTOP(app->desktops[i]), FALSE);
-    }
+    /* reload all the desktop */
+    if(app->desktop)
+        xfce_desktop_refresh(XFCE_DESKTOP(app->desktop), FALSE);
 
     g_application_release(G_APPLICATION(app));
 
@@ -408,7 +382,6 @@ cb_xfdesktop_application_next(GAction  *action,
                               gpointer  data)
 {
     XfdesktopApplication *app;
-    gint i;
 
     TRACE("entering");
 
@@ -417,14 +390,12 @@ cb_xfdesktop_application_next(GAction  *action,
     app = XFDESKTOP_APPLICATION(data);
 
     /* If xfdesktop never started there's nothing to do here */
-    if(!app->desktops)
+    if(!app->desktop)
         return;
 
-    /* reload all the desktops forcing the wallpaper to advance */
-    for(i = 0; i < app->nscreens; ++i) {
-        if(app->desktops[i])
-            xfce_desktop_refresh(XFCE_DESKTOP(app->desktops[i]), TRUE);
-    }
+    /* reload the desktop forcing the wallpaper to advance */
+    if(app->desktop)
+        xfce_desktop_refresh(XFCE_DESKTOP(app->desktop), TRUE);
 }
 
 static void
@@ -461,23 +432,6 @@ cb_xfdesktop_application_quit(GAction  *action,
     session_die(app);
 }
 
-static gint
-xfdesktop_application_get_current_screen_number(XfdesktopApplication *app)
-{
-    GdkDisplay *display = gdk_display_get_default();
-    GdkScreen *screen;
-    gint screen_num;
-
-    gdk_display_get_pointer(display, &screen, NULL, NULL, NULL);
-
-    screen_num = gdk_screen_get_number(screen);
-
-    if(screen_num >= app->nscreens) {
-        return -1;
-    }
-
-    return screen_num;
-}
 
 /* parameter is a boolean that determines whether to popup the primay or
  * windowlist menu */
@@ -488,7 +442,6 @@ cb_xfdesktop_application_menu(GAction  *action,
 {
     XfdesktopApplication *app;
     gboolean popup_root_menu;
-    gint screen_num;
 
     TRACE("entering");
 
@@ -502,16 +455,11 @@ cb_xfdesktop_application_menu(GAction  *action,
     popup_root_menu = g_variant_get_boolean(parameter);
     app = XFDESKTOP_APPLICATION(data);
 
-    screen_num = xfdesktop_application_get_current_screen_number(app);
-    /* not initialized */
-    if(screen_num < 0)
-        return;
-
     if(popup_root_menu) {
-        xfce_desktop_popup_root_menu(XFCE_DESKTOP(app->desktops[screen_num]),
+        xfce_desktop_popup_root_menu(XFCE_DESKTOP(app->desktop),
                                      NULL);
     } else {
-        xfce_desktop_popup_secondary_root_menu(XFCE_DESKTOP(app->desktops[screen_num]),
+        xfce_desktop_popup_secondary_root_menu(XFCE_DESKTOP(app->desktop),
                                                NULL);
     }
 }
@@ -522,7 +470,6 @@ cb_xfdesktop_application_arrange(GAction  *action,
                                  gpointer  data)
 {
     XfdesktopApplication *app;
-    gint screen_num;
 
     TRACE("entering");
 
@@ -532,12 +479,7 @@ cb_xfdesktop_application_arrange(GAction  *action,
 
     app = XFDESKTOP_APPLICATION(data);
 
-    screen_num = xfdesktop_application_get_current_screen_number(app);
-    /* not initialized */
-    if(screen_num < 0)
-        return;
-
-    xfce_desktop_arrange_icons(XFCE_DESKTOP(app->desktops[screen_num]));
+    xfce_desktop_arrange_icons(XFCE_DESKTOP(app->desktop));
 }
 
 /* parameter is a boolean that determines whether to enable or disable the
@@ -684,7 +626,6 @@ xfdesktop_application_start(XfdesktopApplication *app)
 {
     GdkDisplay *gdpy;
     GError *error = NULL;
-    gint i;
     gchar buf[1024];
 
     TRACE("entering");
@@ -717,32 +658,27 @@ xfdesktop_application_start(XfdesktopApplication *app)
     } else
         app->channel = xfconf_channel_get(XFDESKTOP_CHANNEL);
 
-    /* create an XfceDesktop for every screen */
-    app->nscreens = gdk_display_get_n_screens(gdpy);
-    app->desktops = g_new0(GtkWidget *, app->nscreens);
+    g_snprintf(buf, sizeof(buf), "/backdrop/screen%d/", 0);
+    app->desktop = xfce_desktop_new(gdk_display_get_default_screen(gdpy),
+                                    app->channel, buf);
 
-    for(i = 0; i < app->nscreens; i++) {
-        g_snprintf(buf, sizeof(buf), "/backdrop/screen%d/", i);
-        app->desktops[i] = xfce_desktop_new(gdk_display_get_screen(gdpy, i),
-                                            app->channel, buf);
+    /* hook into the scroll event so we can forward it to the window
+     * manager */
+    gtk_widget_add_events(app->desktop, GDK_BUTTON_PRESS_MASK
+                          | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK);
+    g_signal_connect(G_OBJECT(app->desktop), "scroll-event",
+                     G_CALLBACK(scroll_cb), app);
 
-        /* hook into the scroll event so we can forward it to the window
-         * manager */
-        gtk_widget_add_events(app->desktops[i], GDK_BUTTON_PRESS_MASK
-                              | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK);
-        g_signal_connect(G_OBJECT(app->desktops[i]), "scroll-event",
-                         G_CALLBACK(scroll_cb), app);
+    menu_attach(XFCE_DESKTOP(app->desktop));
+    windowlist_attach(XFCE_DESKTOP(app->desktop));
 
-        menu_attach(XFCE_DESKTOP(app->desktops[i]));
-        windowlist_attach(XFCE_DESKTOP(app->desktops[i]));
+    /* display the desktop and try to put it at the bottom */
+    gtk_widget_realize(app->desktop);
+    gdk_window_lower(gtk_widget_get_window(app->desktop));
 
-        /* display the desktop and try to put it at the bottom */
-        gtk_widget_realize(app->desktops[i]);
-        gdk_window_lower(gtk_widget_get_window(app->desktops[i]));
+    xfce_desktop_set_session_logout_func(XFCE_DESKTOP(app->desktop),
+                                         session_logout);
 
-        xfce_desktop_set_session_logout_func(XFCE_DESKTOP(app->desktops[i]),
-                                             session_logout);
-    }
 
     menu_init(app->channel);
     windowlist_init(app->channel);
@@ -779,7 +715,6 @@ static void
 xfdesktop_application_shutdown(GApplication *g_application)
 {
     XfdesktopApplication *app = XFDESKTOP_APPLICATION(g_application);
-    gint i;
 
     TRACE("entering");
 
@@ -791,15 +726,12 @@ xfdesktop_application_shutdown(GApplication *g_application)
     menu_cleanup();
     windowlist_cleanup();
 
-    if(app->desktops) {
-        for(i = 0; i < app->nscreens; i++) {
-            /* ensure the desktops get freed if they haven't been */
-            if(app->desktops[i] && GTK_IS_WIDGET(app->desktops[i]))
-                gtk_widget_destroy(app->desktops[i]);
-        }
+    if(app->desktop) {
+        /* ensure the desktop gets freed if it hasen't been */
+        if(app->desktop && GTK_IS_WIDGET(app->desktop))
+            gtk_widget_destroy(app->desktop);
 
-        g_free(app->desktops);
-        app->desktops = NULL;
+        app->desktop = NULL;
     }
 
     xfconf_shutdown();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list