Re: [evolution-patches] Patch to fix DnD to composer



Notzed,

I have attached the revised patch. It show the attachment bar when the attachments are added and removes when all the attachments are removed.

-Srini.

>>> Not Zed <notzed ximian com> 06/02/05 9:55 AM >>>

> Sorry I didnt know. I didnt know how to pass a pointer. Initially i
> passed it as a string. I thought it as evil and passed as 'any '.
> Since the name suggested generic :-). So ill revert back to 'String'. 

If you want to do any CORBA stuff you should read some background
information on it.  Michaels suggested approach looks good, and it will
fail-over properly if the stuff isn't in-proc.  Better than a pointer
address which might just crash.

> Michael, i have made gtkhtml-editor as a widget and have it working as
> well. But im not pretty confident on that. It works perfectly, except
> some bonobo leaks. Still quite a few work pending. I would love to
> make this better and use it in future. I have all the PersistStream,
> File, EditorEngine converted a library.

I don't understand why you would need persist-stream etc.  You can
probably just set the content directly, or have simple iterators to fill
it up/extract it.


_______________________________________________
evolution-patches mailing list
evolution-patches lists ximian com
http://lists.ximian.com/mailman/listinfo/evolution-patches

Index: Editor.idl
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/Editor.idl,v
retrieving revision 1.7
diff -u -p -r1.7 Editor.idl
--- Editor.idl	13 Feb 2002 15:52:09 -0000	1.7
+++ Editor.idl	2 Jun 2005 08:54:58 -0000
@@ -90,6 +90,11 @@ module Editor {
 		 * is there any undo event in undo queue?
 		 */
 		boolean hasUndo ();
+
+		/*
+		 * Gets the html widget
+		 */
+		 void getWidget ();		
 	};
 	
 	struct URLRequestEvent {
Index: engine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/engine.c,v
retrieving revision 1.26
diff -u -p -r1.26 engine.c
--- engine.c	17 May 2005 14:48:59 -0000	1.26
+++ engine.c	2 Jun 2005 08:54:58 -0000
@@ -227,6 +227,15 @@ impl_drop_undo (PortableServer_Servant s
 }
 
 static void
+impl_get_widget (PortableServer_Servant servant, CORBA_Environment * ev)
+{
+	EditorEngine *e = html_editor_engine_from_servant (servant);
+
+	g_object_set_data (e, "html-widget", e->cd->html);
+	return;
+}
+
+static void
 engine_object_finalize (GObject *object)
 {
 	EditorEngine *e = EDITOR_ENGINE (object);
@@ -270,6 +279,7 @@ editor_engine_class_init (EditorEngineCl
 	epv->ignoreWord               = impl_ignore_word;
 	epv->hasUndo                  = impl_has_undo;
 	epv->dropUndo                 = impl_drop_undo;
+	epv->getWidget		      = impl_get_widget;
 }
 
 BONOBO_TYPE_FUNC_FULL (
Index: e-msg-composer-select-file.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-select-file.c,v
retrieving revision 1.34
diff -u -p -r1.34 e-msg-composer-select-file.c
--- e-msg-composer-select-file.c	9 May 2005 15:09:39 -0000	1.34
+++ e-msg-composer-select-file.c	2 Jun 2005 08:50:09 -0000
@@ -45,6 +45,7 @@
 
 #include "e-msg-composer-select-file.h"
 #include <e-util/e-icon-factory.h>
+#include "e-msg-composer.h"
 
 enum {
 	SELECTOR_MODE_MULTI    = (1 << 0),
@@ -213,6 +214,9 @@ select_attach_response(GtkWidget *select
 		g_object_set_data_full ((GObject *) composer, "attach_path", path, g_free);
 
 		func(composer, names, gtk_toggle_button_get_active(showinline));
+		
+		gtk_widget_show (composer->attachment_expander);
+		gtk_widget_show (composer->attachment_scrolled_window);
 
 		g_slist_foreach(names, (GFunc)g_free, NULL);
 		g_slist_free(names);
Index: e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.508
diff -u -p -r1.508 e-msg-composer.c
--- e-msg-composer.c	23 May 2005 07:10:03 -0000	1.508
+++ e-msg-composer.c	2 Jun 2005 08:50:11 -0000
@@ -2315,7 +2315,8 @@ attachment_bar_changed_cb (EMsgComposerA
 		
 	} else {
 		gtk_label_set_text (GTK_LABEL (composer->attachment_expander_num), "");
-		gtk_widget_hide (composer->attachment_expander_icon);
+		gtk_widget_hide (composer->attachment_expander);
+		gtk_widget_hide (composer->attachment_scrolled_window);
 	}
 	
 	
@@ -2865,6 +2866,8 @@ drop_action(EMsgComposer *composer, GdkD
 		d(printf ("dropping an unknown\n"));
 		break;
 	}
+	gtk_widget_show (composer->attachment_expander);
+	gtk_widget_show (composer->attachment_scrolled_window);
 
 	printf("Drag finished, success %d delete %d\n", success, delete);
 
@@ -2914,9 +2917,10 @@ drop_popup_free(EPopup *ep, GSList *item
 }
 
 static void
-drag_data_received (EMsgComposer *composer, GdkDragContext *context,
+drag_data_received (GtkWidget *w, GdkDragContext *context,
 		    int x, int y, GtkSelectionData *selection,
-		    guint info, guint time)
+		    guint info, guint time,
+		    EMsgComposer *composer)
 {
 	if (selection->data == NULL || selection->length == -1)
 		return;
@@ -3362,6 +3366,9 @@ create_composer (int visible_mask)
 	int vis;
 	GList *icon_list;
 	BonoboControlFrame *control_frame;
+	GtkWidget *html_widget = NULL;
+	gpointer servant;;
+	BonoboObject *impl;	
 	
 	composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
 	gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
@@ -3385,7 +3392,7 @@ create_composer (int visible_mask)
 
 	/* DND support */
 	gtk_drag_dest_set (GTK_WIDGET (composer), GTK_DEST_DEFAULT_ALL,  drop_types, num_drop_types, GDK_ACTION_COPY|GDK_ACTION_ASK|GDK_ACTION_MOVE);
-	g_signal_connect(composer, "drag_data_received", G_CALLBACK (drag_data_received), NULL);
+	g_signal_connect(composer, "drag_data_received", G_CALLBACK (drag_data_received), composer);
 	g_signal_connect(composer, "drag-motion", G_CALLBACK(drag_motion), composer);
 	e_msg_composer_load_config (composer, visible_mask);
 	
@@ -3474,7 +3481,7 @@ create_composer (int visible_mask)
 			  G_CALLBACK (attachment_bar_changed_cb), composer);
 
 	composer->attachment_expander_label =
-		gtk_label_new_with_mnemonic (_("_Attachment Bar (drop attachments here)"));
+		gtk_label_new_with_mnemonic (_("_Attachment Bar"));
 	composer->attachment_expander_num = gtk_label_new ("");
 	gtk_label_set_use_markup (GTK_LABEL (composer->attachment_expander_num), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (composer->attachment_expander_label), 0.0, 0.5);
@@ -3498,9 +3505,10 @@ create_composer (int visible_mask)
 	gtk_box_pack_start (GTK_BOX (vbox), expander_hbox, FALSE, FALSE, 0);
 	gtk_box_pack_start (GTK_BOX (vbox), composer->attachment_scrolled_window,
 			    FALSE, FALSE, GNOME_PAD_SMALL);
-
-	gtk_widget_show (composer->attachment_scrolled_window);
-	gtk_widget_show (expander_hbox);
+	
+	composer->attachment_expander = expander_hbox;
+	gtk_widget_hide (composer->attachment_scrolled_window);
+	gtk_widget_hide (expander_hbox);
 	
 	bonobo_window_set_contents (BONOBO_WINDOW (composer), vbox);
 	gtk_widget_show (vbox);
@@ -3515,6 +3523,18 @@ create_composer (int visible_mask)
 		e_error_run (GTK_WINDOW (composer), "mail-composer:no-editor-control", NULL);
 		gtk_object_destroy (GTK_OBJECT (composer));
 		return NULL;
+	}
+
+	CORBA_exception_init (&ev);
+	GNOME_GtkHTML_Editor_Engine_getWidget(composer->editor_engine, &ev);
+	servant = ORBit_small_get_servant (composer->editor_engine);
+    	if (servant && (impl = bonobo_object (servant)))
+		html_widget = g_object_get_data (G_OBJECT(impl), "html-widget");
+	
+	CORBA_exception_free (&ev); 
+
+	if (html_widget) {
+		g_signal_connect (html_widget, "drag_data_received", G_CALLBACK (drag_data_received), composer);
 	}
 	
 	setup_cut_copy_paste (composer);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]