diff options
Diffstat (limited to 'src/xsane-device-preferences.c')
-rw-r--r-- | src/xsane-device-preferences.c | 124 |
1 files changed, 46 insertions, 78 deletions
diff --git a/src/xsane-device-preferences.c b/src/xsane-device-preferences.c index 7f6a80e..f70590b 100644 --- a/src/xsane-device-preferences.c +++ b/src/xsane-device-preferences.c @@ -3,7 +3,7 @@ xsane-device-preferences.c Oliver Rauch <Oliver.Rauch@rauch-domain.de> - Copyright (C) 1998-2002 Oliver Rauch + Copyright (C) 1998-2005 Oliver Rauch This file is part of the XSANE package. This program is free software; you can redistribute it and/or modify @@ -65,6 +65,9 @@ desc_xsane_device[] = {"xsane-gamma-window-x-position", xsane_rc_pref_int, DPOFFSET(gamma_dialog_posx)}, {"xsane-gamma-window-y-position", xsane_rc_pref_int, DPOFFSET(gamma_dialog_posy)}, + {"xsane-batch-window-x-position", xsane_rc_pref_int, DPOFFSET(batch_dialog_posx)}, + {"xsane-batch-window-y-position", xsane_rc_pref_int, DPOFFSET(batch_dialog_posy)}, + {"xsane-preview-window-x-position", xsane_rc_pref_int, DPOFFSET(preview_dialog_posx)}, {"xsane-preview-window-y-position", xsane_rc_pref_int, DPOFFSET(preview_dialog_posy)}, {"xsane-preview-window-width", xsane_rc_pref_int, DPOFFSET(preview_dialog_width)}, @@ -162,7 +165,7 @@ static int xsane_device_preferences_load_values(Wire *w, SANE_Handle device) status = SANE_STATUS_GOOD; info = 0; - for (i = 1; (opt = xsane_get_option_descriptor(device, i)); ++i) /* search all options */ + for (i = 1; (i < num_options) && (opt = xsane_get_option_descriptor(device, i)); ++i) /* search all options */ { if (!opt->name || strcmp(opt->name, name) != 0) /* test if option names are equal */ { @@ -240,10 +243,13 @@ static int xsane_device_preferences_save_values(Wire *w, SANE_Handle device) SANE_String str = 0; SANE_Word word; int i; + SANE_Int num_options; DBG(DBG_proc, "xsane_device_preferences_save_values\n"); - for (i = 0; (opt = xsane_get_option_descriptor(device, i)); ++i) + xsane_control_option(device, 0, SANE_ACTION_GET_VALUE, &num_options, 0); + + for (i = 0; (i < num_options) && (opt = xsane_get_option_descriptor(device, i)); ++i) { if ((opt->cap & (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT)) != (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT) || !opt->name) @@ -384,6 +390,12 @@ void xsane_device_preferences_load_file(char *filename) xsane.histogram_dialog_posx = XSANE_HISTOGRAM_POS_X; xsane.histogram_dialog_posy = XSANE_HISTOGRAM_POS_Y; + xsane.gamma_dialog_posx = XSANE_GAMMA_POS_X; + xsane.gamma_dialog_posy = XSANE_GAMMA_POS_Y; + + xsane.batch_dialog_posx = XSANE_BATCH_POS_X; + xsane.batch_dialog_posy = XSANE_BATCH_POS_Y; + xsane.preview_dialog_posx = XSANE_PREVIEW_POS_X; xsane.preview_dialog_posy = XSANE_PREVIEW_POS_Y; xsane.preview_dialog_width = XSANE_PREVIEW_WIDTH; @@ -483,58 +495,6 @@ void xsane_device_preferences_load_file(char *filename) return; } - -#if 0 -/* add here: read version info */ -#if 0 - while (!feof(file)) - { - fgets(option, sizeof(option), file); /* get option name */ - option[strlen(option)-1] = 0; /* remove cr */ - if (strcmp(option, "\"xsane-version\"") == 0) - { - fgets(option, sizeof(option), file); /* get version */ - option[strlen(option)-1] = 0; /* remove cr */ - len = strlen(option); - if (len) - { - if (option[len-1] == 34) - { - option[len-1] = 0; /* remove " */ - } - } - version = strdup(option+1); - } - else - { - fgets(option, sizeof(option), file); /* skip option */ - } - } -#endif - - - if (version) - { - if (strcmp(version, XSANE_VERSION)) - { - snprintf(buf, sizeof(buf), "File: \"%s\"\n" - "has been saved with xsane-%s,\n" - "this may cause problems!", filename, version); - xsane_back_gtk_warning(buf, TRUE); - } - free(version); - } - else - { - snprintf(buf, sizeof(buf), "File: \"%s\"\n" - "has been saved with xsane before version 0.40,\n" - "this may cause problems!", filename); - xsane_back_gtk_warning(buf, TRUE); - } -#endif - - - while (1) /* read device dependant xsane options */ { xsane_rc_io_w_space(&w, 3); @@ -592,12 +552,16 @@ void xsane_device_preferences_load_file(char *filename) } } } - gtk_widget_set_uposition(xsane.shell, xsane.shell_posx, xsane.shell_posy); + gtk_window_move(GTK_WINDOW(xsane.shell), xsane.shell_posx, xsane.shell_posy); gtk_window_set_default_size(GTK_WINDOW(xsane.shell), xsane.shell_width, xsane.shell_height); - gtk_widget_set_uposition(xsane.standard_options_shell, xsane.standard_options_shell_posx, xsane.standard_options_shell_posy); - gtk_widget_set_uposition(xsane.advanced_options_shell, xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy); - gtk_widget_set_uposition(xsane.histogram_dialog, xsane.histogram_dialog_posx, xsane.histogram_dialog_posy); - gtk_widget_set_uposition(xsane.preview->top, xsane.preview_dialog_posx, xsane.preview_dialog_posy); + gtk_window_move(GTK_WINDOW(xsane.standard_options_shell), xsane.standard_options_shell_posx, xsane.standard_options_shell_posy); + gtk_window_move(GTK_WINDOW(xsane.advanced_options_shell), xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy); + gtk_window_move(GTK_WINDOW(xsane.histogram_dialog), xsane.histogram_dialog_posx, xsane.histogram_dialog_posy); +#if 0 + gtk_window_move(GTK_WINDOW(xsane.gamma_dialog), xsane.gamma_dialog_posx, xsane.gamma_dialog_posy); +#endif + gtk_window_move(GTK_WINDOW(xsane.batch_scan_dialog), xsane.batch_dialog_posx, xsane.batch_dialog_posy); + gtk_window_move(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_posx, xsane.preview_dialog_posy); gtk_window_set_default_size(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_width, xsane.preview_dialog_height); xsane_update_param(0); @@ -636,14 +600,12 @@ void xsane_device_preferences_load(void) DBG(DBG_proc, "xsane_device_preferences_load\n"); - xsane_clear_histogram(&xsane.histogram_raw); - xsane_clear_histogram(&xsane.histogram_enh); xsane_set_sensitivity(FALSE); sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_LOAD_SETTINGS, xsane.device_text); xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, 0, xsane.device_set_filename, ".drc", XSANE_PATH_LOCAL_SANE); - if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, FALSE, FALSE, FALSE)) + if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE)) { xsane_device_preferences_load_file(filename); } @@ -693,25 +655,33 @@ void xsane_device_preferences_save_file(char *filename) XSANE_RC_IO_W_STRINGCONST(&w, XSANE_VERSION); /* make geometry and position values up to date */ - xsane_widget_get_uposition(xsane.shell, &xsane.shell_posx, &xsane.shell_posy); - gdk_window_get_size(xsane.shell->window, &xsane.shell_width, &xsane.shell_height); - gtk_widget_set_uposition(xsane.shell, xsane.shell_posx, xsane.shell_posy); /* geometry used when window closed and opened again */ + xsane_window_get_position(xsane.shell, &xsane.shell_posx, &xsane.shell_posy); + gdk_drawable_get_size(xsane.shell->window, &xsane.shell_width, &xsane.shell_height); + gtk_window_move(GTK_WINDOW(xsane.shell), xsane.shell_posx, xsane.shell_posy); /* geometry used when window closed and opened again */ gtk_window_set_default_size(GTK_WINDOW(xsane.shell), xsane.shell_width, xsane.shell_height); - xsane_widget_get_uposition(xsane.standard_options_shell, &xsane.standard_options_shell_posx, &xsane.standard_options_shell_posy); - gtk_widget_set_uposition(xsane.standard_options_shell, xsane.standard_options_shell_posx, xsane.standard_options_shell_posy); + xsane_window_get_position(xsane.standard_options_shell, &xsane.standard_options_shell_posx, &xsane.standard_options_shell_posy); + gtk_window_move(GTK_WINDOW(xsane.standard_options_shell), xsane.standard_options_shell_posx, xsane.standard_options_shell_posy); - xsane_widget_get_uposition(xsane.advanced_options_shell, &xsane.advanced_options_shell_posx, &xsane.advanced_options_shell_posy); - gtk_widget_set_uposition(xsane.advanced_options_shell, xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy); + xsane_window_get_position(xsane.advanced_options_shell, &xsane.advanced_options_shell_posx, &xsane.advanced_options_shell_posy); + gtk_window_move(GTK_WINDOW(xsane.advanced_options_shell), xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy); + + xsane_window_get_position(xsane.histogram_dialog, &xsane.histogram_dialog_posx, &xsane.histogram_dialog_posy); + gtk_window_move(GTK_WINDOW(xsane.histogram_dialog), xsane.histogram_dialog_posx, xsane.histogram_dialog_posy); + +#if 0 + xsane_window_get_position(xsane.gamma_dialog, &xsane.gamma_dialog_posx, &xsane.gamma_dialog_posy); + gtk_window_move(GTK_WINDOW(xsane.gamma_dialog), xsane.gamma_dialog_posx, xsane.gamma_dialog_posy); +#endif - xsane_widget_get_uposition(xsane.histogram_dialog, &xsane.histogram_dialog_posx, &xsane.histogram_dialog_posy); - gtk_widget_set_uposition(xsane.histogram_dialog, xsane.histogram_dialog_posx, xsane.histogram_dialog_posy); + xsane_window_get_position(xsane.batch_scan_dialog, &xsane.batch_dialog_posx, &xsane.batch_dialog_posy); + gtk_window_move(GTK_WINDOW(xsane.batch_scan_dialog), xsane.batch_dialog_posx, xsane.batch_dialog_posy); if (xsane.preview) { - xsane_widget_get_uposition(xsane.preview->top, &xsane.preview_dialog_posx, &xsane.preview_dialog_posy); - gdk_window_get_size(xsane.preview->top->window, &xsane.preview_dialog_width, &xsane.preview_dialog_height); - gtk_widget_set_uposition(xsane.preview->top, xsane.preview_dialog_posx, xsane.preview_dialog_posy); + xsane_window_get_position(xsane.preview->top, &xsane.preview_dialog_posx, &xsane.preview_dialog_posy); + gdk_drawable_get_size(xsane.preview->top->window, &xsane.preview_dialog_width, &xsane.preview_dialog_height); + gtk_window_move(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_posx, xsane.preview_dialog_posy); gtk_window_set_default_size(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_width, xsane.preview_dialog_height); } @@ -749,14 +719,12 @@ void xsane_device_preferences_save(void) DBG(DBG_proc, "xsane_device_preferences_save\n"); - xsane_clear_histogram(&xsane.histogram_raw); - xsane_clear_histogram(&xsane.histogram_enh); xsane_set_sensitivity(FALSE); sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_SAVE_SETTINGS, xsane.device_text); xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, 0, xsane.device_set_filename, ".drc", XSANE_PATH_LOCAL_SANE); - if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, FALSE, FALSE, FALSE)) + if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE)) { xsane_device_preferences_save_file(filename); } |