From: <enl...@li...> - 2005-10-14 08:34:18
|
Enlightenment CVS committal Author : raster Project : e17 Module : apps/e Dir : e17/apps/e/src/bin Modified Files: e_config_dialog.c e_config_dialog.h e_int_config_focus.c Log Message: addressing some cfdialog issues =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config_dialog.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_config_dialog.c 14 Oct 2005 04:18:01 -0000 1.3 +++ e_config_dialog.c 14 Oct 2005 08:34:12 -0000 1.4 @@ -3,13 +3,6 @@ */ #include "e.h" -/* FIXME: - * * Having 2 cfdata creates is useless. roll the basic and advanced into 1 and - * simply have 2 different views on the same dataset - * * We have no way of associating this config data WITH another object (like - * a window border) so we need a way to pass that in. - */ - /* 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); @@ -24,15 +17,15 @@ /* 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_new(E_Container *con, char *title, E_Config_Dialog_View *view, void *data) { 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->view = *view; cfd->con = con; cfd->title = strdup(title); + cfd->data = data; _e_config_dialog_go(cfd, E_CONFIG_DIALOG_CFDATA_TYPE_BASIC); @@ -47,10 +40,7 @@ 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->view.free_cfdata(cfd, cfd->cfdata); cfd->cfdata = NULL; } if (cfd->dia) @@ -65,52 +55,47 @@ 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 (!cfd->cfdata) cfd->cfdata = cfd->view.create_cfdata(cfd); if (type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) { - cfd->cfdata = cfd->basic.create_cfdata(pdata, cfd->view_type); - if (cfd->advanced.free_cfdata) + if (cfd->view.advanced.create_widgets) { - 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); + ob = cfd->view.basic.create_widgets(cfd, 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, + _("Advanced Settings"), 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); + o = cfd->view.basic.create_widgets(cfd, 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 (cfd->view.basic.create_widgets) { - 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); + ob = cfd->view.advanced.create_widgets(cfd, 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, + _("Basic Settings"), 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); + o = cfd->view.advanced.create_widgets(cfd, e_win_evas_get(cfd->dia->win), cfd->cfdata); } e_widget_min_size_get(o, &mw, &mh); @@ -148,9 +133,9 @@ cfd = dia->data; if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) - cfd->basic.apply_cfdata(cfd->cfdata); + cfd->view.basic.apply_cfdata(cfd, cfd->cfdata); else - cfd->advanced.apply_cfdata(cfd->cfdata); + cfd->view.advanced.apply_cfdata(cfd, cfd->cfdata); e_object_del(E_OBJECT(cfd)); } @@ -161,9 +146,9 @@ cfd = dia->data; if (cfd->view_type == E_CONFIG_DIALOG_CFDATA_TYPE_BASIC) - cfd->basic.apply_cfdata(cfd->cfdata); + cfd->view.basic.apply_cfdata(cfd, cfd->cfdata); else - cfd->advanced.apply_cfdata(cfd->cfdata); + cfd->view.advanced.apply_cfdata(cfd, cfd->cfdata); } static void =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config_dialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_config_dialog.h 13 Oct 2005 15:15:27 -0000 1.1 +++ e_config_dialog.h 14 Oct 2005 08:34:12 -0000 1.2 @@ -20,10 +20,12 @@ 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); + void *(*create_cfdata) (E_Config_Dialog *cfd); + void (*free_cfdata) (E_Config_Dialog *cfd, void *cfdata); + struct { + void (*apply_cfdata) (E_Config_Dialog *cfd, void *cfdata); + Evas_Object *(*create_widgets) (E_Config_Dialog *cfd, Evas *evas, void *cfdata); + } basic, advanced; }; struct _E_Config_Dialog @@ -31,14 +33,15 @@ E_Object e_obj_inherit; E_Config_Dialog_CFData_Type view_type; - E_Config_Dialog_View basic, advanced; + E_Config_Dialog_View view; void *cfdata; E_Container *con; char *title; E_Dialog *dia; + void *data; }; -EAPI E_Config_Dialog *e_config_dialog_new(E_Container *con, char *title, E_Config_Dialog_View *basic, E_Config_Dialog_View *advanced); +EAPI E_Config_Dialog *e_config_dialog_new(E_Container *con, char *title, E_Config_Dialog_View *view, void *data); #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_int_config_focus.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_int_config_focus.c 13 Oct 2005 15:15:27 -0000 1.1 +++ e_int_config_focus.c 14 Oct 2005 08:34:12 -0000 1.2 @@ -3,72 +3,74 @@ */ #include "e.h" -#define MD_CLICK 0 -#define MD_MOUSE 1 -#define MD_SLOPPY 2 -typedef struct _A_CFData { +/* PROTOTYPES */ +typedef struct _CFData CFData; + +static void *_create_data(E_Config_Dialog *cfd); +static void _free_data(E_Config_Dialog *cfd, CFData *cfdata); +static void _basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata); +static void _advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata); +static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata); +static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata); + +struct _CFData +{ + /*- BASIC -*/ + int mode; + /*- ADVANCED -*/ 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; + E_Config_Dialog_View v; + + /* methods */ + v.create_cfdata = _create_data; + v.free_cfdata = _free_data; + v.basic.apply_cfdata = _basic_apply_data; + v.basic.create_widgets = _basic_create_widgets; + v.advanced.apply_cfdata = _advanced_apply_data; + v.advanced.create_widgets = _advanced_create_widgets; + /* create config diaolg for NULL object/data */ + cfd = e_config_dialog_new(con, _("Focus Settings"), &v, NULL); +} + +/**--CREATE--**/ +static void * +_create_data(E_Config_Dialog *cfd) +{ + CFData *cfdata; + + cfdata = E_NEW(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; + + cfdata->mode = cfdata->focus_policy; - 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) { + +static void +_free_data(E_Config_Dialog *cfd, CFData *cfdata) +{ free(cfdata); } -static void _b_apply_data(B_CFData *cfdata) { + +/**--APPLY--**/ +static void +_basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata) +{ e_border_button_bindings_ungrab_all(); - if (cfdata->mode == MD_CLICK) + if (cfdata->mode == E_FOCUS_CLICK) { e_config->focus_policy = E_FOCUS_CLICK; e_config->focus_setting = E_FOCUS_NEW_WINDOW; @@ -76,7 +78,7 @@ e_config->always_click_to_raise = 0; e_config->always_click_to_focus = 0; } - else if (cfdata->mode == MD_MOUSE) + else if (cfdata->mode == E_FOCUS_MOUSE) { e_config->focus_policy = E_FOCUS_MOUSE; e_config->focus_setting = E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED; @@ -95,36 +97,10 @@ 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) { +static void +_advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata) +{ e_border_button_bindings_ungrab_all(); e_config->focus_policy = cfdata->focus_policy; e_config->focus_setting = cfdata->focus_setting; @@ -134,9 +110,30 @@ e_border_button_bindings_grab_all(); e_config_save_queue(); } -static Evas_Object *_a_create_widgets(Evas *evas, A_CFData *cfdata) { + +/**--GUI--**/ +static Evas_Object * +_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, 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"), E_FOCUS_CLICK, rg); + e_widget_list_object_append(o, ob, 1, 1, 0.5); + ob = e_widget_radio_add(evas, _("Window under the Mouse"), E_FOCUS_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"), E_FOCUS_SLOPPY, rg); + e_widget_list_object_append(o, ob, 1, 1, 0.5); + return o; +} + +static Evas_Object * +_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, 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); |