[evolution/webkit: 54/57] EAttachmentView is not longer owned by EMFormatHTMLDisplay



commit ae2dc384dfd3b0acb89467d9501042dbd49b790f
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Oct 6 12:35:29 2011 +0200

    EAttachmentView is not longer owned by EMFormatHTMLDisplay
    
    EAttachmentStore is stored within a PURI object and when widget_func
    for the PURI is called a new EMailAttachmentBar is created and the
    store is assigned.
    
    When creating an attachment PURI the PURI table is seached for closest
    parent attachment-bar PURI and is assigned to it.

 mail/e-mail-attachment-bar.c       |   93 ++++++++++++++++++++++++-----------
 mail/e-mail-attachment-bar.h       |    4 +-
 mail/e-mail-display.c              |   71 ++++++++++++++++------------
 mail/em-format-html-display.c      |   87 ++++++++++++++++++++++++---------
 mail/em-format-html-display.h      |   10 +++-
 widgets/misc/e-attachment-button.c |   58 +++++++++++-----------
 widgets/misc/e-attachment-button.h |    4 +-
 widgets/misc/e-attachment-store.h  |    1 +
 8 files changed, 211 insertions(+), 117 deletions(-)
---
diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c
index 17a7ae1..71a2e10 100644
--- a/mail/e-mail-attachment-bar.c
+++ b/mail/e-mail-attachment-bar.c
@@ -58,7 +58,8 @@ enum {
 	PROP_ACTIVE_VIEW,
 	PROP_DRAGGING,
 	PROP_EDITABLE,
-	PROP_EXPANDED
+	PROP_EXPANDED,
+	PROP_STORE
 };
 
 static gpointer parent_class;
@@ -66,7 +67,6 @@ static gpointer parent_class;
 static void
 mail_attachment_bar_update_status (EMailAttachmentBar *bar)
 {
-	EAttachmentView *view;
 	EAttachmentStore *store;
 	GtkActivatable *activatable;
 	GtkAction *action;
@@ -76,8 +76,7 @@ mail_attachment_bar_update_status (EMailAttachmentBar *bar)
 	gchar *display_size;
 	gchar *markup;
 
-	view = E_ATTACHMENT_VIEW (bar);
-	store = e_attachment_view_get_store (view);
+	store = E_ATTACHMENT_STORE (bar->priv->model);
 	label = GTK_LABEL (bar->priv->status_label);
 
 	num_attachments = e_attachment_store_get_num_attachments (store);
@@ -108,6 +107,31 @@ mail_attachment_bar_update_status (EMailAttachmentBar *bar)
 }
 
 static void
