[evolution-patches] (Mailer) Fix for attachment bar to hide the labels when No attachments



Hi,

I have fixed few issues wrt the new attachment bar. 
 (1) It hides the label/expander when no attachments are there. 
also it changes Attachments to attachments. 

-Srini
Index: em-format-html-display.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html-display.c,v
retrieving revision 1.70
diff -u -p -r1.70 em-format-html-display.c
--- em-format-html-display.c	25 Jul 2005 04:23:40 -0000	1.70
+++ em-format-html-display.c	2 Aug 2005 05:06:44 -0000
@@ -112,7 +112,7 @@ struct _EMFormatHTMLDisplayPrivate {
 	GtkWidget *arrow;
 	GtkWidget *forward;
 	GtkWidget *down;
-	GtkWidget *save;
+	GtkWidget *label_box;
 	gboolean  show_bar;
 	gboolean  bar_added;
 	GHashTable *files;
@@ -1862,18 +1862,18 @@ efhd_attachment_bar_refresh (EMFormatHTM
 	if (!efhd->priv->attachment_bar)
 		return;
 
+	/* We come here only when there are attachments */
 	nattachments = e_attachment_bar_get_num_attachments (E_ATTACHMENT_BAR(efhd->priv->attachment_bar));
-	if (nattachments) {
+	if (nattachments > 1) {
 		char *txt;
 
-		/* Cant i put in the number of attachments here ?*/
-		txt = g_strdup_printf(ngettext("%d Attachment", "%d Attachments", nattachments), nattachments);
+		txt = g_strdup_printf("%d attachments", nattachments);
 		gtk_label_set_text ((GtkLabel *)efhd->priv->label, txt);
 		g_free (txt);
 
-		/* Enable the expander button and the save all button.*/
-		gtk_widget_set_sensitive (efhd->priv->arrow, TRUE);
-		gtk_widget_set_sensitive (efhd->priv->save, TRUE);
+	} else {
+		/* Show the expander button and the save all button.*/
+		gtk_widget_show (efhd->priv->label_box);
 	}
 }
 
@@ -1882,7 +1882,7 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLE
 {
 	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh;
 	struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv;
-	GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image;
+	GtkWidget *hbox1, *hbox3, *vbox, *txt, *image, *save;
 	int width, height;
 
 	priv->attachment_bar = e_attachment_bar_new(NULL);
@@ -1895,23 +1895,21 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLE
 	gtk_box_pack_start ((GtkBox *)hbox3, priv->down, FALSE, FALSE, 0);
 	priv->arrow = (GtkWidget *)gtk_tool_button_new(hbox3, NULL);
 
-	priv->label = gtk_label_new(_("No Attachment"));
-	priv->save = gtk_button_new();
+	priv->label = gtk_label_new(_("1 attachment"));
+	save = gtk_button_new();
 	image = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_BUTTON);
 	txt = gtk_label_new(_("Save All"));
 	hbox1 = gtk_hbox_new(FALSE, 0);
 	gtk_box_pack_start((GtkBox *)hbox1, image, FALSE, FALSE, 2);
 	gtk_box_pack_start((GtkBox *)hbox1, txt, FALSE, FALSE, 0);
 
-	gtk_container_add((GtkContainer *)priv->save, hbox1);
+	gtk_container_add((GtkContainer *)save, hbox1);
 
-	gtk_widget_set_sensitive(priv->arrow, FALSE);
-	gtk_widget_set_sensitive(priv->save, FALSE);
 
-	hbox2 = gtk_hbox_new (FALSE, 0);
-	gtk_box_pack_start ((GtkBox *)hbox2, priv->arrow, FALSE, FALSE, 0);
-	gtk_box_pack_start ((GtkBox *)hbox2, priv->label, FALSE, FALSE, 2);
-	gtk_box_pack_start ((GtkBox *)hbox2, priv->save, FALSE, FALSE, 2);
+	priv->label_box = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)priv->label_box, priv->arrow, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)priv->label_box, priv->label, FALSE, FALSE, 2);
+	gtk_box_pack_start ((GtkBox *)priv->label_box, save, FALSE, FALSE, 2);
 
 	priv->attachment_box = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start ((GtkBox *)priv->attachment_box, priv->attachment_bar, TRUE, TRUE, 0);
@@ -1925,12 +1923,14 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLE
 					84 /* FIXME: Default show only one row, Dont hardcode size*/);
 	
 	vbox = gtk_vbox_new (FALSE, 0);
-	gtk_box_pack_start ((GtkBox *)vbox, hbox2, FALSE, FALSE, 2);
+	gtk_box_pack_start ((GtkBox *)vbox, priv->label_box, FALSE, FALSE, 2);
 	gtk_box_pack_start ((GtkBox *)vbox, priv->attachment_box, TRUE, TRUE, 2);
 
 	gtk_container_add ((GtkContainer *)eb, vbox);
-	gtk_widget_show_all ((GtkWidget *)eb);
+	gtk_widget_show_all ((GtkWidget *)eb);	
 
+	gtk_widget_hide (priv->label_box);
+	
 	if (priv->show_bar) {
 		gtk_widget_show(priv->down);
 		gtk_widget_hide(priv->forward);
@@ -1943,7 +1943,7 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLE
 	g_signal_connect (priv->arrow, "clicked", G_CALLBACK(attachment_bar_arrow_clicked), efh);
 	g_signal_connect (priv->attachment_bar, "button_press_event", G_CALLBACK(efhd_bar_button_press_event), efhd);
 	g_signal_connect (priv->attachment_bar, "popup-menu", G_CALLBACK(efhd_bar_popup_menu_event), efhd);
-	g_signal_connect (priv->save, "clicked", G_CALLBACK(attachments_save_all_clicked), efh);
+	g_signal_connect (save, "clicked", G_CALLBACK(attachments_save_all_clicked), efh);
 
 	return TRUE;
 }


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