#define POI_FONT_SIZE_BIG (10)
#define POI_FONT_SIZE_SMALL (8)
-/* Hash table for caching POI icons */
-static GHashTable *poi_icon_hash = NULL;
-
/* POI icon text pango stuff */
static PangoContext *context = NULL;
static PangoLayout *layout = NULL;
static PangoFontDescription *fontdesc = NULL;
static GdkGC *poi_gc;
-
-/* POI Icon theme. "classic" or "square". Should be made into a configuration option */
-static gchar *theme="square";
-
static GtkListStore *poi_store=NULL;
-
static gint last_zoom=-1;
static guint prev_ux=0, prev_uy=0;
gboolean
map_poi_init(GtkWidget *map_widget)
{
-poi_icon_hash=g_hash_table_new(g_str_hash, g_str_equal);
context=gtk_widget_get_pango_context(map_widget);
layout=pango_layout_new(context);
fontdesc=pango_font_description_new();
gdk_draw_layout(_map_pixmap, gc, x-(w>>1), y-h-_draw_width, layout);
}
-static GdkPixbuf *
-map_poi_get_icon(gchar *icon)
-{
-gchar buffer[100];
-GdkPixbuf *pixbuf;
-GError *error = NULL;
-
-if (icon==NULL)
- return NULL;
-
-g_snprintf(buffer, sizeof(buffer), DATADIR "/map-icons/%s.%s/%s.png",
- theme, (_zoom<2) ? "big" : "small", icon);
-
-pixbuf = g_hash_table_lookup(poi_icon_hash, buffer);
-if (pixbuf)
- return pixbuf;
-
-pixbuf=gdk_pixbuf_new_from_file(buffer, &error);
-
-if (error)
- return NULL;
-
-g_hash_table_insert(poi_icon_hash, g_strdup(buffer), pixbuf);
-return pixbuf;
-}
-
/**
* Set POI color from given #rrggbb string, fallback to default if it fails
*/
ITEM_COLOR, &color,
-1);
- pixbuf=map_poi_get_icon(icon);
+ pixbuf=poi_get_icon(icon, _zoom<2 ? TRUE : FALSE);
gc=map_set_poi_fg_color_from_string(color, _gc[COLORABLE_POI]);
latlon2unit(lat1, lon1, unitx, unity);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_edit = gtk_button_new_with_label(_("Edit")));
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), btn_add = gtk_button_new_with_label(_("Add")));
-store = poi_category_generate_store();
+store=poi_category_generate_store();
if (!store)
return TRUE;
-sw = gtk_scrolled_window_new(NULL, NULL);
+sw=gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, TRUE, TRUE, 0);
-tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+tree_view=gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
/* Maemo-related? */
g_object_set(tree_view, "allow-checkbox-mode", FALSE, NULL);
gtk_container_add(GTK_CONTAINER(sw), tree_view);
g_object_unref(G_OBJECT(store));
+renderer = gtk_cell_renderer_pixbuf_new();
+column = gtk_tree_view_column_new_with_attributes(_("Icon"), renderer, "pixbuf", CAT_ICON, NULL);
+gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Label"), renderer, "text", CAT_LABEL, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
static sqlite3 *poidb;
+/* POI Icon theme. "classic" or "square". Should be made into a configuration option */
+static gchar *theme="square";
+
+/* Hash table for caching POI icons */
+static GHashTable *poi_icon_hash = NULL;
+
struct _poi_categories {
node_type_t type;
const gchar *name, *desc, *icon, *color;
gboolean
poi_init(sqlite3 **db)
{
+if (!poi_icon_hash)
+ poi_icon_hash=g_hash_table_new(g_str_hash, g_str_equal);
+
if (!db || !*db)
return FALSE;
return NULL;
}
+GdkPixbuf *
+poi_get_icon(gchar *icon, gboolean big)
+{
+gchar buffer[100];
+GdkPixbuf *pixbuf;
+GError *error = NULL;
+
+if (icon==NULL)
+ return NULL;
+
+if (strlen(icon)==0)
+ return NULL;
+
+g_snprintf(buffer, sizeof(buffer), DATADIR "/map-icons/%s.%s/%s.png",
+ theme, (big==TRUE) ? "big" : "small", icon);
+
+pixbuf=g_hash_table_lookup(poi_icon_hash, buffer);
+if (pixbuf)
+ return pixbuf;
+
+pixbuf=gdk_pixbuf_new_from_file(buffer, &error);
+
+if (error)
+ return NULL;
+
+g_hash_table_insert(poi_icon_hash, g_strdup(buffer), pixbuf);
+return pixbuf;
+}
+
GtkListStore *
poi_category_generate_store(void)
{
if (!poidb)
return NULL;
-store=gtk_list_store_new(CAT_NUM_COLUMNS,
+store=gtk_list_store_new(CAT_NUM_COLUMNS, /* pixbuf */
G_TYPE_UINT,
G_TYPE_BOOLEAN,
G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_UINT);
+ G_TYPE_STRING,
+ G_TYPE_UINT,
+ GDK_TYPE_PIXBUF);
while (SQLITE_ROW == sqlite3_step(poisql.selall_cat)) {
gtk_list_store_append(store, &iter);
CAT_ENABLED, sqlite3_column_int(poisql.selall_cat, 3),
CAT_LABEL, sqlite3_column_text(poisql.selall_cat, 1),
CAT_DESC, sqlite3_column_text(poisql.selall_cat, 2),
- CAT_POI_CNT, sqlite3_column_int(poisql.selall_cat, 6), -1);
+ CAT_POI_CNT, sqlite3_column_int(poisql.selall_cat, 6),
+ CAT_ICON, poi_get_icon(sqlite3_column_text(poisql.selall_cat, 4),TRUE),
+ -1);
}
sqlite3_reset(poisql.selall_cat);
gboolean poi_category_update(guint cat_id, poi_category *c);
gboolean poi_category_toggle(guint cat_id, gboolean cat_enabled);
+GdkPixbuf *poi_get_icon(gchar *icon, gboolean big);
+
GtkListStore *poi_category_generate_store(void);
#endif