diff options
author | Hao Sheng <hao.sheng@sun.com> | 2004-04-06 17:15:51 +0800 |
---|---|---|
committer | Yuedong Du <york@src.gnome.org> | 2004-04-06 17:15:51 +0800 |
commit | 056b964b59c8150cdb532a29d12179f0ac1b09f8 (patch) | |
tree | 4138b8465d8f5930f5ecfadb36276a4a2a502d18 /addressbook | |
parent | f24ee0c5c97a394027b636d639be56dec7a01fb6 (diff) | |
download | gsoc2013-evolution-056b964b59c8150cdb532a29d12179f0ac1b09f8.tar.gz gsoc2013-evolution-056b964b59c8150cdb532a29d12179f0ac1b09f8.tar.zst gsoc2013-evolution-056b964b59c8150cdb532a29d12179f0ac1b09f8.zip |
: implement keyboard navigation(TAB/shift+TAB) (activaite_editor) : add a
2004-04-06 Hao Sheng <hao.sheng@sun.com>
* gui/widgets/e-minicard.c :
(e_minicard_event) : implement keyboard navigation(TAB/shift+TAB)
(activaite_editor) : add a new function to activiate contact editor
for support "Enter" key
* gui/widgets/e-minicard-view-widget.c :
(e_minicard_view_widget_class_init) : set the default focus at
initialization
(e_minicard_view_widget_real_focus_in_event) : set the first item
be focused as default
Fixes #55056
svn path=/trunk/; revision=25332
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 14 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view-widget.c | 22 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 115 |
3 files changed, 126 insertions, 25 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index c1a07e0f9d..1da163d8ef 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,17 @@ +2004-04-06 Hao Sheng <hao.sheng@sun.com> + + * gui/widgets/e-minicard.c : + (e_minicard_event) : implement keyboard navigation(TAB/shift+TAB) + (activaite_editor) : add a new function to activiate contact editor + for support "Enter" key + * gui/widgets/e-minicard-view-widget.c : + (e_minicard_view_widget_class_init) : set the default focus at + initialization + (e_minicard_view_widget_real_focus_in_event) : set the first item + be focused as default + + Fixes #55056 + 2004-04-05 Chris Toshok <toshok@ximian.com> * util/eab-destination.h: wrap this with the correct #ifdef. diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c index ff1bdc1f06..1d7b9f55fc 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ b/addressbook/gui/widgets/e-minicard-view-widget.c @@ -39,6 +39,8 @@ static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocati static void e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style); static void e_minicard_view_widget_realize (GtkWidget *widget); +static gboolean e_minicard_view_widget_real_focus_in_event (GtkWidget *widget, GdkEventFocus *event); + static ECanvasClass *parent_class = NULL; /* The arguments we take */ @@ -158,6 +160,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass) widget_class->style_set = e_minicard_view_widget_style_set; widget_class->realize = e_minicard_view_widget_realize; widget_class->size_allocate = e_minicard_view_widget_size_allocate; + widget_class->focus_in_event = e_minicard_view_widget_real_focus_in_event; canvas_class->reflow = e_minicard_view_widget_reflow; @@ -166,6 +169,25 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass) klass->right_click = NULL; } +static gboolean +e_minicard_view_widget_real_focus_in_event(GtkWidget *widget, GdkEventFocus *event) +{ + GnomeCanvas *canvas; + EMinicardViewWidget *view; + + canvas = GNOME_CANVAS (widget); + view = E_MINICARD_VIEW_WIDGET(widget); + + if (!canvas->focused_item) { + EReflow *reflow = E_REFLOW (view->emv); + int unsorted = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), 0); + + canvas->focused_item = reflow->items [unsorted]; + } + + return GTK_WIDGET_CLASS(parent_class)->focus_in_event (widget, event); + } + static void e_minicard_view_widget_init (EMinicardViewWidget *view) { diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index c587d9764e..36038eef48 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -519,6 +519,44 @@ editor_closed_cb (GtkObject *editor, gpointer data) } static gboolean +activiate_editor(GnomeCanvasItem *item) +{ + EMinicard *e_minicard; + e_minicard = E_MINICARD (item); + + if (e_minicard->editor) { + eab_editor_raise (e_minicard->editor); + } + else { + EBook *book = NULL; + if (E_IS_MINICARD_VIEW(item->parent)) { + g_object_get(item->parent, "book", &book, NULL); + } + + if (book != NULL) { + if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) { + EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact, + FALSE, e_minicard->editable); + e_minicard->editor = G_OBJECT (editor); + } + else { + EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact, + FALSE, e_minicard->editable); + e_minicard->editor = G_OBJECT (editor); + } + + g_object_ref (e_minicard->editor); + g_signal_connect (e_minicard->editor, "editor_closed", + G_CALLBACK (editor_closed_cb), e_minicard); + + g_object_unref (book); + } + } + + return TRUE; +} + +static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) { EMinicard *e_minicard; @@ -601,36 +639,63 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) break; case GDK_2BUTTON_PRESS: if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - if (e_minicard->editor) { - eab_editor_raise (e_minicard->editor); - } else { - EBook *book = NULL; - if (E_IS_MINICARD_VIEW(item->parent)) { - g_object_get(item->parent, - "book", &book, - NULL); - } + return activiate_editor(item); + } + break; + case GDK_KEY_PRESS: + if (event->key.keyval == GDK_Tab || + event->key.keyval == GDK_KP_Tab || + event->key.keyval == GDK_ISO_Left_Tab) { - if (book != NULL) { - if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) { - EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact, - FALSE, e_minicard->editable); - e_minicard->editor = EAB_EDITOR (editor); - } - else { - EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact, - FALSE, e_minicard->editable); - e_minicard->editor = EAB_EDITOR (editor); - } - g_object_ref (e_minicard->editor); + EMinicardView *view = E_MINICARD_VIEW(item->parent); + EReflow *reflow = E_REFLOW(view); - g_signal_connect (e_minicard->editor, "editor_closed", - G_CALLBACK (editor_closed_cb), e_minicard); + if (reflow == NULL) { + return FALSE; + } - g_object_unref (book); + if (event->key.state & GDK_SHIFT_MASK) { + if (event->key.state & GDK_CONTROL_MASK) { + return FALSE; + } + else { + int row_count = e_selection_model_row_count(reflow->selection); + int model_index = e_selection_model_cursor_row (reflow->selection); + int view_index = e_sorter_model_to_sorted (reflow->selection->sorter, model_index); + + if (view_index == 0) + view_index = row_count-1; + else + view_index--; + + model_index = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), view_index); + e_canvas_item_grab_focus(reflow->items[model_index], FALSE); + return TRUE; + } + } + else { + if (event->key.state & GDK_CONTROL_MASK) { + return FALSE; + } + else { + int row_count = e_selection_model_row_count(reflow->selection); + int model_index = e_selection_model_cursor_row (reflow->selection); + int view_index = e_sorter_model_to_sorted (reflow->selection->sorter, model_index); + + if (view_index == row_count-1) + view_index = 0; + else + view_index++; + + model_index = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), view_index); + e_canvas_item_grab_focus(reflow->items[model_index], FALSE); + return TRUE; } } - return TRUE; + } + else if (event->key.keyval == GDK_Return || + event->key.keyval == GDK_KP_Enter) { + return activiate_editor(item); } break; default: |