X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fmain.c;h=59afa6c4b2d56040a2ae942c2cbd75ec25a860d3;hb=2e5ff0bff41fa53d4941b6f0fe49c8914bf29cbc;hp=188d1ea352aca86b277c10ac075b6f2a6be4a5c5;hpb=ddd27893ae44eb5eb62c80e5751a6943a4782fe2;p=xournal.git diff --git a/src/main.c b/src/main.c index 188d1ea..59afa6c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,3 @@ -#define ENABLE_XINPUT_BUGFIX 1 -/* change the above to 0 if you are experiencing calibration problems with - XInput and want to try things differently -*/ - #ifdef HAVE_CONFIG_H # include #endif @@ -26,23 +21,18 @@ 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")); gtk_widget_hide(GET_COMPONENT("journalFlatten")); gtk_widget_hide(GET_COMPONENT("papercolorOther")); - gtk_widget_hide(GET_COMPONENT("toolsText")); - gtk_widget_hide(GET_COMPONENT("buttonText")); - gtk_widget_hide(GET_COMPONENT("button2Text")); - gtk_widget_hide(GET_COMPONENT("button3Text")); gtk_widget_hide(GET_COMPONENT("toolsSelectRegion")); gtk_widget_hide(GET_COMPONENT("buttonSelectRegion")); gtk_widget_hide(GET_COMPONENT("button2SelectRegion")); gtk_widget_hide(GET_COMPONENT("button3SelectRegion")); 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 +47,28 @@ 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.font_name = g_strdup(ui.default_font_name); + ui.font_size = ui.default_font_size; + ui.hiliter_alpha_mask = 0xffffff00 + (guint)(255*ui.hiliter_opacity); - 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,39 +91,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 &= ui.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(); @@ -186,24 +174,23 @@ void init_stuff (int argc, char *argv[]) dev_list = gdk_devices_list(); while (dev_list != NULL) { device = (GdkDevice *)dev_list->data; - if (device->source != GDK_SOURCE_MOUSE) { + if (device != gdk_device_get_core_pointer()) { /* get around a GDK bug: map the valuator range CORRECTLY to [0,1] */ -#if ENABLE_XINPUT_BUGFIX +#ifdef ENABLE_XINPUT_BUGFIX gdk_device_set_axis_use(device, 0, GDK_AXIS_IGNORE); gdk_device_set_axis_use(device, 1, GDK_AXIS_IGNORE); #endif gdk_device_set_mode(device, GDK_MODE_SCREEN); can_xinput = TRUE; } - else gdk_device_set_mode(device, GDK_MODE_DISABLED); dev_list = dev_list->next; } if (!can_xinput) 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_widget_set_extension_events(GTK_WIDGET (canvas), + ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsUseXInput")), ui.use_xinput); @@ -211,11 +198,20 @@ 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(); + update_vbox_order(ui.vertical_order[ui.fullscreen?1:0]); + gtk_widget_grab_focus(GTK_WIDGET(canvas)); // show everything... @@ -277,6 +273,7 @@ main (int argc, char *argv[]) winMain = create_winMain (); init_stuff (argc, argv); + gtk_window_set_icon(GTK_WINDOW(winMain), create_pixbuf("xournal.png")); gtk_main ();