evolution r37524 - in branches/kill-bonobo: . mail widgets/misc



Author: mbarnes
Date: Wed Apr 15 00:15:46 2009
New Revision: 37524
URL: http://svn.gnome.org/viewvc/evolution?rev=37524&view=rev

Log:
Add "View Inline" / "Hide" menu items to the popup menu.
Add application icons to the "Open With" menu items.


Modified:
   branches/kill-bonobo/configure.in
   branches/kill-bonobo/mail/em-format-html-display.c
   branches/kill-bonobo/widgets/misc/e-attachment-button.c
   branches/kill-bonobo/widgets/misc/e-attachment-view.c
   branches/kill-bonobo/widgets/misc/e-attachment-view.h
   branches/kill-bonobo/widgets/misc/e-attachment.c
   branches/kill-bonobo/widgets/misc/e-attachment.h

Modified: branches/kill-bonobo/configure.in
==============================================================================
--- branches/kill-bonobo/configure.in	(original)
+++ branches/kill-bonobo/configure.in	Wed Apr 15 00:15:46 2009
@@ -22,7 +22,7 @@
 
 # Required Packages
 m4_define([glib_minimum_version], [2.18.0])
-m4_define([gtk_minimum_version], [2.14.0])
+m4_define([gtk_minimum_version], [2.16.0])
 m4_define([eds_minimum_version], [evo_version])
 m4_define([gnome_icon_theme_minimum_version], [2.19.91])
 m4_define([libbonobo_minimum_version], [2.20.3])

Modified: branches/kill-bonobo/mail/em-format-html-display.c
==============================================================================
--- branches/kill-bonobo/mail/em-format-html-display.c	(original)
+++ branches/kill-bonobo/mail/em-format-html-display.c	Wed Apr 15 00:15:46 2009
@@ -1219,8 +1219,10 @@
 	}
 
 	attachment = info->attachment;
+	e_attachment_set_shown (attachment, info->shown);
 	e_attachment_set_signed (attachment, info->sign);
 	e_attachment_set_encrypted (attachment, info->encrypt);
+	e_attachment_set_can_show (attachment, info->handle != NULL);
 
 	parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html));
 	parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
@@ -1238,10 +1240,6 @@
 	widget = e_attachment_button_new (view);
 	e_attachment_button_set_attachment (
 		E_ATTACHMENT_BUTTON (widget), attachment);
-	e_attachment_button_set_expandable (
-		E_ATTACHMENT_BUTTON (widget), (info->handle != NULL));
-	e_attachment_button_set_expanded (
-		E_ATTACHMENT_BUTTON (widget), info->shown);
 	gtk_container_add (GTK_CONTAINER (eb), widget);
 	gtk_widget_show (widget);
 

Modified: branches/kill-bonobo/widgets/misc/e-attachment-button.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-button.c	(original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-button.c	Wed Apr 15 00:15:46 2009
@@ -35,6 +35,9 @@
 	EAttachment *attachment;
 	gulong reference_handler_id;
 
+	EMutualBinding *can_show_binding;
+	EMutualBinding *shown_binding;
+
 	GtkWidget *expand_button;
 	GtkWidget *toggle_button;
 	GtkWidget *cell_view;
@@ -56,11 +59,17 @@
 static void
 attachment_button_menu_deactivate_cb (EAttachmentButton *button)
 {
+	EAttachmentView *view;
+	GtkActionGroup *action_group;
 	GtkToggleButton *toggle_button;
 
+	view = e_attachment_button_get_view (button);
+	action_group = e_attachment_view_get_action_group (view, "inline");
 	toggle_button = GTK_TOGGLE_BUTTON (button->priv->toggle_button);
 
 	gtk_toggle_button_set_active (toggle_button, FALSE);
+
+	gtk_action_group_set_visible (action_group, FALSE);
 }
 
 static void
@@ -96,9 +105,9 @@
 
 	direction = gtk_widget_get_direction (widget);
 	if (direction == GTK_TEXT_DIR_LTR)
-		x += MAX (widget->allocation.width - menu_requisition.width, 0);
+		*x += MAX (widget->allocation.width - menu_requisition.width, 0);
 	else if (menu_requisition.width > widget->allocation.width)
-		x -= menu_requisition.width - widget->allocation.width;
+		*x -= menu_requisition.width - widget->allocation.width;
 
 	if ((*y + toggle_button->allocation.height + menu_requisition.height) <= monitor.y + monitor.height)
 		*y += toggle_button->allocation.height;
@@ -139,10 +148,12 @@
 attachment_button_show_popup_menu (EAttachmentButton *button,
                                    GdkEventButton *event)
 {
-	GtkToggleButton *toggle_button;
 	EAttachmentView *view;
+	GtkActionGroup *action_group;
+	GtkToggleButton *toggle_button;
 
 	view = e_attachment_button_get_view (button);
+	action_group = e_attachment_view_get_action_group (view, "inline");
 	toggle_button = GTK_TOGGLE_BUTTON (button->priv->toggle_button);
 
 	attachment_button_select_path (button);
@@ -152,6 +163,7 @@
 		view, event, (GtkMenuPositionFunc)
 		attachment_button_menu_position, button);
 
+	gtk_action_group_set_visible (action_group, TRUE);
 }
 
 static void
