Enlightenment CVS committal
Author : codewarrior
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_dialog.c e_dialog.h e_actions.c
Log Message:
Added tab / focus support to e_dialog's buttons.
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dialog.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- e_dialog.c 23 Sep 2005 18:58:35 -0000 1.13
+++ e_dialog.c 24 Sep 2005 01:59:26 -0000 1.14
@@ -19,6 +19,7 @@
static void _e_dialog_free(E_Dialog *dia);
static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const
char *emission, const char *source);
static void _e_dialog_cb_delete(E_Win *win);
+static int _e_dialog_key_down_cb (void *data, int type, void *event);
/* local subsystem globals */
@@ -72,6 +73,9 @@
e_box_align_set(o, 0.5, 0.5);
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o);
evas_object_show(o);
+
+ dia->focused = NULL;
+ dia->key_down_handler = ecore_event_handler_add (ECORE_X_EVENT_KEY_DOWN,
_e_dialog_key_down_cb, dia);
return dia;
}
@@ -118,6 +122,31 @@
dia->buttons = evas_list_append(dia->buttons, db);
}
+int
+e_dialog_button_focus(E_Dialog *dia, int button)
+{
+ E_Dialog_Button *db = NULL;
+
+ db = evas_list_nth (dia->buttons, button);
+
+ if (!db)
+ return 0;
+
+ if (dia->focused)
+ {
+ E_Dialog_Button *focused;
+
+ focused = dia->focused->data;
+ if (focused)
+ edje_object_signal_emit(focused->obj, "unfocus", "");
+ }
+
+ dia->focused = evas_list_nth_list(dia->buttons, button);
+ edje_object_signal_emit(db->obj, "focus", "");
+
+ return 1;
+}
+
void
e_dialog_title_set(E_Dialog *dia, char *title)
{
@@ -187,6 +216,7 @@
if (dia->icon_object) evas_object_del(dia->icon_object);
if (dia->box_object) evas_object_del(dia->box_object);
if (dia->bg_object) evas_object_del(dia->bg_object);
+ ecore_event_handler_del (dia->key_down_handler);
e_object_del(E_OBJECT(dia->win));
free(dia);
}
@@ -203,6 +233,63 @@
e_object_del(E_OBJECT(db->dialog));
}
+/* TODO: Implement shift-tab and left arrow */
+static int
+_e_dialog_key_down_cb (void *data, int type, void *event)
+{
+ Ecore_X_Event_Key_Down *ev = event;
+ E_Dialog *dia = data;
+
+ if (!strcmp(ev->keyname, "Tab") || !strcmp(ev->keyname, "Right"))
+ {
+ if (dia->focused && dia->buttons)
+ {
+ if (dia->focused->next)
+ {
+ E_Dialog_Button *db;
+
+ db = dia->focused->data;
+ edje_object_signal_emit(db->obj, "unfocus", "");
+
+ dia->focused = dia->focused->next;
+ db = dia->focused->data;
+ edje_object_signal_emit(db->obj, "focus", "");
+
+ } else {
+
+ E_Dialog_Button *db;
+
+ db = dia->focused->data;
+ edje_object_signal_emit(db->obj, "unfocus", "");
+
+ dia->focused = dia->buttons;
+ db = evas_list_data (dia->focused);
+ edje_object_signal_emit(db->obj, "focus", "");
+ }
+ } else {
+
+ E_Dialog_Button *db;
+
+ dia->focused = dia->buttons;
+
+ db = dia->focused->data;
+ edje_object_signal_emit(db->obj, "focus", "");
+ }
+ return 1;
+ }
+
+ if ((!strcmp(ev->keyname, "Enter") || !strcmp(ev->keyname, "Return") ||
+ !strcmp(ev->keyname, "Space")) && dia->focused)
+ {
+ E_Dialog_Button *db;
+
+ db = evas_list_data (dia->focused);
+ edje_object_signal_emit(db->obj, "click", "");
+ }
+
+ return 1;
+}
+
static void
_e_dialog_cb_delete(E_Win *win)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e_dialog.h 19 Sep 2005 10:52:45 -0000 1.2
+++ e_dialog.h 24 Sep 2005 01:59:26 -0000 1.3
@@ -21,11 +21,14 @@
Evas_Object *text_object;
Evas_Object *icon_object;
Evas_List *buttons;
+ Evas_List *focused;
+ Ecore_Event_Handler *key_down_handler;
void *data;
};
EAPI E_Dialog *e_dialog_new (E_Container *con);
EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon,
void (*func) (void *data, E_Dialog *dia), void *data);
+EAPI int e_dialog_button_focus(E_Dialog *dia, int button);
EAPI void e_dialog_title_set (E_Dialog *dia, char *title);
EAPI void e_dialog_text_set (E_Dialog *dia, char *text);
EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord
size);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_actions.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- e_actions.c 23 Sep 2005 15:47:17 -0000 1.28
+++ e_actions.c 24 Sep 2005 01:59:26 -0000 1.29
@@ -1131,6 +1131,7 @@
e_dialog_icon_set(dia, "enlightenment/exit", 64);
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok,
NULL);
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
+ e_dialog_button_focus (dia, 1);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
}
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs