static void
add_clicked (GtkButton     *button,
             ChamplainView *view)
{
  GtkWidget *window, *dialog, *vbox, *combo;
  GtkResponseType response;

  window = g_object_get_data (G_OBJECT (view), "window");
  dialog = gtk_dialog_new_with_buttons ("Add secondary map source",
                                        GTK_WINDOW (window),
                                        GTK_DIALOG_MODAL,
                                        "Add",
                                        GTK_RESPONSE_OK,
                                        "Cancel",
                                        GTK_RESPONSE_CANCEL,
                                        NULL);

  combo = gtk_combo_box_new ();
  build_combo_box (GTK_COMBO_BOX (combo));
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

  vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_container_add (GTK_CONTAINER (vbox), combo);

  gtk_widget_show_all (dialog);

  response = gtk_dialog_run (GTK_DIALOG (dialog));

  if (response == GTK_RESPONSE_OK)
    {
      GtkTreeModel *model;
      GtkTreeIter iter;
      ChamplainMapSource *source;
      ChamplainMapSourceFactory *factory;
      char *id;

      if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
        return;

      model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));

      gtk_tree_model_get (model, &iter, COL_ID, &id, -1);

      factory = champlain_map_source_factory_dup_default ();
      source = champlain_map_source_factory_create_memcached_source (factory, id);

      champlain_view_add_overlay_source (view, source, 0.6 * 255);
      g_object_unref (factory);
      g_free (id);
    }

  gtk_widget_destroy (dialog);
}
Esempio n. 2
0
void bar_pane_gps_set_map_source(PaneGPSData *pgd, const gchar *map_id)
{
	ChamplainMapSource *map_source;
	ChamplainMapSourceFactory *map_factory;

	map_factory = champlain_map_source_factory_dup_default();
	map_source = champlain_map_source_factory_create(map_factory, map_id);

	if (map_source != NULL)
		{
		g_object_set(G_OBJECT(pgd->gps_view), "map-source", map_source, NULL);
		g_object_unref(map_factory);
		}

	g_object_unref(map_source);
}
Esempio n. 3
0
static GtkWidget *bar_pane_gps_menu(PaneGPSData *pgd)
{
	GtkWidget *menu;
	GtkWidget *map_centre;
	GtkWidget *parent;
	ChamplainMapSourceFactory *map_factory;
	GSList *map_list;
	ChamplainMapSourceDesc *map_desc;
	const gchar *current;

	menu = popup_menu_short_lived();

	map_factory = champlain_map_source_factory_dup_default();
	map_list = champlain_map_source_factory_dup_list(map_factory);
	current = bar_pane_gps_get_map_id(pgd);

	while (map_list)
		{
		map_desc = (ChamplainMapSourceDesc *)(map_list->data);
		
		menu_item_add_radio(menu, map_desc->name, map_desc->id, strcmp(map_desc->id, current) == 0, G_CALLBACK(bar_pane_gps_change_map_cb), pgd); 
		
		map_list = g_slist_next(map_list);
		}
		
	menu_item_add_divider(menu);
	menu_item_add_check(menu, _("Enable markers"), pgd->enable_markers_checked,
											G_CALLBACK(bar_pane_gps_enable_markers_checked_toggle_cb), pgd);
	map_centre = menu_item_add_check(menu, _("Centre map on marker"), pgd->centre_map_checked,
											G_CALLBACK(bar_pane_gps_centre_map_checked_toggle_cb), pgd);
	if (!pgd->enable_markers_checked)
		{
		gtk_widget_set_sensitive(map_centre, FALSE);
		}

	g_slist_free(map_list);
	g_object_unref(map_factory);
	//g_object_unref(map_centre);

	return menu;
}
static void
build_combo_box (GtkComboBox *box)
{
  ChamplainMapSourceFactory *factory;
  GSList *sources, *iter;
  GtkTreeStore *store;
  GtkTreeIter parent;
  GtkCellRenderer *cell;

  store = gtk_tree_store_new (N_COLS, G_TYPE_STRING, /* id */
        G_TYPE_STRING, /* name */
        -1);

  factory = champlain_map_source_factory_dup_default ();
  sources = champlain_map_source_factory_get_registered (factory);

  iter = sources;
  while (iter != NULL)
    {
      ChamplainMapSourceDesc *desc = CHAMPLAIN_MAP_SOURCE_DESC (iter->data);
      const gchar *id = champlain_map_source_desc_get_id (desc);
      const gchar *name = champlain_map_source_desc_get_name (desc);

      gtk_tree_store_append (store, &parent, NULL);
      gtk_tree_store_set (store, &parent, COL_ID, id,
          COL_NAME, name, -1);

      iter = g_slist_next (iter);
    }

  g_slist_free (sources);
  g_object_unref (factory);

  gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));

  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box), cell, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (box), cell,
      "text", COL_NAME, NULL);
}
static void
map_source_changed (GtkWidget *widget,
    ChamplainView *view)
{
  gchar *id;
  ChamplainMapSource *source;
  GtkTreeIter iter;
  GtkTreeModel *model;

  if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
    return;

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

  gtk_tree_model_get (model, &iter, COL_ID, &id, -1);

  ChamplainMapSourceFactory *factory = champlain_map_source_factory_dup_default ();
  source = champlain_map_source_factory_create_cached_source (factory, id);

  g_object_set (G_OBJECT (view), "map-source", source, NULL);
  g_object_unref (factory);
}
Esempio n. 6
0
static void
cmd_map_change_map (GtkRadioAction *action,
                    GtkRadioAction *current,
                    EmerillonWindow *self)
{
  gint value;
  ChamplainMapSourceFactory *factory;
  ChamplainMapSource *source;

  factory = champlain_map_source_factory_dup_default ();
  value = gtk_radio_action_get_current_value (current);

  switch (value)
    {
      default:
      case 0:
        source = champlain_map_source_factory_create_cached_source (factory,
            CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK);
        break;
      case 1:
        source = champlain_map_source_factory_create_cached_source (factory,
            CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP);
        break;
      case 2:
        source = champlain_map_source_factory_create_cached_source (factory,
            CHAMPLAIN_MAP_SOURCE_OSM_TRANSPORT_MAP);
        break;
      case 3:
        source = champlain_map_source_factory_create_cached_source (factory,
            CHAMPLAIN_MAP_SOURCE_MFF_RELIEF);
        break;

    }
  champlain_view_set_map_source (self->priv->view, source);
  g_object_unref (factory);
}