[Xfce4-commits] [xfce/xfce4-session] 15/30: Port the main part of xfsm to Gtk3

noreply at xfce.org noreply at xfce.org
Sun May 15 18:03:34 CEST 2016


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

eric pushed a commit to branch master
in repository xfce/xfce4-session.

commit b3a918b1975858a6219161f49ce4e696af6d3473
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Wed Apr 20 18:14:14 2016 +0300

    Port the main part of xfsm to Gtk3
---
 xfce4-session/main.c               |   3 -
 xfce4-session/xfsm-chooser.c       |   8 +--
 xfce4-session/xfsm-compat-gnome.c  |   4 +-
 xfce4-session/xfsm-compat-kde.c    |   4 +-
 xfce4-session/xfsm-fadeout.c       |  21 +++----
 xfce4-session/xfsm-legacy.c        |   2 +-
 xfce4-session/xfsm-logout-dialog.c | 113 +++++++++++++++++++++++++++----------
 xfce4-session/xfsm-manager.c       |  16 +++---
 xfce4-session/xfsm-splash-screen.c |   6 +-
 9 files changed, 116 insertions(+), 61 deletions(-)

diff --git a/xfce4-session/main.c b/xfce4-session/main.c
index 8e2aea9..fba6dc5 100644
--- a/xfce4-session/main.c
+++ b/xfce4-session/main.c
@@ -142,9 +142,6 @@ init_display (XfsmManager   *manager,
   gdk_flush ();
 
   sm_init (channel, disable_tcp, manager);
-
-  /* gtk resource files may have changed */
-  gtk_rc_reparse_all ();
 }
 
 
diff --git a/xfce4-session/xfsm-chooser.c b/xfce4-session/xfsm-chooser.c
index 9532488..948cfcf 100644
--- a/xfce4-session/xfsm-chooser.c
+++ b/xfce4-session/xfsm-chooser.c
@@ -198,7 +198,7 @@ xfsm_chooser_init (XfsmChooser *chooser)
   gtk_widget_show (chooser->tree);
 
   /* "Logout" button */
-  button = xfce_gtk_button_new_mixed (GTK_STOCK_QUIT, _("Log out"));
+  button = xfce_gtk_button_new_mixed ("application-exit", _("Log out"));
   gtk_widget_set_tooltip_text (button,
                                _("Cancel the login attempt and return to "
                                  "the login screen."));
@@ -207,7 +207,7 @@ xfsm_chooser_init (XfsmChooser *chooser)
   gtk_widget_show (button);
 
   /* "New" button */
-  button = xfce_gtk_button_new_mixed (GTK_STOCK_NEW, _("New session"));
+  button = xfce_gtk_button_new_mixed ("document-new", _("New session"));
   gtk_widget_set_tooltip_text (button, _("Create a new session."));
   gtk_dialog_add_action_widget (GTK_DIALOG (chooser), button,
                                 XFSM_RESPONSE_NEW);
@@ -231,8 +231,8 @@ xfsm_chooser_realized (GtkWidget   *widget,
 {
   GdkCursor *cursor;
 
-  cursor = gdk_cursor_new (GDK_LEFT_PTR);
+  cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_LEFT_PTR);
   gdk_window_set_cursor (gtk_widget_get_window(widget), cursor);
-  gdk_cursor_unref (cursor);
+  g_object_unref (cursor);
 }
 
diff --git a/xfce4-session/xfsm-compat-gnome.c b/xfce4-session/xfsm-compat-gnome.c
index 2d0d52d..8734fb9 100644
--- a/xfce4-session/xfsm-compat-gnome.c
+++ b/xfce4-session/xfsm-compat-gnome.c
@@ -222,7 +222,7 @@ xfsm_compat_gnome_smproxy_startup (void)
 
   XSync (dpy, False);
 
-  gdk_error_trap_pop ();
+  gdk_error_trap_pop_ignored ();
 }
 
 
@@ -238,7 +238,7 @@ xfsm_compat_gnome_smproxy_shutdown (void)
       gnome_smproxy_window = None;
     }
 
-  gdk_error_trap_pop ();
+  gdk_error_trap_pop_ignored ();
 }
 
 
diff --git a/xfce4-session/xfsm-compat-kde.c b/xfce4-session/xfsm-compat-kde.c
index b51387e..6b6f2f4 100644
--- a/xfce4-session/xfsm-compat-kde.c
+++ b/xfce4-session/xfsm-compat-kde.c
@@ -43,6 +43,8 @@
 #include <unistd.h>
 #endif
 
