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.
28 #include <glib/gi18n.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"
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
,
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
63 RhythmDBEntry
*current_entry
;
69 GtkWidget
*last_update
;
70 GtkWidget
*last_episode
;
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))
85 G_DEFINE_TYPE (RBFeedPodcastPropertiesDialog
, rb_feed_podcast_properties_dialog
, GTK_TYPE_DIALOG
)
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
));
98 rb_feed_podcast_properties_dialog_init (RBFeedPodcastPropertiesDialog
*dialog
)
102 dialog
->priv
= RB_FEED_PODCAST_PROPERTIES_DIALOG_GET_PRIVATE (dialog
);
104 g_signal_connect_object (G_OBJECT (dialog
),
106 G_CALLBACK (rb_feed_podcast_properties_dialog_response_cb
),
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",
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
),
126 gtk_dialog_set_default_response (GTK_DIALOG (dialog
),
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
));
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
);
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
);
180 rb_feed_podcast_properties_dialog_response_cb (GtkDialog
*gtkdialog
,
182 RBFeedPodcastPropertiesDialog
*dialog
)
184 gtk_widget_destroy (GTK_WIDGET (dialog
));
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
);
204 rb_feed_podcast_properties_dialog_update_title (RBFeedPodcastPropertiesDialog
*dialog
)
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
);
215 rb_feed_podcast_properties_dialog_update_title_label (RBFeedPodcastPropertiesDialog
*dialog
)
219 title
= rhythmdb_entry_get_string (dialog
->priv
->current_entry
, RHYTHMDB_PROP_TITLE
);
220 gtk_label_set_text (GTK_LABEL (dialog
->priv
->title
), title
);
224 rb_feed_podcast_properties_dialog_update_author (RBFeedPodcastPropertiesDialog
*dialog
)
228 artist
= rhythmdb_entry_get_string (dialog
->priv
->current_entry
, RHYTHMDB_PROP_ARTIST
);
229 gtk_label_set_text (GTK_LABEL (dialog
->priv
->author
), artist
);
233 rb_feed_podcast_properties_dialog_update_location (RBFeedPodcastPropertiesDialog
*dialog
)
235 const char *location
;
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
);
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
);
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
);
263 rb_feed_podcast_properties_dialog_update_last_update (RBFeedPodcastPropertiesDialog
*dialog
)
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
);
275 rb_feed_podcast_properties_dialog_update_last_episode (RBFeedPodcastPropertiesDialog
*dialog
)
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
);
287 rb_feed_podcast_properties_dialog_update_summary (RBFeedPodcastPropertiesDialog
*dialog
)
291 summary
= rhythmdb_entry_get_string (dialog
->priv
->current_entry
, RHYTHMDB_PROP_SUMMARY
);
292 gtk_label_set (GTK_LABEL (dialog
->priv
->summary
), summary
);
296 rb_feed_podcast_properties_dialog_parse_time (gulong value
)
301 str
= g_strdup (_("Unknown"));
303 str
= rb_utf_friendly_time ((time_t)value
);