static void gth_map_view_init (GthMapView *self) { ClutterActor *scale; self->priv = GTH_MAP_VIEW_GET_PRIVATE (self); gtk_box_set_spacing (GTK_BOX (self), 6); gtk_container_set_border_width (GTK_CONTAINER (self), 2); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); /* No GPS label */ self->priv->no_gps_label = gtk_label_new (_("The geographical position information is not available for this image.")); g_object_set (G_OBJECT (self->priv->no_gps_label), "wrap", TRUE, "wrap-mode", PANGO_WRAP_WORD_CHAR, "single-line-mode", FALSE, "justify", GTK_JUSTIFY_CENTER, "width-request", LABEL_MAX_WIDTH, NULL); gtk_widget_show (self->priv->no_gps_label); gtk_box_pack_start (GTK_BOX (self), self->priv->no_gps_label, TRUE, TRUE, 0); /* The map widget */ self->priv->embed = gtk_champlain_embed_new (); self->priv->map_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (self->priv->embed)); g_object_set (G_OBJECT (self->priv->map_view), "reactive", TRUE, "zoom-level", 5, "zoom-on-double-click", TRUE, "kinetic-mode", TRUE, NULL); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), self->priv->map_view); champlain_view_bin_layout_add (self->priv->map_view, scale, CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END); self->priv->marker_layer = champlain_marker_layer_new (); champlain_view_add_layer (self->priv->map_view, CHAMPLAIN_LAYER (self->priv->marker_layer)); clutter_actor_show (CLUTTER_ACTOR (self->priv->marker_layer)); self->priv->marker = champlain_label_new_with_text ("", "Sans 10", NULL, NULL); clutter_actor_show (self->priv->marker); champlain_marker_layer_add_marker (self->priv->marker_layer, CHAMPLAIN_MARKER (self->priv->marker)); gtk_widget_show_all (self->priv->embed); gtk_widget_hide (self->priv->embed); gtk_box_pack_start (GTK_BOX (self), self->priv->embed, TRUE, TRUE, 0); }
static void impl_activate (PeasActivatable *plugin) { PlacemarksPluginPrivate *priv; GtkUIManager *manager; GtkListStore *store; priv = PLACEMARKS_PLUGIN (plugin)->priv; priv->window = EMERILLON_WINDOW (emerillon_window_dup_default ()); priv->map_view = emerillon_window_get_map_view (priv->window); priv->markers_layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_NONE); champlain_view_add_layer(priv->map_view, CHAMPLAIN_LAYER(priv->markers_layer)); manager = emerillon_window_get_ui_manager (priv->window); priv->action_group = gtk_action_group_new ("PlacemarksActions"); gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (priv->action_group, action_entries, G_N_ELEMENTS (action_entries), plugin); gtk_ui_manager_insert_action_group (manager, priv->action_group, -1); priv->ui_id = gtk_ui_manager_add_ui_from_string (manager, ui_definition, -1, NULL); g_warn_if_fail (priv->ui_id != 0); store = gtk_list_store_new (COL_COUNT, G_TYPE_STRING, /* ID */ G_TYPE_STRING, /* Name */ G_TYPE_FLOAT, /* Latitude */ G_TYPE_STRING, /* Latitude as a string */ G_TYPE_FLOAT, /* Longitude */ G_TYPE_STRING, /* Longitude as a string */ G_TYPE_INT, /* Zoom level */ G_TYPE_STRING, /* Zoom level as a string */ G_TYPE_UINT, /* UI ID */ G_TYPE_POINTER); /* Marker pointer */ priv->model = GTK_TREE_MODEL (store); priv->deleted_cb_id = g_signal_connect (priv->model, "row-deleted", G_CALLBACK (row_deleted_cb), plugin); load_placemarks (PLACEMARKS_PLUGIN (plugin)); load_menus (PLACEMARKS_PLUGIN (plugin)); }
int main (int argc, char *argv[]) { ClutterActor *actor, *marker, *stage; ChamplainMarkerLayer *layer; GpsCallbackData callback_data; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Create the map view */ actor = champlain_view_new (); clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); /* Create the marker layer */ layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); clutter_actor_show (CLUTTER_ACTOR (layer)); champlain_view_add_layer (CHAMPLAIN_VIEW (actor), CHAMPLAIN_LAYER (layer)); /* Create a marker */ marker = create_marker (); champlain_marker_layer_add_marker (layer, CHAMPLAIN_MARKER (marker)); /* Finish initialising the map view */ g_object_set (G_OBJECT (actor), "zoom-level", 12, "kinetic-mode", TRUE, NULL); champlain_view_center_on (CHAMPLAIN_VIEW (actor), lat, lon); /* Create callback that updates the map periodically */ callback_data.view = CHAMPLAIN_VIEW (actor); callback_data.marker = CHAMPLAIN_MARKER (marker); g_timeout_add (1000, (GSourceFunc) gps_callback, &callback_data); clutter_actor_show (stage); clutter_main (); return 0; }
static void phidias_items_geo_init (PhidiasItemsGeo *item) { ChamplainView *view; item->priv = PHIDIAS_ITEMS_GEO_GET_PRIVATE (item); memset (item->priv, 0, sizeof (PhidiasItemsGeoPrivate)); item->priv->markers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); dispose_zoom_icons (item); view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (item)); item->priv->current_layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); champlain_view_add_layer (view, CHAMPLAIN_LAYER (item->priv->current_layer)); champlain_view_set_min_zoom_level (view, 2); champlain_view_set_zoom_on_double_click (view, FALSE); champlain_view_set_keep_center_on_resize (view, TRUE); }
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 void create_map_window (GourmapUi *ui) { GourmapUiPrivate *priv; GtkWidget *hbox; GtkWidget *vbox1, *vbox2; GtkWidget *toolbar; GtkWidget *addr_label; GtkToolItem *item; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *select; priv = GET_PRIVATE (ui); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); /* map */ priv->map = gtk_champlain_embed_new (); priv->champ_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (priv->map)); clutter_actor_set_reactive (CLUTTER_ACTOR (priv->champ_view), TRUE); g_object_set (G_OBJECT (priv->champ_view), "kinetic-mode", TRUE, NULL); priv->marker_layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); champlain_view_add_layer (priv->champ_view, CHAMPLAIN_LAYER (priv->marker_layer)); /* sidebar */ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); /* restaurant list */ priv->store = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_UINT); priv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->store)); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Restaurant List"), renderer, "text", NAME_COLUMN, NULL); select = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); g_signal_connect (G_OBJECT (select), "changed", G_CALLBACK (tree_selection_changed_cb), (gpointer) ui); gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column); gtk_box_pack_start (GTK_BOX (vbox2), priv->treeview, TRUE, TRUE, 0); /* random button */ priv->rand_button = gtk_button_new_with_label (_("Random Selection!")); g_signal_connect (G_OBJECT (priv->rand_button), "clicked", G_CALLBACK (random_button_cb), (gpointer) ui); gtk_box_pack_start (GTK_BOX (vbox2), priv->rand_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->map, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0); /* address */ toolbar = gtk_toolbar_new (); item = gtk_tool_item_new (); addr_label = gtk_label_new (_("Address")); gtk_container_add (GTK_CONTAINER (item), addr_label); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); item = gtk_tool_item_new (); gtk_tool_item_set_expand (item, TRUE); priv->addr_entry = gtk_entry_new (); gtk_container_add (GTK_CONTAINER (item), priv->addr_entry); g_signal_connect (G_OBJECT (priv->addr_entry), "activate", G_CALLBACK (activate_addr_entry_cb), (gpointer) ui); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); item = gtk_tool_button_new_from_stock (GTK_STOCK_OK); g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (activate_addr_entry_cb), (gpointer) ui); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); gtk_box_pack_start (GTK_BOX (vbox1), hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox1), toolbar, FALSE, FALSE, 0); /* main window */ priv->main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (priv->main_window), 1024, 768); gtk_widget_set_name (priv->main_window, _("Gourmap")); g_signal_connect (G_OBJECT (priv->main_window), "destroy", G_CALLBACK (destroy_cb), NULL); gtk_container_add (GTK_CONTAINER (priv->main_window), vbox1); }
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); }
GtkWidget *bar_pane_gps_new(const gchar *id, const gchar *title, const gchar *map_id, const gint zoom, const gdouble latitude, const gdouble longitude, gboolean expanded, gint height) { PaneGPSData *pgd; GtkWidget *vbox, *frame; GtkWidget *gpswidget, *viewport; GtkWidget *status, *state, *progress, *slider; ChamplainLayer *layer; ChamplainView *view; const gchar *slider_list[] = {GTK_STOCK_ZOOM_IN, GTK_STOCK_ZOOM_OUT, NULL}; const gchar **slider_icons = slider_list; pgd = g_new0(PaneGPSData, 1); pgd->pane.pane_set_fd = bar_pane_gps_set_fd; pgd->pane.pane_notify_selection = bar_pane_gps_notify_selection; pgd->pane.pane_event = bar_pane_gps_event; pgd->pane.pane_write_config = bar_pane_gps_write_config; pgd->pane.title = bar_pane_expander_title(title); pgd->pane.id = g_strdup(id); pgd->pane.type = PANE_GPS; pgd->pane.expanded = expanded; pgd->height = height; frame = gtk_frame_new(NULL); vbox = gtk_vbox_new(FALSE, 0); gpswidget = gtk_champlain_embed_new(); view = gtk_champlain_embed_get_view(GTK_CHAMPLAIN_EMBED(gpswidget)); gtk_box_pack_start(GTK_BOX(vbox), gpswidget, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); status = gtk_hbox_new(FALSE,0); slider = gtk_scale_button_new(GTK_ICON_SIZE_SMALL_TOOLBAR, 1, 17, 1, slider_icons); gtk_widget_set_tooltip_text(slider, "Zoom"); gtk_scale_button_set_value(GTK_SCALE_BUTTON(slider), (gdouble)zoom); progress = gtk_progress_bar_new(); state = gtk_label_new(""); gtk_label_set_justify(GTK_LABEL(state), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(status), GTK_WIDGET(slider), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(status), GTK_WIDGET(state), FALSE, FALSE, 5); gtk_box_pack_end(GTK_BOX(status), GTK_WIDGET(progress), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox),GTK_WIDGET(status), FALSE, FALSE, 0); layer = champlain_layer_new(); champlain_view_add_layer(view, layer); pgd->icon_layer = layer; pgd->gps_view = CLUTTER_ACTOR(view); pgd->widget = frame; pgd->progress = progress; pgd->slider = slider; pgd->state = state; bar_pane_gps_set_map_source(pgd, map_id); g_object_set(G_OBJECT(view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, "zoom-level", zoom, "keep-center-on-resize", TRUE, /* This seems to be broken, https://bugzilla.gnome.org/show_bug.cgi?id=596419 "decel-rate", 1.0, */ "show-license", TRUE, "zoom-on-double-click", FALSE, "max-zoom-level", 17, "min-zoom-level", 1, NULL); champlain_view_center_on(view, latitude, longitude); pgd->centre_map_checked = TRUE; g_object_set_data(G_OBJECT(pgd->widget), "pane_data", pgd); g_signal_connect(G_OBJECT(pgd->widget), "destroy", G_CALLBACK(bar_pane_gps_destroy), pgd); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); gtk_widget_set_size_request(pgd->widget, -1, height); clutter_set_motion_events_enabled(TRUE); g_signal_connect(G_OBJECT(gpswidget), "button_press_event", G_CALLBACK(bar_pane_gps_map_keypress_cb), pgd); g_signal_connect(pgd->gps_view, "notify::state", G_CALLBACK(bar_pane_gps_view_state_changed_cb), pgd); g_signal_connect(pgd->gps_view, "notify::zoom-level", G_CALLBACK(bar_pane_gps_view_state_changed_cb), pgd); g_signal_connect(G_OBJECT(slider), "value-changed", G_CALLBACK(bar_pane_gps_slider_changed_cb), pgd); file_data_register_notify_func(bar_pane_gps_notify_cb, pgd, NOTIFY_PRIORITY_LOW); pgd->create_markers_id = 0; pgd->enable_markers_checked = TRUE; pgd->centre_map_checked = TRUE; return pgd->widget; }
int main (int argc, char *argv[]) { ClutterActor *actor, *stage, *buttons, *button; ChamplainMarkerLayer *layer; ChamplainPathLayer *path; gfloat width, total_width = 0; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Create the map view */ actor = champlain_view_new (); clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600); clutter_actor_add_child (stage, actor); /* Create the buttons */ buttons = clutter_actor_new (); clutter_actor_set_position (buttons, PADDING, PADDING); button = make_button ("Zoom in"); clutter_actor_add_child (buttons, button); clutter_actor_set_reactive (button, TRUE); clutter_actor_get_size (button, &width, NULL); total_width += width + PADDING; g_signal_connect (button, "button-release-event", G_CALLBACK (zoom_in), actor); button = make_button ("Zoom out"); clutter_actor_add_child (buttons, button); clutter_actor_set_reactive (button, TRUE); clutter_actor_set_position (button, total_width, 0); clutter_actor_get_size (button, &width, NULL); g_signal_connect (button, "button-release-event", G_CALLBACK (zoom_out), actor); clutter_actor_add_child (stage, buttons); ClutterContent *canvas; canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 512, 256); g_signal_connect (canvas, "draw", G_CALLBACK (draw_background_tile), NULL); clutter_content_invalidate (canvas); champlain_view_set_background_pattern (CHAMPLAIN_VIEW (actor), canvas); /* Create the markers and marker layer */ layer = create_marker_layer (CHAMPLAIN_VIEW (actor), &path); champlain_view_add_layer (CHAMPLAIN_VIEW (actor), CHAMPLAIN_LAYER (layer)); /* Connect to the click event */ clutter_actor_set_reactive (actor, TRUE); g_signal_connect (actor, "button-release-event", G_CALLBACK (map_view_button_release_cb), actor); /* Finish initialising the map view */ g_object_set (G_OBJECT (actor), "zoom-level", 12, "kinetic-mode", TRUE, NULL); champlain_view_center_on (CHAMPLAIN_VIEW (actor), 45.466, -73.75); clutter_actor_show (stage); clutter_main (); return 0; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *widget, *vbox, *bbox, *button, *viewport, *image; ChamplainView *view; ChamplainMarkerLayer *layer; ClutterActor *scale; ChamplainLicense *license_actor; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* create the main, top level, window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* give the window a 10px wide border */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* give it the title */ gtk_window_set_title (GTK_WINDOW (window), "libchamplain Gtk+ demo"); /* Connect the destroy event of the window with our on_destroy function * When the window is about to be destroyed we get a notificaiton and * stop the main GTK loop */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy), NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); widget = gtk_champlain_embed_new (); view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget)); clutter_actor_set_reactive (CLUTTER_ACTOR (view), TRUE); g_signal_connect (view, "button-release-event", G_CALLBACK (mouse_click_cb), view); g_object_set (G_OBJECT (view), "kinetic-mode", TRUE, "zoom-level", 5, NULL); g_object_set_data (G_OBJECT (view), "window", window); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), view); /* align to the bottom left */ clutter_actor_set_x_expand (scale, TRUE); clutter_actor_set_y_expand (scale, TRUE); clutter_actor_set_x_align (scale, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (scale, CLUTTER_ACTOR_ALIGN_END); clutter_actor_add_child (CLUTTER_ACTOR (view), scale); license_actor = champlain_view_get_license_actor (view); champlain_license_set_extra_text (license_actor, "Don't eat cereals with orange juice\nIt tastes bad"); champlain_view_center_on (CHAMPLAIN_VIEW (view), 45.466, -73.75); layer = create_marker_layer (view, &path); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path)); champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer)); path_layer = champlain_path_layer_new (); /* Cheap approx of Highway 10 */ append_point (path_layer, 45.4095, -73.3197); append_point (path_layer, 45.4104, -73.2846); append_point (path_layer, 45.4178, -73.2239); append_point (path_layer, 45.4176, -73.2181); append_point (path_layer, 45.4151, -73.2126); append_point (path_layer, 45.4016, -73.1926); append_point (path_layer, 45.3994, -73.1877); append_point (path_layer, 45.4000, -73.1815); append_point (path_layer, 45.4151, -73.1218); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path_layer)); gtk_widget_set_size_request (widget, 640, 481); bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-in", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom In"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-out", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom Out"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Markers"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_signal_connect (button, "toggled", G_CALLBACK (toggle_layer), layer); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Toggle wrap"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), champlain_view_get_horizontal_wrap (view)); g_signal_connect (button, "toggled", G_CALLBACK (toggle_wrap), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_combo_box_new (); build_combo_box (GTK_COMBO_BOX (button)); gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0); g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_spin_button_new_with_range (0, 20, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), champlain_view_get_zoom_level (view)); g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), view); g_signal_connect (view, "notify::zoom-level", G_CALLBACK (map_zoom_changed), button); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("list-add", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("camera-photo-symbolic", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (export_png), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_image_new (); gtk_widget_set_size_request (button, 22, -1); g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed), button); gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0); viewport = gtk_frame_new (NULL); gtk_container_add (GTK_CONTAINER (viewport), widget); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), viewport); /* and insert it into the main window */ gtk_container_add (GTK_CONTAINER (window), vbox); /* make sure that everything, window and label, are visible */ gtk_widget_show_all (window); /* start the main loop */ gtk_main (); return 0; }
static void impl_activate (EogWindowActivatable *activatable) { EogMapPlugin *plugin = EOG_MAP_PLUGIN (activatable); GtkWidget *sidebar, *vbox, *bbox, *button, *viewport; GtkWidget *embed; ClutterActor *scale; eog_debug (DEBUG_PLUGINS); /* This is a workaround until bug 590692 is fixed. */ viewport = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (viewport), GTK_SHADOW_ETCHED_IN); /*viewport = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_ETCHED_IN);*/ embed = gtk_champlain_embed_new (); plugin->map = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (embed)); g_object_set (G_OBJECT (plugin->map), "zoom-level", 3, "kinetic-mode", TRUE, NULL); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), plugin->map); /* align to the bottom left */ champlain_view_bin_layout_add (plugin->map, scale, CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END); gtk_container_add (GTK_CONTAINER (viewport), embed); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); bbox = gtk_toolbar_new (); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "go-jump-symbolic"); gtk_widget_set_tooltip_text (button, _("Jump to current image's location")); g_signal_connect (button, "clicked", G_CALLBACK (jump_to), plugin); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->jump_to_button = button; button = GTK_WIDGET (gtk_separator_tool_item_new ()); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-in-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom in")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-out-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom out")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); champlain_view_add_layer (CHAMPLAIN_VIEW (plugin->map), CHAMPLAIN_LAYER (plugin->layer)); sidebar = eog_window_get_sidebar (plugin->window); plugin->viewport = vbox; gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_widget_set_vexpand (viewport, TRUE); gtk_container_add (GTK_CONTAINER (vbox), viewport); eog_sidebar_add_page (EOG_SIDEBAR (sidebar), _("Map"), vbox); gtk_widget_show_all (vbox); plugin->win_prepared_id = g_signal_connect (G_OBJECT (plugin->window), "prepared", G_CALLBACK (prepared_cb), plugin); /* Call the callback once in case the window is already ready */ prepared_cb (plugin->window, plugin); }