[libwnck/wip/muktupavels/wnck-handle: 28/29] port tests to WnckHandle




commit af4032905c2af59d444a9b600ea5b247d045fc10
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Aug 19 22:11:17 2019 +0300

    port tests to WnckHandle

 libwnck/test-pager.c    | 23 ++++++++++++++---------
 libwnck/test-selector.c |  8 ++++++--
 libwnck/test-shutdown.c |  6 ++++--
 libwnck/test-tasklist.c | 11 ++++++++---
 libwnck/test-wnck.c     | 13 ++++++++-----
 5 files changed, 40 insertions(+), 21 deletions(-)
---
diff --git a/libwnck/test-pager.c b/libwnck/test-pager.c
index d60b0476..9c15173d 100644
--- a/libwnck/test-pager.c
+++ b/libwnck/test-pager.c
@@ -23,12 +23,13 @@ static GOptionEntry entries[] = {
 };
 
 static void
-create_pager_window (GtkOrientation       orientation,
-                     gboolean             show_all,
-                     WnckPagerDisplayMode mode,
-                     WnckPagerScrollMode  scroll_mode,
-                     int                  rows,
-                     gboolean             wrap)
+create_pager_window (WnckHandle           *handle,
+                     GtkOrientation        orientation,
+                     gboolean              show_all,
+                     WnckPagerDisplayMode  mode,
+                     WnckPagerScrollMode   scroll_mode,
+                     int                   rows,
+                     gboolean              wrap)
 {
   GtkWidget *win;
   GtkWidget *pager;
@@ -50,7 +51,7 @@ create_pager_window (GtkOrientation       orientation,
                     G_CALLBACK (gtk_main_quit),
                     NULL);
 
-  pager = wnck_pager_new ();
+  pager = wnck_pager_new_with_handle (handle);
 
   wnck_pager_set_show_all (WNCK_PAGER (pager), show_all);
   wnck_pager_set_display_mode (WNCK_PAGER (pager), mode);
@@ -72,6 +73,7 @@ main (int argc, char **argv)
   GtkOrientation  orientation;
   WnckPagerDisplayMode mode;
   WnckPagerScrollMode scroll_mode;
+  WnckHandle *handle;
   WnckScreen *screen;
 
   ctxt = g_option_context_new ("");
@@ -86,7 +88,8 @@ main (int argc, char **argv)
   if (rtl)
     gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
 
-  screen = wnck_screen_get_default ();
+  handle = wnck_handle_new (WNCK_CLIENT_TYPE_APPLICATION);
+  screen = wnck_handle_get_default_screen (handle);
 
   /* because the pager doesn't respond to signals at the moment */
   wnck_screen_force_update (screen);
@@ -106,9 +109,11 @@ main (int argc, char **argv)
   else
          scroll_mode = WNCK_PAGER_SCROLL_2D;
 
-  create_pager_window (orientation, !only_current, mode, scroll_mode, n_rows, wrap_on_scroll);
+  create_pager_window (handle, orientation, !only_current, mode, scroll_mode, n_rows, wrap_on_scroll);
 
   gtk_main ();
 
+  g_object_unref (handle);
+
   return 0;
 }
diff --git a/libwnck/test-selector.c b/libwnck/test-selector.c
index fb27ea38..dcc09cbf 100644
--- a/libwnck/test-selector.c
+++ b/libwnck/test-selector.c
@@ -16,6 +16,7 @@ int
 main (int argc, char **argv)
 {
   GOptionContext *ctxt;
+  WnckHandle *handle;
   WnckScreen *screen;
   GtkWidget *win;
   GtkWidget *frame;
@@ -30,7 +31,8 @@ main (int argc, char **argv)
 
   gtk_init (&argc, &argv);
 
-  screen = wnck_screen_get_default ();
+  handle = wnck_handle_new (WNCK_CLIENT_TYPE_APPLICATION);
+  screen = wnck_handle_get_default_screen (handle);
 
   /* because the pager doesn't respond to signals at the moment */
   wnck_screen_force_update (screen);
@@ -48,7 +50,7 @@ main (int argc, char **argv)
                     G_CALLBACK (gtk_main_quit),
                     NULL);
 
-  selector = wnck_selector_new ();
+  selector = wnck_selector_new_with_handle (handle);
 
   frame = gtk_frame_new (NULL);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
@@ -71,5 +73,7 @@ main (int argc, char **argv)
 
   gtk_main ();
 
+  g_object_unref (handle);
+
   return 0;
 }
