aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-04-15 08:15:46 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-04-15 08:15:46 +0800
commitca691310d85f7a266d070cb004d3534215ac47d0 (patch)
tree6a793011d0e1387928d2392df384dae026ac9b58
parent582ec45a59973e3beed7370c3476edaeb16c9eac (diff)
downloadgsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar.gz
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar.bz2
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar.lz
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar.xz
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.tar.zst
gsoc2013-evolution-ca691310d85f7a266d070cb004d3534215ac47d0.zip
Add "View Inline" / "Hide" menu items to the popup menu.
Add application icons to the "Open With" menu items. svn path=/branches/kill-bonobo/; revision=37524
-rw-r--r--configure.in2
-rw-r--r--mail/em-format-html-display.c6
-rw-r--r--widgets/misc/e-attachment-button.c38
-rw-r--r--widgets/misc/e-attachment-view.c123
-rw-r--r--widgets/misc/e-attachment-view.h3
-rw-r--r--widgets/misc/e-attachment.c92
-rw-r--r--widgets/misc/e-attachment.h6
7 files changed, 222 insertions, 48 deletions
diff --git a/configure.in b/configure.in
index a899f9f30b..a8f1e0cfbb 100644
--- a/configure.in
+++ b/configure.in
@@ -22,7 +22,7 @@ GTKHTML_PACKAGE=3.14
# 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])
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index d413133c3d..6faa6ae803 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -1219,8 +1219,10 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
}
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 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
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);
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index fa43373a3c..a9c230bac7 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -35,6 +35,9 @@ struct _EAttachmentButtonPrivate {
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 gpointer parent_class;
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 @@ attachment_button_menu_position (GtkMenu *menu,
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 @@ static void
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 @@ attachment_button_show_popup_menu (EAttachmentButton *button,
view, event, (GtkMenuPositionFunc)
attachment_button_menu_position, button);
+ gtk_action_group_set_visible (action_group, TRUE);
}
static void
@@ -630,6 +642,12 @@ e_attachment_button_set_attachment (EAttachmentButton *button,
}
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 @@ e_attachment_button_set_attachment (EAttachmentButton *button,
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");
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c
index f976b71483..2ad34d6751 100644
--- a/widgets/misc/e-attachment-view.c
+++ b/widgets/misc/e-attachment-view.c
@@ -51,6 +51,11 @@ static const gchar *ui =
" <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 @@ action_cancel_cb (GtkAction *action,
}
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 @@ exit:
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 @@ static GtkActionEntry editable_entries[] = {
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 @@ attachment_view_update_actions (EAttachmentView *view)
{
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_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ attachment_view_update_actions (EAttachmentView *view)
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 @@ e_attachment_view_init (EAttachmentView *view)
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 @@ e_attachment_view_init (EAttachmentView *view)
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 @@ e_attachment_view_init (EAttachmentView *view)
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 @@ e_attachment_view_dispose (EAttachmentView *view)
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
diff --git a/widgets/misc/e-attachment-view.h b/widgets/misc/e-attachment-view.h
index 8d1bd328dd..0fc5118669 100644
--- a/widgets/misc/e-attachment-view.h
+++ b/widgets/misc/e-attachment-view.h
@@ -101,9 +101,6 @@ struct _EAttachmentViewPrivate {
/* Popup Menu Management */
GtkUIManager *ui_manager;
- GtkActionGroup *standard_actions;
- GtkActionGroup *editable_actions;
- GtkActionGroup *openwith_actions;
guint merge_id;
guint editable : 1;
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index a97ea1e70f..92ebd36be4 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -66,8 +66,10 @@ struct _EAttachmentPrivate {
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 @@ struct _EAttachmentPrivate {
enum {
PROP_0,
+ PROP_CAN_SHOW,
PROP_DISPOSITION,
PROP_ENCRYPTED,
PROP_FILE,
@@ -90,6 +93,7 @@ enum {
PROP_PERCENT,
PROP_REFERENCE,
PROP_SAVING,
+ PROP_SHOWN,
PROP_SIGNED
};
@@ -445,6 +449,12 @@ attachment_set_property (GObject *object,
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 @@ attachment_set_property (GObject *object,
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 @@ attachment_get_property (GObject *object,
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 @@ attachment_get_property (GObject *object,
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 @@ attachment_class_init (EAttachmentClass *class)
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 @@ attachment_class_init (EAttachmentClass *class)
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 @@ e_attachment_cancel (EAttachment *attachment)
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 @@ e_attachment_get_saving (EAttachment *attachment)
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)
{
diff --git a/widgets/misc/e-attachment.h b/widgets/misc/e-attachment.h
index 1184b32012..934e1e04b6 100644
--- a/widgets/misc/e-attachment.h
+++ b/widgets/misc/e-attachment.h
@@ -71,6 +71,9 @@ void e_attachment_add_to_multipart (EAttachment *attachment,
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 @@ GtkTreeRowReference *
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,