@@ -630,6 +642,12 @@
 	}
 
 	if (button->priv->attachment != NULL) {
+		e_mutual_binding_unbind (
+			button->priv->can_show_binding);
+		button->priv->can_show_binding = NULL;
+		e_mutual_binding_unbind (
+			button->priv->shown_binding);
+		button->priv->shown_binding = NULL;
 		g_signal_handler_disconnect (
 			button->priv->attachment,
 			button->priv->reference_handler_id);
@@ -639,15 +657,27 @@
 	button->priv->attachment = attachment;
 
 	if (attachment != NULL) {
+		EMutualBinding *binding;
 		gulong handler_id;
 
+		binding = e_mutual_binding_new (
+			G_OBJECT (attachment), "can-show",
+			G_OBJECT (button), "expandable");
+		button->priv->can_show_binding = binding;
+
+		binding = e_mutual_binding_new (
+			G_OBJECT (attachment), "shown",
+			G_OBJECT (button), "expanded");
+		button->priv->shown_binding = binding;
+
 		handler_id = g_signal_connect_swapped (
 			attachment, "notify::reference",
 			G_CALLBACK (attachment_button_update_cell_view),
 			button);
+		button->priv->reference_handler_id = handler_id;
+
 		attachment_button_update_cell_view (button);
 		attachment_button_update_pixbufs (button);
-		button->priv->reference_handler_id = handler_id;
 	}
 
 	g_object_notify (G_OBJECT (button), "attachment");

Modified: branches/kill-bonobo/widgets/misc/e-attachment-view.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-view.c	(original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-view.c	Wed Apr 15 00:15:46 2009
@@ -51,6 +51,11 @@
 "    <menuitem action='remove'/>"
 "    <menuitem action='properties'/>"
 "    <separator/>"
+"    <placeholder name='inline-actions'>"
+"      <menuitem action='show'/>"
+"      <menuitem action='hide'/>"
+"    </placeholder>"
+"    <separator/>"
 "    <placeholder name='custom-actions'/>"
 "    <separator/>"
 "    <menuitem action='add'/>"
@@ -93,6 +98,23 @@
 }
 
 static void
+action_hide_cb (GtkAction *action,
+                EAttachmentView *view)
+{
+	EAttachment *attachment;
+	GList *selected;
+
+	selected = e_attachment_view_get_selected_attachments (view);
+	g_return_if_fail (g_list_length (selected) == 1);
+	attachment = selected->data;
+
+	e_attachment_set_shown (attachment, FALSE);
+
+	g_list_foreach (selected, (GFunc) g_object_unref, NULL);
+	g_list_free (selected);
+}
+
+static void
 action_open_in_cb (GtkAction *action,
                    EAttachmentView *view)
 {
@@ -246,6 +268,23 @@
 	g_list_free (selected);
 }
 
+static void
+action_show_cb (GtkAction *action,
+                EAttachmentView *view)
+{
+	EAttachment *attachment;
+	GList *selected;
+
+	selected = e_attachment_view_get_selected_attachments (view);
+	g_return_if_fail (g_list_length (selected) == 1);
+	attachment = selected->data;
+
+	e_attachment_set_shown (attachment, TRUE);
+
+	g_list_foreach (selected, (GFunc) g_object_unref, NULL);
+	g_list_free (selected);
+}
+
 static GtkActionEntry standard_entries[] = {
 
 	{ "cancel",
@@ -303,6 +342,23 @@
 	  G_CALLBACK (action_remove_cb) }
 };
 
+static GtkActionEntry inline_entries[] = {
+
+	{ "hide",
+	  NULL,
+	  N_("_Hide"),
+	  NULL,
+	  NULL,  /* XXX Add a tooltip! */
+	  G_CALLBACK (action_hide_cb) },
+
+	{ "show",
+	  NULL,
+	  N_("_View Inline"),
+	  NULL,
+	  NULL,  /* XXX Add a tooltip! */
+	  G_CALLBACK (action_show_cb) }
+};
+
 static void
 attachment_view_netscape_url (EAttachmentView *view,
                               GdkDragContext *drag_context,
@@ -514,10 +570,13 @@
 {
 	EAttachmentViewPrivate *priv;
 	EAttachment *attachment;
+	GtkActionGroup *action_group;
 	GtkAction *action;
 	GList *list, *iter;
 	guint n_selected;
 	gboolean busy = FALSE;
+	gboolean can_show = FALSE;
+	gboolean shown = FALSE;
 
 	g_return_if_fail (E_IS_ATTACHMENT_VIEW (view));
 
@@ -529,6 +588,8 @@
 		attachment = g_object_ref (list->data);
 		busy |= e_attachment_get_loading (attachment);
 		busy |= e_attachment_get_saving (attachment);
+		can_show = e_attachment_get_can_show (attachment);
+		shown = e_attachment_get_shown (attachment);
 	} else
 		attachment = NULL;
 
@@ -538,6 +599,9 @@
 	action = e_attachment_view_get_action (view, "cancel");
 	gtk_action_set_visible (action, busy);
 
+	action = e_attachment_view_get_action (view, "hide");
+	gtk_action_set_visible (action, can_show && shown);
+
 	action = e_attachment_view_get_action (view, "properties");
 	gtk_action_set_visible (action, !busy && n_selected == 1);
 
@@ -547,9 +611,13 @@
 	action = e_attachment_view_get_action (view, "save-as");
 	gtk_action_set_visible (action, !busy && n_selected > 0);
 
+	action = e_attachment_view_get_action (view, "show");
+	gtk_action_set_visible (action, can_show && !shown);
+
 	/* Clear out the "openwith" action group. */
 	gtk_ui_manager_remove_ui (priv->ui_manager, priv->merge_id);
-	e_action_group_remove_all_actions (priv->openwith_actions);
+	action_group = e_attachment_view_get_action_group (view, "openwith");
+	e_action_group_remove_all_actions (action_group);
 
 	if (attachment == NULL || busy)
 		return;
@@ -559,6 +627,7 @@
 	for (iter = list; iter != NULL; iter = iter->next) {
 		GAppInfo *app_info = iter->data;
 		GtkAction *action;
+		GIcon *app_icon;
 		const gchar *app_executable;
 		const gchar *app_name;
 		gchar *action_tooltip;
@@ -569,6 +638,7 @@
 			continue;
 
 		app_executable = g_app_info_get_executable (app_info);
+		app_icon = g_app_info_get_icon (app_info);
 		app_name = g_app_info_get_name (app_info);
 
 		action_name = g_strdup_printf ("open-in-%s", app_executable);
@@ -580,6 +650,8 @@
 		action = gtk_action_new (
 			action_name, action_label, action_tooltip, NULL);
 
+		gtk_action_set_gicon (action, app_icon);
+
 		g_object_set_data_full (
 			G_OBJECT (action),
 			"app-info", g_object_ref (app_info),
@@ -594,7 +666,7 @@
 			action, "activate",
 			G_CALLBACK (action_open_in_cb), view);
 
-		gtk_action_group_add_action (priv->openwith_actions, action);
+		gtk_action_group_add_action (action_group, action);
 
 		gtk_ui_manager_add_ui (
 			priv->ui_manager, priv->merge_id,
@@ -713,7 +785,6 @@
 	EAttachmentViewPrivate *priv;
 	GtkUIManager *ui_manager;
 	GtkActionGroup *action_group;
-	const gchar *domain = GETTEXT_PACKAGE;
 	GError *error = NULL;
 
 	priv = e_attachment_view_get_private (view);
@@ -722,26 +793,29 @@
 	priv->merge_id = gtk_ui_manager_new_merge_id (ui_manager);
 	priv->ui_manager = ui_manager;
 
-	action_group = gtk_action_group_new ("standard");
-	gtk_action_group_set_translation_domain (action_group, domain);
+	action_group = e_attachment_view_add_action_group (view, "standard");
+
 	gtk_action_group_add_actions (
 		action_group, standard_entries,
 		G_N_ELEMENTS (standard_entries), view);
-	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-	priv->standard_actions = action_group;
 
-	action_group = gtk_action_group_new ("editable");
-	gtk_action_group_set_translation_domain (action_group, domain);
+	action_group = e_attachment_view_add_action_group (view, "editable");
+
+	e_mutual_binding_new (
+		G_OBJECT (view), "editable",
+		G_OBJECT (action_group), "visible");
 	gtk_action_group_add_actions (
 		action_group, editable_entries,
 		G_N_ELEMENTS (editable_entries), view);
-	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-	priv->editable_actions = action_group;
 
-	action_group = gtk_action_group_new ("openwith");
-	gtk_action_group_set_translation_domain (action_group, domain);
-	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-	priv->openwith_actions = action_group;
+	action_group = e_attachment_view_add_action_group (view, "inline");
+
+	gtk_action_group_add_actions (
+		action_group, inline_entries,
+		G_N_ELEMENTS (inline_entries), view);
+	gtk_action_group_set_visible (action_group, FALSE);
+
+	e_attachment_view_add_action_group (view, "openwith");
 
 	/* Because we are loading from a hard-coded string, there is
 	 * no chance of I/O errors.  Failure here implies a malformed
@@ -750,10 +824,6 @@
 	if (error != NULL)
 		g_error ("%s", error->message);
 
-	e_mutual_binding_new (
-		G_OBJECT (view), "editable",
-		G_OBJECT (priv->editable_actions), "visible");
-
 	attachment_view_init_handlers (view);
 
 	e_attachment_view_drag_source_set (view);
@@ -797,21 +867,6 @@
 		g_object_unref (priv->ui_manager);
 		priv->ui_manager = NULL;
 	}
-
-	if (priv->standard_actions != NULL) {
-		g_object_unref (priv->standard_actions);
-		priv->standard_actions = NULL;
-	}
-
-	if (priv->editable_actions != NULL) {
-		g_object_unref (priv->editable_actions);
-		priv->editable_actions = NULL;
-	}
-
-	if (priv->openwith_actions != NULL) {
-		g_object_unref (priv->openwith_actions);
-		priv->openwith_actions = NULL;
-	}
 }
 
 void

Modified: branches/kill-bonobo/widgets/misc/e-attachment-view.h
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-view.h	(original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-view.h	Wed Apr 15 00:15:46 2009
@@ -101,9 +101,6 @@
 
 	/* Popup Menu Management */
 	GtkUIManager *ui_manager;
-	GtkActionGroup *standard_actions;
-	GtkActionGroup *editable_actions;
-	GtkActionGroup *openwith_actions;
 	guint merge_id;
 
 	guint editable : 1;

Modified: branches/kill-bonobo/widgets/misc/e-attachment.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment.c	(original)
+++ branches/kill-bonobo/widgets/misc/e-attachment.c	Wed Apr 15 00:15:46 2009
@@ -66,8 +66,10 @@
 	gchar *disposition;
 	gint percent;
 
-	guint loading : 1;
-	guint saving  : 1;
+	guint can_show : 1;
+	guint loading  : 1;
+	guint saving   : 1;
+	guint shown    : 1;
 
 	camel_cipher_validity_encrypt_t encrypted;
 	camel_cipher_validity_sign_t signed_;
@@ -81,6 +83,7 @@
 
 enum {
 	PROP_0,
+	PROP_CAN_SHOW,
 	PROP_DISPOSITION,
 	PROP_ENCRYPTED,
 	PROP_FILE,
@@ -90,6 +93,7 @@
 	PROP_PERCENT,
 	PROP_REFERENCE,
 	PROP_SAVING,
+	PROP_SHOWN,
 	PROP_SIGNED
 };
 
@@ -445,6 +449,12 @@
                          GParamSpec *pspec)
 {
 	switch (property_id) {
+		case PROP_CAN_SHOW:
+			e_attachment_set_can_show (
+				E_ATTACHMENT (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_DISPOSITION:
 			e_attachment_set_disposition (
 				E_ATTACHMENT (object),
@@ -463,6 +473,12 @@
 				g_value_get_object (value));
 			return;
 
+		case PROP_SHOWN:
+			e_attachment_set_shown (
+				E_ATTACHMENT (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_MIME_PART:
 			e_attachment_set_mime_part (
 				E_ATTACHMENT (object),
@@ -492,6 +508,12 @@
                          GParamSpec *pspec)
 {
 	switch (property_id) {
+		case PROP_CAN_SHOW:
+			g_value_set_boolean (
+				value, e_attachment_get_can_show (
+				E_ATTACHMENT (object)));
+			return;
+
 		case PROP_DISPOSITION:
 			g_value_set_string (
 				value, e_attachment_get_disposition (
@@ -516,6 +538,12 @@
 				E_ATTACHMENT (object)));
 			return;
 
+		case PROP_SHOWN:
+			g_value_set_boolean (
+				value, e_attachment_get_shown (
+				E_ATTACHMENT (object)));
+			return;
+
 		case PROP_LOADING:
 			g_value_set_boolean (
 				value, e_attachment_get_loading (
@@ -625,6 +653,17 @@
 
 	g_object_class_install_property (
 		object_class,
+		PROP_CAN_SHOW,
+		g_param_spec_boolean (
+			"can-show",
+			"Can Show",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_DISPOSITION,
 		g_param_spec_string (
 			"disposition",
@@ -721,6 +760,17 @@
 			FALSE,
 			G_PARAM_READABLE));
 
+	g_object_class_install_property (
+		object_class,
+		PROP_SHOWN,
+		g_param_spec_boolean (
+			"shown",
+			"Shown",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT));
+
 	/* FIXME Define a GEnumClass for this. */
 	g_object_class_install_property (
 		object_class,
@@ -985,6 +1035,25 @@
 	g_cancellable_cancel (attachment->priv->cancellable);
 }
 
+gboolean
+e_attachment_get_can_show (EAttachment *attachment)
+{
+	g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
+
+	return attachment->priv->can_show;
+}
+
+void
+e_attachment_set_can_show (EAttachment *attachment,
+                           gboolean can_show)
+{
+	g_return_if_fail (E_IS_ATTACHMENT (attachment));
+
+	attachment->priv->can_show = can_show;
+
+	g_object_notify (G_OBJECT (attachment), "can-show");
+}
+
 const gchar *
 e_attachment_get_disposition (EAttachment *attachment)
 {
@@ -1114,6 +1183,25 @@
 	return attachment->priv->saving;
 }
 
+gboolean
+e_attachment_get_shown (EAttachment *attachment)
+{
+	g_return_val_if_fail (E_IS_ATTACHMENT (attachment), FALSE);
+
+	return attachment->priv->shown;
+}
+
+void
+e_attachment_set_shown (EAttachment *attachment,
+                        gboolean shown)
+{
+	g_return_if_fail (E_IS_ATTACHMENT (attachment));
+
+	attachment->priv->shown = shown;
+
+	g_object_notify (G_OBJECT (attachment), "shown");
+}
+
 camel_cipher_validity_encrypt_t
 e_attachment_get_encrypted (EAttachment *attachment)
 {

Modified: branches/kill-bonobo/widgets/misc/e-attachment.h
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment.h	(original)
+++ branches/kill-bonobo/widgets/misc/e-attachment.h	Wed Apr 15 00:15:46 2009
@@ -71,6 +71,9 @@
 						 CamelMultipart *multipart,
 						 const gchar *default_charset);
 void		e_attachment_cancel		(EAttachment *attachment);
+gboolean	e_attachment_get_can_show	(EAttachment *attachment);
+void		e_attachment_set_can_show	(EAttachment *attachment,
+						 gboolean can_show);
 const gchar *	e_attachment_get_disposition	(EAttachment *attachment);
 void		e_attachment_set_disposition	(EAttachment *attachment,
 						 const gchar *disposition);
@@ -88,6 +91,9 @@
 void		e_attachment_set_reference	(EAttachment *attachment,
 						 GtkTreeRowReference *reference);
 gboolean	e_attachment_get_saving		(EAttachment *attachment);
+gboolean	e_attachment_get_shown		(EAttachment *attachment);
+void		e_attachment_set_shown		(EAttachment *attachment,
+						 gboolean shown);
 camel_cipher_validity_encrypt_t
 		e_attachment_get_encrypted	(EAttachment *attachment);
 void		e_attachment_set_encrypted	(EAttachment *attachment,



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