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



commit 2ca0a8158401ed51bf6bdc0eef48bb2ee74b2fae
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 4847cd2..a789357 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>
+
 #define E_ATTACHMENT_BUTTON_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_ATTACHMENT_BUTTON, EAttachmentButtonPrivate))
@@ -44,6 +46,7 @@ struct _EAttachmentButtonPrivate {
 	GtkWidget *toggle_button;
 	GtkWidget *cell_view;
 	GtkWidget *popup_menu;
+	GtkWidget *label;
 
 	guint expandable : 1;
 	guint expanded   : 1;
@@ -616,6 +619,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);
@@ -754,6 +762,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",
@@ -777,6 +787,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]