tasn pushed a commit to branch master.
commit f4d5732ff90e9b7952165af870804261b6f3e8b0
Author: Tom Hacohen <[email protected]>
Date: Mon May 20 13:03:43 2013 +0100
Made clouseau_enable an elm_config option.
You can now just use elementary_config to enable and disable clouseau on
run-time.
---
src/bin/config.c | 51 ++++++++++++++++++++++++++++++++++++++++++
src/lib/elm_config.c | 21 ++++++++++++++++++
src/lib/elm_config.h | 16 ++++++++++++++
src/lib/elm_main.c | 62 +++++++++++++++++++++++++++++++++-------------------
src/lib/elm_priv.h | 2 ++
5 files changed, 129 insertions(+), 23 deletions(-)
diff --git a/src/bin/config.c b/src/bin/config.c
index a4d4177..7586012 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -763,6 +763,20 @@ sel_change(void *data __UNUSED__,
}
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
_status_basic(Evas_Object *win,
Evas_Object *bx0)
{
@@ -928,6 +942,14 @@ _cf_selection(void *data,
_flip_to(data, "selection");
}
+static void
+_cf_debug(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ _flip_to(data, "debug");
+}
+
const char *
_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);
}
+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 *
_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, "stock_spellcheck", "Access", _cf_access, 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);
evas_object_show(tb);
@@ -3408,6 +3458,7 @@ _status_config_full(Evas_Object *win,
_status_config_caches(win, naviframe);
_status_config_access(win, naviframe);
_status_config_selection(win, naviframe);
+ _status_config_debug(win, naviframe);
_status_config_sizing(win, naviframe); // Note: call this at the end.
// FIXME uncomment after flip style fix, please
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index 6f16915..aee702e 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -187,6 +187,7 @@ _prop_config_get(void)
_elm_config_font_overlay_apply();
_elm_rescale();
_elm_recache();
+ _elm_clouseau_reload();
_elm_win_access(_elm_config->access_mode);
ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
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_270, T_STRING);
ELM_CONFIG_VAL(D, T, disable_external_menu, T_UCHAR);
+ ELM_CONFIG_VAL(D, T, clouseau_enable, T_UCHAR);
#undef T
#undef D
#undef T_INT
@@ -1700,6 +1702,9 @@ _env_get(void)
if (s) eina_stringshare_replace(&_elm_config->indicator_service_270, s);
s = getenv("ELM_DISABLE_EXTERNAL_MENU");
if (s) _elm_config->disable_external_menu = !!atoi(s);
+
+ s = getenv("ELM_CLOUSEAU");
+ if (s) _elm_config->clouseau_enable = atoi(s);
}
EAPI Eina_Bool
@@ -2297,6 +2302,19 @@ elm_config_disable_external_menu_set(Eina_Bool 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
elm_config_all_flush(void)
{
@@ -2348,6 +2366,7 @@ _elm_config_init(void)
_config_apply();
_elm_config_font_overlay_apply();
_elm_recache();
+ _elm_clouseau_reload();
}
void
@@ -2439,6 +2458,7 @@ _elm_config_reload(void)
_elm_config_font_overlay_apply();
_elm_rescale();
_elm_recache();
+ _elm_clouseau_reload();
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_rescale();
_elm_recache();
+ _elm_clouseau_reload();
}
}
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index 71efd19..ec33f79 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -1165,6 +1165,22 @@ EAPI Eina_Bool elm_config_mirrored_get(void);
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.
*
* @param rotation The rotation which related with the indicator service name,
in degrees (0-360),
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index 1ee5e22..2ed2115 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -209,6 +209,7 @@ static struct {
void (*init)(void);
void (*shutdown)(void);
Eina_Bool (*app_connect)(const char *appname);
+ Eina_Bool is_init;
} _clouseau_info;
#define _CLOUSEAU_LOAD_SYMBOL(cls_struct, sym) \
@@ -225,16 +226,37 @@ static struct {
} \
while (0)
-static Eina_Bool
-_clouseau_module_load()
+static void
+_elm_clouseau_unload()
+{
+ if (!_clouseau_info.is_init)
+ return;
+
+ if (_clouseau_info.shutdown)
+ {
+ _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()
{
- const char *elm_clouseau_env = getenv("ELM_CLOUSEAU");
- Eina_Bool want_cls = EINA_FALSE;
- if (elm_clouseau_env)
- want_cls = atoi(elm_clouseau_env);
+ if (!_elm_config->clouseau_enable)
+ {
+ _elm_clouseau_unload();
+ return EINA_TRUE;
+ }
- if (!want_cls)
- return EINA_FALSE;
+ if (_clouseau_info.is_init)
+ return EINA_TRUE;
_clouseau_info.handle = eina_module_new(
PACKAGE_LIB_DIR "/libclouseau" LIBEXT);
@@ -250,6 +272,14 @@ _clouseau_module_load()
_CLOUSEAU_LOAD_SYMBOL(_clouseau_info, shutdown);
_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;
}
@@ -263,15 +293,6 @@ elm_init(int argc,
elm_quicklaunch_sub_init(argc, argv);
_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;
}
@@ -288,12 +309,7 @@ elm_shutdown(void)
_elm_win_shutdown();
while (_elm_win_deferred_free) ecore_main_loop_iterate();
- if (_clouseau_info.shutdown)
- {
- _clouseau_info.shutdown();
- eina_module_free(_clouseau_info.handle);
- _clouseau_info.handle = NULL;
- }
+ _elm_clouseau_unload();
// wrningz :(
// _prefix_shutdown();
if (app_name)
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 969b67d..5d5b5fc 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -239,6 +239,7 @@ struct _Elm_Config
const char *indicator_service_270;
unsigned char selection_clear_enable;
unsigned char disable_external_menu;
+ unsigned char clouseau_enable;
/* Not part of the EET file */
Eina_Bool is_mirrored : 1;
@@ -338,6 +339,7 @@ void _elm_unneed_ethumb(void);
void _elm_unneed_web(void);
void _elm_rescale(void);
+Eina_Bool _elm_clouseau_reload(void);
void _elm_config_init(void);
void _elm_config_sub_init(void);
--
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d