summaryrefslogtreecommitdiff
path: root/src/simple-scan.c
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2010-07-12 19:34:33 +0200
committerAlessio Treglia <alessio@debian.org>2010-07-12 19:34:33 +0200
commitc15dc3b14e35850849f3559ac0305b4cac4a7046 (patch)
tree2742af1506956e8f7e2e750e5907d36c627538da /src/simple-scan.c
parent37e8ad6c00349fd62f09c8cfe3e22acf545db2ac (diff)
Imported Upstream version 2.31.5~bzr424upstream/2.31.5.bzr424
Diffstat (limited to 'src/simple-scan.c')
-rw-r--r--src/simple-scan.c54
1 files changed, 4 insertions, 50 deletions
diff --git a/src/simple-scan.c b/src/simple-scan.c
index b8c3962..54236ae 100644
--- a/src/simple-scan.c
+++ b/src/simple-scan.c
@@ -26,6 +26,8 @@
static ScanDevice *default_device = NULL;
+static gboolean have_devices = FALSE;
+
static GUdevClient *udev_client;
static SimpleScan *ui;
@@ -62,6 +64,7 @@ update_scan_devices_cb (Scanner *scanner, GList *devices)
devices_copy = g_list_prepend (devices_copy, default_device);
}
+ have_devices = devices_copy != NULL;
ui_set_scan_devices (ui, devices_copy);
g_list_free (devices_copy);
@@ -261,7 +264,7 @@ scanner_failed_cb (Scanner *scanner, GError *error)
/* Title of error dialog when scan failed */
_("Failed to scan"),
error->message,
- TRUE);
+ have_devices);
}
}
@@ -305,54 +308,6 @@ cancel_cb (SimpleScan *ui)
}
-static gboolean
-save_book_by_extension (GFile *file, GError **error)
-{
- gboolean result;
- gchar *uri, *uri_lower;
-
- uri = g_file_get_uri (file);
- uri_lower = g_utf8_strdown (uri, -1);
- if (g_str_has_suffix (uri_lower, ".pdf"))
- result = book_save (book, "pdf", file, error);
- else if (g_str_has_suffix (uri_lower, ".ps"))
- result = book_save (book, "ps", file, error);
- else if (g_str_has_suffix (uri_lower, ".png"))
- result = book_save (book, "png", file, error);
- else if (g_str_has_suffix (uri_lower, ".tif") || g_str_has_suffix (uri_lower, ".tiff"))
- result = book_save (book, "tiff", file, error);
- else
- result = book_save (book, "jpeg", file, error);
-
- g_free (uri);
- g_free (uri_lower);
-
- return result;
-}
-
-
-static void
-save_cb (SimpleScan *ui, const gchar *uri)
-{
- GError *error = NULL;
- GFile *file;
-
- g_debug ("Saving to '%s'", uri);
-
- file = g_file_new_for_uri (uri);
- if (!save_book_by_extension (file, &error)) {
- g_warning ("Error saving file: %s", error->message);
- ui_show_error (ui,
- /* Title of error dialog when save failed */
- _("Failed to save file"),
- error->message,
- FALSE);
- g_error_free (error);
- }
- g_object_unref (file);
-}
-
-
static gchar *
get_temporary_filename (const gchar *prefix, const gchar *extension)
{
@@ -625,7 +580,6 @@ main (int argc, char **argv)
book = ui_get_book (ui);
g_signal_connect (ui, "start-scan", G_CALLBACK (scan_cb), NULL);
g_signal_connect (ui, "stop-scan", G_CALLBACK (cancel_cb), NULL);
- g_signal_connect (ui, "save", G_CALLBACK (save_cb), NULL);
g_signal_connect (ui, "email", G_CALLBACK (email_cb), NULL);
g_signal_connect (ui, "quit", G_CALLBACK (quit_cb), NULL);