hythmbox-2.98/plugins/iradio/rb-station-properties-dialog.c

No issues found

  1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2  *
  3  *  Copyright (C) 2002 Colin Walters <walters@gnu.org>
  4  *
  5  *  This program is free software; you can redistribute it and/or modify
  6  *  it under the terms of the GNU General Public License as published by
  7  *  the Free Software Foundation; either version 2 of the License, or
  8  *  (at your option) any later version.
  9  *
 10  *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 11  *  GStreamer plugins to be used and distributed together with GStreamer
 12  *  and Rhythmbox. This permission is above and beyond the permissions granted
 13  *  by the GPL license by which Rhythmbox is covered. If you modify this code
 14  *  you may extend this exception to your version of the code, but you are not
 15  *  obligated to do so. If you do not wish to do so, delete this exception
 16  *  statement from your version.
 17  *
 18  *  This program is distributed in the hope that it will be useful,
 19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 21  *  GNU General Public License for more details.
 22  *
 23  *  You should have received a copy of the GNU General Public License
 24  *  along with this program; if not, write to the Free Software
 25  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 26  *
 27  */
 28 
 29 #include "config.h"
 30 
 31 #include <string.h>
 32 #include <time.h>
 33 
 34 #include <glib/gi18n.h>
 35 #include <gtk/gtk.h>
 36 
 37 #include "rb-station-properties-dialog.h"
 38 #include "rb-file-helpers.h"
 39 #include "rb-builder-helpers.h"
 40 #include "rb-dialog.h"
 41 #include "rb-rating.h"
 42 #include "rb-util.h"
 43 
 44 static void rb_station_properties_dialog_class_init (RBStationPropertiesDialogClass *klass);
 45 static void rb_station_properties_dialog_init (RBStationPropertiesDialog *dialog);
 46 static void rb_station_properties_dialog_constructed (GObject *object);
 47 static void rb_station_properties_dialog_dispose (GObject *object);
 48 static void rb_station_properties_dialog_finalize (GObject *object);
 49 static void rb_station_properties_dialog_set_property (GObject *object,
 50 						       guint prop_id,
 51 						       const GValue *value,
 52 						       GParamSpec *pspec);
 53 static void rb_station_properties_dialog_get_property (GObject *object,
 54 						       guint prop_id,
 55 						       GValue *value,
 56 						       GParamSpec *pspec);
 57 static gboolean rb_station_properties_dialog_get_current_entry (RBStationPropertiesDialog *dialog);
 58 static void rb_station_properties_dialog_update_title (RBStationPropertiesDialog *dialog);
 59 static void rb_station_properties_dialog_update_location (RBStationPropertiesDialog *dialog);
 60 static void rb_station_properties_dialog_response_cb (GtkDialog *gtkdialog,
 61 						      int response_id,
 62 						      RBStationPropertiesDialog *dialog);
 63 
 64 static void rb_station_properties_dialog_update (RBStationPropertiesDialog *dialog);
 65 static void rb_station_properties_dialog_update_title_entry (RBStationPropertiesDialog *dialog);
 66 static void rb_station_properties_dialog_update_genre (RBStationPropertiesDialog *dialog);
 67 static void rb_station_properties_dialog_update_play_count (RBStationPropertiesDialog *dialog);
 68 static void rb_station_properties_dialog_update_bitrate (RBStationPropertiesDialog *dialog);
 69 static void rb_station_properties_dialog_update_last_played (RBStationPropertiesDialog *dialog);
 70 static void rb_station_properties_dialog_update_rating (RBStationPropertiesDialog *dialog);
 71 static void rb_station_properties_dialog_update_playback_error (RBStationPropertiesDialog *dialog);
 72 static void rb_station_properties_dialog_rated_cb (RBRating *rating,
 73 						   double score,
 74 						   RBStationPropertiesDialog *dialog);
 75 static void rb_station_properties_dialog_sync_entries (RBStationPropertiesDialog *dialog);
 76 static void rb_station_properties_dialog_show (GtkWidget *widget);
 77 static void rb_station_properties_dialog_location_changed_cb (GtkEntry *entry,
 78 							      RBStationPropertiesDialog *dialog);
 79 
 80 struct RBStationPropertiesDialogPrivate
 81 {
 82 	GObject     *plugin;
 83 	RBEntryView *entry_view;
 84 	RhythmDB    *db;
 85 	RhythmDBEntry *current_entry;
 86 
 87 	GtkWidget   *title;
 88 	GtkWidget   *genre;
 89 	GtkWidget   *location;
 90 	GtkWidget   *lastplayed;
 91 	GtkWidget   *playcount;
 92 	GtkWidget   *bitrate;
 93 	GtkWidget   *rating;
 94 	GtkWidget   *playback_error;
 95 	GtkWidget   *playback_error_box;
 96 	GtkWidget   *close_button;
 97 
 98 };
 99 