+mail_attachment_bar_set_store (EMailAttachmentBar *bar,
+			       EAttachmentStore *store)
+{
+	g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
+
+	bar->priv->model = g_object_ref (store);
+
+	gtk_icon_view_set_model (GTK_ICON_VIEW (bar->priv->icon_view),
+		bar->priv->model);
+	gtk_tree_view_set_model (GTK_TREE_VIEW (bar->priv->tree_view),
+		bar->priv->model);
+
+	g_signal_connect_swapped (
+		bar->priv->model, "notify::num-attachments",
+		G_CALLBACK (mail_attachment_bar_update_status), bar);
+
+	g_signal_connect_swapped (
+		bar->priv->model, "notify::total-size",
+		G_CALLBACK (mail_attachment_bar_update_status), bar);
+
+	/* Initialize */
+	mail_attachment_bar_update_status (bar);
+}
+
+static void
 mail_attachment_bar_set_property (GObject *object,
                                   guint property_id,
                                   const GValue *value,
@@ -115,7 +139,7 @@ mail_attachment_bar_set_property (GObject *object,
 {
 	switch (property_id) {
 		case PROP_ACTIVE_VIEW:
-			e_mail_attachment_bar_set_active_view (
+				e_mail_attachment_bar_set_active_view (
 				E_MAIL_ATTACHMENT_BAR (object),
 				g_value_get_int (value));
 			return;
@@ -137,6 +161,11 @@ mail_attachment_bar_set_property (GObject *object,
 				E_MAIL_ATTACHMENT_BAR (object),
 				g_value_get_boolean (value));
 			return;
+		case PROP_STORE:
+			mail_attachment_bar_set_store (
+				E_MAIL_ATTACHMENT_BAR (object),
+				g_value_get_object (value));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -176,6 +205,11 @@ mail_attachment_bar_get_property (GObject *object,
 				e_mail_attachment_bar_get_expanded (
 				E_MAIL_ATTACHMENT_BAR (object)));
 			return;
+		case PROP_STORE:
+			g_value_set_object (
+				value,
+				e_mail_attachment_bar_get_store (
+				E_MAIL_ATTACHMENT_BAR (object)));
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -189,7 +223,6 @@ mail_attachment_bar_dispose (GObject *object)
 	priv = E_MAIL_ATTACHMENT_BAR (object)->priv;
 
 	if (priv->model != NULL) {
-		e_attachment_store_remove_all (E_ATTACHMENT_STORE (priv->model));
 		g_object_unref (priv->model);
 		priv->model = NULL;
 	}
@@ -334,17 +367,6 @@ mail_attachment_bar_get_private (EAttachmentView *view)
 	return e_attachment_view_get_private (view);
 }
 
-static EAttachmentStore *
-mail_attachment_bar_get_store (EAttachmentView *view)
-{
-	EMailAttachmentBarPrivate *priv;
-
-	priv = E_MAIL_ATTACHMENT_BAR (view)->priv;
-	view = E_ATTACHMENT_VIEW (priv->icon_view);
-
-	return e_attachment_view_get_store (view);
-}
-
 static GtkTreePath *
 mail_attachment_bar_get_path_at_pos (EAttachmentView *view,
                                      gint x,
@@ -476,6 +498,17 @@ mail_attachment_bar_class_init (EMailAttachmentBarClass *class)
 			G_PARAM_READWRITE |
 			G_PARAM_CONSTRUCT));
 
+	g_object_class_install_property (
+		object_class,
+		PROP_STORE,
+		g_param_spec_object (
+			"store",
+			"Attachment Store",
+			NULL,
+			E_TYPE_ATTACHMENT_STORE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY));
+
 	g_object_class_override_property (
 		object_class, PROP_DRAGGING, "dragging");
 
@@ -487,7 +520,7 @@ static void
 mail_attachment_bar_interface_init (EAttachmentViewInterface *interface)
 {
 	interface->get_private = mail_attachment_bar_get_private;
-	interface->get_store = mail_attachment_bar_get_store;
+	interface->get_store = e_mail_attachment_bar_get_store;
 	interface->get_path_at_pos = mail_attachment_bar_get_path_at_pos;
 	interface->get_selected_paths = mail_attachment_bar_get_selected_paths;
 	interface->path_is_selected = mail_attachment_bar_path_is_selected;
@@ -509,7 +542,6 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
 
 	bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (
 		bar, E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarPrivate);
-	bar->priv->model = e_attachment_store_new ();
 
 	gtk_box_set_spacing (GTK_BOX (bar), 6);
 
@@ -633,14 +665,6 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
 	bar->priv->status_label = g_object_ref (widget);
 	gtk_widget_show (widget);
 
-	g_signal_connect_swapped (
-		bar->priv->model, "notify::num-attachments",
-		G_CALLBACK (mail_attachment_bar_update_status), bar);
-
-	g_signal_connect_swapped (
-		bar->priv->model, "notify::total-size",
-		G_CALLBACK (mail_attachment_bar_update_status), bar);
-
 	g_object_unref (size_group);
 }
 
@@ -680,11 +704,14 @@ e_mail_attachment_bar_get_type (void)
 }
 
 GtkWidget *
-e_mail_attachment_bar_new (void)
+e_mail_attachment_bar_new (EAttachmentStore *store)
 {
+	g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL);
+
 	return g_object_new (
 		E_TYPE_MAIL_ATTACHMENT_BAR,
-		"editable", FALSE, NULL);
+		"editable", FALSE,
+		"store", store, NULL);
 }
 
 gint
@@ -753,3 +780,11 @@ e_mail_attachment_bar_set_expanded (EMailAttachmentBar *bar,
 
 	g_object_notify (G_OBJECT (bar), "expanded");
 }
