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



On Wed, 2005-08-03 at 15:34 +0800, Not Zed wrote:
> Shouldn't you hide the whole thing?  why track the label widget
> separately?  i.e. the vbox containing everything, not just the label
> widget box.
> 
Yes im doing it.
> remember that changing the string affects all of the translators ... is
> it that important?
> 
Hmm. yes. it is nice if we have it. i can announce the change. 

> I dont think you need to change all of this, it would be better to keep
> the ngettext version rather than have 2 separate 'n attachment' strings.
> 
Yes. Keeping it the old way.
Also i have added a code to resize the bar, when the evolution window
resizes.

> +       /* 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);
>         }
> 
> On Tue, 2005-08-02 at 10:58 +0530, Srinivasa Ragavan wrote:
> > 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
> > _______________________________________________
> > evolution-patches mailing list
> > evolution-patches lists ximian com
> > http://lists.ximian.com/mailman/listinfo/evolution-patches
> 
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: em-format-html-display.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html-display.c,v
retrieving revision 1.70
diff -u -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	4 Aug 2005 05:35:41 -0000
@@ -112,7 +112,7 @@
 	GtkWidget *arrow;
 	GtkWidget *forward;
 	GtkWidget *down;
-	GtkWidget *save;
+	GtkWidget *attachment_area;
 	gboolean  show_bar;
 	gboolean  bar_added;
 	GHashTable *files;
@@ -1867,22 +1867,48 @@
 		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(ngettext("%d attachment", "%d attachments", nattachments), 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);
+	
+		/* Show the bar even when the first attachment is added */
+		if (nattachments == 1) {
+			gtk_widget_show_all (efhd->priv->attachment_area);
+			
+			if (efhd->priv->show_bar) {
+				gtk_widget_show(efhd->priv->down);
+				gtk_widget_hide(efhd->priv->forward);
+			} else {
+				gtk_widget_show(efhd->priv->forward);
+				gtk_widget_hide(efhd->priv->down);
+				gtk_widget_hide(efhd->priv->attachment_box);
+			}
+		}
 	}
 }
 
+
+static void
+efhd_bar_resize(GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh)
+{
+	int width;
+	GtkRequisition req;
+	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh;
+
+	gtk_widget_size_request (efhd->priv->attachment_bar, &req);
+	width = ((GtkWidget *) efh->html)->allocation.width - 36;
+	gtk_widget_set_size_request (efhd->priv->attachment_bar, width, req.height);
+
+	/* Update the bar to refresh the icons and adjust the height */
+	e_attachment_bar_refresh (E_ATTACHMENT_BAR(efhd->priv->attachment_bar));
+}
+
 static gboolean
 efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject)
 {
 	EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh;
 	struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv;
-	GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image;
+	GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image, *save;
 	int width, height;
 
 	priv->attachment_bar = e_attachment_bar_new(NULL);
@@ -1896,22 +1922,19 @@
 	priv->arrow = (GtkWidget *)gtk_tool_button_new(hbox3, NULL);
 
 	priv->label = gtk_label_new(_("No Attachment"));
-	priv->save = gtk_button_new();
+	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_widget_set_sensitive(priv->arrow, FALSE);
-	gtk_widget_set_sensitive(priv->save, FALSE);
+	gtk_container_add((GtkContainer *)save, hbox1);
 
 	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);
+	gtk_box_pack_start ((GtkBox *)hbox2, 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);
@@ -1929,21 +1952,17 @@
 	gtk_box_pack_start ((GtkBox *)vbox, priv->attachment_box, TRUE, TRUE, 2);
 
 	gtk_container_add ((GtkContainer *)eb, vbox);
-	gtk_widget_show_all ((GtkWidget *)eb);
-
-	if (priv->show_bar) {
-		gtk_widget_show(priv->down);
-		gtk_widget_hide(priv->forward);
-	} else {
-		gtk_widget_show(priv->forward);
-		gtk_widget_hide(priv->down);
-		gtk_widget_hide(priv->attachment_box);
-	}
+	gtk_widget_show ((GtkWidget *)eb);
 
+	/* Lets hide it by default and show only when there are attachments */
+	priv->attachment_area = vbox;
+	gtk_widget_hide_all (priv->attachment_area);
+	
 	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);
+	g_signal_connect (eb, "size_allocate", G_CALLBACK (efhd_bar_resize), efh);
 
 	return TRUE;
 }
Index: e-attachment-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-attachment-bar.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-attachment-bar.c
--- e-attachment-bar.c	29 Jul 2005 04:39:25 -0000	1.4
+++ e-attachment-bar.c	4 Aug 2005 05:33:34 -0000
@@ -488,6 +488,12 @@ e_attachment_bar_remove_selected (EAttac
 }
 
 void
+e_attachment_bar_refresh (EAttachmentBar *bar)
+{
+	update (bar);
+}
+
+void
 e_attachment_bar_edit_selected (EAttachmentBar *bar)
 {
 	GnomeIconList *icon_list;
Index: e-attachment-bar.h
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-attachment-bar.h,v
retrieving revision 1.2
diff -u -p -r1.2 e-attachment-bar.h
--- e-attachment-bar.h	20 Jul 2005 11:17:42 -0000	1.2
+++ e-attachment-bar.h	4 Aug 2005 05:33:34 -0000
@@ -81,6 +81,7 @@ void e_attachment_bar_remove_selected (E
 GtkWidget ** e_attachment_bar_get_selector(EAttachmentBar *bar);
 GSList *e_attachment_bar_get_parts (EAttachmentBar *bar);
 GSList *e_attachment_bar_get_selected (EAttachmentBar *bar);
+void e_attachment_bar_refresh (EAttachmentBar *bar);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */


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