+#include <gdk/gdkx.h>
+
 #include <libxfce4util/libxfce4util.h>
 
 #include <xfce4-session/xfsm-compat-kde.h>
@@ -132,7 +134,7 @@ xfsm_compat_kde_startup (XfsmSplashScreen *splash)
   run (command);
 
   /* tell kde if we are running multi-head */
-  if (gdk_display_get_n_screens (gdk_display_get_default ()) > 1)
+  if (XScreenCount (gdk_x11_display_get_xdisplay (gdk_display_get_default ())) > 1)
     {
       g_snprintf (command, 256, "qdbus org.kde.klauncher /KLauncher setLaunchEnv "
                                 "KDE_MULTIHEAD \"true\"");
diff --git a/xfce4-session/xfsm-fadeout.c b/xfce4-session/xfsm-fadeout.c
index a3a0f01..8102acf 100644
--- a/xfce4-session/xfsm-fadeout.c
+++ b/xfce4-session/xfsm-fadeout.c
@@ -24,7 +24,7 @@
 #endif
 
 #include <gtk/gtk.h>
-
+#include <gdk/gdkx.h>
 #include <xfce4-session/xfsm-fadeout.h>
 
 
@@ -51,11 +51,11 @@ xfsm_fadeout_new (GdkDisplay *display)
   cairo_surface_t *surface;
   GdkScreen       *gdk_screen;
   GdkWindow       *window;
-  GdkColor         black = { 0, };
+  GdkRGBA          black = { 0, };
 
   fadeout = g_slice_new0 (XfsmFadeout);
 
-  cursor = gdk_cursor_new (GDK_WATCH);
+  cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
 
   attr.x = 0;
   attr.y = 0;
@@ -65,7 +65,7 @@ xfsm_fadeout_new (GdkDisplay *display)
   attr.cursor = cursor;
   attr.override_redirect = TRUE;
 
-  for (n = 0; n < gdk_display_get_n_screens (display); ++n)
+  for (n = 0; n < XScreenCount (gdk_x11_display_get_xdisplay ((display))); ++n)
     {
       gdk_screen = gdk_display_get_screen (display, n);
 
@@ -80,10 +80,10 @@ xfsm_fadeout_new (GdkDisplay *display)
                                | GDK_WA_NOREDIR | GDK_WA_CURSOR);
 
       if (gdk_screen_is_composited (gdk_screen)
-          && gdk_screen_get_rgba_colormap (gdk_screen) != NULL)
+          && gdk_screen_get_rgba_visual (gdk_screen) != NULL)
         {
           /* transparent black window */
-          gdk_window_set_background (window, &black);
+          gdk_window_set_background_rgba (window, &black);
           gdk_window_set_opacity (window, 0.50);
         }
       else
@@ -93,14 +93,13 @@ xfsm_fadeout_new (GdkDisplay *display)
           cr = cairo_create (surface);
 
           /* make of copy of the root window */
-          root_pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (root), NULL,
-                                                      0, 0, 0, 0, width, height);
+          root_pixbuf = gdk_pixbuf_get_from_window (root, 0, 0, width, height);
           gdk_cairo_set_source_pixbuf (cr, root_pixbuf, 0, 0);
           cairo_paint (cr);
           g_object_unref (G_OBJECT (root_pixbuf));
 
           /* draw black layer */
-          gdk_cairo_set_source_color (cr, &black);
+          gdk_cairo_set_source_rgba (cr, &black);
           cairo_paint_with_alpha (cr, 0.50);
           cairo_destroy (cr);
           cairo_surface_destroy (surface);
@@ -112,7 +111,7 @@ xfsm_fadeout_new (GdkDisplay *display)
   /* show all windows all at once */
   g_slist_foreach (fadeout->windows, (GFunc) gdk_window_show, NULL);
 
-  gdk_cursor_unref (cursor);
+  g_object_unref (cursor);
 
   return fadeout;
 }
@@ -122,8 +121,10 @@ xfsm_fadeout_new (GdkDisplay *display)
 void
 xfsm_fadeout_clear (XfsmFadeout *fadeout)
 {
+/* TODO: Test if this is needed.
   if (fadeout != NULL)
     g_slist_foreach (fadeout->windows, (GFunc) gdk_window_clear, NULL);
+ */
 }
 
 
