[glib] GMenu: add g_menu_remove_all() API
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GMenu: add g_menu_remove_all() API
- Date: Fri, 19 Apr 2013 18:52:59 +0000 (UTC)
commit 1de0625103e98710689d65cecfc288e15a5d240d
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Apr 8 15:27:16 2013 -0400
GMenu: add g_menu_remove_all() API
Removes all of the items from a GMenu. The keyboard indicator wants to
do this as part of refreshing the layout list, as an example.
https://bugzilla.gnome.org/show_bug.cgi?id=697601
docs/reference/gio/gio-sections.txt | 1 +
gio/gmenu.c | 23 +++++++++++++++++++++++
gio/gmenu.h | 3 +++
3 files changed, 27 insertions(+)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index ca8cbf2..683b66b 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -3773,6 +3773,7 @@ g_menu_prepend_submenu
<SUBSECTION>
g_menu_remove
+g_menu_remove_all
<SUBSECTION>
GMenuItem
diff --git a/gio/gmenu.c b/gio/gmenu.c
index 1fa132f1..940ba66 100644
--- a/gio/gmenu.c
+++ b/gio/gmenu.c
@@ -486,6 +486,29 @@ g_menu_remove (GMenu *menu,
g_menu_model_items_changed (G_MENU_MODEL (menu), position, 1, 0);
}
+/**
+ * g_menu_remove_all:
+ * @menu: a #GMenu
+ *
+ * Removes all items in the menu.
+ *
+ * Since: 2.38
+ **/
+void
+g_menu_remove_all (GMenu *menu)
+{
+ gint i, n;
+
+ g_return_if_fail (G_IS_MENU (menu));
+ n = menu->items->len;
+
+ for (i = 0; i < n; i++)
+ g_menu_clear_item (&g_array_index (menu->items, struct item, i));
+ g_array_set_size (menu->items, 0);
+
+ g_menu_model_items_changed (G_MENU_MODEL (menu), 0, n, 0);
+}
+
static void
g_menu_finalize (GObject *object)
{
diff --git a/gio/gmenu.h b/gio/gmenu.h
index 729915d..e68cf83 100644
--- a/gio/gmenu.h
+++ b/gio/gmenu.h
@@ -63,6 +63,9 @@ GLIB_AVAILABLE_IN_2_32
void g_menu_remove (GMenu *menu,
gint position);
+GLIB_AVAILABLE_IN_2_38
+void g_menu_remove_all (GMenu *menu);
+
GLIB_AVAILABLE_IN_2_32
void g_menu_insert (GMenu *menu,
gint position,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]