From: Carsten Haitzler Date: Thu, 13 Oct 2005 15:15:27 +0000 (+0000) Subject: first gui config dialog... quickly snuck into the menu - shoudl go in panel X-Git-Tag: submit/efl/20131021.015651~14773 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d0b7433872859333dcd88a95f994f11abcc3586;p=platform%2Fupstream%2Fenlightenment.git first gui config dialog... quickly snuck into the menu - shoudl go in panel tho.... SVN revision: 17511 --- diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index c1c317d..b5a1aa0 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -91,7 +91,9 @@ e_widget_list.h \ e_widget_button.h \ e_widget_label.h \ e_widget_frametable.h \ -e_widget_table.h +e_widget_table.h \ +e_config_dialog.h \ +e_int_config_focus.h enlightenment_src = \ e_user.c \ @@ -165,6 +167,8 @@ e_widget_button.c \ e_widget_label.c \ e_widget_frametable.c \ e_widget_table.c \ +e_config_dialog.c \ +e_int_config_focus.c \ $(ENLIGHTENMENTHEADERS) enlightenment_SOURCES = \ diff --git a/src/bin/e_config_dialog.c b/src/bin/e_config_dialog.c new file mode 100644 index 0000000..81a1778 --- /dev/null +++ b/src/bin/e_config_dialog.c @@ -0,0 +1,178 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +/* local subsystem functions */ +static void _e_config_dialog_free(E_Config_Dialog *cfd); +static void _e_config_dialog_go(E_Config_Dialog *cfd, E_Config_Dialog_CFData_Type type); +static void _e_config_dialog_cb_dialog_del(void *obj); +static void _e_config_dialog_cb_ok(void *data, E_Dialog *dia); +static void _e_config_dialog_cb_apply(void *data, E_Dialog *dia); +static void _e_config_dialog_cb_advanced(void *data, void *data2); +static void _e_config_dialog_cb_basic(void *data, void *data2); + +/* local subsystem globals */ + +/* externally accessible functions */ + +E_Config_Dialog * +e_config_dialog_new(E_Container *con, char *title, E_Config_Dialog_View *basic, E_Config_Dialog_View *advanced) +{ + E_Config_Dialog *cfd; + + cfd = E_OBJECT_ALLOC(E_Config_Dialog, E_CONFIG_DIALOG_TYPE, _e_config_dialog_free); + cfd->basic = *basic; + if (advanced) cfd->advanced = *advanced; + cfd->con = con; + cfd->title = strdup(title); + + _e_config_dialog_go(cfd, E_CONFIG_DIALOG_CFDATA_TYPE_BASIC); + + return cfd; +} + +/* local subsystem functions */ + +static void +_e_config_dialog_free(E_Config_Dialog *cfd) +{ + E_FREE(cfd->title); + if (cfd->cfdata) + { + if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) + cfd->basic.free_cfdata(cfd->cfdata); + else + cfd->advanced.free_cfdata(cfd->cfdata); + cfd->cfdata = NULL; + } + if (cfd->dia) + { + e_object_del_attach_func_set(E_OBJECT(cfd->dia), NULL); + e_object_del(E_OBJECT(cfd->dia)); + cfd->dia = NULL; + } + free(cfd); +} + +static void +_e_config_dialog_go(E_Config_Dialog *cfd, E_Config_Dialog_CFData_Type type) +{ + void *pdata; + E_Dialog *pdia; + Evas_Object *o, *ob; + Evas_Coord mw = 0, mh = 0; + + pdata = cfd->cfdata; + pdia = cfd->dia; + + cfd->dia = e_dialog_new(cfd->con); + cfd->dia->data = cfd; + e_object_del_attach_func_set(E_OBJECT(cfd->dia), _e_config_dialog_cb_dialog_del); + e_dialog_title_set(cfd->dia, cfd->title); + + if (type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) + { + cfd->cfdata = cfd->basic.create_cfdata(pdata, cfd->view_type); + if (cfd->advanced.free_cfdata) + { + if (pdata) cfd->advanced.free_cfdata(pdata); + o = e_widget_list_add(e_win_evas_get(cfd->dia->win), 0, 0); + ob = cfd->basic.create_widgets(e_win_evas_get(cfd->dia->win), cfd->cfdata); + e_widget_list_object_append(o, ob, 1, 1, 0.0); + ob = e_widget_button_add(e_win_evas_get(cfd->dia->win), + "Advanced...", NULL, + _e_config_dialog_cb_advanced, cfd, NULL); + e_widget_list_object_append(o, ob, 0, 0, 1.0); + } + else + o = cfd->basic.create_widgets(e_win_evas_get(cfd->dia->win), cfd->cfdata); + } + else + { + cfd->cfdata = cfd->advanced.create_cfdata(pdata, cfd->view_type); + if (cfd->basic.free_cfdata) + { + if (pdata) cfd->basic.free_cfdata(pdata); + o = e_widget_list_add(e_win_evas_get(cfd->dia->win), 0, 0); + ob = cfd->advanced.create_widgets(e_win_evas_get(cfd->dia->win), cfd->cfdata); + e_widget_list_object_append(o, ob, 1, 1, 0.0); + ob = e_widget_button_add(e_win_evas_get(cfd->dia->win), + "Basic...", NULL, + _e_config_dialog_cb_basic, cfd, NULL); + e_widget_list_object_append(o, ob, 0, 0, 1.0); + } + else + o = cfd->advanced.create_widgets(e_win_evas_get(cfd->dia->win), cfd->cfdata); + } + + e_widget_min_size_get(o, &mw, &mh); + e_dialog_content_set(cfd->dia, o, mw, mh); + + e_dialog_button_add(cfd->dia, "OK", NULL, _e_config_dialog_cb_ok, cfd); + e_dialog_button_add(cfd->dia, "Apply", NULL, _e_config_dialog_cb_apply, cfd); + e_dialog_button_add(cfd->dia, "Cancel", NULL, NULL, NULL); + e_win_centered_set(cfd->dia->win, 1); + e_dialog_show(cfd->dia); + cfd->view_type = type; + if (pdia) + { + e_object_del_attach_func_set(E_OBJECT(pdia), NULL); + e_object_del(E_OBJECT(pdia)); + } +} + +static void +_e_config_dialog_cb_dialog_del(void *obj) +{ + E_Dialog *dia; + E_Config_Dialog *cfd; + + dia = obj; + cfd = dia->data; + cfd->dia = NULL; + e_object_del(E_OBJECT(cfd)); +} + +static void +_e_config_dialog_cb_ok(void *data, E_Dialog *dia) +{ + E_Config_Dialog *cfd; + + cfd = dia->data; + if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) + cfd->basic.apply_cfdata(cfd->cfdata); + else + cfd->advanced.apply_cfdata(cfd->cfdata); + e_object_del(E_OBJECT(cfd)); +} + +static void +_e_config_dialog_cb_apply(void *data, E_Dialog *dia) +{ + E_Config_Dialog *cfd; + + cfd = dia->data; + if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) + cfd->basic.apply_cfdata(cfd->cfdata); + else + cfd->advanced.apply_cfdata(cfd->cfdata); +} + +static void +_e_config_dialog_cb_advanced(void *data, void *data2) +{ + E_Config_Dialog *cfd; + + cfd = data; + _e_config_dialog_go(cfd, E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED); +} + +static void +_e_config_dialog_cb_basic(void *data, void *data2) +{ + E_Config_Dialog *cfd; + + cfd = data; + _e_config_dialog_go(cfd, E_CONFIG_DIALOG_CFDATA_TYPE_BASIC); +} diff --git a/src/bin/e_config_dialog.h b/src/bin/e_config_dialog.h new file mode 100644 index 0000000..5324849 --- /dev/null +++ b/src/bin/e_config_dialog.h @@ -0,0 +1,44 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS + +typedef enum _E_Config_Dialog_CFData_Type +{ + E_CONFIG_DIALOG_CFDATA_TYPE_BASIC, + E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED +} E_Config_Dialog_CFData_Type; + +typedef struct _E_Config_Dialog E_Config_Dialog; +typedef struct _E_Config_Dialog_View E_Config_Dialog_View; + +#else +#ifndef E_CONFIG_DIALOG_H +#define E_CONFIG_DIALOG_H + +#define E_CONFIG_DIALOG_TYPE 0xE0b01017 + +struct _E_Config_Dialog_View +{ + void *(*create_cfdata) (void *cfdata_other, E_Config_Dialog_CFData_Type type_other); + void (*free_cfdata) (void *cfdata); + void (*apply_cfdata) (void *cfdata); + Evas_Object *(*create_widgets) (Evas *evas, void *cfdata); +}; + +struct _E_Config_Dialog +{ + E_Object e_obj_inherit; + + E_Config_Dialog_CFData_Type view_type; + E_Config_Dialog_View basic, advanced; + void *cfdata; + E_Container *con; + char *title; + E_Dialog *dia; +}; + +EAPI E_Config_Dialog *e_config_dialog_new(E_Container *con, char *title, E_Config_Dialog_View *basic, E_Config_Dialog_View *advanced); + +#endif +#endif diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index b641321..fa73844 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -73,3 +73,5 @@ #include "e_widget_label.h" #include "e_widget_frametable.h" #include "e_widget_table.h" +#include "e_config_dialog.h" +#include "e_int_config_focus.h" diff --git a/src/bin/e_int_config_focus.c b/src/bin/e_int_config_focus.c new file mode 100644 index 0000000..c759039 --- /dev/null +++ b/src/bin/e_int_config_focus.c @@ -0,0 +1,174 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +#define MD_CLICK 0 +#define MD_MOUSE 1 +#define MD_SLOPPY 2 +typedef struct _A_CFData { + int focus_policy; + int focus_setting; + int pass_click_on; + int always_click_to_raise; + int always_click_to_focus; +} A_CFData; +typedef struct _B_CFData { + int mode; + A_CFData advanced; +} B_CFData; + +/*** BEGIN template ***/ +static void *_b_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other); +static void _b_free_data(B_CFData *cfdata); +static void _b_apply_data(B_CFData *cfdata); +static Evas_Object *_b_create_widgets(Evas *evas, B_CFData *cfdata); +static void *_a_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other); +static void _a_free_data(A_CFData *cfdata); +static void _a_apply_data(A_CFData *cfdata); +static Evas_Object *_a_create_widgets(Evas *evas, A_CFData *cfdata); + +void e_int_config_focus(E_Container *con) +{ + E_Config_Dialog *cfd; + E_Config_Dialog_View a, b; + + b.create_cfdata = _b_create_data; + b.free_cfdata = _b_free_data; + b.apply_cfdata = _b_apply_data; + b.create_widgets = _b_create_widgets; + a.create_cfdata = _a_create_data; + a.free_cfdata = _a_free_data; + a.apply_cfdata = _a_apply_data; + a.create_widgets = _a_create_widgets; + cfd = e_config_dialog_new(con, _("Focus Settings"), &b, &a); +} +/*** END template ***/ + +static void *_b_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other) { + B_CFData *cfdata; + cfdata = E_NEW(B_CFData, 1); + + cfdata->advanced.focus_policy = e_config->focus_policy; + cfdata->advanced.focus_setting = e_config->focus_setting; + cfdata->advanced.pass_click_on = e_config->pass_click_on; + cfdata->advanced.always_click_to_raise = e_config->always_click_to_raise; + cfdata->advanced.always_click_to_focus = e_config->always_click_to_focus; + + if (cfdata->advanced.focus_policy == E_FOCUS_CLICK) + cfdata->mode = MD_CLICK; + else if (cfdata->advanced.focus_policy == E_FOCUS_MOUSE) + cfdata->mode = MD_MOUSE; + else + cfdata->mode = MD_SLOPPY; + return cfdata; +} +static void _b_free_data(B_CFData *cfdata) { + free(cfdata); +} +static void _b_apply_data(B_CFData *cfdata) { + e_border_button_bindings_ungrab_all(); + if (cfdata->mode == MD_CLICK) + { + e_config->focus_policy = E_FOCUS_CLICK; + e_config->focus_setting = E_FOCUS_NEW_WINDOW; + e_config->pass_click_on = 1; + e_config->always_click_to_raise = 0; + e_config->always_click_to_focus = 0; + } + else if (cfdata->mode == MD_MOUSE) + { + e_config->focus_policy = E_FOCUS_MOUSE; + e_config->focus_setting = E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED; + e_config->pass_click_on = 1; + e_config->always_click_to_raise = 0; + e_config->always_click_to_focus = 0; + } + else + { + e_config->focus_policy = E_FOCUS_SLOPPY; + e_config->focus_setting = E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED; + e_config->pass_click_on = 1; + e_config->always_click_to_raise = 0; + e_config->always_click_to_focus = 0; + } + e_border_button_bindings_grab_all(); + e_config_save_queue(); +} +static Evas_Object *_b_create_widgets(Evas *evas, B_CFData *cfdata) { + Evas_Object *o, *ob; + E_Radio_Group *rg; + o = e_widget_list_add(evas, 0, 0); + rg = e_widget_radio_group_new(&(cfdata->mode)); + ob = e_widget_radio_add(evas, _("Click Window to Focus"), MD_CLICK, rg); + e_widget_list_object_append(o, ob, 1, 1, 0.5); + ob = e_widget_radio_add(evas, _("Window under the Mouse"), MD_MOUSE, rg); + e_widget_list_object_append(o, ob, 1, 1, 0.5); + ob = e_widget_radio_add(evas, _("Most recent Window under the Mouse"), MD_SLOPPY, rg); + e_widget_list_object_append(o, ob, 1, 1, 0.5); + return o; +} + +static void *_a_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other) { + A_CFData *cfdata; + cfdata = E_NEW(A_CFData, 1); + + cfdata->focus_policy = e_config->focus_policy; + cfdata->focus_setting = e_config->focus_setting; + cfdata->pass_click_on = e_config->pass_click_on; + cfdata->always_click_to_raise = e_config->always_click_to_raise; + cfdata->always_click_to_focus = e_config->always_click_to_focus; + + return cfdata; +} +static void _a_free_data(A_CFData *cfdata) { + free(cfdata); +} +static void _a_apply_data(A_CFData *cfdata) { + e_border_button_bindings_ungrab_all(); + e_config->focus_policy = cfdata->focus_policy; + e_config->focus_setting = cfdata->focus_setting; + e_config->pass_click_on = cfdata->pass_click_on; + e_config->always_click_to_raise = cfdata->always_click_to_raise; + e_config->always_click_to_focus = cfdata->always_click_to_focus; + e_border_button_bindings_grab_all(); + e_config_save_queue(); +} +static Evas_Object *_a_create_widgets(Evas *evas, A_CFData *cfdata) { + Evas_Object *o, *ob, *of; + E_Radio_Group *rg; + o = e_widget_list_add(evas, 0, 0); + + of = e_widget_framelist_add(evas, _("Focus"), 0); + rg = e_widget_radio_group_new(&(cfdata->focus_policy)); + ob = e_widget_radio_add(evas, _("Click to focus"), E_FOCUS_CLICK, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("Pointer focus"), E_FOCUS_MOUSE, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("Sloppy focus"), E_FOCUS_SLOPPY, rg); + e_widget_framelist_object_append(of, ob); + e_widget_list_object_append(o, of, 1, 1, 0.5); + + of = e_widget_framelist_add(evas, _("New Window Focus"), 0); + rg = e_widget_radio_group_new(&(cfdata->focus_setting)); + ob = e_widget_radio_add(evas, _("No new windows get focus"), E_FOCUS_NONE, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("All new windows get focus"), E_FOCUS_NEW_WINDOW, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("Only new dialogs get focus"), E_FOCUS_NEW_DIALOG, rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("Only new dialogs get focus if the parent has focus"), E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED, rg); + e_widget_framelist_object_append(of, ob); + e_widget_list_object_append(o, of, 1, 1, 0.5); + + of = e_widget_framelist_add(evas, _("Other Settings"), 0); + ob = e_widget_check_add(evas, _("Always pass on caught click events to programs"), &(cfdata->pass_click_on)); + e_widget_framelist_object_append(of, ob); + ob = e_widget_check_add(evas, _("A click on a window always raises it"), &(cfdata->always_click_to_raise)); + e_widget_framelist_object_append(of, ob); + ob = e_widget_check_add(evas, _("A click in a window always focuses it"), &(cfdata->always_click_to_focus)); + e_widget_framelist_object_append(of, ob); + e_widget_list_object_append(o, of, 1, 1, 0.5); + + return o; +} diff --git a/src/bin/e_int_config_focus.h b/src/bin/e_int_config_focus.h new file mode 100644 index 0000000..5668cba --- /dev/null +++ b/src/bin/e_int_config_focus.h @@ -0,0 +1,12 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS +#else +#ifndef E_INT_CONFIG_FOCUS_H +#define E_INT_CONFIG_FOCUS_H + +EAPI void e_int_config_focus(E_Container *con); + +#endif +#endif diff --git a/src/bin/e_int_menus.c b/src/bin/e_int_menus.c index df654bb..a9508af 100644 --- a/src/bin/e_int_menus.c +++ b/src/bin/e_int_menus.c @@ -36,6 +36,7 @@ static void _e_int_menus_main_fm(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_int_menus_config_pre_cb (void *data, E_Menu *m); static void _e_int_menus_config_free_hook (void *obj); static void _e_int_menus_config_item_cb (void *data, E_Menu *m, E_Menu_Item *mi); +static void _e_int_menus_config_generic_cb (void *data, E_Menu *m, E_Menu_Item *mi); static void _e_int_menus_clients_pre_cb (void *data, E_Menu *m); static void _e_int_menus_clients_free_hook (void *obj); static void _e_int_menus_clients_item_cb (void *data, E_Menu *m, E_Menu_Item *mi); @@ -607,6 +608,10 @@ _e_int_menus_config_pre_cb(void *data, E_Menu *m) e_menu_item_label_set(mi, _("Configuration Panel")); e_menu_item_callback_set(mi, _e_int_menus_config_item_cb, NULL); + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, _("Focus Settings")); + e_menu_item_callback_set(mi, _e_int_menus_config_generic_cb, "focus"); + l = evas_hash_find(_e_int_menus_augmentation, "config"); if (l) { @@ -636,6 +641,12 @@ _e_int_menus_config_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) } static void +_e_int_menus_config_generic_cb(void *data, E_Menu *m, E_Menu_Item *mi) +{ + if (!strcmp((char *)data, "focus")) e_int_config_focus(m->zone->container); +} + +static void _e_int_menus_clients_pre_cb(void *data, E_Menu *m) { E_Menu_Item *mi; diff --git a/src/bin/e_test.c b/src/bin/e_test.c index 99e0698..3141a0d 100644 --- a/src/bin/e_test.c +++ b/src/bin/e_test.c @@ -405,6 +405,81 @@ _e_test_internal(E_Container *con) e_dialog_show(dia); } #elif 0 + +typedef struct _B_CFData { + int val; +} B_CFData; +typedef struct _A_CFData { + int val2; +} A_CFData; + +static void *_b_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other); +static void _b_free_data(B_CFData *cfdata); +static void _b_apply_data(B_CFData *cfdata); +static Evas_Object *_b_create_widgets(Evas *evas, B_CFData *cfdata); +static void *_a_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other); +static void _a_free_data(A_CFData *cfdata); +static void _a_apply_data(A_CFData *cfdata); +static Evas_Object *_a_create_widgets(Evas *evas, A_CFData *cfdata); + +static void *_b_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other) { + B_CFData *cfdata; + cfdata = E_NEW(B_CFData, 1); + if (cfdata_other) cfdata->val = ((A_CFData *)cfdata_other)->val2; + return cfdata; +} +static void _b_free_data(B_CFData *cfdata) { + printf("FREE BASIC\n"); + free(cfdata); +} +static void _b_apply_data(B_CFData *cfdata) { + printf("APPLY BASIC %i\n", cfdata->val); +} +static Evas_Object *_b_create_widgets(Evas *evas, B_CFData *cfdata) { + Evas_Object *o, *ob; + o = e_widget_framelist_add(evas, "Basic Options", 0); + ob = e_widget_check_add(evas, "Basic Checkbox", &(cfdata->val)); + e_widget_framelist_object_append(o, ob); + return o; +} + +static void *_a_create_data(void *cfdata_other, E_Config_Dialog_CFData_Type type_other) { + A_CFData *cfdata; + cfdata = E_NEW(A_CFData, 1); + if (cfdata_other) cfdata->val2 = ((B_CFData *)cfdata_other)->val; + return cfdata; +} +static void _a_free_data(A_CFData *cfdata) { + printf("FREE ADVANCED\n"); + free(cfdata); +} +static void _a_apply_data(A_CFData *cfdata) { + printf("APPLY ADVANCED %i\n", cfdata->val2); +} +static Evas_Object *_a_create_widgets(Evas *evas, A_CFData *cfdata) { + Evas_Object *o, *ob; + o = e_widget_framelist_add(evas, "Advanced Options", 0); + ob = e_widget_check_add(evas, "Advanced Checkbox", &(cfdata->val2)); + e_widget_framelist_object_append(o, ob); + return o; +} + +static void +_e_test_internal(E_Container *con) +{ + E_Config_Dialog *cfd; + E_Config_Dialog_View a, b; + + b.create_cfdata = _b_create_data; + b.free_cfdata = _b_free_data; + b.apply_cfdata = _b_apply_data; + b.create_widgets = _b_create_widgets; + a.create_cfdata = _a_create_data; + a.free_cfdata = _a_free_data; + a.apply_cfdata = _a_apply_data; + a.create_widgets = _a_create_widgets; + cfd = e_config_dialog_new(con, "A test dialog", &b, &a); +} #else static void _e_test_internal(E_Container *con)