~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to podcast/rb-feed-podcast-properties-dialog.c

Tags: upstream-0.9.2cvs20060102
ImportĀ upstreamĀ versionĀ 0.9.2cvs20060102

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
static void rb_feed_podcast_properties_dialog_update_author (RBFeedPodcastPropertiesDialog *dialog);
52
52
static void rb_feed_podcast_properties_dialog_update_language (RBFeedPodcastPropertiesDialog *dialog);
53
53
static void rb_feed_podcast_properties_dialog_update_last_update (RBFeedPodcastPropertiesDialog *dialog);
 
54
static void rb_feed_podcast_properties_dialog_update_last_episode (RBFeedPodcastPropertiesDialog *dialog);
54
55
static void rb_feed_podcast_properties_dialog_update_copyright (RBFeedPodcastPropertiesDialog *dialog);
55
56
static void rb_feed_podcast_properties_dialog_update_summary (RBFeedPodcastPropertiesDialog *dialog);
56
57
static gchar* rb_feed_podcast_properties_dialog_parse_time (gulong time);
57
58
 
58
 
static GtkWidget * boldify_label (GtkWidget *label);
59
 
 
60
59
struct RBFeedPodcastPropertiesDialogPrivate
61
60
{
62
61
        RhythmDB *db;
67
66
        GtkWidget   *location;
68
67
        GtkWidget   *language;
69
68
        GtkWidget   *last_update;
 
69
        GtkWidget   *last_episode;
70
70
        GtkWidget   *copyright;
71
71
        GtkWidget   *summary;
72
72
        
73
 
        GtkWidget   *okbutton;
 
73
        GtkWidget   *close_button;
74
74
};
75
75
 
 
76
#define RB_FEED_PODCAST_PROPERTIES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_FEED_PODCAST_PROPERTIES_DIALOG, RBFeedPodcastPropertiesDialogPrivate))
 
77
 
76
78
enum 
77
79
{
78
80
        PROP_0,
88
90
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
89
91
 
90
92
        object_class->finalize = rb_feed_podcast_properties_dialog_finalize;
 
93
 
 
94
        g_type_class_add_private (klass, sizeof (RBFeedPodcastPropertiesDialogPrivate));
91
95
}
92
96
 
93
97
static void
95
99
{
96
100
        GladeXML *xml;
97
101
        
98
 
        dialog->priv = g_new0 (RBFeedPodcastPropertiesDialogPrivate, 1);
 
102
        dialog->priv = RB_FEED_PODCAST_PROPERTIES_DIALOG_GET_PRIVATE (dialog);
99
103
        
100
104
        g_signal_connect_object (G_OBJECT (dialog),
101
105
                                 "response",
102
106
                                 G_CALLBACK (rb_feed_podcast_properties_dialog_response_cb),
103
107
                                 dialog, 0);
104
108
 
 
109
        gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400);
 
110
 
105
111
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
106
112
        gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
107
113
        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
108
114
 
109
 
        gtk_dialog_set_default_response (GTK_DIALOG (dialog),
110
 
                                         GTK_RESPONSE_OK);
111
 
 
112
115
        xml = rb_glade_xml_new ("podcast-feed-properties.glade",
113
116
                                "podcastproperties",
114
117
                                dialog);
117
120
        gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
118
121
                           glade_xml_get_widget (xml, "podcastproperties"));
119
122
        
120
 
        dialog->priv->okbutton = gtk_dialog_add_button (GTK_DIALOG (dialog),
121
 
                                                        GTK_STOCK_OK,
122
 
                                                        GTK_RESPONSE_OK);
123
 
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
123
        dialog->priv->close_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
 
124
                                                            GTK_STOCK_CLOSE,
 
125
                                                            GTK_RESPONSE_CLOSE);
 
126
        gtk_dialog_set_default_response (GTK_DIALOG (dialog),
 
127
                                         GTK_RESPONSE_CLOSE);
124
128
 
125
129
        /* get the widgets from the XML */
126
130
        dialog->priv->title = glade_xml_get_widget (xml, "titleLabel");
128
132
        dialog->priv->location = glade_xml_get_widget (xml, "locationLabel");
129
133
        dialog->priv->language = glade_xml_get_widget (xml, "languageLabel");
130
134
        dialog->priv->last_update = glade_xml_get_widget (xml, "lastupdateLabel");
 
135
        dialog->priv->last_episode = glade_xml_get_widget (xml, "lastepisodeLabel");
131
136
        dialog->priv->copyright = glade_xml_get_widget (xml, "copyrightLabel");
132
137
        dialog->priv->summary = glade_xml_get_widget (xml, "summaryLabel");
133
138
 
134
 
        boldify_label (glade_xml_get_widget (xml, "titleDescLabel"));
135
 
        boldify_label (glade_xml_get_widget (xml, "authorDescLabel"));
136
 
        boldify_label (glade_xml_get_widget (xml, "locationDescLabel"));
137
 
        boldify_label (glade_xml_get_widget (xml, "languageDescLabel"));
138
 
        boldify_label (glade_xml_get_widget (xml, "lastupdateDescLabel"));
139
 
        boldify_label (glade_xml_get_widget (xml, "copyrightDescLabel"));
