From 6d2c382788a4042d53f49a080acd11b499aa52f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Wed, 28 Mar 2012 18:38:11 +0200 Subject: WebKit port - port formatter and mail module --- mail/e-mail-attachment-bar.c | 94 ++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 30 deletions(-) (limited to 'mail/e-mail-attachment-bar.c') diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c index 21a298c56d..7572c664cb 100644 --- a/mail/e-mail-attachment-bar.c +++ b/mail/e-mail-attachment-bar.c @@ -60,7 +60,8 @@ enum { PROP_ACTIVE_VIEW, PROP_DRAGGING, PROP_EDITABLE, - PROP_EXPANDED + PROP_EXPANDED, + PROP_STORE }; /* Forward Declarations */ @@ -78,7 +79,6 @@ G_DEFINE_TYPE_WITH_CODE ( static void mail_attachment_bar_update_status (EMailAttachmentBar *bar) { - EAttachmentView *view; EAttachmentStore *store; GtkActivatable *activatable; GtkAction *action; @@ -88,8 +88,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); @@ -119,6 +118,31 @@ mail_attachment_bar_update_status (EMailAttachmentBar *bar) g_free (display_size); } +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, @@ -127,7 +151,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; @@ -149,6 +173,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); @@ -188,6 +217,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); @@ -201,8 +235,6 @@ mail_attachment_bar_dispose (GObject *object) priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (object); if (priv->model != NULL) { - e_attachment_store_remove_all ( - E_ATTACHMENT_STORE (priv->model)); g_object_unref (priv->model); priv->model = NULL; } @@ -347,17 +379,6 @@ mail_attachment_bar_get_private (EAttachmentView *view) return e_attachment_view_get_private (view); } -static EAttachmentStore * -mail_attachment_bar_get_store (EAttachmentView *view) -{ - EMailAttachmentBar *bar; - - bar = E_MAIL_ATTACHMENT_BAR (view); - view = E_ATTACHMENT_VIEW (bar->priv->icon_view); - - return e_attachment_view_get_store (view); -} - static GtkTreePath * mail_attachment_bar_get_path_at_pos (EAttachmentView *view, gint x, @@ -488,6 +509,17 @@ e_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"); @@ -499,7 +531,7 @@ static void e_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; @@ -520,7 +552,6 @@ e_mail_attachment_bar_init (EMailAttachmentBar *bar) GtkAction *action; bar->priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (bar); - bar->priv->model = e_attachment_store_new (); gtk_box_set_spacing (GTK_BOX (bar), 6); @@ -644,23 +675,18 @@ e_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); } 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 @@ -729,3 +755,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); +} -- cgit v1.2.3