Skip to content

Commit

Permalink
Improving Github lwindolf#28: Use large icons in wide view. Drop stat…
Browse files Browse the repository at this point in the history
…e column and add red important label within title. Refactor icon loading for large icon support.
  • Loading branch information
lwindolf authored and rich-coe committed Feb 7, 2016
1 parent 5f8c735 commit 80f20c9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file export.c OPML feed list import & export
*
* Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
* Copyright (C) 2004-2012 Lars Windolf <lars.windolf@gmx.de>
* Copyright (C) 2004-2015 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -327,7 +327,7 @@ import_parse_outline (xmlNodePtr cur, nodePtr parentNode, gboolean trusted)
node->expanded = TRUE;

/* 3. Try to load the favicon (needs to be done before adding to the feed list) */
node_set_icon (node, favicon_load_from_cache (node->id));
node_load_icon (node);

/* 4. add to GUI parent */
feedlist_node_imported (node);
Expand Down
7 changes: 5 additions & 2 deletions src/favicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file favicon.c Liferea favicon handling
*
* Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
* Copyright (C) 2015 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -68,7 +69,9 @@ favicon_download_ctxt_free (faviconDownloadCtxtPtr ctxt)

static void favicon_download_run(faviconDownloadCtxtPtr ctxt);

GdkPixbuf * favicon_load_from_cache(const gchar *id) {
GdkPixbuf *
favicon_load_from_cache (const gchar *id, guint size)
{
struct stat statinfo;
gchar *filename;
GdkPixbuf *pixbuf, *result = NULL;
Expand All @@ -82,7 +85,7 @@ GdkPixbuf * favicon_load_from_cache(const gchar *id) {
if(0 == stat((const char*)filename, &statinfo)) {
pixbuf = gdk_pixbuf_new_from_file(filename, &error);
if(pixbuf) {
result = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
result = gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR);
g_object_unref(pixbuf);
} else { /* Error */
fprintf(stderr, "Failed to load pixbuf file: %s: %s\n",
Expand Down
4 changes: 3 additions & 1 deletion src/favicon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file favicon.h Liferea favicon handling
*
* Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
* Copyright (C) 2015 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,10 +32,11 @@
* Tries to load a given favicon from cache.
*
* @param id the favicon id
* @param size width / height in pixel
*
* @returns a pixmap (or NULL)
*/
GdkPixbuf * favicon_load_from_cache(const gchar *id);
GdkPixbuf * favicon_load_from_cache (const gchar *id, guint size);

/**
* Removes a given favicon from the favicon cache.
Expand Down
19 changes: 15 additions & 4 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ node_new (nodeTypePtr type)
node->sortColumn = NODE_VIEW_SORT_BY_TIME;
node->sortReversed = TRUE; /* default sorting is newest date at top */
node->available = TRUE;
node_set_icon (node, NULL); /* initialize favicon file name */

id = node_new_id ();
node_set_id (node, id);
Expand Down Expand Up @@ -401,14 +400,20 @@ node_get_title (nodePtr node)
}

void
node_set_icon (nodePtr node, gpointer icon)
node_load_icon (nodePtr node)
{
/* Load pixbuf for all widget based rendering */
if (node->icon)
g_object_unref (node->icon);
node->icon = icon;
if (node->largeIcon)
g_object_unref (node->largeIcon);

node->icon = favicon_load_from_cache (node->id, 16);
node->largeIcon = favicon_load_from_cache (node->id, 32);

/* Create filename for HTML rendering */
g_free (node->iconFile);

if (node->icon)
node->iconFile = common_create_cache_filename ("favicons", node->id, "png");
else
Expand All @@ -425,6 +430,12 @@ node_get_icon (nodePtr node)
return node->icon;
}

gpointer
node_get_large_icon (nodePtr node)
{
return node->largeIcon;
}

const gchar *
node_get_favicon_file (nodePtr node)
{
Expand Down
15 changes: 12 additions & 3 deletions src/node.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file node.h hierarchic feed list node interface
*
* Copyright (C) 2003-2010 Lars Windolf <lars.windolf@gmx.de>
* Copyright (C) 2003-2015 Lars Windolf <lars.windolf@gmx.de>
* Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -57,7 +57,8 @@ typedef struct node {
guint newCount; /**< number of recently downloaded items */

gchar *title; /**< the label of the node in the feed list */
gpointer icon; /**< pointer to pixmap, if there is a favicon */
gpointer icon; /**< 16x16 favicon GdkPixBuf (or NULL) */
gpointer largeIcon; /**< 32x32 favicon GdkPixBuf (or NULL) */
gboolean available; /**< availability of this node (usually the last downloading state) */
gboolean expanded; /**< expansion state (for nodes with childs) */

Expand Down Expand Up @@ -229,7 +230,15 @@ void node_set_icon(nodePtr node, gpointer icon);
*
* @returns a pixmap or NULL
*/
gpointer node_get_icon(nodePtr node);
gpointer node_get_icon (nodePtr node);

/**
* Returns a large icon for the node. Does not return any default
* icons like node_get_icon() does.
*
* @returns a pixmap or NULL
*/
gpointer node_get_large_icon (nodePtr node);

/**
* Returns the name of the favicon cache file for the given node.
Expand Down
4 changes: 2 additions & 2 deletions src/subscription.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file subscription.c common subscription handling
*
* Copyright (C) 2003-2012 Lars Windolf <lars.windolf@gmx.de>
* Copyright (C) 2003-2015 Lars Windolf <lars.windolf@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -133,7 +133,7 @@ subscription_favicon_downloaded (gpointer user_data)
{
nodePtr node = (nodePtr)user_data;

node_set_icon (node, favicon_load_from_cache (node->id));
node_load_icon (node);
feed_list_node_update (node->id);
}

Expand Down
32 changes: 21 additions & 11 deletions src/ui/item_list_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ struct ItemListViewPrivate {
GtkTreeStore *batch_itemstore; /**< GtkTreeStore prepared unattached and to be set on update() */

GtkTreeViewColumn *enclosureColumn;
GtkTreeViewColumn *faviconColumn;

gboolean dateHidden; /**< TRUE if date has to be rendered into headline column (because date column is invisible) */
gboolean wideView; /**< TRUE if date has to be rendered into headline column (because date column is invisible) */
};

static GObjectClass *parent_class = NULL;
Expand Down Expand Up @@ -436,6 +437,7 @@ item_list_view_update_item (ItemListView *ilv, itemPtr item)
GtkTreeIter iter;
gchar *title, *time_str;
const GdkPixbuf *state_icon;
const gchar *important = " <span background='red' color='black'> important </span> ";

if (!item_list_view_id_to_iter (ilv, item->id, &iter))
return;
Expand All @@ -445,13 +447,14 @@ item_list_view_update_item (ItemListView *ilv, itemPtr item)
title = item->title && strlen (item->title) ? item->title : _("*** No title ***");
title = g_strstrip (g_markup_escape_text (title, -1));

if (ilv->priv->dateHidden) {
if (ilv->priv->wideView) {
/* Append date to headline on hidden date column */
gchar *tmp = title;
title = g_strdup_printf ("%s%s%s <span size='smaller'>--- (%s)</span>",
(FALSE == item->readStatus)?"<span weight='bold'>":"",
title = g_strdup_printf ("%s<span size='larger'>%s</span>%s %s<span size='smaller'>--- (%s)</span>",
!item->readStatus?"<span weight='bold'>":"",
title,
(FALSE == item->readStatus)?"</span>":"",
item->flagStatus?important:"",
time_str);
g_free (tmp);
}
Expand Down Expand Up @@ -691,12 +694,16 @@ item_list_view_create (gboolean wide)

ilscrolledwindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (ilscrolledwindow);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
if (wide)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
else
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (ilscrolledwindow), GTK_SHADOW_IN);

ilv->priv->treeview = GTK_TREE_VIEW (gtk_tree_view_new ());
if (wide) {
gtk_tree_view_set_fixed_height_mode (ilv->priv->treeview, FALSE);
gtk_tree_view_set_headers_visible (ilv->priv->treeview, FALSE);
gtk_tree_view_set_grid_lines (ilv->priv->treeview, GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
}
gtk_container_add (GTK_CONTAINER (ilscrolledwindow), GTK_WIDGET (ilv->priv->treeview));
Expand All @@ -710,6 +717,8 @@ item_list_view_create (gboolean wide)
column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_STATEICON, NULL);
gtk_tree_view_append_column (ilv->priv->treeview, column);
gtk_tree_view_column_set_sort_column_id (column, IS_STATE);
if (wide)
gtk_tree_view_column_set_visible (column, FALSE);

renderer = gtk_cell_renderer_pixbuf_new ();
column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_ENCICON, NULL);
Expand All @@ -725,13 +734,14 @@ item_list_view_create (gboolean wide)
g_object_set (column, "resizable", TRUE, NULL);
if (wide) {
gtk_tree_view_column_set_visible (column, FALSE);
ilv->priv->dateHidden = TRUE;
ilv->priv->wideView = TRUE;
}

renderer = gtk_cell_renderer_pixbuf_new ();
column = gtk_tree_view_column_new_with_attributes ("", renderer, "pixbuf", IS_FAVICON, NULL);
gtk_tree_view_column_set_sort_column_id (column, IS_SOURCE);
gtk_tree_view_append_column (ilv->priv->treeview, column);
ilv->priv->faviconColumn = column;

renderer = gtk_cell_renderer_text_new ();
headline_column = gtk_tree_view_column_new_with_attributes (_("Headline"), renderer,
Expand Down Expand Up @@ -794,7 +804,7 @@ item_list_view_add_item_to_tree_store (ItemListView *ilv, GtkTreeStore *itemstor
IS_TIME, (guint64)item->time,
IS_NR, item->id,
IS_PARENT, node,
IS_FAVICON, node->icon,
IS_FAVICON, ilv->priv->wideView?node_get_large_icon (node):node_get_icon (node),
IS_ENCICON, item->hasEnclosure?icon_get (ICON_ENCLOSURE):NULL,
IS_ENCLOSURE, item->hasEnclosure,
IS_SOURCE, node,
Expand Down Expand Up @@ -822,25 +832,25 @@ item_list_view_add_item (ItemListView *ilv, itemPtr item)
void
item_list_view_enable_favicon_column (ItemListView *ilv, gboolean enabled)
{
gtk_tree_view_column_set_visible (ilv->priv->enclosureColumn, enabled);
gtk_tree_view_column_set_visible (ilv->priv->faviconColumn, enabled);
}

void
on_popup_launch_item_selected (void)
{
launch_item_selected (INTERNAL);
launch_item_selected (INTERNAL);
}

void
on_popup_launch_item_in_tab_selected (void)
{
launch_item_selected (TAB);
launch_item_selected (TAB);
}

void
on_popup_launch_item_external_selected (void)
{
launch_item_selected (EXTERNAL);
launch_item_selected (EXTERNAL);
}

/* menu callbacks */
Expand Down
8 changes: 6 additions & 2 deletions src/ui/liferea_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct LifereaShellPrivate {
guint statusbarLockTimer; /**< timer id for status bar lock reset timer */

GtkWidget *statusbar_feedsinfo;
GtkWidget *statusbar_feedsinfo_evbox;
GtkActionGroup *generalActions;
GtkActionGroup *addActions; /**< all types of "New" options */
GtkActionGroup *feedActions; /**< update and mark read */
Expand Down Expand Up @@ -1281,9 +1282,12 @@ liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState)
shell->priv->statusbar = GTK_STATUSBAR (liferea_shell_lookup ("statusbar"));
shell->priv->statusbarLocked = FALSE;
shell->priv->statusbarLockTimer = 0;
shell->priv->statusbar_feedsinfo_evbox = gtk_event_box_new ();
shell->priv->statusbar_feedsinfo = gtk_label_new("");
gtk_widget_show(shell->priv->statusbar_feedsinfo);
gtk_box_pack_start (GTK_BOX (shell->priv->statusbar), shell->priv->statusbar_feedsinfo, FALSE, FALSE, 5);
gtk_container_add (GTK_CONTAINER (shell->priv->statusbar_feedsinfo_evbox), shell->priv->statusbar_feedsinfo);
gtk_widget_show_all (shell->priv->statusbar_feedsinfo_evbox);
gtk_box_pack_start (GTK_BOX (shell->priv->statusbar), shell->priv->statusbar_feedsinfo_evbox, FALSE, FALSE, 5);
g_signal_connect (G_OBJECT (shell->priv->statusbar_feedsinfo_evbox), "button_release_event", G_CALLBACK (on_next_unread_item_activate), NULL);

/* 4.) setup tabs */

Expand Down

0 comments on commit 80f20c9

Please sign in to comment.