+// the set zoom dialog
+
+GtkWidget *zoom_dialog;
+double zoom_percent;
+
+void
+on_viewSetZoom_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ int response;
+ double test_w, test_h;
+ GtkSpinButton *spinZoom;
+
+ end_text();
+ reset_focus();
+ zoom_dialog = create_zoomDialog();
+ zoom_percent = 100*ui.zoom / DEFAULT_ZOOM;
+ spinZoom = GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(zoom_dialog), "spinZoom"));
+ gtk_spin_button_set_increments(spinZoom, ui.zoom_step_increment, 5*ui.zoom_step_increment);
+ gtk_spin_button_set_value(spinZoom, zoom_percent);
+ test_w = 100*(GTK_WIDGET(canvas))->allocation.width/ui.cur_page->width/DEFAULT_ZOOM;
+ test_h = 100*(GTK_WIDGET(canvas))->allocation.height/ui.cur_page->height/DEFAULT_ZOOM;
+ if (zoom_percent > 99.9 && zoom_percent < 100.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom100")), TRUE);
+ else if (zoom_percent > test_w-0.1 && zoom_percent < test_w+0.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoomWidth")), TRUE);
+ else if (zoom_percent > test_h-0.1 && zoom_percent < test_h+0.1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoomHeight")), TRUE);
+ else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom")), TRUE);
+ gtk_widget_show(zoom_dialog);
+
+ do {
+ response = gtk_dialog_run(GTK_DIALOG(zoom_dialog));
+ if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
+ ui.zoom = DEFAULT_ZOOM*zoom_percent/100;
+ gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
+ rescale_text_items();
+ rescale_bg_pixmaps();
+ }
+ } while (response == GTK_RESPONSE_APPLY);
+
+ gtk_widget_destroy(zoom_dialog);
+}
+
+
+void
+on_spinZoom_value_changed (GtkSpinButton *spinbutton,
+ gpointer user_data)
+{
+ double val;
+
+ val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")));
+ if (val<1) return;
+ if (val<10) val=10.;
+ if (val>1500) val=1500.;
+ if (val<zoom_percent-1 || val>zoom_percent+1)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "radioZoom")), TRUE);
+ zoom_percent = val;
+}
+
+
+void
+on_radioZoom_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ // nothing to do
+}
+
+
+void
+on_radioZoom100_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100.;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
+
+void
+on_radioZoomWidth_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100*(GTK_WIDGET(canvas))->allocation.width/ui.cur_page->width/DEFAULT_ZOOM;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
+
+void
+on_radioZoomHeight_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ if (!gtk_toggle_button_get_active(togglebutton)) return;
+ zoom_percent = 100*(GTK_WIDGET(canvas))->allocation.height/ui.cur_page->height/DEFAULT_ZOOM;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data(
+ G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent);
+}
+
+
+void
+on_toolsHand_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_RADIO_MENU_ITEM) {
+ if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)))
+ return;
+ } else {
+ if (!gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem)))
+ return;
+ }
+
+ if (ui.cur_mapping != 0) return;
+ if (ui.toolno[0] == TOOL_HAND) return;
+
+ end_text();
+ reset_focus();
+ reset_selection();
+ ui.toolno[0] = TOOL_HAND;
+ ui.ruler[0] = FALSE;
+ update_mapping_linkings(-1);
+ update_tool_buttons();
+ update_tool_menu();
+ update_color_menu();
+ update_cursor();
+}
+
+
+void
+on_button2Hand_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ process_mapping_activate(menuitem, 1, TOOL_HAND);
+}
+
+
+void
+on_button3Hand_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ process_mapping_activate(menuitem, 2, TOOL_HAND);
+}
+
+
+void
+on_optionsPrintRuling_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ end_text();
+ reset_focus();
+ ui.print_ruling = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem));
+}
+
+void
+on_optionsDiscardCore_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ end_text();
+ reset_focus();
+ ui.discard_corepointer =
+ gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem));
+ update_mappings_menu();
+}
+
+void
+on_fontButton_font_set (GtkFontButton *fontbutton,
+ gpointer user_data)
+{
+ gchar *str;
+
+ str = g_strdup(gtk_font_button_get_font_name(fontbutton));
+ process_font_sel(str);
+}
+