From fd008f43f9e0848369972b0bc0e52129380e229b Mon Sep 17 00:00:00 2001 From: auroux Date: Sat, 25 Nov 2006 17:49:46 +0000 Subject: [PATCH] Release 0.3.2. --- ChangeLog | 5 +- NEWS | 2 +- README | 2 +- configure.in | 2 +- html-doc/manual.html | 63 +++++-- src/TODO | 11 +- src/main.c | 101 +++++----- src/xo-callbacks.c | 68 ++++--- src/xo-callbacks.h | 4 + src/xo-file.c | 436 ++++++++++++++++++++++++++++++++++++++++++- src/xo-file.h | 10 +- src/xo-interface.c | 9 + src/xo-misc.c | 17 +- src/xo-print.c | 2 + src/xournal.h | 25 ++- xournal.glade | 10 + 16 files changed, 648 insertions(+), 119 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0582621..7eb6912 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ -Version ?: +Version 0.3.2 (Nov 25, 2006): + - preferences file and Save Preferences command + - extra customization (via preferences file) - minor UI changes (patch contributed by Eduardo de Barros Lima) - hand tool (partially contributed by Vincenzo Ciancia) + - a few bugfixes in rendering of bitmap backgrounds Version 0.3.1 (Aug 3, 2006): - fixed a file format bug on systems with non-standard numeric locale diff --git a/NEWS b/NEWS index 59b1c49..24c081a 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Version 0.3.1 (August 3, 2006) +Version 0.3.2 (November 25, 2006) Installation: see INSTALL User's manual: see html-doc/manual.html diff --git a/README b/README index 59b1c49..24c081a 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Version 0.3.1 (August 3, 2006) +Version 0.3.2 (November 25, 2006) Installation: see INSTALL User's manual: see html-doc/manual.html diff --git a/configure.in b/configure.in index fc25bac..29093ca 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(configure.in) -AM_INIT_AUTOMAKE(xournal, 0.3.1-CVS) +AM_INIT_AUTOMAKE(xournal, 0.3.2) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE diff --git a/html-doc/manual.html b/html-doc/manual.html index fd27230..7ff5255 100644 --- a/html-doc/manual.html +++ b/html-doc/manual.html @@ -24,7 +24,7 @@ Xournal User's Manual

- Version 0.3.1 + Version 0.3.2


