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



commit 276aeeef4a13f12152469593591c8b9c667f9c7f
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    | 21 +++++++++++++--------
 libwnck/test-selector.c |  8 ++++++--
 libwnck/test-shutdown.c |  6 ++++--
 libwnck/test-tasklist.c | 11 ++++++++---
 libwnck/test-wnck.c     | 13 ++++++++-----
 5 files changed, 39 insertions(+), 20 deletions(-)
---
diff --git a/libwnck/test-pager.c b/libwnck/test-pager.c
index 316b13a..109ad04 100644
--- a/libwnck/test-pager.c
+++ b/libwnck/test-pager.c
@@ -21,11 +21,12 @@ static GOptionEntry entries[] = {
 };
 
 static void
-create_pager_window (GtkOrientation       orientation,
-                     gboolean             show_all,
-                     WnckPagerDisplayMode mode,
-                     int                  rows,
-                     gboolean             wrap)
+create_pager_window (WnckHandle           *handle,
+                     GtkOrientation        orientation,
+                     gboolean              show_all,
+                     WnckPagerDisplayMode  mode,
+                     int                   rows,
+                     gboolean              wrap)
 {
   GtkWidget *win;
   GtkWidget *pager;
@@ -47,7 +48,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);
@@ -67,6 +68,7 @@ main (int argc, char **argv)
   GOptionContext *ctxt;
   GtkOrientation  orientation;
   WnckPagerDisplayMode mode;
+  WnckHandle *handle;
   WnckScreen *screen;
 
   ctxt = g_option_context_new ("");
@@ -81,7 +83,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);
@@ -96,9 +99,11 @@ main (int argc, char **argv)
   else
          mode = WNCK_PAGER_DISPLAY_CONTENT;
 
-  create_pager_window (orientation, !only_current, mode, n_rows, wrap_on_scroll);
+  create_pager_window (handle, orientation, !only_current, 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 fb27ea3..dcc09cb 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 0f09d42..0f1d286 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 6b27f5a..a0562b0 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 ffaad59..77085cd 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]