[evolution/webkit: 21/113] Add a GtkLabel to EAttachmentButton to display name of the attachment.



commit 468b7642745f39a111d224fe822294d34dd6f922
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Sep 14 11:40:33 2011 +0200

    Add a GtkLabel to EAttachmentButton to display name of the attachment.
    
    Before this was done by putting EAttachmentButton into HTML table and
    writing the name next to it. But since we now embed the button directly
    to GtkWidget structure, we need to display the name of the attachment
    via a GtkLabel now.

 widgets/misc/e-attachment-button.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index efc184b..dba1155 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -27,6 +27,8 @@
 
 #include "e-attachment-button.h"
 
+#include <glib/gi18n.h>
+
 struct _EAttachmentButtonPrivate {
 
 	EAttachmentView *view;
@@ -40,6 +42,7 @@ struct _EAttachmentButtonPrivate {
 	GtkWidget *toggle_button;
 	GtkWidget *cell_view;
 	GtkWidget *popup_menu;
+	GtkWidget *label;
 
 	guint expandable : 1;
 	guint expanded   : 1;
@@ -613,6 +616,11 @@ e_attachment_button_init (EAttachmentButton *button)
 	gtk_container_add (GTK_CONTAINER (container), widget);
 	gtk_widget_show (widget);
 
+	widget = gtk_label_new ("");
+	gtk_box_pack_start (GTK_BOX (button), widget, FALSE, FALSE, 10);
+	gtk_widget_show (widget);
+	button->priv->label = widget;
+
 	/* Configure Renderers */
 
 	cell_layout = GTK_CELL_LAYOUT (button->priv->cell_view);
@@ -751,6 +759,8 @@ e_attachment_button_set_attachment (EAttachmentButton *button,
 	if (attachment != NULL) {
 		GBinding *binding;
 		gulong handler_id;
+		GFileInfo *finfo;
+		const gchar *name;
 
 		binding = g_object_bind_property (
 			attachment, "can-show",
@@ -774,6 +784,13 @@ e_attachment_button_set_attachment (EAttachmentButton *button,
 
 		attachment_button_update_cell_view (button);
 		attachment_button_update_pixbufs (button);
+
+   		finfo = e_attachment_get_file_info (attachment);
+   		name = g_file_info_get_display_name (finfo);
+		if (name &&  *name)
+			gtk_label_set_text (GTK_LABEL (button->priv->label), name);
+		else
+			gtk_label_set_text (GTK_LABEL (button->priv->label), _("attachment.dat"));
 	}
 
 	/* update drag sources */



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