Made clouseau_enable an elm_config option.

You can now just use elementary_config to enable and disable clouseau on
run-time.
This commit is contained in:
Tom Hacohen 2013-05-20 13:03:43 +01:00
parent 1e9ef8aa5b
commit de1c965029
5 changed files with 129 additions and 23 deletions

View File

@ -762,6 +762,20 @@ sel_change(void *data __UNUSED__,
elm_config_save(); elm_config_save();
} }
static void
dbg_change(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
Eina_Bool val = elm_check_state_get(obj);
Eina_Bool sel = elm_config_clouseau_enable_get();
if (val == sel) return;
elm_config_clouseau_enable_set(val);
elm_config_all_flush();
elm_config_save();
}
static void static void
_status_basic(Evas_Object *win, _status_basic(Evas_Object *win,
Evas_Object *bx0) Evas_Object *bx0)
@ -928,6 +942,14 @@ _cf_selection(void *data,
_flip_to(data, "selection"); _flip_to(data, "selection");
} }
static void
_cf_debug(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
_flip_to(data, "debug");
}
const char * const char *
_elm_theme_current_get(const char *theme_search_order) _elm_theme_current_get(const char *theme_search_order)
{ {
@ -1492,6 +1514,33 @@ _status_config_selection(Evas_Object *win,
elm_naviframe_item_simple_push(naviframe, bx); elm_naviframe_item_simple_push(naviframe, bx);
} }
static void
_status_config_debug(Evas_Object *win,
Evas_Object *naviframe)
{
Evas_Object *bx, *ck;
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
ck = elm_check_add(win);
elm_object_tooltip_text_set(ck, "Set clouseau mode");
elm_object_text_set(ck, "Enable clouseau");
evas_object_data_set(win, "clouseau_check", ck);
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
elm_check_state_set(ck, elm_config_clouseau_enable_get());
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_smart_callback_add(ck, "changed", dbg_change, NULL);
evas_object_data_set(win, "debug", bx);
elm_naviframe_item_simple_push(naviframe, bx);
}
static Evas_Object * static Evas_Object *
_sample_theme_new(Evas_Object *win) _sample_theme_new(Evas_Object *win)
{ {
@ -3391,6 +3440,7 @@ _status_config_full(Evas_Object *win,
elm_toolbar_item_append(tb, "appointment-new", "Caches", _cf_caches, win); elm_toolbar_item_append(tb, "appointment-new", "Caches", _cf_caches, win);
elm_toolbar_item_append(tb, "stock_spellcheck", "Access", _cf_access, win); elm_toolbar_item_append(tb, "stock_spellcheck", "Access", _cf_access, win);
elm_toolbar_item_append(tb, "clear-selection-check", "Selection", _cf_selection, win); elm_toolbar_item_append(tb, "clear-selection-check", "Selection", _cf_selection, win);
elm_toolbar_item_append(tb, "preferences-other", "Debug", _cf_debug, win);
elm_box_pack_end(bx0, tb); elm_box_pack_end(bx0, tb);
evas_object_show(tb); evas_object_show(tb);
@ -3408,6 +3458,7 @@ _status_config_full(Evas_Object *win,
_status_config_caches(win, naviframe); _status_config_caches(win, naviframe);
_status_config_access(win, naviframe); _status_config_access(win, naviframe);
_status_config_selection(win, naviframe); _status_config_selection(win, naviframe);
_status_config_debug(win, naviframe);
_status_config_sizing(win, naviframe); // Note: call this at the end. _status_config_sizing(win, naviframe); // Note: call this at the end.
// FIXME uncomment after flip style fix, please // FIXME uncomment after flip style fix, please

View File

@ -187,6 +187,7 @@ _prop_config_get(void)
_elm_config_font_overlay_apply(); _elm_config_font_overlay_apply();
_elm_rescale(); _elm_rescale();
_elm_recache(); _elm_recache();
_elm_clouseau_reload();
_elm_win_access(_elm_config->access_mode); _elm_win_access(_elm_config->access_mode);
ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL); ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
return EINA_TRUE; return EINA_TRUE;
@ -434,6 +435,7 @@ _desc_init(void)
ELM_CONFIG_VAL(D, T, indicator_service_180, T_STRING); ELM_CONFIG_VAL(D, T, indicator_service_180, T_STRING);
ELM_CONFIG_VAL(D, T, indicator_service_270, T_STRING); ELM_CONFIG_VAL(D, T, indicator_service_270, T_STRING);
ELM_CONFIG_VAL(D, T, disable_external_menu, T_UCHAR); ELM_CONFIG_VAL(D, T, disable_external_menu, T_UCHAR);
ELM_CONFIG_VAL(D, T, clouseau_enable, T_UCHAR);
#undef T #undef T
#undef D #undef D
#undef T_INT #undef T_INT
@ -1700,6 +1702,9 @@ _env_get(void)
if (s) eina_stringshare_replace(&_elm_config->indicator_service_270, s); if (s) eina_stringshare_replace(&_elm_config->indicator_service_270, s);
s = getenv("ELM_DISABLE_EXTERNAL_MENU"); s = getenv("ELM_DISABLE_EXTERNAL_MENU");
if (s) _elm_config->disable_external_menu = !!atoi(s); if (s) _elm_config->disable_external_menu = !!atoi(s);
s = getenv("ELM_CLOUSEAU");
if (s) _elm_config->clouseau_enable = atoi(s);
} }
EAPI Eina_Bool EAPI Eina_Bool
@ -2297,6 +2302,19 @@ elm_config_disable_external_menu_set(Eina_Bool disable)
_elm_config->disable_external_menu = !!disable; _elm_config->disable_external_menu = !!disable;
} }
EAPI Eina_Bool
elm_config_clouseau_enable_get(void)
{
return _elm_config->clouseau_enable;
}
EAPI void
elm_config_clouseau_enable_set(Eina_Bool enable)
{
_elm_config->clouseau_enable = !!enable;
_elm_clouseau_reload();
}
EAPI void EAPI void
elm_config_all_flush(void) elm_config_all_flush(void)
{ {
@ -2348,6 +2366,7 @@ _elm_config_init(void)
_config_apply(); _config_apply();
_elm_config_font_overlay_apply(); _elm_config_font_overlay_apply();
_elm_recache(); _elm_recache();
_elm_clouseau_reload();
} }
void void
@ -2439,6 +2458,7 @@ _elm_config_reload(void)
_elm_config_font_overlay_apply(); _elm_config_font_overlay_apply();
_elm_rescale(); _elm_rescale();
_elm_recache(); _elm_recache();
_elm_clouseau_reload();
ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL); ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
} }
@ -2510,6 +2530,7 @@ _elm_config_profile_set(const char *profile)
_elm_config_font_overlay_apply(); _elm_config_font_overlay_apply();
_elm_rescale(); _elm_rescale();
_elm_recache(); _elm_recache();
_elm_clouseau_reload();
} }
} }

