tasn pushed a commit to branch master. http://git.enlightenment.org/tools/clouseau.git/commit/?id=87c046e9ad817e10c08d692e2acde259e510918c
commit 87c046e9ad817e10c08d692e2acde259e510918c Author: Tom Hacohen <t...@stosb.com> Date: Thu Nov 7 10:11:46 2013 +0000 Client: Added a GUI settings dialog. This is a continuation of the previous commit actually letting you control the settings from a nice settings dialog. --- src/bin/Makefile.am | 3 +- src/bin/client/config_dialog.c | 94 ++++++++++++++++++++++++++++++++++++++++++ src/bin/client/config_dialog.h | 8 ++++ src/bin/clouseau_client.c | 60 ++++++++++----------------- 4 files changed, 126 insertions(+), 39 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 50517aa..8ed761a 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -5,7 +5,8 @@ bin_PROGRAMS = clouseaud clouseau_client clouseaud_SOURCES = clouseaud.c clouseau_client_SOURCES = \ clouseau_client.c \ - client/cfg.c + client/cfg.c \ + client/config_dialog.c AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ diff --git a/src/bin/client/config_dialog.c b/src/bin/client/config_dialog.c new file mode 100644 index 0000000..1e85503 --- /dev/null +++ b/src/bin/client/config_dialog.c @@ -0,0 +1,94 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <Elementary.h> + +#include "Clouseau.h" +#include "client/cfg.h" +#include "client/config_dialog.h" + +static Clouseau_Config_Changed_Cb _conf_changed_cb = NULL; +static void *_conf_changed_cb_data = NULL; + +static Eina_Bool _cfg_changed; + +static void +_close_btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Evas_Object *win = data; + + if (_cfg_changed) + _conf_changed_cb(_conf_changed_cb_data); + + _conf_changed_cb = NULL; + _conf_changed_cb_data = NULL; + + evas_object_del(win); +} + +static void +_config_check_changed(void *data, Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Eina_Bool *setting = data; + *setting = elm_check_state_get(obj); + _cfg_changed = EINA_TRUE; +} + +void +clouseau_settings_dialog_open(Evas_Object *parent, Clouseau_Config_Changed_Cb callback, const void *callback_data) +{ + Evas_Object *win, *bx; + + _cfg_changed = EINA_FALSE; + _conf_changed_cb = callback; + _conf_changed_cb_data = (void *) callback_data; + + win = elm_win_inwin_add(parent); + evas_object_show(win); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bx); + + elm_win_inwin_content_set(win, bx); + + Evas_Object *check; + + check = elm_check_add(bx); + elm_object_text_set(check, "Show Hidden"); + elm_check_state_set(check, _clouseau_cfg->show_hidden); + elm_box_pack_end(bx, check); + evas_object_show(check); + evas_object_smart_callback_add(check, "changed", + _config_check_changed, &(_clouseau_cfg->show_hidden)); + + check = elm_check_add(bx); + elm_object_text_set(check, "Show Clippers"); + elm_check_state_set(check, _clouseau_cfg->show_clippers); + elm_box_pack_end(bx, check); + evas_object_show(check); + evas_object_smart_callback_add(check, "changed", + _config_check_changed, &(_clouseau_cfg->show_clippers)); + + check = elm_check_add(bx); + elm_object_text_set(check, "Only show Elementary widgets"); + elm_check_state_set(check, _clouseau_cfg->show_elm_only); + elm_box_pack_end(bx, check); + evas_object_show(check); + evas_object_smart_callback_add(check, "changed", + _config_check_changed, &(_clouseau_cfg->show_elm_only)); + + Evas_Object *btn; + + btn = elm_button_add(bx); + elm_object_text_set(btn, "Close"); + evas_object_size_hint_align_set(bx, 1.0, EVAS_HINT_FILL); + elm_box_pack_end(bx, btn); + evas_object_show(btn); + evas_object_smart_callback_add(btn, "clicked", + _close_btn_clicked, win); +} diff --git a/src/bin/client/config_dialog.h b/src/bin/client/config_dialog.h new file mode 100644 index 0000000..e0a9b9a --- /dev/null +++ b/src/bin/client/config_dialog.h @@ -0,0 +1,8 @@ +#ifndef _CONFIG_DIALOG_H +#define _CONFIG_DIALOG_H + +typedef void (*Clouseau_Config_Changed_Cb)(void *data); +void clouseau_settings_dialog_open(Evas_Object *parent, Clouseau_Config_Changed_Cb callback, const void *callback_data); + +#endif + diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c index abb57b3..1484485 100644 --- a/src/bin/clouseau_client.c +++ b/src/bin/clouseau_client.c @@ -7,6 +7,7 @@ #include "Clouseau.h" #include "client/cfg.h" +#include "client/config_dialog.h" #define CLIENT_NAME "Clouseau Client" @@ -85,7 +86,7 @@ struct _Gui_Elementns }; typedef struct _Gui_Elementns Gui_Elements; -static int _load_list(Gui_Elements *g); +static void _load_list(Gui_Elements *g); static void _bt_load_file(void *data, Evas_Object *obj EINA_UNUSED, void *event_info); static void _show_gui(Gui_Elements *g, Eina_Bool work_offline); @@ -1342,7 +1343,7 @@ _gl_selected(void *data, Evas_Object *pobj EINA_UNUSED, void *event_info) /* END - replacing clouseau_object_highlight(obj); */ } -static int +static void _load_list(Gui_Elements *g) { elm_progressbar_pulse(g->pb, EINA_FALSE); @@ -1364,7 +1365,7 @@ _load_list(Gui_Elements *g) if (!eet_svr) { _update_tree_offline(g, g->sel_app->td); - return 0; + return; } if (eina_list_search_unsorted(apps, _app_ptr_cmp, @@ -1379,16 +1380,6 @@ _load_list(Gui_Elements *g) } } } - - return 0; -} - -static void -_show_clippers_check_changed(void *data, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - _clouseau_cfg->show_clippers = elm_check_state_get(obj); - _load_list(data); } static void @@ -1399,14 +1390,6 @@ _highlight_check_check_changed(EINA_UNUSED void *data, Evas_Object *obj, } static void -_show_hidden_check_changed(void *data, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - _clouseau_cfg->show_hidden = elm_check_state_get(obj); - _load_list(data); -} - -static void _bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Gui_Elements *g = data; @@ -1590,6 +1573,14 @@ _list_tree_item_pointer_find(Eina_List *tree, uintptr_t ptr) } static void +_settings_btn_clicked(void *data EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + clouseau_settings_dialog_open(gui->win, + (Clouseau_Config_Changed_Cb) _load_list, (void *) gui); +} + +static void _save_file_dialog(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { /* START - Popup to save eet file */ @@ -1802,7 +1793,7 @@ _jump_to_entry_activated(void *data, static void _control_buttons_create(Gui_Elements *g, Evas_Object *win) { - Evas_Object *show_hidden_check, *show_clippers_check, *highlight_check; + Evas_Object *highlight_check; Evas_Object *jump_to_entry, *frame; frame = elm_frame_add(gui->bx); @@ -1834,28 +1825,12 @@ _control_buttons_create(Gui_Elements *g, Evas_Object *win) elm_box_pack_end(g->hbx, g->dd_list); evas_object_show(g->dd_list); - show_hidden_check = elm_check_add(g->hbx); - elm_object_text_set(show_hidden_check, "Show Hidden"); - elm_check_state_set(show_hidden_check, _clouseau_cfg->show_hidden); - elm_box_pack_end(g->hbx, show_hidden_check); - evas_object_show(show_hidden_check); - - show_clippers_check = elm_check_add(g->hbx); - elm_object_text_set(show_clippers_check, "Show Clippers"); - elm_check_state_set(show_clippers_check, _clouseau_cfg->show_clippers); - elm_box_pack_end(g->hbx, show_clippers_check); - evas_object_show(show_clippers_check); - highlight_check = elm_check_add(g->hbx); elm_object_text_set(highlight_check , "Highlight"); elm_check_state_set(highlight_check , do_highlight); elm_box_pack_end(g->hbx, highlight_check); evas_object_show(highlight_check); - evas_object_smart_callback_add(show_hidden_check, "changed", - _show_hidden_check_changed, g); - evas_object_smart_callback_add(show_clippers_check, "changed", - _show_clippers_check_changed, g); evas_object_smart_callback_add(highlight_check, "changed", _highlight_check_check_changed, g); @@ -1872,6 +1847,15 @@ _control_buttons_create(Gui_Elements *g, Evas_Object *win) evas_object_smart_callback_add(jump_to_entry, "activated", _jump_to_entry_activated, g); + + Evas_Object *btn_settings; + + btn_settings = elm_button_add(g->hbx); + elm_object_text_set(btn_settings, "Settings"); + evas_object_smart_callback_add(btn_settings, "clicked", + _settings_btn_clicked, NULL); + elm_box_pack_end(g->hbx, btn_settings); + evas_object_show(btn_settings); } static void --