static void contact_widget_location_update (EmpathyContactWidget *information) { GHashTable *location; GValue *value; gdouble lat = 0.0, lon = 0.0; gboolean has_position = TRUE; GtkWidget *label; guint row = 0; static const gchar* ordered_geolocation_keys[] = { EMPATHY_LOCATION_TEXT, EMPATHY_LOCATION_URI, EMPATHY_LOCATION_DESCRIPTION, EMPATHY_LOCATION_BUILDING, EMPATHY_LOCATION_FLOOR, EMPATHY_LOCATION_ROOM, EMPATHY_LOCATION_STREET, EMPATHY_LOCATION_AREA, EMPATHY_LOCATION_LOCALITY, EMPATHY_LOCATION_REGION, EMPATHY_LOCATION_COUNTRY, NULL }; int i; const gchar *skey; gboolean display_map = FALSE; if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION)) { gtk_widget_hide (information->vbox_location); return; } location = empathy_contact_get_location (information->contact); if (location == NULL || g_hash_table_size (location) == 0) { gtk_widget_hide (information->vbox_location); return; } value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT); if (value == NULL) has_position = FALSE; else lat = g_value_get_double (value); value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON); if (value == NULL) has_position = FALSE; else lon = g_value_get_double (value); value = g_hash_table_lookup (location, EMPATHY_LOCATION_TIMESTAMP); if (value == NULL) { gchar *loc = g_strdup_printf ("<b>%s</b>", _("Location")); gtk_label_set_markup (GTK_LABEL (information->label_location), loc); g_free (loc); } else { gchar *user_date; gchar *text; gint64 stamp; time_t time_; stamp = g_value_get_int64 (value); time_ = stamp; user_date = empathy_time_to_string_relative (time_); text = g_strconcat ( _("<b>Location</b>, "), user_date, NULL); gtk_label_set_markup (GTK_LABEL (information->label_location), text); g_free (text); } /* Prepare the location information table */ if (information->table_location != NULL) { gtk_widget_destroy (information->table_location); } information->table_location = gtk_table_new (1, 2, FALSE); gtk_box_pack_start (GTK_BOX (information->subvbox_location), information->table_location, FALSE, FALSE, 5); for (i = 0; (skey = ordered_geolocation_keys[i]); i++) { const gchar* user_label; GValue *gvalue; char *svalue = NULL; gvalue = g_hash_table_lookup (location, (gpointer) skey); if (gvalue == NULL) continue; user_label = location_key_to_label (skey); label = gtk_label_new (user_label); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach (GTK_TABLE (information->table_location), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0); gtk_widget_show (label); if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE) { gdouble dvalue; dvalue = g_value_get_double (gvalue); svalue = g_strdup_printf ("%f", dvalue); } else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING) { svalue = g_value_dup_string (gvalue); } else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64) { time_t time_; time_ = g_value_get_int64 (value); svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC")); } if (svalue != NULL) { label = gtk_label_new (svalue); gtk_table_attach_defaults (GTK_TABLE (information->table_location), label, 1, 2, row, row + 1); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) gtk_label_set_selectable (GTK_LABEL (label), TRUE); } g_free (svalue); row++; } #if HAVE_LIBCHAMPLAIN if (has_position && !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such * windows */ display_map = TRUE; } #endif if (row > 0) { /* We can display some fields */ gtk_widget_show (information->table_location); } else if (!display_map) { /* Can't display either fields or map */ gtk_widget_hide (information->vbox_location); return; } #if HAVE_LIBCHAMPLAIN if (display_map) { ClutterActor *marker; ChamplainLayer *layer; information->map_view_embed = gtk_champlain_embed_new (); information->map_view = gtk_champlain_embed_get_view ( GTK_CHAMPLAIN_EMBED (information->map_view_embed)); gtk_container_add (GTK_CONTAINER (information->viewport_map), information->map_view_embed); g_object_set (G_OBJECT (information->map_view), "show-license", TRUE, "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, "zoom-level", 10, NULL); layer = champlain_layer_new (); champlain_view_add_layer (information->map_view, layer); marker = champlain_marker_new_with_text ( empathy_contact_get_name (information->contact), NULL, NULL, NULL); champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); champlain_view_center_on (information->map_view, lat, lon); gtk_widget_show_all (information->viewport_map); } #endif gtk_widget_show (information->vbox_location); }
static void contact_widget_location_update (EmpathyContactWidget *information) { GHashTable *location; GValue *value; gdouble lat = 0.0, lon = 0.0; gboolean has_position = TRUE; GtkWidget *label; guint row = 0; GHashTableIter iter; gpointer key, pvalue; if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION)) { gtk_widget_hide (information->vbox_location); return; } location = empathy_contact_get_location (information->contact); if (location == NULL || g_hash_table_size (location) == 0) { gtk_widget_hide (information->vbox_location); return; } value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT); if (value == NULL) has_position = FALSE; else lat = g_value_get_double (value); value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON); if (value == NULL) has_position = FALSE; else lon = g_value_get_double (value); value = g_hash_table_lookup (location, EMPATHY_LOCATION_TIMESTAMP); if (value == NULL) gtk_label_set_markup (GTK_LABEL (information->label_location), _("<b>Location</b>")); else { gchar *user_date; gchar *text; gint64 stamp; time_t time; stamp = g_value_get_int64 (value); time = stamp; user_date = empathy_time_to_string_relative (time); text = g_strconcat ( _("<b>Location</b>, "), user_date, NULL); gtk_label_set_markup (GTK_LABEL (information->label_location), text); g_free (text); } /* Prepare the location information table */ if (information->table_location != NULL) { gtk_widget_destroy (information->table_location); } information->table_location = gtk_table_new (1, 2, FALSE); gtk_box_pack_start (GTK_BOX (information->subvbox_location), information->table_location, FALSE, FALSE, 5); g_hash_table_iter_init (&iter, location); while (g_hash_table_iter_next (&iter, &key, &pvalue)) { const gchar *skey; const gchar* user_label; GValue *gvalue; char *svalue = NULL; skey = (const gchar *) key; user_label = location_key_to_label (skey); gvalue = (GValue *) pvalue; label = gtk_label_new (user_label); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach (GTK_TABLE (information->table_location), label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0); gtk_widget_show (label); if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE) { gdouble dvalue; dvalue = g_value_get_double (gvalue); svalue = g_strdup_printf ("%f", dvalue); } else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING) { svalue = g_value_dup_string (gvalue); } else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64) { time_t time; time = g_value_get_int64 (value); svalue = empathy_time_to_string_utc (time, _("%B %e, %Y at %R UTC")); } if (svalue != NULL) { label = gtk_label_new (svalue); gtk_table_attach_defaults (GTK_TABLE (information->table_location), label, 1, 2, row, row + 1); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_widget_show (label); } g_free (svalue); row++; } gtk_widget_show (information->table_location); #if HAVE_LIBCHAMPLAIN /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such * windows */ if (has_position && !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { ClutterActor *marker; ChamplainLayer *layer; information->map_view_embed = gtk_champlain_embed_new (); information->map_view = gtk_champlain_embed_get_view ( GTK_CHAMPLAIN_EMBED (information->map_view_embed)); gtk_container_add (GTK_CONTAINER (information->viewport_map), information->map_view_embed); g_object_set (G_OBJECT (information->map_view), "show-license", FALSE, "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL); layer = champlain_layer_new (); champlain_view_add_layer (information->map_view, layer); marker = champlain_marker_new_with_text ( empathy_contact_get_name (information->contact), NULL, NULL, NULL); champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); champlain_view_center_on (information->map_view, lat, lon); gtk_widget_show_all (information->viewport_map); } #endif gtk_widget_show (information->vbox_location); }
static gboolean bar_pane_gps_create_markers_cb(gpointer data) { PaneGPSData *pgd = data; gdouble latitude; gdouble longitude; GList *work; ClutterActor *marker; FileData *fd; ClutterColor marker_colour = { MARKER_COLOUR }; GString *message; gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), (gdouble)(pgd->selection_count - g_list_length(pgd->selection_list)) / (gdouble)pgd->selection_count); message = g_string_new(""); g_string_printf(message, "%i/%i", (pgd->selection_count - g_list_length(pgd->selection_list)), pgd->selection_count); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), message->str); g_string_free(message, TRUE); work = pgd->selection_list; while (work) { fd = work->data; pgd->selection_list = g_list_remove(pgd->selection_list, work->data); /* If the file has a parent, it must be a sidecar file. Do not process sidecar files */ if (fd != NULL && fd->parent == NULL) { latitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLatitude", 1000); longitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLongitude", 1000); if ((latitude != 1000) && (longitude != 1000)) { marker = champlain_marker_new_with_text("i","courier 5", &marker_colour, &marker_colour); champlain_base_marker_set_position(CHAMPLAIN_BASE_MARKER(marker), latitude, longitude); clutter_container_add(CLUTTER_CONTAINER(pgd->icon_layer), marker, NULL); clutter_actor_set_reactive(marker, TRUE); g_signal_connect(G_OBJECT(marker), "button_release_event", G_CALLBACK(bar_pane_gps_marker_keypress_cb), pgd); g_object_set_data(G_OBJECT(marker), "file_fd", fd); g_ptr_array_add(pgd->marker_list, marker); if (pgd->centre_map_checked) { g_ptr_array_add(pgd->marker_list, NULL); champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view), (void *)pgd->marker_list->pdata, FALSE); g_ptr_array_remove(pgd->marker_list, NULL); } } } return TRUE; } if (pgd->marker_list->len >= 1) { g_ptr_array_add(pgd->marker_list, NULL); if (pgd->centre_map_checked) { champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view), (void *)pgd->marker_list->pdata, FALSE); } } gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), 0); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), NULL); g_list_free(pgd->selection_list); g_ptr_array_free(pgd->marker_list, TRUE); pgd->create_markers_id = 0; return FALSE; }