+
+EAttachmentStore*
+e_mail_attachment_bar_get_store (EMailAttachmentBar *bar)
+{
+	g_return_val_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar), NULL);
+
+	return E_ATTACHMENT_STORE (bar->priv->model);
+}
diff --git a/mail/e-mail-attachment-bar.h b/mail/e-mail-attachment-bar.h
index 93c1b89..161c0d7 100644
--- a/mail/e-mail-attachment-bar.h
+++ b/mail/e-mail-attachment-bar.h
@@ -60,7 +60,7 @@ struct _EMailAttachmentBarClass {
 };
 
 GType		e_mail_attachment_bar_get_type	(void);
-GtkWidget *	e_mail_attachment_bar_new	(void);
+GtkWidget *	e_mail_attachment_bar_new	(EAttachmentStore *store);
 gint		e_mail_attachment_bar_get_active_view
 						(EMailAttachmentBar *bar);
 void		e_mail_attachment_bar_set_active_view
@@ -71,6 +71,8 @@ gboolean	e_mail_attachment_bar_get_expanded
 void		e_mail_attachment_bar_set_expanded
 						(EMailAttachmentBar *bar,
 						 gboolean expanded);
+EAttachmentStore*
+		e_mail_attachment_bar_get_store	(EMailAttachmentBar *bar);
 
 G_END_DECLS
 
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index c8c1374..80f4cae 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -42,7 +42,7 @@
 #include <libsoup/soup-requester.h>
 
 struct _EMailDisplayPrivate {
-	GtkWidget *vbox;
+	GtkWidget *grid;
 
 	ESearchBar *searchbar;
 	EMFormatHTML *formatter;
@@ -473,26 +473,28 @@ mail_display_setup_webview (EMailDisplay *display)
 
 static void
 mail_display_insert_web_view (EMailDisplay *display,
-			      EWebView *web_view,
-			      gboolean expandable)
+			      EWebView *web_view)
 {
 	GtkWidget *scrolled_window;
 
 	display->priv->webviews = g_list_append (display->priv->webviews, web_view);
-
 	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
 	g_object_set (G_OBJECT (scrolled_window),
 		"hscrollbar-policy", GTK_POLICY_NEVER,
 		"vscrollbar-policy", GTK_POLICY_NEVER,
-		"shadow-type", GTK_SHADOW_NONE, NULL);
+		"shadow-type", GTK_SHADOW_NONE,
+		"expand", TRUE,
+		NULL);
 		//"min-content-height", 300, NULL);
 	gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));
 
-	gtk_box_pack_start (GTK_BOX (display->priv->vbox), scrolled_window, expandable, TRUE, 0);
+	gtk_container_add (GTK_CONTAINER (display->priv->grid), scrolled_window);
 	gtk_widget_show_all (scrolled_window);
 
 #if 0
-	gtk_box_pack_start (GTK_BOX (display->priv->vbox), GTK_WIDGET (web_view), expandable, TRUE, 0);
+	g_object_set (G_OBJECT (web_view),
+		"expand", TRUE, NULL);
+	gtk_container_add (GTK_CONTAINER (display->priv->grid), GTK_WIDGET (web_view));
 	gtk_widget_show_all (GTK_WIDGET (web_view));
 #endif
 }
