aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-attachment-bar.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-03-31 06:26:35 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-03-31 06:26:35 +0800
commit04cc4a2cb1bf87417f82d1094ddde611019c0ab8 (patch)
treefeb70083426a3cefcd2a5d2fe5718addb97619a0 /mail/e-mail-attachment-bar.c
parent8a1f639a670696e71daac8305ae0823668d29a14 (diff)
downloadgsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar.gz
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar.bz2
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar.lz
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar.xz
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.tar.zst
gsoc2013-evolution-04cc4a2cb1bf87417f82d1094ddde611019c0ab8.zip
Saving progress again on the attachment rewrite.
svn path=/branches/kill-bonobo/; revision=37486
Diffstat (limited to 'mail/e-mail-attachment-bar.c')
-rw-r--r--mail/e-mail-attachment-bar.c153
1 files changed, 109 insertions, 44 deletions
diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c
index 97f5a7fb00..0043dc383f 100644
--- a/mail/e-mail-attachment-bar.c
+++ b/mail/e-mail-attachment-bar.c
@@ -44,6 +44,8 @@ struct _EMailAttachmentBarPrivate {
GtkWidget *tree_frame;
GtkWidget *status_icon;
GtkWidget *status_label;
+ GtkWidget *save_all_button;
+ GtkWidget *save_one_button;
gint active_view;
guint expanded : 1;
@@ -93,7 +95,9 @@ mail_attachment_bar_update_status (EMailAttachmentBar *bar)
{
EAttachmentView *view;
EAttachmentStore *store;
+ GtkActivatable *activatable;
GtkExpander *expander;
+ GtkAction *action;
GtkLabel *label;
gint num_attachments;
guint64 total_size;
@@ -116,6 +120,14 @@ mail_attachment_bar_update_status (EMailAttachmentBar *bar)
gtk_label_set_markup (label, markup);
g_free (markup);
+ activatable = GTK_ACTIVATABLE (bar->priv->save_all_button);
+ action = gtk_activatable_get_related_action (activatable);
+ gtk_action_set_visible (action, (num_attachments > 1));
+
+ activatable = GTK_ACTIVATABLE (bar->priv->save_one_button);
+ action = gtk_activatable_get_related_action (activatable);
+ gtk_action_set_visible (action, (num_attachments == 1));
+
g_free (display_size);
}
@@ -237,6 +249,16 @@ mail_attachment_bar_dispose (GObject *object)
priv->status_label = NULL;
}
+ if (priv->save_all_button != NULL) {
+ g_object_unref (priv->save_all_button);
+ priv->save_all_button = NULL;
+ }
+
+ if (priv->save_one_button != NULL) {
+ g_object_unref (priv->save_one_button);
+ priv->save_one_button = NULL;
+ }
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -273,6 +295,22 @@ mail_attachment_bar_constructed (GObject *object)
G_OBJECT (priv->vbox), "visible");
}
+static void
+mail_attachment_bar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ /* XXX This works around GtkHTMLEmbedded brokenness.
+ * Once we finally move to WebKit, remove this. */
+ if (!GTK_WIDGET_VISIBLE (widget)) {
+ requisition->width = 0;
+ requisition->height = 0;
+ return;
+ }
+
+ /* Chain up to parent's size_request() method. */
+ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+}
+
static EAttachmentViewPrivate *
mail_attachment_bar_get_private (EAttachmentView *view)
{
@@ -381,6 +419,7 @@ static void
mail_attachment_bar_class_init (EMailAttachmentBarClass *class)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EMailAttachmentBarPrivate));
@@ -391,6 +430,9 @@ mail_attachment_bar_class_init (EMailAttachmentBarClass *class)
object_class->dispose = mail_attachment_bar_dispose;
object_class->constructed = mail_attachment_bar_constructed;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_request = mail_attachment_bar_size_request;
+
g_object_class_install_property (
object_class,
PROP_ACTIVE_VIEW,
@@ -436,10 +478,12 @@ mail_attachment_bar_iface_init (EAttachmentViewIface *iface)
static void
mail_attachment_bar_init (EMailAttachmentBar *bar)
{
+ EAttachmentView *view;
GtkTreeSelection *selection;
GtkSizeGroup *size_group;
GtkWidget *container;
GtkWidget *widget;
+ GtkAction *action;
bar->priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (bar);
bar->priv->model = e_attachment_store_new ();
@@ -449,12 +493,55 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
/* Keep the expander label and save button the same height. */
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+ /* Construct the Attachment Views */
+
+ container = GTK_WIDGET (bar);
+
+ widget = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->vbox = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = bar->priv->vbox;
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ bar->priv->icon_frame = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_attachment_icon_view_new ();
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_icon_view_set_model (GTK_ICON_VIEW (widget), bar->priv->model);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ bar->priv->icon_view = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = bar->priv->vbox;
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ bar->priv->tree_frame = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_attachment_tree_view_new ();
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (widget), bar->priv->model);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ bar->priv->tree_view = g_object_ref (widget);
+ gtk_widget_show (widget);
+
/* Construct the Controls */
container = GTK_WIDGET (bar);
widget = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
container = widget;
@@ -465,6 +552,27 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
bar->priv->expander = g_object_ref (widget);
gtk_widget_show (widget);
+ /* The "Save All" button proxies the "save-all" action from
+ * one of the two attachment views. Doesn't matter which. */
+ widget = gtk_button_new ();
+ view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+ action = e_attachment_view_get_action (view, "save-all");
+ gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new ());
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->save_all_button = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Same deal with the "Save" button. */
+ widget = gtk_button_new ();
+ view = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+ action = e_attachment_view_get_action (view, "save-one");
+ gtk_button_set_image (GTK_BUTTON (widget), gtk_image_new ());
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->save_one_button = g_object_ref (widget);
+ gtk_widget_show (widget);
+
widget = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
@@ -500,49 +608,6 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
bar->priv->status_label = g_object_ref (widget);
gtk_widget_show (widget);
- /* Construct the Attachment Views */
-
- container = GTK_WIDGET (bar);
-
- widget = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
- bar->priv->vbox = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = bar->priv->vbox;
-
- widget = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- bar->priv->icon_frame = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_attachment_icon_view_new ();
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_icon_view_set_model (GTK_ICON_VIEW (widget), bar->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- bar->priv->icon_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = bar->priv->vbox;
-
- widget = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- bar->priv->tree_frame = g_object_ref (widget);
- gtk_widget_show (widget);
-
- container = widget;
-
- widget = e_attachment_tree_view_new ();
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_tree_view_set_model (GTK_TREE_VIEW (widget), bar->priv->model);
- gtk_container_add (GTK_CONTAINER (container), widget);
- bar->priv->tree_view = g_object_ref (widget);
- gtk_widget_show (widget);
-
selection = gtk_tree_view_get_selection (
GTK_TREE_VIEW (bar->priv->tree_view));