summaryrefslogtreecommitdiff
path: root/src/xsane-preferences.c
diff options
context:
space:
mode:
authorAurelien Jarno <aurel32@debian.org>2005-02-03 16:24:20 +0100
committerMattia Rizzolo <mattia@mapreri.org>2014-10-03 14:05:06 +0000
commit825ef604db05e42ea267a86187bf62d54670c98c (patch)
treec41b8addd68e573fcf6ef599ec777e251a130b8e /src/xsane-preferences.c
parentac8459519a9ef2a1ee635509b52a653da1bfe9d5 (diff)
parent817e6294b42b3e4435f1b99728afc1dca84a6445 (diff)
Imported Debian patch 0.97-3debian/0.97-3
Diffstat (limited to 'src/xsane-preferences.c')
-rw-r--r--src/xsane-preferences.c187
1 files changed, 148 insertions, 39 deletions
diff --git a/src/xsane-preferences.c b/src/xsane-preferences.c
index 4ceec06..83da4e5 100644
--- a/src/xsane-preferences.c
+++ b/src/xsane-preferences.c
@@ -3,7 +3,7 @@
xsane-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
@@ -51,7 +51,9 @@ Preferences preferences =
{
0, /* xsane-version string */
0, /* default path to temporary directory (not defined here) */
+ 0, /* default working_directory */
0, /* no default filename */
+ 0, /* no default filetype */
0137, /* image umask (permission mask for -rw-r------) */
0027, /* directory umask (permission mask for -rwxr-x----) */
0, /* no fax project */
@@ -65,6 +67,8 @@ Preferences preferences =
296.98, /* fax_height: height of fax paper in mm */
0.0, /* fax_leftoffset */
0.0, /* fax_bottomoffset */
+ 1, /* fax_fine_mode */
+#ifdef XSANE_ACTIVATE_MAIL
0, /* no default from email address */
0, /* no default reply to email address */
0, /* no default smtp server */
@@ -76,9 +80,14 @@ Preferences preferences =
0, /* no default pop3 passsword */
0, /* no mail project */
0, /* no mail viewer */
+ 0, /* no mail filetype */
+#endif
0, /* no default ocrcommand */
0, /* no default ocr input file option */
0, /* no default ocr output file option */
+ 0, /* do not use progress pipe */
+ 0, /* no option for progress pipe filedeskriptor */
+ 0, /* no progress keyword */
0, /* no doc viewer */
80.0, /* jpeg_quality */
7.0, /* png_compression */
@@ -88,15 +97,18 @@ Preferences preferences =
1, /* save_devprefs_at_exit */
1, /* overwrite_warning */
1, /* skip_existing_numbers */
+ 0, /* save_pnm16_as_ascii */
0, /* reduce_16bit_to_8bit */
1, /* filename_counter_step */
4, /* filename_counter_len */
+ 6, /* show_range_mode */
1, /* tooltips enabled */
- 1, /* (dont) show histogram */
- 1, /* (dont) show gamma */
- 1, /* (dont) show standard options */
- 0, /* (dont) show advanced options */
- 0, /* (dont) show resolution list */
+ 1, /* show histogram */
+ 1, /* show gamma */
+ 0, /* don't show batch scan */
+ 1, /* show standard options */
+ 0, /* don`t show advanced options */
+ 0, /* don`t show resolution list */
10.0, /* length unit */
1, /* main window fixed (1) or scrolled (0) */
0, /* preview_own_cmap */
@@ -126,7 +138,7 @@ Preferences preferences =
1, /* preselect_scanarea after preview scan */
1, /* auto_correct_colors after preview scan */
GTK_UPDATE_DISCONTINUOUS, /* update policy for gtk frontend sliders */
- 0, /* psrotate: rotate in postscript mode (landscape) */
+ 0, /* paper_orientation */
0, /* preset_area_definitions */
0, /* printernr */
0 /* printerdefinitions */
@@ -144,7 +156,9 @@ desc[] =
{
{"xsane-version", xsane_rc_pref_string, POFFSET(xsane_version_str)},
{"tmp-path", xsane_rc_pref_string, POFFSET(tmp_path)},
+ {"working-directory", xsane_rc_pref_string, POFFSET(working_directory)},
{"filename", xsane_rc_pref_string, POFFSET(filename)},
+ {"filetype", xsane_rc_pref_string, POFFSET(filetype)},
{"image-umask", xsane_rc_pref_int, POFFSET(image_umask)},
{"directory-umask", xsane_rc_pref_int, POFFSET(directory_umask)},
{"fax-project", xsane_rc_pref_string, POFFSET(fax_project)},
@@ -158,6 +172,8 @@ desc[] =
{"fax-height", xsane_rc_pref_double, POFFSET(fax_height)},
{"fax-left-offset", xsane_rc_pref_double, POFFSET(fax_leftoffset)},
{"fax-bottom-offset", xsane_rc_pref_double, POFFSET(fax_bottomoffset)},
+ {"fax-fine-mode", xsane_rc_pref_int, POFFSET(fax_fine_mode)},
+#ifdef XSANE_ACTIVATE_MAIL
{"mail-from", xsane_rc_pref_string, POFFSET(mail_from)},
{"mail-reply-to", xsane_rc_pref_string, POFFSET(mail_reply_to)},
{"mail-smtp-server", xsane_rc_pref_string, POFFSET(mail_smtp_server)},
@@ -168,11 +184,16 @@ desc[] =
{"mail-pop3-user", xsane_rc_pref_string, POFFSET(mail_pop3_user)},
{"mail-pop3-pass", xsane_rc_pref_string, POFFSET(mail_pop3_pass)},
{"mail-project", xsane_rc_pref_string, POFFSET(mail_project)},
- {"mail-viewert", xsane_rc_pref_string, POFFSET(mail_viewer)},
+ {"mail-viewer", xsane_rc_pref_string, POFFSET(mail_viewer)},
+ {"mail-filetype", xsane_rc_pref_string, POFFSET(mail_filetype)},
+#endif
{"ocr-command", xsane_rc_pref_string, POFFSET(ocr_command)},
{"ocr-inputfile-option", xsane_rc_pref_string, POFFSET(ocr_inputfile_option)},
{"ocr-outputfile-options", xsane_rc_pref_string, POFFSET(ocr_outputfile_option)},
- {"doc-viewer", xsane_rc_pref_string, POFFSET(doc_viewer)},
+ {"ocr-use-gui-pipe", xsane_rc_pref_int, POFFSET(ocr_use_gui_pipe)},
+ {"ocr-gui-outfd-option", xsane_rc_pref_string, POFFSET(ocr_gui_outfd_option)},
+ {"ocr-progress-keyword", xsane_rc_pref_string, POFFSET(ocr_progress_keyword)},
+ {"browser", xsane_rc_pref_string, POFFSET(browser)},
{"jpeg-quality", xsane_rc_pref_double, POFFSET(jpeg_quality)},
{"png-compression", xsane_rc_pref_double, POFFSET(png_compression)},
{"tiff-compression16_nr", xsane_rc_pref_int, POFFSET(tiff_compression16_nr)},
@@ -181,12 +202,15 @@ desc[] =
{"save-devprefs-at-exit", xsane_rc_pref_int, POFFSET(save_devprefs_at_exit)},
{"overwrite-warning", xsane_rc_pref_int, POFFSET(overwrite_warning)},
{"skip-existing-numbers", xsane_rc_pref_int, POFFSET(skip_existing_numbers)},
+ {"save-pnm16-as-ascii", xsane_rc_pref_int, POFFSET( save_pnm16_as_ascii)},
{"reduce-16bit-to8bit", xsane_rc_pref_int, POFFSET(reduce_16bit_to_8bit)},
{"filename-counter-step", xsane_rc_pref_int, POFFSET(filename_counter_step)},
{"filename-counter-len", xsane_rc_pref_int, POFFSET(filename_counter_len)},
+ {"show-range-mode", xsane_rc_pref_int, POFFSET(show_range_mode)},
{"tool-tips", xsane_rc_pref_int, POFFSET(tooltips_enabled)},
{"show-histogram", xsane_rc_pref_int, POFFSET(show_histogram)},
{"show-gamma", xsane_rc_pref_int, POFFSET(show_gamma)},
+ {"show-batch-scan", xsane_rc_pref_int, POFFSET(show_batch_scan)},
{"show-standard-options", xsane_rc_pref_int, POFFSET(show_standard_options)},
{"show-advanced-options", xsane_rc_pref_int, POFFSET(show_advanced_options)},
{"show-resolution-list", xsane_rc_pref_int, POFFSET(show_resolution_list)},
@@ -219,9 +243,8 @@ desc[] =
{"preselect-scanarea", xsane_rc_pref_int, POFFSET(preselect_scanarea)},
{"auto-correct-colors", xsane_rc_pref_int, POFFSET(auto_correct_colors)},
{"gtk-update-policy", xsane_rc_pref_int, POFFSET(gtk_update_policy)},
- {"postscript-rotate", xsane_rc_pref_int, POFFSET(psrotate)},
+ {"paper-orientation", xsane_rc_pref_int, POFFSET(paper_orientation)},
{"preset-area-definitions", xsane_rc_pref_int, POFFSET(preset_area_definitions)},
- {"medium-definitions", xsane_rc_pref_int, POFFSET(medium_definitions)},
{"printernr", xsane_rc_pref_int, POFFSET(printernr)},
{"printerdefinitions", xsane_rc_pref_int, POFFSET(printerdefinitions)}
};
@@ -347,23 +370,6 @@ void preferences_save(int fd)
n++;
}
- /* save mediums */
-
- n=0;
-
- while (n < preferences.medium_definitions)
- {
- DBG(DBG_info2, "saving preferences medium definition %s\n", preferences.medium[n]->name);
- for (i = 0; i < NELEMS(desc_medium); ++i)
- {
- xsane_rc_io_w_string(&w, &desc_medium[i].name);
- (*desc_medium[i].codec) (&w, preferences.medium[n], desc_medium[i].offset);
- }
- n++;
- }
-
-
-
xsane_rc_io_w_set_dir(&w, WIRE_DECODE); /* flush it out */
xsane_rc_io_w_exit(&w);
}
@@ -390,28 +396,43 @@ void preferences_restore(int fd)
if (w.status)
{
xsane_rc_io_w_exit(&w);
+ preferences.printerdefinitions = 0;
+ preferences.preset_area_definitions = 0;
return;
}
xsane_rc_io_w_string(&w, &name);
- if (w.status || !name)
+ if (w.status == EINVAL) /* not a string */
+ {
+ w.status = 0;
+ xsane_rc_io_w_skip_newline(&w); /* skip this line */
+ }
+ else if (w.status || !name) /* other error */
{
xsane_rc_io_w_exit(&w);
return;
}
-
- for (i = 0; i < NELEMS (desc); ++i)
+ else /* identifier read */
{
- if (strcmp(name, desc[i].name) == 0)
+ for (i = 0; i < NELEMS(desc); ++i)
+ {
+ if (strcmp(name, desc[i].name) == 0)
+ {
+ DBG(DBG_info2, "reading preferences value for %s\n", desc[i].name);
+ (*desc[i].codec) (&w, &preferences, desc[i].offset);
+ break;
+ }
+ }
+
+ if (!strcmp(name, "printerdefinitions"))
{
- DBG(DBG_info2, "reading preferences value for %s\n", desc[i].name);
- (*desc[i].codec) (&w, &preferences, desc[i].offset);
break;
}
- }
- if (!strcmp(name, "printerdefinitions"))
- {
- break;
+ else if (i == NELEMS(desc))
+ {
+ DBG(DBG_info2, "preferences identifier %s unknown\n", name);
+ xsane_rc_io_w_skip_newline(&w); /* skip this line */
+ }
}
}
@@ -494,8 +515,94 @@ void preferences_restore(int fd)
}
}
+ xsane_rc_io_w_exit(&w);
+}
+
+/* --------------------------------------------------------------------- */
+/* --------------------------------------------------------------------- */
+
+void preferences_save_media(int fd)
+{
+ Wire w;
+ int i, n;
+ char *medium_defs="MEDIUM_DEFINITIONS";
+
+ DBG(DBG_proc, "preferences_save_media\n");
+
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_ENCODE);
+
+ xsane_rc_io_w_string(&w, &medium_defs);
+ xsane_rc_io_w_word(&w, &preferences.medium_definitions);
+
+ /* save media */
+
+ n=0;
+
+ DBG(DBG_info, "saving %d medium definitions\n", preferences.medium_definitions);
+
+ while (n < preferences.medium_definitions)
+ {
+ DBG(DBG_info2, "=> saving medium definition %s\n", preferences.medium[n]->name);
+ for (i = 0; i < NELEMS(desc_medium); ++i)
+ {
+ xsane_rc_io_w_string(&w, &desc_medium[i].name);
+ (*desc_medium[i].codec) (&w, preferences.medium[n], desc_medium[i].offset);
+ }
+ n++;
+ }
+
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE); /* flush it out */
+ xsane_rc_io_w_exit(&w);
+}
+
+/* --------------------------------------------------------------------- */
+
+void preferences_restore_media(int fd)
+{
+ SANE_String name;
+ Wire w;
+ int i, n;
+
+ DBG(DBG_proc, "preferences_restore_media\n");
+
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE);
+
+ preferences.medium_definitions = 0;
+
+ xsane_rc_io_w_space(&w, 3);
+ if (w.status)
+ {
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ xsane_rc_io_w_string(&w, &name);
+ if (w.status || !name)
+ {
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ if (strcmp(name, "MEDIUM_DEFINITIONS")) /* falsche Datei */
+ {
+ DBG(DBG_info, "no medium definitions in file\n");
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ xsane_rc_io_w_word(&w, &preferences.medium_definitions);
+
if (preferences.medium_definitions)
{
+ DBG(DBG_info, "reading %d medium definition\n", preferences.medium_definitions);
preferences.medium = calloc(preferences.medium_definitions, sizeof(void *));
n=0;
@@ -527,10 +634,12 @@ void preferences_restore(int fd)
break;
}
}
- DBG(DBG_info2, "preferences medium definition %s read\n", preferences.medium[n]->name);
+ DBG(DBG_info2, "=> medium definition %s read\n", preferences.medium[n]->name);
n++;
}
}
xsane_rc_io_w_exit(&w);
}
+
+/* --------------------------------------------------------------------- */