[balsa] Address-view: Set the "icon-name" property
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Address-view: Set the "icon-name" property
- Date: Sat, 17 Oct 2020 18:43:53 +0000 (UTC)
commit 404713ada916e9c2c6a0f9160a65e7c8ff3b4d82
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Oct 17 14:39:39 2020 -0400
Address-view: Set the "icon-name" property
of the GtkCellRendererPixbufs instead of the "pixbuf" property.
* libbalsa/address-view.c (lbav_button_activated), (libbalsa_address_view_new):
the icon column is now G_TYPE_STRING instead of GDK_TYPE_PIXBUF;
(libbalsa_address_view_set_book_icon),
(libbalsa_address_view_set_close_icon),
(libbalsa_address_view_set_drop_down_icon): the parameter is a string, not a pixbuf;
* libbalsa/address-view.h: ditto;
* src/balsa-icons.c (balsa_register_pixmaps), (balsa_register_pixbufs):
register the address-view icons by name instead of pixbuf.
ChangeLog | 15 +++++++++++++
libbalsa/address-view.c | 30 ++++++++++++-------------
libbalsa/address-view.h | 6 ++---
src/balsa-icons.c | 58 +++++++++++++++++++++++++++----------------------
4 files changed, 65 insertions(+), 44 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 01e6d80d0..d93d366ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2020-10-17 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Address-view: Set the "icon-name" property of the
+ GtkCellRendererPixbufs instead of the "pixbuf" property.
+
+ * libbalsa/address-view.c (lbav_button_activated), (libbalsa_address_view_new):
+ the icon column is now G_TYPE_STRING instead of GDK_TYPE_PIXBUF;
+ (libbalsa_address_view_set_book_icon),
+ (libbalsa_address_view_set_close_icon),
+ (libbalsa_address_view_set_drop_down_icon): the parameter is a
+ string, not a pixbuf;
+ * libbalsa/address-view.h: ditto;
+ * src/balsa-icons.c (balsa_register_pixmaps),
+ (balsa_register_pixbufs): register the address-view icons by name instead of pixbuf.
+
2020-09-23 Peter Bloomfield <pbloomfield bellsouth net>
Remove LibBalsaCellRendererButton
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 11f0b3d3c..8ef5cbe1a 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -160,8 +160,8 @@ const gchar *const libbalsa_address_view_types[] = {
N_("Reply To:"),
};
-/* Pixbufs */
-static GdkPixbuf *lbav_book_icon, *lbav_close_icon, *lbav_drop_down_icon;
+/* Icon names */
+static const char *lbav_book_icon, *lbav_close_icon, *lbav_drop_down_icon;
/*
* Helpers
@@ -843,15 +843,15 @@ lbav_button_activated(LibBalsaAddressView *address_view,
GtkTreeView *tree_view = GTK_TREE_VIEW(address_view);
GtkTreeModel *model = gtk_tree_view_get_model(tree_view);
GtkTreeIter iter;
- GdkPixbuf *pixbuf;
+ char *icon_name;
if (!gtk_tree_model_get_iter(model, &iter, path)) {
return;
}
- gtk_tree_model_get(model, &iter, ADDRESS_ICON_COL, &pixbuf, -1);
+ gtk_tree_model_get(model, &iter, ADDRESS_ICON_COL, &icon_name, -1);
- if (pixbuf == lbav_close_icon) {
+ if (strcmp(icon_name, lbav_close_icon) == 0) {
/* User clicked a remove button. */
GtkListStore *address_store = GTK_LIST_STORE(model);
guint type;
@@ -871,7 +871,7 @@ lbav_button_activated(LibBalsaAddressView *address_view,
gtk_tree_row_reference_free(row_ref);
}
- g_object_unref(pixbuf);
+ g_free(icon_name);
}
/*
@@ -968,7 +968,7 @@ libbalsa_address_view_new(const gchar * const *types,
/* ADDRESS_NAME_COL: */
G_TYPE_STRING,
/* ADDRESS_ICON_COL: */
- GDK_TYPE_PIXBUF);
+ G_TYPE_STRING);
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE
(address_store),
@@ -999,7 +999,7 @@ libbalsa_address_view_new(const gchar * const *types,
renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column, renderer, FALSE);
gtk_tree_view_column_set_attributes(column, renderer,
- "pixbuf", ADDRESS_ICON_COL,
+ "icon-name", ADDRESS_ICON_COL,
NULL);
gtk_tree_view_append_column(tree_view, column);
@@ -1042,7 +1042,7 @@ libbalsa_address_view_new(const gchar * const *types,
* combo: */
address_view->dropdown_column = column = gtk_tree_view_column_new();
renderer = gtk_cell_renderer_pixbuf_new();
- g_object_set(renderer, "pixbuf", lbav_drop_down_icon, NULL);
+ g_object_set(renderer, "icon-name", lbav_drop_down_icon, NULL);
gtk_tree_view_column_pack_start(column, renderer, FALSE);
gtk_tree_view_append_column(tree_view, column);
@@ -1255,25 +1255,25 @@ libbalsa_address_view_get_list(LibBalsaAddressView * address_view,
}
void
-libbalsa_address_view_set_book_icon(GdkPixbuf * icon)
+libbalsa_address_view_set_book_icon(const char * icon)
{
- g_return_if_fail(GDK_IS_PIXBUF(icon));
+ g_return_if_fail(icon != NULL);
lbav_book_icon = icon;
}
void
-libbalsa_address_view_set_close_icon(GdkPixbuf * icon)
+libbalsa_address_view_set_close_icon(const char * icon)
{
- g_return_if_fail(GDK_IS_PIXBUF(icon));
+ g_return_if_fail(icon != NULL);
lbav_close_icon = icon;
}
void
-libbalsa_address_view_set_drop_down_icon(GdkPixbuf * icon)
+libbalsa_address_view_set_drop_down_icon(const char * icon)
{
- g_return_if_fail(GDK_IS_PIXBUF(icon));
+ g_return_if_fail(icon != NULL);
lbav_drop_down_icon = icon;
}
diff --git a/libbalsa/address-view.h b/libbalsa/address-view.h
index 21117c747..570543a04 100644
--- a/libbalsa/address-view.h
+++ b/libbalsa/address-view.h
@@ -62,9 +62,9 @@ InternetAddressList *libbalsa_address_view_get_list(LibBalsaAddressView *
const gchar *
address_type);
-void libbalsa_address_view_set_book_icon(GdkPixbuf * book_icon);
-void libbalsa_address_view_set_close_icon(GdkPixbuf * close_icon);
-void libbalsa_address_view_set_drop_down_icon(GdkPixbuf * drop_down_icon);
+void libbalsa_address_view_set_book_icon(const char * book_icon);
+void libbalsa_address_view_set_close_icon(const char * close_icon);
+void libbalsa_address_view_set_drop_down_icon(const char * drop_down_icon);
G_END_DECLS
#endif /* __LIBBALSA_ADDRESS_VIEW_H__ */
diff --git a/src/balsa-icons.c b/src/balsa-icons.c
index 084f3898f..4057d8f7a 100644
--- a/src/balsa-icons.c
+++ b/src/balsa-icons.c
@@ -131,7 +131,6 @@ balsa_register_pixmaps(void)
/* the following book icons aren't strictly necessary as Gnome provides
them. However, this simplifies porting balsa if the Gnome libs
aren't present... */
- { BALSA_PIXMAP_BOOK_RED, "stock_book_red" },
{ BALSA_PIXMAP_BOOK_YELLOW, "stock_book_yellow" },
{ BALSA_PIXMAP_BOOK_GREEN, "stock_book_green" },
{ BALSA_PIXMAP_BOOK_BLUE, "stock_book_blue" },
@@ -162,9 +161,6 @@ balsa_register_pixmaps(void)
{ BALSA_PIXMAP_INFO_REPLIED, "mail-replied" },
{ BALSA_PIXMAP_INFO_NEW, "mail-unread" },
{ BALSA_PIXMAP_INFO_FLAGGED, "emblem-important" },
-
- /* drop-down icon for the address-view (16x16) */
- { BALSA_PIXMAP_DROP_DOWN, "pan-down-symbolic" },
};
unsigned i;
@@ -191,32 +187,38 @@ void
balsa_register_pixbufs(GtkWidget * widget)
{
static struct {
- void (*set_icon) (GdkPixbuf *);
- const gchar *icon;
- } icons[] = {
- {
- libbalsa_mailbox_set_unread_icon, BALSA_PIXMAP_INFO_NEW}, {
- libbalsa_mailbox_set_trash_icon, BALSA_PIXMAP_INFO_DELETED}, {
- libbalsa_mailbox_set_flagged_icon, BALSA_PIXMAP_INFO_FLAGGED}, {
- libbalsa_mailbox_set_replied_icon, BALSA_PIXMAP_INFO_REPLIED}, {
- libbalsa_mailbox_set_attach_icon, BALSA_PIXMAP_INFO_ATTACHMENT}, {
- libbalsa_mailbox_set_good_icon, BALSA_PIXMAP_SIGN_GOOD}, {
- libbalsa_mailbox_set_notrust_icon, BALSA_PIXMAP_SIGN_NOTRUST}, {
- libbalsa_mailbox_set_bad_icon, BALSA_PIXMAP_SIGN_BAD}, {
- libbalsa_mailbox_set_sign_icon, BALSA_PIXMAP_SIGN}, {
- libbalsa_mailbox_set_encr_icon, BALSA_PIXMAP_ENCR}, {
- libbalsa_address_view_set_book_icon, BALSA_PIXMAP_BOOK_RED}, {
- libbalsa_address_view_set_close_icon, "window-close-symbolic"}, {
- libbalsa_address_view_set_drop_down_icon, BALSA_PIXMAP_DROP_DOWN},
+ void (*set_icon_pixbuf) (GdkPixbuf *);
+ const char *icon;
+ } icon_pixbufs[] = {
+ {libbalsa_mailbox_set_unread_icon, BALSA_PIXMAP_INFO_NEW},
+ {libbalsa_mailbox_set_trash_icon, BALSA_PIXMAP_INFO_DELETED},
+ {libbalsa_mailbox_set_flagged_icon, BALSA_PIXMAP_INFO_FLAGGED},
+ {libbalsa_mailbox_set_replied_icon, BALSA_PIXMAP_INFO_REPLIED},
+ {libbalsa_mailbox_set_attach_icon, BALSA_PIXMAP_INFO_ATTACHMENT},
+ {libbalsa_mailbox_set_good_icon, BALSA_PIXMAP_SIGN_GOOD},
+ {libbalsa_mailbox_set_notrust_icon, BALSA_PIXMAP_SIGN_NOTRUST},
+ {libbalsa_mailbox_set_bad_icon, BALSA_PIXMAP_SIGN_BAD},
+ {libbalsa_mailbox_set_sign_icon, BALSA_PIXMAP_SIGN},
+ {libbalsa_mailbox_set_encr_icon, BALSA_PIXMAP_ENCR},
+ };
+
+ static struct {
+ void (*set_icon_name) (const char *);
+ const char *icon;
+ } icon_names[] = {
+ {libbalsa_address_view_set_book_icon, "stock_book_red"},
+ {libbalsa_address_view_set_close_icon, "window-close-symbolic"},
+ {libbalsa_address_view_set_drop_down_icon, "pan-down-symbolic"},
};
- guint i;
+
+ unsigned i;
GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
- for (i = 0; i < G_N_ELEMENTS(icons); i++) {
+ for (i = 0; i < G_N_ELEMENTS(icon_pixbufs); i++) {
GdkPixbuf *pixbuf;
GError *err = NULL;
- gint width, height;
- const gchar *use_id = balsa_icon_id(icons[i].icon);
+ int width, height;
+ const char *use_id = balsa_icon_id(icon_pixbufs[i].icon);
if (use_id == NULL) /* No icon table */
break;
@@ -230,9 +232,13 @@ balsa_register_pixbufs(GtkWidget * widget)
width, err->message);
g_clear_error(&err);
} else {
- icons[i].set_icon(pixbuf);
+ icon_pixbufs[i].set_icon_pixbuf(pixbuf);
}
}
+
+ for (i = 0; i < G_N_ELEMENTS(icon_names); i++) {
+ icon_names[i].set_icon_name(icon_names[i].icon);
+ }
}
const gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]