diff --git a/xfce4-session/xfsm-legacy.c b/xfce4-session/xfsm-legacy.c
index c82dc73..6026673 100644
--- a/xfce4-session/xfsm-legacy.c
+++ b/xfce4-session/xfsm-legacy.c
@@ -664,7 +664,7 @@ xfsm_legacy_shutdown (void)
 
   gdk_flush ();
 
-  gdk_error_trap_pop ();
+  gdk_error_trap_pop_ignored ();
 #endif
 }
 
diff --git a/xfce4-session/xfsm-logout-dialog.c b/xfce4-session/xfsm-logout-dialog.c
index 1d98fdd..8d51577 100644
--- a/xfce4-session/xfsm-logout-dialog.c
+++ b/xfce4-session/xfsm-logout-dialog.c
@@ -166,7 +166,7 @@ xfsm_logout_dialog_init (XfsmLogoutDialog *dialog)
   if (xfsm_shutdown_can_save_session (dialog->shutdown))
     save_session = xfconf_channel_get_bool (channel, "/general/SaveOnExit", TRUE);
 
-  main_vbox = gtk_vbox_new (FALSE, BORDER);
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), main_vbox, TRUE, TRUE, 0);
   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), BORDER);
   gtk_widget_show (main_vbox);
@@ -191,29 +191,29 @@ xfsm_logout_dialog_init (XfsmLogoutDialog *dialog)
   gtk_label_set_attributes (GTK_LABEL (label), attrs);
   pango_attr_list_unref (attrs);
 
-  separator = gtk_hseparator_new ();
+  separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_box_pack_start (GTK_BOX (main_vbox), separator, FALSE, TRUE, 0);
   gtk_widget_show (separator);
 
   /**
    * Start mode MODE_LOGOUT_BUTTONS
    **/
-  dialog->box[MODE_LOGOUT_BUTTONS] = vbox = gtk_vbox_new (FALSE, BORDER);
+  dialog->box[MODE_LOGOUT_BUTTONS] = vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
 
   /**
    * Cancel
    **/
   dialog->button_cancel = gtk_dialog_add_button (GTK_DIALOG (dialog),
-                                                 GTK_STOCK_CANCEL,
+                                                 _("_Cancel"),
                                                  GTK_RESPONSE_CANCEL);
 
-  button_vbox = gtk_vbox_new (TRUE, BORDER);
+  button_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_box_pack_start (GTK_BOX (vbox), button_vbox, FALSE, TRUE, 0);
   gtk_widget_show (button_vbox);
 
   /* row for logout/shutdown and reboot */
-  hbox = gtk_hbox_new (TRUE, BORDER);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER);
   gtk_box_pack_start (GTK_BOX (button_vbox), hbox, FALSE, TRUE, 0);
   gtk_widget_show (hbox);
 
@@ -269,7 +269,7 @@ xfsm_logout_dialog_init (XfsmLogoutDialog *dialog)
   gtk_widget_show (button);
 
   /* new row for suspend/hibernate */
-  hbox = gtk_hbox_new (TRUE, BORDER);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER);
   gtk_box_pack_start (GTK_BOX (button_vbox), hbox, FALSE, TRUE, 0);
 
   /**
@@ -355,24 +355,25 @@ xfsm_logout_dialog_init (XfsmLogoutDialog *dialog)
   /**
    * Start mode MODE_SHOW_ERROR
    **/
-  dialog->box[MODE_SHOW_ERROR] = vbox = gtk_vbox_new (FALSE, BORDER);
+  dialog->box[MODE_SHOW_ERROR] = vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
 
-  hbox = gtk_hbox_new (FALSE, BORDER * 2);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER * 2);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
   gtk_widget_show (hbox);
 
-  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+  image = gtk_image_new_from_icon_name ("dialog-error", GTK_ICON_SIZE_DIALOG);
   gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
   gtk_widget_show (image);
 
-  vbox = gtk_vbox_new (FALSE, BORDER);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
   gtk_widget_show (vbox);
 
   label = gtk_label_new (_("An error occurred"));
   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-  gtk_misc_set_alignment (GTK_MISC (label), 0.00, 0.50);
+  gtk_label_set_xalign (GTK_LABEL (label), 0.00);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.50);
   gtk_label_set_attributes (GTK_LABEL (label), attrs);
   gtk_widget_show (label);
 
