Add a check on the filter argument, instead of blindly passing it to

2006-08-14  Emmanuele Bassi  <ebassi@gnome.org>

	* gtk/gtkrecentchooser.c:
	(gtk_recent_chooser_add_filter),
	(gtk_recent_chooser_remove_filter),
	(gtk_recent_chooser_set_filter): Add a check on the
	filter argument, instead of blindly passing it to
	underlying implementation.

	* gtk/gtkrecentchoosermenu.c:
	(gtk_recent_chooser_menu_add_filter),
	(gtk_recent_chooser_menu_remove_filter),
	(gtk_recent_chooser_menu_list_filters): Implement
	these GtkRecentChooser methods, by setting and
	returning the only GtkRecentFilter object supported
	by a GtkRecentChooserMenu. (#347856, reported by Rod
	Butcher)
This commit is contained in:
Emmanuele Bassi 2006-08-14 20:58:21 +00:00 committed by Emmanuele Bassi
parent f060a9866f
commit e4f6c9d4d0
4 changed files with 66 additions and 12 deletions

View File

@ -1,3 +1,21 @@
2006-08-14 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentchooser.c:
(gtk_recent_chooser_add_filter),
(gtk_recent_chooser_remove_filter),
(gtk_recent_chooser_set_filter): Add a check on the
filter argument, instead of blindly passing it to
underlying implementation.
* gtk/gtkrecentchoosermenu.c:
(gtk_recent_chooser_menu_add_filter),
(gtk_recent_chooser_menu_remove_filter),
(gtk_recent_chooser_menu_list_filters): Implement
these GtkRecentChooser methods, by setting and
returning the only GtkRecentFilter object supported
by a GtkRecentChooserMenu. (#347856, reported by Rod
Butcher)
2006-08-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_remove): Null the

View File

@ -1,3 +1,21 @@
2006-08-14 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentchooser.c:
(gtk_recent_chooser_add_filter),
(gtk_recent_chooser_remove_filter),
(gtk_recent_chooser_set_filter): Add a check on the
filter argument, instead of blindly passing it to
underlying implementation.
* gtk/gtkrecentchoosermenu.c:
(gtk_recent_chooser_menu_add_filter),
(gtk_recent_chooser_menu_remove_filter),
(gtk_recent_chooser_menu_list_filters): Implement
these GtkRecentChooser methods, by setting and
returning the only GtkRecentFilter object supported
by a GtkRecentChooserMenu. (#347856, reported by Rod
Butcher)
2006-08-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkcombobox.c (gtk_combo_box_remove): Null the

View File

@ -884,6 +884,7 @@ gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
}
@ -902,6 +903,7 @@ gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
}
@ -940,6 +942,7 @@ gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
}

View File

@ -671,28 +671,40 @@ static void
gtk_recent_chooser_menu_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_warning (_("This function is not implemented for "
"widgets of class '%s'"),
g_type_name (G_OBJECT_TYPE (chooser)));
GtkRecentChooserMenu *menu;
menu = GTK_RECENT_CHOOSER_MENU (chooser);
gtk_recent_chooser_menu_set_current_filter (menu, filter);
}
static void
gtk_recent_chooser_menu_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_warning (_("This function is not implemented for "
"widgets of class '%s'"),
g_type_name (G_OBJECT_TYPE (chooser)));
GtkRecentChooserMenu *menu;
menu = GTK_RECENT_CHOOSER_MENU (chooser);
if (filter == menu->priv->current_filter)
{
g_object_unref (menu->priv->current_filter);
menu->priv->current_filter = NULL;
g_object_notify (G_OBJECT (menu), "filter");
}
}
static GSList *
gtk_recent_chooser_menu_list_filters (GtkRecentChooser *chooser)
{
g_warning (_("This function is not implemented for "
"widgets of class '%s'"),
g_type_name (G_OBJECT_TYPE (chooser)));
GtkRecentChooserMenu *menu;
GSList *retval = NULL;
return NULL;
if (menu->priv->current_filter)
retval = g_slist_prepend (retval, menu->priv->current_filter);
return retval;
}
static void
@ -706,8 +718,11 @@ gtk_recent_chooser_menu_set_current_filter (GtkRecentChooserMenu *menu,
if (priv->current_filter)
g_object_unref (G_OBJECT (priv->current_filter));
priv->current_filter = filter;
g_object_ref_sink (priv->current_filter);
if (filter)
{
priv->current_filter = filter;
g_object_ref_sink (priv->current_filter);
}
g_object_notify (G_OBJECT (menu), "filter");
}