diff --git a/libwnck/test-shutdown.c b/libwnck/test-shutdown.c
index 0f09d428..0f1d286d 100644
--- a/libwnck/test-shutdown.c
+++ b/libwnck/test-shutdown.c
@@ -31,6 +31,7 @@ main (int    argc,
       char **argv)
 {
   GMainLoop *loop;
+  WnckHandle *handle;
   WnckScreen *screen;
 
   gdk_init (&argc, &argv);
@@ -39,7 +40,8 @@ main (int    argc,
 
   while (TRUE)
     {
-      screen = wnck_screen_get_default ();
+      handle = wnck_handle_new (WNCK_CLIENT_TYPE_APPLICATION);
+      screen = wnck_handle_get_default_screen (handle);
 
       g_print ("libwnck is active for 5 seconds; change the active window to get notifications\n");
       g_signal_connect (screen, "active-window-changed",
@@ -48,7 +50,7 @@ main (int    argc,
       g_main_loop_run (loop);
 
       g_print ("libwnck is shutting down for 5 seconds; no notification will happen anymore\n");
-      wnck_shutdown ();
+      g_clear_object (&handle);
       g_timeout_add_seconds (5, quit_loop, loop);
       g_main_loop_run (loop);
 
diff --git a/libwnck/test-tasklist.c b/libwnck/test-tasklist.c
index 6b27f5a9..a0562b0e 100644
--- a/libwnck/test-tasklist.c
+++ b/libwnck/test-tasklist.c
@@ -55,6 +55,7 @@ int
 main (int argc, char **argv)
 {
   GOptionContext *ctxt;
+  WnckHandle *handle;
   WnckScreen *screen;
   GtkWidget *win;
   GtkWidget *frame;
@@ -72,8 +73,10 @@ main (int argc, char **argv)
   if (rtl)
     gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
 
-  wnck_set_default_mini_icon_size (icon_size);
-  screen = wnck_screen_get_default ();
+
+  handle = wnck_handle_new (WNCK_CLIENT_TYPE_APPLICATION);
+  wnck_handle_set_default_mini_icon_size (handle, icon_size);
+  screen = wnck_handle_get_default_screen (handle);
 
   /* because the pager doesn't respond to signals at the moment */
   wnck_screen_force_update (screen);
@@ -91,7 +94,7 @@ main (int argc, char **argv)
                     G_CALLBACK (gtk_main_quit),
                     NULL);
 
-  tasklist = wnck_tasklist_new ();
+  tasklist = wnck_tasklist_new_with_handle (handle);
 
   wnck_tasklist_set_include_all_workspaces (WNCK_TASKLIST (tasklist), display_all);
   if (always_group)
@@ -161,5 +164,7 @@ main (int argc, char **argv)
 
   gtk_main ();
 
+  g_object_unref (handle);
+
   return 0;
 }
diff --git a/libwnck/test-wnck.c b/libwnck/test-wnck.c
index ffaad596..77085cd0 100644
--- a/libwnck/test-wnck.c
+++ b/libwnck/test-wnck.c
@@ -3,6 +3,7 @@
 #include <libwnck/libwnck.h>
 #include <gtk/gtk.h>
 
+static WnckHandle *handle;
 static GtkWidget *global_tree_view;
 static GtkTreeModel *global_tree_model;
 static guint refill_idle;
@@ -80,11 +81,11 @@ main (int argc, char **argv)
   g_option_context_parse (ctxt, &argc, &argv, NULL);
   g_option_context_free (ctxt);
 
-  wnck_set_default_mini_icon_size (icon_size);
-
   gtk_init (&argc, &argv);
 
-  screen = wnck_screen_get (0);
+  handle = wnck_handle_new (WNCK_CLIENT_TYPE_APPLICATION);
+  wnck_handle_set_default_mini_icon_size (handle, icon_size);
+  screen = wnck_handle_get_screen (handle, 0);
 
   g_signal_connect (G_OBJECT (screen), "active_window_changed",
                     G_CALLBACK (active_window_changed_callback),
@@ -145,7 +146,9 @@ main (int argc, char **argv)
   gtk_widget_show_all (win);
   
   gtk_main ();
-  
+
+  g_object_unref (handle);
+
   return 0;
 }
 
@@ -914,7 +917,7 @@ do_refill_model (gpointer data)
   refill_idle = 0;
 
   refill_tree_model (global_tree_model,
-                     wnck_screen_get (0));
+                     wnck_handle_get_screen (handle, 0));
 
   return FALSE;
 }


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