static void update_marker_image (ChamplainLabel *marker, GtkIconSize size) { GtkWidget *widget; ClutterActor *thumb; widget = gtk_button_new (); thumb = gtk_clutter_texture_new (); gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (thumb), widget, "image-x-generic", size, NULL); /* don't need to unref widget because it is floating */ champlain_label_set_image (marker, thumb); }
static void show_text_markers (ClutterActor *actor, ClutterEvent *event, PhidiasItemsGeo *item) { GList *markers; GList *iter; ChamplainLabel *m; if (item->priv->show_text == TRUE) return; markers = g_hash_table_get_values (item->priv->markers); for (iter = markers; iter; iter = g_list_next (iter)) { m = CHAMPLAIN_LABEL (iter->data); champlain_label_set_image (m, NULL); champlain_label_set_font_name (m, "Serif 9"); } g_list_free (markers); item->priv->show_text = TRUE; }
static void show_point_markers (ClutterActor *actor, ClutterEvent *event, PhidiasItemsGeo *item) { GList *markers; GList *iter; ClutterActor *icon; ChamplainLabel *m; if (item->priv->show_text == FALSE) return; markers = g_hash_table_get_values (item->priv->markers); for (iter = markers; iter; iter = g_list_next (iter)) { m = CHAMPLAIN_LABEL (iter->data); icon = g_object_get_data (G_OBJECT (m), "icon"); champlain_label_set_image (m, icon); champlain_label_set_font_name (m, "Serif 0"); } g_list_free (markers); item->priv->show_text = FALSE; }
static gboolean add_marker (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { int latitude_offset; int longitude_offset; double lat; double lon; gchar *title; gchar *latitude_str; gchar *longitude_str; gchar *check; ClutterActor *marker; ClutterActor *icon; PhidiasItemsGeo *item; item = data; latitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 0)); longitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 1)); gtk_tree_model_get (model, iter, ITEM_INFO_TITLE, &title, latitude_offset, &latitude_str, longitude_offset, &longitude_str, -1); if (latitude_str == NULL || longitude_str == NULL) goto end; check = NULL; lat = strtod (latitude_str, &check); if (*check != '\0') goto end; check = NULL; lon = strtod (longitude_str, &check); if (*check != '\0') goto end; check = g_markup_escape_text (title, -1); g_free (title); title = check; /* TODO Provide a proper ChamplainMarker implementation, able to store the icon, the title, the description, and able to react to clicks */ icon = do_marker_icon ("go-jump", 22); if (item->priv->show_text) { marker = champlain_label_new_with_text (title, "Serif 9", NULL, NULL); } else { marker = champlain_label_new_with_text (title, "Serif 0", NULL, NULL); champlain_label_set_image (CHAMPLAIN_LABEL (marker), icon); } g_object_set_data (G_OBJECT (marker), "icon", icon); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon); champlain_marker_layer_add_marker (item->priv->current_layer, CHAMPLAIN_MARKER (marker)); g_hash_table_insert (item->priv->markers, gtk_tree_path_to_string (path), marker); end: if (title != NULL) g_free (title); if (latitude_str != NULL) g_free (latitude_str); if (longitude_str != NULL) g_free (longitude_str); return FALSE; }