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 747648eadb4bf722326f25156d27d4fb2fdf89fa
Author: Carsten Haitzler <[email protected]>
AuthorDate: Wed Jan 7 18:26:57 2026 +0000
reduce config items ... also spotted bugs waiting XXXd them
---
src/modules/clipboard/e_mod_config.c | 80 +++------------------------------
src/modules/clipboard/e_mod_main.c | 51 +++++----------------
src/modules/clipboard/e_mod_main.h | 19 +++-----
src/modules/clipboard/utility.c | 87 ++++++++----------------------------
4 files changed, 40 insertions(+), 197 deletions(-)
diff --git a/src/modules/clipboard/e_mod_config.c b/src/modules/clipboard/e_mod_config.c
index 939accaf5..a8d7d1dd2 100644
--- a/src/modules/clipboard/e_mod_config.c
+++ b/src/modules/clipboard/e_mod_config.c
@@ -64,15 +64,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->clip_copy = clip_cfg->clip_copy;
cfdata->clip_select = clip_cfg->clip_select;
- cfdata->persistence = clip_cfg->persistence;
cfdata->hist_reverse = clip_cfg->hist_reverse;
cfdata->hist_items = clip_cfg->hist_items;
- cfdata->confirm_clear = clip_cfg->confirm_clear;
cfdata->label_length = clip_cfg->label_length;
- cfdata->ignore_ws = clip_cfg->ignore_ws;
- cfdata->ignore_ws_copy = clip_cfg->ignore_ws_copy;
- cfdata->trim_ws = clip_cfg->trim_ws;
- cfdata->trim_nl = clip_cfg->trim_nl;
}
static int
@@ -80,16 +74,11 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
{
clip_cfg->clip_copy = cfdata->clip_copy;
clip_cfg->clip_select = cfdata->clip_select;
- clip_cfg->persistence = cfdata->persistence;
clip_cfg->hist_reverse = cfdata->hist_reverse;
-
- // do we need to Truncate our history list?
+ // truncate hist list if needed
if (clip_cfg->hist_items != (unsigned int)cfdata->hist_items)
config_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)
{
@@ -97,12 +86,6 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
cfdata->init_label_length = cfdata->label_length;
}
clip_cfg->label_length = cfdata->label_length;
-
- clip_cfg->ignore_ws = cfdata->ignore_ws;
- clip_cfg->ignore_ws_copy = cfdata->ignore_ws_copy;
- clip_cfg->trim_ws = cfdata->trim_ws;
- clip_cfg->trim_nl = cfdata->trim_nl;
-
// now save configuration
e_config_save_queue();
return 1;
@@ -128,15 +111,10 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
// history config section
of = e_widget_framelist_add(evas, _("History"), 0);
- ob = e_widget_check_add(evas, _(" Save History"), &(cfdata->persistence));
- e_widget_framelist_object_append(of, ob);
ob = e_widget_check_add(evas, _(" Reverse Order"), &(cfdata->hist_reverse));
e_widget_framelist_object_append(of, ob);
- ob = e_widget_check_add(evas, _(" Confirm before Clearing"), &(cfdata->confirm_clear));
- e_widget_framelist_object_append(of, ob);
-
ob = e_widget_label_add(evas, _(" Items in History"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, "%2.0f", HIST_MIN, HIST_MAX, 1.0, 0, &(cfdata->hist_items), NULL, 40);
@@ -145,10 +123,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_list_object_append(o, of, 1, 0, 0.5);
// label config section
- of = e_widget_framelist_add(evas, _("Labels"), 0);
- ob = e_widget_check_add(evas, _(" Ignore Whitespace"), &(cfdata->ignore_ws));
- e_widget_framelist_object_append(of, ob);
-
ob = e_widget_label_add(evas, _(" Label Length"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, "%2.0f", LABEL_MIN, LABEL_MAX, 1.0, 0, &(cfdata->label_length), NULL, 40);
@@ -156,19 +130,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_list_object_append(o, of, 1, 0, 0.5);
- // content config section
- of = e_widget_framelist_add(evas, _("Content"), 0);
- ob = e_widget_check_add(evas, _(" Ignore Whitespace"), &(cfdata->ignore_ws_copy));
- e_widget_framelist_object_append(of, ob);
-
- ob = e_widget_check_add(evas, _(" Trim Whitespace"), &(cfdata->trim_ws));
- e_widget_framelist_object_append(of, ob);
-
- ob = e_widget_check_add(evas, _(" Trim Newlines"), &(cfdata->trim_nl));
- e_widget_framelist_object_append(of, ob);
-
- e_widget_list_object_append(o, of, 1, 0, 0.5);
-
e_dialog_resizable_set(cfd->dia, EINA_TRUE);
return o;
}
@@ -200,15 +161,9 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfd
{
if (clip_cfg->clip_copy != cfdata->clip_copy) return 1;
if (clip_cfg->clip_select != cfdata->clip_select) return 1;
- if (clip_cfg->persistence != cfdata->persistence) return 1;
if (clip_cfg->hist_reverse != cfdata->hist_reverse) return 1;
if (clip_cfg->hist_items != (unsigned int)cfdata->hist_items) return 1;
- if (clip_cfg->confirm_clear != cfdata->confirm_clear) return 1;
if (clip_cfg->label_length != (unsigned int)cfdata->label_length) return 1;
- if (clip_cfg->ignore_ws != cfdata->ignore_ws) return 1;
- if (clip_cfg->ignore_ws_copy != cfdata->ignore_ws_copy) return 1;
- if (clip_cfg->trim_ws != cfdata->trim_ws) return 1;
- if (clip_cfg->trim_nl != cfdata->trim_nl) return 1;
return 0;
}
@@ -233,16 +188,10 @@ config_init(void)
E_CONFIG_VAL(D, T, version, UINT);
E_CONFIG_LIST(D, T, items, conf_item_edd);
E_CONFIG_VAL(D, T, label_length, UINT);
- E_CONFIG_VAL(D, T, hist_items, INT);
- E_CONFIG_VAL(D, T, clip_copy, INT);
- E_CONFIG_VAL(D, T, clip_select, INT);
- E_CONFIG_VAL(D, T, persistence, INT);
- E_CONFIG_VAL(D, T, hist_reverse, INT);
- E_CONFIG_VAL(D, T, confirm_clear, INT);
- E_CONFIG_VAL(D, T, ignore_ws, INT);
- E_CONFIG_VAL(D, T, ignore_ws_copy, INT);
- E_CONFIG_VAL(D, T, trim_ws, INT);
- E_CONFIG_VAL(D, T, trim_nl, INT);
+ E_CONFIG_VAL(D, T, hist_items, UINT);
+ E_CONFIG_VAL(D, T, clip_copy, UCHAR);
+ E_CONFIG_VAL(D, T, clip_select, UCHAR);
+ E_CONFIG_VAL(D, T, hist_reverse, UCHAR);
clip_cfg = e_config_domain_load("module.clipboard", conf_edd);
if (clip_cfg)
@@ -272,33 +221,16 @@ conifg_new_limit(void)
clip_cfg->label_length_changed = EINA_FALSE;
clip_cfg->clip_copy = 1;
clip_cfg->clip_select = 1;
- clip_cfg->persistence = 1;
clip_cfg->hist_reverse = 0;
clip_cfg->hist_items = 20;
- clip_cfg->confirm_clear = 1;
clip_cfg->label_length = 50;
- clip_cfg->ignore_ws = 0;
- clip_cfg->ignore_ws_copy = 0;
- clip_cfg->trim_ws = 0;
- clip_cfg->trim_nl = 0;
}
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);
E_CONFIG_LIMIT(clip_cfg->clip_select, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->persistence, 0, 1);
E_CONFIG_LIMIT(clip_cfg->hist_reverse, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->confirm_clear, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->ignore_ws, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->ignore_ws_copy, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->trim_ws, 0, 1);
- E_CONFIG_LIMIT(clip_cfg->trim_nl, 0, 1);
-
- if (clip_cfg->version != MOD_CONFIG_FILE_VERSION)
- { // config is new or older - thus changed so save out
- clip_cfg->version = MOD_CONFIG_FILE_VERSION;
- e_config_save_queue();
- }
+ clip_cfg->version = MOD_CONFIG_FILE_VERSION;
return EINA_TRUE;
}
diff --git a/src/modules/clipboard/e_mod_main.c b/src/modules/clipboard/e_mod_main.c
index 552b3967c..0972824e7 100644
--- a/src/modules/clipboard/e_mod_main.c
+++ b/src/modules/clipboard/e_mod_main.c
@@ -40,8 +40,6 @@ static void _clipboard_cb_paste_item(void *d1, void *d2);
static void _cb_menu_post_deactivate(void *data, E_Menu *menu EINA_UNUSED);
static void _cb_context_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Event_Mouse_Down *event);
static void _cb_clear_history(void *d1, void *d2 EINA_UNUSED);
-static void _cb_dialog_delete(void *data EINA_UNUSED);
-static void _cb_dialog_keep(void *data EINA_UNUSED);
static void _cb_action_switch(E_Object *o EINA_UNUSED, const char *params);
static void _cb_config_show(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED);
@@ -228,6 +226,7 @@ _clipboard_popup_new(Instance *inst)
inst->table = e_widget_table_add(e_win_evas_win_get(evas), 0);
+ // make this a scrollable genlist...
if (clip_cfg->items)
{
Eina_List *it;
@@ -251,14 +250,13 @@ _clipboard_popup_new(Instance *inst)
if (!cd->name)
{
eina_stringshare_del(cd->name);
- set_clip_name(&cd->name, cd->str,
- clip_cfg->ignore_ws, clip_cfg->label_length);
+ set_clip_name(&cd->name, cd->str, clip_cfg->label_length);
}
o = e_widget_button_add(evas,
cd->name,
NULL,
_clipboard_cb_paste_item,
- cd->str,
+ (void *)cd->str, // XXX: what if items list changes while buttons up?
inst);
e_widget_table_object_align_append(inst->table, o, 0, row, 2, 1, 1, 0, 1, 0, 0, 0.5);
row++;
@@ -273,6 +271,7 @@ _clipboard_popup_new(Instance *inst)
row++;
}
+ // XXX: make this a box - homogeneous below lsit above
o = e_widget_button_add(evas, _("Clear"), "edit-clear", _cb_clear_history, inst, NULL);
e_widget_disabled_set(o, !clip_cfg->items);
e_widget_table_object_align_append(inst->table, o, 0, row, 1, 1, 0, 0, 0, 0, 0.5, 0.5);
@@ -353,31 +352,7 @@ static void
_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();
_clipboard_popup_free((Instance *)d1);
-}
-
-static void
-_cb_dialog_keep(void *data EINA_UNUSED)
-{
- return;
-}
-
-static void
-_cb_dialog_delete(void *data EINA_UNUSED)
-{
_clear_history();
}
@@ -435,7 +410,7 @@ _cliboard_cb_paste(void *data,
Config_Item *cd = NULL;
Instance *instance = data;
char *paste = NULL;
- char *last = "";
+ const char *last = "";
EINA_SAFETY_ON_NULL_RETURN_VAL(instance, EINA_TRUE);
@@ -446,21 +421,15 @@ _cliboard_cb_paste(void *data,
if (!paste) return EINA_TRUE;
if (!!strcmp(last, paste))
- {
+ { // if new past differs to most recent stored...
if (strlen(paste) == 0) return ECORE_CALLBACK_DONE;
- if (clip_cfg->ignore_ws_copy && is_empty(paste)) return ECORE_CALLBACK_DONE;
+ if (is_empty(paste)) return ECORE_CALLBACK_DONE;
cd = E_NEW(Config_Item, 1);
if (cd)
{
- if (!set_clip_content(&cd->str, paste,
- CLIP_TRIM_MODE(clip_cfg)))
- { // try to continue
- CRI("Something bad happened !!");
- E_FREE(cd);
- goto error;
- }
- if (!set_clip_name(&cd->name, cd->str,
- clip_cfg->ignore_ws, clip_cfg->label_length))
+ // XXX: if we select huge amounts of text this could use a lot of ram
+ cd->str = eina_stringshare_add(paste);
+ if (!set_clip_name(&cd->name, cd->str, clip_cfg->label_length))
{ // try to continue
CRI("Something bad happened !!");
E_FREE(cd);
diff --git a/src/modules/clipboard/e_mod_main.h b/src/modules/clipboard/e_mod_main.h
index 6299c25a2..7cc071960 100644
--- a/src/modules/clipboard/e_mod_main.h
+++ b/src/modules/clipboard/e_mod_main.h
@@ -34,7 +34,7 @@ EAPI int e_modapi_save (E_Module *m EINA_UNUSED);
// compatible anymore, it creates an entire new one.
// You need to increment GENERATION when you add new values to the
// configuration file but is not needed to delete the existing conf
-#define MOD_CONFIG_FILE_EPOCH 1
+#define MOD_CONFIG_FILE_EPOCH 2
#define MOD_CONFIG_FILE_GENERATION 4
#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION)
@@ -82,27 +82,20 @@ struct _Config
unsigned int hist_items; /* Number of history items to store */
unsigned int label_length; /* Number of characters of item to display */
// these are booleans really...
- int clip_copy; /* Clipboard to use */
- int clip_select; /* Clipboard to use */
- int persistence; /* History file persistance */
- int hist_reverse; /* Order to display History */
- int confirm_clear; /* Display history confirmation dialog on deletion */
- int ignore_ws; /* Should we ignore White space in label */
- int ignore_ws_copy; /* Should we not copy White space only */
- int trim_ws; /* Should we trim White space from selection */
- int trim_nl; /* Should we trim new lines from selection */
+ unsigned char clip_copy; /* Clipboard to use */
+ unsigned char clip_select; /* Clipboard to use */
+ unsigned char hist_reverse; /* Order to display History */
};
struct _Config_Item
{
char *name; // cut down label/name for gui
- char *str; // stored string
+ const char *str; // stored string (stringshare)
};
E_Config_Dialog *config_clipboard_module(Evas_Object *parent, const char *params EINA_UNUSED);
-Eina_Bool set_clip_content(char **content, char *text, int mode);
-Eina_Bool set_clip_name(char **name, char *text, int mode, int n);
+Eina_Bool set_clip_name(char **name, const char *text, int max);
Eina_Bool is_empty(const char *str);
extern Config *clip_cfg;
diff --git a/src/modules/clipboard/utility.c b/src/modules/clipboard/utility.c
index ae20f2432..f1e46da61 100644
--- a/src/modules/clipboard/utility.c
+++ b/src/modules/clipboard/utility.c
@@ -1,22 +1,19 @@
#include "e_mod_main.h"
-#define TRIM_SPACES 0
-#define TRIM_NEWLINES 1
-
-static char *_strip_whitespace (char *str, int mode);
-static int _is_newline (const int c);
+static char *_strip_whitespace(char *str);
static char *
-_sanitize_ln(char *text, const unsigned int n, const int mode)
+_sanitize_ln(char *text, const unsigned int n)
{
char *ret = malloc(n + 1);
char *temp = ret;
- unsigned int chr, i = 0;
+ unsigned char chr;
+ unsigned int i = 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
if (!ret) return NULL;
- if (mode) text = _strip_whitespace(text, TRIM_SPACES);
+ text = _strip_whitespace(text);
for (;;)
{
chr = *text;
@@ -60,88 +57,40 @@ _sanitize_ln(char *text, const unsigned int n, const int mode)
* You have been warned!!
*/
char *
-_strip_whitespace(char *str, int mode)
+_strip_whitespace(char *str)
{
char *end;
- int (*compare)(int);
- if (mode == TRIM_SPACES) compare = isspace;
- else compare = _is_newline;
- while ((*compare)(*str)) str++;
- if (*str == 0) return str; // empty string ?
+ while (isspace(str[0])) str++;
+ if (str[0] == 0) return str; // empty string ?
end = str + strlen(str) - 1;
- while ((end > str) && (*compare)(*end)) end--;
- *(end + 1) = 0; // write new null terminator
+ while ((end > str) && isspace(end[0])) end--;
+ (end + 1)[0] = 0; // write new null terminator
return str;
}
-static int
-_is_newline(const int c)
-{
- return ((c == '\n') || (c == '\r'));
-}
-
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 = "";
- }
- 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 whitespace since white space includes new lines drop thru here
- EINA_FALLTHROUGH;
- 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;
- }
- else ERR("Error: Clip content pointer is Null!!");
- return ret;
-}
-
-Eina_Bool
-set_clip_name(char **name, char *text, int mode, int n)
-{
+set_clip_name(char **name, const char *text, int max)
+{ // this is dodgey.. do a proper processing into tb mrkup for genlist
Eina_Bool ret = EINA_TRUE;
+ char *text2;
if (!text) // sanity check
{
WRN("ERROR: Text is NULL\n");
text = "";
}
+ text2 = strdup(text);
+ if (!text2) return EINA_FALSE;
// to be continued later
- if (name) *name = _sanitize_ln(text, n, mode);
+ if (name) *name = _sanitize_ln(text2, max);
else
{
+ free(text2);
ERR("Error: Clip name pointer is Null!!");
return EINA_FALSE;
}
+ free(text2);
if (!*name)
{ // this is bad, leave it to calling function
CRI("ERROR: Memory allocation Failed!!");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.