X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fxo-callbacks.c;h=6d38176e20afed678de470fee2602c5994b229ba;hb=13d7457867c57ac5ac826df4d6b478fee795c0a4;hp=038507ad4724ae69c38de812836065d787d0dc2d;hpb=64fbee630efe4a6a731bcc7b68855d933946b050;p=xournal.git diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c index 038507a..6d38176 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,11 +19,14 @@ #include "xo-file.h" #include "xo-paint.h" #include "xo-print.h" +#include "xo-shapes.h" void on_fileNew_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); if (close_journal()) { new_journal(); ui.zoom = ui.startup_zoom; @@ -43,24 +47,27 @@ on_fileNewBackground_activate (GtkMenuItem *menuitem, int file_domain; gboolean success; + end_text(); + reset_focus(); if (!ok_to_close()) return; // user aborted on save confirmation - dialog = gtk_file_chooser_dialog_new("Open PDF", GTK_WINDOW (winMain), + dialog = gtk_file_chooser_dialog_new(_("Open PDF"), GTK_WINDOW (winMain), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); filt_all = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_all, "All files"); + gtk_file_filter_set_name(filt_all, _("All files")); gtk_file_filter_add_pattern(filt_all, "*"); filt_pdf = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_pdf, "PDF files"); + gtk_file_filter_set_name(filt_pdf, _("PDF files")); gtk_file_filter_add_pattern(filt_pdf, "*.pdf"); + gtk_file_filter_add_pattern(filt_pdf, "*.PDF"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_pdf); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all); if (ui.default_path!=NULL) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), ui.default_path); - attach_opt = gtk_check_button_new_with_label("Attach file to the journal"); + attach_opt = gtk_check_button_new_with_label(_("Attach file to the journal")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attach_opt), FALSE); gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER (dialog), attach_opt); @@ -95,7 +102,7 @@ on_fileNewBackground_activate (GtkMenuItem *menuitem, /* open failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error opening file '%s'", filename); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_free(filename); @@ -111,17 +118,19 @@ on_fileOpen_activate (GtkMenuItem *menuitem, char *filename; gboolean success; + end_text(); + reset_focus(); if (!ok_to_close()) return; // user aborted on save confirmation - dialog = gtk_file_chooser_dialog_new("Open Journal", GTK_WINDOW (winMain), + dialog = gtk_file_chooser_dialog_new(_("Open Journal"), GTK_WINDOW (winMain), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); filt_all = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_all, "All files"); + gtk_file_filter_set_name(filt_all, _("All files")); gtk_file_filter_add_pattern(filt_all, "*"); filt_xoj = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_xoj, "Xournal files"); + gtk_file_filter_set_name(filt_xoj, _("Xournal files")); gtk_file_filter_add_pattern(filt_xoj, "*.xoj"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_xoj); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all); @@ -142,7 +151,7 @@ on_fileOpen_activate (GtkMenuItem *menuitem, /* open failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error opening file '%s'", filename); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_free(filename); @@ -156,6 +165,8 @@ on_fileSave_activate (GtkMenuItem *menuitem, { GtkWidget *dialog; + end_text(); + reset_focus(); if (ui.filename == NULL) { on_fileSaveAs_activate(menuitem, user_data); return; @@ -169,7 +180,7 @@ on_fileSave_activate (GtkMenuItem *menuitem, set_cursor_busy(FALSE); /* save failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error saving file '%s'", ui.filename); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error saving file '%s'"), ui.filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } @@ -187,7 +198,9 @@ on_fileSaveAs_activate (GtkMenuItem *menuitem, gboolean warn; struct stat stat_buf; - dialog = gtk_file_chooser_dialog_new("Save Journal", GTK_WINDOW (winMain), + end_text(); + reset_focus(); + dialog = gtk_file_chooser_dialog_new(_("Save Journal"), GTK_WINDOW (winMain), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); @@ -212,10 +225,10 @@ on_fileSaveAs_activate (GtkMenuItem *menuitem, } filt_all = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_all, "All files"); + gtk_file_filter_set_name(filt_all, _("All files")); gtk_file_filter_add_pattern(filt_all, "*"); filt_xoj = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_xoj, "Xournal files"); + gtk_file_filter_set_name(filt_xoj, _("Xournal files")); gtk_file_filter_add_pattern(filt_xoj, "*.xoj"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_xoj); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all); @@ -241,7 +254,7 @@ on_fileSaveAs_activate (GtkMenuItem *menuitem, if (warn) { warning_dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - "Should the file %s be overwritten?", filename); + _("Should the file %s be overwritten?"), filename); if (gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES) warn = FALSE; gtk_widget_destroy(warning_dialog); @@ -260,7 +273,7 @@ on_fileSaveAs_activate (GtkMenuItem *menuitem, set_cursor_busy(FALSE); /* save failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error saving file '%s'", filename); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error saving file '%s'"), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_free(filename); @@ -279,7 +292,7 @@ void on_filePrint_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget *printDialog, *preview; + GtkWidget *printDialog; GnomePrintJob *gpj; int fromPage, toPage; int response; @@ -287,6 +300,8 @@ on_filePrint_activate (GtkMenuItem *menuitem, guchar *s; GnomePrintConfig *config = gnome_print_config_default(); + end_text(); + reset_focus(); if (ui.filename!=NULL) { if (g_str_has_suffix(ui.filename, ".xoj")) { in_fn = g_strdup(ui.filename); @@ -311,10 +326,10 @@ on_filePrint_activate (GtkMenuItem *menuitem, gpj = gnome_print_job_new(config); /* was NULL */ gnome_print_config_unref(config); /* end */ - printDialog = gnome_print_dialog_new(gpj, (guchar *)"Print", GNOME_PRINT_DIALOG_RANGE); + printDialog = gnome_print_dialog_new(gpj, (guchar *) _("Print"), GNOME_PRINT_DIALOG_RANGE); gnome_print_dialog_construct_range_page(GNOME_PRINT_DIALOG(printDialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_RANGE, - 1, journal.npages, (guchar *)"Current page", (guchar *)"Pages"); + 1, journal.npages, (guchar *) _("Current page"), (guchar *) _("Pages")); /* don't have "Current page" as option, else it becomes the default!! */ gtk_dialog_set_response_sensitive(GTK_DIALOG(printDialog), @@ -366,10 +381,11 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem, char *filename, *in_fn; char stime[30]; time_t curtime; - int response; gboolean warn; - dialog = gtk_file_chooser_dialog_new("Export to PDF", GTK_WINDOW (winMain), + end_text(); + reset_focus(); + dialog = gtk_file_chooser_dialog_new(_("Export to PDF"), GTK_WINDOW (winMain), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL); @@ -392,11 +408,12 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem, } filt_all = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_all, "All files"); + gtk_file_filter_set_name(filt_all, _("All files")); gtk_file_filter_add_pattern(filt_all, "*"); filt_pdf = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_pdf, "PDF files"); + gtk_file_filter_set_name(filt_pdf, _("PDF files")); gtk_file_filter_add_pattern(filt_pdf, "*.pdf"); + gtk_file_filter_add_pattern(filt_pdf, "*.PDF"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_pdf); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); @@ -412,7 +429,7 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem, if (warn) { warning_dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, - "Should the file %s be overwritten?", filename); + _("Should the file %s be overwritten?"), filename); if (gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES) warn = FALSE; gtk_widget_destroy(warning_dialog); @@ -425,7 +442,7 @@ on_filePrintPDF_activate (GtkMenuItem *menuitem, if (!print_to_pdf(filename)) { set_cursor_busy(FALSE); dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error creating file '%s'", filename); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error creating file '%s'"), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } @@ -438,6 +455,8 @@ void on_fileQuit_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); if (ok_to_close()) gtk_main_quit (); } @@ -453,10 +472,14 @@ on_editUndo_activate (GtkMenuItem *menuitem, struct Brush tmp_brush; struct Background *tmp_bg; double tmp_x, tmp_y; + gchar *tmpstr; + GnomeCanvasGroup *group; + end_text(); + reset_focus(); if (undo == NULL) return; // nothing to undo! reset_selection(); // safer - if (undo->type == ITEM_STROKE) { + if (undo->type == ITEM_STROKE || undo->type == ITEM_TEXT) { // we're keeping the stroke info, but deleting the canvas item gtk_object_destroy(GTK_OBJECT(undo->item->canvas_item)); undo->item->canvas_item = NULL; @@ -464,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 @@ -476,11 +499,8 @@ on_editUndo_activate (GtkMenuItem *menuitem, undo->layer->nitems--; } // recreate the deleted one - erasure->item->canvas_item = gnome_canvas_item_new(undo->layer->group, - gnome_canvas_line_get_type(), "points", erasure->item->path, - "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, - "fill-color-rgba", erasure->item->brush.color_rgba, - "width-units", erasure->item->brush.thickness, NULL); + make_canvas_item_one(undo->layer->group, erasure->item); + undo->layer->items = g_list_insert(undo->layer->items, erasure->item, erasure->npos); if (erasure->npos == 0) @@ -556,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; @@ -592,16 +617,9 @@ on_editUndo_activate (GtkMenuItem *menuitem, (undo->val >= 0) ? undo->val:0); undo->page->nlayers++; - for (itemlist = undo->layer->items; itemlist!=NULL; itemlist = itemlist->next) { - it = (struct Item *)itemlist->data; - if (it->type == ITEM_STROKE) { - it->canvas_item = gnome_canvas_item_new(undo->layer->group, - gnome_canvas_line_get_type(), "points", it->path, - "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, - "fill-color-rgba", it->brush.color_rgba, - "width-units", it->brush.thickness, NULL); - } - } + for (itemlist = undo->layer->items; itemlist!=NULL; itemlist = itemlist->next) + make_canvas_item_one(undo->layer->group, (struct Item *)itemlist->data); + do_switch_page(ui.pageno, FALSE, FALSE); // show the restored layer & others... } else if (undo->type == ITEM_REPAINTSEL) { @@ -611,12 +629,39 @@ 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) + 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, - "width-units", it->brush.thickness, NULL); + "fill-color-rgba", it->brush.color_rgba, NULL); } } + else if (undo->type == ITEM_TEXT_EDIT) { + tmpstr = undo->str; + undo->str = undo->item->text; + undo->item->text = tmpstr; + gnome_canvas_item_set(undo->item->canvas_item, "text", tmpstr, NULL); + update_item_bbox(undo->item); + } + else if (undo->type == ITEM_TEXT_ATTRIB) { + tmpstr = undo->str; + undo->str = undo->item->font_name; + undo->item->font_name = tmpstr; + tmp_x = undo->val_x; + undo->val_x = undo->item->font_size; + undo->item->font_size = tmp_x; + g_memmove(&tmp_brush, undo->brush, sizeof(struct Brush)); + g_memmove(undo->brush, &(undo->item->brush), sizeof(struct Brush)); + g_memmove(&(undo->item->brush), &tmp_brush, sizeof(struct Brush)); + gnome_canvas_item_set(undo->item->canvas_item, + "fill-color-rgba", undo->item->brush.color_rgba, NULL); + update_text_item_displayfont(undo->item); + update_item_bbox(undo->item); + } // move item from undo to redo stack u = undo; @@ -641,32 +686,28 @@ on_editRedo_activate (GtkMenuItem *menuitem, struct Background *tmp_bg; struct Layer *l; double tmp_x, tmp_y; + gchar *tmpstr; + GnomeCanvasGroup *group; + end_text(); + reset_focus(); if (redo == NULL) return; // nothing to redo! reset_selection(); // safer - if (redo->type == ITEM_STROKE) { + if (redo->type == ITEM_STROKE || redo->type == ITEM_TEXT) { // re-create the canvas_item - redo->item->canvas_item = gnome_canvas_item_new(redo->layer->group, - gnome_canvas_line_get_type(), "points", redo->item->path, - "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, - "fill-color-rgba", redo->item->brush.color_rgba, - "width-units", redo->item->brush.thickness, NULL); + make_canvas_item_one(redo->layer->group, redo->item); // reinsert the item on its layer 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); // re-create all the created items for (itemlist = erasure->replacement_items; itemlist!=NULL; itemlist = itemlist->next) { it = (struct Item *)itemlist->data; - it->canvas_item = gnome_canvas_item_new(redo->layer->group, - gnome_canvas_line_get_type(), "points", it->path, - "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, - "fill-color-rgba", it->brush.color_rgba, - "width-units", it->brush.thickness, NULL); + make_canvas_item_one(redo->layer->group, it); redo->layer->items = g_list_insert_before(redo->layer->items, target, it); redo->layer->nitems++; lower_canvas_item_to(redo->layer->group, it->canvas_item, erasure->item->canvas_item); @@ -739,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); @@ -756,14 +797,14 @@ 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; - it->canvas_item = gnome_canvas_item_new(redo->layer->group, - gnome_canvas_line_get_type(), "points", it->path, - "cap-style", GDK_CAP_ROUND, "join-style", GDK_JOIN_ROUND, - "fill-color-rgba", it->brush.color_rgba, - "width-units", it->brush.thickness, NULL); + make_canvas_item_one(redo->layer->group, it); redo->layer->items = g_list_append(redo->layer->items, it); redo->layer->nitems++; } @@ -801,12 +842,39 @@ 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) + 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, - "width-units", it->brush.thickness, NULL); + "fill-color-rgba", it->brush.color_rgba, NULL); } } + else if (redo->type == ITEM_TEXT_EDIT) { + tmpstr = redo->str; + redo->str = redo->item->text; + redo->item->text = tmpstr; + gnome_canvas_item_set(redo->item->canvas_item, "text", tmpstr, NULL); + update_item_bbox(redo->item); + } + else if (redo->type == ITEM_TEXT_ATTRIB) { + tmpstr = redo->str; + redo->str = redo->item->font_name; + redo->item->font_name = tmpstr; + tmp_x = redo->val_x; + redo->val_x = redo->item->font_size; + redo->item->font_size = tmp_x; + g_memmove(&tmp_brush, redo->brush, sizeof(struct Brush)); + g_memmove(redo->brush, &(redo->item->brush), sizeof(struct Brush)); + g_memmove(&(redo->item->brush), &tmp_brush, sizeof(struct Brush)); + gnome_canvas_item_set(redo->item->canvas_item, + "fill-color-rgba", redo->item->brush.color_rgba, NULL); + update_text_item_displayfont(redo->item); + update_item_bbox(redo->item); + } // move item from redo to undo stack u = redo; @@ -823,6 +891,8 @@ void on_editCut_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); selection_to_clip(); selection_delete(); } @@ -832,6 +902,8 @@ void on_editCopy_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); selection_to_clip(); } @@ -840,6 +912,8 @@ void on_editPaste_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); clipboard_paste(); } @@ -848,6 +922,8 @@ void on_editDelete_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); selection_delete(); } @@ -860,6 +936,7 @@ on_viewContinuous_activate (GtkMenuItem *menuitem, double yscroll; struct Page *pg; + reset_focus(); if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; if (ui.view_continuous) return; ui.view_continuous = TRUE; @@ -880,6 +957,7 @@ on_viewOnePage_activate (GtkMenuItem *menuitem, GtkAdjustment *v_adj; double yscroll; + reset_focus(); if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; if (!ui.view_continuous) return; ui.view_continuous = FALSE; @@ -896,9 +974,11 @@ void on_viewZoomIn_activate (GtkMenuItem *menuitem, gpointer user_data) { + reset_focus(); if (ui.zoom > MAX_ZOOM) return; ui.zoom *= ui.zoom_step_factor; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } @@ -907,9 +987,11 @@ void on_viewZoomOut_activate (GtkMenuItem *menuitem, gpointer user_data) { + reset_focus(); if (ui.zoom < MIN_ZOOM) return; ui.zoom /= ui.zoom_step_factor; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } @@ -918,8 +1000,10 @@ void on_viewNormalSize_activate (GtkMenuItem *menuitem, gpointer user_data) { + reset_focus(); ui.zoom = DEFAULT_ZOOM; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } @@ -928,8 +1012,10 @@ void on_viewPageWidth_activate (GtkMenuItem *menuitem, gpointer user_data) { + reset_focus(); ui.zoom = (GTK_WIDGET(canvas))->allocation.width/ui.cur_page->width; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } @@ -938,6 +1024,8 @@ void on_viewFirstPage_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); do_switch_page(0, TRUE, FALSE); } @@ -946,6 +1034,8 @@ void on_viewPreviousPage_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); if (ui.pageno == 0) return; do_switch_page(ui.pageno-1, TRUE, FALSE); } @@ -955,8 +1045,9 @@ void on_viewNextPage_activate (GtkMenuItem *menuitem, gpointer user_data) { + 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; } @@ -968,6 +1059,8 @@ void on_viewLastPage_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); do_switch_page(journal.npages-1, TRUE, FALSE); } @@ -976,6 +1069,8 @@ void on_viewShowLayer_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); if (ui.layerno == ui.cur_page->nlayers-1) return; reset_selection(); ui.layerno++; @@ -989,6 +1084,8 @@ void on_viewHideLayer_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); if (ui.layerno == -1) return; reset_selection(); gnome_canvas_item_hide(GNOME_CANVAS_ITEM(ui.cur_layer->group)); @@ -1005,7 +1102,8 @@ on_journalNewPageBefore_activate (GtkMenuItem *menuitem, { struct Page *pg; - if (page_ops_forbidden()) return; + end_text(); + reset_focus(); reset_selection(); pg = new_page(ui.cur_page); journal.pages = g_list_insert(journal.pages, pg, ui.pageno); @@ -1025,7 +1123,8 @@ on_journalNewPageAfter_activate (GtkMenuItem *menuitem, { struct Page *pg; - if (page_ops_forbidden()) return; + end_text(); + reset_focus(); reset_selection(); pg = new_page(ui.cur_page); journal.pages = g_list_insert(journal.pages, pg, ui.pageno+1); @@ -1045,7 +1144,8 @@ on_journalNewPageEnd_activate (GtkMenuItem *menuitem, { struct Page *pg; - if (page_ops_forbidden()) return; + end_text(); + reset_focus(); reset_selection(); pg = new_page((struct Page *)g_list_last(journal.pages)->data); journal.pages = g_list_append(journal.pages, pg); @@ -1066,7 +1166,8 @@ on_journalDeletePage_activate (GtkMenuItem *menuitem, GList *layerlist, *itemlist; struct Layer *l; - if (page_ops_forbidden()) return; + end_text(); + reset_focus(); if (journal.npages == 1) return; reset_selection(); prepare_new_undo(); @@ -1100,6 +1201,8 @@ on_journalNewLayer_activate (GtkMenuItem *menuitem, { struct Layer *l; + end_text(); + reset_focus(); reset_selection(); l = g_new(struct Layer, 1); l->items = NULL; @@ -1128,6 +1231,8 @@ on_journalDeleteLayer_activate (GtkMenuItem *menuitem, { GList *list; + end_text(); + reset_focus(); if (ui.cur_layer == NULL) return; reset_selection(); prepare_new_undo(); @@ -1199,6 +1304,8 @@ on_journalPaperSize_activate (GtkMenuItem *menuitem, struct Page *pg; GList *pglist; + end_text(); + reset_focus(); papersize_dialog = create_papersizeDialog(); papersize_width = ui.cur_page->width; papersize_height = ui.cur_page->height; @@ -1248,6 +1355,8 @@ void on_papercolorWhite_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_WHITE); } @@ -1256,6 +1365,8 @@ void on_papercolorYellow_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_YELLOW); } @@ -1264,6 +1375,8 @@ void on_papercolorPink_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_RED); } @@ -1272,6 +1385,8 @@ void on_papercolorOrange_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_ORANGE); } @@ -1280,6 +1395,8 @@ void on_papercolorBlue_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_BLUE); } @@ -1288,6 +1405,8 @@ void on_papercolorGreen_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_papercolor_activate(menuitem, COLOR_GREEN); } @@ -1304,6 +1423,8 @@ void on_paperstylePlain_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_paperstyle_activate(menuitem, RULING_NONE); } @@ -1312,6 +1433,8 @@ void on_paperstyleLined_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_paperstyle_activate(menuitem, RULING_LINED); } @@ -1320,6 +1443,8 @@ void on_paperstyleRuled_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_paperstyle_activate(menuitem, RULING_RULED); } @@ -1328,6 +1453,8 @@ void on_paperstyleGraph_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); process_paperstyle_activate(menuitem, RULING_GRAPH); } @@ -1345,12 +1472,14 @@ on_journalLoadBackground_activate (GtkMenuItem *menuitem, char *filename; gboolean attach; - dialog = gtk_file_chooser_dialog_new("Open Background", GTK_WINDOW (winMain), + end_text(); + reset_focus(); + dialog = gtk_file_chooser_dialog_new(_("Open Background"), GTK_WINDOW (winMain), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); filt_all = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_all, "All files"); + gtk_file_filter_set_name(filt_all, _("All files")); gtk_file_filter_add_pattern(filt_all, "*"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all); @@ -1358,7 +1487,7 @@ on_journalLoadBackground_activate (GtkMenuItem *menuitem, if (!gtk_check_version(2, 6, 0)) { filt_pix = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_pix, "Bitmap files"); + gtk_file_filter_set_name(filt_pix, _("Bitmap files")); gtk_file_filter_add_pixbuf_formats(filt_pix); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_pix); } @@ -1366,12 +1495,14 @@ on_journalLoadBackground_activate (GtkMenuItem *menuitem, #endif filt_pspdf = gtk_file_filter_new(); - gtk_file_filter_set_name(filt_pspdf, "PS/PDF files (as bitmaps)"); + gtk_file_filter_set_name(filt_pspdf, _("PS/PDF files (as bitmaps)")); gtk_file_filter_add_pattern(filt_pspdf, "*.ps"); + gtk_file_filter_add_pattern(filt_pspdf, "*.PS"); gtk_file_filter_add_pattern(filt_pspdf, "*.pdf"); + gtk_file_filter_add_pattern(filt_pspdf, "*.PDF"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_pspdf); - attach_opt = gtk_check_button_new_with_label("Attach file to the journal"); + attach_opt = gtk_check_button_new_with_label(_("Attach file to the journal")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attach_opt), FALSE); gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER (dialog), attach_opt); @@ -1394,7 +1525,7 @@ on_journalLoadBackground_activate (GtkMenuItem *menuitem, if (bglist == NULL) { dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Error opening background '%s'", filename); + _("Error opening background '%s'"), filename); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_free(filename); @@ -1444,6 +1575,7 @@ on_journalLoadBackground_activate (GtkMenuItem *menuitem, if (ui.zoom != DEFAULT_ZOOM) { ui.zoom = DEFAULT_ZOOM; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } do_switch_page(ui.pageno, TRUE, TRUE); @@ -1455,6 +1587,8 @@ on_journalScreenshot_activate (GtkMenuItem *menuitem, { struct Background *bg; + end_text(); + reset_focus(); reset_selection(); gtk_window_iconify(GTK_WINDOW(winMain)); // hide ourselves gdk_display_sync(gdk_display_get_default()); @@ -1488,6 +1622,7 @@ on_journalScreenshot_activate (GtkMenuItem *menuitem, if (ui.zoom != DEFAULT_ZOOM) { ui.zoom = DEFAULT_ZOOM; gnome_canvas_set_pixels_per_unit(canvas, ui.zoom); + rescale_text_items(); rescale_bg_pixmaps(); } do_switch_page(ui.pageno, TRUE, TRUE); @@ -1500,6 +1635,8 @@ on_journalApplyAllPages_activate (GtkMenuItem *menuitem, { gboolean active; + end_text(); + reset_focus(); active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); if (active == ui.bg_apply_all_pages) return; ui.bg_apply_all_pages = active; @@ -1551,10 +1688,13 @@ on_toolsPen_activate (GtkMenuItem *menuitem, if (ui.cur_mapping != 0) return; if (ui.toolno[0] == TOOL_PEN) return; + end_text(); + 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(); @@ -1578,9 +1718,10 @@ on_toolsEraser_activate (GtkMenuItem *menuitem, if (ui.cur_mapping != 0) return; if (ui.toolno[0] == TOOL_ERASER) return; + end_text(); + 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(); @@ -1605,10 +1746,13 @@ on_toolsHighlighter_activate (GtkMenuItem *menuitem, if (ui.cur_mapping != 0) return; // not user-generated if (ui.toolno[0] == TOOL_HIGHLIGHTER) return; + end_text(); + 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(); @@ -1621,7 +1765,26 @@ void on_toolsText_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; // not user-generated + if (ui.toolno[0] == TOOL_TEXT) return; + + reset_focus(); + reset_selection(); + ui.toolno[0] = TOOL_TEXT; + ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); + update_mapping_linkings(-1); + update_tool_buttons(); + update_tool_menu(); + update_color_menu(); + update_cursor(); } @@ -1648,8 +1811,9 @@ on_toolsSelectRectangle_activate (GtkMenuItem *menuitem, if (ui.cur_mapping != 0) return; // not user-generated if (ui.toolno[0] == TOOL_SELECTRECT) return; + end_text(); + reset_focus(); ui.toolno[0] = TOOL_SELECTRECT; - ui.ruler[0] = FALSE; update_mapping_linkings(-1); update_tool_buttons(); update_tool_menu(); @@ -1673,9 +1837,10 @@ on_toolsVerticalSpace_activate (GtkMenuItem *menuitem, if (ui.cur_mapping != 0) return; // not user-generated if (ui.toolno[0] == TOOL_VERTSPACE) return; + end_text(); + reset_focus(); reset_selection(); ui.toolno[0] = TOOL_VERTSPACE; - ui.ruler[0] = FALSE; update_mapping_linkings(-1); update_tool_buttons(); update_tool_menu(); @@ -1850,6 +2015,8 @@ on_eraserStandard_activate (GtkMenuItem *menuitem, gpointer user_data) { if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; + end_text(); + reset_focus(); ui.brushes[0][TOOL_ERASER].tool_options = TOOLOPT_ERASER_STANDARD; update_mapping_linkings(TOOL_ERASER); } @@ -1860,6 +2027,8 @@ on_eraserWhiteout_activate (GtkMenuItem *menuitem, gpointer user_data) { if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; + end_text(); + reset_focus(); ui.brushes[0][TOOL_ERASER].tool_options = TOOLOPT_ERASER_WHITEOUT; update_mapping_linkings(TOOL_ERASER); } @@ -1870,6 +2039,8 @@ on_eraserDeleteStrokes_activate (GtkMenuItem *menuitem, gpointer user_data) { if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) return; + end_text(); + reset_focus(); ui.brushes[0][TOOL_ERASER].tool_options = TOOLOPT_ERASER_STROKES; update_mapping_linkings(TOOL_ERASER); } @@ -1903,20 +2074,34 @@ void on_toolsTextFont_activate (GtkMenuItem *menuitem, gpointer user_data) { - -} - + GtkWidget *dialog; + gchar *str; + + dialog = gtk_font_selection_dialog_new(_("Select Font")); + str = make_cur_font_name(); + gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog), str); + g_free(str); + if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) { + gtk_widget_destroy(dialog); + reset_focus(); + return; + } + str = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog)); + gtk_widget_destroy(dialog); + process_font_sel(str); +} void on_toolsDefaultPen_activate (GtkMenuItem *menuitem, gpointer user_data) { switch_mapping(0); + end_text(); + reset_focus(); reset_selection(); 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(); @@ -1931,11 +2116,12 @@ on_toolsDefaultEraser_activate (GtkMenuItem *menuitem, gpointer user_data) { switch_mapping(0); + end_text(); + reset_focus(); reset_selection(); 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(); @@ -1950,11 +2136,12 @@ on_toolsDefaultHighlighter_activate (GtkMenuItem *menuitem, gpointer user_data) { switch_mapping(0); + end_text(); + reset_focus(); reset_selection(); 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(); @@ -1967,7 +2154,26 @@ void on_toolsDefaultText_activate (GtkMenuItem *menuitem, gpointer user_data) { - + switch_mapping(0); + if (ui.toolno[0]!=TOOL_TEXT) end_text(); + reset_focus(); + reset_selection(); + ui.toolno[0] = TOOL_TEXT; + 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; + g_free(ui.font_name); + ui.font_name = g_strdup(ui.default_font_name); + ui.font_size = ui.default_font_size; + if (ui.cur_item_type == ITEM_TEXT) { + refont_text_item(ui.cur_item, ui.font_name, ui.font_size); + } + update_font_button(); + update_mapping_linkings(-1); + update_tool_buttons(); + update_tool_menu(); + update_color_menu(); + update_cursor(); } @@ -1975,9 +2181,30 @@ void on_toolsSetAsDefault_activate (GtkMenuItem *menuitem, gpointer user_data) { + struct Item *it; + if (ui.cur_mapping!=0) return; if (ui.toolno[0] < NUM_STROKE_TOOLS) g_memmove(ui.default_brushes+ui.toolno[0], &(ui.brushes[0][ui.toolno[0]]), sizeof(struct Brush)); + if (ui.toolno[0] == TOOL_TEXT) { + if (ui.cur_item_type == ITEM_TEXT) { + g_free(ui.font_name); + ui.font_name = g_strdup(ui.cur_item->font_name); + ui.font_size = ui.cur_item->font_size; + } + else if (ui.selection!=NULL && ui.selection->items!=NULL && + ui.selection->items->next==NULL && + (it=(struct Item*)ui.selection->items->data)->type == ITEM_TEXT) { + g_free(ui.font_name); + ui.font_name = g_strdup(it->font_name); + ui.font_size = it->font_size; + } + g_free(ui.default_font_name); + ui.default_font_name = g_strdup(ui.font_name); + ui.default_font_size = ui.font_size; + } + end_text(); + reset_focus(); } @@ -1985,7 +2212,41 @@ 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)); + 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->ruler; + 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->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)); @@ -1993,9 +2254,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->recognizer; + if (active == current) return; - if (active && (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER)) { + 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]); @@ -2005,7 +2269,11 @@ on_toolsRuler_activate (GtkMenuItem *menuitem, update_cursor(); } - ui.ruler[0] = active; + ui.cur_brush->recognizer = active; + if (active) { + ui.cur_brush->ruler = FALSE; + reset_recognizer(); + } update_mapping_linkings(ui.toolno[0]); update_ruler_indicator(); } @@ -2015,6 +2283,8 @@ void on_optionsSavePreferences_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); save_config_to_file(); } @@ -2034,6 +2304,8 @@ on_helpAbout_activate (GtkMenuItem *menuitem, GtkWidget *aboutDialog; GtkLabel *labelTitle; + end_text(); + reset_focus(); aboutDialog = create_aboutDialog (); labelTitle = GTK_LABEL(g_object_get_data(G_OBJECT(aboutDialog), "labelTitle")); gtk_label_set_markup(labelTitle, @@ -2047,10 +2319,15 @@ void on_buttonToolDefault_clicked (GtkToolButton *toolbutton, gpointer user_data) { + if (ui.toolno[0]==TOOL_TEXT) { + on_toolsDefaultText_activate(NULL, NULL); + return; + } + end_text(); + reset_focus(); 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(); @@ -2101,18 +2378,38 @@ on_canvas_button_press_event (GtkWidget *widget, GtkWidget *dialog; int mapping; gboolean is_core; - - if (ui.cur_item_type != ITEM_NONE) return FALSE; // we're already doing something - if (event->button > 3) return FALSE; // no painting with the mouse wheel! + struct Item *item; is_core = (event->device == gdk_device_get_core_pointer()); if (!ui.use_xinput && !is_core) return FALSE; if (ui.use_xinput && is_core && ui.discard_corepointer) return FALSE; - 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->button > 3) return FALSE; // no painting with the mouse wheel! + 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) { + if (!is_event_within_textview(event)) end_text(); +/* // bugfix for GTK+ 2.17, no longer needed as XInput is disabled during text edition + else fix_extended_events(ui.cur_item->widget, (GdkEvent *)event, + gtk_text_view_get_window(GTK_TEXT_VIEW(ui.cur_item->widget), GTK_TEXT_WINDOW_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; if (ui.use_erasertip && event->device->source == GDK_SOURCE_ERASER) @@ -2144,12 +2441,12 @@ on_canvas_button_press_event (GtkWidget *widget, if (ui.cur_layer == NULL) { /* warn */ dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Drawing is not allowed on the " - "background layer.\n Switching to Layer 1."); + GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Drawing is not allowed on the " + "background layer.\n Switching to Layer 1.")); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); on_viewShowLayer_activate(NULL, NULL); - return; + return FALSE; } // switch mappings if needed @@ -2157,7 +2454,18 @@ on_canvas_button_press_event (GtkWidget *widget, ui.which_mouse_button = event->button; switch_mapping(mapping); - // if this can be a selection move, then it takes precedence over anything else + // in text tool, clicking in a text area edits it + if (ui.toolno[mapping] == TOOL_TEXT) { + item = click_is_in_text(ui.cur_layer, pt[0], pt[1]); + if (item!=NULL) { + reset_selection(); + start_text((GdkEvent *)event, item); + return FALSE; + } + } + + // 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) @@ -2168,6 +2476,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)) { @@ -2184,6 +2494,9 @@ on_canvas_button_press_event (GtkWidget *widget, else if (ui.toolno[mapping] == TOOL_VERTSPACE) { start_vertspace((GdkEvent *)event); } + else if (ui.toolno[mapping] == TOOL_TEXT) { + start_text((GdkEvent *)event, NULL); + } return FALSE; } @@ -2206,6 +2519,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(); @@ -2216,6 +2530,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; } @@ -2234,6 +2551,21 @@ on_canvas_enter_notify_event (GtkWidget *widget, return FALSE; } +gboolean +on_canvas_leave_notify_event (GtkWidget *widget, + GdkEventCrossing *event, + gpointer user_data) +{ +#ifdef INPUT_DEBUG + printf("DEBUG: leave notify\n"); +#endif + if (ui.need_emergency_disable_xinput) { + gtk_widget_set_extension_events(GTK_WIDGET (canvas), GDK_EXTENSION_EVENTS_NONE); + ui.need_emergency_disable_xinput = FALSE; + } + return FALSE; +} + gboolean on_canvas_expose_event (GtkWidget *widget, @@ -2250,6 +2582,23 @@ 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; } @@ -2262,19 +2611,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(); @@ -2285,6 +2652,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; } @@ -2306,6 +2676,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); } @@ -2321,7 +2694,8 @@ on_comboLayer_changed (GtkComboBox *combobox, if (ui.in_update_page_stuff) return; // avoid a bad retroaction - gtk_widget_grab_focus(GTK_WIDGET(canvas)); // stop focus on us + end_text(); + reset_focus(); val = gtk_combo_box_get_active(combobox); if (val == -1) return; @@ -2349,6 +2723,8 @@ on_winMain_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { + end_text(); + reset_focus(); if (ok_to_close()) gtk_main_quit(); return TRUE; } @@ -2358,8 +2734,44 @@ void on_optionsUseXInput_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); ui.allow_xinput = ui.use_xinput = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); + +/* HOW THINGS USED TO BE: + + 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. + + As much as possible, we'd like to keep doing this, though GTK+ 2.17 + is making our life harder (crasher bugs require us to disable XInput + while editing text or using the layers combo box, but disabling + XInput while in a XInput-aware window causes the interface to become + non-responsive). +*/ + + // this causes core events to be discarded... unwanted! +/* + gtk_widget_set_extension_events(GTK_WIDGET (canvas), + ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE); +*/ + + // this version only activates extension events on the canvas's parent GdkWindow + 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(); } @@ -2390,7 +2802,11 @@ on_vscroll_changed (GtkAdjustment *adjustment, ui.pageno--; tmppage = g_list_nth_data(journal.pages, ui.pageno); } - if (need_update) do_switch_page(ui.pageno, FALSE, FALSE); + if (need_update) { + end_text(); + do_switch_page(ui.pageno, FALSE, FALSE); + } + reset_focus(); return; } @@ -2401,13 +2817,13 @@ on_spinPageNo_value_changed (GtkSpinButton *spinbutton, int val; if (ui.in_update_page_stuff) return; // avoid a bad retroaction - - gtk_widget_grab_focus(GTK_WIDGET(canvas)); // stop blink-blink text cursor + + end_text(); + reset_focus(); 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; } @@ -2426,6 +2842,8 @@ on_journalDefaultBackground_activate (GtkMenuItem *menuitem, struct Page *pg; GList *pglist; + end_text(); + reset_focus(); reset_selection(); pg = ui.cur_page; @@ -2461,6 +2879,8 @@ on_journalSetAsDefault_activate (GtkMenuItem *menuitem, { if (ui.cur_page->bg->type != BG_SOLID) return; + end_text(); + reset_focus(); prepare_new_undo(); undo->type = ITEM_NEW_DEFAULT_BG; undo->val_x = ui.default_page.width; @@ -2594,6 +3014,8 @@ on_viewFullscreen_activate (GtkMenuItem *menuitem, active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON (menuitem)); if (active == ui.fullscreen) return; + end_text(); + reset_focus(); ui.fullscreen = active; gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("viewFullscreen")), ui.fullscreen); @@ -2611,6 +3033,8 @@ void on_optionsButtonMappings_activate (GtkMenuItem *menuitem, gpointer user_data) { + end_text(); + reset_focus(); ui.use_erasertip = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); update_mappings_menu(); @@ -2625,6 +3049,8 @@ on_optionsAntialiasBG_activate (GtkMenuItem *menuitem, active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); if (ui.antialias_bg == active) return; + end_text(); + reset_focus(); ui.antialias_bg = active; rescale_bg_pixmaps(); } @@ -2638,6 +3064,8 @@ on_optionsProgressiveBG_activate (GtkMenuItem *menuitem, active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); if (ui.progressive_bg == active) return; + end_text(); + reset_focus(); ui.progressive_bg = active; if (!ui.progressive_bg) rescale_bg_pixmaps(); } @@ -2651,6 +3079,8 @@ on_mru_activate (GtkMenuItem *menuitem, gboolean success; GtkWidget *dialog; + end_text(); + reset_focus(); if (!ok_to_close()) return; // user aborted on save confirmation for (which = 0 ; which < MRU_SIZE; which++) { @@ -2665,7 +3095,7 @@ on_mru_activate (GtkMenuItem *menuitem, /* open failed */ dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error opening file '%s'", ui.mru[which]); + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), ui.mru[which]); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); delete_mru_entry(which); @@ -2700,7 +3130,7 @@ void on_button2Text_activate (GtkMenuItem *menuitem, gpointer user_data) { - + process_mapping_activate(menuitem, 1, TOOL_TEXT); } @@ -2735,6 +3165,8 @@ on_button2LinkBrush_activate (GtkMenuItem *menuitem, int i; if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return; + end_text(); + reset_focus(); ui.linked_brush[1] = BRUSH_LINKED; for (i=0;i= NUM_STROKE_TOOLS) { ui.linked_brush[1] = BRUSH_STATIC; update_mappings_menu_linkings(); @@ -2752,9 +3186,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; } @@ -2786,7 +3217,7 @@ void on_button3Text_activate (GtkMenuItem *menuitem, gpointer user_data) { - + process_mapping_activate(menuitem, 2, TOOL_TEXT); } @@ -2821,6 +3252,8 @@ on_button3LinkBrush_activate (GtkMenuItem *menuitem, int i; if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return; + end_text(); + reset_focus(); ui.linked_brush[2] = BRUSH_LINKED; for (i=0;i= NUM_STROKE_TOOLS) { ui.linked_brush[2] = BRUSH_STATIC; update_mappings_menu_linkings(); @@ -2838,9 +3273,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 @@ -2856,6 +3288,8 @@ on_viewSetZoom_activate (GtkMenuItem *menuitem, 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")); @@ -2881,6 +3315,7 @@ on_viewSetZoom_activate (GtkMenuItem *menuitem, 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); @@ -2963,9 +3398,10 @@ on_toolsHand_activate (GtkMenuItem *menuitem, 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(); @@ -2994,6 +3430,8 @@ 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)); } @@ -3001,7 +3439,89 @@ 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); +} + +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(); +} +