X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fxo-callbacks.c;h=6c087d3a0dc95c74dfd9276bdabd577895087316;hb=8d8f9e44b17ef9737084eea7693072e4777a0609;hp=2fa9d7c869fbedfc0d26ee1ed2793f7d95994c57;hpb=2e5ff0bff41fa53d4941b6f0fe49c8914bf29cbc;p=xournal.git diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c index 2fa9d7c..6c087d3 100644 --- a/src/xo-callbacks.c +++ b/src/xo-callbacks.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "xournal.h" #include "xo-callbacks.h" @@ -18,6 +19,7 @@ #include "xo-file.h" #include "xo-paint.h" #include "xo-print.h" +#include "xo-shapes.h" void on_fileNew_activate (GtkMenuItem *menuitem, @@ -290,7 +292,7 @@ void on_filePrint_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget *printDialog, *preview; + GtkWidget *printDialog; GnomePrintJob *gpj; int fromPage, toPage; int response; @@ -379,7 +381,6 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem, char *filename, *in_fn; char stime[30]; time_t curtime; - int response; gboolean warn; end_text(); @@ -472,6 +473,7 @@ on_editUndo_activate (GtkMenuItem *menuitem, struct Background *tmp_bg; double tmp_x, tmp_y; gchar *tmpstr; + GnomeCanvasGroup *group; end_text(); reset_focus(); @@ -485,7 +487,7 @@ on_editUndo_activate (GtkMenuItem *menuitem, undo->layer->items = g_list_remove(undo->layer->items, undo->item); undo->layer->nitems--; } - else if (undo->type == ITEM_ERASURE) { + else if (undo->type == ITEM_ERASURE || undo->type == ITEM_RECOGNIZER) { for (list = undo->erasurelist; list!=NULL; list = list->next) { erasure = (struct UndoErasureData *)list->data; // delete all the created items @@ -574,6 +576,11 @@ on_editUndo_activate (GtkMenuItem *menuitem, move_journal_items_by(undo->itemlist, -undo->val_x, -undo->val_y, undo->layer2, undo->layer, undo->auxlist); } + else if (undo->type == ITEM_RESIZESEL) { + resize_journal_items_by(undo->itemlist, + 1/undo->scaling_x, 1/undo->scaling_y, + -undo->val_x/undo->scaling_x, -undo->val_y/undo->scaling_y); + } else if (undo->type == ITEM_PASTE) { for (itemlist = undo->itemlist; itemlist != NULL; itemlist = itemlist->next) { it = (struct Item *)itemlist->data; @@ -622,10 +629,12 @@ on_editUndo_activate (GtkMenuItem *menuitem, g_memmove(&tmp_brush, &(it->brush), sizeof(struct Brush)); g_memmove(&(it->brush), list->data, sizeof(struct Brush)); g_memmove(list->data, &tmp_brush, sizeof(struct Brush)); - if (it->type == ITEM_STROKE && it->canvas_item != NULL) - gnome_canvas_item_set(it->canvas_item, - "fill-color-rgba", it->brush.color_rgba, - "width-units", it->brush.thickness, NULL); + if (it->type == ITEM_STROKE && it->canvas_item != NULL) { + // remark: a variable-width item might have lost its variable-width + group = (GnomeCanvasGroup *) it->canvas_item->parent; + gtk_object_destroy(GTK_OBJECT(it->canvas_item)); + make_canvas_item_one(group, it); + } if (it->type == ITEM_TEXT && it->canvas_item != NULL) gnome_canvas_item_set(it->canvas_item, "fill-color-rgba", it->brush.color_rgba, NULL); @@ -678,6 +687,7 @@ on_editRedo_activate (GtkMenuItem *menuitem, struct Layer *l; double tmp_x, tmp_y; gchar *tmpstr; + GnomeCanvasGroup *group; end_text(); reset_focus(); @@ -690,7 +700,7 @@ on_editRedo_activate (GtkMenuItem *menuitem, redo->layer->items = g_list_append(redo->layer->items, redo->item); redo->layer->nitems++; } - else if (redo->type == ITEM_ERASURE) { + else if (redo->type == ITEM_ERASURE || redo->type == ITEM_RECOGNIZER) { for (list = redo->erasurelist; list!=NULL; list = list->next) { erasure = (struct UndoErasureData *)list->data; target = g_list_find(redo->layer->items, erasure->item); @@ -770,7 +780,7 @@ on_editRedo_activate (GtkMenuItem *menuitem, } journal.pages = g_list_remove(journal.pages, redo->page); journal.npages--; - if (ui.pageno > undo->val || ui.pageno == journal.npages) ui.pageno--; + if (ui.pageno > redo->val || ui.pageno == journal.npages) ui.pageno--; ui.cur_page = NULL; // so do_switch_page() won't try to remap the layers of the defunct page do_switch_page(ui.pageno, TRUE, TRUE); @@ -787,6 +797,10 @@ on_editRedo_activate (GtkMenuItem *menuitem, move_journal_items_by(redo->itemlist, redo->val_x, redo->val_y, redo->layer, redo->layer2, NULL); } + else if (redo->type == ITEM_RESIZESEL) { + resize_journal_items_by(redo->itemlist, + redo->scaling_x, redo->scaling_y, redo->val_x, redo->val_y); + } else if (redo->type == ITEM_PASTE) { for (itemlist = redo->itemlist; itemlist != NULL; itemlist = itemlist->next) { it = (struct Item *)itemlist->data; @@ -828,10 +842,12 @@ on_editRedo_activate (GtkMenuItem *menuitem, g_memmove(&tmp_brush, &(it->brush), sizeof(struct Brush)); g_memmove(&(it->brush), list->data, sizeof(struct Brush)); g_memmove(list->data, &tmp_brush, sizeof(struct Brush)); - if (it->type == ITEM_STROKE && it->canvas_item != NULL) - gnome_canvas_item_set(it->canvas_item, - "fill-color-rgba", it->brush.color_rgba, - "width-units", it->brush.thickness, NULL); + if (it->type == ITEM_STROKE && it->canvas_item != NULL) { + // remark: a variable-width item might have lost its variable-width + group = (GnomeCanvasGroup *) it->canvas_item->parent; + gtk_object_destroy(GTK_OBJECT(it->canvas_item)); + make_canvas_item_one(group, it); + } if (it->type == ITEM_TEXT && it->canvas_item != NULL) gnome_canvas_item_set(it->canvas_item, "fill-color-rgba", it->brush.color_rgba, NULL); @@ -1032,7 +1048,6 @@ on_viewNextPage_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); if (ui.pageno == journal.npages-1) { // create a page at end - if (page_ops_forbidden()) return; on_journalNewPageEnd_activate(menuitem, user_data); return; } @@ -1089,7 +1104,6 @@ on_journalNewPageBefore_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); - if (page_ops_forbidden()) return; reset_selection(); pg = new_page(ui.cur_page); journal.pages = g_list_insert(journal.pages, pg, ui.pageno); @@ -1111,7 +1125,6 @@ on_journalNewPageAfter_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); - if (page_ops_forbidden()) return; reset_selection(); pg = new_page(ui.cur_page); journal.pages = g_list_insert(journal.pages, pg, ui.pageno+1); @@ -1133,7 +1146,6 @@ on_journalNewPageEnd_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); - if (page_ops_forbidden()) return; reset_selection(); pg = new_page((struct Page *)g_list_last(journal.pages)->data); journal.pages = g_list_append(journal.pages, pg); @@ -1156,7 +1168,6 @@ on_journalDeletePage_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); - if (page_ops_forbidden()) return; if (journal.npages == 1) return; reset_selection(); prepare_new_undo(); @@ -1681,8 +1692,9 @@ on_toolsPen_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_PEN; - ui.ruler[0] = FALSE; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); + ui.cur_brush->ruler = ui.default_brushes[TOOL_PEN].ruler; + ui.cur_brush->recognizer = ui.default_brushes[TOOL_PEN].recognizer; update_mapping_linkings(TOOL_PEN); update_tool_buttons(); update_tool_menu(); @@ -1710,7 +1722,6 @@ on_toolsEraser_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_ERASER; - ui.ruler[0] = FALSE; ui.cur_brush = &(ui.brushes[0][TOOL_ERASER]); update_mapping_linkings(TOOL_ERASER); update_tool_buttons(); @@ -1739,8 +1750,9 @@ on_toolsHighlighter_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_HIGHLIGHTER; - ui.ruler[0] = FALSE; ui.cur_brush = &(ui.brushes[0][TOOL_HIGHLIGHTER]); + ui.cur_brush->ruler = ui.default_brushes[TOOL_HIGHLIGHTER].ruler; + ui.cur_brush->recognizer = ui.default_brushes[TOOL_HIGHLIGHTER].recognizer; update_mapping_linkings(TOOL_HIGHLIGHTER); update_tool_buttons(); update_tool_menu(); @@ -1767,7 +1779,6 @@ on_toolsText_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_TEXT; - ui.ruler[0] = FALSE; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); update_mapping_linkings(-1); update_tool_buttons(); @@ -1803,7 +1814,6 @@ on_toolsSelectRectangle_activate (GtkMenuItem *menuitem, end_text(); reset_focus(); ui.toolno[0] = TOOL_SELECTRECT; - ui.ruler[0] = FALSE; update_mapping_linkings(-1); update_tool_buttons(); update_tool_menu(); @@ -1831,7 +1841,6 @@ on_toolsVerticalSpace_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_VERTSPACE; - ui.ruler[0] = FALSE; update_mapping_linkings(-1); update_tool_buttons(); update_tool_menu(); @@ -2093,7 +2102,6 @@ on_toolsDefaultPen_activate (GtkMenuItem *menuitem, g_memmove(&(ui.brushes[0][TOOL_PEN]), ui.default_brushes+TOOL_PEN, sizeof(struct Brush)); ui.toolno[0] = TOOL_PEN; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); - ui.ruler[0] = FALSE; update_mapping_linkings(TOOL_PEN); update_tool_buttons(); update_tool_menu(); @@ -2114,7 +2122,6 @@ on_toolsDefaultEraser_activate (GtkMenuItem *menuitem, g_memmove(&(ui.brushes[0][TOOL_ERASER]), ui.default_brushes+TOOL_ERASER, sizeof(struct Brush)); ui.toolno[0] = TOOL_ERASER; ui.cur_brush = &(ui.brushes[0][TOOL_ERASER]); - ui.ruler[0] = FALSE; update_mapping_linkings(TOOL_ERASER); update_tool_buttons(); update_tool_menu(); @@ -2135,7 +2142,6 @@ on_toolsDefaultHighlighter_activate (GtkMenuItem *menuitem, g_memmove(&(ui.brushes[0][TOOL_HIGHLIGHTER]), ui.default_brushes+TOOL_HIGHLIGHTER, sizeof(struct Brush)); ui.toolno[0] = TOOL_HIGHLIGHTER; ui.cur_brush = &(ui.brushes[0][TOOL_HIGHLIGHTER]); - ui.ruler[0] = FALSE; update_mapping_linkings(TOOL_HIGHLIGHTER); update_tool_buttons(); update_tool_menu(); @@ -2153,7 +2159,6 @@ on_toolsDefaultText_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_TEXT; - ui.ruler[0] = FALSE; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); ui.cur_brush->color_no = ui.default_brushes[TOOL_PEN].color_no; ui.cur_brush->color_rgba = ui.default_brushes[TOOL_PEN].color_rgba; @@ -2207,7 +2212,7 @@ void on_toolsRuler_activate (GtkMenuItem *menuitem, gpointer user_data) { - gboolean active; + gboolean active, current; if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_CHECK_MENU_ITEM) active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); @@ -2215,11 +2220,12 @@ on_toolsRuler_activate (GtkMenuItem *menuitem, active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem)); if (ui.cur_mapping != 0) return; - if (active == ui.ruler[0]) return; + current = (ui.toolno[0] == TOOL_PEN || ui.toolno[0] == TOOL_HIGHLIGHTER) && ui.cur_brush->ruler; + if (active == current) return; end_text(); reset_focus(); - if (active && (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER)) { + if (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER) { reset_selection(); ui.toolno[0] = TOOL_PEN; ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); @@ -2229,7 +2235,45 @@ on_toolsRuler_activate (GtkMenuItem *menuitem, update_cursor(); } - ui.ruler[0] = active; + ui.cur_brush->ruler = active; + if (active) ui.cur_brush->recognizer = FALSE; + update_mapping_linkings(ui.toolno[0]); + update_ruler_indicator(); +} + + +void +on_toolsReco_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + gboolean active, current; + + if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_CHECK_MENU_ITEM) + active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); + else + active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem)); + + if (ui.cur_mapping != 0) return; + current = (ui.toolno[0] == TOOL_PEN || ui.toolno[0] == TOOL_HIGHLIGHTER) && ui.cur_brush->recognizer; + if (active == current) return; + + end_text(); + reset_focus(); + if (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER) { + reset_selection(); + ui.toolno[0] = TOOL_PEN; + ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); + update_color_menu(); + update_tool_buttons(); + update_tool_menu(); + update_cursor(); + } + + ui.cur_brush->recognizer = active; + if (active) { + ui.cur_brush->ruler = FALSE; + reset_recognizer(); + } update_mapping_linkings(ui.toolno[0]); update_ruler_indicator(); } @@ -2284,7 +2328,6 @@ on_buttonToolDefault_clicked (GtkToolButton *toolbutton, switch_mapping(0); if (ui.toolno[0] < NUM_STROKE_TOOLS) { g_memmove(&(ui.brushes[0][ui.toolno[0]]), ui.default_brushes+ui.toolno[0], sizeof(struct Brush)); - ui.ruler[0] = FALSE; update_mapping_linkings(ui.toolno[0]); update_thickness_buttons(); update_color_buttons(); @@ -2341,14 +2384,25 @@ on_canvas_button_press_event (GtkWidget *widget, if (!ui.use_xinput && !is_core) return FALSE; if (ui.use_xinput && is_core && ui.discard_corepointer) return FALSE; if (event->button > 3) return FALSE; // no painting with the mouse wheel! - if (!is_core) { - // re-get the axis values since Synaptics sends bogus ones - gdk_device_get_state(event->device, event->window, event->axes, NULL); + if (event->type != GDK_BUTTON_PRESS) return FALSE; + // double-clicks may have broken axes member (free'd) due to a bug in GDK + if (!is_core) fix_xinput_coords((GdkEvent *)event); - } + +#ifdef INPUT_DEBUG + printf("DEBUG: ButtonDown (%s) (x,y)=(%.2f,%.2f)\n", + is_core?"core":"xinput", event->x, event->y); +#endif + if (!finite(event->x) || !finite(event->y)) return FALSE; // Xorg 7.3 bug if (ui.cur_item_type == ITEM_TEXT && !is_event_within_textview(event)) end_text(); + if (ui.cur_item_type == ITEM_STROKE && ui.is_corestroke && !is_core && + ui.cur_path.num_points == 1) { + // Xorg 7.3+ sent core event before XInput event: fix initial point + ui.is_corestroke = FALSE; + get_pointer_coords((GdkEvent *)event, ui.cur_path.coords); + } if (ui.cur_item_type != ITEM_NONE) return FALSE; // we're already doing something ui.is_corestroke = is_core; @@ -2387,7 +2441,7 @@ on_canvas_button_press_event (GtkWidget *widget, gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); on_viewShowLayer_activate(NULL, NULL); - return; + return FALSE; } // switch mappings if needed @@ -2405,7 +2459,8 @@ on_canvas_button_press_event (GtkWidget *widget, } } - // if this can be a selection move, then it takes precedence over anything else + // if this can be a selection move or resize, then it takes precedence over anything else + if (start_resizesel((GdkEvent *)event)) return FALSE; if (start_movesel((GdkEvent *)event)) return FALSE; if (ui.toolno[mapping] != TOOL_SELECTREGION && ui.toolno[mapping] != TOOL_SELECTRECT) @@ -2416,6 +2471,8 @@ on_canvas_button_press_event (GtkWidget *widget, if (ui.toolno[mapping] == TOOL_HAND) { ui.cur_item_type = ITEM_HAND; get_pointer_coords((GdkEvent *)event, ui.hand_refpt); + ui.hand_refpt[0] += ui.cur_page->hoffset; + ui.hand_refpt[1] += ui.cur_page->voffset; } else if (ui.toolno[mapping] == TOOL_PEN || ui.toolno[mapping] == TOOL_HIGHLIGHTER || (ui.toolno[mapping] == TOOL_ERASER && ui.cur_brush->tool_options == TOOLOPT_ERASER_WHITEOUT)) { @@ -2457,6 +2514,7 @@ on_canvas_button_release_event (GtkWidget *widget, if (ui.cur_item_type == ITEM_STROKE) { finalize_stroke(); + if (ui.cur_brush->recognizer) recognize_patterns(); } else if (ui.cur_item_type == ITEM_ERASURE) { finalize_erasure(); @@ -2467,6 +2525,9 @@ on_canvas_button_release_event (GtkWidget *widget, else if (ui.cur_item_type == ITEM_MOVESEL || ui.cur_item_type == ITEM_MOVESEL_VERT) { finalize_movesel(); } + else if (ui.cur_item_type == ITEM_RESIZESEL) { + finalize_resizesel(); + } else if (ui.cur_item_type == ITEM_HAND) { ui.cur_item_type = ITEM_NONE; } @@ -2501,6 +2562,24 @@ on_canvas_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { + // If zoomed-out and in single page mode, switch pages with PgUp/PgDn. + if (!ui.view_continuous && + (0.96 * ui.zoom * ui.cur_page->height < + GTK_WIDGET(canvas)->allocation.height)) { + if (event->keyval == GDK_Page_Down) { + end_text(); + reset_focus(); + if (ui.pageno == journal.npages-1) { return FALSE; } + do_switch_page(ui.pageno+1, TRUE, FALSE); + } + if (event->keyval == GDK_Page_Up) { + end_text(); + reset_focus(); + if (ui.pageno == 0) { return FALSE; } + do_switch_page(ui.pageno-1, TRUE, FALSE); + } + } + return FALSE; } @@ -2512,19 +2591,37 @@ on_canvas_motion_notify_event (GtkWidget *widget, { gboolean looks_wrong, is_core; double pt[2]; - - if (ui.cur_item_type == ITEM_NONE) return FALSE; // we don't care + + /* we don't care about this event unless some operation is in progress; + or if there's a selection (then we might want to change the mouse + cursor to indicate the possibility of resizing) */ + if (ui.cur_item_type == ITEM_NONE && ui.selection==NULL) return FALSE; is_core = (event->device == gdk_device_get_core_pointer()); if (!ui.use_xinput && !is_core) return FALSE; - if (ui.use_xinput && is_core && !ui.is_corestroke) return FALSE; if (!is_core) fix_xinput_coords((GdkEvent *)event); + if (!finite(event->x) || !finite(event->y)) return FALSE; // Xorg 7.3 bug + + if (ui.selection!=NULL && ui.cur_item_type == ITEM_NONE) { + get_pointer_coords((GdkEvent *)event, pt); + update_cursor_for_resize(pt); + return FALSE; + } + + if (ui.use_xinput && is_core && !ui.is_corestroke) return FALSE; + if (!is_core) ui.is_corestroke = FALSE; +#ifdef INPUT_DEBUG + printf("DEBUG: MotionNotify (%s) (x,y)=(%.2f,%.2f)\n", + is_core?"core":"xinput", event->x, event->y); +#endif + looks_wrong = !(event->state & (1<<(7+ui.which_mouse_button))); if (looks_wrong) { /* mouse button shouldn't be up... give up */ if (ui.cur_item_type == ITEM_STROKE) { finalize_stroke(); + if (ui.cur_brush->recognizer) recognize_patterns(); } else if (ui.cur_item_type == ITEM_ERASURE) { finalize_erasure(); @@ -2535,6 +2632,9 @@ on_canvas_motion_notify_event (GtkWidget *widget, else if (ui.cur_item_type == ITEM_MOVESEL || ui.cur_item_type == ITEM_MOVESEL_VERT) { finalize_movesel(); } + else if (ui.cur_item_type == ITEM_RESIZESEL) { + finalize_resizesel(); + } switch_mapping(0); return FALSE; } @@ -2556,6 +2656,9 @@ on_canvas_motion_notify_event (GtkWidget *widget, else if (ui.cur_item_type == ITEM_MOVESEL || ui.cur_item_type == ITEM_MOVESEL_VERT) { continue_movesel((GdkEvent *)event); } + else if (ui.cur_item_type == ITEM_RESIZESEL) { + continue_resizesel((GdkEvent *)event); + } else if (ui.cur_item_type == ITEM_HAND) { do_hand((GdkEvent *)event); } @@ -2615,8 +2718,29 @@ on_optionsUseXInput_activate (GtkMenuItem *menuitem, reset_focus(); ui.allow_xinput = ui.use_xinput = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); - gtk_widget_set_extension_events(GTK_WIDGET (canvas), + +/* Important note: we'd like ONLY the canvas window itself to receive + XInput events, while its child window in the GDK hierarchy (also + associated to the canvas widget) receives the core events. + This way on_canvas_... will get both types of events -- otherwise, + the proximity detection code in GDK is broken and we'll lose core + events. + + Up to GTK+ 2.10, gtk_widget_set_extension_events() only sets + extension events for the widget's main window itself; in GTK+ 2.11 + also traverses GDK child windows that belong to the widget + and sets their extension events too. We want to avoid that. + So we use gdk_input_set_extension_events() directly on the canvas. +*/ + +/* // this causes GTK+ 2.11 bugs + gtk_widget_set_extension_events(GTK_WIDGET (canvas), ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE); +*/ + gdk_input_set_extension_events(GTK_WIDGET(canvas)->window, + GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, + ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE); + update_mappings_menu(); } @@ -2669,7 +2793,6 @@ on_spinPageNo_value_changed (GtkSpinButton *spinbutton, val = gtk_spin_button_get_value_as_int(spinbutton) - 1; if (val == journal.npages) { // create a page at end - if (page_ops_forbidden()) return; on_journalNewPageEnd_activate(NULL, NULL); return; } @@ -3032,9 +3155,6 @@ on_button2CopyBrush_activate (GtkMenuItem *menuitem, } ui.linked_brush[1] = BRUSH_COPIED; g_memmove(&(ui.brushes[1][ui.toolno[1]]), &(ui.brushes[0][ui.toolno[1]]), sizeof(struct Brush)); - ui.ruler[1] = ui.ruler[0]; - if (ui.toolno[1]!=TOOL_PEN && ui.toolno[1]!=TOOL_HIGHLIGHTER) - ui.ruler[1] = FALSE; } @@ -3122,9 +3242,6 @@ on_button3CopyBrush_activate (GtkMenuItem *menuitem, } ui.linked_brush[2] = BRUSH_COPIED; g_memmove(&(ui.brushes[2][ui.toolno[2]]), &(ui.brushes[0][ui.toolno[2]]), sizeof(struct Brush)); - ui.ruler[2] = ui.ruler[0]; - if (ui.toolno[2]!=TOOL_PEN && ui.toolno[2]!=TOOL_HIGHLIGHTER) - ui.ruler[2] = FALSE; } // the set zoom dialog @@ -3254,7 +3371,6 @@ on_toolsHand_activate (GtkMenuItem *menuitem, reset_focus(); reset_selection(); ui.toolno[0] = TOOL_HAND; - ui.ruler[0] = FALSE; update_mapping_linkings(-1); update_tool_buttons(); update_tool_menu(); @@ -3309,3 +3425,72 @@ on_fontButton_font_set (GtkFontButton *fontbutton, process_font_sel(str); } +void +on_optionsLeftHanded_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + end_text(); + reset_focus(); + ui.left_handed = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); + gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(GET_COMPONENT("scrolledwindowMain")), + ui.left_handed?GTK_CORNER_TOP_RIGHT:GTK_CORNER_TOP_LEFT); +} + +void +on_optionsShortenMenus_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + gchar *item, *nextptr; + GtkWidget *w; + + end_text(); + reset_focus(); + ui.shorten_menus = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); + + /* go over the item list */ + item = ui.shorten_menu_items; + while (*item==' ') item++; + while (*item) { + nextptr = strchr(item, ' '); + if (nextptr!=NULL) *nextptr = 0; + // hide or show the item + w = GET_COMPONENT(item); + if (w != NULL) { + if (ui.shorten_menus) gtk_widget_hide(w); + else gtk_widget_show(w); + } + // next item + if (nextptr==NULL) break; + *nextptr = ' '; + item = nextptr; + while (*item==' ') item++; + } + + // just in case someone tried to unhide stuff they shouldn't be seeing + hide_unimplemented(); + // maybe we should also make sure the drawing area stays visible ? +} + +void +on_optionsAutoSavePrefs_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + end_text(); + reset_focus(); + ui.auto_save_prefs = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); +} + +void +on_optionsPressureSensitive_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + int i; + end_text(); + reset_focus(); + ui.pressure_sensitivity = + gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); + for (i=0; i<=NUM_BUTTONS; i++) + ui.brushes[i][TOOL_PEN].variable_width = ui.pressure_sensitivity; + update_mappings_menu(); +} +