q66 pushed a commit to branch master. http://git.enlightenment.org/enlightenment/modules/tclock.git/commit/?id=2b57ff648b27cc174501d327c2c580dc6d014ac2
commit 2b57ff648b27cc174501d327c2c580dc6d014ac2 Author: Daniel Kolesa <d.kol...@samsung.com> Date: Mon Jan 26 17:18:30 2015 +0000 convert config dialog to elementary --- src/e_mod_config.c | 251 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 160 insertions(+), 91 deletions(-) diff --git a/src/e_mod_config.c b/src/e_mod_config.c index 98f66fc..9272af9 100644 --- a/src/e_mod_config.c +++ b/src/e_mod_config.c @@ -3,8 +3,10 @@ struct _E_Config_Dialog_Data { - int show_date, show_time, show_tip; - char *time_format, *date_format, *tip_format; + E_Config_Dialog *cfd; + Eina_Bool show_time, show_date, show_tip; + Evas_Object *time_entry, *date_entry, *tip_entry; + const char *time_format, *date_format, *tip_format; }; /* Protos */ @@ -12,9 +14,12 @@ static void *_create_data(E_Config_Dialog *cfd); static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata); static Evas_Object *_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata); static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -static void _cb_time_check(void *data, Evas_Object *obj); -static void _cb_date_check(void *data, Evas_Object *obj); -static void _cb_tooltip_check(void *data, Evas_Object *obj); + +static void +_cb_changed(void *data, Evas_Object *obj, void *event __UNUSED__) +{ + e_config_dialog_changed_set(((E_Config_Dialog_Data *)data)->cfd, EINA_TRUE); +} void _config_tclock_module(Config_Item *ci) @@ -46,9 +51,9 @@ _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata) cfdata->show_time = ci->show_time; cfdata->show_date = ci->show_date; cfdata->show_tip = ci->show_tip; - if (ci->time_format) cfdata->time_format = strdup(ci->time_format); - if (ci->date_format) cfdata->date_format = strdup(ci->date_format); - if (ci->tip_format) cfdata->tip_format = strdup(ci->tip_format); + if (ci->time_format) cfdata->time_format = eina_stringshare_add(ci->time_format); + if (ci->date_format) cfdata->date_format = eina_stringshare_add(ci->date_format); + if (ci->tip_format) cfdata->tip_format = eina_stringshare_add(ci->tip_format); } static void * @@ -68,68 +73,159 @@ _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { if (!tclock_config) return; tclock_config->config_dialog = NULL; - free(cfdata->time_format); - free(cfdata->date_format); - free(cfdata->tip_format); + eina_stringshare_del(cfdata->time_format); + eina_stringshare_del(cfdata->date_format); + eina_stringshare_del(cfdata->tip_format); E_FREE(cfdata); } static Evas_Object * -_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata) +_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) { - Evas_Object *o = NULL, *of = NULL, *ob = NULL; + Evas_Object *o = NULL, *of = NULL, *obx = NULL, *bx = NULL; Evas_Object *time_entry = NULL, *time_check = NULL; Evas_Object *date_entry = NULL, *date_check = NULL; Evas_Object *tooltip_entry = NULL, *tooltip_check = NULL; - o = e_widget_list_add(evas, 0, 0); - - of = e_widget_frametable_add(evas, D_("Top"), 1); - time_check = - e_widget_check_add(evas, D_("Show Top Line"), &(cfdata->show_time)); - e_widget_frametable_object_append(of, time_check, 0, 0, 1, 1, 1, 0, 1, 0); - time_entry = e_widget_entry_add(evas, &cfdata->time_format, NULL, NULL, NULL); - e_widget_on_change_hook_set(time_check, _cb_time_check, time_entry); - e_widget_disabled_set(time_entry, !cfdata->show_time); - e_widget_size_min_set(time_entry, 150, 20); - e_widget_frametable_object_append(of, time_entry, 0, 1, 1, 1, 1, 0, 1, 0); - ob = - e_widget_label_add(evas, D_("Consult strftime(3) for format syntax")); - e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0); - e_widget_list_object_append(o, of, 1, 1, 0.5); - - of = e_widget_frametable_add (evas, D_ ("Bottom"), 1); - date_check = - e_widget_check_add(evas, D_("Show Bottom Line"), &(cfdata->show_date)); - e_widget_frametable_object_append(of, date_check, 0, 0, 1, 1, 1, 0, 1, 0); - date_entry = e_widget_entry_add(evas, &(cfdata->date_format), - NULL, NULL, NULL); - e_widget_on_change_hook_set(date_check, _cb_date_check, date_entry); - e_widget_disabled_set(date_entry, !cfdata->show_date); - e_widget_size_min_set(date_entry, 150, 20); - e_widget_frametable_object_append(of, date_entry, 0, 1, 1, 1, 1, 0, 1, 0); - ob = - e_widget_label_add(evas, D_("Consult strftime(3) for format syntax")); - e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0); - e_widget_list_object_append(o, of, 1, 1, 0.5); - - of = e_widget_frametable_add(evas, D_("Tool Tip"), 1); - tooltip_check = - e_widget_check_add(evas, D_("Show Tooltip"), &(cfdata->show_tip)); - e_widget_frametable_object_append(of, tooltip_check, 0, 0, 1, 1, 1, 0, 1, 0); - tooltip_entry = e_widget_entry_add(evas, &(cfdata->tip_format), - NULL, NULL, NULL); - e_widget_on_change_hook_set(tooltip_check, _cb_tooltip_check, tooltip_entry); - e_widget_disabled_set(tooltip_entry, !cfdata->show_tip); - e_widget_size_min_set(tooltip_entry, 150, 20); - e_widget_frametable_object_append(of, tooltip_entry, - 0, 1, 1, 1, 1, 0, 1, 0); - ob = - e_widget_label_add(evas, D_("Consult strftime(3) for format syntax")); - e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0); - e_widget_list_object_append(o, of, 1, 1, 0.5); - - return o; + Evas_Object *win = cfd->dia->win; + + o = elm_box_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(o); + bx = o; + + o = elm_frame_add(win); + elm_object_text_set(o, D_("Top")); + elm_frame_autocollapse_set(o, EINA_TRUE); + elm_box_pack_end(bx, o); + evas_object_show(o); + of = o; + + o = elm_box_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(of, o); + evas_object_show(o); + obx = o; + + o = elm_check_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, D_("Show Top Line")); + elm_check_state_pointer_set(o, &cfdata->show_time); + elm_box_pack_end(obx, o); + evas_object_show(o); + time_check = o; + + o = elm_entry_add(win); + elm_entry_scrollable_set(o, EINA_TRUE); + elm_entry_single_line_set(o, EINA_TRUE); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, cfdata->time_format); + elm_box_pack_end(obx, o); + evas_object_show(o); + time_entry = o; + cfdata->time_entry = o; + + evas_object_smart_callback_add(time_check, "changed", _cb_changed, cfdata); + evas_object_smart_callback_add(time_entry, "changed", _cb_changed, cfdata); + elm_widget_disabled_set(time_entry, !cfdata->show_time); + + o = elm_label_add(win); + elm_object_text_set(o, D_("Consult strftime(3) for format syntax")); + elm_box_pack_end(obx, o); + evas_object_show(o); + + o = elm_frame_add(win); + elm_object_text_set(o, D_("Bottom")); + elm_frame_autocollapse_set(o, EINA_TRUE); + elm_box_pack_end(bx, o); + evas_object_show(o); + of = o; + + o = elm_box_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(of, o); + evas_object_show(o); + obx = o; + + o = elm_check_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, D_("Show Bottom Line")); + elm_check_state_pointer_set(o, &cfdata->show_date); + elm_box_pack_end(obx, o); + evas_object_show(o); + date_check = o; + + o = elm_entry_add(win); + elm_entry_scrollable_set(o, EINA_TRUE); + elm_entry_single_line_set(o, EINA_TRUE); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, cfdata->date_format); + elm_box_pack_end(obx, o); + evas_object_show(o); + date_entry = o; + cfdata->date_entry = o; + + evas_object_smart_callback_add(date_check, "changed", _cb_changed, cfdata); + evas_object_smart_callback_add(date_entry, "changed", _cb_changed, cfdata); + elm_widget_disabled_set(date_entry, !cfdata->show_date); + + o = elm_label_add(win); + elm_object_text_set(o, D_("Consult strftime(3) for format syntax")); + elm_box_pack_end(obx, o); + evas_object_show(o); + + o = elm_frame_add(win); + elm_object_text_set(o, D_("Tool Tip")); + elm_frame_autocollapse_set(o, EINA_TRUE); + elm_box_pack_end(bx, o); + evas_object_show(o); + of = o; + + o = elm_box_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(of, o); + evas_object_show(o); + obx = o; + + o = elm_check_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, D_("Show Tooltip")); + elm_check_state_pointer_set(o, &cfdata->show_tip); + elm_box_pack_end(obx, o); + evas_object_show(o); + tooltip_check = o; + + o = elm_entry_add(win); + elm_entry_scrollable_set(o, EINA_TRUE); + elm_entry_single_line_set(o, EINA_TRUE); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, cfdata->tip_format); + elm_box_pack_end(obx, o); + evas_object_show(o); + tooltip_entry = o; + cfdata->tip_entry = o; + + evas_object_smart_callback_add(tooltip_check, "changed", _cb_changed, cfdata); + evas_object_smart_callback_add(tooltip_entry, "changed", _cb_changed, cfdata); + elm_widget_disabled_set(tooltip_entry, !cfdata->show_tip); + + o = elm_label_add(win); + elm_object_text_set(o, D_("Consult strftime(3) for format syntax")); + elm_box_pack_end(obx, o); + evas_object_show(o); + + cfdata->cfd = cfd; + return bx; } static int @@ -142,41 +238,14 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) ci->show_time = cfdata->show_time; ci->show_tip = cfdata->show_tip; if (ci->time_format) eina_stringshare_del(ci->time_format); - ci->time_format = eina_stringshare_add(cfdata->time_format); + ci->time_format = eina_stringshare_add(elm_object_text_get(cfdata->time_entry)); if (ci->date_format) eina_stringshare_del(ci->date_format); - ci->date_format = eina_stringshare_add(cfdata->date_format); + ci->date_format = eina_stringshare_add(elm_object_text_get(cfdata->date_entry)); if (ci->tip_format) eina_stringshare_del(ci->tip_format); - ci->tip_format = eina_stringshare_add(cfdata->tip_format); + ci->tip_format = eina_stringshare_add(elm_object_text_get(cfdata->tip_entry)); e_config_save_queue(); _tclock_config_updated(ci); return 1; } - -static void -_cb_time_check(void *data, Evas_Object *obj) -{ - int checked = 0; - - checked = e_widget_check_checked_get(obj); - e_widget_disabled_set(data, !checked); -} - -static void -_cb_date_check(void *data, Evas_Object *obj) -{ - int checked = 0; - - checked = e_widget_check_checked_get(obj); - e_widget_disabled_set(data, !checked); -} - -static void -_cb_tooltip_check(void *data, Evas_Object *obj) -{ - int checked = 0; - - checked = e_widget_check_checked_get(obj); - e_widget_disabled_set(data, !checked); -} --