aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-11-08 14:49:14 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-11-08 14:49:14 +0800
commit234540a383de150f0a79df466aa76dae4096d09c (patch)
treece8697e153cefd8ce95644370392c874c443b33a /composer/e-msg-composer.c
parentab44fe3e1d962e7876693929c940121e2954379d (diff)
downloadgsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.gz
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.bz2
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.lz
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.xz
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.zst
gsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.zip
Fix bonobo object setup.
2002-11-08 Not Zed <NotZed@Ximian.com> * listener.c: Fix bonobo object setup. * e-msg-composer-hdrs.c: Remove oaf stuff, fix destroy to be multi-call safe. * e-msg-composer-attachment.c (e_msg_composer_attachment_new): Remove utf8 from locale conversions, & glib api changes. (ok_cb): " * e-msg-composer-attachment-bar.c (add_from_file): gtk message dialog. (pixbuf_for_mime_type): glib,gnome-vfs api changes. (init): Estimate the icon_height based on the pango font description size, this is probably not correct. (properties_cb): (remove_cb): Changed signature for gnomeui callbacks. (popup_icon_context_menu): (popup_context_menu): popup_menu api change (destroy): Protect from multiple calls. (e_msg_composer_attachment_bar_new): Remove push/pop visual/colormap stuff. * composer-marshal.list: The list of marshallers used by the composer. * Makefile.am (composer-marshal.h): Added composer marshal builder. * evolution-composer.c (class_init): bonobo object epv setup change. (factory_fn): Fix changes to factory callback. * e-icon-list.c: (icon_get_height): Use bounding box to calc height. (icon_event): drop gtk_selection_extended. (e_icon_list_remove): " (select_icon): (unselect_icon): " * e-msg-composer.c (autosave_save_draft): Dup fd rather than poke camel_stream_fd's data. Also, use camel_stream_close() rather than flush. (autosave_manager_query_load_orphans): Port to gtk dialog. (autosave_query_cb): Removed, redundant. (save): Port to gtkdialog. (prepare_engine): Fix bonobo-object-client code. (get_file_content): gtk dialog (do_exit): gtk dialog. (setup_signatures_menu): dump gtkutf8 stuff. (marshal_NONE__NONE_INT): What WAS jeff thinking? Removed :) (class_init): g object setup. (e_msg_composer_get_type): " (create_composer): remove bonobo_window_construct, use create property instead. g_signal stuff. bonobo stuff. (is_special_header): Use ascii_strncasecmp (e_msg_composer_set_pending_body): gtk->g_object_get/set_data. (e_msg_composer_set_body): use ascii_strncasecmp (e_msg_composer_add_inline_image_from_mime_part): make cid const. (autosave_manager_register): (autosave_manager_unregister): Use g_path_get_basename() & account for differences. (composer_shutdown): rename to finalise/etc. (class_init): Use object:finalize instead of shutdown. (e_msg_composer_set_body): Use _() rather than U_(). (build_message): gtk dialog. 2002-11-06 Not Zed <NotZed@Ximian.com> * e-msg-composer-attachment-bar.c (pixbuf_for_mime_type): Add error return to gdk_pixbuf_new_from_file(). svn path=/trunk/; revision=18659
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c480
1 files changed, 245 insertions, 235 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 60e06c0006..cabd5929a7 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -51,23 +51,19 @@
#include <sys/wait.h>
#include <unistd.h>
+#include <glib/gunicode.h>
+
#include <gtk/gtkoptionmenu.h>
-#include <gal/unicode/gunicode.h>
-#include <gal/util/e-unicode-i18n.h>
-#include <gal/widgets/e-unicode.h>
+/*#include <gal/widgets/e-unicode.h>*/
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-exec.h>
-#include <libgnomeui/gnome-app.h>
+/*#include <libgnomeui/gnome-app.h>*/
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomeui/gnome-dialog.h>
-#include <libgnomeui/gnome-dialog-util.h>
-#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-window-icon.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
-#include <bonobo/bonobo-object-client.h>
#include <bonobo/bonobo-stream-memory.h>
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-widget.h>
@@ -80,16 +76,15 @@
#include <gal/widgets/e-scroll-frame.h>
#include <gal/e-text/e-entry.h>
-#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/htmlselection.h>
-
#include "widgets/misc/e-charset-picker.h"
#include "camel/camel.h"
#include "camel/camel-charset-map.h"
#include "camel/camel-session.h"
-#include "mail/mail.h"
+#warning "need to re-add mail.h"
+/*#include "mail.h"*/
+#include "mail/mail-callbacks.h"
#include "mail/mail-crypto.h"
#include "mail/mail-tools.h"
#include "mail/mail-ops.h"
@@ -342,7 +337,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
/* evil kludgy hack for Redirect */
if (composer->redirect) {
e_msg_composer_hdrs_to_redirect (hdrs, composer->redirect);
- camel_object_ref (CAMEL_OBJECT (composer->redirect));
+ camel_object_ref (composer->redirect);
return composer->redirect;
}
@@ -383,7 +378,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
plain = camel_data_wrapper_new ();
stream = camel_stream_mem_new_with_byte_array (data);
camel_data_wrapper_construct_from_stream (plain, stream);
- camel_object_unref (CAMEL_OBJECT (stream));
+ camel_object_unref (stream);
camel_data_wrapper_set_mime_type_field (plain, type);
header_content_type_unref (type);
@@ -403,14 +398,14 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
if (!data) {
/* The component has probably died */
- camel_object_unref (CAMEL_OBJECT (new));
- camel_object_unref (CAMEL_OBJECT (plain));
+ camel_object_unref (new);
+ camel_object_unref (plain);
return NULL;
}
html = camel_data_wrapper_new ();
stream = camel_stream_mem_new_with_byte_array (data);
camel_data_wrapper_construct_from_stream (html, stream);
- camel_object_unref (CAMEL_OBJECT (stream));
+ camel_object_unref (stream);
camel_data_wrapper_set_mime_type (html, "text/html; charset=utf-8");
/* Build the multipart/alternative */
@@ -421,16 +416,16 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), plain);
- camel_object_unref (CAMEL_OBJECT (plain));
+ camel_object_unref (plain);
camel_mime_part_set_encoding (part, plain_encoding);
camel_multipart_add_part (body, part);
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (part);
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), html);
- camel_object_unref (CAMEL_OBJECT (html));
+ camel_object_unref (html);
camel_multipart_add_part (body, part);
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (part);
/* If there are inlined images, construct a
* multipart/related containing the
@@ -447,9 +442,9 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (body));
- camel_object_unref (CAMEL_OBJECT (body));
+ camel_object_unref (body);
camel_multipart_add_part (html_with_images, part);
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (part);
add_inlined_images (composer, html_with_images);
clear_current_images (composer);
@@ -475,9 +470,9 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
camel_medium_set_content_object (CAMEL_MEDIUM (part), current);
if (current == plain)
camel_mime_part_set_encoding (part, plain_encoding);
- camel_object_unref (CAMEL_OBJECT (current));
+ camel_object_unref (current);
camel_multipart_add_part (multipart, part);
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (part);
e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart, composer->charset);
@@ -500,7 +495,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
camel_medium_set_content_object (CAMEL_MEDIUM (part), current);
if (current == plain)
camel_mime_part_set_encoding (part, plain_encoding);
- camel_object_unref (CAMEL_OBJECT (current));
+ camel_object_unref (current);
if (composer->pgp_sign) {
CamelInternetAddress *from = NULL;
@@ -631,14 +626,14 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
}
current = camel_medium_get_content_object (CAMEL_MEDIUM (part));
- camel_object_ref (CAMEL_OBJECT (current));
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_ref (current);
+ camel_object_unref (part);
}
camel_medium_set_content_object (CAMEL_MEDIUM (new), current);
if (current == plain)
camel_mime_part_set_encoding (CAMEL_MIME_PART (new), plain_encoding);
- camel_object_unref (CAMEL_OBJECT (current));
+ camel_object_unref (current);
#if defined (HAVE_NSS) && defined (SMIME_SUPPORTED)
if (composer->smime_sign) {
@@ -659,12 +654,12 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
smime_mesg = mail_crypto_smime_sign (new, certname, TRUE, TRUE, &ex);
if (from)
- camel_object_unref (CAMEL_OBJECT (from));
+ camel_object_unref (from);
if (camel_exception_is_set (&ex))
goto exception;
- camel_object_unref (CAMEL_OBJECT (new));
+ camel_object_unref (new);
new = smime_mesg;
}
@@ -693,7 +688,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
g_ptr_array_add (recipients, g_strdup (address));
if (from)
- camel_object_unref (CAMEL_OBJECT (addr));
+ camel_object_unref (addr);
}
addr = camel_mime_message_get_recipients (new, CAMEL_RECIPIENT_TYPE_TO);
@@ -722,7 +717,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
smime_mesg = mail_crypto_smime_encrypt (new, address, recipients, &ex);
- camel_object_unref (CAMEL_OBJECT (from));
+ camel_object_unref (from);
for (i = 0; i < recipients->len; i++)
g_free (recipients->pdata[i]);
@@ -731,7 +726,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
if (camel_exception_is_set (&ex))
goto exception;
- camel_object_unref (CAMEL_OBJECT (new));
+ camel_object_unref (new);
new = smime_mesg;
}
@@ -750,16 +745,20 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
exception:
if (part != CAMEL_MIME_PART (new))
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (part);
- camel_object_unref (CAMEL_OBJECT (new));
+ camel_object_unref (new);
if (camel_exception_is_set (&ex)) {
GtkWidget *dialog;
-
- dialog = gnome_error_dialog_parented (camel_exception_get_description (&ex),
- GTK_WINDOW (composer));
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "%s", camel_exception_get_description (&ex));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_object_unref(dialog);
camel_exception_clear (&ex);
}
@@ -781,13 +780,17 @@ get_file_content (EMsgComposer *composer, const char *file_name, gboolean want_h
fd = open (file_name, O_RDONLY);
if (fd == -1) {
- char *msg;
-
if (warn) {
- msg = g_strdup_printf (_("Error while reading file %s:\n%s"),
- file_name, g_strerror (errno));
- gnome_error_dialog (msg);
- g_free (msg);
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Error while reading file %s:\n%s"),
+ file_name, g_strerror (errno));
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_object_unref(dialog);
}
return g_strdup ("");
}
@@ -866,8 +869,8 @@ prepare_engine (EMsgComposer *composer)
/* printf ("prepare_engine\n"); */
CORBA_exception_init (&ev);
- composer->editor_engine = (GNOME_GtkHTML_Editor_Engine) bonobo_object_client_query_interface
- (bonobo_widget_get_server (BONOBO_WIDGET (composer->editor)), "IDL:GNOME/GtkHTML/Editor/Engine:1.0", &ev);
+ composer->editor_engine = (GNOME_GtkHTML_Editor_Engine) Bonobo_Unknown_queryInterface
+ (bonobo_widget_get_objref (BONOBO_WIDGET (composer->editor)), "IDL:GNOME/GtkHTML/Editor/Engine:1.0", &ev);
if ((composer->editor_engine != CORBA_OBJECT_NIL) && (ev._major == CORBA_NO_EXCEPTION)) {
/* printf ("trying set listener\n"); */
@@ -1109,9 +1112,11 @@ set_config (EMsgComposer *composer, char *key, int val)
return;
full_key = g_strconcat ("/Mail/Composer/", key, NULL);
-
+
+#warning "bonobo config"
+#if 0
bonobo_config_set_long (composer->config_db, full_key, val, NULL);
-
+#endif
g_free (full_key);
}
@@ -1155,25 +1160,19 @@ save (EMsgComposer *composer, const char *file_name)
/* check to see if we already have the file */
if ((fd = open (my_file_name, O_RDONLY | O_CREAT | O_EXCL, 0777)) == -1) {
- GtkWidget *dialog, *label;
-
- dialog = gnome_dialog_new (_("Warning!"),
- GNOME_STOCK_BUTTON_YES,
- GNOME_STOCK_BUTTON_NO,
- NULL);
- label = gtk_label_new (_("File exists, overwrite?"));
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0);
-
- switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) {
- case -1:
- gtk_widget_destroy (dialog);
- return;
- case 1:
+ GtkWidget *dialog;
+ int resp;
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+ _("File exists, overwrite?"));
+ resp = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_object_unref(dialog);
+ if (resp != GTK_RESPONSE_YES) {
+ g_free(my_file_name);
return;
- default:
- /* ie, the user hit "Yes" so just continue as normal */
- break;
}
} else
close (fd);
@@ -1183,8 +1182,12 @@ save (EMsgComposer *composer, const char *file_name)
Bonobo_PersistFile_save (composer->persist_file_interface, my_file_name, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
+#warning "e_notice??"
+ char *tmp = g_path_get_basename(my_file_name);
+
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
- _("Error saving file: %s"), g_basename (my_file_name));
+ _("Error saving file: %s"), tmp);
+ g_free(tmp);
} else
GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "saved", &ev);
@@ -1202,9 +1205,13 @@ load (EMsgComposer *composer, const char *file_name)
Bonobo_PersistFile_load (composer->persist_file_interface, file_name, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ char *tmp = g_path_get_basename(file_name);
+
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
- _("Error loading file: %s"), g_basename (file_name));
+ _("Error loading file: %s"), tmp);
+ g_free(tmp);
+ }
CORBA_exception_free (&ev);
}
@@ -1229,7 +1236,7 @@ autosave_save_draft (EMsgComposer *composer)
CamelMimeMessage *message;
CamelStream *stream;
char *file;
- int fd;
+ int fd, camelfd;
gboolean success = TRUE;
fd = composer->autosave_fd;
@@ -1250,34 +1257,41 @@ autosave_save_draft (EMsgComposer *composer)
}
if (lseek (fd, (off_t)0, SEEK_SET) == -1) {
- camel_object_unref (CAMEL_OBJECT (message));
+ camel_object_unref (message);
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Unable to seek on file: %s\n%s"), file, g_strerror (errno));
return FALSE;
}
if (ftruncate (fd, (off_t)0) == -1) {
- camel_object_unref (CAMEL_OBJECT (message));
+ camel_object_unref (message);
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Unable to truncate file: %s\n%s"), file, g_strerror (errno));
return FALSE;
}
+
+ /* dup the fd because we dont want camel to close it when done */
+ camelfd = dup(fd);
+ if (fd == -1) {
+ camel_object_unref (message);
+ e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
+ _("Unable to copy file descriptor: %s\n%s"), file, g_strerror (errno));
+ return FALSE;
+ }
/* this does an lseek so we don't have to */
- stream = camel_stream_fs_new_with_fd (fd);
+ stream = camel_stream_fs_new_with_fd (camelfd);
if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream) == -1
- || camel_stream_flush (CAMEL_STREAM (stream)) == -1) {
+ || camel_stream_close (CAMEL_STREAM (stream)) == -1) {
e_notice (GTK_WINDOW (composer), GNOME_MESSAGE_BOX_ERROR,
_("Error autosaving message: %s\n %s"), file, strerror(errno));
success = FALSE;
}
- /* set the fd to -1 in the stream so camel doesn't close it we want to keep it open */
- CAMEL_STREAM_FS (stream)->fd = -1;
- camel_object_unref (CAMEL_OBJECT (stream));
+ camel_object_unref (stream);
- camel_object_unref (CAMEL_OBJECT (message));
+ camel_object_unref (message);
return success;
}
@@ -1306,13 +1320,13 @@ autosave_load_draft (const char *filename)
if (composer) {
autosave_save_draft (composer);
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (composer_send_cb), NULL);
+ g_signal_connect (GTK_OBJECT (composer), "send",
+ G_CALLBACK (composer_send_cb), NULL);
gtk_widget_show (GTK_WIDGET (composer));
}
- camel_object_unref ((CamelObject *)stream);
+ camel_object_unref (stream);
return composer;
}
@@ -1323,14 +1337,6 @@ autosave_is_owned (AutosaveManager *am, const char *file)
}
static void
-autosave_query_cb (gint reply, gpointer data)
-{
- int *yes = data;
-
- *yes = !reply;
-}
-
-static void
autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer)
{
GtkWidget *dialog;
@@ -1356,7 +1362,7 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer
* check if the file has any length, It is a valid case if it doesn't
* so we simply don't ask then.
*/
- if (stat (filename, &st) < 0 || st.st_size == 0) {
+ if (stat (filename, &st) == -1 || st.st_size == 0) {
unlink (filename);
g_free (filename);
continue;
@@ -1368,11 +1374,16 @@ autosave_manager_query_load_orphans (AutosaveManager *am, EMsgComposer *composer
closedir (dir);
if (match != NULL) {
- dialog = gnome_question_dialog_parented (_("Ximian Evolution has found unsaved files from a previous session.\n"
- "Would you like to try to recover them?"),
- autosave_query_cb, &load, GTK_WINDOW (composer));
-
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO,
+ _("Ximian Evolution has found unsaved files from a previous session.\n"
+ "Would you like to try to recover them?"));
+ load = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES;
+ gtk_widget_destroy(dialog);
+ g_object_unref(dialog);
}
while (match != NULL) {
@@ -1462,7 +1473,7 @@ autosave_manager_register (AutosaveManager *am, EMsgComposer *composer)
g_return_if_fail (composer != NULL);
if (autosave_init_file (composer)) {
- key = g_basename (composer->autosave_file);
+ key = g_path_get_basename (composer->autosave_file);
g_hash_table_insert (am->table, key, composer);
if (am->ask) {
/* keep recursion out of our bedrooms. */
@@ -1477,10 +1488,18 @@ autosave_manager_register (AutosaveManager *am, EMsgComposer *composer)
static void
autosave_manager_unregister (AutosaveManager *am, EMsgComposer *composer)
{
+ char *key, *oldkey;
+ void *olddata;
+
if (!composer->autosave_file)
return;
- g_hash_table_remove (am->table, g_basename (composer->autosave_file));
+ key = g_path_get_basename(composer->autosave_file);
+ if (g_hash_table_lookup_extended(am->table, key, (void **)&oldkey, &olddata)) {
+ g_hash_table_remove(am->table, oldkey);
+ g_free(oldkey);
+ g_free(key);
+ }
/* only remove the file if we can successfully save it */
/* FIXME this test could probably be more efficient */
@@ -1498,7 +1517,7 @@ autosave_manager_unregister (AutosaveManager *am, EMsgComposer *composer)
static void
menu_file_save_draft_cb (BonoboUIComponent *uic, void *data, const char *path)
{
- gtk_signal_emit (GTK_OBJECT (data), signals[SAVE_DRAFT], FALSE);
+ g_signal_emit (data, signals[SAVE_DRAFT], 0, FALSE);
e_msg_composer_unset_changed (E_MSG_COMPOSER (data));
}
@@ -1507,7 +1526,7 @@ menu_file_save_draft_cb (BonoboUIComponent *uic, void *data, const char *path)
static void
do_exit (EMsgComposer *composer)
{
- char *subject, *subject_utf8, *label;
+ char *subject;
GtkWidget *dialog;
int button;
@@ -1517,39 +1536,32 @@ do_exit (EMsgComposer *composer)
}
gdk_window_raise (GTK_WIDGET (composer)->window);
-
- subject_utf8 = e_msg_composer_hdrs_get_subject (E_MSG_COMPOSER_HDRS (composer->hdrs));
- subject = e_utf8_to_locale_string (subject_utf8);
- g_free (subject_utf8);
-
- label = g_strdup_printf (_("The message \"%s\" has not been sent.\n\nDo you wish to save your changes?"), subject);
- g_free (subject);
-
- dialog = gnome_message_box_new (label, GNOME_MESSAGE_BOX_QUESTION,
- GNOME_STOCK_BUTTON_YES, /* Save */
- GNOME_STOCK_BUTTON_NO, /* Don't save */
- GNOME_STOCK_BUTTON_CANCEL, /* Cancel */
- NULL);
-
- g_free (label);
-
+
+ subject = e_msg_composer_hdrs_get_subject (E_MSG_COMPOSER_HDRS (composer->hdrs));
+ dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO,
+ _("The message \"%s\" has not been sent.\n\nDo you wish to save your changes?"),
+ subject);
+ g_free(subject);
+ gtk_dialog_add_button (GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_window_set_title (GTK_WINDOW (dialog), _("Warning: Modified Message"));
- gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (composer));
- gnome_dialog_set_default (GNOME_DIALOG (dialog), 0);
- button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
-
- switch (button) {
- case 0:
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+ button = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_object_unref(dialog);
+
+ switch(button) {
+ case GTK_RESPONSE_YES:
/* Save */
- gtk_signal_emit (GTK_OBJECT (composer), signals[SAVE_DRAFT], TRUE);
+ g_signal_emit (GTK_OBJECT (composer), signals[SAVE_DRAFT], 0, TRUE);
e_msg_composer_unset_changed (composer);
break;
- case 1:
+ case GTK_RESPONSE_NO:
/* Don't save */
gtk_widget_destroy (GTK_WIDGET (composer));
break;
- default:
- /* Cancel */
+ case GTK_RESPONSE_CANCEL:
break;
}
}
@@ -1970,11 +1982,7 @@ setup_signatures_menu (EMsgComposer *composer)
list = mail_config_get_signature_list ();
if (list)
for (l = list; l; len ++, l = l->next) {
- gchar *gtk_str;
-
- gtk_str = e_utf8_to_gtk_string (menu, ((MailConfigSignature *)l->data)->name);
- ADD (gtk_str);
- g_free (gtk_str);
+ ADD(((MailConfigSignature *)l->data)->name);
}
#undef ADD
@@ -1982,7 +1990,7 @@ setup_signatures_menu (EMsgComposer *composer)
gtk_option_menu_set_menu (GTK_OPTION_MENU (composer->sig_omenu), menu);
sig_select_item (composer);
- gtk_signal_connect (GTK_OBJECT (menu), "selection-done", signature_cb, composer);
+ g_signal_connect (menu, "selection-done", (GCallback)signature_cb, composer);
}
static void
@@ -1996,7 +2004,8 @@ setup_ui (EMsgComposer *composer)
bonobo_ui_container_set_win (container, BONOBO_WINDOW (composer));
composer->uic = bonobo_ui_component_new_default ();
- bonobo_ui_component_set_container (composer->uic, bonobo_object_corba_objref (BONOBO_OBJECT (container)));
+ /* FIXME: handle bonobo exceptions */
+ bonobo_ui_component_set_container (composer->uic, bonobo_object_corba_objref (BONOBO_OBJECT (container)), NULL);
bonobo_ui_component_add_verb_list_with_data (composer->uic, verbs, composer);
@@ -2004,15 +2013,20 @@ setup_ui (EMsgComposer *composer)
bonobo_ui_util_set_ui (composer->uic, EVOLUTION_DATADIR,
"evolution-message-composer.xml",
- "evolution-message-composer");
+ "evolution-message-composer", NULL);
e_pixmaps_update (composer->uic, pixcache);
/* Populate the Charset Encoding menu and default it to whatever the user
chose as his default charset in the mailer */
+#warning "bonobo_config"
+#if 0
default_charset = bonobo_config_get_string (composer->config_db,
"/Mail/Format/default_charset",
NULL);
+#else
+ default_charset = g_strdup("iso-8859-1");
+#endif
e_charset_picker_bonobo_ui_populate (composer->uic, "/menu/Edit/EncodingPlaceholder",
default_charset,
menu_changed_charset_cb,
@@ -2218,7 +2232,7 @@ update_auto_recipients (EMsgComposerHdrs *hdrs, int mode, const char *auto_addrs
}
}
- camel_object_unref (CAMEL_OBJECT (iaddr));
+ camel_object_unref (iaddr);
}
switch (mode) {
@@ -2302,15 +2316,15 @@ from_changed_cb (EMsgComposerHdrs *hdrs, void *data)
/* GtkObject methods. */
static void
-composer_shutdown (GtkObject *object)
+composer_finalise (GObject *object)
{
/* When destroy() is called, the contents of the window
* (including the remote editor control) will already have
* been destroyed, so we have to do this here.
*/
autosave_manager_unregister (am, E_MSG_COMPOSER (object));
- if (GTK_OBJECT_CLASS (parent_class)->shutdown != NULL)
- (* GTK_OBJECT_CLASS (parent_class)->shutdown) (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize != NULL)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
@@ -2421,7 +2435,7 @@ message_rfc822_dnd (EMsgComposer *composer, CamelStream *stream)
message = camel_mime_message_new ();
if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (message), mp) == -1) {
- camel_object_unref (CAMEL_OBJECT (message));
+ camel_object_unref (message);
break;
}
@@ -2432,15 +2446,15 @@ message_rfc822_dnd (EMsgComposer *composer, CamelStream *stream)
camel_mime_part_set_content_type (part, "message/rfc822");
e_msg_composer_attachment_bar_attach_mime_part (E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
part);
- camel_object_unref (CAMEL_OBJECT (message));
- camel_object_unref (CAMEL_OBJECT (part));
+ camel_object_unref (message);
+ camel_object_unref (part);
camel_exception_clear (ex);
/* skip over the FROM_END state */
camel_mime_parser_step (mp, 0, 0);
}
- camel_object_unref (CAMEL_OBJECT (mp));
+ camel_object_unref (mp);
camel_exception_free (ex);
}
@@ -2464,7 +2478,7 @@ drag_data_received (EMsgComposer *composer, GdkDragContext *context,
camel_stream_reset (stream);
message_rfc822_dnd (composer, stream);
- camel_object_unref (CAMEL_OBJECT (stream));
+ camel_object_unref (stream);
break;
case DND_TYPE_TEXT_URI_LIST:
d(printf ("dropping a text/uri-list\n"));
@@ -2501,58 +2515,48 @@ drag_data_received (EMsgComposer *composer, GdkDragContext *context,
(E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
mime_part);
- camel_object_unref (CAMEL_OBJECT (mime_part));
+ camel_object_unref (mime_part);
default:
d(printf ("dropping an unknown\n"));
break;
}
}
-typedef void (*GtkSignal_NONE__NONE_INT) (GtkObject *, int, gpointer);
-
-static void marshal_NONE__NONE_INT (GtkObject *object, GtkSignalFunc func,
- gpointer func_data, GtkArg *args)
-{
- GtkSignal_NONE__NONE_INT rfunc;
-
- rfunc = (GtkSignal_NONE__NONE_INT) func;
- (*rfunc)(object, GTK_VALUE_INT (args[0]), func_data);
-}
-
-
static void
class_init (EMsgComposerClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
-
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS(klass);
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
- object_class->shutdown = composer_shutdown;
+ gobject_class->finalize = composer_finalise;
object_class->destroy = destroy;
-
widget_class->delete_event = delete_event;
- parent_class = gtk_type_class (bonobo_window_get_type ());
+ parent_class = g_type_class_ref(bonobo_window_get_type ());
signals[SEND] =
- gtk_signal_new ("send",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMsgComposerClass, send),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
+ g_signal_new ("send",
+ E_TYPE_MSG_COMPOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMsgComposerClass, send),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals[SAVE_DRAFT] =
- gtk_signal_new ("save-draft",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EMsgComposerClass, save_draft),
- marshal_NONE__NONE_INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+ g_signal_new ("save-draft",
+ E_TYPE_MSG_COMPOSER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMsgComposerClass, save_draft),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1, G_TYPE_BOOLEAN);
}
static void
@@ -2601,21 +2605,20 @@ init (EMsgComposer *composer)
GtkType
e_msg_composer_get_type (void)
{
- static GtkType type = 0;
+ static GType type = 0;
if (type == 0) {
- static const GtkTypeInfo info = {
- "EMsgComposer",
- sizeof (EMsgComposer),
+ static const GTypeInfo info = {
sizeof (EMsgComposerClass),
- (GtkClassInitFunc) class_init,
- (GtkObjectInitFunc) init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, NULL,
+ (GClassInitFunc) class_init,
+ NULL, NULL,
+ sizeof (EMsgComposer),
+ 0,
+ (GInstanceInitFunc) init,
};
-
- type = gtk_type_unique (bonobo_window_get_type (), &info);
+
+ type = g_type_register_static (bonobo_window_get_type (), "EMsgComposer", &info, 0);
}
return type;
@@ -2624,6 +2627,7 @@ e_msg_composer_get_type (void)
static void
load_from_config_db (EMsgComposer *composer)
{
+#if 0
Bonobo_ConfigDatabase db = composer->config_db;
composer->view_from = bonobo_config_get_long_with_default (
@@ -2636,6 +2640,7 @@ load_from_config_db (EMsgComposer *composer)
db, "Mail/Composer/ViewBCC", 0, NULL);
composer->view_subject = bonobo_config_get_long_with_default (
db, "Mail/Composer/ViewSubject", 1, NULL);
+#endif
}
static void
@@ -2698,7 +2703,7 @@ map_default_cb (EMsgComposer *composer, gpointer user_data)
to = e_msg_composer_hdrs_get_to_entry (E_MSG_COMPOSER_HDRS (composer->hdrs));
cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (to));
pb = bonobo_control_frame_get_control_property_bag (cf, NULL);
- text = bonobo_property_bag_client_get_value_string (pb, "text", NULL);
+ text = bonobo_pbclient_get_string (pb, "text", NULL);
bonobo_object_release_unref (pb, NULL);
if (!text || text[0] == '\0') {
@@ -2743,7 +2748,7 @@ composer_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
if (event->keyval == GDK_Escape) {
do_exit (E_MSG_COMPOSER (widget));
- gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key-press-event");
+ g_signal_stop_emission_by_name(widget, "key-press-event");
return TRUE; /* Handled. */
}
@@ -2755,34 +2760,34 @@ create_composer (int visible_mask)
{
EMsgComposer *composer;
GtkWidget *vbox;
- BonoboObject *editor_server;
+ Bonobo_Unknown editor_server;
+ CORBA_Environment ev;
int vis;
g_return_val_if_fail (gtk_main_level () > 0, NULL);
-
- composer = gtk_type_new (E_TYPE_MSG_COMPOSER);
+
+#warning " does win_name need qualifying? "
+ composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
all_composers = g_slist_prepend (all_composers, composer);
- gtk_signal_connect (GTK_OBJECT (composer), "key-press-event",
- GTK_SIGNAL_FUNC (composer_key_pressed),
- NULL);
- gtk_signal_connect (GTK_OBJECT (composer), "destroy",
- GTK_SIGNAL_FUNC (msg_composer_destroy_notify),
- NULL);
+ g_signal_connect (composer, "key-press-event",
+ G_CALLBACK (composer_key_pressed),
+ NULL);
+ g_signal_connect (composer, "destroy",
+ G_CALLBACK (msg_composer_destroy_notify),
+ NULL);
gtk_window_set_default_size (GTK_WINDOW (composer),
DEFAULT_WIDTH, DEFAULT_HEIGHT);
gnome_window_icon_set_from_file (GTK_WINDOW (composer), EVOLUTION_DATADIR
"/images/evolution/compose-message.png");
- bonobo_window_construct (BONOBO_WINDOW (composer), "e-msg-composer",
- _("Compose a message"));
/* DND support */
gtk_drag_dest_set (GTK_WIDGET (composer), GTK_DEST_DEFAULT_ALL,
drop_types, num_drop_types, GDK_ACTION_COPY);
- gtk_signal_connect (GTK_OBJECT (composer), "drag_data_received",
- GTK_SIGNAL_FUNC (drag_data_received), NULL);
+ g_signal_connect (composer, "drag_data_received",
+ G_CALLBACK (drag_data_received), NULL);
e_msg_composer_load_config (composer);
setup_ui (composer);
@@ -2802,12 +2807,12 @@ create_composer (int visible_mask)
}
gtk_box_pack_start (GTK_BOX (vbox), composer->hdrs, FALSE, FALSE, 0);
- gtk_signal_connect (GTK_OBJECT (composer->hdrs), "subject_changed",
- GTK_SIGNAL_FUNC (subject_changed_cb), composer);
- gtk_signal_connect (GTK_OBJECT (composer->hdrs), "hdrs_changed",
- GTK_SIGNAL_FUNC (hdrs_changed_cb), composer);
- gtk_signal_connect (GTK_OBJECT (composer->hdrs), "from_changed",
- GTK_SIGNAL_FUNC (from_changed_cb), composer);
+ g_signal_connect (composer->hdrs, "subject_changed",
+ G_CALLBACK (subject_changed_cb), composer);
+ g_signal_connect (composer->hdrs, "hdrs_changed",
+ G_CALLBACK (hdrs_changed_cb), composer);
+ g_signal_connect (composer->hdrs, "from_changed",
+ G_CALLBACK (from_changed_cb), composer);
gtk_widget_show (composer->hdrs);
prepare_signatures_menu (composer);
@@ -2834,13 +2839,16 @@ create_composer (int visible_mask)
"FormatHTML", composer->send_html,
NULL);
- editor_server = BONOBO_OBJECT (bonobo_widget_get_server (BONOBO_WIDGET (composer->editor)));
-
+ editor_server = bonobo_widget_get_objref (BONOBO_WIDGET (composer->editor));
+
+ /* FIXME: handle exceptions */
+ CORBA_exception_init(&ev);
composer->persist_file_interface
- = bonobo_object_query_interface (editor_server, "IDL:Bonobo/PersistFile:1.0");
+ = Bonobo_Unknown_queryInterface (editor_server, "IDL:Bonobo/PersistFile:1.0", &ev);
composer->persist_stream_interface
- = bonobo_object_query_interface (editor_server, "IDL:Bonobo/PersistStream:1.0");
-
+ = Bonobo_Unknown_queryInterface (editor_server, "IDL:Bonobo/PersistStream:1.0", &ev);
+ CORBA_exception_free (&ev);
+
gtk_box_pack_start (GTK_BOX (vbox), composer->editor, TRUE, TRUE, 0);
/* Attachment editor, wrapped into an EScrollFrame. We don't
@@ -2860,8 +2868,8 @@ create_composer (int visible_mask)
composer->attachment_scroll_frame,
FALSE, FALSE, GNOME_PAD_SMALL);
- gtk_signal_connect (GTK_OBJECT (composer->attachment_bar), "changed",
- GTK_SIGNAL_FUNC (attachment_bar_changed_cb), composer);
+ g_signal_connect (composer->attachment_bar, "changed",
+ G_CALLBACK (attachment_bar_changed_cb), composer);
bonobo_window_set_contents (BONOBO_WINDOW (composer), vbox);
gtk_widget_show (vbox);
@@ -2884,7 +2892,7 @@ create_composer (int visible_mask)
return NULL;
}
- gtk_signal_connect (GTK_OBJECT (composer), "map", map_default_cb, NULL);
+ g_signal_connect (composer, "map", (GCallback)map_default_cb, NULL);
if (am == NULL) {
am = autosave_manager_new ();
@@ -2967,10 +2975,10 @@ is_special_header (const char *hdr_name)
1. it's not a X-* header or
2. it's an X-Evolution* header
*/
- if (g_strncasecmp (hdr_name, "X-", 2))
+ if (g_ascii_strncasecmp (hdr_name, "X-", 2))
return TRUE;
- if (!g_strncasecmp (hdr_name, "X-Evolution", 11))
+ if (!g_ascii_strncasecmp (hdr_name, "X-Evolution", 11))
return TRUE;
/* we can keep all other X-* headers */
@@ -2983,9 +2991,9 @@ e_msg_composer_set_pending_body (EMsgComposer *composer, char *text)
{
char *old;
- old = gtk_object_get_data (GTK_OBJECT (composer), "body:text");
+ old = g_object_get_data (G_OBJECT(composer), "body:text");
g_free (old);
- gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
+ g_object_set_data (G_OBJECT(composer), "body:text", text);
}
static void
@@ -2993,12 +3001,12 @@ e_msg_composer_flush_pending_body (EMsgComposer *composer, gboolean apply)
{
char *body;
- body = gtk_object_get_data (GTK_OBJECT (composer), "body:text");
+ body = g_object_get_data (G_OBJECT(composer), "body:text");
if (body) {
if (apply)
set_editor_text (composer, body);
- gtk_object_set_data (GTK_OBJECT (composer), "body:text", NULL);
+ g_object_set_data (G_OBJECT(composer), "body:text", NULL);
g_free (body);
}
}
@@ -3617,7 +3625,7 @@ e_msg_composer_new_redirect (CamelMimeMessage *message, const char *resent_from)
subject = camel_mime_message_get_subject (message);
composer->redirect = message;
- camel_object_ref (CAMEL_OBJECT (message));
+ camel_object_ref (message);
e_msg_composer_set_headers (composer, resent_from, NULL, NULL, NULL, subject);
@@ -3859,9 +3867,9 @@ e_msg_composer_set_body (EMsgComposer *composer, const char *body,
{
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- set_editor_text (composer, U_("<b>(The composer contains a non-text "
- "message body, which cannot be "
- "edited.)<b>"));
+ set_editor_text (composer, _("<b>(The composer contains a non-text "
+ "message body, which cannot be "
+ "edited.)<b>"));
e_msg_composer_set_send_html (composer, FALSE);
disable_editor (composer);
@@ -3870,7 +3878,7 @@ e_msg_composer_set_body (EMsgComposer *composer, const char *body,
g_free (composer->mime_type);
composer->mime_type = g_strdup (mime_type);
- if (g_strncasecmp (composer->mime_type, "text/calendar", 13) == 0) {
+ if (g_ascii_strncasecmp (composer->mime_type, "text/calendar", 13) == 0) {
EMsgComposerHdrs *hdrs = E_MSG_COMPOSER_HDRS (composer->hdrs);
if (hdrs->account && hdrs->account->pgp_no_imip_sign)
e_msg_composer_set_pgp_sign (composer, FALSE);
@@ -3936,7 +3944,7 @@ CamelMimePart *
e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
const char *file_name)
{
- char *mime_type, *cid, *url;
+ char *mime_type, *cid, *url, *name;
CamelStream *stream;
CamelDataWrapper *wrapper;
CamelMimePart *part;
@@ -3960,11 +3968,13 @@ e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
- camel_object_unref (CAMEL_OBJECT (wrapper));
+ camel_object_unref (wrapper);
cid = header_msgid_generate ();
camel_mime_part_set_content_id (part, cid);
- camel_mime_part_set_filename (part, g_basename (file_name));
+ name = g_path_get_basename(file_name);
+ camel_mime_part_set_filename (part, name);
+ g_free(name);
camel_mime_part_set_encoding (part, CAMEL_MIME_PART_ENCODING_BASE64);
url = g_strdup_printf ("file:%s", file_name);
@@ -3990,18 +4000,18 @@ void
e_msg_composer_add_inline_image_from_mime_part (EMsgComposer *composer,
CamelMimePart *part)
{
- char *cid, *url;
- const char *location;
-
- cid = (char *)camel_mime_part_get_content_id (part);
+ char *url;
+ const char *location, *cid;
+
+ cid = camel_mime_part_get_content_id (part);
if (!cid) {
camel_mime_part_set_content_id (part, NULL);
- cid = (char *)camel_mime_part_get_content_id (part);
+ cid = camel_mime_part_get_content_id (part);
}
url = g_strdup_printf ("cid:%s", cid);
g_hash_table_insert (composer->inline_images, url, part);
- camel_object_ref (CAMEL_OBJECT (part));
+ camel_object_ref (part);
location = camel_mime_part_get_content_location (part);
if (location) {