[evolution-patches] Please review my patch for bug #47544
- From: Antonio Xu <antonio xu sun com>
- To: evolution-patches <evolution-patches lists ximian com>
- Cc: gtkhtml-maintainers ximian com, evolution-mail-maintainers <evolution-mail-maintainers ximian com>
- Subject: [evolution-patches] Please review my patch for bug #47544
- Date: Tue, 19 Aug 2003 19:21:21 +0800
Hello All,
Could you review my patch for bug #47544?
I add a callback function in listener of gtkhtml editor, when we drop a
attachment in composer, gtkhtml will notify composer to attach the file
according to the specific url on evolution side.
Bug Summary:Evolution uses links instead of creating attachments
Bug URL:http://bugzilla.ximian.com/show_bug.cgi?id=47544
Thanks
Antonio Xu
Index: src/gtkhtml.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.h,v
retrieving revision 1.146
diff -p -u -r1.146 gtkhtml.h
--- src/gtkhtml.h 20 May 2003 18:25:14 -0000 1.146
+++ src/gtkhtml.h 19 Aug 2003 09:47:25 -0000
@@ -95,6 +95,7 @@ struct _GtkHTMLClass {
void (* size_changed) (GtkHTML *html);
void (* iframe_created) (GtkHTML *html, GtkHTML *iframe);
+ gboolean (* receive_file_uri)(GtkHTML *html, const gchar *url);
/* keybindings signals */
void (* scroll) (GtkHTML *html, GtkOrientation orientation, GtkScrollType scroll_type,
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.520.2.5
diff -p -u -r1.520.2.5 gtkhtml.c
--- src/gtkhtml.c 15 Aug 2003 07:47:04 -0000 1.520.2.5
+++ src/gtkhtml.c 19 Aug 2003 09:49:05 -0000
@@ -117,6 +117,7 @@ enum {
INSERTION_COLOR_CHANGED,
SIZE_CHANGED,
IFRAME_CREATED,
+ RECEIVE_FILE_URI,
/* keybindings signals */
SCROLL,
CURSOR_MOVE,
@@ -2217,7 +2218,11 @@ new_obj_from_uri (HTMLEngine *e, gchar *
NULL, NULL, -1, -1, FALSE, FALSE, 0,
html_colorset_get_color (e->settings->color_set, HTMLTextColor),
HTML_VALIGN_BOTTOM, TRUE);
- }
+ }
+ gboolean attach_sucess;
+ g_signal_emit (e->widget, signals[RECEIVE_FILE_URI], 0, uri, &attach_sucess);
+ if (attach_sucess)
+ return NULL;
}
for (i = 0; known_protocols [i]; i++) {
@@ -2491,6 +2496,7 @@ gtk_html_class_init (GtkHTMLClass *klass
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
signals [IFRAME_CREATED] =
g_signal_new ("iframe_created",
G_TYPE_FROM_CLASS (object_class),
@@ -2500,6 +2506,16 @@ gtk_html_class_init (GtkHTMLClass *klass
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_HTML);
+
+ signals [RECEIVE_FILE_URI] =
+ g_signal_new ("receive_file_uri",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkHTMLClass, receive_file_uri),
+ NULL, NULL,
+ html_g_cclosure_marshal_BOOL__STRING,
+ G_TYPE_BOOLEAN, 1,
+ G_TYPE_STRING);
signals [SCROLL] =
g_signal_new ("scroll",
Index: src/htmlclosures.list
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclosures.list,v
retrieving revision 1.2
diff -p -u -r1.2 htmlclosures.list
--- src/htmlclosures.list 19 Nov 2002 04:43:57 -0000 1.2
+++ src/htmlclosures.list 19 Aug 2003 09:51:34 -0000
@@ -1,4 +1,5 @@
BOOL:OBJECT
+BOOL:STRING
VOID:STRING,POINTER
VOID:POINTER,INT
VOID:STRING,STRING,STRING
Index: components/html-editor/editor-control-factory.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/editor-control-factory.c,v
retrieving revision 1.132.2.1
diff -p -u -r1.132.2.1 editor-control-factory.c
--- components/html-editor/editor-control-factory.c 1 Jul 2003 10:34:34 -0000 1.132.2.1
+++ components/html-editor/editor-control-factory.c 19 Aug 2003 09:57:40 -0000
@@ -315,6 +315,40 @@ html_show_popup(GtkWidget *html, GtkHTML
return TRUE;
}
+static gboolean
+add_attachment_by_url (GtkWidget *html, const gchar *url, gpointer data)
+{
+ GValue *arg, *retval = NULL;
+ GtkHTMLControlData *cd;
+ GNOME_GtkHTML_Editor_Engine engine;
+ GNOME_GtkHTML_Editor_Listener listener;
+ CORBA_Environment ev;
+ gboolean result = FALSE;
+
+ g_return_val_if_fail(data != NULL, FALSE);
+ g_return_val_if_fail(url != NULL, FALSE);
+
+ cd = (GtkHTMLControlData *) data;
+ arg = g_new0 (GValue, 1);
+ g_value_init (arg, G_TYPE_STRING);
+ g_value_set_string (arg, url);
+ CORBA_exception_init (&ev);
+ engine = bonobo_object_corba_objref (BONOBO_OBJECT (cd->editor_bonobo_engine));
+
+ if (engine != CORBA_OBJECT_NIL
+ && (listener = GNOME_GtkHTML_Editor_Engine__get_listener (engine, &ev)) != CORBA_OBJECT_NIL) {
+ retval = send_event_str (engine, listener, "add_attachment", arg);
+ }
+
+ result = g_value_get_boolean (retval);
+ CORBA_exception_free (&ev);
+ g_value_unset (arg);
+ g_free (arg);
+ g_value_unset (retval);
+ g_free (retval);
+ return result;
+}
+
static gint
html_button_pressed (GtkWidget *html, GdkEventButton *event, GtkHTMLControlData *cd)
{
@@ -638,6 +672,7 @@ editor_control_construct (BonoboControl
g_signal_connect (html_widget, "button_press_event", G_CALLBACK (html_button_pressed), cd);
g_signal_connect_after (html_widget, "button_press_event", G_CALLBACK (html_button_pressed_after), cd);
g_signal_connect (html_widget, "popup_menu", G_CALLBACK(html_show_popup), cd);
+ g_signal_connect (html_widget, "receive_file_uri", G_CALLBACK(add_attachment_by_url), cd);
cd->control = control;
}
Index: composer/listener.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/listener.c,v
retrieving revision 1.31
diff -p -u -r1.31 listener.c
--- composer/listener.c 19 Jun 2003 16:59:02 -0000 1.31
+++ composer/listener.c 19 Aug 2003 10:02:20 -0000
@@ -29,6 +29,8 @@
#include <bonobo/bonobo-stream-client.h>
#include "listener.h"
+#include "e-msg-composer-attachment-bar.h"
+#include "camel/camel.h"
static BonoboObjectClass *listener_parent_class;
static POA_GNOME_GtkHTML_Editor_Listener__vepv listener_vepv;
@@ -240,6 +242,31 @@ impl_event (PortableServer_Servant _serv
bonobo_stream_client_write (e->stream, ba->data, ba->len, ev);
camel_object_unref (cstream);
+ } else if (!strcmp (name, "add_attachment")) {
+ gchar **urls, *str, *tmp = NULL;
+ int i;
+ CamelURL *url;
+ gboolean result = TRUE;
+ tmp = BONOBO_ARG_GET_STRING (arg);
+ if (tmp != NULL) {
+ urls = g_strsplit (tmp, "\n", 0);
+ for (i = 0; urls[i] != NULL; i++) {
+ str = g_strstrip (urls[i]);
+ url = camel_url_new (str, NULL);
+ g_free (str);
+ if (url == NULL)
+ continue;
+ e_msg_composer_attachment_bar_attach
+ (E_MSG_COMPOSER_ATTACHMENT_BAR (l->composer->attachment_bar),
+ url->path);
+ camel_url_free (url);
+ }
+ } else
+ result = FALSE;
+
+ g_free (urls);
+ rv = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+ BONOBO_ARG_SET_BOOLEAN (rv, result);
}
return rv ? rv : get_any_null ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]