gtk_widget_hide(GET_COMPONENT("filePrintOptions"));
gtk_widget_hide(GET_COMPONENT("journalFlatten"));
gtk_widget_hide(GET_COMPONENT("papercolorOther"));
- gtk_widget_hide(GET_COMPONENT("journalApplyAllPages"));
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"));
GList *dev_list;
GdkDevice *device;
GdkScreen *screen;
- int i;
+ int i, j;
struct Brush *b;
- gboolean can_xinput;
+ 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 ());
+ // 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)
+ ui.mrufile = g_build_filename(tmppath, MRU_FILE, NULL);
+ g_free(tmppath);
+
// initialize data
// TODO: load this from a preferences file
undo = NULL; redo = NULL;
journal.pages = NULL;
bgpdf.status = STATUS_NOT_INIT;
-
- if (argc == 1) new_journal();
- else if (!open_journal(argv[1])) {
- new_journal();
- w = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error opening file '%s'", argv[1]);
- gtk_dialog_run(GTK_DIALOG(w));
- gtk_widget_destroy(w);
- }
+
+ new_journal();
ui.cur_item_type = ITEM_NONE;
ui.cur_item = NULL;
ui.cur_path.coords = NULL;
ui.cur_path_storage_alloc = 0;
ui.cur_path.ref_count = 1;
- ui.toolno = TOOL_PEN;
- ui.cur_brush = ui.brushes + TOOL_PEN;
- ui.ruler = FALSE;
+
ui.selection = NULL;
ui.cursor = NULL;
+ ui.bg_apply_all_pages = FALSE;
- ui.brushes[TOOL_PEN].color_no = COLOR_BLACK;
- ui.brushes[TOOL_ERASER].color_no = COLOR_WHITE;
- ui.brushes[TOOL_HIGHLIGHTER].color_no = COLOR_YELLOW;
+ 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 + i;
+ b = &(ui.brushes[0][i]);
b->tool_type = i;
b->color_rgba = predef_colors_rgba[b->color_no];
if (i == TOOL_HIGHLIGHTER) {
b->thickness_no = THICKNESS_MEDIUM;
b->thickness = predef_thickness[i][b->thickness_no];
b->tool_options = 0;
- g_memmove(ui.default_brushes+i, ui.brushes+i, sizeof(struct Brush));
+ 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));
}
+ ui.cur_mapping = 0;
+ ui.use_erasertip = FALSE;
// initialize various interface elements
gtk_window_set_default_size(GTK_WINDOW (winMain), 720, 480);
update_toolbar_and_menu();
+
// set up and initialize the canvas
gtk_widget_show (GTK_WIDGET (canvas));
ui.screen_width = gdk_screen_get_width(screen);
ui.screen_height = gdk_screen_get_height(screen);
- ui.saved_toolno = -1;
-
can_xinput = FALSE;
dev_list = gdk_devices_list();
while (dev_list != NULL) {
device = (GdkDevice *)dev_list->data;
- if (device->source == GDK_SOURCE_PEN || device->source == GDK_SOURCE_ERASER) {
+ if (device->source != GDK_SOURCE_MOUSE) {
/* get around a GDK bug: map the valuator range CORRECTLY to [0,1] */
#if ENABLE_XINPUT_BUGFIX
gdk_device_set_axis_use(device, 0, GDK_AXIS_IGNORE);
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)
ui.use_xinput = ui.allow_xinput && can_xinput;
ui.antialias_bg = TRUE;
- ui.emulate_eraser = FALSE;
ui.progressive_bg = TRUE;
gtk_check_menu_item_set_active(
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("optionsEmulateEraser")), ui.emulate_eraser);
hide_unimplemented();
update_undo_redo_enabled();
update_copy_paste_enabled();
+
+ // show everything...
+
+ gtk_widget_show (winMain);
+ update_cursor();
+
+ // load the MRU
+
+ init_mru();
+
+ // and finally, open a file specified on the command line
+ // (moved here because display parameters weren't initialized yet...)
+
+ if (argc == 1) return;
+ set_cursor_busy(TRUE);
+ if (g_path_is_absolute(argv[1]))
+ tmpfn = g_strdup(argv[1]);
+ else {
+ tmppath = g_get_current_dir();
+ tmpfn = g_build_filename(tmppath, argv[1], NULL);
+ g_free(tmppath);
+ }
+ success = open_journal(tmpfn);
+ g_free(tmpfn);
+ set_cursor_busy(FALSE);
+ if (!success) {
+ w = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Error opening file '%s'", argv[1]);
+ gtk_dialog_run(GTK_DIALOG(w));
+ gtk_widget_destroy(w);
+ }
}
init_stuff (argc, argv);
- gtk_widget_show (winMain);
- update_cursor();
-
gtk_main ();
if (bgpdf.status != STATUS_NOT_INIT) shutdown_bgpdf();
if (bgpdf.status != STATUS_NOT_INIT) end_bgpdf_shutdown();
+
+ save_mru_list();
return 0;
}