~snaggen/rhythmbox/bpm

« back to all changes in this revision

Viewing changes to iradio/rb-new-station-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 new station dialog
4
 
 *
5
 
 *  Copyright (C) 2005 Renato Araujo Oliveira Filho - INdT <renato.filho@indt.org.br>
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-new-station-dialog.h"
34
 
#include "rb-glade-helpers.h"
35
 
#include "rb-dialog.h"
36
 
#include "rb-entry-view.h"
37
 
#include "rb-debug.h"
38
 
 
39
 
static void rb_new_station_dialog_class_init (RBNewStationDialogClass *klass);
40
 
static void rb_new_station_dialog_init (RBNewStationDialog *dialog);
41
 
static void rb_new_station_dialog_finalize (GObject *object);
42
 
static void rb_new_station_dialog_response_cb (GtkDialog *gtkdialog,
43
 
                                               int response_id,
44
 
                                               RBNewStationDialog *dialog);
45
 
static void rb_new_station_dialog_text_changed (GtkEditable *buffer,
46
 
                                                RBNewStationDialog *dialog);
47
 
 
48
 
struct RBNewStationDialogPrivate
49
 
{
50
 
        GtkWidget   *url;
51
 
        GtkWidget   *okbutton;
52
 
        GtkWidget   *cancelbutton;
53
 
};
54
 
 
55
 
#define RB_NEW_STATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_NEW_STATION_DIALOG, RBNewStationDialogPrivate))
56
 
 
57
 
enum
58
 
{
59
 
        LOCATION_ADDED,
60
 
        LAST_SIGNAL
61
 
};
62
 
 
63
 
static guint rb_new_station_dialog_signals [LAST_SIGNAL] = { 0 };
64
 
 
65
 
G_DEFINE_TYPE (RBNewStationDialog, rb_new_station_dialog, GTK_TYPE_DIALOG)
66
 
 
67
 
static void
68
 
rb_new_station_dialog_class_init (RBNewStationDialogClass *klass)
69
 
{
70
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
71
 
 
72
 
        object_class->finalize = rb_new_station_dialog_finalize;
73
 
 
74
 
        rb_new_station_dialog_signals [LOCATION_ADDED] =
75
 
                g_signal_new ("location-added",
76
 
                              G_OBJECT_CLASS_TYPE (object_class),
77
 
                              G_SIGNAL_RUN_LAST,
78
 
                              G_STRUCT_OFFSET (RBNewStationDialogClass, location_added),
79
 
                              NULL, NULL,
80
 
                              g_cclosure_marshal_VOID__STRING,
81
 
                              G_TYPE_NONE,
82
 
                              1,
83
 
                              G_TYPE_STRING);
84
 
 
85
 
        g_type_class_add_private (klass, sizeof (RBNewStationDialogPrivate));
86
 
}
87
 
 
88
 
static void
89
 
rb_new_station_dialog_init (RBNewStationDialog *dialog)
90
 
{
91
 
        GladeXML *xml;
92
 
 
93
 
        /* create the dialog and some buttons forward - close */
94
 
        dialog->priv = RB_NEW_STATION_DIALOG_GET_PRIVATE (dialog);
95
 
 
96
 
        g_signal_connect_object (G_OBJECT (dialog),
97
 
                                 "response",
98
 
                                 G_CALLBACK (rb_new_station_dialog_response_cb),
99
 
                                 dialog, 0);
100
 
 
101
 
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
102
 
        gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
103
 
        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
104
 
 
105
 
        gtk_window_set_title (GTK_WINDOW (dialog), _("New Internet Radio Station"));
106
 
 
107
 
        dialog->priv->cancelbutton = gtk_dialog_add_button (GTK_DIALOG (dialog),
108
 
                                                            GTK_STOCK_CANCEL,
109
 
                                                            GTK_RESPONSE_CANCEL);
110
 
        dialog->priv->okbutton = gtk_dialog_add_button (GTK_DIALOG (dialog),
111
 
                                                        GTK_STOCK_ADD,
112
 
                                                        GTK_RESPONSE_OK);
113
 
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
114
 
 
115
 
        xml = rb_glade_xml_new ("station-new.glade",
116
 
                                "newstation",
117
 
                                dialog);
118
 
 
119
 
        gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
120
 
                           glade_xml_get_widget (xml, "newstation"));
