[mutter] Add ::window-added and ::window-removed signals to MetaWorkspace



commit 6e9803cd9f56fd755caba69a62af33b13f6c74bd
Author: Dan Winship <dwinship redhat com>
Date:   Mon Feb 2 15:27:43 2009 -0500

    Add ::window-added and ::window-removed signals to MetaWorkspace
    
    Add sigals to MetaWorkspace to allow tracking when windows are added
    and removed. Note that on window creation that these signals are fired
    before the window setup is totally complete, so they need to be used
    with some care. (For example, the compositor, if present, has not
    been notified of the new window.)
    
    http://bugzilla.gnome.org/show_bug.cgi?id=580025
---
 src/core/workspace.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/src/core/workspace.c b/src/core/workspace.c
index f563a3b..00ae8e2 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -53,6 +53,16 @@ static void workspace_free_struts        (MetaWorkspace *workspace);
 
 G_DEFINE_TYPE (MetaWorkspace, meta_workspace, G_TYPE_OBJECT);
 
+enum
+{
+  WINDOW_ADDED,
+  WINDOW_REMOVED,
+
+  LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
 static void
 meta_workspace_finalize (GObject *object)
 {
@@ -102,11 +112,27 @@ meta_workspace_class_init (MetaWorkspaceClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GParamSpec   *pspec;
 
-
   object_class->finalize     = meta_workspace_finalize;
   object_class->get_property = meta_workspace_get_property;
   object_class->set_property = meta_workspace_set_property;
 
+  signals[WINDOW_ADDED] = g_signal_new ("window-added",
+                                        G_TYPE_FROM_CLASS (klass),
+                                        G_SIGNAL_RUN_LAST,
+                                        0,
+                                        NULL, NULL,
+                                        g_cclosure_marshal_VOID__OBJECT,
+                                        G_TYPE_NONE, 1,
+                                        META_TYPE_WINDOW);
+  signals[WINDOW_REMOVED] = g_signal_new ("window-removed",
+                                          G_TYPE_FROM_CLASS (klass),
+                                          G_SIGNAL_RUN_LAST,
+                                          0,
+                                          NULL, NULL,
+                                          g_cclosure_marshal_VOID__OBJECT,
+                                          G_TYPE_NONE, 1,
+                                          META_TYPE_WINDOW);
+
   pspec = g_param_spec_uint ("n-windows",
                              "N Windows",
                              "Number of windows",
@@ -302,6 +328,7 @@ meta_workspace_add_window (MetaWorkspace *workspace,
    */
   meta_window_queue (window, META_QUEUE_CALC_SHOWING|META_QUEUE_MOVE_RESIZE);
 
+  g_signal_emit (workspace, signals[WINDOW_ADDED], 0, window);
   g_object_notify (G_OBJECT (workspace), "n-windows");
 }
 
@@ -350,6 +377,7 @@ meta_workspace_remove_window (MetaWorkspace *workspace,
    */
   meta_window_queue (window, META_QUEUE_CALC_SHOWING|META_QUEUE_MOVE_RESIZE);
 
+  g_signal_emit (workspace, signals[WINDOW_REMOVED], 0, window);
   g_object_notify (G_OBJECT (workspace), "n-windows");
 }
 



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