~snaggen/rhythmbox/bpm

« back to all changes in this revision

Viewing changes to iradio/rb-station-properties-dialog.c

  • Committer: Jonathan Matthew
  • Author(s): Jonathan Matthew
  • Date: 2007-01-07 12:16:12 UTC
  • Revision ID: git-v1:5b6958ea3cf24f2c8bcfa15b9cab1fc7798b7305
Moved lots of files around. Now everything should be in the directory it's

2007-01-07  Jonathan Matthew  <jonathan@kaolin.wh9.net>

        Moved lots of files around.  Now everything should be in the directory
        it's built in and all plugin-specific files should be installed into
        the plugin directory.

        * plugins/audioscrobbler/rb-audioscrobbler-plugin.c:
        (impl_create_configure_dialog):
        * plugins/audioscrobbler/rb-audioscrobbler.c:
        (rb_audioscrobbler_class_init), (rb_audioscrobbler_dispose),
        (rb_audioscrobbler_finalize),
        (rb_audioscrobbler_get_config_widget):
        * plugins/audioscrobbler/rb-audioscrobbler.h:
        Use rb_plugin_find_file where needed.

        * widgets/rb-uri-dialog.c: (rb_uri_dialog_class_init),
        (rb_uri_dialog_init), (rb_uri_dialog_finalize),
        (rb_uri_dialog_new), (rb_uri_dialog_response_cb),
        (rb_uri_dialog_text_changed):
        * widgets/rb-uri-dialog.h:
        New common 'enter a URI' dialog, used by iradio and podcast code.

        * plugins/iradio/rb-iradio-plugin.c: (impl_activate):
        * plugins/iradio/rb-iradio-source.c:
        (rb_iradio_source_constructor), (rb_iradio_source_new),
        (impl_song_properties), (rb_iradio_source_first_time_changed),
        (new_station_location_added), (rb_iradio_source_cmd_new_station):
        * plugins/iradio/rb-iradio-source.h:
        * plugins/iradio/rb-station-properties-dialog.c:
        (rb_station_properties_dialog_class_init),
        (rb_station_properties_dialog_init),
        (rb_station_properties_dialog_constructor),
        (rb_station_properties_dialog_set_property),
        (rb_station_properties_dialog_get_property),
        (rb_station_properties_dialog_new):
        * plugins/iradio/rb-station-properties-dialog.h:
        Use the common URI dialog, use rb_plugin_find_file where needed.

        * sources/rb-podcast-source.c:
        (rb_podcast_source_location_added_cb),
        (rb_podcast_source_cmd_new_podcast):
        Use the common URI dialog.

svn path=/trunk/; revision=4725

Show diffs side-by-side

added added

removed removed

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