[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] make e_utils/entangle use desktop



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
Here is a **quick** fix to have entangle working with .desktop files.
I don't have the time nor the skill to implement the FDO icon search
thing, so the way it searches for an icon is :
1. iconpath specified in the .desktop
2. in the icon theme specified in the .desktop
3. fallback icon

hope that's not too bad :|

Greets
Albin 'Lut!n' Tonnerre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFFUgA+IjAgwqfG8N8RAvmcAJ4/vakI07tsNYAtPhAMkBudHzu2eQCgiuiC
lBAfCQBI7u6CVoenPfmyySw=
=v+4o
-----END PGP SIGNATURE-----
--- e_utils/src/bin/entangle/Entangle.h	2005-05-16 06:03:50.000000000 +0200
+++ e_utils/src/bin/entangle.patch/Entangle.h	2006-11-08 16:44:39.000000000 +0100
@@ -9,6 +9,7 @@
 #include <Ecore.h>
 #include <Ecore_File.h>
 #include <Ecore_Evas.h>
+#include <Ecore_Desktop.h>
 #include <Evas.h>
 #include <Edje.h>
 #include <Eet.h>
@@ -36,6 +37,7 @@
     char *name;
     char *exe;
     char *class;
+    char *icon;
 };
 
 typedef struct Entangle_App Entangle_App;
--- e_utils/src/bin/entangle/entangle_apps.c	2006-05-25 23:56:28.000000000 +0200
+++ e_utils/src/bin/entangle.patch/entangle_apps.c	2006-11-08 16:38:14.000000000 +0100
@@ -44,7 +44,7 @@
 
     entangle_apps_dir_init(entangle_apps_bar, "bar/default");
     entangle_apps_dir_init(entangle_apps_engage, "bar/engage");
-    entangle_apps_dir_init(entangle_apps_favorite, "favorite");
+    entangle_apps_dir_init(entangle_apps_favorite, "menu/favorite");
     entangle_apps_dir_init(entangle_apps_restart, "restart");
     entangle_apps_dir_init(entangle_apps_startup, "startup");
 
@@ -75,8 +75,8 @@
     }
 
     entangle_apps_dir_save(entangle_apps_bar, "bar/default");
-    entangle_apps_dir_save(entangle_apps_engage, "engage");
-    entangle_apps_dir_save(entangle_apps_favorite, "favorite");
+    entangle_apps_dir_save(entangle_apps_engage, "bar/engage");
+    entangle_apps_dir_save(entangle_apps_favorite, "menu/favorite");
     entangle_apps_dir_save(entangle_apps_restart, "restart");
     entangle_apps_dir_save(entangle_apps_startup, "startup");
 }
--- e_utils/src/bin/entangle/entangle_eapps.c	2005-10-24 12:51:19.000000000 +0200
+++ e_utils/src/bin/entangle.patch/entangle_eapps.c	2006-11-08 16:33:26.000000000 +0100
@@ -3,6 +3,8 @@
 #include <limits.h>
 #include <string.h>
 
+#define FALLBACK_ICON "/usr/share/enlightenment/data/images/enlightenment.png"
+
 static Ecore_Hash *entangle_eapps = NULL;
 static Ecore_List *entangle_eapp_list = NULL;
 static void entangle_eapps_cb_free(void *data);
@@ -10,6 +12,7 @@
 int
 entangle_eapps_init()
 {
+    ecore_desktop_init();
     char path[PATH_MAX];
     char *home;
     Ecore_List *eapps;
@@ -44,12 +47,12 @@
         char *ret;
 	char *ext;
         int ret_size;
-        Eet_File *ef;
         char e_path[PATH_MAX];
         Entangle_Eapp *eapp;
+        Ecore_Desktop *desktop;
 
 	ext = strrchr(name, '.');
-	if ((!ext) || strcmp(ext, ".eap")) continue;
+	if ((!ext) || strcmp(ext, ".desktop")) continue;
 
         eapp = calloc(1, sizeof(Entangle_Eapp));
         if (!eapp) 
@@ -62,14 +65,15 @@
 
         snprintf(e_path, PATH_MAX, "%s/%s", path, name);
         eapp->path = strdup(e_path);
-        ef = eet_open(e_path, EET_FILE_MODE_READ);
-        if (!ef) 
+        desktop = ecore_desktop_get(e_path, NULL);
+        if(!desktop)
         {
             fprintf(stderr, "Error reading: %s\n", e_path);
             continue;
         }
 
-        ret = eet_read(ef, "app/info/name", &ret_size);
+        ret = desktop->eap_name;
+        ret_size = strlen(ret);
         if (ret_size > 0)
         {
             eapp->name = malloc(sizeof(char) * (ret_size + 1));
@@ -79,7 +83,8 @@
 
         IF_FREE(ret);
 
-        ret = eet_read(ef, "app/info/exe", &ret_size);
+        ret = desktop->exec;
+        ret_size = strlen(ret);
         if (ret_size > 0)
         {
             eapp->exe = malloc(sizeof(char) * (ret_size + 1));
@@ -89,7 +94,8 @@
 
         IF_FREE(ret);
 
-        ret = eet_read(ef, "app/window/class", &ret_size);
+        ret = desktop->window_class;
+        ret_size = strlen(ret);
         if (ret_size > 0)
         {
             eapp->class = malloc(sizeof(char) * (ret_size + 1));
@@ -99,13 +105,26 @@
 
         IF_FREE(ret);
 
+        ret = desktop->icon_path;
+        if (!ret) { ret = ecore_desktop_icon_find(desktop->icon, "32x32", desktop->icon_theme); if (!ret) { ret = strdup(FALLBACK_ICON); } }
+        if (!ret) continue; 
+        ret_size = strlen(ret);
+        if (ret_size > 0)
+        {
+            eapp->icon = malloc(sizeof(char) * (ret_size + 1));
+            strncpy(eapp->icon, ret, ret_size);
+            eapp->icon[ret_size] = 0;
+        }
+
+        IF_FREE(ret);
         ecore_hash_set(entangle_eapps, eapp->eapp_name, eapp);
         ecore_list_append(entangle_eapp_list, eapp->eapp_name);
-        eet_close(ef);
+        ecore_desktop_destroy(desktop);
     }
 
     ecore_list_destroy(eapps);
 
+    ecore_desktop_shutdown;
     return 1;
 }
 
--- e_utils/src/bin/entangle/entangle_ui.c	2006-11-08 16:43:45.000000000 +0100
+++ e_utils/src/bin/entangle.patch/entangle_ui.c	2006-11-08 16:45:35.000000000 +0100
@@ -756,8 +756,8 @@
     {
         if (e->button == 1)
         {
-            o = edje_object_add(evas);
-            edje_object_file_set(o, eapp->path, "icon");
+            o = evas_object_image_add(evas);
+            evas_object_image_file_set(o, eapp->icon, NULL);
             evas_object_move(o, e->canvas.x - 18, e->canvas.y - 18);
             evas_object_resize(o, 36, 36);
             evas_object_layer_set(o, 2);