100 #define RB_STATION_PROPERTIES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_STATION_PROPERTIES_DIALOG, RBStationPropertiesDialogPrivate))
101 
102 enum
103 {
104 	PROP_0,
105 	PROP_ENTRY_VIEW,
106 	PROP_PLUGIN
107 };
108 
109 G_DEFINE_DYNAMIC_TYPE (RBStationPropertiesDialog, rb_station_properties_dialog, GTK_TYPE_DIALOG)
110 
111 static void
112 rb_station_properties_dialog_class_init (RBStationPropertiesDialogClass *klass)
113 {
114 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
115 	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
116 
117 	object_class->constructed = rb_station_properties_dialog_constructed;
118 	object_class->set_property = rb_station_properties_dialog_set_property;
119 	object_class->get_property = rb_station_properties_dialog_get_property;
120 
121 	widget_class->show = rb_station_properties_dialog_show;
122 
123 	g_object_class_install_property (object_class,
124 					 PROP_ENTRY_VIEW,
125 					 g_param_spec_object ("entry-view",
126 					                      "RBEntryView",
127 					                      "RBEntryView object",
128 					                      RB_TYPE_ENTRY_VIEW,
129 					                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
130 	g_object_class_install_property (object_class,
131 					 PROP_PLUGIN,
132 					 g_param_spec_object ("plugin",
133 					                      "plugin instance",
134 					                      "plugin instance to use to find files",
135 					                      G_TYPE_OBJECT,
136 					                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
137 
138 	object_class->dispose = rb_station_properties_dialog_dispose;
139 	object_class->finalize = rb_station_properties_dialog_finalize;
140 
141 	g_type_class_add_private (klass, sizeof (RBStationPropertiesDialogPrivate));
142 }
143 
144 static void
145 rb_station_properties_dialog_class_finalize (RBStationPropertiesDialogClass *klass)
146 {
147 }
148 
149 static void
150 rb_station_properties_dialog_init (RBStationPropertiesDialog *dialog)
151 {
152         dialog->priv = RB_STATION_PROPERTIES_DIALOG_GET_PRIVATE (dialog);
153 }
154 
155 static void
156 rb_station_properties_dialog_constructed (GObject *object)
157 {
158 	RBStationPropertiesDialog *dialog;
159 	GtkWidget *content_area;
160 	GtkBuilder *builder;
161 	char *builder_file;
162 	AtkObject *lobj, *robj;
163 
164 	RB_CHAIN_GOBJECT_METHOD (rb_station_properties_dialog_parent_class, constructed, object);
165 	dialog = RB_STATION_PROPERTIES_DIALOG (object);
166 
167 	g_signal_connect_object (dialog,
168 				 "response",
169 				 G_CALLBACK (rb_station_properties_dialog_response_cb),
170 				 dialog, 0);
171 
172 	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
173 
174 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
175 	gtk_box_set_spacing (GTK_BOX (content_area), 2);
176 
177 	builder_file = rb_find_plugin_data_file (dialog->priv->plugin, "station-properties.ui");
178 	g_assert (builder_file != NULL);
179 	builder = rb_builder_load (builder_file, dialog);
180 	g_free (builder_file);
181 
182 	gtk_container_add (GTK_CONTAINER (content_area),
183 			   GTK_WIDGET (gtk_builder_get_object (builder, "stationproperties")));
184 
185 	dialog->priv->close_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
186 							    GTK_STOCK_CLOSE,
187 							    GTK_RESPONSE_CLOSE);
188 	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
189 
190 	/* get the widgets from the builder */
191 	dialog->priv->title = GTK_WIDGET (gtk_builder_get_object (builder, "titleEntry"));
192 	dialog->priv->genre = GTK_WIDGET (gtk_builder_get_object (builder, "genreEntry"));
193 	dialog->priv->location = GTK_WIDGET (gtk_builder_get_object (builder, "locationEntry"));
194 
195 	dialog->priv->lastplayed = GTK_WIDGET (gtk_builder_get_object (builder, "lastplayedLabel"));
196 	dialog->priv->playcount = GTK_WIDGET (gtk_builder_get_object (builder, "playcountLabel"));
197 	dialog->priv->bitrate = GTK_WIDGET (gtk_builder_get_object (builder, "bitrateLabel"));
198 	dialog->priv->playback_error = GTK_WIDGET (gtk_builder_get_object (builder, "errorLabel"));
199 	dialog->priv->playback_error_box = GTK_WIDGET (gtk_builder_get_object (builder, "errorBox"));
200 
201 	rb_builder_boldify_label (builder, "titleLabel");
202 	rb_builder_boldify_label (builder, "genreLabel");
203 	rb_builder_boldify_label (builder, "locationLabel");
204 	rb_builder_boldify_label (builder, "ratingLabel");
205 	rb_builder_boldify_label (builder, "lastplayedDescLabel");
206 	rb_builder_boldify_label (builder, "playcountDescLabel");
207 	rb_builder_boldify_label (builder, "bitrateDescLabel");
208 
209 	g_signal_connect_object (G_OBJECT (dialog->priv->location),
210 				 "changed",
211 				 G_CALLBACK (rb_station_properties_dialog_location_changed_cb),
212 				 dialog, 0);
213 
214 	dialog->priv->rating = GTK_WIDGET (rb_rating_new ());
215 	g_signal_connect_object (dialog->priv->rating,
216 				 "rated",
217 				 G_CALLBACK (rb_station_properties_dialog_rated_cb),
218 				 G_OBJECT (dialog), 0);
219 	gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (builder, "ratingVBox")),
220 			   dialog->priv->rating);
221 
222 	/* add relationship between the rating label and the rating widget */
223 	lobj = gtk_widget_get_accessible (GTK_WIDGET (gtk_builder_get_object (builder, "ratingLabel")));
224 	robj = gtk_widget_get_accessible (dialog->priv->rating);
225 
226 	atk_object_add_relationship (lobj, ATK_RELATION_LABEL_FOR, robj);
227 	atk_object_add_relationship (robj, ATK_RELATION_LABELLED_BY, lobj);
228 
229 	g_object_unref (builder);
230 }
231 
232 static void
233 rb_station_properties_dialog_dispose (GObject *object)
234 {
235 	RBStationPropertiesDialog *dialog;
236 
237 	g_return_if_fail (object != NULL);
238 	g_return_if_fail (RB_IS_STATION_PROPERTIES_DIALOG (object));
239 
240 	dialog = RB_STATION_PROPERTIES_DIALOG (object);
241 	g_return_if_fail (dialog->priv != NULL);
242 
243 	if (dialog->priv->db != NULL) {
244 		g_object_unref (dialog->priv->db);
245 	}
246 
247 	G_OBJECT_CLASS (rb_station_properties_dialog_parent_class)->dispose (object);
248 }
249 
250 static void
251 rb_station_properties_dialog_finalize (GObject *object)
252 {
253 	RBStationPropertiesDialog *dialog;
254 
255 	g_return_if_fail (object != NULL);
256 	g_return_if_fail (RB_IS_STATION_PROPERTIES_DIALOG (object));
257 
258 	dialog = RB_STATION_PROPERTIES_DIALOG (object);
259 
260 	g_return_if_fail (dialog->priv != NULL);
261 
262 	G_OBJECT_CLASS (rb_station_properties_dialog_parent_class)->finalize (object);
263 }
264 
265 static void
266 rb_station_properties_dialog_set_property (GObject *object,
267 					   guint prop_id,
268 					   const GValue *value,
269 					   GParamSpec *pspec)
270 {
271 	RBStationPropertiesDialog *dialog = RB_STATION_PROPERTIES_DIALOG (object);
272 
273 	switch (prop_id) {
274 	case PROP_ENTRY_VIEW:
275 		if (dialog->priv->db != NULL) {
276 			g_object_unref (dialog->priv->db);
277 		}
278 
279 		dialog->priv->entry_view = g_value_get_object (value);
280 
281 		g_object_get (G_OBJECT (dialog->priv->entry_view),
282 			      "db", &dialog->priv->db, NULL);
283 		break;
284 	case PROP_PLUGIN:
285 		dialog->priv->plugin = g_value_get_object (value);
286 		break;
287 	default:
288 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
289 		break;
290 	}
291 }
292 
293 static void
294 rb_station_properties_dialog_get_property (GObject *object,
295 					   guint prop_id,
296 					   GValue *value,
297 					   GParamSpec *pspec)
298 {
299 	RBStationPropertiesDialog *dialog = RB_STATION_PROPERTIES_DIALOG (object);
300 
301 	switch (prop_id) {
302 	case PROP_ENTRY_VIEW:
303 		g_value_set_object (value, dialog->priv->entry_view);
304 		break;
305 	case PROP_PLUGIN:
306 		g_value_set_object (value, dialog->priv->plugin);
307 		break;
308 	default:
309 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
310 		break;
311 	}
312 }
313 
314 GtkWidget *
315 rb_station_properties_dialog_new (GObject *plugin, RBEntryView *entry_view)
316 {
317 	RBStationPropertiesDialog *dialog;
318 
319 	g_return_val_if_fail (RB_IS_ENTRY_VIEW (entry_view), NULL);
320 
321 	dialog = g_object_new (RB_TYPE_STATION_PROPERTIES_DIALOG,
322 			       "plugin", plugin,
323 			       "entry-view", entry_view,
324 			       NULL);
325 
326 	if (!rb_station_properties_dialog_get_current_entry (dialog)) {
327 		g_object_unref (G_OBJECT (dialog));
328 		return NULL;
329 	}
330 
331 	rb_station_properties_dialog_update (dialog);
332 
333 	return GTK_WIDGET (dialog);
334 }
335 
336 static void
337 rb_station_properties_dialog_response_cb (GtkDialog *gtkdialog,
338 					  int response_id,
339 					  RBStationPropertiesDialog *dialog)
340 {
341 	if (dialog->priv->current_entry)
342 		rb_station_properties_dialog_sync_entries (dialog);
343 
344 	gtk_widget_destroy (GTK_WIDGET (dialog));
345 }
346 
347 static gboolean
348 rb_station_properties_dialog_get_current_entry (RBStationPropertiesDialog *dialog)
349 {
350 	GList *selected_entries;
351 
352 	/* get the entry */
353 	selected_entries = rb_entry_view_get_selected_entries (dialog->priv->entry_view);
354 
355 	if ((selected_entries == NULL) ||
356 	    (selected_entries->data == NULL)) {
357 		dialog->priv->current_entry = NULL;
358 		return FALSE;
359 	}
360 
361 	if (dialog->priv->current_entry != NULL) {
362 		rhythmdb_entry_unref (dialog->priv->current_entry);
363 	}
364 
365 	dialog->priv->current_entry = rhythmdb_entry_ref (selected_entries->data);
366 
367 	g_list_foreach (selected_entries, (GFunc)rhythmdb_entry_unref, NULL);
368 	g_list_free (selected_entries);
369 
370 	return TRUE;
371 }
372 
373 static void
374 rb_station_properties_dialog_update (RBStationPropertiesDialog *dialog)
375 {
376 	rb_station_properties_dialog_update_title (dialog);
377 
378 	if (dialog->priv->current_entry) {
379 		rb_station_properties_dialog_update_location (dialog);
380 		rb_station_properties_dialog_update_title_entry (dialog);
381 		rb_station_properties_dialog_update_genre (dialog);
382 	}
383 
384 	rb_station_properties_dialog_update_play_count (dialog);
385 	rb_station_properties_dialog_update_bitrate (dialog);
386 	rb_station_properties_dialog_update_last_played (dialog);
387 	rb_station_properties_dialog_update_rating (dialog);
388 	rb_station_properties_dialog_location_changed_cb (GTK_ENTRY (dialog->priv->location), dialog);
389 }
390 
391 static void
392 rb_station_properties_dialog_update_title (RBStationPropertiesDialog *dialog)
393 {
394 	const char *name;
395 	char *tmp;
396 
397 	if (dialog->priv->current_entry) {
398 		name = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_TITLE);
399 		tmp = g_strdup_printf (_("%s Properties"), name);
400 		gtk_window_set_title (GTK_WINDOW (dialog), tmp);
401 		g_free (tmp);
402 	} else {
403 		gtk_window_set_title (GTK_WINDOW (dialog), _("New Internet Radio Station"));
404 	}
405 }
406 
407 static void
408 rb_station_properties_dialog_update_title_entry (RBStationPropertiesDialog *dialog)
409 {
410 	const char *title;
411 
412 	title = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_TITLE);
413 	gtk_entry_set_text (GTK_ENTRY (dialog->priv->title),title);
414 }
415 
416 static void
417 rb_station_properties_dialog_update_genre (RBStationPropertiesDialog *dialog)
418 {
419 	const char *genre;
420 
421 	genre = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_GENRE);
422 	gtk_entry_set_text (GTK_ENTRY (dialog->priv->genre), genre);
423 }
424 
425 static void
426 rb_station_properties_dialog_update_location (RBStationPropertiesDialog *dialog)
427 {
428 	const char *location;
429 	char *unescaped;
430 
431 	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
432 	unescaped = g_uri_unescape_string (location, NULL);
433 	gtk_entry_set_text (GTK_ENTRY (dialog->priv->location), unescaped);
434 	g_free (unescaped);
435 }
436 
437 static void
438 rb_station_properties_dialog_rated_cb (RBRating *rating,
439 				       double score,
440 				       RBStationPropertiesDialog *dialog)
441 {
442 	GValue value = {0, };
443 
444 	g_return_if_fail (RB_IS_RATING (rating));
445 	g_return_if_fail (RB_IS_STATION_PROPERTIES_DIALOG (dialog));
446 	g_return_if_fail (score >= 0 && score <= 5 );
447 
448 	if (!dialog->priv->current_entry)
449 		return;
450 
451 	g_value_init (&value, G_TYPE_DOUBLE);
452 	g_value_set_double (&value, score);
453 
454 	/* set the new value for the song */
455 	rhythmdb_entry_set (dialog->priv->db,
456 			    dialog->priv->current_entry,
457 			    RHYTHMDB_PROP_RATING,
458 			    &value);
459 	g_value_unset (&value);
460 	rhythmdb_commit (dialog->priv->db);
461 
462 	g_object_set (G_OBJECT (dialog->priv->rating), "rating", score, NULL);
463 }
464 
465 static void
466 rb_station_properties_dialog_update_play_count (RBStationPropertiesDialog *dialog)
467 {
468 	char *text;
469 	long int count = 0;
470 
471 	if (dialog->priv->current_entry)
472 		count = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_PLAY_COUNT);
473 
474 	text = g_strdup_printf ("%ld", count);
475 	gtk_label_set_text (GTK_LABEL (dialog->priv->playcount), text);
476 	g_free (text);
477 }
478 
479 static void
480 rb_station_properties_dialog_update_bitrate (RBStationPropertiesDialog *dialog)
481 {
482 	gulong val = 0;
483 	char *text;
484 
485 	if (dialog->priv->current_entry)
486 		val = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_BITRATE);
487 
488 	if (val == 0)
489 		text = g_strdup (_("Unknown"));
490 	else
491 		text = g_strdup_printf (_("%lu kbps"), val);
492 
493 	gtk_label_set_text (GTK_LABEL (dialog->priv->bitrate), text);
494 	g_free (text);
495 }
496 
497 static void
498 rb_station_properties_dialog_update_last_played (RBStationPropertiesDialog *dialog)
499 {
500 	const char *last_played = _("Never");
501 
502 	if (dialog->priv->current_entry)
503 		last_played = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LAST_PLAYED_STR);
504 	gtk_label_set_text (GTK_LABEL (dialog->priv->lastplayed), last_played);
505 }
506 
507 static void
508 rb_station_properties_dialog_update_rating (RBStationPropertiesDialog *dialog)
509 {
510 	gdouble rating = 0.0;
511 	g_return_if_fail (RB_IS_STATION_PROPERTIES_DIALOG (dialog));
512 
513 	if (dialog->priv->current_entry)
514 		rating = rhythmdb_entry_get_double (dialog->priv->current_entry, RHYTHMDB_PROP_RATING);
515 
516 	g_object_set (G_OBJECT (dialog->priv->rating), "rating", rating, NULL);
517 }
518 
519 static void
520 rb_station_properties_dialog_update_playback_error (RBStationPropertiesDialog *dialog)
521 {
522 	const char *error;
523 
524 	g_return_if_fail (RB_IS_STATION_PROPERTIES_DIALOG (dialog));
525 
526 	error = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_PLAYBACK_ERROR);
527 	if (dialog->priv->current_entry && error) {
528 		gtk_label_set_text (GTK_LABEL (dialog->priv->playback_error), error);
529 		gtk_widget_show (dialog->priv->playback_error_box);
530 	} else {
531 		gtk_label_set_text (GTK_LABEL (dialog->priv->playback_error), "");
532 		gtk_widget_hide (dialog->priv->playback_error_box);
533 	}
534 }
535 
536 static void
537 rb_station_properties_dialog_sync_entries (RBStationPropertiesDialog *dialog)
538 {
539 	const char *title;
540 	const char *genre;
541 	const char *location;
542 	const char *string;
543 	GValue val = {0,};
544 	gboolean changed = FALSE;
545 	RhythmDBEntry *entry = dialog->priv->current_entry;
546 
547 	title = gtk_entry_get_text (GTK_ENTRY (dialog->priv->title));
548 	genre = gtk_entry_get_text (GTK_ENTRY (dialog->priv->genre));
549 	location = gtk_entry_get_text (GTK_ENTRY (dialog->priv->location));
550 
551 	string = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE);
552 	if (strcmp (title, string)) {
553 		g_value_init (&val, G_TYPE_STRING);
554 		g_value_set_string (&val, title);
555 		rhythmdb_entry_set (dialog->priv->db, entry,
556 				    RHYTHMDB_PROP_TITLE,
557 				    &val);
558 		g_value_unset (&val);
559 		changed = TRUE;
560 	}
561 
562 	string = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_GENRE);
563 	if (strcmp (genre, string)) {
564 		g_value_init (&val, G_TYPE_STRING);
565 		g_value_set_string (&val, genre);
566 		rhythmdb_entry_set (dialog->priv->db, entry,
567 				    RHYTHMDB_PROP_GENRE, &val);
568 		g_value_unset (&val);
569 		changed = TRUE;
570 	}
571 
572 	string = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
573 	if (strcmp (location, string)) {
574 		if (rhythmdb_entry_lookup_by_location (dialog->priv->db, location) == NULL) {
575 			g_value_init (&val, G_TYPE_STRING);
576 			g_value_set_string (&val, location);
577 			rhythmdb_entry_set (dialog->priv->db, entry,
578 					    RHYTHMDB_PROP_LOCATION, &val);
579 			g_value_unset (&val);
580 			changed = TRUE;
581 		} else {
582 			rb_error_dialog (NULL, _("Unable to change station property"), _("Unable to change station URI to %s, as that station already exists"), location);
583 		}
584 	}
585 
586 	if (changed)
587 		rhythmdb_commit (dialog->priv->db);
588 }
589 
590 static void
591 rb_station_properties_dialog_show (GtkWidget *widget)
592 {
593 	if (GTK_WIDGET_CLASS (rb_station_properties_dialog_parent_class)->show)
594 		GTK_WIDGET_CLASS (rb_station_properties_dialog_parent_class)->show (widget);
595 
596 	rb_station_properties_dialog_update_playback_error (
597 			RB_STATION_PROPERTIES_DIALOG (widget));
598 }
599 
600 static void
601 rb_station_properties_dialog_location_changed_cb (GtkEntry *entry,
602 						  RBStationPropertiesDialog *dialog)
603 {
604 }
605 
606 void
607 _rb_station_properties_dialog_register_type (GTypeModule *module)
608 {
609 	rb_station_properties_dialog_register_type (module);
610 }