View File

@ -1164,6 +1164,22 @@ EAPI Eina_Bool elm_config_mirrored_get(void);
*/ */
EAPI void elm_config_mirrored_set(Eina_Bool mirrored); EAPI void elm_config_mirrored_set(Eina_Bool mirrored);
/**
* Get the clouseau state. EINA_TRUE if clouseau was tried to be run.
*
* @since 1.8
* @return EINA_TRUE if clouseau was tried to run, EINA_FALSE otherwise
*/
EAPI Eina_Bool elm_config_clouseau_enable_get(void);
/**
* Get the clouseau state. EINA_TRUE if clouseau should be attempted to be run.
*
* @since 1.8
* @param enabled EINA_TRUE to try and run clouseau, EINA_FALSE otherwise.
*/
EAPI void elm_config_clouseau_enable_set(Eina_Bool enabled);
/** /**
* Get the indicator service name according to the rotation degree. * Get the indicator service name according to the rotation degree.
* *

View File

@ -209,6 +209,7 @@ static struct {
void (*init)(void); void (*init)(void);
void (*shutdown)(void); void (*shutdown)(void);
Eina_Bool (*app_connect)(const char *appname); Eina_Bool (*app_connect)(const char *appname);
Eina_Bool is_init;
} _clouseau_info; } _clouseau_info;
#define _CLOUSEAU_LOAD_SYMBOL(cls_struct, sym) \ #define _CLOUSEAU_LOAD_SYMBOL(cls_struct, sym) \
@ -225,16 +226,37 @@ static struct {
} \ } \
while (0) while (0)
static Eina_Bool static void
_clouseau_module_load() _elm_clouseau_unload()
{ {
const char *elm_clouseau_env = getenv("ELM_CLOUSEAU"); if (!_clouseau_info.is_init)
Eina_Bool want_cls = EINA_FALSE; return;
if (elm_clouseau_env)
want_cls = atoi(elm_clouseau_env);
if (!want_cls) if (_clouseau_info.shutdown)
return EINA_FALSE; {
_clouseau_info.shutdown();
}
if (_clouseau_info.handle)
{
eina_module_free(_clouseau_info.handle);
_clouseau_info.handle = NULL;
}
_clouseau_info.is_init = EINA_FALSE;
}
Eina_Bool
_elm_clouseau_reload()
{
if (!_elm_config->clouseau_enable)
{
_elm_clouseau_unload();
return EINA_TRUE;
}
if (_clouseau_info.is_init)
return EINA_TRUE;
_clouseau_info.handle = eina_module_new( _clouseau_info.handle = eina_module_new(
PACKAGE_LIB_DIR "/libclouseau" LIBEXT); PACKAGE_LIB_DIR "/libclouseau" LIBEXT);
@ -250,6 +272,14 @@ _clouseau_module_load()
_CLOUSEAU_LOAD_SYMBOL(_clouseau_info, shutdown); _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, shutdown);
_CLOUSEAU_LOAD_SYMBOL(_clouseau_info, app_connect); _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, app_connect);
_clouseau_info.init();
if(!_clouseau_info.app_connect(elm_app_name_get()))
{
ERR("Failed connecting to the clouseau server.");
}
_clouseau_info.is_init = EINA_TRUE;
return EINA_TRUE; return EINA_TRUE;
} }
@ -263,15 +293,6 @@ elm_init(int argc,
elm_quicklaunch_sub_init(argc, argv); elm_quicklaunch_sub_init(argc, argv);
_prefix_shutdown(); _prefix_shutdown();
if (_clouseau_module_load())
{
_clouseau_info.init();
if(!_clouseau_info.app_connect(elm_app_name_get()))
{
ERR("Failed connecting to the clouseau server.");
}
}
return _elm_init_count; return _elm_init_count;
} }
@ -288,12 +309,7 @@ elm_shutdown(void)
_elm_win_shutdown(); _elm_win_shutdown();
while (_elm_win_deferred_free) ecore_main_loop_iterate(); while (_elm_win_deferred_free) ecore_main_loop_iterate();
if (_clouseau_info.shutdown) _elm_clouseau_unload();
{
_clouseau_info.shutdown();
eina_module_free(_clouseau_info.handle);
_clouseau_info.handle = NULL;
}
// wrningz :( // wrningz :(
// _prefix_shutdown(); // _prefix_shutdown();
if (app_name) if (app_name)

View File

@ -239,6 +239,7 @@ struct _Elm_Config
const char *indicator_service_270; const char *indicator_service_270;
unsigned char selection_clear_enable; unsigned char selection_clear_enable;
unsigned char disable_external_menu; unsigned char disable_external_menu;
unsigned char clouseau_enable;
/* Not part of the EET file */ /* Not part of the EET file */
Eina_Bool is_mirrored : 1; Eina_Bool is_mirrored : 1;
@ -338,6 +339,7 @@ void _elm_unneed_ethumb(void);
void _elm_unneed_web(void); void _elm_unneed_web(void);
void _elm_rescale(void); void _elm_rescale(void);
Eina_Bool _elm_clouseau_reload(void);
void _elm_config_init(void); void _elm_config_init(void);
void _elm_config_sub_init(void); void _elm_config_sub_init(void);