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 aea8698d80f88dfb9c67d58a67b85bec8d2c7739
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Thu Mar 20 14:12:34 2025 +0000
add a PROPER right clikc menu based on fle content...
now right click on an icon presents a proper menu. right now open and
the list of possible desktop apps to open with all works. it also
modifies your mimeapps list to use by default whatever you used last
like efm does. have to fix right clikc in blank space though. not done
yet
---
src/efm/efm_back_end.c | 1 -
src/efm/efm_menu.c | 2 +-
src/efm/efm_popup_menu.c | 254 +++++++++++++++++++++++++++++++++++++++++++++--
src/efm/efm_util.c | 3 +-
src/shared/mimeapps.c | 28 +++++-
src/shared/mimeapps.h | 4 +-
6 files changed, 279 insertions(+), 13 deletions(-)
diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c
index 5faec7e..c29a74c 100644
--- a/src/efm/efm_back_end.c
+++ b/src/efm/efm_back_end.c
@@ -1,7 +1,6 @@
#include "cmd.h"
#include "efm_structs.h"
#include "efreet_desktop.h"
-#include "eina_log.h"
#include "sort.h"
#include "efm.h"
#include "efm_util.h"
diff --git a/src/efm/efm_menu.c b/src/efm/efm_menu.c
index 407c503..10cd4ec 100644
--- a/src/efm/efm_menu.c
+++ b/src/efm/efm_menu.c
@@ -71,7 +71,7 @@ _mi_add(Efm_Menu *m, Efm_Menu_Item_Type type, const char *label,
eina_stringshare_replace(&(mi->icon), icon);
mi->private1 = cb;
mi->private2 = data;
- mi->private2 = data2;
+ mi->private3 = data2;
return mi;
}
diff --git a/src/efm/efm_popup_menu.c b/src/efm/efm_popup_menu.c
index 872d07e..e4d64f3 100644
--- a/src/efm/efm_popup_menu.c
+++ b/src/efm/efm_popup_menu.c
@@ -1,12 +1,13 @@
#include "efm.h"
#include "efm_private.h"
#include "efm_structs.h"
-#include "eina_types.h"
+#include "efm_util.h"
+#include "mimeapps.h"
static void
_cb_menu_done(void *data, void *data2, Evas_Object *efm, const Efm_Menu *menu)
{
- printf("menu done\n");
+ printf("menu done\n");
}
static void
@@ -114,13 +115,252 @@ _icon_strbuf_icon_def(Icon *icon, Eina_Strbuf *icbuf)
return icstr;
}
+typedef struct
+{
+ Smart_Data *sd;
+ Efreet_Desktop *d_main;
+ Eina_List *desktops;
+ const char *mime;
+} Popup_Context;
+
+static void
+_cb_menu_file_done(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu *menu)
+{
+ Popup_Context *ctx = data;
+ Efreet_Desktop *d;
+
+ printf("menu file done\n");
+ efreet_desktop_unref(ctx->d_main);
+ if (ctx->mime) eina_stringshare_del(ctx->mime);
+ EINA_LIST_FREE(ctx->desktops, d) efreet_desktop_unref(d);
+ free(ctx);
+}
+
+static void
+_cb_menu_open_with_done(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu *menu)
+{
+ printf("menu open with done\n");
+}
+
+static void
+_cb_menu_item_open(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ Popup_Context *ctx = data;
+ Efreet_Desktop *d = data2;
+ Eina_Strbuf *strbuf;
+
+ printf("open\n");
+ if (!d)
+ {
+ // XXX: if d == NULL tghen ask for desktop in sel
+ return;
+ }
+ // we know the desktop to use - ask backend to file-run
+ strbuf = eina_strbuf_new();
+ if (strbuf)
+ {
+ Eina_Strbuf *buf = cmd_strbuf_new("file-run");
+
+ if (d)
+ {
+ cmd_strbuf_append(buf, "open-with", d->orig_path);
+ // XXX: IO: this is a read+write to disk... not great in main loop
+ if (ctx->mime) mimeapps_handler_save(ctx->mime, d);
+ }
+ if (_selected_icons_uri_strbuf_append(ctx->sd, strbuf))
+ {
+ _uri_list_cmd_strbuf_append(buf, "path",
+ eina_strbuf_string_get(strbuf));
+ }
+ cmd_strbuf_exe_consume(buf, ctx->sd->exe_open);
+ eina_strbuf_free(strbuf);
+ }
+}
+
+static void
+_cb_menu_item_open_all(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("open all select dialog\n");
+}
+
+static void
+_cb_menu_item_rename(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("rename\n");
+}
+
+static void
+_cb_menu_item_cut(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("cut\n");
+}
+
+static void
+_cb_menu_item_copy(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("copy\n");
+}
+
+static void
+_cb_menu_item_paste(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("paste\n");
+}
+
+static void
+_cb_menu_item_delete(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("delete\n");
+}
+
+static void
+_cb_menu_item_props(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("props\n");
+}
+
+static void
+_cb_menu_item_sel_all(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("sel all\n");
+}
+
+static void
+_cb_menu_item_sel_none(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("sel none\n");
+}
+
+static void
+_cb_menu_item_refresh(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("refresh\n");
+}
+
+static void
+_cb_menu_item_mkdir(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("mkdir\n");
+}
+
+static void
+_cb_menu_item_close(void *data, void *data2, Evas_Object *efm,
+ const Efm_Menu_Item *menu_item)
+{
+ printf("close\n");
+}
+
Efm_Menu *
_efm_popup_icon_menu_add(Smart_Data *sd, Icon *ic, Evas_Coord x, Evas_Coord y)
-{
- Efm_Menu *m1, *m2;
- Eina_Strbuf *icbuf;
- const char *icstr;
+{ // menu click on icon(s)
+ Popup_Context *ctx;
+ Efm_Menu *m1, *m2;
+ Eina_Strbuf *icbuf;
+ const char *icstr;
+ Efreet_Desktop *d_main = NULL;
+ printf("POPUP MENU ICON\n");
+ // XXX what if ic is gone by time menu activated?
+ ctx = calloc(1, sizeof(Popup_Context));
+ if (!ctx) return NULL;
+ ctx->sd = sd;
+ if (ic->info.mime)
+ {
+ d_main = mimeapps_handler_find(ic->info.mime);
+ ctx->mime = eina_stringshare_add(ic->info.mime);
+ }
+ m1 = _efm_menu_add("File", "std:file", _cb_menu_file_done, ctx, NULL);
+ _efm_menu_it_normal(m1, "Open", "std:document-open", _cb_menu_item_open, ctx,
+ d_main);
+ {
+ Efreet_Desktop *d;
+ Eina_List *mimes = NULL;
+ char buf[PATH_MAX];
+ const char *icon = NULL;
+
+ // XXX: ask backend to fill in the menu or to augment it?
+ m2 = _efm_menu_add("Open With", NULL,
+ _cb_menu_open_with_done, ctx, NULL);
+ _efm_menu_it_sub(m1, "Open With", NULL, m2);
+ ctx->d_main = d_main;
+ if (d_main)
+ {
+ if (d_main->icon)
+ {
+ if (d_main->icon[0] == '/') icon = d_main->icon;
+ else
+ {
+ snprintf(buf, sizeof(buf), "fdo:%s", d_main->icon);
+ icon = buf;
+ }
+ }
+ _efm_menu_it_normal(m2, d_main->name, icon, _cb_menu_item_open, ctx,
+ d_main);
+ }
+ if (ic->info.mime) mimes = efreet_util_desktop_mime_list(ic->info.mime);
+ if ((d_main) && (mimes)) _efm_menu_it_separator(m2);
+ EINA_LIST_FREE(mimes, d)
+ {
+ if (d == d_main)
+ {
+ efreet_desktop_unref(d);
+ continue;
+ }
+ icon = NULL;
+ if (d->icon)
+ {
+ if (d->icon[0] == '/') icon = d->icon;
+ else
+ {
+ snprintf(buf, sizeof(buf), "fdo:%s", d->icon);
+ icon = buf;
+ }
+ }
+ _efm_menu_it_normal(m2, d->name, icon, _cb_menu_item_open, ctx, d);
+ ctx->desktops = eina_list_append(ctx->desktops, d);
+ }
+ if ((d_main) || (mimes)) _efm_menu_it_separator(m2);
+ _efm_menu_it_normal(m2, "Select Other", NULL, _cb_menu_item_open_all, ctx,
+ NULL);
+ }
+ // XXX: actions
+ _efm_menu_it_separator(m1);
+ _efm_menu_it_normal(m1, "Rename", "std:edit-rename", _cb_menu_item_rename, ctx, NULL);
+ _efm_menu_it_normal(m1, "Cut", "std:edit-cut", _cb_menu_item_cut, ctx, NULL);
+ _efm_menu_it_normal(m1, "Copy", "std:edit-copy", _cb_menu_item_copy, ctx, NULL);
+ _efm_menu_it_normal(m1, "Paste", "std:edit-paste", _cb_menu_item_paste, ctx, NULL);
+ _efm_menu_it_normal(m1, "Delete", "std:delete", _cb_menu_item_delete, ctx, NULL);
+ _efm_menu_it_separator(m1);
+ _efm_menu_it_normal(m1, "Properties", "std:document-properties", _cb_menu_item_props, ctx, NULL);
+ _efm_menu_it_separator(m1);
+ // XXX: view subdir
+ _efm_menu_it_normal(m1, "Select All", "std:edit-select-all",
+ _cb_menu_item_sel_all, ctx, NULL);
+ _efm_menu_it_normal(m1, "Select None", NULL, _cb_menu_item_sel_none, ctx, NULL);
+ _efm_menu_it_normal(m1, "Refresh", "std:view-refresh", _cb_menu_item_refresh, ctx, NULL);
+ _efm_menu_it_normal(m1, "Create Directory", "std:folder-new", _cb_menu_item_mkdir, ctx,
+ NULL);
+ // XXX: sort
+ // XXX: show hidden
+ _efm_menu_it_separator(m1);
+ _efm_menu_it_normal(m1, "Close", "std:window-close", _cb_menu_item_close, ctx, NULL);
+ _efm_menu_show(ic->sd->o_smart, m1, x, y);
+
+ return m1;
// XXX: right click icon menu.... should have
//
// regular menu:
@@ -197,7 +437,7 @@ _efm_popup_icon_menu_add(Smart_Data *sd, Icon *ic, Evas_Coord x, Evas_Coord y)
Efm_Menu *
_efm_popup_main_menu_add(Smart_Data *sd, Evas_Coord x, Evas_Coord y)
-{
+{ // menu click in blank area
Efm_Menu *m;
m = _efm_menu_add("Main Menu", "std:security-high", _cb_menu_done, NULL,
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index f2ab3b1..e688539 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -811,7 +811,7 @@ _icon_open_with_cmd_strbuf_append(Eina_Strbuf *strbuf, const char *key,
return;
}
printf("FFF: [%s]: [%s]\n", icon->info.file, icon->info.mime);
- Efreet_Desktop *d = _mimeapps_handler_find(icon->info.mime);
+ Efreet_Desktop *d = mimeapps_handler_find(icon->info.mime);
if (!d) continue;
// open-with=/path/to/file.desktop
cmd_strbuf_append(strbuf, key, d->orig_path);
@@ -1160,6 +1160,7 @@ _cb_icon_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
if (!dragged)
{
printf("XXX: right mouse\n");
+ if (!icon->selected) _icon_select(icon);
_efm_popup_icon_menu_add(icon->sd, icon, icon->down_x,
icon->down_y);
}
diff --git a/src/shared/mimeapps.c b/src/shared/mimeapps.c
index b7d679d..e6e0485 100644
--- a/src/shared/mimeapps.c
+++ b/src/shared/mimeapps.c
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <ctype.h>
static const char *
_xdg_defaults_get(const char *path, const char *mime)
@@ -63,7 +62,7 @@ _desktop_first_free_others(Eina_List *lst)
}
Efreet_Desktop *
-_mimeapps_handler_find(const char *mime)
+mimeapps_handler_find(const char *mime)
{
Efreet_Desktop *desktop = NULL;
char path[PATH_MAX];
@@ -97,3 +96,28 @@ _mimeapps_handler_find(const char *mime)
desktop = _desktop_first_free_others(efreet_util_desktop_mime_list(mime));
return desktop;
}
+
+void
+mimeapps_handler_save(const char *mime, Efreet_Desktop *d)
+{
+ Efreet_Ini *ini;
+ char path[PATH_MAX];
+
+ snprintf(path, sizeof(path), "%s/mimeapps.list", efreet_config_home_get());
+ ini = efreet_ini_new(path);
+
+ if (!ini)
+ {
+ ini = efreet_ini_new(path);
+ if (!ini) return;
+ }
+ if (!efreet_ini_section_set(ini, "Default Applications"))
+ {
+ efreet_ini_section_add(ini, "Default Applications");
+ efreet_ini_section_set(ini, "Default Applications");
+ }
+ if (d->orig_path)
+ efreet_ini_string_set(ini, mime, ecore_file_file_get(d->orig_path));
+ efreet_ini_save(ini, path);
+ efreet_ini_free(ini);
+}
\ No newline at end of file
diff --git a/src/shared/mimeapps.h b/src/shared/mimeapps.h
index e5bcc67..989479d 100644
--- a/src/shared/mimeapps.h
+++ b/src/shared/mimeapps.h
@@ -3,7 +3,9 @@
#include <Eina.h>
#include <Efreet.h>
+#include <Ecore_File.h>
-Efreet_Desktop *_mimeapps_handler_find(const char *mime);
+Efreet_Desktop *mimeapps_handler_find(const char *mime);
+void mimeapps_handler_save(const char *mime, Efreet_Desktop *d);
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.