on_fileNew_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
if (close_journal()) {
new_journal();
- ui.zoom = DEFAULT_ZOOM;
+ ui.zoom = ui.startup_zoom;
update_page_stuff();
gtk_adjustment_set_value(gtk_layout_get_vadjustment(GTK_LAYOUT(canvas)), 0);
gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
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),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
filt_all = gtk_file_filter_new();
gtk_file_filter_set_name(filt_all, "All files");
filt_pdf = gtk_file_filter_new();
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");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attach_opt), FALSE);
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER (dialog), attach_opt);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
gtk_widget_destroy(dialog);
return;
}
gtk_main_iteration();
}
new_journal();
- ui.zoom = DEFAULT_ZOOM;
+ ui.zoom = ui.startup_zoom;
gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
update_page_stuff();
success = init_bgpdf(filename, TRUE, file_domain);
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),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+ 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_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);
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
+
+ if (ui.default_path!=NULL) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), ui.default_path);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
gtk_widget_destroy(dialog);
return;
}
{
GtkWidget *dialog;
+ end_text();
+ reset_focus();
if (ui.filename == NULL) {
on_fileSaveAs_activate(menuitem, user_data);
return;
gboolean warn;
struct stat stat_buf;
+ 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_ACCEPT, NULL);
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
if (ui.filename!=NULL) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), ui.filename);
else {
curtime = time(NULL);
strftime(stime, 30, "%F-Note-%H-%M.xoj", localtime(&curtime));
+ if (ui.default_path!=NULL)
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), ui.default_path);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (dialog), stime);
}
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (dialog), filt_all);
// somehow this doesn't seem to be set by default
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
do {
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
gtk_widget_destroy(dialog);
return;
}
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);
gpointer user_data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog, *warning_dialog;
GtkFileFilter *filt_all, *filt_pdf;
char *filename, *in_fn;
char stime[30];
time_t curtime;
- GnomePrintJob *gpj;
- GnomePrintConfig *config;
-
+ int response;
+ gboolean warn;
- dialog = gtk_file_chooser_dialog_new("Print 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_ACCEPT, NULL);
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
if (ui.filename!=NULL) {
if (g_str_has_suffix(ui.filename, ".xoj")) {
} else {
curtime = time(NULL);
strftime(stime, 30, "%F-Note-%H-%M.pdf", localtime(&curtime));
+ if (ui.default_path!=NULL)
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), ui.default_path);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (dialog), stime);
in_fn = NULL;
}
filt_pdf = gtk_file_filter_new();
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);
+ g_free(in_fn);
- // somehow this doesn't seem to be set by default
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+ do {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
+ gtk_widget_destroy(dialog);
+ return;
+ }
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ warn = g_file_test(filename, G_FILE_TEST_EXISTS);
+ 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);
+ if (gtk_dialog_run(GTK_DIALOG(warning_dialog)) == GTK_RESPONSE_YES)
+ warn = FALSE;
+ gtk_widget_destroy(warning_dialog);
+ }
+ } while(warn);
+
+ gtk_widget_destroy(dialog);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
- g_free(in_fn);
+ set_cursor_busy(TRUE);
+ 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_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
- return;
}
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- g_free(in_fn);
- gtk_widget_destroy(dialog);
-
- config = gnome_print_config_default();
- gnome_print_config_set(config, (guchar *)"Printer", (guchar *)"PDF");
- gpj = gnome_print_job_new(config);
- gnome_print_job_print_to_file(gpj, filename);
-
- print_job_render(gpj, 0, journal.npages-1);
- gnome_print_config_unref(config);
-
+ set_cursor_busy(FALSE);
g_free(filename);
}
on_fileQuit_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
if (ok_to_close()) gtk_main_quit ();
}
struct Brush tmp_brush;
struct Background *tmp_bg;
double tmp_x, tmp_y;
+ gchar *tmpstr;
+ 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;
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)
(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) {
gnome_canvas_item_set(it->canvas_item,
"fill-color-rgba", it->brush.color_rgba,
"width-units", it->brush.thickness, NULL);
+ if (it->type == ITEM_TEXT && it->canvas_item != NULL)
+ gnome_canvas_item_set(it->canvas_item,
+ "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;
struct Background *tmp_bg;
struct Layer *l;
double tmp_x, tmp_y;
+ gchar *tmpstr;
+ 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++;
// 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);
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++;
}
gnome_canvas_item_set(it->canvas_item,
"fill-color-rgba", it->brush.color_rgba,
"width-units", it->brush.thickness, NULL);
+ if (it->type == ITEM_TEXT && it->canvas_item != NULL)
+ gnome_canvas_item_set(it->canvas_item,
+ "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;
on_editCut_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
selection_to_clip();
selection_delete();
}
on_editCopy_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
selection_to_clip();
}
on_editPaste_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
clipboard_paste();
}
on_editDelete_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
selection_delete();
}
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;
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;
on_viewZoomIn_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ reset_focus();
if (ui.zoom > MAX_ZOOM) return;
- ui.zoom *= 1.5;
+ ui.zoom *= ui.zoom_step_factor;
gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
+ rescale_text_items();
rescale_bg_pixmaps();
}
on_viewZoomOut_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ reset_focus();
if (ui.zoom < MIN_ZOOM) return;
- ui.zoom /= 1.5;
+ ui.zoom /= ui.zoom_step_factor;
gnome_canvas_set_pixels_per_unit(canvas, ui.zoom);
+ rescale_text_items();
rescale_bg_pixmaps();
}
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();
}
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();
}
on_viewFirstPage_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
do_switch_page(0, TRUE, FALSE);
}
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);
}
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);
on_viewLastPage_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
do_switch_page(journal.npages-1, TRUE, FALSE);
}
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++;
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));
{
struct Page *pg;
+ end_text();
+ reset_focus();
if (page_ops_forbidden()) return;
reset_selection();
pg = new_page(ui.cur_page);
{
struct Page *pg;
+ end_text();
+ reset_focus();
if (page_ops_forbidden()) return;
reset_selection();
pg = new_page(ui.cur_page);
{
struct Page *pg;
+ end_text();
+ reset_focus();
if (page_ops_forbidden()) return;
reset_selection();
pg = new_page((struct Page *)g_list_last(journal.pages)->data);
GList *layerlist, *itemlist;
struct Layer *l;
+ end_text();
+ reset_focus();
if (page_ops_forbidden()) return;
if (journal.npages == 1) return;
reset_selection();
{
struct Layer *l;
+ end_text();
+ reset_focus();
reset_selection();
l = g_new(struct Layer, 1);
l->items = NULL;
{
GList *list;
+ end_text();
+ reset_focus();
if (ui.cur_layer == NULL) return;
reset_selection();
prepare_new_undo();
#define STD_SIZE_LETTER_R 3
#define STD_SIZE_CUSTOM 4
-#define UNIT_CM 0
-#define UNIT_IN 1
-#define UNIT_PX 2
-#define UNIT_PT 3
-
-double unit_sizes[4] = {28.346, 72., 1/DEFAULT_ZOOM, 1.};
+double unit_sizes[4] = {28.346, 72., 72./DISPLAY_DPI_DEFAULT, 1.};
double std_widths[STD_SIZE_CUSTOM] = {595.27, 841.89, 612., 792.};
double std_heights[STD_SIZE_CUSTOM] = {841.89, 595.27, 792., 612.};
double std_units[STD_SIZE_CUSTOM] = {UNIT_CM, UNIT_CM, UNIT_IN, UNIT_IN};
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;
- papersize_unit = UNIT_CM;
+ papersize_unit = ui.default_unit;
+ unit_sizes[UNIT_PX] = 1./DEFAULT_ZOOM;
// if (ui.cur_page->bg->type == BG_PIXMAP) papersize_unit = UNIT_PX;
papersize_std = STD_SIZE_CUSTOM;
for (i=0;i<STD_SIZE_CUSTOM;i++)
on_papercolorWhite_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_WHITE);
}
on_papercolorYellow_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_YELLOW);
}
on_papercolorPink_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_RED);
}
on_papercolorOrange_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_ORANGE);
}
on_papercolorBlue_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_BLUE);
}
on_papercolorGreen_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_papercolor_activate(menuitem, COLOR_GREEN);
}
on_paperstylePlain_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_paperstyle_activate(menuitem, RULING_NONE);
}
on_paperstyleLined_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_paperstyle_activate(menuitem, RULING_LINED);
}
on_paperstyleRuled_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_paperstyle_activate(menuitem, RULING_RULED);
}
on_paperstyleGraph_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ end_text();
+ reset_focus();
process_paperstyle_activate(menuitem, RULING_GRAPH);
}
char *filename;
gboolean attach;
+ 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_ACCEPT, NULL);
-
+ 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_add_pattern(filt_all, "*");
filt_pspdf = gtk_file_filter_new();
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");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attach_opt), FALSE);
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER (dialog), attach_opt);
+
+ if (ui.default_path!=NULL) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), ui.default_path);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
gtk_widget_destroy(dialog);
return;
}
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);
{
struct Background *bg;
+ end_text();
+ reset_focus();
reset_selection();
gtk_window_iconify(GTK_WINDOW(winMain)); // hide ourselves
gdk_display_sync(gdk_display_get_default());
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);
{
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;
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;
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;
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;
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.ruler[0] = FALSE;
+ ui.cur_brush = &(ui.brushes[0][TOOL_PEN]);
+ update_mapping_linkings(-1);
+ update_tool_buttons();
+ update_tool_menu();
+ update_color_menu();
+ update_cursor();
}
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);
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;
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);
}
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);
}
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);
}
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;
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;
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;
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.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;
+ 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();
}
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();
}
if (ui.cur_mapping != 0) return;
if (active == ui.ruler[0]) return;
+ end_text();
+ reset_focus();
if (active && (ui.toolno[0]!=TOOL_PEN && ui.toolno[0]!=TOOL_HIGHLIGHTER)) {
reset_selection();
ui.toolno[0] = TOOL_PEN;
on_optionsSavePreferences_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
-
+ end_text();
+ reset_focus();
+ save_config_to_file();
}
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,
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));
struct Page *tmppage;
GtkWidget *dialog;
int mapping;
-
- 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!
+ gboolean is_core;
+ struct Item *item;
- if (ui.use_xinput) {
- if (event->device->source == GDK_SOURCE_MOUSE) 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.discard_corepointer) return FALSE;
+ 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) {
// re-get the axis values since Synaptics sends bogus ones
gdk_device_get_state(event->device, event->window, event->axes, NULL);
fix_xinput_coords((GdkEvent *)event);
}
- else if (event->device->source != GDK_SOURCE_MOUSE) return FALSE;
+
+ if (ui.cur_item_type == ITEM_TEXT && !is_event_within_textview(event))
+ end_text();
+ 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)
mapping = NUM_BUTTONS;
ui.which_mouse_button = event->button;
switch_mapping(mapping);
+ // 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, then it takes precedence over anything else
if (start_movesel((GdkEvent *)event)) return FALSE;
// process the event
- if (ui.toolno[mapping] == TOOL_PEN || ui.toolno[mapping] == TOOL_HIGHLIGHTER ||
+ if (ui.toolno[mapping] == TOOL_HAND) {
+ ui.cur_item_type = ITEM_HAND;
+ get_pointer_coords((GdkEvent *)event, ui.hand_refpt);
+ }
+ 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)) {
create_new_stroke((GdkEvent *)event);
}
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;
}
GdkEventButton *event,
gpointer user_data)
{
+ gboolean is_core;
+
if (ui.cur_item_type == ITEM_NONE) return FALSE; // not doing anything
if (event->button != ui.which_mouse_button) return FALSE; // ignore
- if (ui.use_xinput) {
- if (event->device->source == GDK_SOURCE_MOUSE) return FALSE;
- fix_xinput_coords((GdkEvent *)event);
- }
- else if (event->device->source != GDK_SOURCE_MOUSE) 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 (ui.cur_item_type == ITEM_STROKE) {
finalize_stroke();
else if (ui.cur_item_type == ITEM_MOVESEL || ui.cur_item_type == ITEM_MOVESEL_VERT) {
finalize_movesel();
}
+ else if (ui.cur_item_type == ITEM_HAND) {
+ ui.cur_item_type = ITEM_NONE;
+ }
switch_mapping(0);
return FALSE;
GdkEventKey *event,
gpointer user_data)
{
-
return FALSE;
}
GdkEventMotion *event,
gpointer user_data)
{
- gboolean looks_wrong;
+ gboolean looks_wrong, is_core;
double pt[2];
if (ui.cur_item_type == ITEM_NONE) return FALSE; // we don't care
- if (ui.use_xinput) {
- if (event->device->source == GDK_SOURCE_MOUSE) return FALSE;
- fix_xinput_coords((GdkEvent *)event);
- }
- else if (event->device->source != GDK_SOURCE_MOUSE) 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);
looks_wrong = !(event->state & (1<<(7+ui.which_mouse_button)));
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_HAND) {
+ do_hand((GdkEvent *)event);
+ }
return FALSE;
}
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;
GdkEvent *event,
gpointer user_data)
{
+ end_text();
+ reset_focus();
if (ok_to_close()) gtk_main_quit();
return TRUE;
}
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));
+ gtk_widget_set_extension_events(GTK_WIDGET (canvas),
+ ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
+ update_mappings_menu();
}
void
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;
}
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;
on_journalDefaultBackground_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ struct Page *pg;
+ GList *pglist;
+
+ end_text();
+ reset_focus();
reset_selection();
- prepare_new_undo();
- undo->type = ITEM_NEW_BG_RESIZE;
- undo->page = ui.cur_page;
- undo->bg = ui.cur_page->bg;
- undo->val_x = ui.cur_page->width;
- undo->val_y = ui.cur_page->height;
- ui.cur_page->bg = (struct Background *)g_memdup(ui.default_page.bg, sizeof(struct Background));
- ui.cur_page->width = ui.default_page.width;
- ui.cur_page->height = ui.default_page.height;
- ui.cur_page->bg->canvas_item = undo->bg->canvas_item;
- undo->bg->canvas_item = NULL;
+ pg = ui.cur_page;
+ for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) {
+ if (ui.bg_apply_all_pages) pg = (struct Page *)pglist->data;
+ prepare_new_undo();
+ if (ui.bg_apply_all_pages) {
+ if (pglist->next!=NULL) undo->multiop |= MULTIOP_CONT_REDO;
+ if (pglist->prev!=NULL) undo->multiop |= MULTIOP_CONT_UNDO;
+ }
+ undo->type = ITEM_NEW_BG_RESIZE;
+ undo->page = pg;
+ undo->bg = pg->bg;
+ undo->val_x = pg->width;
+ undo->val_y = pg->height;
+ pg->bg = (struct Background *)g_memdup(ui.default_page.bg, sizeof(struct Background));
+ pg->width = ui.default_page.width;
+ pg->height = ui.default_page.height;
+ pg->bg->canvas_item = undo->bg->canvas_item;
+ undo->bg->canvas_item = NULL;
- make_page_clipbox(ui.cur_page);
- update_canvas_bg(ui.cur_page);
+ make_page_clipbox(pg);
+ update_canvas_bg(pg);
+ if (!ui.bg_apply_all_pages) break;
+ }
do_switch_page(ui.pageno, TRUE, TRUE);
}
{
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;
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);
+ gtk_toggle_tool_button_set_active(
+ GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonFullscreen")), ui.fullscreen);
- if (ui.fullscreen) {
- gtk_window_fullscreen(GTK_WINDOW(winMain));
- gtk_widget_hide(GET_COMPONENT("menubar"));
- gtk_widget_hide(GET_COMPONENT("hbox1"));
- }
- else {
- gtk_window_unfullscreen(GTK_WINDOW(winMain));
- gtk_widget_show(GET_COMPONENT("menubar"));
- gtk_widget_show(GET_COMPONENT("hbox1"));
- }
+ if (ui.fullscreen) gtk_window_fullscreen(GTK_WINDOW(winMain));
+ else gtk_window_unfullscreen(GTK_WINDOW(winMain));
+
+ update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]);
}
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();
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();
}
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();
}
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++) {
on_button2Text_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
-
+ process_mapping_activate(menuitem, 1, TOOL_TEXT);
}
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;i++) update_mapping_linkings(i);
}
gpointer user_data)
{
if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return;
+ end_text();
+ reset_focus();
if (ui.toolno[1] >= NUM_STROKE_TOOLS) {
ui.linked_brush[1] = BRUSH_STATIC;
update_mappings_menu_linkings();
on_button3Text_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
-
+ process_mapping_activate(menuitem, 2, TOOL_TEXT);
}
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;i++) update_mapping_linkings(i);
}
gpointer user_data)
{
if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return;
+ end_text();
+ reset_focus();
if (ui.toolno[2] >= NUM_STROKE_TOOLS) {
ui.linked_brush[2] = BRUSH_STATIC;
update_mappings_menu_linkings();
ui.ruler[2] = FALSE;
}
+// 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);
+}
+