summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-27 11:31:02 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-27 18:14:42 +0300
commitcb8a2bec774e7b04336075f7938a145d411f07f2 (patch)
treeaeecb66d8bc4107c5b0a6a511ba7c19f482a2d96
parentc51d3d8ae1e80f10e0cfaf4a2d312db44e9e94e3 (diff)
fix behavior of Apply button in settings window
-rw-r--r--src/bin/egui_gui/egui_layout_c.json8
-rw-r--r--src/bin/egui_gui/settings_view.c27
2 files changed, 30 insertions, 5 deletions
diff --git a/src/bin/egui_gui/egui_layout_c.json b/src/bin/egui_gui/egui_layout_c.json
index 38e0e34..ad87e9f 100644
--- a/src/bin/egui_gui/egui_layout_c.json
+++ b/src/bin/egui_gui/egui_layout_c.json
@@ -965,7 +965,8 @@ _create_settings_win()
965 "Properties": 965 "Properties":
966 { 966 {
967 "part_text":[null, "Apply"], 967 "part_text":[null, "Apply"],
968 "visibility":[true] 968 "visibility":[true],
969 "disabled":[true]
969 }, 970 },
970 "Callbacks": 971 "Callbacks":
971 { 972 {
@@ -979,6 +980,7 @@ _create_settings_win()
979 pub_widgets.settings_button_apply = settings_button_apply; 980 pub_widgets.settings_button_apply = settings_button_apply;
980 eo_do(settings_button_apply, elm_obj_widget_part_text_set(NULL, "Apply")); 981 eo_do(settings_button_apply, elm_obj_widget_part_text_set(NULL, "Apply"));
981 eo_do(settings_button_apply, evas_obj_visibility_set(EINA_TRUE)); 982 eo_do(settings_button_apply, evas_obj_visibility_set(EINA_TRUE));
983 eo_do(settings_button_apply, elm_obj_widget_disabled_set(EINA_TRUE));
982 eo_do(settings_button_apply, eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _settings_apply_button_clicked, NULL)); 984 eo_do(settings_button_apply, eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _settings_apply_button_clicked, NULL));
983 eo_do(settings_buttons_box, elm_obj_box_pack_end(settings_button_apply)); 985 eo_do(settings_buttons_box, elm_obj_box_pack_end(settings_button_apply));
984/* @egui 986/* @egui
@@ -1063,6 +1065,8 @@ egui_layout_rm_win_show(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Ev
1063 _create_rm_win(); 1065 _create_rm_win();
1064 1066
1065 if (!_rm_win_show_post_cb(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP; 1067 if (!_rm_win_show_post_cb(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP;
1068
1069
1066 return EO_CALLBACK_CONTINUE; 1070 return EO_CALLBACK_CONTINUE;
1067} 1071}
1068 1072
@@ -1089,6 +1093,8 @@ egui_layout_settings_win_show(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const
1089 _create_settings_win(); 1093 _create_settings_win();
1090 1094
1091 if (!_settings_win_show_post_cb(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP; 1095 if (!_settings_win_show_post_cb(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP;
1096
1097
1092 return EO_CALLBACK_CONTINUE; 1098 return EO_CALLBACK_CONTINUE;
1093} 1099}
1094 1100
diff --git a/src/bin/egui_gui/settings_view.c b/src/bin/egui_gui/settings_view.c
index 368fbbf..b6c7b50 100644
--- a/src/bin/egui_gui/settings_view.c
+++ b/src/bin/egui_gui/settings_view.c
@@ -11,19 +11,31 @@
11 11
12static SettingsView_Type _toolbar_selected_type = SETTINGSVIEW_NOT_SELECTED; 12static SettingsView_Type _toolbar_selected_type = SETTINGSVIEW_NOT_SELECTED;
13 13
14
15/* Enable "Apply" button." */
16static Eina_Bool
17_settings_apply_button_enable(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
18{
19 GUI *_g = get_gui();
20 eo_do(_g->settings_button_apply, elm_obj_widget_disabled_set(EINA_FALSE));
21 return EO_CALLBACK_CONTINUE;
22}
23
24/* Toolbar item clicked callback. */
14static void 25static void
15_settingsview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 26_settingsview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
16{ 27{
17 SettingsView_Type type = (int) (intptr_t) data; 28 SettingsView_Type type = (int) (intptr_t) data;
29 GUI *g = get_gui();
18 if (_toolbar_selected_type == type) 30 if (_toolbar_selected_type == type)
19 return; 31 return;
20 _toolbar_selected_type = type; 32 _toolbar_selected_type = type;
21 33
22 GUI *g = get_gui();
23 const Gui_Context *ctx = _active_context_get(); 34 const Gui_Context *ctx = _active_context_get();
35 eo_do(g->project_name_entry, elm_obj_widget_part_text_set(NULL, gui_context_project_name_get(ctx)));
24 eo_do(g->settings_table, elm_obj_table_pack(g->project_name_label, 0, 0, 1, 1)); 36 eo_do(g->settings_table, elm_obj_table_pack(g->project_name_label, 0, 0, 1, 1));
25 eo_do(g->settings_table, elm_obj_table_pack(g->project_name_entry, 1, 0, 1, 1)); 37 eo_do(g->settings_table, elm_obj_table_pack(g->project_name_entry, 1, 0, 1, 1));
26 eo_do(g->project_name_entry, elm_obj_widget_part_text_set(NULL, gui_context_project_name_get(ctx))); 38 evas_object_smart_callback_add(g->project_name_entry, "changed,user", _settings_apply_button_enable, NULL);
27} 39}
28 40
29/* "Apply" button "clicked" callback." */ 41/* "Apply" button "clicked" callback." */
@@ -36,8 +48,15 @@ _settings_apply_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, cons
36 eo_do(_g->project_name_entry, new_project_name = elm_obj_widget_part_text_get(NULL)); 48 eo_do(_g->project_name_entry, new_project_name = elm_obj_widget_part_text_get(NULL));
37 old_project_name = gui_context_project_name_get(ctx); 49 old_project_name = gui_context_project_name_get(ctx);
38 50
39 if (new_project_name && (strcmp(new_project_name, old_project_name))) 51 if (strlen(new_project_name) && (strcmp(new_project_name, old_project_name)))
40 gui_context_project_name_set((Gui_Context *) ctx, new_project_name); 52 {
53 gui_context_project_name_set((Gui_Context *) ctx, new_project_name);
54 }
55 else if (!strlen(new_project_name))
56 {
57 eo_do(_g->project_name_entry, elm_obj_widget_part_text_set(NULL, old_project_name));
58 }
59 eo_do(_g->settings_button_apply, elm_obj_widget_disabled_set(EINA_TRUE));
41 return EO_CALLBACK_CONTINUE; 60 return EO_CALLBACK_CONTINUE;
42} 61}
43 62