121
 
 
122
 
        /* get the widgets from the XML */
123
 
        dialog->priv->url = glade_xml_get_widget (xml, "txt_url");
124
 
        gtk_entry_set_activates_default (GTK_ENTRY (dialog->priv->url), TRUE);
125
 
 
126
 
        g_signal_connect_object (G_OBJECT (dialog->priv->url),
127
 
                                 "changed",
128
 
                                 G_CALLBACK (rb_new_station_dialog_text_changed),
129
 
                                 dialog, 0);
130
 
 
131
 
        /* default focus */
132
 
        gtk_widget_grab_focus (dialog->priv->url);
133
 
 
134
 
        /* FIXME */
135
 
        gtk_widget_set_sensitive (dialog->priv->okbutton, FALSE);
136
 
 
137
 
        g_object_unref (G_OBJECT (xml));
138
 
}
139
 
 
140
 
static void
141
 
rb_new_station_dialog_finalize (GObject *object)
142
 
{
143
 
        RBNewStationDialog *dialog;
144
 
 
145
 
        g_return_if_fail (object != NULL);
146
 
        g_return_if_fail (RB_IS_NEW_STATION_DIALOG (object));
147
 
 
148
 
        dialog = RB_NEW_STATION_DIALOG (object);
149
 
 
150
 
        g_return_if_fail (dialog->priv != NULL);
151
 
 
152
 
        G_OBJECT_CLASS (rb_new_station_dialog_parent_class)->finalize (object);
153
 
}
154
 
 
155
 
GtkWidget *
156
 
rb_new_station_dialog_new (RBEntryView *view)
157
 
{
158
 
        RBNewStationDialog *dialog;
159
 
 
160
 
        dialog = g_object_new (RB_TYPE_NEW_STATION_DIALOG, NULL);
161
 
 
162
 
        return GTK_WIDGET (dialog);
163
 
}
164
 
 
165
 
static void
166
 
rb_new_station_dialog_create_station (RBNewStationDialog *dialog)
167
 
{
168
 
        char *valid_url;
169
 
        char *str;
170
 
 
171
 
        str = gtk_editable_get_chars (GTK_EDITABLE (dialog->priv->url), 0, -1);
172
 
        valid_url = g_strstrip (str);
173
 
 
174
 
        g_signal_emit (dialog, rb_new_station_dialog_signals [LOCATION_ADDED], 0, valid_url);
175
 
 
176
 
        g_free (str);
177
 
}
178
 
 
179
 
static void
180
 
rb_new_station_dialog_response_cb (GtkDialog *gtkdialog,
181
 
                                   int response_id,
182
 
                                   RBNewStationDialog *dialog)
183
 
{
184
 
 
185
 
        if (response_id != GTK_RESPONSE_OK)
186
 
                return;
187
 
 
188
 
        rb_new_station_dialog_create_station (dialog);
189
 
 
190
 
        gtk_widget_hide (GTK_WIDGET (gtkdialog));
191
 
}
192
 
 
193
 
static void
194
 
rb_new_station_dialog_text_changed (GtkEditable *buffer,
195
 
                                    RBNewStationDialog *dialog)
196
 
{
197
 
        char *text = gtk_editable_get_chars (buffer, 0, -1);
198
 
        gboolean has_text = ((text != NULL) && (*text != 0));
199
 
 
200
 
        g_free (text);
201
 
 
202
 
        gtk_widget_set_sensitive (dialog->priv->okbutton, has_text);
203
 
}