140
 
        boldify_label (glade_xml_get_widget (xml, "summaryDescLabel"));
 
139
        rb_glade_boldify_label (xml, "titleDescLabel");
 
140
        rb_glade_boldify_label (xml, "authorDescLabel");
 
141
        rb_glade_boldify_label (xml, "locationDescLabel");
 
142
        rb_glade_boldify_label (xml, "languageDescLabel");
 
143
        rb_glade_boldify_label (xml, "lastupdateDescLabel");
 
144
        rb_glade_boldify_label (xml, "lastepisodeDescLabel");
 
145
        rb_glade_boldify_label (xml, "copyrightDescLabel");
 
146
        rb_glade_boldify_label (xml, "summaryDescLabel");
141
147
 
142
148
        g_object_unref (G_OBJECT (xml));
143
149
}
154
160
 
155
161
        g_return_if_fail (dialog->priv != NULL);
156
162
 
157
 
        g_free (dialog->priv);
158
 
 
159
163
        G_OBJECT_CLASS (rb_feed_podcast_properties_dialog_parent_class)->finalize (object);
160
164
}
161
165
 
172
176
        return GTK_WIDGET (dialog);
173
177
}
174
178
 
175
 
static GtkWidget *
176
 
boldify_label (GtkWidget *label)
177
 
{
178
 
        gchar *str_final;
179
 
        str_final = g_strdup_printf ("<b>%s</b>",
180
 
                                     gtk_label_get_label (GTK_LABEL (label)));
181
 
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), str_final);
182
 
        g_free (str_final);
183
 
        return label;
184
 
}
185
 
 
186
179
static void
187
180
rb_feed_podcast_properties_dialog_response_cb (GtkDialog *gtkdialog,
188
181
                                               int response_id,
195
188
rb_feed_podcast_properties_dialog_update (RBFeedPodcastPropertiesDialog *dialog)
196
189
{
197
190
        g_return_if_fail (dialog->priv->current_entry != NULL);
 
191
 
198
192
        rb_feed_podcast_properties_dialog_update_location (dialog);
199
193
        rb_feed_podcast_properties_dialog_update_title (dialog);
200
194
        rb_feed_podcast_properties_dialog_update_title_label (dialog);
201
195
        rb_feed_podcast_properties_dialog_update_author (dialog);
202
196
        rb_feed_podcast_properties_dialog_update_language (dialog);
203
197
        rb_feed_podcast_properties_dialog_update_last_update (dialog);
 
198
        rb_feed_podcast_properties_dialog_update_last_episode (dialog);
204
199
        rb_feed_podcast_properties_dialog_update_copyright (dialog);
205
200
        rb_feed_podcast_properties_dialog_update_summary (dialog);
206
201
}
211
206
        const char *name;
212
207
        char *tmp;      
213
208
        name = rb_refstring_get (dialog->priv->current_entry->title);
214
 
        tmp = g_strdup_printf (_("Properties for %s"), name);
 
209
        tmp = g_strdup_printf (_("%s Properties"), name);
215
210
        gtk_window_set_title (GTK_WINDOW (dialog), tmp);
216
211
        g_free (tmp);
217
212
}
256
251
static void
257
252
rb_feed_podcast_properties_dialog_update_last_update (RBFeedPodcastPropertiesDialog *dialog)
258
253
{
259
 
        char *time;
260
 
 
261
 
        time = rb_feed_podcast_properties_dialog_parse_time (dialog->priv->current_entry->podcast->post_time);
262
 
        gtk_label_set (GTK_LABEL (dialog->priv->last_update),
263
 
                       time);
264
 
        g_free (time);
 
254
        char *time_str;
 
255
        gulong time_val;
 
256
 
 
257
        time_val = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_LAST_SEEN);
 
258
        time_str = rb_feed_podcast_properties_dialog_parse_time (time_val);
 
259
        gtk_label_set (GTK_LABEL (dialog->priv->last_update), time_str);
 
260
        g_free (time_str);
 
261
}
 
262
 
 
263
static void
 
264
rb_feed_podcast_properties_dialog_update_last_episode (RBFeedPodcastPropertiesDialog *dialog)
 
265
{
 
266
        char *time_str;
 
267
        gulong time_val;
 
268
 
 
269
        time_val = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_POST_TIME);
 
270
        time_str = rb_feed_podcast_properties_dialog_parse_time (time_val);
 
271
        gtk_label_set (GTK_LABEL (dialog->priv->last_episode), time_str);
 
272
        g_free (time_str);
265
273
}
266
274
 
267
275
static void
275
283
rb_feed_podcast_properties_dialog_parse_time (gulong value)
276
284
{
277
285
        char *str;
278
 
        struct tm then;
279
286
 
280
287
        if (0 == value) {
281
 
                return NULL;
 
288
                str = g_strdup (_("Unknown"));
 
289
        } else {
 
290
                str = rb_utf_friendly_time ((time_t)value);
282
291
        }
283
292
 
284
 
        localtime_r ((time_t*)&value, &then);
285
 
        str = eel_strdup_strftime (_("%Y-%m-%d %H:%M"), &then);
286
 
 
287
293
        return str;
288
294
}