[gtk+/gtk-2-22] Bug 611709 - Add gtk_statusbar_remove_all



commit 75e48d68bc326a75ef99307957f4be3c2c96df19
Author: Garrett Regier <alias301 gmail com>
Date:   Sat May 15 13:58:30 2010 -0700

    Bug 611709 - Add gtk_statusbar_remove_all

 gtk/gtk.symbols    |    1 +
 gtk/gtkstatusbar.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkstatusbar.h |    3 ++
 3 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index f6d1aae..24ad5da 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3885,6 +3885,7 @@ gtk_statusbar_new
 gtk_statusbar_pop
 gtk_statusbar_push
 gtk_statusbar_remove
+gtk_statusbar_remove_all
 gtk_statusbar_set_has_resize_grip
 #endif
 #endif
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index ff7bc0f..81d28d0 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -463,6 +463,72 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
 }
 
 /**
+ * gtk_statusbar_remove_all:
+ * @statusbar: a #GtkStatusBar
+ * @context_id: a context identifier
+ *
+ * Forces the removal of all messages from a statusbar's
+ * stack with the exact @context_id.
+ *
+ * Since: 2.22
+ */
+void
+gtk_statusbar_remove_all (GtkStatusbar *statusbar,
+                          guint         context_id)
+{
+  GtkStatusbarMsg *msg;
+  GSList *prev, *list;
+
+  g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
+
+  if (statusbar->messages == NULL)
+    return;
+
+  msg = statusbar->messages->data;
+
+  /* care about signal emission if the topmost item is removed */
+  if (msg->context_id == context_id)
+    {
+      gtk_statusbar_pop (statusbar, context_id);
+
+      prev = NULL;
+      list = statusbar->messages;
+    }
+  else
+    {
+      prev = statusbar->messages;
+      list = prev->next;
+    }
+
+  while (list != NULL)
+    {
+      msg = list->data;
+
+      if (msg->context_id == context_id)
+        {
+          if (prev == NULL)
+            statusbar->messages = list->next;
+          else
+            prev->next = list->next;
+
+          g_free (msg->text);
+          g_slice_free (GtkStatusbarMsg, msg);
+          g_slist_free_1 (list);
+
+          if (prev == NULL)
+            prev = statusbar->messages;
+
+          list = prev->next;
+        }
+      else
+        {
+          prev = list;
+          list = prev->next;
+        }
+    }
+}
+
+/**
  * gtk_statusbar_set_has_resize_grip:
  * @statusbar: a #GtkStatusBar
  * @setting: %TRUE to have a resize grip
diff --git a/gtk/gtkstatusbar.h b/gtk/gtkstatusbar.h
index ff05976..525b272 100644
--- a/gtk/gtkstatusbar.h
+++ b/gtk/gtkstatusbar.h
@@ -102,6 +102,9 @@ void       gtk_statusbar_pop          	(GtkStatusbar *statusbar,
 void       gtk_statusbar_remove        	(GtkStatusbar *statusbar,
 					 guint	       context_id,
 					 guint         message_id);
+void       gtk_statusbar_remove_all    	(GtkStatusbar *statusbar,
+					 guint	       context_id);
+					 
 
 void     gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
 					    gboolean      setting);



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