@@ -510,7 +512,7 @@ mail_display_load_as_source (EMailDisplay *display,
 	e_mail_display_clear (display);
 
 	web_view = mail_display_setup_webview (display);
-	mail_display_insert_web_view (display, web_view, TRUE);
+	mail_display_insert_web_view (display, web_view);
 
 	uri = em_format_build_mail_uri (emf->folder, emf->message_uid,
 		"part_id", G_TYPE_STRING, ".message",
@@ -518,7 +520,7 @@ mail_display_load_as_source (EMailDisplay *display,
 		NULL);
 	e_web_view_load_uri (web_view, uri);
 
-	gtk_widget_show_all (display->priv->vbox);
+	gtk_widget_show_all (display->priv->grid);
 }
 
 static void
@@ -528,9 +530,11 @@ mail_display_load_normal (EMailDisplay *display,
 	EWebView *web_view;
 	EMFormatPURI *puri;
 	EMFormat *emf = (EMFormat *) display->priv->formatter;
+	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf;
+	EAttachmentView *attachment_view;
 	gchar *uri;
 	GList *iter;
-	GtkBox *box;
+	GtkContainer *grid;
 
 	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
 
@@ -544,9 +548,11 @@ mail_display_load_normal (EMailDisplay *display,
 	/* First remove all widgets left after previous message */
 	e_mail_display_clear (display);
 
-	box = GTK_BOX (display->priv->vbox);
-	gtk_widget_show (display->priv->vbox);
 
+	grid = GTK_CONTAINER (display->priv->grid);
+	gtk_widget_show (display->priv->grid);
+
+	attachment_view = NULL;
 	for (iter = emf->mail_part_list; iter; iter = iter->next) {
 		GtkWidget *widget = NULL;
 
@@ -566,23 +572,30 @@ mail_display_load_normal (EMailDisplay *display,
 				continue;
 			}
 
-			gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+			if (E_IS_ATTACHMENT_BUTTON (widget) && attachment_view)
+				e_attachment_button_set_view (E_ATTACHMENT_BUTTON (widget),
+					attachment_view);
+
+			gtk_container_add (grid, widget);
+
 			if (E_IS_ATTACHMENT_VIEW (widget)) {
-				EAttachmentStore *store = e_attachment_view_get_store (E_ATTACHMENT_VIEW (widget));
+				EAttachmentStore *store;
+
+				attachment_view = E_ATTACHMENT_VIEW (widget);
+				store = e_attachment_view_get_store (attachment_view);
+
 				if (e_attachment_store_get_num_attachments (store) > 0)
 					gtk_widget_show (widget);
 				else
 					gtk_widget_hide (widget);
-
-				g_object_ref (widget);
-			} else
+			} else {
 				gtk_widget_show (widget);
-
+			}
 		}
 
 		if ((!puri->is_attachment && puri->write_func) || (puri->is_attachment && puri->write_func && puri->widget_func)) {
 			web_view = mail_display_setup_webview (display);
-			mail_display_insert_web_view (display, web_view, TRUE);
+			mail_display_insert_web_view (display, web_view);
 			e_web_view_load_uri (web_view, uri);
 
 			if (widget) {
@@ -662,16 +675,14 @@ mail_display_init (EMailDisplay *display)
 {
 	SoupSession *session;
 	SoupSessionFeature *feature;
-	GValue margin = {0};
 
 	display->priv = G_TYPE_INSTANCE_GET_PRIVATE (
 		display, E_TYPE_MAIL_DISPLAY, EMailDisplayPrivate);
 
-	display->priv->vbox = gtk_vbox_new (FALSE, 10);
-	gtk_container_add (GTK_CONTAINER (display), display->priv->vbox);
-	g_value_init (&margin, G_TYPE_INT);
-	g_value_set_int (&margin, 10);
-	g_object_set_property (G_OBJECT (display->priv->vbox), "margin", &margin);
+	display->priv->grid = g_object_new (GTK_TYPE_GRID,
+		"orientation", GTK_ORIENTATION_VERTICAL,
+		"margin", 10, NULL);
+	gtk_container_add (GTK_CONTAINER (display), display->priv->grid);
 
 	display->priv->webviews = NULL;
 
@@ -903,8 +914,8 @@ e_mail_display_set_status (EMailDisplay *display,
 	e_mail_display_clear (display);
 
 	label = gtk_label_new (status);
-	gtk_box_pack_start (GTK_BOX (display->priv->vbox), label, TRUE, TRUE, 0);
-	gtk_widget_show_all (display->priv->vbox);
+	gtk_container_add (GTK_CONTAINER (display->priv->grid), label);
+	gtk_widget_show_all (display->priv->grid);
 }
 
 static void
@@ -915,7 +926,7 @@ remove_widget (GtkWidget *widget, gpointer user_data)
 	if (!GTK_IS_WIDGET (widget))
 		return;
 
-	gtk_container_remove  (GTK_CONTAINER (display->priv->vbox), widget);
+	gtk_container_remove  (GTK_CONTAINER (display->priv->grid), widget);
 }
 
 void
@@ -923,9 +934,9 @@ e_mail_display_clear (EMailDisplay *display)
 {
 	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
 
-	gtk_widget_hide (display->priv->vbox);
+	gtk_widget_hide (display->priv->grid);
 
-	gtk_container_foreach (GTK_CONTAINER (display->priv->vbox),
+	gtk_container_foreach (GTK_CONTAINER (display->priv->grid),
 		(GtkCallback) remove_widget, display);
 
 	g_list_free (display->priv->webviews);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 5bce2fb..3c98b67 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -68,7 +68,7 @@
 #define d(x)
 
 struct _EMFormatHTMLDisplayPrivate {
-	EAttachmentView *attachment_view;
+		void *dummy;
 };
 
 /* TODO: move the dialogue elsehwere */
@@ -111,6 +111,53 @@ static void efhd_builtin_init (EMFormatHTMLDisplayClass *efhc);
 
 static gpointer parent_class;
 
+static EAttachmentStore*
+find_parent_attachment_store (EMFormatHTMLDisplay *efhd, GString *part_id)
+{
+	EMFormat *emf = (EMFormatHTML *) efhd;
+	EMFormatAttachmentBarPURI *abp;
+	EMFormatPURI *puri;
+	gchar *tmp, *pos;
+
+	tmp = g_strdup (part_id->str);
+
+	do {
+		gchar *id;
+
+		pos = g_strrstr (tmp, ".");
+		if (!pos)
+			break;
+
+		g_free (tmp);
+		tmp = g_strndup (part_id->str, pos - tmp);
+		id = g_strdup_printf ("%s.attachment-bar", tmp);
+
+		puri = g_hash_table_lookup (emf->mail_part_table, id);
+
+		g_free (id);
+
+	} while (pos && !puri);
+
+	g_free (tmp);
+
+	abp = (EMFormatAttachmentBarPURI *) puri;
+
+	return abp->store;
+}
+
+static void
+efhd_attachment_bar_puri_free (EMFormatPURI *puri)
+{
+	EMFormatAttachmentBarPURI *abp;
+
+	abp = (EMFormatAttachmentBarPURI *) puri;
+
+	if (abp->store) {
+		g_object_unref (abp->store);
+		abp->store = NULL;
+	}
+}
+
 static void
 efhd_xpkcs7mime_free (EMFormatPURI *puri)
 {
@@ -442,7 +489,7 @@ efhd_parse_attachment (EMFormat *emf,
 	else
 		parent = NULL;
 
-	store = e_attachment_view_get_store (efhd->priv->attachment_view);
+	store = find_parent_attachment_store (efhd, part_id);
 	e_attachment_store_add_attachment (store, puri->attachment);
 
 	if (emf->folder && emf->folder->summary && emf->message_uid) {
@@ -737,11 +784,6 @@ efhd_finalize (GObject *object)
 	efhd = EM_FORMAT_HTML_DISPLAY (object);
 	g_return_if_fail (efhd != NULL);
 
-	if (efhd->priv->attachment_view) {
-		gtk_widget_destroy (GTK_WIDGET (efhd->priv->attachment_view));
-		efhd->priv->attachment_view = NULL;
-	}
-
 	/* Chain up to parent's finalize() method. */
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -783,8 +825,6 @@ efhd_init (EMFormatHTMLDisplay *efhd)
 	efhd->priv = G_TYPE_INSTANCE_GET_PRIVATE (
 		efhd, EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate);
 
-	efhd->priv->attachment_view = E_ATTACHMENT_VIEW (e_mail_attachment_bar_new ());
-
 	/* we want to convert url's etc */
 	EM_FORMAT_HTML (efhd)->text_html_flags |=
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
@@ -966,7 +1006,7 @@ efhd_attachment_button (EMFormat *emf,
 		return NULL;
 	}
 
-	widget = e_attachment_button_new (efhd->priv->attachment_view);
+	widget = e_attachment_button_new ();
 	e_attachment_button_set_attachment (
 		E_ATTACHMENT_BUTTON (widget), info->attachment);
 	gtk_widget_set_can_focus (widget, TRUE);
@@ -986,9 +1026,14 @@ efhd_attachment_bar (EMFormat *emf,
 		     EMFormatPURI *puri,
 		     GCancellable *cancellable)
 {
-	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf;
+	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay*) emf;
+	EMFormatAttachmentBarPURI *abp = (EMFormatAttachmentBarPURI *) puri;
+	GtkWidget *widget;
 
-	return GTK_WIDGET (efhd->priv->attachment_view);
+	widget = e_mail_attachment_bar_new (abp->store);
+	printf("Create bar for PURI %p", puri);
+
+	return widget;
 }
 
 static void
@@ -1032,7 +1077,7 @@ efhd_message_add_bar (EMFormat *emf,
                       GCancellable *cancellable)
 {
 	gchar *classid;
-	EMFormatAttachmentPURI *puri;
+	EMFormatAttachmentBarPURI *puri;
 	gint len;
 
 	if (g_cancellable_is_cancelled (cancellable))
@@ -1040,9 +1085,12 @@ efhd_message_add_bar (EMFormat *emf,
 
 	len = part_id->len;
 	g_string_append (part_id, ".attachment-bar");
-	puri = (EMFormatAttachmentPURI *) em_format_puri_new (
-			emf, sizeof (EMFormatAttachmentPURI), part, part_id->str);
+	puri = (EMFormatAttachmentBarPURI *) em_format_puri_new (
+			emf, sizeof (EMFormatAttachmentBarPURI), part, part_id->str);
 	puri->puri.widget_func = efhd_attachment_bar;
+	puri->puri.free = efhd_attachment_bar_puri_free;
+	puri->store = E_ATTACHMENT_STORE (e_attachment_store_new ());
+
 	em_format_add_puri (emf, (EMFormatPURI*) puri);
 
 	g_string_truncate (part_id, len);
@@ -1195,12 +1243,3 @@ efhd_free_attach_puri_data (EMFormatPURI *puri)
 	g_free (info->attachment_view_part_id);
 	info->attachment_view_part_id = NULL;
 }
-
-/* returned object owned by html_display, thus do not unref it */
-EAttachmentView *
-em_format_html_display_get_attachment_view (EMFormatHTMLDisplay *efhd)
-{
-	g_return_val_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd), NULL);
-
-	return E_ATTACHMENT_VIEW (efhd->priv->attachment_view);
-}
diff --git a/mail/em-format-html-display.h b/mail/em-format-html-display.h
index 0136c8e..079d9bb 100644
--- a/mail/em-format-html-display.h
+++ b/mail/em-format-html-display.h
@@ -52,9 +52,16 @@ G_BEGIN_DECLS
 typedef struct _EMFormatHTMLDisplay EMFormatHTMLDisplay;
 typedef struct _EMFormatHTMLDisplayClass EMFormatHTMLDisplayClass;
 typedef struct _EMFormatHTMLDisplayPrivate EMFormatHTMLDisplayPrivate;
+typedef struct _EMFormatAttachmentBarPURI EMFormatAttachmentBarPURI;
 typedef struct _EMFormatAttachmentPURI EMFormatAttachmentPURI;
 typedef struct _EMFormatSMIMEPURI EMFormatSMIMEPURI;
 
+struct _EMFormatAttachmentBarPURI {
+	EMFormatPURI puri;
+
+	EAttachmentStore *store;
+};
+
 struct _EMFormatAttachmentPURI {
 	EMFormatPURI puri;
 
@@ -110,9 +117,6 @@ struct _EMFormatHTMLDisplayClass {
 GType		em_format_html_display_get_type	(void);
 EMFormatHTMLDisplay *
 		em_format_html_display_new	(void);
-EAttachmentView *
-		em_format_html_display_get_attachment_view
-						(EMFormatHTMLDisplay *html_display);
 G_END_DECLS
 
 #endif /* EM_FORMAT_HTML_DISPLAY_H */
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index dba1155..50ceabe 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -354,27 +354,6 @@ attachment_button_toggle_button_press_event_cb (EAttachmentButton *button,
 }
 
 static void
-attachment_button_set_view (EAttachmentButton *button,
-                            EAttachmentView *view)
-{
-	GtkWidget *popup_menu;
-
-	g_return_if_fail (button->priv->view == NULL);
-
-	button->priv->view = g_object_ref (view);
-
-	popup_menu = e_attachment_view_get_popup_menu (view);
-
-	g_signal_connect_swapped (
-		popup_menu, "deactivate",
-		G_CALLBACK (attachment_button_menu_deactivate_cb), button);
-
-	/* Keep a reference to the popup menu so we can
-	 * disconnect the signal handler in dispose(). */
-	button->priv->popup_menu = g_object_ref (popup_menu);
-}
-
-static void
 attachment_button_set_property (GObject *object,
                                 guint property_id,
                                 const GValue *value,
@@ -400,7 +379,7 @@ attachment_button_set_property (GObject *object,
 			return;
 
 		case PROP_VIEW:
-			attachment_button_set_view (
+			e_attachment_button_set_view (
 				E_ATTACHMENT_BUTTON (object),
 				g_value_get_object (value));
 			return;
@@ -565,8 +544,7 @@ e_attachment_button_class_init (EAttachmentButtonClass *class)
 			"View",
 			NULL,
 			E_TYPE_ATTACHMENT_VIEW,
-			G_PARAM_READWRITE |
-			G_PARAM_CONSTRUCT_ONLY));
+			G_PARAM_READWRITE));
 }
 
 static void
@@ -703,13 +681,10 @@ e_attachment_button_init (EAttachmentButton *button)
 }
 
 GtkWidget *
-e_attachment_button_new (EAttachmentView *view)
+e_attachment_button_new ()
 {
-	g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
 	return g_object_new (
-		E_TYPE_ATTACHMENT_BUTTON,
-		"view", view, NULL);
+		E_TYPE_ATTACHMENT_BUTTON, NULL);
 }
 
 EAttachmentView *
@@ -720,6 +695,31 @@ e_attachment_button_get_view (EAttachmentButton *button)
 	return button->priv->view;
 }
 
+void
+e_attachment_button_set_view (EAttachmentButton *button,
+			      EAttachmentView *view)
+{
+	GtkWidget *popup_menu;
+
+	g_return_if_fail (button->priv->view == NULL);
+
+	if (button->priv->view)
+		g_object_unref (button->priv->view);
+	button->priv->view = g_object_ref (view);
+
+	popup_menu = e_attachment_view_get_popup_menu (view);
+
+	g_signal_connect_swapped (
+		popup_menu, "deactivate",
+		G_CALLBACK (attachment_button_menu_deactivate_cb), button);
+
+	/* Keep a reference to the popup menu so we can
+	 * disconnect the signal handler in dispose(). */
+	if (button->priv->popup_menu)
+		g_object_unref (button->priv->popup_menu);
+	button->priv->popup_menu = g_object_ref (popup_menu);
+}
+
 EAttachment *
 e_attachment_button_get_attachment (EAttachmentButton *button)
 {
diff --git a/widgets/misc/e-attachment-button.h b/widgets/misc/e-attachment-button.h
index a27d8ae..b8a0cbb 100644
--- a/widgets/misc/e-attachment-button.h
+++ b/widgets/misc/e-attachment-button.h
@@ -61,9 +61,11 @@ struct _EAttachmentButtonClass {
 };
 
 GType		e_attachment_button_get_type	(void);
-GtkWidget *	e_attachment_button_new	(EAttachmentView *view);
+GtkWidget *	e_attachment_button_new	(void);
 EAttachmentView *
 		e_attachment_button_get_view	(EAttachmentButton *button);
+void		e_attachment_button_set_view	(EAttachmentButton *button,
+						 EAttachmentView *view);
 EAttachment *	e_attachment_button_get_attachment
 						(EAttachmentButton *button);
 void		e_attachment_button_set_attachment
diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h
index 7309dd9..a963f05 100644
--- a/widgets/misc/e-attachment-store.h
+++ b/widgets/misc/e-attachment-store.h
@@ -130,3 +130,4 @@ gchar **	e_attachment_store_save_finish	(EAttachmentStore *store,
 G_END_DECLS
 
 #endif /* E_ATTACHMENT_STORE_H */
+



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