Display feed URLs and show an icon instead of error dialogues

This commit is contained in:
Dale Whittaker 2009-04-27 20:58:30 +02:00 committed by Christian Dywan
parent 6d2013f16f
commit 129f7d8f77
2 changed files with 56 additions and 59 deletions

View file

@ -89,9 +89,17 @@ feed_panel_treeview_render_icon_cb (GtkTreeViewColumn* column,
pitem = item; pitem = item;
uri = katze_item_get_uri (pitem); uri = katze_item_get_uri (pitem);
pixbuf = katze_net_load_icon (panel->net, uri, NULL, NULL, NULL); if (uri)
if (!pixbuf) {
pixbuf = panel->pixbuf; pixbuf = katze_net_load_icon (panel->net, uri, NULL, NULL, NULL);
if (!pixbuf)
pixbuf = panel->pixbuf;
}
else
{
pixbuf = gtk_widget_render_icon (panel->treeview,
GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, NULL);
}
g_object_set (renderer, "pixbuf", pixbuf, NULL); g_object_set (renderer, "pixbuf", pixbuf, NULL);
@ -339,41 +347,47 @@ feed_panel_cursor_or_row_changed_cb (GtkTreeView* treeview,
const gchar* text; const gchar* text;
gtk_tree_model_get (model, &iter, 0, &item, -1); gtk_tree_model_get (model, &iter, 0, &item, -1);
uri = katze_item_get_uri (item); uri = katze_item_get_uri (item);
if (uri) if (KATZE_IS_ARRAY (item))
{ {
if (KATZE_IS_ARRAY (item)) gint64 date;
{
gint64 date;
SoupDate* sdate;
text = NULL; text = NULL;
if (!uri)
text = g_strdup (katze_item_get_text (KATZE_ITEM (item)));
else
{
date = katze_item_get_added (item); date = katze_item_get_added (item);
if (date) if (date)
{ {
SoupDate* sdate;
const gchar* suri;
sdate = soup_date_new_from_time_t ((time_t) date); sdate = soup_date_new_from_time_t ((time_t) date);
text = g_strdup_printf ("Last updated %s.", soup_date_to_string (sdate, SOUP_DATE_HTTP)); suri = (const gchar*)g_object_get_data (G_OBJECT (item), "feeduri");
text = g_strdup_printf (
"<html><head><title>feed</title></head>"
"<body><h3>%s</h3><p />Last updated %s.</body></html>",
suri, soup_date_to_string (sdate, SOUP_DATE_HTTP));
soup_date_free (sdate); soup_date_free (sdate);
} }
webkit_web_view_load_html_string ( }
WEBKIT_WEB_VIEW (panel->webview), text ? text : "", uri); webkit_web_view_load_html_string (
g_free ((gchar*) text); WEBKIT_WEB_VIEW (panel->webview), text ? text : "", uri);
g_free ((gchar*) text);
sensitive = TRUE; sensitive = TRUE;
}
else
{
text = katze_item_get_text (item);
if (text)
{
webkit_web_view_load_html_string (
WEBKIT_WEB_VIEW (panel->webview), text, uri);
}
}
g_object_unref (item);
} }
else
{
text = katze_item_get_text (item);
if (text)
{
webkit_web_view_load_html_string (
WEBKIT_WEB_VIEW (panel->webview), text, uri);
}
}
g_object_unref (item);
} }
if (GTK_IS_WIDGET (panel->delete)) if (GTK_IS_WIDGET (panel->delete))
gtk_widget_set_sensitive (panel->delete, sensitive); gtk_widget_set_sensitive (panel->delete, sensitive);

View file

@ -141,28 +141,12 @@ static void
feed_handle_net_error (FeedNetPrivate* netpriv, feed_handle_net_error (FeedNetPrivate* netpriv,
const gchar* msg) const gchar* msg)
{ {
GtkWidget* dialog; const gchar* uri;
dialog = gtk_message_dialog_new ( uri = (gchar*) g_object_get_data (G_OBJECT (netpriv->feed), "feeduri");
NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, katze_item_set_name (KATZE_ITEM (netpriv->feed), uri);
_("Error")); katze_item_set_text (KATZE_ITEM (netpriv->feed), msg);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), katze_item_set_uri (KATZE_ITEM (netpriv->feed), NULL);
"%s", msg);
gtk_window_set_title (GTK_WINDOW (dialog), EXTENSION_NAME);
gtk_widget_show (dialog);
g_signal_connect_swapped (dialog, "response",
G_CALLBACK (gtk_widget_destroy), dialog);
if (feed_has_flags (netpriv->feed, FEED_NEW))
{
KatzeArray* parent;
KatzeItem* child;
child = KATZE_ITEM (netpriv->feed);
parent = katze_item_get_parent (child);
katze_array_remove_item (parent, child);
feed_save_items (netpriv->extension, parent);
}
feed_remove_flags (netpriv->feed, FEED_READ); feed_remove_flags (netpriv->feed, FEED_READ);
} }
@ -206,20 +190,18 @@ feed_transfer_cb (KatzeNetRequest* request,
feed_handle_net_error (netpriv, error->message); feed_handle_net_error (netpriv, error->message);
g_error_free (error); g_error_free (error);
} }
else
{
if (feed_has_flags (netpriv->feed, FEED_REMOVE))
{
KatzeArray* parent;
/* deferred remove */ if (feed_has_flags (netpriv->feed, FEED_REMOVE))
parent = katze_item_get_parent (KATZE_ITEM (netpriv->feed)); {
katze_array_remove_item (parent, netpriv->feed); KatzeArray* parent;
feed_save_items (netpriv->extension, parent);
} /* deferred remove */
else parent = katze_item_get_parent (KATZE_ITEM (netpriv->feed));
feed_set_flags (netpriv->feed, 0); katze_array_remove_item (parent, netpriv->feed);
feed_save_items (netpriv->extension, parent);
} }
else
feed_set_flags (netpriv->feed, 0);
} }
netpriv->parsers = NULL; netpriv->parsers = NULL;
@ -415,6 +397,7 @@ feed_app_add_browser_cb (MidoriApp* app,
update_feed (priv, KATZE_ITEM (feed)); update_feed (priv, KATZE_ITEM (feed));
} }
} }
g_strdupv (sfeeds);
action_group = midori_browser_get_action_group (browser); action_group = midori_browser_get_action_group (browser);
action = gtk_action_group_get_action (action_group, "Location"); action = gtk_action_group_get_action (action_group, "Location");