This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository enlightenment.
View the commit online.
commit 33be485167e0bc2b0f1149bbde02e6f63dfa296c
Author: Carsten Haitzler <[email protected]>
AuthorDate: Mon Jan 5 10:56:27 2026 +0000
Revert "unify formatting to vbe the same as e's formartting and consistent"
This reverts commit a2d4a9ef9ffb2ef0f2126a474c9361a62c396f4a.
i seem to have broken something in reformatting... go back
---
src/modules/clipboard/clip_log.c | 83 ++++---
src/modules/clipboard/common.h | 38 ++--
src/modules/clipboard/e_mod_config.c | 43 ++--
src/modules/clipboard/e_mod_main.c | 404 ++++++++++++++++++-----------------
src/modules/clipboard/history.c | 275 ++++++++++++------------
src/modules/clipboard/history.h | 3 +-
src/modules/clipboard/utility.c | 174 +++++++--------
7 files changed, 505 insertions(+), 515 deletions(-)
diff --git a/src/modules/clipboard/clip_log.c b/src/modules/clipboard/clip_log.c
index d7b0c6cd9..ca4c65d2b 100644
--- a/src/modules/clipboard/clip_log.c
+++ b/src/modules/clipboard/clip_log.c
@@ -15,17 +15,15 @@ int clipboard_log = -1;
Eina_Bool
logger_init(char *package)
{
- if (clipboard_log < 0)
- {
- clip_cfg->log_name = eina_stringshare_add(package);
- clipboard_log = eina_log_domain_register(clip_cfg->log_name, EINA_COLOR_CYAN);
- if(clipboard_log < 0)
- {
- EINA_LOG_CRIT("Could not register log domain %s", package);
- return EINA_FALSE;
- }
- eina_log_domain_level_set(clip_cfg->log_name, EINA_LOG_LEVEL_DBG);
+ if(clipboard_log < 0) {
+ clip_cfg->log_name = eina_stringshare_add(package);
+ clipboard_log = eina_log_domain_register(clip_cfg->log_name, EINA_COLOR_CYAN);
+ if(clipboard_log < 0) {
+ EINA_LOG_CRIT("Could not register log domain %s", package);
+ return EINA_FALSE;
}
+ eina_log_domain_level_set(clip_cfg->log_name, EINA_LOG_LEVEL_DBG);
+ }
return EINA_TRUE;
}
@@ -34,13 +32,13 @@ logger_shutdown(char *package)
{
Eina_Stringshare *temp;
- if ((temp = eina_stringshare_add(package))) eina_stringshare_del(temp);
+ if ((temp = eina_stringshare_add(package)))
+ eina_stringshare_del(temp);
- if (clipboard_log >= 0)
- {
- eina_log_domain_unregister(clipboard_log);
- clipboard_log = -1;
- }
+ if(clipboard_log >= 0) {
+ eina_log_domain_unregister(clipboard_log);
+ clipboard_log = -1;
+ }
return clipboard_log;
}
@@ -49,33 +47,34 @@ cb_mod_log(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file,
const char *fnc, int line, const char *fmt, void *data EINA_UNUSED, va_list args)
{
if ((d->name) && (d->namelen == sizeof(clip_cfg->log_name) - 1) &&
- (memcmp(d->name, clip_cfg->log_name, sizeof(clip_cfg->log_name) - 1) == 0))
- {
- const char *prefix;
- Eina_Bool use_color = !eina_log_color_disable_get();
+ (memcmp(d->name, clip_cfg->log_name, sizeof(clip_cfg->log_name) - 1) == 0))
+ {
+ const char *prefix;
+ Eina_Bool use_color = !eina_log_color_disable_get();
- if (use_color) fputs(eina_log_level_color_get(level), stderr);
+ if (use_color)
+ fputs(eina_log_level_color_get(level), stderr);
- switch (level)
- {
- case EINA_LOG_LEVEL_CRITICAL:
- prefix = "Critical. ";
- break;
- case EINA_LOG_LEVEL_ERR:
- prefix = "Error. ";
- break;
- case EINA_LOG_LEVEL_WARN:
- prefix = "Warning. ";
- break;
- default:
- prefix = "";
- }
- fprintf(stderr, "%s: %s", "E_CLIPBOARD", prefix);
-
- if (use_color) fputs(EINA_COLOR_RESET, stderr);
-
- vfprintf(stderr, fmt, args);
- putc('\n', stderr);
+ switch (level) {
+ case EINA_LOG_LEVEL_CRITICAL:
+ prefix = "Critical. ";
+ break;
+ case EINA_LOG_LEVEL_ERR:
+ prefix = "Error. ";
+ break;
+ case EINA_LOG_LEVEL_WARN:
+ prefix = "Warning. ";
+ break;
+ default:
+ prefix = "";
}
- else eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
+ fprintf(stderr, "%s: %s", "E_CLIPBOARD", prefix);
+
+ if (use_color)
+ fputs(EINA_COLOR_RESET, stderr);
+
+ vfprintf(stderr, fmt, args);
+ putc('\n', stderr);
+ } else
+ eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args);
}
diff --git a/src/modules/clipboard/common.h b/src/modules/clipboard/common.h
index fb4f8df87..e37fdd5df 100644
--- a/src/modules/clipboard/common.h
+++ b/src/modules/clipboard/common.h
@@ -33,37 +33,37 @@ do { \
typedef struct _Clip_Data
{
- /* A structure used for storing clipboard data in */
- char *name;
- char *content;
+ /* A structure used for storing clipboard data in */
+ char *name;
+ char *content;
} Clip_Data;
typedef struct _Instance Instance;
struct _Instance
{
- E_Gadcon_Client *gcc;
- Evas_Object *o_button;
- Evas_Object *table;
- E_Gadcon_Popup *popup;
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_button;
+ Evas_Object *table;
+ E_Gadcon_Popup *popup;
};
typedef struct _Mod_Inst Mod_Inst;
struct _Mod_Inst
{
- /* Sructure to store a global module instance in
- * complete with a hidden window for event notification purposes */
- Instance *inst;
- /* A pointer to an window used to
- * recieve or send clipboard events to */
- Evas_Object *ewin;
- /* Callback function to handle clipboard events */
- Eina_List *handle;
- /* Stores Clipboard History */
- Eina_List *items;
+ /* Sructure to store a global module instance in
+ * complete with a hidden window for event notification purposes */
+
+ Instance *inst;
+ /* A pointer to an window used to
+ * recieve or send clipboard events to */
+ Evas_Object *ewin;
+ /* Callback function to handle clipboard events */
+ Eina_List *handle;
+ /* Stores Clipboard History */
+ Eina_List *items;
};
void cb_mod_log(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
-void free_clip_data(Clip_Data *clip);
-
extern int clipboard_log;
+void free_clip_data(Clip_Data *clip);
#endif
diff --git a/src/modules/clipboard/e_mod_config.c b/src/modules/clipboard/e_mod_config.c
index 7452b5101..1bc4993da 100644
--- a/src/modules/clipboard/e_mod_config.c
+++ b/src/modules/clipboard/e_mod_config.c
@@ -74,19 +74,16 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
/* Do we need to Truncate our history list? */
if (clip_cfg->hist_items != (unsigned int)cfdata->hist_items)
- {
- truncate_history(cfdata-> hist_items);
- }
+ truncate_history(cfdata-> hist_items);
clip_cfg->hist_items = cfdata->hist_items;
clip_cfg->confirm_clear = cfdata->confirm_clear;
/* Has clipboard label name length changed ? */
- if ((unsigned int)cfdata->label_length != cfdata->init_label_length)
- {
- clip_cfg->label_length_changed = EINA_TRUE;
- cfdata->init_label_length = cfdata->label_length;
- }
+ if ((unsigned int)cfdata->label_length != cfdata->init_label_length) {
+ clip_cfg->label_length_changed = EINA_TRUE;
+ cfdata->init_label_length = cfdata->label_length;
+ }
clip_cfg->label_length = cfdata->label_length;
clip_cfg->ignore_ws = cfdata->ignore_ws;
@@ -171,7 +168,7 @@ config_clipboard_module(Evas_Object *parent EINA_UNUSED,
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
- if (e_config_dialog_find("E", "settings/clipboard")) return NULL;
+ if(e_config_dialog_find("E", "settings/clipboard")) return NULL;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
@@ -180,8 +177,8 @@ config_clipboard_module(Evas_Object *parent EINA_UNUSED,
v->basic.check_changed = _basic_check_changed;
cfd = e_config_dialog_new(NULL, _("Clipboard Settings"),
- "E", "preferences/clipboard",
- "preferences-engine", 0, v, NULL);
+ "E", "preferences/clipboard",
+ "preferences-engine", 0, v, NULL);
clip_cfg->config_dialog = cfd;
return cfd;
}
@@ -210,18 +207,18 @@ truncate_history(const unsigned int n)
Eet_Error err = EET_ERROR_NONE;
EINA_SAFETY_ON_NULL_RETURN_VAL(clip_inst, EET_ERROR_BAD_OBJECT);
- if (clip_inst->items)
- {
- if (eina_list_count(clip_inst->items) > n)
- {
- Eina_List *last;
- Eina_List *discard;
- last = eina_list_nth_list(clip_inst->items, n-1);
- clip_inst->items = eina_list_split_list(clip_inst->items, last, &discard);
- if (discard) E_FREE_LIST(discard, free_clip_data);
- err = clip_save(clip_inst->items);
- }
+ if (clip_inst->items) {
+ if (eina_list_count(clip_inst->items) > n) {
+ Eina_List *last;
+ Eina_List *discard;
+ last = eina_list_nth_list(clip_inst->items, n-1);
+ clip_inst->items = eina_list_split_list(clip_inst->items, last, &discard);
+ if (discard)
+ E_FREE_LIST(discard, free_clip_data);
+ err = clip_save(clip_inst->items);
}
- else err = EET_ERROR_EMPTY;
+ }
+ else
+ err = EET_ERROR_EMPTY;
return err;
}
diff --git a/src/modules/clipboard/e_mod_main.c b/src/modules/clipboard/e_mod_main.c
index 83121455d..1a14c8198 100644
--- a/src/modules/clipboard/e_mod_main.c
+++ b/src/modules/clipboard/e_mod_main.c
@@ -21,15 +21,14 @@ static const char *_gc_label(const E_Gadcon_Client_Class *client_class EIN
static void _gc_shutdown(E_Gadcon_Client * gcc);
/* Define the gadcon class that this module provides (just 1) */
-static const E_Gadcon_Client_Class _gadcon_class =
-{
- GADCON_CLIENT_CLASS_VERSION,
- "clipboard",
- {
- _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
- e_gadcon_site_is_not_toolbar
- },
- E_GADCON_CLIENT_STYLE_PLAIN
+static const E_Gadcon_Client_Class _gadcon_class = {
+ GADCON_CLIENT_CLASS_VERSION,
+ "clipboard",
+ {
+ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
+ e_gadcon_site_is_not_toolbar
+ },
+ E_GADCON_CLIENT_STYLE_PLAIN
};
/* Set the version and the name IN the code (not just the .desktop file)
@@ -39,10 +38,9 @@ E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Clipboard"};
/* actual module specifics */
Config *clip_cfg = NULL;
-Mod_Inst *clip_inst = NULL; /* Need by e_mod_config.c */
-
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *conf_item_edd = NULL;
+Mod_Inst *clip_inst = NULL; /* Need by e_mod_config.c */
static E_Action *act = NULL;
/* First some call backs */
@@ -65,32 +63,31 @@ static void _clip_inst_free(Instance *inst);
static void _clip_add_item(Clip_Data *clip_data);
static void _clipboard_popup_new(Instance *inst);
static void _clear_history(void);
-static Eina_List *_item_in_history(Clip_Data *cd);
-static int _clip_compare(Clip_Data *cd, char *text);
+static Eina_List * _item_in_history(Clip_Data *cd);
+static int _clip_compare(Clip_Data *cd, char *text);
/* new module needs a new config :), or config too old and we need one anyway */
static void
_clip_config_new(E_Module *m)
{
/* setup defaults */
- if (!clip_cfg)
- {
- clip_cfg = E_NEW(Config, 1);
+ if (!clip_cfg) {
+ clip_cfg = E_NEW(Config, 1);
- clip_cfg->label_length_changed = EINA_FALSE;
+ clip_cfg->label_length_changed = EINA_FALSE;
- clip_cfg->clip_copy = CF_DEFAULT_COPY;
- clip_cfg->clip_select = CF_DEFAULT_SELECT;
- clip_cfg->persistence = CF_DEFAULT_PERSISTANCE;
- clip_cfg->hist_reverse = CF_DEFAULT_HIST_REVERSE;
- clip_cfg->hist_items = CF_DEFAULT_HIST_ITEMS;
- clip_cfg->confirm_clear = CF_DEFAULT_CONFIRM;
- clip_cfg->label_length = CF_DEFAULT_LABEL_LENGTH;
- clip_cfg->ignore_ws = CF_DEFAULT_IGNORE_WS;
- clip_cfg->ignore_ws_copy = CF_DEFAULT_IGNORE_WS_COPY;
- clip_cfg->trim_ws = CF_DEFAULT_WS;
- clip_cfg->trim_nl = CF_DEFAULT_NL;
- }
+ clip_cfg->clip_copy = CF_DEFAULT_COPY;
+ clip_cfg->clip_select = CF_DEFAULT_SELECT;
+ clip_cfg->persistence = CF_DEFAULT_PERSISTANCE;
+ clip_cfg->hist_reverse = CF_DEFAULT_HIST_REVERSE;
+ clip_cfg->hist_items = CF_DEFAULT_HIST_ITEMS;
+ clip_cfg->confirm_clear = CF_DEFAULT_CONFIRM;
+ clip_cfg->label_length = CF_DEFAULT_LABEL_LENGTH;
+ clip_cfg->ignore_ws = CF_DEFAULT_IGNORE_WS;
+ clip_cfg->ignore_ws_copy = CF_DEFAULT_IGNORE_WS_COPY;
+ clip_cfg->trim_ws = CF_DEFAULT_WS;
+ clip_cfg->trim_nl = CF_DEFAULT_NL;
+ }
E_CONFIG_LIMIT(clip_cfg->hist_items, HIST_MIN, HIST_MAX);
E_CONFIG_LIMIT(clip_cfg->label_length, LABEL_MIN, LABEL_MAX);
E_CONFIG_LIMIT(clip_cfg->clip_copy, 0, 1);
@@ -103,6 +100,7 @@ _clip_config_new(E_Module *m)
E_CONFIG_LIMIT(clip_cfg->trim_ws, 0, 1);
E_CONFIG_LIMIT(clip_cfg->trim_nl, 0, 1);
+
/* update the version */
clip_cfg->version = MOD_CONFIG_FILE_VERSION;
@@ -118,11 +116,10 @@ _clip_config_free(void)
{
Config_Item *ci;
- EINA_LIST_FREE(clip_cfg->items, ci)
- {
- eina_stringshare_del(ci->id);
- free(ci);
- }
+ EINA_LIST_FREE(clip_cfg->items, ci){
+ eina_stringshare_del(ci->id);
+ free(ci);
+ }
clip_cfg->module = NULL;
E_FREE(clip_cfg);
}
@@ -135,13 +132,14 @@ _clipboard_cb_mouse_down(void *data,
{
Instance *inst = data;
Evas_Event_Mouse_Down *ev = event;
-
+
if (ev->button == 1)
{
if (inst->popup) _clipboard_popup_free(inst);
else _clipboard_popup_new(inst);
}
- else if (ev->button == 3) _cb_context_show(data, NULL, NULL, event);
+ else if (ev->button == 3)
+ _cb_context_show(data, NULL, NULL, event);
}
/*
@@ -170,8 +168,9 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
e_gadcon_client_util_menu_attach(gcc);
evas_object_event_callback_add(inst->o_button,
EVAS_CALLBACK_MOUSE_DOWN,
- _clipboard_cb_mouse_down,
+ (Evas_Object_Event_Cb)_clipboard_cb_mouse_down,
inst);
+
return gcc;
}
@@ -183,8 +182,9 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
static void
_gc_shutdown(E_Gadcon_Client *gcc)
{
- Instance *inst = gcc->data;
-
+ Instance *inst;
+
+ inst = gcc->data;
_clipboard_popup_free(inst);
_clip_inst_free(inst);
}
@@ -288,49 +288,51 @@ _clipboard_popup_comp_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
static void
_clipboard_popup_new(Instance *inst)
{
+ EINA_SAFETY_ON_FALSE_RETURN(inst->popup == NULL);
Evas *evas;
Evas_Object *o;
int row = 0;
- if (inst->popup) return;
+ if(inst->popup) return;
inst->popup = e_gadcon_popup_new(inst->gcc, 0);
evas = e_comp->evas;
inst->table = e_widget_table_add(e_win_evas_win_get(evas), 0);
- if (clip_inst->items)
- {
- Eina_List *it;
- Clip_Data *clip;
- /* Flag to see if Label len changed */
- Eina_Bool label_length_changed = clip_cfg->label_length_changed;
- clip_cfg->label_length_changed = EINA_FALSE;
+ if (clip_inst->items){
+ Eina_List *it;
+ Clip_Data *clip;
- /* revert list if selected */
- if (clip_cfg->hist_reverse) clip_inst->items=eina_list_reverse(clip_inst->items);
+ /* Flag to see if Label len changed */
+ Eina_Bool label_length_changed = clip_cfg->label_length_changed;
+ clip_cfg->label_length_changed = EINA_FALSE;
- /* show list in history menu */
- EINA_LIST_FOREACH(clip_inst->items, it, clip)
- {
- if (label_length_changed)
- {
- free(clip->name);
- set_clip_name(&clip->name, clip->content,
- clip_cfg->ignore_ws, clip_cfg->label_length);
- }
- o = e_widget_button_add(evas,
- clip->name,
- NULL,
- _clipboard_cb_paste_item,
- clip->content,
- inst);
- e_widget_table_object_align_append(inst->table, o, 0, row, 2, 1, 1, 0, 1, 0, 0, 0.5);
- row++;
+ /* revert list if selected */
+ if (clip_cfg->hist_reverse)
+ clip_inst->items=eina_list_reverse(clip_inst->items);
+
+ /* show list in history menu */
+ EINA_LIST_FOREACH(clip_inst->items, it, clip)
+ {
+ if (label_length_changed) {
+ free(clip->name);
+ set_clip_name(&clip->name, clip->content,
+ clip_cfg->ignore_ws, clip_cfg->label_length);
}
- /* revert list back if selected */
- if (clip_cfg->hist_reverse) clip_inst->items = eina_list_reverse(clip_inst->items);
- }
+ o = e_widget_button_add(evas,
+ clip->name,
+ NULL,
+ _clipboard_cb_paste_item,
+ clip->content,
+ inst);
+ e_widget_table_object_align_append(inst->table, o, 0, row, 2, 1, 1, 0, 1, 0, 0, 0.5);
+ row++;
+ }
+ /* revert list back if selected */
+ if (clip_cfg->hist_reverse)
+ clip_inst->items=eina_list_reverse(clip_inst->items);
+ }
else
{
o = e_widget_label_add(evas, _("Empty"));
@@ -359,34 +361,28 @@ static void
_clip_add_item(Clip_Data *cd)
{
Eina_List *it;
-
EINA_SAFETY_ON_NULL_RETURN(cd);
- if (*cd->content == 0)
- {
- ERR("Warning Clip content is Empty!");
- return;
- }
- if ((it = _item_in_history(cd)))
- {
- /* Move to top of list */
- clip_inst->items = eina_list_promote_list(clip_inst->items, it);
+ if (*cd->content == 0) {
+ ERR("Warning Clip content is Empty!");
+ return;
+ }
+
+ if ((it = _item_in_history(cd))) {
+ /* Move to top of list */
+ clip_inst->items = eina_list_promote_list(clip_inst->items, it);
+ } else {
+ /* add item to the list */
+ if (eina_list_count(clip_inst->items) < clip_cfg->hist_items) {
+ clip_inst->items = eina_list_prepend(clip_inst->items, cd);
}
- else
- {
- /* add item to the list */
- if (eina_list_count(clip_inst->items) < clip_cfg->hist_items)
- {
- clip_inst->items = eina_list_prepend(clip_inst->items, cd);
- }
- else
- {
- /* remove last item from the list */
- clip_inst->items = eina_list_remove_list(clip_inst->items, eina_list_last(clip_inst->items));
- /* add clipboard data stored in cd to the list as a first item */
- clip_inst->items = eina_list_prepend(clip_inst->items, cd);
- }
+ else {
+ /* remove last item from the list */
+ clip_inst->items = eina_list_remove_list(clip_inst->items, eina_list_last(clip_inst->items));
+ /* add clipboard data stored in cd to the list as a first item */
+ clip_inst->items = eina_list_prepend(clip_inst->items, cd);
}
+ }
/* saving list to the file */
clip_save(clip_inst->items);
@@ -397,8 +393,10 @@ _item_in_history(Clip_Data *cd)
{
/* Safety check: should never happen */
EINA_SAFETY_ON_NULL_RETURN_VAL(cd, NULL);
- if (clip_inst->items) return eina_list_search_unsorted_list(clip_inst->items, (Eina_Compare_Cb)_clip_compare, cd->content);
- else return NULL;
+ if (clip_inst->items)
+ return eina_list_search_unsorted_list(clip_inst->items, (Eina_Compare_Cb) _clip_compare, cd->content);
+ else
+ return NULL;
}
static int
@@ -411,16 +409,21 @@ static void
_clear_history(void)
{
EINA_SAFETY_ON_NULL_RETURN(clip_inst);
- if (clip_inst->items) E_FREE_LIST(clip_inst->items, free_clip_data);
+ if (clip_inst->items)
+ E_FREE_LIST(clip_inst->items, free_clip_data);
+
elm_object_cnp_selection_clear(e_comp->evas, ELM_SEL_TYPE_CLIPBOARD);
+
clip_save(clip_inst->items);
}
Eet_Error
clip_save(Eina_List *items)
{
- if (clip_cfg->persistence) return save_history(items);
- else return EET_ERROR_NONE;
+ if(clip_cfg->persistence)
+ return save_history(items);
+ else
+ return EET_ERROR_NONE;
}
static void
@@ -428,18 +431,18 @@ _cb_clear_history(void *d1, void *d2 EINA_UNUSED)
{
EINA_SAFETY_ON_NULL_RETURN(clip_cfg);
- if (clip_cfg->confirm_clear)
- {
- e_confirm_dialog_show(_("Confirm History Deletion"),
- "application-exit",
- _("You wish to delete the clipboards history.<br>"
- "<br>"
- "Are you sure you want to delete it?"),
- _("Delete"), _("Keep"),
- _cb_dialog_delete, NULL, NULL, NULL,
- _cb_dialog_keep, NULL);
- }
- else _clear_history();
+ if (clip_cfg->confirm_clear) {
+ e_confirm_dialog_show(_("Confirm History Deletion"),
+ "application-exit",
+ _("You wish to delete the clipboards history.<br>"
+ "<br>"
+ "Are you sure you want to delete it?"),
+ _("Delete"), _("Keep"),
+ _cb_dialog_delete, NULL, NULL, NULL,
+ _cb_dialog_keep, NULL);
+ }
+ else
+ _clear_history();
_clipboard_popup_free((Instance *)d1);
}
@@ -458,22 +461,24 @@ _cb_dialog_delete(void *data EINA_UNUSED)
static void
_clipboard_cb_paste_item(void *d1, void *d2)
{
- const char *paste = d1;
+ const char *paste;
+ paste = d1;
elm_cnp_selection_set(clip_inst->ewin,
ELM_SEL_TYPE_CLIPBOARD,
ELM_SEL_FORMAT_TEXT,
paste,
strlen(paste));
- if (d2) _clipboard_popup_free((Instance *)d2);
+ if(d2)
+ _clipboard_popup_free((Instance *)d2);
}
static void
_cb_menu_post_deactivate(void *data, E_Menu *menu EINA_UNUSED)
{
- Instance *inst = data;
+ EINA_SAFETY_ON_NULL_RETURN(data);
- EINA_SAFETY_ON_NULL_RETURN(inst);
+ Instance *inst = data;
//e_gadcon_locked_set(inst->gcc->gadcon, 0);
edje_object_signal_emit(inst->o_button, "e,state,unfocused", "e");
}
@@ -486,10 +491,14 @@ _cb_action_switch(E_Object *o EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
Mouse_Event *event EINA_UNUSED)
{
- if (!strcmp(params, "float")) _clipboard_popup_new(data);
- else if (!strcmp(params, "settings")) _cb_config_show(data, NULL, NULL);
+ if (!strcmp(params, "float"))
+ _clipboard_popup_new(data);
+ else if (!strcmp(params, "settings"))
+ _cb_config_show(data, NULL, NULL);
/* Only call clear dialog if there is something to clear */
- else if (!strcmp(params, "clear") && clip_inst->items) _cb_clear_history(NULL, NULL);
+ else if (!strcmp(params, "clear") &&
+ clip_inst->items)
+ _cb_clear_history(NULL, NULL);
}
void
@@ -506,7 +515,8 @@ _clip_inst_free(Instance *inst)
{
EINA_SAFETY_ON_NULL_RETURN(inst);
inst->gcc = NULL;
- if (inst->o_button) evas_object_del(inst->o_button);
+ if(inst->o_button)
+ evas_object_del(inst->o_button);
E_FREE(inst);
}
@@ -522,47 +532,48 @@ _cliboard_cb_paste(void *data,
EINA_SAFETY_ON_NULL_RETURN_VAL(instance, EINA_TRUE);
- if (clip_inst->items) last = ((Clip_Data *)eina_list_data_get(clip_inst->items))->content;
+ if (clip_inst->items)
+ last = ((Clip_Data *) eina_list_data_get (clip_inst->items))->content;
- if (event) paste = event->data;
-
- if (!paste) return EINA_TRUE;
-
- if (!strcmp(last, paste))
- {
- if (strlen(paste) == 0) return ECORE_CALLBACK_DONE;
- if (clip_cfg->ignore_ws_copy && is_empty(paste)) return ECORE_CALLBACK_DONE;
+ if(event)
+ paste = event->data;
+ if (!paste)
+ return EINA_TRUE;
+
+ if (strcmp(last, paste ) != 0) {
+ if (strlen(paste) == 0)
+ return ECORE_CALLBACK_DONE;
+ if (clip_cfg->ignore_ws_copy && is_empty(paste)) {
+ return ECORE_CALLBACK_DONE;
+ }
cd = E_NEW(Clip_Data, 1);
- if (cd)
- {
- if (!set_clip_content(&cd->content, paste, CLIP_TRIM_MODE(clip_cfg)))
- {
- CRI("Something bad happened !!");
- /* Try to continue */
- E_FREE(cd);
- goto error;
- }
- if (!set_clip_name(&cd->name, cd->content,
- clip_cfg->ignore_ws, clip_cfg->label_length))
- {
- CRI("Something bad happened !!");
- /* Try to continue */
- E_FREE(cd);
- goto error;
- }
- _clip_add_item(cd);
- }
- }
-error:
+ if (!set_clip_content(&cd->content, paste,
+ CLIP_TRIM_MODE(clip_cfg))) {
+ CRI("Something bad happened !!");
+ /* Try to continue */
+ E_FREE(cd);
+ goto error;
+ }
+ if (!set_clip_name(&cd->name, cd->content,
+ clip_cfg->ignore_ws, clip_cfg->label_length)){
+ CRI("Something bad happened !!");
+ /* Try to continue */
+ E_FREE(cd);
+ goto error;
+ }
+ _clip_add_item(cd);
+ }
+ error:
return EINA_TRUE;
}
static void
_clipboard_cb_elm_selection_lost(void *data, Elm_Sel_Type selection)
{
- Mod_Inst *mod_inst = data;
-
+ Mod_Inst *mod_inst;
+
+ mod_inst = data;
if (selection == ELM_SEL_TYPE_CLIPBOARD)
elm_cnp_selection_get(mod_inst->ewin,
ELM_SEL_TYPE_CLIPBOARD,
@@ -576,14 +587,15 @@ _clipboard_cb_event_selection(void *data,
Evas_Object *obj EINA_UNUSED,
void *event EINA_UNUSED)
{
- Mod_Inst *mod_inst = data;
+ Mod_Inst *mod_inst;
+ mod_inst = data;
elm_cnp_selection_get(mod_inst->ewin,
ELM_SEL_TYPE_CLIPBOARD,
ELM_SEL_FORMAT_TARGETS,
_cliboard_cb_paste,
mod_inst);
- if (clip_cfg->clip_select)
+ if(clip_cfg->clip_select)
elm_cnp_selection_get(e_comp->evas,
ELM_SEL_TYPE_PRIMARY,
ELM_SEL_FORMAT_TARGETS,
@@ -608,8 +620,8 @@ e_modapi_init (E_Module *m)
/* Display this Modules config info in the main Config Panel
* Under Preferences catogory */
e_configure_registry_item_add("preferences/clipboard", 10,
- "Clipboard Settings", NULL,
- "edit-paste", config_clipboard_module);
+ "Clipboard Settings", NULL,
+ "edit-paste", config_clipboard_module);
conf_item_edd = E_CONFIG_DD_NEW("clip_cfg_Item", Config_Item);
#undef T
@@ -639,15 +651,16 @@ e_modapi_init (E_Module *m)
/* Tell E to find any existing module data. First run ? */
clip_cfg = e_config_domain_load("module.clipboard", conf_edd);
- if (clip_cfg)
- {
- /* Check config version */
- if (!e_util_module_config_check("Clipboard", clip_cfg->version, MOD_CONFIG_FILE_VERSION)) _clip_config_free();
- }
+ if (clip_cfg) {
+ /* Check config version */
+ if (!e_util_module_config_check("Clipboard", clip_cfg->version, MOD_CONFIG_FILE_VERSION))
+ _clip_config_free();
+ }
/* If we don't have a config yet, or it got erased above,
* then create a default one */
- if (!clip_cfg) _clip_config_new(m);
+ if (!clip_cfg)
+ _clip_config_new(m);
/* Initialize Einna_log for developers */
logger_init(CLIP_LOG_NAME);
@@ -658,13 +671,12 @@ e_modapi_init (E_Module *m)
/* Add Module Key Binding actions */
act = e_action_add("clipboard");
- if (act)
- {
- act->func.go = (void *) _cb_action_switch;
- e_action_predef_name_set(_("Clipboard"), ACT_FLOAT, "clipboard", "float", NULL, 0);
- e_action_predef_name_set(_("Clipboard"), ACT_CONFIG, "clipboard", "settings", NULL, 0);
- e_action_predef_name_set(_("Clipboard"), ACT_CLEAR, "clipboard", "clear", NULL, 0);
- }
+ if (act) {
+ act->func.go = (void *) _cb_action_switch;
+ e_action_predef_name_set(_("Clipboard"), ACT_FLOAT, "clipboard", "float", NULL, 0);
+ e_action_predef_name_set(_("Clipboard"), ACT_CONFIG, "clipboard", "settings", NULL, 0);
+ e_action_predef_name_set(_("Clipboard"), ACT_CLEAR, "clipboard", "clear", NULL, 0);
+ }
/* Create a global clip_inst for our module
* complete with a hidden window for event notification purposes
@@ -676,24 +688,21 @@ e_modapi_init (E_Module *m)
hist_err = read_history(&(clip_inst->items), clip_cfg->ignore_ws, clip_cfg->label_length);
if (hist_err == EET_ERROR_NONE && eina_list_count(clip_inst->items))
- {
- _clipboard_cb_paste_item(eina_list_data_get(clip_inst->items), NULL);
- }
- else clip_save(clip_inst->items); // Something must be wrong with history file - create a new one
-
+ _clipboard_cb_paste_item(eina_list_data_get(clip_inst->items), NULL);
+ else
+ /* Something must be wrong with history file
+ * so we create a new one */
+ clip_save(clip_inst->items);
/* Make sure the history read has no more items than allowed
* by clipboard config file. This should never happen without user
* intervention of some kind. */
if (clip_inst->items)
- {
- if (eina_list_count(clip_inst->items) > clip_cfg->hist_items)
- {
- /* FIXME: Do we need to warn user in case this is backed up data
- * being restored ? */
- WRN("History File truncation!");
- truncate_history(clip_cfg->hist_items);
- }
- }
+ if (eina_list_count(clip_inst->items) > clip_cfg->hist_items) {
+ /* FIXME: Do we need to warn user in case this is backed up data
+ * being restored ? */
+ WRN("History File truncation!");
+ truncate_history(clip_cfg->hist_items);
+ }
clip_inst->ewin = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
@@ -761,20 +770,18 @@ noclip:
EINA_SAFETY_ON_NULL_GOTO(clip_cfg, noconfig);
/* Kill the config dialog */
- while ((clip_cfg->config_dialog = e_config_dialog_get("E", "preferences/clipboard")))
- {
- e_object_del(E_OBJECT(clip_cfg->config_dialog));
- }
+ while((clip_cfg->config_dialog = e_config_dialog_get("E", "preferences/clipboard")))
+ e_object_del(E_OBJECT(clip_cfg->config_dialog));
- if (clip_cfg->config_dialog) e_object_del(E_OBJECT(clip_cfg->config_dialog));
+ if(clip_cfg->config_dialog)
+ e_object_del(E_OBJECT(clip_cfg->config_dialog));
E_FREE(clip_cfg->config_dialog);
/* Cleanup our item list */
- EINA_LIST_FREE(clip_cfg->items, ci)
- {
- eina_stringshare_del(ci->id);
- free(ci);
- }
+ EINA_LIST_FREE(clip_cfg->items, ci){
+ eina_stringshare_del(ci->id);
+ free(ci);
+ }
clip_cfg->module = NULL;
/* keep the planet green */
E_FREE(clip_cfg);
@@ -784,14 +791,13 @@ noconfig:
e_configure_registry_item_del("preferences/clipboard");
/* Clean up all key binding actions */
- if (act)
- {
- e_action_predef_name_del("Clipboard", ACT_FLOAT);
- e_action_predef_name_del("Clipboard", ACT_CONFIG);
- e_action_predef_name_del("Clipboard", ACT_CLEAR);
- e_action_del("clipboard");
- act = NULL;
- }
+ if (act) {
+ e_action_predef_name_del("Clipboard", ACT_FLOAT);
+ e_action_predef_name_del("Clipboard", ACT_CONFIG);
+ e_action_predef_name_del("Clipboard", ACT_CLEAR);
+ e_action_del("clipboard");
+ act = NULL;
+ }
/* Clean EET */
E_CONFIG_DD_FREE(conf_edd);
diff --git a/src/modules/clipboard/history.c b/src/modules/clipboard/history.c
index 360788444..7af720533 100644
--- a/src/modules/clipboard/history.c
+++ b/src/modules/clipboard/history.c
@@ -43,12 +43,13 @@ Eina_Bool _set_history_path(char *path);
Eina_Bool
_mkpath_if_not_exists(const char *path)
{
- Eina_Bool success = EINA_TRUE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
+ Eina_Bool success = EINA_TRUE;
- if (!ecore_file_exists(path)) return ecore_file_mkdir(path);
- return success;
+ if(!ecore_file_exists(path))
+ return ecore_file_mkdir(path);
+ return success;
}
/**
@@ -61,51 +62,51 @@ _mkpath_if_not_exists(const char *path)
Eina_Bool
_set_data_path(char *path)
{
- /* FIXME: Non-portable nix only code */
- const char *temp_str = NULL;
- Eina_Bool success = EINA_TRUE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
- /* See if XDG_DATA_HOME is defined
- * if so use it
- * if not use XDG_DATA_HOME default
- */
- temp_str = getenv("XDG_DATA_HOME");
- if (temp_str && temp_str[0] == '/' )
- {
- const int len = snprintf(NULL, 0, "%s", temp_str) + 1 +
- (temp_str[strlen(temp_str)] != '/');
- if (len <= PATH_MAX)
- {
- snprintf(path, strlen(temp_str)+1, "%s", temp_str);
- // Ensure XDG_DATA_HOME terminates in '/'
- if (path[strlen(path)-1] != '/') strncat(path, "/", PATH_MAX - strlen(path) - 1);
- }
- else PATH_MAX_ERR;
+ /* FIXME: Non-portable nix only code */
+ const char *temp_str = NULL;
+ Eina_Bool success = EINA_TRUE;
+
+ /* See if XDG_DATA_HOME is defined
+ * if so use it
+ * if not use XDG_DATA_HOME default
+ */
+ temp_str = getenv("XDG_DATA_HOME");
+ if (temp_str && temp_str[0] == '/' ) {
+ const int len = snprintf(NULL, 0, "%s", temp_str)
+ + 1 + (temp_str[strlen(temp_str)] != '/');
+ if (len <= PATH_MAX) {
+ snprintf(path, strlen(temp_str)+1, "%s", temp_str);
+ // Ensure XDG_DATA_HOME terminates in '/'
+ if (path[strlen(path)-1] != '/')
+ strncat(path, "/", PATH_MAX-strlen(path)-1);
+ }
+ else
+ PATH_MAX_ERR;
}
- // XDG_DATA_HOME default
- else
- {
+ /* XDG_DATA_HOME default */
+ else {
if (temp_str && temp_str[0] != '/')
WRN("Malformed XDG_DATA_HOME path: %s", temp_str);
struct passwd *pw = NULL;
pw = getpwuid(getuid());
temp_str = pw->pw_dir;
const int len = snprintf(NULL, 0, "%s/.local/share/", temp_str) + 1;
- if (len <= PATH_MAX)
- {
- // Hopefully unnecessary Safety check
- if (temp_str) snprintf(path, PATH_MAX-1, "%s/.local/share/", temp_str);
- else
- {
- // Should never happen
- memset(path,0,PATH_MAX);
- success = EINA_FALSE;
- }
+ if (len <= PATH_MAX) {
+ // Hopefully unnecessary Safety check
+ if (temp_str)
+ snprintf(path, PATH_MAX-1, "%s/.local/share/", temp_str);
+ else {
+ // Should never happen
+ memset(path,0,PATH_MAX);
+ success = EINA_FALSE;
}
- else PATH_MAX_ERR;
+ }
+ else
+ PATH_MAX_ERR;
}
- return success;
+ return success;
}
/**
@@ -121,25 +122,24 @@ _set_data_path(char *path)
Eina_Bool
_set_history_path(char *path)
{
- char temp_str[PATH_MAX] = {0};
- Eina_Bool success = EINA_TRUE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(path, EINA_FALSE);
+ char temp_str[PATH_MAX] = {0};
+ Eina_Bool success = EINA_TRUE;
- if (_set_data_path(path))
- {
- const int len = snprintf(NULL, 0, "%s%s/%s", path, CLIPBOARD_MOD_NAME, HISTORY_NAME) + 1;
- if (len <= PATH_MAX)
- {
- strncpy(temp_str, path, PATH_MAX-1);
- snprintf(path, PATH_MAX-1, "%s%s/", temp_str, CLIPBOARD_MOD_NAME);
- success = _mkpath_if_not_exists(path);
- strncat(path, HISTORY_NAME, PATH_MAX-strlen(path)-1);
- }
- else PATH_MAX_ERR;
- }
- else success = EINA_FALSE;
- return success;
+ if(_set_data_path(path)) {
+ const int len = snprintf(NULL, 0, "%s%s/%s", path, CLIPBOARD_MOD_NAME, HISTORY_NAME) + 1;
+ if (len <= PATH_MAX) {
+ strncpy(temp_str, path, PATH_MAX-1);
+ snprintf(path, PATH_MAX-1, "%s%s/", temp_str, CLIPBOARD_MOD_NAME);
+ success = _mkpath_if_not_exists(path);
+ strncat(path, HISTORY_NAME, PATH_MAX-strlen(path)-1);
+ }
+ else
+ PATH_MAX_ERR;
+ } else
+ success = EINA_FALSE;
+ return success;
}
/**
@@ -157,90 +157,83 @@ _set_history_path(char *path)
Eet_Error
read_history(Eina_List **items, unsigned ignore_ws, unsigned label_length)
{
- Eet_File *history_file = NULL;
- Clip_Data *cd = NULL;
- Eina_List *l = NULL;
- char history_path[PATH_MAX] = {0};
- char *ret = NULL;
- char *str = NULL;
- int size = 0;
- int str_len = 0;
- unsigned int i =0;
- long item_num = 0;
- long version = 0;
+ Eet_File *history_file = NULL;
+ Clip_Data *cd = NULL;
+ Eina_List *l = NULL;
+ char history_path[PATH_MAX] = {0};
+ char *ret = NULL;
+ char *str = NULL;
+ int size = 0;
+ int str_len = 0;
+ unsigned int i =0;
+ long item_num = 0;
+ long version = 0;
- /* Open history file */
- if (!_set_history_path(history_path))
- {
+ /* Open history file */
+ if(!_set_history_path(history_path)) {
ERR("History File Creation Error: %s", history_path);
return EET_ERROR_BAD_OBJECT;
}
- history_file = eet_open(history_path, EET_FILE_MODE_READ);
- if (!history_file)
- {
+ history_file = eet_open(history_path, EET_FILE_MODE_READ);
+ if (!history_file) {
ERR("Failed to open history file: %s", history_path);
*items = NULL;
return EET_ERROR_BAD_OBJECT;
}
- /* Check History Version */
- ret = eet_read(history_file, "VERSION", &size);
- if (!ret)
- {
+ /* Check History Version */
+ ret = eet_read(history_file, "VERSION", &size);
+ if (!ret){
INF("No version number in history file");
ret = "0";
}
- version = strtol(ret, NULL, 10);
- if (version && version != HISTORY_VERSION)
- {
+ version = strtol(ret, NULL, 10);
+ if (version && version != HISTORY_VERSION) {
INF("History file version mismatch, deleting history");
*items = NULL;
return eet_close(history_file);
}
- /* Read Number of items */
- ret = eet_read(history_file, "MAX_ITEMS", &size);
- if (!ret)
- {
+ /* Read Number of items */
+ ret = eet_read(history_file, "MAX_ITEMS", &size);
+ if (!ret) {
ERR("History file corruption: %s", history_path);
*items = NULL;
return eet_close(history_file);
}
- /* If we have no items in history wrap it up and return. */
- item_num = strtol(ret, NULL, 10);
- if (item_num <= 0)
- {
+ /* If we have no items in history wrap it up and return. */
+ item_num = strtol(ret, NULL, 10);
+ if (item_num <= 0) {
INF("History file empty or corrupt: %s", history_path);
*items = NULL;
return eet_close(history_file);
}
- /* Malloc properly sized str */
- CALLOC_DIGIT_STR(str, item_num);
- str_len = sizeof(str);
- /* Read each item */
- for (i = 1; i <= item_num; i++)
- {
- cd = E_NEW(Clip_Data, 1);
- snprintf(str, str_len, "%d", i);
- ret = eet_read(history_file, str, &size);
- if (!ret)
- {
+ /* Malloc properly sized str */
+ CALLOC_DIGIT_STR(str, item_num);
+ str_len = sizeof(str);
+ /* Read each item */
+ for (i = 1; i <= item_num; i++){
+ cd = E_NEW(Clip_Data, 1);
+ snprintf(str, str_len, "%d", i);
+ ret = eet_read(history_file, str, &size);
+ if (!ret) {
ERR("History file corruption: %s", history_path);
*items = NULL;
- if (l) E_FREE_LIST(l, free_clip_data);
+ if (l)
+ E_FREE_LIST(l, free_clip_data);
free(str);
free(cd);
return eet_close(history_file);
}
- // FIXME: DATA VALIDATION
- cd->content = strdup(ret);
- set_clip_name(&cd->name, cd->content,
- ignore_ws, label_length);
- l = eina_list_append(l, cd);
+ // FIXME: DATA VALIDATION
+ cd->content = strdup(ret);
+ set_clip_name(&cd->name, cd->content,
+ ignore_ws, label_length);
+ l = eina_list_append(l, cd);
}
- /* and wrap it up */
- free(ret);
- free(str);
- *items = l;
- return eet_close(history_file);
+ /* and wrap it up */
+ free(ret);
+ free(str);
+ *items = l;
+ return eet_close(history_file);
}
/**
@@ -259,58 +252,52 @@ read_history(Eina_List **items, unsigned ignore_ws, unsigned label_length)
Eet_Error
save_history(Eina_List *items)
{
- Eet_File *history_file = NULL;
- Eina_List *l = NULL;
- Clip_Data *cd = NULL;
- char history_path[PATH_MAX] = {0};
- char *str = NULL;
- int str_len = 0;
- unsigned int i = 1;
- unsigned int n = 0;
- Eet_Error ret;
+ Eet_File *history_file = NULL;
+ Eina_List *l = NULL;
+ Clip_Data *cd = NULL;
+ char history_path[PATH_MAX] = {0};
+ char *str = NULL;
+ int str_len = 0;
+ unsigned int i = 1;
+ unsigned int n = 0;
+ Eet_Error ret;
- /* Open history file */
- if (!_set_history_path(history_path))
- {
+ /* Open history file */
+ if(!_set_history_path(history_path)) {
ERR("History File Creation Error: %s", history_path);
return EET_ERROR_BAD_OBJECT;
}
- history_file = eet_open(history_path, EET_FILE_MODE_WRITE);
+ history_file = eet_open(history_path, EET_FILE_MODE_WRITE);
- if (history_file)
- {
+ if (history_file) {
/* Malloc properly sized str */
/* if !items, 0 items is assumed */
n = eina_list_count(items);
CALLOC_DIGIT_STR(str,n);
- str_len = sizeof(str) - 1;
+ str_len = sizeof(str)-1;
/* Write history version */
snprintf(str, str_len, "%d", (HISTORY_VERSION > 9 ? 9 : HISTORY_VERSION));
eet_write(history_file, "VERSION", str, strlen(str) + 1, 0);
/* If we have no items in history wrap it up and return */
- if (!items)
- {
- snprintf(str, str_len, "%d", 0);
- eet_write(history_file, "MAX_ITEMS", str, strlen(str) + 1, 0);
- free(str);
- return eet_close(history_file);
- }
+ if(!items) {
+ snprintf(str, str_len, "%d", 0);
+ eet_write(history_file, "MAX_ITEMS", str, strlen(str) + 1, 0);
+ free(str);
+ return eet_close(history_file);
+ }
/* Otherwise write each item */
- EINA_LIST_FOREACH(items, l, cd)
- {
- snprintf(str, str_len, "%d", i);
- eet_write(history_file, str, cd->content, strlen(cd->content) + 1, 0);
- i++;
- }
+ EINA_LIST_FOREACH(items, l, cd) {
+ snprintf(str, str_len, "%d", i);
+ eet_write(history_file, str, cd->content, strlen(cd->content) + 1, 0);
+ i++;
+ }
/* and wrap it up */
eet_write(history_file, "MAX_ITEMS", str, strlen(str) + 1, 0);
ret = eet_close(history_file);
free(str);
- }
- else
- {
+ } else {
ERR("Unable to open history file: %s", history_path);
- return EET_ERROR_BAD_OBJECT;
+ return EET_ERROR_BAD_OBJECT;
}
- return ret;
+ return ret;
}
diff --git a/src/modules/clipboard/history.h b/src/modules/clipboard/history.h
index 8879f5194..3fe37f1ac 100644
--- a/src/modules/clipboard/history.h
+++ b/src/modules/clipboard/history.h
@@ -4,7 +4,8 @@
#include "common.h"
#include "utility.h"
-Eet_Error read_history(Eina_List **items, unsigned int ignore_ws, unsigned int label_length);
+Eet_Error read_history(Eina_List **items,
+ unsigned ignore_ws, unsigned label_length);
Eet_Error save_history(Eina_List *items);
#endif
diff --git a/src/modules/clipboard/utility.c b/src/modules/clipboard/utility.c
index 303273bd2..5d3e1a54a 100644
--- a/src/modules/clipboard/utility.c
+++ b/src/modules/clipboard/utility.c
@@ -12,50 +12,47 @@ Eina_Bool
set_clip_content(char **content, char* text, int mode)
{
Eina_Bool ret = EINA_TRUE;
- char *temp, *trim;
-
- if (!text) // Sanity check
- {
- WRN("ERROR: Text is NULL\n");
- text = "";
+ char *temp;
+ char *trim;
+ /* Sanity check */
+ if (!text) {
+ WRN("ERROR: Text is NULL\n");
+ text = "";
+ }
+ if (content) {
+ switch (mode) {
+ case 0:
+ /* Don't trim */
+ temp = strdup(text);
+ break;
+ case 1:
+ /* Trim new lines */
+ trim = strip_whitespace(text, TRIM_NEWLINES);
+ temp = strdup(trim);
+ break;
+ case 2:
+ /* Trim all white Space
+ * since white space includes new lines
+ * drop thru here */
+ case 3:
+ /* Trim white space and new lines */
+ trim = strip_whitespace(text, TRIM_SPACES);
+ temp = strdup(trim);
+ break;
+ default :
+ /* Error Don't trim */
+ WRN("ERROR: Invalid strip_mode %d\n", mode);
+ temp = strdup(text);
+ break;
}
- if (content)
- {
- switch (mode)
- {
- case 0:
- /* Don't trim */
- temp = strdup(text);
- break;
- case 1:
- /* Trim new lines */
- trim = strip_whitespace(text, TRIM_NEWLINES);
- temp = strdup(trim);
- break;
- case 2:
- /* Trim all white Space
- * since white space includes new lines
- * drop thru here */
- case 3:
- /* Trim white space and new lines */
- trim = strip_whitespace(text, TRIM_SPACES);
- temp = strdup(trim);
- break;
- default :
- /* Error Don't trim */
- WRN("ERROR: Invalid strip_mode %d\n", mode);
- temp = strdup(text);
- break;
- }
- if (!temp)
- {
- /* This is bad, leave it to calling function */
- CRI("ERROR: Memory allocation Failed!!");
- ret = EINA_FALSE;
- }
- *content = temp;
+ if (!temp) {
+ /* This is bad, leave it to calling function */
+ CRI("ERROR: Memory allocation Failed!!");
+ ret = EINA_FALSE;
}
- else ERR("Error: Clip content pointer is Null!!");
+ *content = temp;
+ } else
+ ERR("Error: Clip content pointer is Null!!");
return ret;
}
@@ -65,24 +62,24 @@ set_clip_name(char **name, char * text, int mode, int n)
Eina_Bool ret = EINA_TRUE;
/* Sanity check */
- if (!text)
- {
- WRN("ERROR: Text is NULL\n");
- text = "";
- }
+ if (!text) {
+ WRN("ERROR: Text is NULL\n");
+ text = "";
+ }
/* to be continued latter */
- if (name) *name = _sanitize_ln(text, n, mode);
- else
- {
- ERR("Error: Clip name pointer is Null!!");
- return EINA_FALSE;
- }
- if (!*name)
- {
+ if (name)
+ *name = _sanitize_ln(text, n, mode);
+ else {
+ ERR("Error: Clip name pointer is Null!!");
+ return EINA_FALSE;
+ }
+
+ if (!*name) {
/* This is bad, leave it to calling function */
CRI("ERROR: Memory allocation Failed!!");
ret = EINA_FALSE;
}
+
return ret;
}
@@ -98,33 +95,34 @@ _sanitize_ln(char *text, const unsigned int n, const int mode)
if (!ret) return NULL;
- if (mode) text = strip_whitespace(text, TRIM_SPACES);
+ if (mode)
+ text = strip_whitespace(text, TRIM_SPACES);
- for (;;)
- {
- chr = *text;
- if (chr == 0) break;
- if (chr < 32)
- { // is it a tab
- if (chr == '\t')
- {
- // default tab
- for (; i + 4; i++)
- { // XXX: we inset tabs... is n big enough? we truncate? why?
- if (i == n) break;
- *temp++ = ' ';
- }
- text++;
- }
- else text++;
+ while (1) {
+ chr = *text;
+ if (chr == 0)
+ break;
+ if (chr < 32) {
+ /* is it a tab */
+ if (chr == 9){
+ // default tab
+ for (; i + 4; i++){
+ if (i == n) break;
+ *temp++ = ' ';
}
- else
- { // assume char is ok and add to temp buffer
- *temp++ = *text++;
- i++;
- }
- if (i == n) break;
+ text++;
+ }
+ else {
+ text++;
+ }
}
+ else {
+ /* assume char is ok and add to temp buffer */
+ *temp++ = *text++;
+ i++;
+ }
+ if (i == n) break;
+ }
*temp = 0;
return ret;
}
@@ -153,15 +151,17 @@ strip_whitespace(char *str, int mode)
if (mode == TRIM_SPACES) compare = isspace;
else compare = isnewline;
- while ((*compare)(*str)) str++;
+ while((*compare)(*str)) str++;
- if (*str == 0) return str; // empty string ?
+ if(*str == 0) // empty string ?
+ return str;
end = str + strlen(str) - 1;
- while(end > str && (*compare)(*end)) end--;
+ while(end > str && (*compare)(*end))
+ end--;
// Write new null terminator
- *(end + 1) = 0;
+ *(end+1) = 0;
return str;
}
@@ -169,14 +169,14 @@ strip_whitespace(char *str, int mode)
int
isnewline(const int c)
{
- return ((c == '\n') || (c == '\r'));
+ return (c == '\n')||(c == '\r');
}
-Eina_Bool
+Eina_Bool
is_empty(const char *str)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_TRUE);
-
- while (isspace((unsigned char)*str) && str++);
+
+ while (isspace((unsigned char) *str) && str++);
return !*str;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.