From 51cf52e71b6425a742adfef0c01e81299426c50d Mon Sep 17 00:00:00 2001 From: Bruce Tao Date: Thu, 4 Mar 2004 08:03:32 +0000 Subject: add a key-press event handler, with which a little modification to Paolo 2004-02-27 Bruce Tao * e-msg-composer-attachment-bar.c: add a key-press event handler, with which a little modification to Paolo Borelli's patch. When one attachment is deleted, the icon right after the last deleted one will be focused. svn path=/trunk/; revision=24959 --- composer/e-msg-composer-attachment-bar.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'composer/e-msg-composer-attachment-bar.c') diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index c2bad68332..c5993d0df4 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -331,7 +332,7 @@ remove_selected (EMsgComposerAttachmentBar *bar) GnomeIconList *icon_list; EMsgComposerAttachment *attachment; GList *attachment_list, *p; - int num; + int num = 0, left, dlen; icon_list = GNOME_ICON_LIST (bar); @@ -341,6 +342,7 @@ remove_selected (EMsgComposerAttachmentBar *bar) attachment_list = NULL; p = gnome_icon_list_get_selection (icon_list); + dlen = g_list_length (p); for ( ; p != NULL; p = p->next) { num = GPOINTER_TO_INT (p->data); attachment = E_MSG_COMPOSER_ATTACHMENT (g_list_nth_data (bar->priv->attachments, num)); @@ -360,6 +362,11 @@ remove_selected (EMsgComposerAttachmentBar *bar) g_list_free (attachment_list); update (bar); + + left = gnome_icon_list_get_num_icons (icon_list); + num = num - dlen + 1; + if (left > 0) + gnome_icon_list_focus_icon (icon_list, left > num ? num : left - 1); } static void @@ -597,6 +604,23 @@ button_press_event (GtkWidget *widget, return TRUE; } +static gint +key_press_event (GtkWidget *widget, GdkEventKey *event) +{ + EMsgComposerAttachmentBar *bar; + GnomeIconList *icon_list; + + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (widget); + icon_list = GNOME_ICON_LIST (bar); + + if (event->keyval == GDK_Delete) { + remove_selected (bar); + return TRUE; + } + + return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); +} + /* Initialization. */ @@ -617,6 +641,7 @@ class_init (EMsgComposerAttachmentBarClass *klass) widget_class->button_press_event = button_press_event; widget_class->popup_menu = popup_menu_event; + widget_class->key_press_event = key_press_event; /* Setup signals. */ -- cgit v1.2.3