+static void zoom_changed (GtkMenuShell *menushell,
+ gpointer user_data)
+{
+ VikWindow *vw = VIK_WINDOW (user_data);
+
+ GtkWidget *aw = gtk_menu_get_active ( GTK_MENU (menushell) );
+ gint active = GPOINTER_TO_INT(g_object_get_data ( G_OBJECT (aw), "position" ));
+
+ gdouble zoom_request = pow (2, active-2 );
+
+ // But has it really changed?
+ gdouble current_zoom = vik_viewport_get_zoom ( vw->viking_vvp );
+ if ( current_zoom != 0.0 && zoom_request != current_zoom ) {
+ vik_viewport_set_zoom ( vw->viking_vvp, zoom_request );
+ // Force drawing update
+ draw_update ( vw );
+ }
+}
+
+static GtkWidget * create_zoom_menu_all_levels ()
+{
+ GtkWidget *menu = gtk_menu_new ();
+ char *itemLabels[] = { "0.25", "0.5", "1", "2", "4", "8", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768", NULL };
+
+ int i;
+ for (i = 0 ; itemLabels[i] != NULL ; i++)
+ {
+ GtkWidget *item = gtk_menu_item_new_with_label (itemLabels[i]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+ g_object_set_data (G_OBJECT (item), "position", GINT_TO_POINTER(i));
+ }
+
+ return menu;
+}
+
+static GtkWidget *create_zoom_combo_all_levels ()
+{
+ GtkWidget *zoom_combo = gtk_combo_box_new_text();
+ GtkComboBox *combo = GTK_COMBO_BOX ( zoom_combo );
+ gtk_combo_box_append_text ( combo, "0.25");
+ gtk_combo_box_append_text ( combo, "0.5");
+ gtk_combo_box_append_text ( combo, "1");
+ gtk_combo_box_append_text ( combo, "2");
+ gtk_combo_box_append_text ( combo, "4");
+ gtk_combo_box_append_text ( combo, "8");
+ gtk_combo_box_append_text ( combo, "16");
+ gtk_combo_box_append_text ( combo, "32");
+ gtk_combo_box_append_text ( combo, "64");
+ gtk_combo_box_append_text ( combo, "128");
+ gtk_combo_box_append_text ( combo, "256");
+ gtk_combo_box_append_text ( combo, "512");
+ gtk_combo_box_append_text ( combo, "1024");
+ gtk_combo_box_append_text ( combo, "2048");
+ gtk_combo_box_append_text ( combo, "4096");
+ gtk_combo_box_append_text ( combo, "8192");
+ gtk_combo_box_append_text ( combo, "16384");
+ gtk_combo_box_append_text ( combo, "32768");
+ /* Create tooltip */
+ gtk_widget_set_tooltip_text (GTK_WIDGET (combo), _("Select zoom level"));
+ return zoom_combo;
+}
+
+static gint zoom_popup_handler (GtkWidget *widget)
+{
+ GtkMenu *menu;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
+
+ /* The "widget" is the menu that was supplied when
+ * g_signal_connect_swapped() was called.
+ */
+ menu = GTK_MENU (widget);
+
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
+ 1, gtk_get_current_event_time());
+ return TRUE;
+}
+
+static void vik_window_init ( VikWindow *vw )