From 63f1f379ca90e1aae107376270efe31edc49a1c6 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 4 Feb 2008 17:18:00 +0200 Subject: [PATCH] Use POI icons in the quick POI buttons --- src/poi-gui.c | 10 +++++++--- src/poi.c | 14 +++++++++++++- src/poi.h | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/poi-gui.c b/src/poi-gui.c index 33e4f03..4d53852 100644 --- a/src/poi-gui.c +++ b/src/poi-gui.c @@ -1035,13 +1035,17 @@ gtk_table_set_homogeneous(GTK_TABLE(table), TRUE); for (x=0;x<3;x++) { for (y=0;y<3;y++) { guint p=x+y*3; + const gchar *iname; GdkPixbuf *icon=NULL; buttons[p]=gtk_button_new_with_label(quick_poi_categories[p].name); - /* XXX: Add code to get the icon */ - if (icon) { + + iname=poi_get_icon_from_type(quick_poi_categories[p].type); + if (iname) + icon=poi_get_icon(iname, TRUE); + if (icon) gtk_button_set_image(buttons[p], gtk_image_new_from_pixbuf(icon)); - } + gtk_table_attach(GTK_TABLE(table), buttons[p], x, x+1, y, y+1, GTK_FILL, 0, 2, 4); g_signal_connect(G_OBJECT(buttons[p]), "clicked", G_CALLBACK(poi_quick_button_cb), GINT_TO_POINTER(quick_poi_categories[p].type)); } diff --git a/src/poi.c b/src/poi.c index 90671d1..eb291e4 100644 --- a/src/poi.c +++ b/src/poi.c @@ -127,7 +127,7 @@ static gboolean poi_populate_categories(sqlite3 *db) { sqlite3_stmt *sql_cat; -gint i; +guint i; sqlite3_prepare_v2(db,"insert or replace into category (cat_id, label, desc, enabled, priority, icon, color)" " values (?, ?, ?, 1, ?, ?, ?)", @@ -151,6 +151,18 @@ sqlite3_finalize(sql_cat); return TRUE; } +const gchar * +poi_get_icon_from_type(gint t) +{ +guint i; + +for (i=0; default_poi_categories[i].name; i++) { + if (t==default_poi_categories[i].type) + return default_poi_categories[i].icon; +} +return NULL; +} + gboolean poi_db_create(sqlite3 *db) { diff --git a/src/poi.h b/src/poi.h index b30e234..b027151 100644 --- a/src/poi.h +++ b/src/poi.h @@ -136,6 +136,8 @@ gboolean poi_category_toggle(guint cat_id, gboolean cat_enabled); GdkPixbuf *poi_get_icon(gchar *icon, gboolean big); +const gchar *poi_get_icon_from_type(gint t); + GtkListStore *poi_category_generate_store(void); #endif -- 2.39.5