aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer-attachment-bar.c27
2 files changed, 33 insertions, 1 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index a2be3658e4..201b395f50 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
2004-02-26 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer.c (set_editor_text): Add a <br> tag between the
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. */