diff options
author | Bruce Tao <bruce.tao@sun.com> | 2004-03-04 16:03:32 +0800 |
---|---|---|
committer | Yuedong Du <york@src.gnome.org> | 2004-03-04 16:03:32 +0800 |
commit | 51cf52e71b6425a742adfef0c01e81299426c50d (patch) | |
tree | 5304699cc5f2f9d8624c30825c8fdb7cdcd5212a /composer/e-msg-composer-attachment-bar.c | |
parent | d1a4e3aa277d9cdd3c696af3ede9f206ce0f66f3 (diff) | |
download | gsoc2013-evolution-51cf52e71b6425a742adfef0c01e81299426c50d.tar.gz gsoc2013-evolution-51cf52e71b6425a742adfef0c01e81299426c50d.tar.zst gsoc2013-evolution-51cf52e71b6425a742adfef0c01e81299426c50d.zip |
add a key-press event handler, with which a little modification to Paolo
2004-02-27 Bruce Tao <bruce.tao@sun.com>
* e-msg-composer-attachment-bar.c: add a key-press event handler,
with which a little modification to Paolo Borelli's patch.
<pborelli@katamail.com> When one attachment is deleted, the
icon right after the last deleted one will be focused.
svn path=/trunk/; revision=24959
Diffstat (limited to 'composer/e-msg-composer-attachment-bar.c')
-rw-r--r-- | composer/e-msg-composer-attachment-bar.c | 27 |
1 files changed, 26 insertions, 1 deletions
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 <glade/glade.h> #include <gconf/gconf.h> #include <gconf/gconf-client.h> +#include <gdk/gdkkeysyms.h> #include <libgnome/gnome-util.h> #include <libgnomeui/gnome-app.h> #include <libgnomeui/gnome-app-helper.h> @@ -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. */ |