@@ -53,6 +53,7 @@ Xournal can be downloaded at

  • The drawing and selection tools
  • Pages, layers, and backgrounds
  • Printing
  • +
  • Configuration
  • Author information, license, bug-reports
  • Version history
  • The file format
  • @@ -190,6 +191,11 @@ the Tools menu): cursor above the top of the page so that the entire block being moved becomes invisible results in the items being moved to the previous page.

    +

    Hand tool

    +

    + This tool lets you browse the journal; dragging the cursor scrolls the + view. +

    Undo and redo

    All operations performed on the currently open journal (drawing, erasing, @@ -477,6 +483,29 @@ file, the backgrounds are converted to (compressed) bitmaps and a new PDF file is generated from scratch.


    + +

    Configuration

    +

    +Starting with version 0.3.2, Xournal's configuration settings can be +saved to a file (~user/.xournal/config) by using the "Save +Preferences" command in the Options menu. The settings saved in the +configuration file include in particular: +

    +The configuration file also gives access to additional customization +options which cannot be set from the user interface, such as: the +display resolution in pixels per inch, the step increment in zoom factors, +the tool selected at startup, the thickness of the various drawing tools, +... +

    +

    Author information, license, bug-reports

    @@ -499,6 +528,15 @@ Bug reports and suggestions can also be submitted on Xournal's

    Version history

    +Version 0.3.2 (November 25, 2006): +

    +

    Version 0.3.1 (August 3, 2006):

    +This patch has been included in version 0.7.6 of the linuxwacom driver, +and should now be obsolete.

    diff --git a/src/TODO b/src/TODO index c41a6a4..9baaeaa 100644 --- a/src/TODO +++ b/src/TODO @@ -1,9 +1,11 @@ List of features to be implemented (not in any particular order) ---------------------------------------------------------------- - +- xoj2pdf on command line +- load images as bg if given on command-line (as with PDF on commandline) +- load PDF pages only on demand (create empty pixmaps at first if can + parse PDF geometry ourselves, else try pdfinfo ??) - de-map space key from button bar - lasso selection tool -- prefs file, save prefs - flatten (incl undo/redo...) - enabled only if nlayers>1 - resize selection - text tool, font chooser, default font @@ -19,5 +21,8 @@ List of features to be implemented (not in any particular order) - recalibration upon screen resize / compensation for miscalibration - find a better behavior for vertical space tool across page boundaries ? - key mappings (pgup/dn for full page, up/dn for scroll) -- zoom increments more flexible (1% instead of 5% ?) - copy/paste of an entire page (beware if PDF bg is not compatible!) +- simple drawing tools: rectangles, ellipses +- option to save all annotated files within the .xoj +- non-antialiased version for handhelds +- customize autogenerated save file names diff --git a/src/main.c b/src/main.c index 188d1ea..0569386 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,8 @@ struct BgPdf bgpdf; // the PDF loader stuff struct UIData ui; // the user interface data struct UndoItem *undo, *redo; // the undo and redo stacks +double DEFAULT_ZOOM; + void hide_unimplemented(void) { gtk_widget_hide(GET_COMPONENT("filePrintOptions")); @@ -42,7 +44,6 @@ void hide_unimplemented(void) gtk_widget_hide(GET_COMPONENT("colorOther")); gtk_widget_hide(GET_COMPONENT("toolsTextFont")); gtk_widget_hide(GET_COMPONENT("toolsDefaultText")); - gtk_widget_hide(GET_COMPONENT("optionsSavePreferences")); gtk_widget_hide(GET_COMPONENT("helpIndex")); } @@ -57,32 +58,25 @@ void init_stuff (int argc, char *argv[]) gboolean can_xinput, success; gchar *tmppath, *tmpfn; - // we need an empty canvas prior to creating the journal structures - canvas = GNOME_CANVAS (gnome_canvas_new_aa ()); + // create some data structures needed to populate the preferences + ui.default_page.bg = g_new(struct Background, 1); // initialize config file names tmppath = g_build_filename(g_get_home_dir(), CONFIG_DIR, NULL); - g_mkdir(tmppath, 0700); // safer (MRU data may be confidential) + mkdir(tmppath, 0700); // safer (MRU data may be confidential) ui.mrufile = g_build_filename(tmppath, MRU_FILE, NULL); + ui.configfile = g_build_filename(tmppath, CONFIG_FILE, NULL); g_free(tmppath); - // initialize data - // TODO: load this from a preferences file + // initialize preferences + init_config_default(); + load_config_from_file(); - ui.default_page.height = 792.0; - ui.default_page.width = 612.0; - ui.default_page.bg = g_new(struct Background, 1); - ui.default_page.bg->type = BG_SOLID; - ui.default_page.bg->color_no = COLOR_WHITE; - ui.default_page.bg->color_rgba = predef_bgcolors_rgba[COLOR_WHITE]; - ui.default_page.bg->ruling = RULING_LINED; + // we need an empty canvas prior to creating the journal structures + canvas = GNOME_CANVAS (gnome_canvas_new_aa ()); + + // initialize data ui.default_page.bg->canvas_item = NULL; - - ui.zoom = DEFAULT_ZOOM; - ui.view_continuous = TRUE; - ui.fullscreen = FALSE; - - ui.allow_xinput = TRUE; ui.layerbox_length = 0; if (argc > 2 || (argc == 2 && argv[1][0] == '-')) { @@ -105,40 +99,42 @@ void init_stuff (int argc, char *argv[]) ui.selection = NULL; ui.cursor = NULL; - ui.bg_apply_all_pages = FALSE; - - ui.cur_brush = &(ui.brushes[0][TOOL_PEN]); - ui.toolno[0] = TOOL_PEN; - for (i=1; i<=NUM_BUTTONS; i++) ui.toolno[i] = TOOL_ERASER; - for (i=0; i<=NUM_BUTTONS; i++) { - ui.ruler[i] = FALSE; - ui.linked_brush[i] = BRUSH_LINKED; - } - ui.brushes[0][TOOL_PEN].color_no = COLOR_BLACK; - ui.brushes[0][TOOL_ERASER].color_no = COLOR_WHITE; - ui.brushes[0][TOOL_HIGHLIGHTER].color_no = COLOR_YELLOW; - for (i=0; i < NUM_STROKE_TOOLS; i++) { - b = &(ui.brushes[0][i]); - b->tool_type = i; - b->color_rgba = predef_colors_rgba[b->color_no]; - if (i == TOOL_HIGHLIGHTER) { - b->color_rgba &= HILITER_ALPHA_MASK; + + ui.cur_brush = &(ui.brushes[0][ui.toolno[0]]); + for (j=0; j<=NUM_BUTTONS; j++) + for (i=0; i < NUM_STROKE_TOOLS; i++) { + b = &(ui.brushes[j][i]); + b->tool_type = i; + b->color_rgba = predef_colors_rgba[b->color_no]; + if (i == TOOL_HIGHLIGHTER) { + b->color_rgba &= HILITER_ALPHA_MASK; + } + b->thickness = predef_thickness[i][b->thickness_no]; } - b->thickness_no = THICKNESS_MEDIUM; - b->thickness = predef_thickness[i][b->thickness_no]; - b->tool_options = 0; - g_memmove(ui.default_brushes+i, b, sizeof(struct Brush)); - for (j=1; j<=NUM_BUTTONS; j++) - g_memmove(&(ui.brushes[j][i]), b, sizeof(struct Brush)); - } + for (i=0; istep_increment = 30; - gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = 30; + gtk_layout_get_hadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment; + gtk_layout_get_vadjustment(GTK_LAYOUT (canvas))->step_increment = ui.scrollbar_step_increment; // set up the page size and canvas size update_page_stuff(); @@ -202,8 +198,6 @@ void init_stuff (int argc, char *argv[]) gtk_widget_set_sensitive(GET_COMPONENT("optionsUseXInput"), FALSE); ui.use_xinput = ui.allow_xinput && can_xinput; - ui.antialias_bg = TRUE; - ui.progressive_bg = TRUE; gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput); @@ -211,8 +205,15 @@ void init_stuff (int argc, char *argv[]) GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAntialiasBG")), ui.antialias_bg); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsProgressiveBG")), ui.progressive_bg); + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPrintRuling")), ui.print_ruling); hide_unimplemented(); + + /* config file only works with glib 2.6 */ + if (glib_minor_version<6) { + gtk_widget_hide(GET_COMPONENT("optionsSavePreferences")); + } update_undo_redo_enabled(); update_copy_paste_enabled(); diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c index 4980035..a11ce65 100644 --- a/src/xo-callbacks.c +++ b/src/xo-callbacks.c @@ -889,7 +889,7 @@ on_viewZoomIn_activate (GtkMenuItem *menuitem, gpointer user_data) { 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_bg_pixmaps(); } @@ -900,7 +900,7 @@ on_viewZoomOut_activate (GtkMenuItem *menuitem, gpointer user_data) { 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_bg_pixmaps(); } @@ -1178,12 +1178,7 @@ gboolean papersize_need_init, papersize_width_valid, papersize_height_valid; #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}; @@ -1199,7 +1194,8 @@ on_journalPaperSize_activate (GtkMenuItem *menuitem, 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;itype = 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); } @@ -2838,11 +2846,13 @@ on_viewSetZoom_activate (GtkMenuItem *menuitem, { int response; double test_w, test_h; + GtkSpinButton *spinZoom; zoom_dialog = create_zoomDialog(); zoom_percent = 100*ui.zoom / DEFAULT_ZOOM; - gtk_spin_button_set_value(GTK_SPIN_BUTTON(g_object_get_data( - G_OBJECT(zoom_dialog), "spinZoom")), zoom_percent); + 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) @@ -2971,3 +2981,11 @@ on_button3Hand_activate (GtkMenuItem *menuitem, process_mapping_activate(menuitem, 2, TOOL_HAND); } + +void +on_optionsPrintRuling_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + ui.print_ruling = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem)); +} + diff --git a/src/xo-callbacks.h b/src/xo-callbacks.h index 8513ec8..0b67562 100644 --- a/src/xo-callbacks.h +++ b/src/xo-callbacks.h @@ -592,3 +592,7 @@ on_button2Hand_activate (GtkMenuItem *menuitem, void on_button3Hand_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_optionsPrintRuling_activate (GtkMenuItem *menuitem, + gpointer user_data); diff --git a/src/xo-file.c b/src/xo-file.c index a241df3..bff53a1 100644 --- a/src/xo-file.c +++ b/src/xo-file.c @@ -22,7 +22,7 @@ #include "xo-misc.h" #include "xo-file.h" -const char *tool_names[NUM_STROKE_TOOLS] = {"pen", "eraser", "highlighter"}; +const char *tool_names[NUM_TOOLS] = {"pen", "eraser", "highlighter", "", "", "selectrect", "vertspace", "hand"}; const char *color_names[COLOR_MAX] = {"black", "blue", "red", "green", "gray", "lightblue", "lightgreen", "magenta", "orange", "yellow", "white"}; const char *bgtype_names[3] = {"solid", "pixmap", "pdf"}; @@ -30,6 +30,8 @@ const char *bgcolor_names[COLOR_MAX] = {"", "blue", "pink", "green", "", "", "", "", "orange", "yellow", "white"}; const char *bgstyle_names[4] = {"plain", "lined", "ruled", "graph"}; const char *file_domain_names[3] = {"absolute", "attach", "clone"}; +const char *unit_names[4] = {"cm", "in", "px", "pt"}; +int PDFTOPPM_PRINTING_DPI, GS_BITMAP_DPI; // creates a new empty journal @@ -1214,3 +1216,435 @@ void save_mru_list(void) if (ui.mru[i]!=NULL) fprintf(f, "%s\n", ui.mru[i]); fclose(f); } + +void init_config_default(void) +{ + int i, j; + + DEFAULT_ZOOM = DISPLAY_DPI_DEFAULT/72.0; + ui.zoom = 1.0*DEFAULT_ZOOM; + ui.default_page.height = 792.0; + ui.default_page.width = 612.0; + ui.default_page.bg->type = BG_SOLID; + ui.default_page.bg->color_no = COLOR_WHITE; + ui.default_page.bg->color_rgba = predef_bgcolors_rgba[COLOR_WHITE]; + ui.default_page.bg->ruling = RULING_LINED; + ui.view_continuous = TRUE; + ui.allow_xinput = TRUE; + ui.bg_apply_all_pages = FALSE; + ui.use_erasertip = FALSE; + ui.window_default_width = 720; + ui.window_default_height = 480; + ui.maximize_at_start = FALSE; + ui.fullscreen = FALSE; + ui.scrollbar_step_increment = 30; + ui.zoom_step_increment = 1; + ui.zoom_step_factor = 1.5; + ui.antialias_bg = TRUE; + ui.progressive_bg = TRUE; + ui.print_ruling = TRUE; + ui.default_unit = UNIT_CM; + + ui.toolno[0] = ui.startuptool = TOOL_PEN; + ui.ruler[0] = ui.startupruler = FALSE; + for (i=1; i<=NUM_BUTTONS; i++) { + ui.toolno[i] = TOOL_ERASER; + ui.ruler[i] = FALSE; + } + for (i=0; i<=NUM_BUTTONS; i++) + ui.linked_brush[i] = BRUSH_LINKED; + ui.brushes[0][TOOL_PEN].color_no = COLOR_BLACK; + ui.brushes[0][TOOL_ERASER].color_no = COLOR_WHITE; + ui.brushes[0][TOOL_HIGHLIGHTER].color_no = COLOR_YELLOW; + for (i=0; i < NUM_STROKE_TOOLS; i++) { + ui.brushes[0][i].thickness_no = THICKNESS_MEDIUM; + ui.brushes[0][i].tool_options = 0; + } + for (i=0; i< NUM_STROKE_TOOLS; i++) + for (j=1; j<=NUM_BUTTONS; j++) + g_memmove(&(ui.brushes[j][i]), &(ui.brushes[0][i]), sizeof(struct Brush)); + + // predef_thickness is already initialized as a global variable + + GS_BITMAP_DPI = 144; + PDFTOPPM_PRINTING_DPI = 150; +} + +#if GLIB_CHECK_VERSION(2,6,0) + +void update_keyval(const gchar *group_name, const gchar *key, + const gchar *comment, gchar *value) +{ + gboolean has_it = g_key_file_has_key(ui.config_data, group_name, key, NULL); + cleanup_numeric(value); + g_key_file_set_value(ui.config_data, group_name, key, value); + g_free(value); + if (!has_it) g_key_file_set_comment(ui.config_data, group_name, key, comment, NULL); +} + +#endif + +void save_config_to_file(void) +{ + gchar *buf; + FILE *f; + +#if GLIB_CHECK_VERSION(2,6,0) + // no support for keyval files before Glib 2.6.0 + if (glib_minor_version<6) return; + + // save some data... + ui.maximize_at_start = (gdk_window_get_state(winMain->window) & GDK_WINDOW_STATE_MAXIMIZED); + if (!ui.maximize_at_start && !ui.fullscreen) + gdk_drawable_get_size(winMain->window, + &ui.window_default_width, &ui.window_default_height); + + update_keyval("general", "display_dpi", + " the display resolution, in pixels per inch", + g_strdup_printf("%.2f", DEFAULT_ZOOM*72)); + update_keyval("general", "initial_zoom", + " the initial zoom level, in percent", + g_strdup_printf("%.2f", 100*ui.zoom/DEFAULT_ZOOM)); + update_keyval("general", "window_maximize", + " maximize the window at startup (true/false)", + g_strdup(ui.maximize_at_start?"true":"false")); + update_keyval("general", "window_fullscreen", + " start in full screen mode (true/false)", + g_strdup(ui.fullscreen?"true":"false")); + update_keyval("general", "window_width", + " the window width in pixels (when not maximized)", + g_strdup_printf("%d", ui.window_default_width)); + update_keyval("general", "window_height", + " the window height in pixels", + g_strdup_printf("%d", ui.window_default_height)); + update_keyval("general", "scrollbar_speed", + " scrollbar step increment (in pixels)", + g_strdup_printf("%d", ui.scrollbar_step_increment)); + update_keyval("general", "zoom_dialog_increment", + " the step increment in the zoom dialog box", + g_strdup_printf("%d", ui.zoom_step_increment)); + update_keyval("general", "zoom_step_factor", + " the multiplicative factor for zoom in/out", + g_strdup_printf("%.3f", ui.zoom_step_factor)); + update_keyval("general", "view_continuous", + " document view (true = continuous, false = single page)", + g_strdup(ui.view_continuous?"true":"false")); + update_keyval("general", "use_xinput", + " use XInput extensions (true/false)", + g_strdup(ui.allow_xinput?"true":"false")); + update_keyval("general", "use_erasertip", + " always map eraser tip to eraser (true/false)", + g_strdup(ui.use_erasertip?"true":"false")); + + update_keyval("paper", "width", + " the default page width, in points (1/72 in)", + g_strdup_printf("%.2f", ui.default_page.width)); + update_keyval("paper", "height", + " the default page height, in points (1/72 in)", + g_strdup_printf("%.2f", ui.default_page.height)); + update_keyval("paper", "color", + " the default paper color", + g_strdup(bgcolor_names[ui.default_page.bg->color_no])); + update_keyval("paper", "style", + " the default paper style (plain, lined, ruled, or graph)", + g_strdup(bgstyle_names[ui.default_page.bg->ruling])); + update_keyval("paper", "apply_all", + " apply paper style changes to all pages (true/false)", + g_strdup(ui.bg_apply_all_pages?"true":"false")); + update_keyval("paper", "default_unit", + " preferred unit (cm, in, px, pt)", + g_strdup(unit_names[ui.default_unit])); + update_keyval("paper", "print_ruling", + " include paper ruling when printing or exporting to PDF (true/false)", + g_strdup(ui.print_ruling?"true":"false")); + update_keyval("paper", "antialias_bg", + " antialiased bitmap backgrounds (true/false)", + g_strdup(ui.antialias_bg?"true":"false")); + update_keyval("paper", "progressive_bg", + " progressive scaling of bitmap backgrounds (true/false)", + g_strdup(ui.progressive_bg?"true":"false")); + update_keyval("paper", "gs_bitmap_dpi", + " bitmap resolution of PS/PDF backgrounds rendered using ghostscript (dpi)", + g_strdup_printf("%d", GS_BITMAP_DPI)); + update_keyval("paper", "pdftoppm_printing_dpi", + " bitmap resolution of PDF backgrounds when printing with libgnomeprint (dpi)", + g_strdup_printf("%d", PDFTOPPM_PRINTING_DPI)); + + update_keyval("tools", "startup_tool", + " selected tool at startup (pen, eraser, highlighter, selectrect, vertspace, hand)", + g_strdup(tool_names[ui.startuptool])); + update_keyval("tools", "startup_ruler", + " ruler mode at startup (true/false) (for pen or highlighter only)", + g_strdup(ui.startupruler?"true":"false")); + update_keyval("tools", "pen_color", + " default pen color", + g_strdup(color_names[ui.default_brushes[TOOL_PEN].color_no])); + update_keyval("tools", "pen_thickness", + " default pen thickness (fine = 1, medium = 2, thick = 3)", + g_strdup_printf("%d", ui.default_brushes[TOOL_PEN].thickness_no)); + update_keyval("tools", "eraser_thickness", + " default eraser thickness (fine = 1, medium = 2, thick = 3)", + g_strdup_printf("%d", ui.default_brushes[TOOL_ERASER].thickness_no)); + update_keyval("tools", "eraser_mode", + " default eraser mode (standard = 0, whiteout = 1, strokes = 2)", + g_strdup_printf("%d", ui.default_brushes[TOOL_ERASER].tool_options)); + update_keyval("tools", "highlighter_color", + " default highlighter color", + g_strdup(color_names[ui.default_brushes[TOOL_HIGHLIGHTER].color_no])); + update_keyval("tools", "highlighter_thickness", + " default highlighter thickness (fine = 1, medium = 2, thick = 3)", + g_strdup_printf("%d", ui.default_brushes[TOOL_HIGHLIGHTER].thickness_no)); + update_keyval("tools", "btn2_tool", + " button 2 tool (pen, eraser, highlighter, selectrect, vertspace, hand)", + g_strdup(tool_names[ui.toolno[1]])); + update_keyval("tools", "btn2_linked", + " button 2 brush linked to primary brush (true/false) (overrides all other settings)", + g_strdup((ui.linked_brush[1]==BRUSH_LINKED)?"true":"false")); + update_keyval("tools", "btn2_ruler", + " button 2 ruler mode (true/false) (for pen or highlighter only)", + g_strdup(ui.ruler[1]?"true":"false")); + update_keyval("tools", "btn2_color", + " button 2 brush color (for pen or highlighter only)", + g_strdup((ui.toolno[1] sup) return FALSE; + *val = conv; + return TRUE; +} + +gboolean parse_keyval_floatlist(const gchar *group, const gchar *key, double *val, int n, double inf, double sup) +{ + gchar *ret, *end; + double conv[5]; + int i; + + if (n>5) return FALSE; + ret = g_key_file_get_value(ui.config_data, group, key, NULL); + if (ret==NULL) return FALSE; + end = ret; + for (i=0; i sup)) { g_free(ret); return FALSE; } + end++; + } + g_free(ret); + for (i=0; i sup) return FALSE; + *val = conv; + return TRUE; +} + +gboolean parse_keyval_enum(const gchar *group, const gchar *key, int *val, const char **names, int n) +{ + gchar *ret; + int i; + + ret = g_key_file_get_value(ui.config_data, group, key, NULL); + if (ret==NULL) return FALSE; + for (i=0; icolor_no), bgcolor_names, COLOR_MAX); + ui.default_page.bg->color_rgba = predef_bgcolors_rgba[ui.default_page.bg->color_no]; + parse_keyval_enum("paper", "style", &(ui.default_page.bg->ruling), bgstyle_names, 4); + parse_keyval_boolean("paper", "apply_all", &ui.bg_apply_all_pages); + parse_keyval_enum("paper", "default_unit", &ui.default_unit, unit_names, 4); + parse_keyval_boolean("paper", "antialias_bg", &ui.antialias_bg); + parse_keyval_boolean("paper", "progressive_bg", &ui.progressive_bg); + parse_keyval_boolean("paper", "print_ruling", &ui.print_ruling); + parse_keyval_int("paper", "gs_bitmap_dpi", &GS_BITMAP_DPI, 1, 1200); + parse_keyval_int("paper", "pdftoppm_printing_dpi", &PDFTOPPM_PRINTING_DPI, 1, 1200); + + parse_keyval_enum("tools", "startup_tool", &ui.startuptool, tool_names, NUM_TOOLS); + ui.toolno[0] = ui.startuptool; + if (ui.startuptool == TOOL_PEN || ui.startuptool == TOOL_HIGHLIGHTER) { + parse_keyval_boolean("tools", "startup_ruler", &ui.startupruler); + ui.ruler[0] = ui.startupruler; + } + parse_keyval_enum("tools", "pen_color", &(ui.brushes[0][TOOL_PEN].color_no), color_names, COLOR_MAX); + parse_keyval_int("tools", "pen_thickness", &(ui.brushes[0][TOOL_PEN].thickness_no), 0, 4); + parse_keyval_int("tools", "eraser_thickness", &(ui.brushes[0][TOOL_ERASER].thickness_no), 1, 3); + parse_keyval_int("tools", "eraser_mode", &(ui.brushes[0][TOOL_ERASER].tool_options), 0, 2); + parse_keyval_enum("tools", "highlighter_color", &(ui.brushes[0][TOOL_HIGHLIGHTER].color_no), color_names, COLOR_MAX); + parse_keyval_int("tools", "highlighter_thickness", &(ui.brushes[0][TOOL_HIGHLIGHTER].thickness_no), 0, 4); + for (i=0; i< NUM_STROKE_TOOLS; i++) + for (j=1; j<=NUM_BUTTONS; j++) + g_memmove(&(ui.brushes[j][i]), &(ui.brushes[0][i]), sizeof(struct Brush)); + + parse_keyval_enum("tools", "btn2_tool", &(ui.toolno[1]), tool_names, NUM_TOOLS); + if (parse_keyval_boolean("tools", "btn2_linked", &b)) + ui.linked_brush[1] = b?BRUSH_LINKED:BRUSH_STATIC; + parse_keyval_enum("tools", "btn3_tool", &(ui.toolno[2]), tool_names, NUM_TOOLS); + if (parse_keyval_boolean("tools", "btn3_linked", &b)) + ui.linked_brush[2] = b?BRUSH_LINKED:BRUSH_STATIC; + for (i=1; i<=NUM_BUTTONS; i++) + if (ui.toolno[i]==TOOL_PEN || ui.toolno[i]==TOOL_HIGHLIGHTER) + ui.ruler[i] = ui.ruler[0]; + if (ui.linked_brush[1]!=BRUSH_LINKED) { + if (ui.toolno[1]==TOOL_PEN || ui.toolno[1]==TOOL_HIGHLIGHTER) { + parse_keyval_boolean("tools", "btn2_ruler", &(ui.ruler[1])); + parse_keyval_enum("tools", "btn2_color", &(ui.brushes[1][ui.toolno[1]].color_no), color_names, COLOR_MAX); + } + if (ui.toolno[1] #endif @@ -30,19 +27,11 @@ guint predef_bgcolors_rgba[COLOR_MAX] = // meaningless ones set to white 0xffffffff, 0xa0e8ffff, 0x80ffc0ff, 0xffc0d4ff, 0xffc080ff, 0xffff80ff, 0xffffffff }; -#ifdef NEW_THICKNESS double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX] = { { 0.42, 0.85, 1.41, 2.26, 5.67 }, // pen thicknesses = 0.15, 0.3, 0.5, 0.8, 2 mm - { 2.83, 2.83, 8.50, 19.84, 19.84 }, // eraser thicknesses = 1, 2.5, 5 mm - { 2.83, 2.83, 8.50, 19.84, 19.84 }, // highlighter thicknesses = 1, 2.5, 5 mm + { 2.83, 2.83, 8.50, 19.84, 19.84 }, // eraser thicknesses = 1, 3, 7 mm + { 2.83, 2.83, 8.50, 19.84, 19.84 }, // highlighter thicknesses = 1, 3, 7 mm }; -#else -double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX] = - { { 0.42, 0.85, 1.41, 2.26, 5.67 }, // pen thicknesses = 0.15, 0.3, 0.5, 0.8, 2 mm - { 2.83, 2.83, 7.08, 14.17, 14.17 }, // eraser thicknesses = 1, 2.5, 5 mm - { 2.83, 2.83, 7.08, 14.17, 14.17 }, // highlighter thicknesses = 1, 2.5, 5 mm - }; -#endif // some manipulation functions @@ -556,7 +545,7 @@ void rescale_bg_pixmaps(void) set_cursor_busy(FALSE); } else { - pix = GDK_PIXBUF(g_object_get_data(G_OBJECT(pg->bg->canvas_item), "pixbuf")); + g_object_get(G_OBJECT(pg->bg->canvas_item), "pixbuf", &pix, NULL); if (pix!=pg->bg->pixbuf) gnome_canvas_item_set(pg->bg->canvas_item, "pixbuf", pg->bg->pixbuf, NULL); pg->bg->pixbuf_scale = 0; diff --git a/src/xo-print.c b/src/xo-print.c index 2050f85..cc2d4c1 100644 --- a/src/xo-print.c +++ b/src/xo-print.c @@ -671,6 +671,7 @@ void pdf_draw_solid_background(struct Page *pg, GString *str) g_string_append_printf(str, "%.2f %.2f %.2f rg 0 0 %.2f %.2f re f ", RGBA_RGB(pg->bg->color_rgba), pg->width, pg->height); + if (!ui.print_ruling) return; if (pg->bg->ruling == RULING_NONE) return; g_string_append_printf(str, "%.2f %.2f %.2f RG %.2f w ", @@ -1028,6 +1029,7 @@ void print_background(GnomePrintContext *gpc, struct Page *pg, gboolean *abort) gnome_print_setrgbcolor(gpc, RGBA_RGB(pg->bg->color_rgba)); gnome_print_rect_filled(gpc, 0, 0, pg->width, pg->height); + if (!ui.print_ruling) return; if (pg->bg->ruling == RULING_NONE) return; gnome_print_setrgbcolor(gpc, RGBA_RGB(RULING_COLOR)); gnome_print_setlinewidth(gpc, RULING_THICKNESS); diff --git a/src/xournal.h b/src/xournal.h index 6ed265a..62d3dc8 100644 --- a/src/xournal.h +++ b/src/xournal.h @@ -6,6 +6,7 @@ #define CONFIG_DIR ".xournal" #define MRU_FILE "recent-files" #define MRU_SIZE 8 +#define CONFIG_FILE "config" // DATA STRUCTURES AND CONSTANTS @@ -13,7 +14,7 @@ #define MAX_AXES 12 #define EPSILON 1E-7 #define MAX_ZOOM 20.0 -#define DEFAULT_ZOOM 1.3333333333 +#define DISPLAY_DPI_DEFAULT 96.0 #define MIN_ZOOM 0.2 /* a string (+ aux data) that maintains a refcount */ @@ -99,6 +100,7 @@ extern guint predef_bgcolors_rgba[COLOR_MAX]; #define TOOL_VERTSPACE 6 #define TOOL_HAND 7 #define NUM_STROKE_TOOLS 3 +#define NUM_TOOLS 8 #define NUM_BUTTONS 3 #define TOOLOPT_ERASER_STANDARD 0 @@ -204,16 +206,26 @@ typedef struct UIData { int screen_width, screen_height; // initial screen size, for XInput events double hand_refpt[2]; char *filename; - gboolean view_continuous, fullscreen; + gboolean view_continuous, fullscreen, maximize_at_start; gboolean in_update_page_stuff; // semaphore to avoid scrollbar retroaction struct Selection *selection; GdkCursor *cursor; gboolean antialias_bg; // bilinear interpolation on bg pixmaps gboolean progressive_bg; // rescale bg's one at a time - char *mrufile; // file for the MRU + char *mrufile, *configfile; // file names for MRU & config char *mru[MRU_SIZE]; // MRU data GtkWidget *mrumenu[MRU_SIZE]; gboolean bg_apply_all_pages; + int window_default_width, window_default_height, scrollbar_step_increment; + gboolean print_ruling; // print the paper ruling ? + int default_unit; // the default unit for paper sizes + int startuptool; // the default tool at startup + gboolean startupruler; + int zoom_step_increment; // the increment in the zoom dialog box + double zoom_step_factor; // the multiplicative factor in zoom in/out +#if GLIB_CHECK_VERSION(2,6,0) + GKeyFile *config_data; +#endif } UIData; #define BRUSH_LINKED 0 @@ -301,3 +313,10 @@ extern struct Journal journal; extern struct UIData ui; extern struct BgPdf bgpdf; extern struct UndoItem *undo, *redo; + +extern double DEFAULT_ZOOM; + +#define UNIT_CM 0 +#define UNIT_IN 1 +#define UNIT_PX 2 +#define UNIT_PT 3 diff --git a/xournal.glade b/xournal.glade index ebfef27..c7ad3c8 100644 --- a/xournal.glade +++ b/xournal.glade @@ -1810,6 +1810,16 @@ + + + True + Print Paper Ruling + True + False + + + + True -- 2.39.2