From 939a466f4a9386582b12743528644f1694dad255 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 10 Feb 2007 12:14:39 +0000 Subject: Fix the english of the comment; remove some type checking; use better 2007-02-10 Emmanuele Bassi * gtk/gtkrecentchoosermenu.c: Fix the english of the comment; remove some type checking; use better variable naming for the internal menu item markers. svn path=/trunk/; revision=17284 --- gtk/gtkrecentchoosermenu.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'gtk/gtkrecentchoosermenu.c') diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c index f11541a782..11731a1a90 100644 --- a/gtk/gtkrecentchoosermenu.c +++ b/gtk/gtkrecentchoosermenu.c @@ -321,15 +321,15 @@ gtk_recent_chooser_menu_constructor (GType type, g_assert (priv->manager); - /* we create a placeholder menuitem, to be used in the case - * were the menu is empty. this placeholder will stay around + /* we create a placeholder menuitem, to be used in case + * the menu is empty. this placeholder will stay around * for the entire lifetime of the menu, and we just hide it * when it's not used. we have to do this, and do it here, * because we need a marker for the beginning of the recent * items list, so that we can insert the new items at the - * right place when populating the menu, in case the user - * appended or prepended custom menuitems to the recent - * chooser menu widget. + * right place when idly populating the menu in case the + * user appended or prepended custom menu items to the + * recent chooser menu widget. */ priv->placeholder = gtk_menu_item_new_with_label (_("No items found")); gtk_widget_set_sensitive (priv->placeholder, FALSE); @@ -999,23 +999,27 @@ gtk_recent_chooser_menu_insert_item (GtkRecentChooserMenu *menu, { GtkRecentChooserMenuPrivate *priv = menu->priv; gint real_position; - GList *children, *l; if (priv->first_recent_item_pos == -1) { + GList *children, *l; + children = gtk_container_get_children (GTK_CONTAINER (menu)); + for (real_position = 0, l = children; l != NULL; real_position += 1, l = l->next) { - GtkWidget *child = l->data; - gint mark = 0; + GObject *child = l->data; + gboolean is_placeholder = FALSE; - mark = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), - "gtk-recent-menu-placeholder")); - if (mark == 1) + is_placeholder = + GPOINTER_TO_INT (g_object_get_data (child, "gtk-recent-menu-placeholder")); + + if (is_placeholder) break; } + g_list_free (children); priv->first_recent_item_pos = real_position; } @@ -1037,12 +1041,13 @@ gtk_recent_chooser_menu_dispose_items (GtkRecentChooserMenu *menu) for (l = children; l != NULL; l = l->next) { GtkWidget *menu_item = GTK_WIDGET (l->data); - gint mark = 0; + gboolean has_mark = FALSE; /* check for our mark, in order to remove just the items we own */ - mark = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), - "gtk-recent-menu-mark")); - if (mark == 1) + has_mark = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "gtk-recent-menu-mark")); + + if (has_mark) { GtkRecentInfo *info; @@ -1145,8 +1150,9 @@ idle_populate_func (gpointer data) pdata->displayed_items += 1; /* mark the menu item as one of our own */ - g_object_set_data (G_OBJECT (item), "gtk-recent-menu-mark", - GINT_TO_POINTER (1)); + g_object_set_data (G_OBJECT (item), + "gtk-recent-menu-mark", + GINT_TO_POINTER (TRUE)); /* attach the RecentInfo object to the menu item, and own a reference * to it, so that it will be destroyed with the menu item when it's -- cgit v1.2.1