This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit 2187a7df140570c1aa8662c96a75e1df459dc48f
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Oct 24 18:04:42 2023 +0100

    add segmentctl and hoversel details
---
 TODO.md                 |   2 -
 src/backends/table/open |  30 +++++---
 src/efm/efm_util.c      | 178 ++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 183 insertions(+), 27 deletions(-)

diff --git a/TODO.md b/TODO.md
index 27c4b9f..8fdfb43 100644
--- a/TODO.md
+++ b/TODO.md
@@ -63,8 +63,6 @@
     * multiple graphs
   * slider
   * range (slider 2 val)
-  * segmentcontrol
-  * hoversel
 
 ## Medium term
 
diff --git a/src/backends/table/open b/src/backends/table/open
index 135ce34..93249fa 100755
--- a/src/backends/table/open
+++ b/src/backends/table/open
@@ -85,9 +85,13 @@ function e_loop() {
         read -a A <<< ${ARGS[$I]}
         IFS="$PIFS"
         KEY=${A[0]}
-        e_val_unescape VAL ${A[1]}
-        NEWARGS+=(${KEY})
-        NEWARGS+=(${VAL})
+        if test -n "$KEY"; then
+          e_val_unescape VAL ${A[1]}
+          NEWARGS+=(${KEY})
+          PIFS="$IFS"; IFS=""
+          NEWARGS+=(${VAL})
+          IFS="$PIFS"
+        fi
       done
       handle_cmd NEWARGS "$CMD"
     fi
@@ -119,25 +123,25 @@ function handle_cmd_dir_set() {
   M="type=file icon="${M}
 # add one new file (4 of them) with params
 
-D="detail-format=text,text,progress,checkview,button,size"
+D="detail-format=text,popdown,progress,checkview,button,size"
   e_val_escape F ${DIR}"abba"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=one detail2=two detail3=33/100 detail4=1 detail5=Click,dance.gif detail6=576/65536"
+    " detail1=one detail2=Opt1!dance.gif,*Opt2!std:clock detail3=33/100 detail4=1 detail5=Click!dance.gif detail6=576/65536"
 
-  D="detail-format=text,text,progress,checkview,button,size"
+  D="detail-format=text,popdown,progress,checkview,button,size"
   e_val_escape F ${DIR}"boopy__==!@#$%^&*();"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=one detail2=two detail3=noval,55/100 detail4=0 detail5=Pressme,std:security-high detail6=16384/65536"
+    " detail1=one detail2=Opt1,Opt2,*Opt3,Opt4 detail3=noval,55/100 detail4=0 detail5=Pressme!std:security-high detail6=16384/65536"
 
-  D="detail-format=icon,check,circle,checkview,timestamp,size"
+  D="detail-format=icon,check,circle,segmentsel,timestamp,size"
   e_val_escape F ${DIR}"g h i"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=std:dialog-error detail2=true detail3=cc::selected detail4=true detail5=1696322215 detail6=65535/65536"
+    " detail1=std:dialog-error detail2=true detail3=cc::selected detail4=*!dance.gif,!std:audio-card,!std:camera detail5=1696322215 detail6=65535/65536"
 
-  D="detail-format=icon,check,circle,checkview,timestamp,size"
+  D="detail-format=icon,check,circle,segmentsel,timestamp,size"
   e_val_escape F ${DIR}"z~"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=dance.gif detail2=false detail3=#ff665580 detail4=false detail5=1296332215 detail6=7823/65536"
+    " detail1=dance.gif detail2=false detail3=#ff665580 detail4=Option1,Opt2,*O3 detail5=1296332215 detail6=7823/65536"
 # end initial listing of files
   e_cmd "list-end"
 }
@@ -149,6 +153,7 @@ function handle_cmd() {
   local -n ARGS=${1}
   local ARGSLEN=${#ARGS[@]}
   local CMD
+
   CMD=${2}
   case "$CMD" in
     # handle command to set the dir to scan/look at
@@ -193,6 +198,9 @@ function handle_cmd() {
     file-detail-clicked )
       e_err "file-detail-clicked" ${ARGS[0]} ${ARGS[1]} ${ARGS[2]} ${ARGS[3]}
       ;;
+    file-detail-select )
+      e_err "file-detail-select" ${ARGS[0]} ${ARGS[1]} ${ARGS[2]} ${ARGS[3]} ${ARGS[4]} ${ARGS[5]}
+      ;;
   esac
 }
 
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 0e0e2e4..ef46bf8 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -1272,7 +1272,7 @@ _cb_icon_detail_check_changed(void *data, Evas_Object *o,
 
 static void
 _cb_icon_detail_button_clicked(void *data, Evas_Object *o,
-                              void *info EINA_UNUSED)
+                               void *info EINA_UNUSED)
 {
   Icon        *icon  = data;
   Eina_Strbuf *buf   = cmd_strbuf_new("file-detail-clicked");
@@ -1286,6 +1286,46 @@ _cb_icon_detail_button_clicked(void *data, Evas_Object *o,
   cmd_strbuf_exe_consume(buf, icon->sd->exe_open);
 }
 
+static void
+_cb_icon_detail_segment_changed(void *data, Evas_Object *o,
+                                void *info)
+{
+  Icon            *icon  = data;
+  Eina_Strbuf     *buf   = cmd_strbuf_new("file-detail-select");
+  int              v;
+  char             detail[32];
+  Elm_Object_Item *it    = info;
+  int              n     = (int)(unsigned long)elm_object_item_data_get(it);
+
+  _icon_path_cmd_strbuf_append(buf, "path", icon->sd, icon);
+  v = (int)(unsigned long)evas_object_data_get(o, "detail");
+  snprintf(detail, sizeof(detail), "detail%i", v);
+  cmd_strbuf_append(buf, "detail", detail);
+  snprintf(detail, sizeof(detail), "%i", n);
+  cmd_strbuf_append(buf, "item", detail);
+  cmd_strbuf_exe_consume(buf, icon->sd->exe_open);
+}
+
+static void
+_cb_icon_detail_popdown_changed(void *data, Evas_Object *o,
+                                void *info)
+{
+  Icon            *icon  = data;
+  Eina_Strbuf     *buf   = cmd_strbuf_new("file-detail-select");
+  int              v;
+  char             detail[32];
+  Elm_Object_Item *it    = info;
+  int              n     = (int)(unsigned long)elm_object_item_data_get(it);
+
+  _icon_path_cmd_strbuf_append(buf, "path", icon->sd, icon);
+  v = (int)(unsigned long)evas_object_data_get(o, "detail");
+  snprintf(detail, sizeof(detail), "detail%i", v);
+  cmd_strbuf_append(buf, "detail", detail);
+  snprintf(detail, sizeof(detail), "%i", n);
+  cmd_strbuf_append(buf, "item", detail);
+  cmd_strbuf_exe_consume(buf, icon->sd->exe_open);
+}
+
 static Evas_Object *
 _icon_detail_icon_add(Evas_Object *base, const char *icon, const char *dir)
 {
@@ -1325,6 +1365,14 @@ _icon_detail_bool_parse(const char *str)
   return EINA_FALSE;
 }
 
+static void
+_icon_detail_elm_object_prepare(Evas_Object *o, int col)
+{
+  elm_object_focus_allow_set(o, EINA_FALSE);
+  evas_object_data_set(o, "detail", (void *)(unsigned long)(col + 1));
+  evas_object_propagate_events_set(o, EINA_FALSE);
+}
+
 static void
 _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                  const char *theme_edj_file, int col, const char *detail,
@@ -1398,7 +1446,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
 
       o = _icon_detail_grid_add(icon, sd, col);
       o = elm_progressbar_add(o);
-      evas_object_pass_events_set(o, EINA_TRUE);
+      _icon_detail_elm_object_prepare(o, col);
       elm_progressbar_horizontal_set(o, EINA_TRUE);
       elm_progressbar_span_size_set(o, 1);
       elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
@@ -1440,9 +1488,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       o2 = elm_table_add(o);
       elm_grid_pack(icon->o_list_detail_swallow[col], o2, 0, 0, 1, 1);
       o = elm_check_add(o);
-      elm_object_focus_allow_set(o, EINA_FALSE);
-      evas_object_data_set(o, "detail", (void *)(unsigned long)(col + 1));
-      evas_object_propagate_events_set(o, EINA_FALSE);
+      _icon_detail_elm_object_prepare(o, col);
       elm_table_pack(o2, o, 0, 0, 1, 1);
       elm_check_state_set(o, _icon_detail_bool_parse(detail));
       evas_object_smart_callback_add(o, "changed",
@@ -1451,22 +1497,21 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       evas_object_show(o);
     }
   else if (!strcmp(format, "button"))
-    { // format: "Label" or "Label,icon" where icon is same as icon above
-      char *label, *p;
+    { // format: "Label" or "Label!icon" = icon above
+      char *label, *sep;
 
       o = _icon_detail_grid_add(icon, sd, col);
       o = elm_button_add(o);
-      elm_object_focus_allow_set(o, EINA_FALSE);
-      evas_object_data_set(o, "detail", (void *)(unsigned long)(col + 1));
-      evas_object_propagate_events_set(o, EINA_FALSE);
+      _icon_detail_elm_object_prepare(o, col);
+      elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
       label = strdup(detail);
       if (label)
         {
-          p = strchr(label, ',');
-          if (p)
+          sep = strchr(label, '!');
+          if (sep)
             {
-              *p++ = 0;
-              o2 = _icon_detail_icon_add(o, p, sd->config.path);
+              *sep++ = 0;
+              o2 = _icon_detail_icon_add(o, sep, sd->config.path);
               elm_object_part_content_set(o, "icon", o2);
               evas_object_show(o2);
             }
@@ -1476,7 +1521,112 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                                          icon);
           free(label);
         }
+      evas_object_show(o);
+    }
+  else if (!strcmp(format, "segmentsel"))
+    { // format: "Opt1,*Opt2" or "*Opt!icon,Opt2" = icon above, *= SELECTED
+      char **plist, **p, *sep, *label;
+      Elm_Object_Item *it;
+      Eina_Bool sel;
+      int n;
+
+      o = _icon_detail_grid_add(icon, sd, col);
+      o = elm_segment_control_add(o);
+      _icon_detail_elm_object_prepare(o, col);
+      elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+      plist = eina_str_split(detail, ",", -1);
+      for (p = plist, n = 0; *p != NULL; p++, n++)
+        {
+          sel = EINA_FALSE;
+          o2 = NULL;
+          sep = strchr(*p, '!');
+          if (sep)
+            {
+              *sep++ = 0;
+              o2 = _icon_detail_icon_add(o, sep, sd->config.path);
+            }
+          label = *p;
+          if (**p == '*')
+            {
+              label++;
+              sel = EINA_TRUE;
+            }
+          if (*label) it = elm_segment_control_item_add(o, o2, label);
+          else it = elm_segment_control_item_add(o, o2, NULL);
+          elm_object_item_data_set(it, (void *)(unsigned long)n);
+          if (sel) elm_segment_control_item_selected_set(it, EINA_TRUE);
+          if (o2) evas_object_show(o2);
+        }
+      evas_object_smart_callback_add(o, "changed",
+                                     _cb_icon_detail_segment_changed,
+                                     icon);
+      free(*plist);
+      free(plist);
+      evas_object_show(o);
+    }
+  else if (!strcmp(format, "popdown"))
+    { // format: "Opt1,*Opt2" or "*Opt!icon,Opt2" = icon above, *= SELECTED
+      char **plist, **p, *sep, *label, *icpath;
+      Elm_Object_Item *it;
+      Eina_Bool sel;
+      Elm_Icon_Type ictype;
+      char buf[PATH_MAX];
+      int n;
+
+      o = _icon_detail_grid_add(icon, sd, col);
+      o = elm_hoversel_add(o);
+      elm_hoversel_auto_update_set(o, EINA_TRUE);
+      elm_hoversel_hover_parent_set(o, sd->o_scroller);
+      _icon_detail_elm_object_prepare(o, col);
       elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+      plist = eina_str_split(detail, ",", -1);
+      for (p = plist, n = 0; *p != NULL; p++, n++)
+        {
+          sel = EINA_FALSE;
+          o2 = NULL;
+          icpath = NULL;
+          ictype = ELM_ICON_NONE;
+          sep = strchr(*p, '!');
+          if (sep)
+            {
+              *sep++ = 0;
+              if (!strncmp(sep, "std:", 4))
+                {
+                  snprintf(buf, sizeof(buf), "%s", sep + 4);
+                  icpath = buf;
+                  ictype = ELM_ICON_STANDARD;
+                }
+              else if (sep[0] == '/')
+                {
+                  snprintf(buf, sizeof(buf), "%s", sep);
+                  icpath = buf;
+                  ictype = ELM_ICON_FILE;
+                }
+              else
+                {
+                  snprintf(buf, sizeof(buf), "%s%s", sd->config.path, sep);
+                  icpath = buf;
+                  ictype = ELM_ICON_FILE;
+                }
+            }
+          label = *p;
+          if (**p == '*')
+            {
+              label++;
+              sel = EINA_TRUE;
+            }
+          if (**p) it = elm_hoversel_item_add(o, label, icpath, ictype,
+                                              NULL, NULL);
+          else it = elm_hoversel_item_add(o, label, icpath, ictype,
+                                          NULL, NULL);
+          elm_object_item_data_set(it, (void *)(unsigned long)n);
+          if (sel) elm_object_text_set(o, label);
+        }
+      evas_object_smart_callback_add(o, "selected",
+                                     _cb_icon_detail_popdown_changed,
+                                     icon);
+      free(*plist);
+      free(plist);
       evas_object_show(o);
     }
   else

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to