diff options
author | Alessio Treglia <quadrispro@ubuntu.com> | 2010-04-14 12:24:35 +0200 |
---|---|---|
committer | Alessio Treglia <quadrispro@ubuntu.com> | 2010-04-14 12:24:35 +0200 |
commit | a9a833c10711f1ec7060322030f11e64f44fca2c (patch) | |
tree | 2c0d84e44be6ed79c04b79540d55618ba73479aa /src/simple-scan.c | |
parent | c2e54e51031fa4b2512b851d13f5781118269d6b (diff) | |
parent | 6d9871f7c7de6caca9eb78683bcba499119e1469 (diff) |
Merge commit 'upstream/1.0.0'
Diffstat (limited to 'src/simple-scan.c')
-rw-r--r-- | src/simple-scan.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/simple-scan.c b/src/simple-scan.c index ab59299..b8c3962 100644 --- a/src/simple-scan.c +++ b/src/simple-scan.c @@ -24,7 +24,7 @@ #include "book.h" -static const char *default_device = NULL; +static ScanDevice *default_device = NULL; static GUdevClient *udev_client; @@ -44,7 +44,27 @@ static gboolean debug = FALSE; static void update_scan_devices_cb (Scanner *scanner, GList *devices) { - ui_set_scan_devices (ui, devices); + GList *devices_copy; + + devices_copy = g_list_copy (devices); + + /* If the default device is not detected add it to the list */ + if (default_device) { + GList *i; + + for (i = devices_copy; i; i = i->next) { + ScanDevice *device = i->data; + if (strcmp (device->name, default_device->name) == 0) + break; + } + + if (!i) + devices_copy = g_list_prepend (devices_copy, default_device); + } + + ui_set_scan_devices (ui, devices_copy); + + g_list_free (devices_copy); } @@ -343,7 +363,7 @@ get_temporary_filename (const gchar *prefix, const gchar *extension) /* NOTE: I'm not sure if this is a 100% safe strategy to use g_file_open_tmp(), close and * use the filename but it appears to work in practise */ - filename = g_strdup_printf ("%s-XXXXXX.%s", prefix, extension); + filename = g_strdup_printf ("%sXXXXXX.%s", prefix, extension); fd = g_file_open_tmp (filename, &path, &error); g_free (filename); if (fd < 0) { @@ -371,7 +391,7 @@ email_cb (SimpleScan *ui, const gchar *profile) gchar *path; /* Open a temporary file */ - path = get_temporary_filename ("scanned-document", "pdf"); + path = get_temporary_filename ("scan", "pdf"); if (path) { GFile *file; @@ -389,7 +409,7 @@ email_cb (SimpleScan *ui, const gchar *profile) gchar *path; GFile *file; - path = get_temporary_filename ("scanned-document", "jpg"); + path = get_temporary_filename ("scan", "jpg"); if (!path) { saved = FALSE; break; @@ -558,7 +578,9 @@ get_options (int argc, char **argv) fprintf (stderr, "Unknown argument: '%s'\n", arg); exit (1); } - default_device = arg; + default_device = g_malloc0 (sizeof (ScanDevice)); + default_device->name = g_strdup (arg); + default_device->label = g_strdup (arg); } } } @@ -621,8 +643,15 @@ main (int argc, char **argv) udev_client = g_udev_client_new (udev_subsystems); g_signal_connect (udev_client, "uevent", G_CALLBACK (on_uevent), NULL); - if (default_device) - ui_set_selected_device (ui, default_device); + if (default_device) { + GList device_list; + + device_list.data = default_device; + device_list.next = NULL; + device_list.prev = NULL; + ui_set_scan_devices (ui, &device_list); + ui_set_selected_device (ui, default_device->name); + } ui_start (ui); scanner_start (scanner); |