aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer-attachment.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-attachment.c
parentab44fe3e1d962e7876693929c940121e2954379d (diff)
downloadgsoc2013-evolution-234540a383de150f0a79df466aa76dae4096d09c.tar.gz
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-attachment.c')
-rw-r--r--composer/e-msg-composer-attachment.c136
1 files changed, 67 insertions, 69 deletions
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index 5903fc3928..0f7c06ff26 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -35,7 +35,7 @@
#include <gtk/gtktogglebutton.h>
#include <camel/camel.h>
#include <gal/widgets/e-unicode.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include "e-msg-composer.h"
#include "e-msg-composer-attachment.h"
@@ -53,22 +53,24 @@ static GtkObjectClass *parent_class = NULL;
static void
changed (EMsgComposerAttachment *attachment)
{
- gtk_signal_emit (GTK_OBJECT (attachment), signals[CHANGED]);
+ g_signal_emit(attachment, signals[CHANGED], 0);
}
/* GtkObject methods. */
static void
-destroy (GtkObject *object)
+finalise(GObject *object)
{
EMsgComposerAttachment *attachment;
attachment = E_MSG_COMPOSER_ATTACHMENT (object);
- camel_object_unref (CAMEL_OBJECT (attachment->body));
+ camel_object_unref(attachment->body);
if (attachment->pixbuf_cache != NULL)
- gdk_pixbuf_unref (attachment->pixbuf_cache);
+ g_object_unref(attachment->pixbuf_cache);
+
+ G_OBJECT_CLASS(parent_class)->finalize(object);
}
@@ -85,27 +87,22 @@ real_changed (EMsgComposerAttachment *msg_composer_attachment)
static void
class_init (EMsgComposerAttachmentClass *klass)
{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass*) klass;
-
- parent_class = gtk_type_class (gtk_object_get_type ());
-
- object_class->destroy = destroy;
-
- signals[CHANGED] = gtk_signal_new ("changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET
- (EMsgComposerAttachmentClass,
- changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
+ GObjectClass *object_class;
+ object_class = (GObjectClass*) klass;
+ parent_class = g_type_class_ref(G_TYPE_OBJECT);
- gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
-
+ object_class->finalize = finalise;
klass->changed = real_changed;
+
+ signals[CHANGED] = g_signal_new ("changed",
+ E_TYPE_MSG_COMPOSER_ATTACHMENT,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(EMsgComposerAttachmentClass, changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -117,24 +114,25 @@ init (EMsgComposerAttachment *msg_composer_attachment)
msg_composer_attachment->pixbuf_cache = NULL;
}
-GtkType
+GType
e_msg_composer_attachment_get_type (void)
{
- static GtkType type = 0;
+ static GType type = 0;
if (type == 0) {
- static const GtkTypeInfo info = {
- "EMsgComposerAttachment",
- sizeof (EMsgComposerAttachment),
+ static const GTypeInfo info = {
sizeof (EMsgComposerAttachmentClass),
- (GtkClassInitFunc) class_init,
- (GtkObjectInitFunc) init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL,
+ NULL,
+ (GClassInitFunc) class_init,
+ NULL,
+ NULL,
+ sizeof (EMsgComposerAttachment),
+ 0,
+ (GInstanceInitFunc) init,
};
- type = gtk_type_unique (gtk_object_get_type (), &info);
+ type = g_type_register_static(G_TYPE_OBJECT, "EMsgComposerAttachment", &info, 0);
}
return type;
@@ -161,7 +159,7 @@ e_msg_composer_attachment_new (const char *file_name,
struct stat statbuf;
char *mime_type;
char *filename;
-
+
g_return_val_if_fail (file_name != NULL, NULL);
if (stat (file_name, &statbuf) < 0) {
@@ -205,14 +203,14 @@ e_msg_composer_attachment_new (const char *file_name,
} else
camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream");
- camel_object_unref (CAMEL_OBJECT (stream));
+ camel_object_unref (stream);
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
- camel_object_unref (CAMEL_OBJECT (wrapper));
+ camel_object_unref (wrapper);
camel_mime_part_set_disposition (part, disposition);
- filename = e_utf8_from_locale_string (g_basename (file_name));
+ filename = g_path_get_basename(file_name);
camel_mime_part_set_filename (part, filename);
g_free (filename);
@@ -227,7 +225,7 @@ e_msg_composer_attachment_new (const char *file_name,
g_free (content_id);
#endif
- new = gtk_type_new (e_msg_composer_attachment_get_type ());
+ new = g_object_new(E_TYPE_MSG_COMPOSER_ATTACHMENT, NULL);
new->editor_gui = NULL;
new->body = part;
new->size = statbuf.st_size;
@@ -269,7 +267,7 @@ e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part)
camel_object_unref (stream);
- new = gtk_type_new (e_msg_composer_attachment_get_type ());
+ new = g_object_new(E_TYPE_MSG_COMPOSER_ATTACHMENT, NULL);
new->editor_gui = NULL;
new->body = mime_part;
new->guessed_type = FALSE;
@@ -306,18 +304,20 @@ destroy_dialog_data (DialogData *data)
static void
update_mime_type (DialogData *data)
{
- const gchar *mime_type;
- gchar *file_name;
+ gchar *mime_type;
+ const gchar *file_name;
if (!data->attachment->guessed_type)
return;
- file_name = e_utf8_gtk_entry_get_text (data->file_name_entry);
- mime_type = gnome_vfs_mime_type_from_name_or_default (file_name, NULL);
- g_free (file_name);
+ file_name = gtk_entry_get_text(data->file_name_entry);
+#warning "do we need to create file uri for gnome-vfs-get-mime-type"
+ mime_type = gnome_vfs_get_mime_type (file_name);
- if (mime_type)
- e_utf8_gtk_entry_set_text (data->mime_type_entry, mime_type);
+ if (mime_type) {
+ gtk_entry_set_text (data->mime_type_entry, mime_type);
+ g_free(mime_type);
+ }
}
static void
@@ -331,20 +331,20 @@ set_entry (GladeXML *xml,
if (entry == NULL)
g_warning ("Entry for `%s' not found.", widget_name);
else
- e_utf8_gtk_entry_set_text (entry, value ? value : "");
+ gtk_entry_set_text (entry, value ? value : "");
}
static void
connect_widget (GladeXML *gui,
const gchar *name,
const gchar *signal_name,
- GtkSignalFunc func,
+ GCallback func,
gpointer data)
{
GtkWidget *widget;
widget = glade_xml_get_widget (gui, name);
- gtk_signal_connect (GTK_OBJECT (widget), signal_name, func, data);
+ g_signal_connect(widget, signal_name, func, data);
}
static void
@@ -355,9 +355,10 @@ close_cb (GtkWidget *widget, gpointer data)
dialog_data = (DialogData *) data;
attachment = dialog_data->attachment;
-
+
+ /* need to unref dialog? */
gtk_widget_destroy (dialog_data->dialog);
- gtk_object_unref (GTK_OBJECT (attachment->editor_gui));
+ g_object_unref(attachment->editor_gui);
attachment->editor_gui = NULL;
destroy_dialog_data (dialog_data);
@@ -368,25 +369,21 @@ ok_cb (GtkWidget *widget, gpointer data)
{
DialogData *dialog_data;
EMsgComposerAttachment *attachment;
- char *str;
+ const gchar *str;
dialog_data = (DialogData *) data;
attachment = dialog_data->attachment;
- str = e_utf8_gtk_entry_get_text (dialog_data->file_name_entry);
+ str = gtk_entry_get_text (dialog_data->file_name_entry);
camel_mime_part_set_filename (attachment->body, str);
- g_free (str);
- str = e_utf8_gtk_entry_get_text (dialog_data->description_entry);
+ str = gtk_entry_get_text (dialog_data->description_entry);
camel_mime_part_set_description (attachment->body, str);
- g_free (str);
- str = e_utf8_gtk_entry_get_text (dialog_data->mime_type_entry);
+ str = gtk_entry_get_text (dialog_data->mime_type_entry);
camel_mime_part_set_content_type (attachment->body, str);
- camel_data_wrapper_set_mime_type (
- camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)), str);
- g_free (str);
+ camel_data_wrapper_set_mime_type(camel_medium_get_content_object(CAMEL_MEDIUM (attachment->body)), str);
switch (gtk_toggle_button_get_active (dialog_data->disposition_checkbox)) {
case 0:
@@ -436,7 +433,7 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment,
}
editor_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer-attachment.glade",
- NULL);
+ NULL, NULL);
if (editor_gui == NULL) {
g_warning ("Cannot load `e-msg-composer-attachment.glade'");
return;
@@ -476,19 +473,20 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment,
disposition = camel_mime_part_get_disposition (attachment->body);
gtk_toggle_button_set_active (dialog_data->disposition_checkbox,
- disposition && !g_strcasecmp (disposition, "inline"));
+ disposition && !g_ascii_strcasecmp (disposition, "inline"));
}
- connect_widget (editor_gui, "ok_button", "clicked", ok_cb, dialog_data);
- connect_widget (editor_gui, "close_button", "clicked", close_cb, dialog_data);
+ connect_widget (editor_gui, "ok_button", "clicked", (GCallback)ok_cb, dialog_data);
+ connect_widget (editor_gui, "close_button", "clicked", (GCallback)close_cb, dialog_data);
connect_widget (editor_gui, "file_name_entry", "focus_out_event",
- file_name_focus_out_cb, dialog_data);
-
+ (GCallback)file_name_focus_out_cb, dialog_data);
+
+#warning "signal connect while alive"
/* make sure that when the composer gets hidden/closed that our windows also close */
parent = gtk_widget_get_toplevel (parent);
- gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy", close_cb, dialog_data,
+ gtk_signal_connect_while_alive (GTK_OBJECT (parent), "destroy", (GCallback)close_cb, dialog_data,
GTK_OBJECT (dialog_data->dialog));
- gtk_signal_connect_while_alive (GTK_OBJECT (parent), "hide", close_cb, dialog_data,
+ gtk_signal_connect_while_alive (GTK_OBJECT (parent), "hide", (GCallback)close_cb, dialog_data,
GTK_OBJECT (dialog_data->dialog));
}