[notification-daemon] Don't show bubbles while dock is visible



commit 575304a84f72b2df5fbc818723cf6078ddb6f1ca
Author: William Jon McCann <jmccann redhat com>
Date:   Thu Oct 7 15:42:48 2010 -0400

    Don't show bubbles while dock is visible

 src/nd-queue.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/nd-stack.c |   12 +++++++++-
 src/nd-stack.h |    1 +
 3 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/src/nd-queue.c b/src/nd-queue.c
index d578024..6787061 100644
--- a/src/nd-queue.c
+++ b/src/nd-queue.c
@@ -267,6 +267,8 @@ popdown_dock (NdQueue *queue)
 
         /* hide again */
         gtk_widget_hide (queue->priv->dock);
+
+        queue_update (queue);
 }
 
 /* This is called when the grab is broken for
@@ -322,11 +324,30 @@ on_dock_key_release (GtkWidget   *widget,
 }
 
 static void
+clear_stacks (NdQueue *queue)
+{
+        int i;
+        int j;
+
+        for (i = 0; i < queue->priv->n_screens; i++) {
+                NotifyScreen *nscreen;
+                nscreen = queue->priv->screens[i];
+                for (j = 0; j < nscreen->n_stacks; j++) {
+                       NdStack *stack;
+                       stack = nscreen->stacks[j];
+                       nd_stack_remove_all (stack);
+                }
+        }
+}
+
+static void
 _nd_queue_remove_all (NdQueue *queue)
 {
         GHashTableIter iter;
         gpointer       key, value;
 
+        clear_stacks (queue);
+
         g_queue_clear (queue->priv->queue);
         g_hash_table_iter_init (&iter, queue->priv->notifications);
         while (g_hash_table_iter_next (&iter, &key, &value)) {
@@ -416,6 +437,39 @@ nd_queue_init (NdQueue *queue)
 }
 
 static void
+destroy_screens (NdQueue *queue)
+{
+        GdkDisplay  *display;
+        int          i;
+        int          j;
+
+        display = gdk_display_get_default ();
+
+        for (i = 0; i < queue->priv->n_screens; i++) {
+                GdkScreen *screen;
+                GdkWindow *gdkwindow;
+
+                screen = gdk_display_get_screen (display, i);
+                g_signal_handlers_disconnect_by_func (screen,
+                                                      G_CALLBACK (on_screen_monitors_changed),
+                                                      queue);
+
+                gdkwindow = gdk_screen_get_root_window (screen);
+                gdk_window_remove_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, queue->priv->screens[i]);
+                for (j = 0; i < queue->priv->screens[i]->n_stacks; j++) {
+                        g_object_unref (queue->priv->screens[i]->stacks[j]);
+                        queue->priv->screens[i]->stacks[j] = NULL;
+                }
+
+                g_free (queue->priv->screens[i]->stacks);
+        }
+
+        g_free (queue->priv->screens);
+        queue->priv->screens = NULL;
+}
+
+
+static void
 nd_queue_finalize (GObject *object)
 {
         NdQueue *queue;
@@ -430,6 +484,8 @@ nd_queue_finalize (GObject *object)
         g_hash_table_destroy (queue->priv->notifications);
         g_queue_free (queue->priv->queue);
 
+        destroy_screens (queue);
+
         G_OBJECT_CLASS (nd_queue_parent_class)->finalize (object);
 }
 
@@ -498,6 +554,12 @@ maybe_show_notification (NdQueue *queue)
 
         /* FIXME: show one at a time if not busy or away */
 
+        /* don't show bubbles when dock is showing */
+        if (gtk_widget_get_visible (queue->priv->dock)) {
+                g_debug ("Dock is showing");
+                return;
+        }
+
         stack = get_stack_with_pointer (queue);
         list = nd_stack_get_bubbles (stack);
         if (g_list_length (list) > 0) {
@@ -1011,6 +1073,11 @@ static void
 on_status_icon_activate (GtkStatusIcon *status_icon,
                          NdQueue       *queue)
 {
+        /* clear the bubble queue since the user will be looking at a
+           full list now */
+        clear_stacks (queue);
+        g_queue_clear (queue->priv->queue);
+
         popup_dock (queue, GDK_CURRENT_TIME);
 }
 
diff --git a/src/nd-stack.c b/src/nd-stack.c
index 27fca03..a72c09a 100644
--- a/src/nd-stack.c
+++ b/src/nd-stack.c
@@ -404,7 +404,7 @@ nd_stack_add_bubble (NdStack  *stack,
                                       req.height + NOTIFY_STACK_SPACING,
                                       &x,
                                       &y);
-        gtk_widget_show (bubble);
+        gtk_widget_show (GTK_WIDGET (bubble));
         gtk_window_move (GTK_WINDOW (bubble), x, y);
 
         if (new_notification) {
@@ -436,3 +436,13 @@ nd_stack_remove_bubble (NdStack  *stack,
         if (gtk_widget_get_realized (GTK_WIDGET (bubble)))
                 gtk_widget_unrealize (GTK_WIDGET (bubble));
 }
+
+void
+nd_stack_remove_all (NdStack  *stack)
+{
+        GList *bubbles;
+
+        bubbles = g_list_copy (stack->priv->bubbles);
+        g_list_foreach (bubbles, (GFunc)gtk_widget_destroy, NULL);
+        g_list_free (bubbles);
+}
diff --git a/src/nd-stack.h b/src/nd-stack.h
index 4f1dedf..6877025 100644
--- a/src/nd-stack.h
+++ b/src/nd-stack.h
@@ -69,6 +69,7 @@ void            nd_stack_add_bubble            (NdStack        *stack,
                                                 gboolean        new_notification);
 void            nd_stack_remove_bubble         (NdStack        *stack,
                                                 NdBubble       *bubble);
+void            nd_stack_remove_all            (NdStack        *stack);
 GList *         nd_stack_get_bubbles           (NdStack        *stack);
 void            nd_stack_queue_update_position (NdStack        *stack);
 



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