diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkrecentchooser.c | 3 | ||||
-rw-r--r-- | gtk/gtkrecentchoosermenu.c | 39 |
2 files changed, 30 insertions, 12 deletions
diff --git a/gtk/gtkrecentchooser.c b/gtk/gtkrecentchooser.c index fe2c39dc19..06b5fdd764 100644 --- a/gtk/gtkrecentchooser.c +++ b/gtk/gtkrecentchooser.c @@ -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); } diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c index 1e066744b3..6f1b636993 100644 --- a/gtk/gtkrecentchoosermenu.c +++ b/gtk/gtkrecentchoosermenu.c @@ -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; + + if (menu->priv->current_filter) + retval = g_slist_prepend (retval, menu->priv->current_filter); - return NULL; + 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"); } |