[rhythmbox] iradio: implement impl_reset_filters



commit 97e9d9643eaf5896f1554ee14a708bfbb6fbd998
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Sep 9 09:28:57 2012 +1000

    iradio: implement impl_reset_filters

 plugins/iradio/rb-iradio-source.c |   24 ++++++++++++++++++++----
 widgets/rb-property-view.c        |    5 +++++
 2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/plugins/iradio/rb-iradio-source.c b/plugins/iradio/rb-iradio-source.c
index e1d1c61..dd052cb 100644
--- a/plugins/iradio/rb-iradio-source.c
+++ b/plugins/iradio/rb-iradio-source.c
@@ -107,6 +107,7 @@ static void impl_add_uri (RBSource *source,
 			  GDestroyNotify destroy_data);
 
 static void rb_iradio_source_do_query (RBIRadioSource *source);
+static void impl_reset_filters (RBSource *source);
 
 void rb_iradio_source_show_columns_changed_cb (GtkToggleButton *button,
 					     RBIRadioSource *source);
@@ -135,6 +136,7 @@ struct RBIRadioSourcePrivate
 
 	GtkActionGroup *action_group;
 
+	RBSourceToolbar *toolbar;
 	RBPropertyView *genres;
 	RBEntryView *stations;
 	gboolean setting_new_query;
@@ -211,6 +213,7 @@ rb_iradio_source_class_init (RBIRadioSourceClass *klass)
 	source_class->impl_song_properties = impl_song_properties;
 	source_class->impl_want_uri = impl_want_uri;
 	source_class->impl_add_uri = impl_add_uri;
+	source_class->impl_reset_filters = impl_reset_filters;
 
 	g_object_class_override_property (object_class,
 					  PROP_SHOW_BROWSER,
@@ -282,7 +285,6 @@ rb_iradio_source_constructed (GObject *object)
 	GtkUIManager *ui_manager;
 	GtkWidget *grid;
 	GtkWidget *paned;
-	RBSourceToolbar *toolbar;
 	gint size;
 	GdkPixbuf *pixbuf;
 
@@ -395,14 +397,14 @@ rb_iradio_source_constructed (GObject *object)
 	gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (source->priv->stations), TRUE, FALSE);
 
 	/* set up toolbar */
-	toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager);
-	rb_source_toolbar_add_search_entry (toolbar, NULL, _("Search your internet radio stations"));
+	source->priv->toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager);
+	rb_source_toolbar_add_search_entry (source->priv->toolbar, NULL, _("Search your internet radio stations"));
 
 	grid = gtk_grid_new ();
 	gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
 	gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
 	gtk_widget_set_margin_top (GTK_WIDGET (grid), 6);
-	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (toolbar), 0, 0, 1, 1);
+	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (source->priv->toolbar), 0, 0, 1, 1);
 	gtk_grid_attach (GTK_GRID (grid), paned, 0, 1, 1, 1);
 
 	gtk_container_add (GTK_CONTAINER (source), grid);
@@ -854,6 +856,20 @@ rb_iradio_source_do_query (RBIRadioSource *source)
 }
 
 static void
+impl_reset_filters (RBSource *asource)
+{
+	RBIRadioSource *source = RB_IRADIO_SOURCE (asource);
+
+	if (source->priv->search_query != NULL) {
+		rhythmdb_query_free (source->priv->search_query);
+		source->priv->search_query = NULL;
+	}
+	rb_source_toolbar_clear_search_entry (source->priv->toolbar);
+
+	rb_property_view_set_selection (source->priv->genres, NULL);
+}
+
+static void
 handle_playlist_entry_cb (TotemPlParser *playlist,
 			  const char *uri,
 			  GHashTable *metadata,
diff --git a/widgets/rb-property-view.c b/widgets/rb-property-view.c
index b8d59b5..a4d6fb4 100644
--- a/widgets/rb-property-view.c
+++ b/widgets/rb-property-view.c
@@ -880,6 +880,11 @@ rb_property_view_selection_changed_cb (GtkTreeSelection *selection,
 					    RHYTHMDB_PROPERTY_MODEL_COLUMN_PRIORITY, &is_all, -1);
 			g_signal_emit (G_OBJECT (view), rb_property_view_signals[PROPERTY_SELECTED], 0,
 				       is_all ? NULL : selected_prop);
+		} else {
+			if (gtk_tree_model_get_iter_first (model, &iter))
+				gtk_tree_selection_select_iter (selection, &iter);
+			g_signal_emit (G_OBJECT (view), rb_property_view_signals[PROPERTY_SELECTED], 0,
+				       NULL);
 		}
 	}
 



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