summaryrefslogtreecommitdiff
path: root/src/xsane-email-project.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xsane-email-project.c')
-rw-r--r--src/xsane-email-project.c91
1 files changed, 77 insertions, 14 deletions
diff --git a/src/xsane-email-project.c b/src/xsane-email-project.c
index 79df15b..b36dd59 100644
--- a/src/xsane-email-project.c
+++ b/src/xsane-email-project.c
@@ -3,7 +3,7 @@
xsane-email-project.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2005 Oliver Rauch
+ Copyright (C) 1998-2007 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -64,6 +64,7 @@ static gint xsane_email_dialog_delete();
static void xsane_email_filetype_callback(GtkWidget *filetype_option_menu, char *filetype);
static void xsane_email_receiver_changed_callback(GtkWidget *widget, gpointer data);
static void xsane_email_subject_changed_callback(GtkWidget *widget, gpointer data);
+static void xsane_email_project_browse_filename_callback(GtkWidget *widget, gpointer data);
static void xsane_email_project_changed_callback(GtkWidget *widget, gpointer data);
static void xsane_email_html_mode_callback(GtkWidget *widget);
static void xsane_email_project_display_status(void);
@@ -150,10 +151,14 @@ void xsane_email_dialog()
gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
gtk_box_pack_start(GTK_BOX(email_scan_vbox), hbox, FALSE, FALSE, 1);
+#if 0
pixmap = gdk_pixmap_create_from_xpm_d(xsane.dialog->window, &mask, xsane.bg_trans, (gchar **) email_xpm);
pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
gdk_drawable_unref(pixmap);
+#endif
+ button = xsane_button_new_with_pixmap(xsane.dialog->window, hbox, email_xpm, DESC_EMAIL_PROJECT_BROWSE,
+ (GtkSignalFunc) xsane_email_project_browse_filename_callback, NULL);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_EMAIL_PROJECT);
@@ -165,7 +170,7 @@ void xsane_email_dialog()
xsane.project_entry = text;
xsane.project_entry_box = hbox;
- gtk_widget_show(pixmapwidget);
+// gtk_widget_show(pixmapwidget);
gtk_widget_show(text);
gtk_widget_show(hbox);
@@ -1073,6 +1078,64 @@ static void xsane_email_subject_changed_callback(GtkWidget *widget, gpointer dat
/* ---------------------------------------------------------------------------------------------------------------------- */
+void xsane_email_project_set_filename(gchar *filename)
+{
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.project_entry), (GtkSignalFunc) xsane_email_project_changed_callback, NULL);
+ gtk_entry_set_text(GTK_ENTRY(xsane.project_entry), (char *) filename); /* update filename in entry */
+ gtk_entry_set_position(GTK_ENTRY(xsane.project_entry), strlen(filename)); /* set cursor to right position of filename */
+
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.project_entry), (GtkSignalFunc) xsane_email_project_changed_callback, NULL);
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_email_project_browse_filename_callback(GtkWidget *widget, gpointer data)
+{
+ char filename[PATH_MAX];
+ char windowname[TEXTBUFSIZE];
+
+ DBG(DBG_proc, "xsane_email_project_browse_filename_callback\n");
+
+ xsane_set_sensitivity(FALSE);
+
+ if (preferences.email_project) /* make sure a correct filename is defined */
+ {
+ strncpy(filename, preferences.email_project, sizeof(filename));
+ filename[sizeof(filename) - 1] = '\0';
+ }
+ else /* no filename given, take standard filename */
+ {
+ strcpy(filename, OUT_FILENAME);
+ }
+
+ snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_EMAIL_PROJECT_BROWSE, xsane.device_text);
+
+ umask((mode_t) preferences.directory_umask); /* define new file permissions */
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, NULL, XSANE_FILE_CHOOSER_ACTION_SELECT_PROJECT, XSANE_GET_FILENAME_SHOW_NOTHING, 0, 0))
+ {
+
+ if (preferences.email_project)
+ {
+ free((void *) preferences.email_project);
+ }
+
+ preferences.email_project = strdup(filename);
+
+ xsane_set_sensitivity(TRUE);
+ xsane_email_project_set_filename(filename);
+
+ xsane_email_project_load();
+ }
+ else
+ {
+ xsane_set_sensitivity(TRUE);
+ }
+ umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
+
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_email_project_changed_callback(GtkWidget *widget, gpointer data)
{
DBG(DBG_proc, "xsane_email_project_changed_callback\n");
@@ -1277,20 +1340,20 @@ static void xsane_email_entry_rename_callback(GtkWidget *widget, gpointer list)
#ifdef HAVE_GTK2
- button = gtk_button_new_from_stock(GTK_STOCK_OK);
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
#else
- button = gtk_button_new_with_label(BUTTON_OK);
+ button = gtk_button_new_with_label(BUTTON_CANCEL);
#endif
- g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_email_entry_rename_button_callback, (void *) 1);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_email_entry_rename_button_callback,(void *) -1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
#ifdef HAVE_GTK2
- button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
#else
- button = gtk_button_new_with_label(BUTTON_CANCEL);
+ button = gtk_button_new_with_label(BUTTON_OK);
#endif
- g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_email_entry_rename_button_callback,(void *) -1);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_email_entry_rename_button_callback, (void *) 1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -1595,7 +1658,7 @@ static void xsane_create_email(int fd)
/* doc files like ps and pdf can not be displayed inline in html email */
if (display_images_inline)
{
- snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
+ snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\r\n", content_id);
}
write(fd, buf, strlen(buf));
}
@@ -1605,7 +1668,7 @@ static void xsane_create_email(int fd)
}
else if (*email_text_pos == 10) /* new line */
{
- snprintf(buf, sizeof(buf), "<br>\n");
+ snprintf(buf, sizeof(buf), "<br>\r\n");
write(fd, buf, strlen(buf));
}
else
@@ -1624,12 +1687,12 @@ static void xsane_create_email(int fd)
/* doc files like ps and pdf can not be displayed inline in html email */
if (display_images_inline)
{
- snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
+ snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\r\n", content_id);
}
write(fd, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), "</html>\n");
+ snprintf(buf, sizeof(buf), "</html>\r\n");
write(fd, buf, strlen(buf));
@@ -1666,7 +1729,7 @@ static void xsane_create_email(int fd)
write_email_mime_ascii(fd, boundary);
write(fd, email_text, strlen(email_text));
- write(fd, "\n\n", 2);
+ write(fd, "\r\n\r\n", 4);
for (i=0; i<attachments; i++)
{
@@ -1856,7 +1919,7 @@ static void xsane_email_send()
free(type);
DBG(DBG_info, "converting %s to %s\n", source_filename, email_filename);
output_format = xsane_identify_output_format(email_filename, NULL, NULL);
- xsane_save_image_as(email_filename, source_filename, output_format, xsane.project_progress_bar, &cancel_save);
+ xsane_save_image_as(email_filename, source_filename, output_format, xsane.enable_color_management, preferences.cms_function, preferences.cms_intent, preferences.cms_bpc, xsane.project_progress_bar, &cancel_save);
list = list->next;
xsane.email_progress_size += xsane_get_filesize(email_filename);
}