@@ -450,7 +451,7 @@ xfsm_logout_dialog_button (const gchar      *title,
   g_signal_connect (G_OBJECT (button), "clicked",
       G_CALLBACK (xfsm_logout_dialog_button_clicked), dialog);
 
-  vbox = gtk_vbox_new (FALSE, BORDER);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER);
   gtk_container_add (GTK_CONTAINER (button), vbox);
   gtk_widget_show (vbox);
@@ -513,13 +514,7 @@ xfsm_logout_dialog_screenshot_new (GdkScreen *screen)
   if (!gdk_rectangle_intersect (&rect, &screen_rect, &rect))
     return NULL;
 
-  screenshot = gdk_pixbuf_get_from_drawable  (NULL,
-                                             GDK_DRAWABLE (window),
-                                             NULL,
-                                             0, 0,
-                                             0, 0,
-                                             rect.width,
-                                             rect.height);
+  screenshot = gdk_pixbuf_get_from_window  (window, 0, 0, rect.width, rect.height);
 
   gdk_display_beep (gdk_screen_get_display (screen));
 
@@ -617,29 +612,66 @@ xfsm_logout_dialog_run (GtkDialog *dialog,
 {
   GdkWindow *window;
   gint       ret;
+#if !GTK_CHECK_VERSION (3, 20, 0)
+  GdkDevice *device;
+#else
+  GdkSeat   *seat;
+#endif
 
   if (grab_input)
     {
       gtk_widget_show_now (GTK_WIDGET (dialog));
 
       window = gtk_widget_get_window (GTK_WIDGET (dialog));
-      if (gdk_keyboard_grab (window, FALSE, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
-        g_critical ("Failed to grab the keyboard for logout window");
+
+#if !GTK_CHECK_VERSION (3, 20, 0)
+          device = gtk_get_current_event_device ();
+
+          if (gdk_device_grab (device,
+                               window,
+                               GDK_OWNERSHIP_APPLICATION,
+                               FALSE,
+                               GDK_KEY_PRESS_MASK,
+                               NULL,
+                               GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
+            {
+              g_critical ("Failed to grab the keyboard for logout window");
+            }
+#else
+          seat = gdk_device_get_seat (gtk_get_current_event_device ());
+
+          if (gdk_seat_grab (seat,
+                             window,
+                             GDK_SEAT_CAPABILITY_KEYBOARD,
+                             FALSE,
+                             NULL,
+                             gtk_get_current_event (),
+                             NULL,
+                             NULL) != GDK_GRAB_SUCCESS)
+            {
+              g_critical ("Failed to grab the keyboard for logout window");
+            }
+#endif
 
 #ifdef GDK_WINDOWING_X11
       /* force input to the dialog */
       gdk_error_trap_push ();
       XSetInputFocus (gdk_x11_get_default_xdisplay (),
-                      GDK_WINDOW_XWINDOW (window),
+                      GDK_WINDOW_XID (window),
                       RevertToParent, CurrentTime);
-      gdk_error_trap_pop ();
+      gdk_error_trap_pop_ignored ();
 #endif
     }
 
   ret = gtk_dialog_run (dialog);
 
+#if !GTK_CHECK_VERSION (3, 20, 0)
   if (grab_input)
-    gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+    gdk_device_ungrab (device, GDK_CURRENT_TIME);
+#else
+    if (grab_input)
+    gdk_seat_ungrab (seat);
+#endif
 
   return ret;
 }
@@ -702,13 +734,36 @@ xfsm_logout_dialog (const gchar      *session_name,
        * the dialog when running it */
       for (;;)
         {
-          if (gdk_keyboard_grab (gtk_widget_get_window (hidden), FALSE,
-                                 GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
+#if !GTK_CHECK_VERSION (3, 20, 0)
+          GdkDevice *device = gtk_get_current_event_device ();
+
+          if (gdk_device_grab (device,
+                               gtk_widget_get_window (hidden),
+                               GDK_OWNERSHIP_APPLICATION,
+                               FALSE,
+                               GDK_KEY_PRESS_MASK,
+                               NULL,
+                               GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
             {
-              gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+              gdk_device_ungrab (device, GDK_CURRENT_TIME);
               break;
             }
-
+#else
+          GdkSeat *seat = gdk_device_get_seat (gtk_get_current_event_device ());
+
+          if (gdk_seat_grab (seat,
+                             gtk_widget_get_window (hidden),
+                             GDK_SEAT_CAPABILITY_KEYBOARD,
+                             FALSE,
+                             NULL,
+                             gtk_get_current_event (),
+                             NULL,
+                             NULL) == GDK_GRAB_SUCCESS)
+            {
+              gdk_seat_ungrab (seat);
+              break;
+            }
+#endif
           g_usleep (G_USEC_PER_SEC / 20);
         }
 
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index d677076..14f6635 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -68,7 +68,7 @@
 
 #include <gdk-pixbuf/gdk-pixdata.h>
 #include <gtk/gtk.h>
-
+#include <gdk/gdkx.h>
 #include <libwnck/libwnck.h>
 
 #include <libxfce4ui/libxfce4ui.h>
@@ -338,7 +338,7 @@ xfsm_manager_restore_active_workspace (XfsmManager *manager,
   gint            n, m;
 
   display = gdk_display_get_default ();
-  for (n = 0; n < gdk_display_get_n_screens (display); ++n)
+  for (n = 0; n < XScreenCount (gdk_x11_display_get_xdisplay (display)); ++n)
     {
       g_snprintf (buffer, 1024, "Screen%d_ActiveWorkspace", n);
       xfsm_verbose ("Attempting to restore %s\n", buffer);
@@ -676,7 +676,7 @@ xfsm_manager_load_failsafe (XfsmManager   *manager,
                   "/sessions/%s/Client%d_PerScreen", failsafe_name, i);
       if (xfconf_channel_get_bool (channel, screen_entry, FALSE))
         {
-          for (n_screen = 0; n_screen < gdk_display_get_n_screens (display); ++n_screen)
+          for (n_screen = 0; n_screen < XScreenCount (gdk_x11_display_get_xdisplay (display)); ++n_screen)
             {
               fclient = g_new0 (FailsafeClient, 1);
               if (n_screen == 0)
@@ -747,10 +747,10 @@ xfsm_manager_load_settings (XfsmManager   *manager,
            * window doesn't look ugly (right now no WM is running, so it
            * won't have window decorations). */
           xfce_message_dialog (NULL, _("Session Manager Error"),
-                               GTK_STOCK_DIALOG_ERROR,
+                               "dialog-error",
                                _("Unable to load a failsafe session"),
                                errorstr,
-                               GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT, NULL);
+                               _("_Quit"), GTK_RESPONSE_ACCEPT, NULL);
           g_free (errorstr);
           exit (EXIT_FAILURE);
         }
@@ -1165,12 +1165,12 @@ xfsm_manager_save_yourself_global (XfsmManager     *manager,
                                        &error))
             {
               xfce_message_dialog (NULL, _("Shutdown Failed"),
-                                   GTK_STOCK_DIALOG_ERROR,
+                                   "dialog-error",
                                    manager->shutdown_type == XFSM_SHUTDOWN_SUSPEND
                                    ? _("Failed to suspend session")
                                    : _("Failed to hibernate session"),
                                    error->message,
-                                   GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
+                                   _("_Close"), GTK_RESPONSE_ACCEPT,
                                    NULL);
               g_error_free (error);
             }
@@ -1735,7 +1735,7 @@ xfsm_manager_store_session (XfsmManager *manager)
 
   /* store current workspace numbers */
   display = gdk_display_get_default ();
-  for (n = 0; n < gdk_display_get_n_screens (display); ++n)
+  for (n = 0; n < XScreenCount (gdk_x11_display_get_xdisplay (display)); ++n)
     {
       screen = wnck_screen_get (n);
       wnck_screen_force_update (screen);
diff --git a/xfce4-session/xfsm-splash-screen.c b/xfce4-session/xfsm-splash-screen.c
index 9c2b796..fac1aaf 100644
--- a/xfce4-session/xfsm-splash-screen.c
+++ b/xfce4-session/xfsm-splash-screen.c
@@ -209,10 +209,10 @@ again:
 
           dialog = gtk_dialog_new_with_buttons (NULL,
                                                 NULL,
-                                                GTK_DIALOG_NO_SEPARATOR,
-                                                GTK_STOCK_CANCEL,
+                                                GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                _("_Cancel"),
                                                 GTK_RESPONSE_CANCEL,
-                                                GTK_STOCK_OK,
+                                                _("_OK"),
                                                 GTK_RESPONSE_OK,
                                                 NULL);
           gtk_dialog_set_default_response (GTK_DIALOG (dialog),

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


More information about the Xfce4-commits mailing list