udapted vi.po
[rhythmbox.git] / podcast / rb-feed-podcast-properties-dialog.c
blobb5394bc706425cc43c2e1eb42fdfb137195e1730
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3 * arch-tag: Headfile of feed_podcast feed properties dialog
5 * Copyright (C) 2005 Renato Araujo Oliveira Filho <renato.filho@indt.org>
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.
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.
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.
23 #include <config.h>
25 #include <string.h>
26 #include <time.h>
28 #include <glib/gi18n.h>
29 #include <gtk/gtk.h>
30 #include <glade/glade.h>
31 #include <libgnomevfs/gnome-vfs.h>
33 #include "rb-feed-podcast-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 #include "rb-cut-and-paste-code.h"
39 #include "rhythmdb.h"
41 static void rb_feed_podcast_properties_dialog_class_init (RBFeedPodcastPropertiesDialogClass *klass);
42 static void rb_feed_podcast_properties_dialog_init (RBFeedPodcastPropertiesDialog *dialog);
43 static void rb_feed_podcast_properties_dialog_finalize (GObject *object);
44 static void rb_feed_podcast_properties_dialog_update_title (RBFeedPodcastPropertiesDialog *dialog);
45 static void rb_feed_podcast_properties_dialog_update_title_label (RBFeedPodcastPropertiesDialog *dialog);
46 static void rb_feed_podcast_properties_dialog_update_location (RBFeedPodcastPropertiesDialog *dialog);
47 static void rb_feed_podcast_properties_dialog_response_cb (GtkDialog *gtkdialog,
48 int response_id,
49 RBFeedPodcastPropertiesDialog *dialog);
51 static void rb_feed_podcast_properties_dialog_update (RBFeedPodcastPropertiesDialog *dialog);
52 static void rb_feed_podcast_properties_dialog_update_author (RBFeedPodcastPropertiesDialog *dialog);
53 static void rb_feed_podcast_properties_dialog_update_language (RBFeedPodcastPropertiesDialog *dialog);
54 static void rb_feed_podcast_properties_dialog_update_last_update (RBFeedPodcastPropertiesDialog *dialog);
55 static void rb_feed_podcast_properties_dialog_update_last_episode (RBFeedPodcastPropertiesDialog *dialog);
56 static void rb_feed_podcast_properties_dialog_update_copyright (RBFeedPodcastPropertiesDialog *dialog);
57 static void rb_feed_podcast_properties_dialog_update_summary (RBFeedPodcastPropertiesDialog *dialog);
58 static gchar* rb_feed_podcast_properties_dialog_parse_time (gulong time);
60 struct RBFeedPodcastPropertiesDialogPrivate
62 RhythmDB *db;
63 RhythmDBEntry *current_entry;
65 GtkWidget *title;
66 GtkWidget *author;
67 GtkWidget *location;
68 GtkWidget *language;
69 GtkWidget *last_update;
70 GtkWidget *last_episode;
71 GtkWidget *copyright;
72 GtkWidget *summary;
74 GtkWidget *close_button;
77 #define RB_FEED_PODCAST_PROPERTIES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_FEED_PODCAST_PROPERTIES_DIALOG, RBFeedPodcastPropertiesDialogPrivate))
79 enum
81 PROP_0,
82 PROP_BACKEND
85 G_DEFINE_TYPE (RBFeedPodcastPropertiesDialog, rb_feed_podcast_properties_dialog, GTK_TYPE_DIALOG)
87 static void
88 rb_feed_podcast_properties_dialog_class_init (RBFeedPodcastPropertiesDialogClass *klass)
90 GObjectClass *object_class = G_OBJECT_CLASS (klass);
92 object_class->finalize = rb_feed_podcast_properties_dialog_finalize;
94 g_type_class_add_private (klass, sizeof (RBFeedPodcastPropertiesDialogPrivate));
97 static void
98 rb_feed_podcast_properties_dialog_init (RBFeedPodcastPropertiesDialog *dialog)
100 GladeXML *xml;
102 dialog->priv = RB_FEED_PODCAST_PROPERTIES_DIALOG_GET_PRIVATE (dialog);
104 g_signal_connect_object (G_OBJECT (dialog),
105 "response",
106 G_CALLBACK (rb_feed_podcast_properties_dialog_response_cb),
107 dialog, 0);
109 gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400);
111 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
112 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
113 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
115 xml = rb_glade_xml_new ("podcast-feed-properties.glade",
116 "podcastproperties",
117 dialog);
118 glade_xml_signal_autoconnect (xml);
120 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
121 glade_xml_get_widget (xml, "podcastproperties"));
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);
129 /* get the widgets from the XML */
130 dialog->priv->title = glade_xml_get_widget (xml, "titleLabel");
131 dialog->priv->author = glade_xml_get_widget (xml, "authorLabel");
132 dialog->priv->location = glade_xml_get_widget (xml, "locationLabel");
133 dialog->priv->language = glade_xml_get_widget (xml, "languageLabel");
134 dialog->priv->last_update = glade_xml_get_widget (xml, "lastupdateLabel");
135 dialog->priv->last_episode = glade_xml_get_widget (xml, "lastepisodeLabel");
136 dialog->priv->copyright = glade_xml_get_widget (xml, "copyrightLabel");
137 dialog->priv->summary = glade_xml_get_widget (xml, "summaryLabel");
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");
148 g_object_unref (G_OBJECT (xml));
151 static void
152 rb_feed_podcast_properties_dialog_finalize (GObject *object)
154 RBFeedPodcastPropertiesDialog *dialog;
156 g_return_if_fail (object != NULL);
157 g_return_if_fail (RB_IS_FEED_PODCAST_PROPERTIES_DIALOG (object));
159 dialog = RB_FEED_PODCAST_PROPERTIES_DIALOG (object);
161 g_return_if_fail (dialog->priv != NULL);
163 G_OBJECT_CLASS (rb_feed_podcast_properties_dialog_parent_class)->finalize (object);
166 GtkWidget *
167 rb_feed_podcast_properties_dialog_new (RhythmDBEntry *entry)
169 RBFeedPodcastPropertiesDialog *dialog;
171 dialog = g_object_new (RB_TYPE_FEED_PODCAST_PROPERTIES_DIALOG, NULL);
172 dialog->priv->current_entry = entry;
174 rb_feed_podcast_properties_dialog_update (dialog);
176 return GTK_WIDGET (dialog);
179 static void
180 rb_feed_podcast_properties_dialog_response_cb (GtkDialog *gtkdialog,
181 int response_id,
182 RBFeedPodcastPropertiesDialog *dialog)
184 gtk_widget_destroy (GTK_WIDGET (dialog));
187 static void
188 rb_feed_podcast_properties_dialog_update (RBFeedPodcastPropertiesDialog *dialog)
190 g_return_if_fail (dialog->priv->current_entry != NULL);
192 rb_feed_podcast_properties_dialog_update_location (dialog);
193 rb_feed_podcast_properties_dialog_update_title (dialog);
194 rb_feed_podcast_properties_dialog_update_title_label (dialog);
195 rb_feed_podcast_properties_dialog_update_author (dialog);
196 rb_feed_podcast_properties_dialog_update_language (dialog);
197 rb_feed_podcast_properties_dialog_update_last_update (dialog);
198 rb_feed_podcast_properties_dialog_update_last_episode (dialog);
199 rb_feed_podcast_properties_dialog_update_copyright (dialog);
200 rb_feed_podcast_properties_dialog_update_summary (dialog);
203 static void
204 rb_feed_podcast_properties_dialog_update_title (RBFeedPodcastPropertiesDialog *dialog)
206 const char *name;
207 char *tmp;
208 name = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_TITLE);
209 tmp = g_strdup_printf (_("%s Properties"), name);
210 gtk_window_set_title (GTK_WINDOW (dialog), tmp);
211 g_free (tmp);
214 static void
215 rb_feed_podcast_properties_dialog_update_title_label (RBFeedPodcastPropertiesDialog *dialog)
217 const char *title;
219 title = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_TITLE);
220 gtk_label_set_text (GTK_LABEL (dialog->priv->title), title);
223 static void
224 rb_feed_podcast_properties_dialog_update_author (RBFeedPodcastPropertiesDialog *dialog)
226 const char *artist;
228 artist = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_ARTIST);
229 gtk_label_set_text (GTK_LABEL (dialog->priv->author), artist);
232 static void
233 rb_feed_podcast_properties_dialog_update_location (RBFeedPodcastPropertiesDialog *dialog)
235 const char *location;
236 char *unescaped;
238 location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
239 unescaped = gnome_vfs_unescape_string_for_display (location);
240 gtk_label_set_text (GTK_LABEL (dialog->priv->location), unescaped);
241 g_free (unescaped);
244 static void
245 rb_feed_podcast_properties_dialog_update_copyright (RBFeedPodcastPropertiesDialog *dialog)
247 const char *copyright;
249 copyright = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_COPYRIGHT);
250 gtk_label_set_text (GTK_LABEL (dialog->priv->copyright), copyright);
253 static void
254 rb_feed_podcast_properties_dialog_update_language (RBFeedPodcastPropertiesDialog *dialog)
256 const char *language;
258 language = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LANG);
259 gtk_label_set_text (GTK_LABEL (dialog->priv->language), language);
262 static void
263 rb_feed_podcast_properties_dialog_update_last_update (RBFeedPodcastPropertiesDialog *dialog)
265 char *time_str;
266 gulong time_val;
268 time_val = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_LAST_SEEN);
269 time_str = rb_feed_podcast_properties_dialog_parse_time (time_val);
270 gtk_label_set (GTK_LABEL (dialog->priv->last_update), time_str);
271 g_free (time_str);
274 static void
275 rb_feed_podcast_properties_dialog_update_last_episode (RBFeedPodcastPropertiesDialog *dialog)
277 char *time_str;
278 gulong time_val;
280 time_val = rhythmdb_entry_get_ulong (dialog->priv->current_entry, RHYTHMDB_PROP_POST_TIME);
281 time_str = rb_feed_podcast_properties_dialog_parse_time (time_val);
282 gtk_label_set (GTK_LABEL (dialog->priv->last_episode), time_str);
283 g_free (time_str);
286 static void
287 rb_feed_podcast_properties_dialog_update_summary (RBFeedPodcastPropertiesDialog *dialog)
289 const char *summary;
291 summary = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_SUMMARY);
292 gtk_label_set (GTK_LABEL (dialog->priv->summary), summary);
295 static char *
296 rb_feed_podcast_properties_dialog_parse_time (gulong value)
298 char *str;
300 if (0 == value) {
301 str = g_strdup (_("Unknown"));
302 } else {
303 str = rb_utf_friendly_time ((time_t)value);
306 return str;