summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2013-02-15 08:16:06 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2013-02-15 08:16:06 +0000
commitdf0920e3a7900461658aee07b0ad6a57d5dad194 (patch)
tree16a24912fd2b7856e1cbbfe9af00627381286c06
parentb23964250800a710bea0bab20e0a506f7144c353 (diff)
patch by Deon Thomas which implements efreet menu caching for e_int_menus
SVN revision: 83939
Diffstat (limited to '')
-rw-r--r--ChangeLog3
-rw-r--r--NEWS1
-rw-r--r--src/bin/e_config.c23
-rw-r--r--src/bin/e_config.h1
-rw-r--r--src/bin/e_int_menus.c116
-rw-r--r--src/bin/e_int_menus.h10
6 files changed, 153 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 315328f09..6254f41c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
12013-02-13 Deon Thomas
2 * Fixed Menu->Applications now only lists valid .desktop files, if the exec is missing it will not be added to the menu list.
3
12013-02-11 Mike Blumenkrantz 42013-02-11 Mike Blumenkrantz
2 5
3 * fixed bug where pointer warping to new clients would start at a random location 6 * fixed bug where pointer warping to new clients would start at a random location
diff --git a/NEWS b/NEWS
index fa0ba5ee2..088932853 100644
--- a/NEWS
+++ b/NEWS
@@ -103,6 +103,7 @@ Improvements:
103 * enable image preloading for all e_widget_preview using edje 103 * enable image preloading for all e_widget_preview using edje
104 * window remember dialog now allows editing of remembers 104 * window remember dialog now allows editing of remembers
105 * container now uses compositor window 105 * container now uses compositor window
106 * Menu->Applications now only list valid .desktop files
106 107
107Fixes: 108Fixes:
108 * IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar. 109 * IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar.
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index d8c5f2ccf..daafbbbc2 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -44,6 +44,7 @@ static E_Config_DD *_e_config_desklock_bg_edd = NULL;
44static E_Config_DD *_e_config_desktop_name_edd = NULL; 44static E_Config_DD *_e_config_desktop_name_edd = NULL;
45static E_Config_DD *_e_config_desktop_window_profile_edd = NULL; 45static E_Config_DD *_e_config_desktop_window_profile_edd = NULL;
46static E_Config_DD *_e_config_remember_edd = NULL; 46static E_Config_DD *_e_config_remember_edd = NULL;
47static E_Config_DD *_e_config_menu_applications_edd = NULL;
47static E_Config_DD *_e_config_color_class_edd = NULL; 48static E_Config_DD *_e_config_color_class_edd = NULL;
48static E_Config_DD *_e_config_gadcon_edd = NULL; 49static E_Config_DD *_e_config_gadcon_edd = NULL;
49static E_Config_DD *_e_config_gadcon_client_edd = NULL; 50static E_Config_DD *_e_config_gadcon_client_edd = NULL;
@@ -123,6 +124,7 @@ _e_config_edd_shutdown(void)
123 E_CONFIG_DD_FREE(_e_config_desktop_name_edd); 124 E_CONFIG_DD_FREE(_e_config_desktop_name_edd);
124 E_CONFIG_DD_FREE(_e_config_desktop_window_profile_edd); 125 E_CONFIG_DD_FREE(_e_config_desktop_window_profile_edd);
125 E_CONFIG_DD_FREE(_e_config_remember_edd); 126 E_CONFIG_DD_FREE(_e_config_remember_edd);
127 E_CONFIG_DD_FREE(_e_config_menu_applications_edd);
126 E_CONFIG_DD_FREE(_e_config_gadcon_edd); 128 E_CONFIG_DD_FREE(_e_config_gadcon_edd);
127 E_CONFIG_DD_FREE(_e_config_gadcon_client_edd); 129 E_CONFIG_DD_FREE(_e_config_gadcon_client_edd);
128 E_CONFIG_DD_FREE(_e_config_shelf_edd); 130 E_CONFIG_DD_FREE(_e_config_shelf_edd);
@@ -284,6 +286,18 @@ _e_config_edd_init(Eina_Bool old)
284#define D _e_config_font_fallback_edd 286#define D _e_config_font_fallback_edd
285 E_CONFIG_VAL(D, T, name, STR); 287 E_CONFIG_VAL(D, T, name, STR);
286 288
289 _e_config_menu_applications_edd = E_CONFIG_DD_NEW("E_Int_Menu_Applications",
290 E_Int_Menu_Applications);
291#undef T
292#undef D
293#define T E_Int_Menu_Applications
294#define D _e_config_menu_applications_edd
295 E_CONFIG_VAL(D, T, orig_path, STR);
296 E_CONFIG_VAL(D, T, try_exec, STR);
297 E_CONFIG_VAL(D, T, exec, STR);
298 E_CONFIG_VAL(D, T, load_time, LL);
299 E_CONFIG_VAL(D, T, exec_valid, INT);
300
287 _e_config_remember_edd = E_CONFIG_DD_NEW("E_Remember", E_Remember); 301 _e_config_remember_edd = E_CONFIG_DD_NEW("E_Remember", E_Remember);
288#undef T 302#undef T
289#undef D 303#undef D
@@ -621,6 +635,7 @@ _e_config_edd_init(Eina_Bool old)
621 E_CONFIG_VAL(D, T, transition_desk, STR); /**/ 635 E_CONFIG_VAL(D, T, transition_desk, STR); /**/
622 E_CONFIG_VAL(D, T, transition_change, STR); /**/ 636 E_CONFIG_VAL(D, T, transition_change, STR); /**/
623 E_CONFIG_LIST(D, T, remembers, _e_config_remember_edd); 637 E_CONFIG_LIST(D, T, remembers, _e_config_remember_edd);
638 E_CONFIG_LIST(D, T, menu_applications, _e_config_menu_applications_edd);
624 E_CONFIG_VAL(D, T, remember_internal_windows, INT); 639 E_CONFIG_VAL(D, T, remember_internal_windows, INT);
625 E_CONFIG_VAL(D, T, remember_internal_fm_windows, UCHAR); 640 E_CONFIG_VAL(D, T, remember_internal_fm_windows, UCHAR);
626 E_CONFIG_VAL(D, T, remember_internal_fm_windows_globally, UCHAR); 641 E_CONFIG_VAL(D, T, remember_internal_fm_windows_globally, UCHAR);
@@ -2124,6 +2139,7 @@ _e_config_free(E_Config *ecf)
2124 E_Config_Env_Var *evr; 2139 E_Config_Env_Var *evr;
2125 E_Config_XKB_Option *op; 2140 E_Config_XKB_Option *op;
2126 E_Config_Desktop_Window_Profile *wp; 2141 E_Config_Desktop_Window_Profile *wp;
2142 E_Int_Menu_Applications *ema;
2127 2143
2128 if (!ecf) return; 2144 if (!ecf) return;
2129 2145
@@ -2219,6 +2235,13 @@ _e_config_free(E_Config *ecf)
2219 if (rem->prop.command) eina_stringshare_del(rem->prop.command); 2235 if (rem->prop.command) eina_stringshare_del(rem->prop.command);
2220 E_FREE(rem); 2236 E_FREE(rem);
2221 } 2237 }
2238 EINA_LIST_FREE(ecf->menu_applications, ema)
2239 {
2240 if (ema->orig_path) eina_stringshare_del(ema->orig_path);
2241 if (ema->try_exec) eina_stringshare_del(ema->try_exec);
2242 if (ema->exec) eina_stringshare_del(ema->exec);
2243 E_FREE(ema);
2244 }
2222 EINA_LIST_FREE(ecf->color_classes, cc) 2245 EINA_LIST_FREE(ecf->color_classes, cc)
2223 { 2246 {
2224 if (cc->name) eina_stringshare_del(cc->name); 2247 if (cc->name) eina_stringshare_del(cc->name);
diff --git a/src/bin/e_config.h b/src/bin/e_config.h
index 73ec92bff..c56bcf56f 100644
--- a/src/bin/e_config.h
+++ b/src/bin/e_config.h
@@ -430,6 +430,7 @@ struct _E_Config
430 const char *desklock_layout; 430 const char *desklock_layout;
431 } xkb; 431 } xkb;
432 432
433 Eina_List *menu_applications;
433 unsigned char exe_always_single_instance; // GUI 434 unsigned char exe_always_single_instance; // GUI
434 int use_desktop_window_profile; // GUI 435 int use_desktop_window_profile; // GUI
435}; 436};
diff --git a/src/bin/e_int_menus.c b/src/bin/e_int_menus.c
index 02a45c737..ae20f52f2 100644
--- a/src/bin/e_int_menus.c
+++ b/src/bin/e_int_menus.c
@@ -644,6 +644,117 @@ _e_int_menus_main_exit(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item
644 if ((a) && (a->func.go)) a->func.go(NULL, NULL); 644 if ((a) && (a->func.go)) a->func.go(NULL, NULL);
645} 645}
646 646
647/*
648 * This function searches $PATH for try_exec or exec
649 * return true if try_exec or exec is found!
650 */
651static Eina_Bool
652_e_int_menus_app_finder(const char *exec)
653{
654 const char *env = getenv("PATH");
655 char **split, buf[PATH_MAX];
656 Eina_Bool exec_found = EINA_FALSE;
657 int i = 0;
658
659 if (strchr(exec, '/'))
660 {
661 if (ecore_file_exists(exec) && ecore_file_can_exec(exec))
662 return EINA_TRUE;
663 }
664
665 if (!env)
666 {
667 ERR("Unable to $PATH, Returning TRUE for every .desktop");
668 return EINA_TRUE;
669 }
670
671 split = eina_str_split(env, ":", 0);
672 for (i = 0; split[i] != NULL; i++)
673 {
674 snprintf(buf, sizeof(buf), "%s/%s", split[i], exec);
675
676 if (ecore_file_exists(buf) && ecore_file_can_exec(buf))
677 {
678 exec_found = EINA_TRUE;
679 break;
680 }
681 }
682 free(split[0]);
683 free(split);
684
685 if (!exec_found)
686 ERR("Unable to find: [%s] I searched $PATH=%s", exec, env);
687
688 return exec_found;
689}
690
691/*
692 * This function initalises E_Int_Menu_Applications and add
693 * our data.
694 */
695static E_Int_Menu_Applications*
696_e_int_menus_app_config_set(Efreet_Desktop *desktop)
697{
698 E_Int_Menu_Applications *ma;
699
700 ma = E_NEW(E_Int_Menu_Applications, 1);
701
702 ma->orig_path = eina_stringshare_add(desktop->orig_path);
703 ma->try_exec = eina_stringshare_add(desktop->try_exec);
704 ma->exec = eina_stringshare_add(desktop->exec);
705 ma->load_time = desktop->load_time;
706 ma->exec_valid = 1; //ALL .desktop files are VALID unless proven otherwise :)
707 return ma;
708}
709
710/*
711 * This function adds/updates our E_Int_Menu_Applications config,
712 * returns true if the .desktop file is valid.
713 */
714static Eina_Bool
715_e_int_menus_app_config_append(Efreet_Desktop *desktop)
716{
717 E_Int_Menu_Applications *ma, *cma;
718 Eina_List *l;
719
720 if (!desktop) return EINA_TRUE;
721
722 cma = _e_int_menus_app_config_set(desktop);
723 EINA_LIST_FOREACH(e_config->menu_applications, l, ma)
724 {
725 if ((!strcmp(ma->orig_path, cma->orig_path)) && (ma->load_time == cma->load_time))
726 return ma->exec_valid;
727
728 if ((!strcmp(ma->orig_path, cma->orig_path)) && (ma->load_time != cma->load_time))
729 {
730 ERR("Modified: [%s]", cma->orig_path);
731 e_config->menu_applications = eina_list_remove(e_config->menu_applications, ma);
732 }
733 }
734
735 if (cma->try_exec)
736 {
737 ERR("Try_Exec: [%s]", cma->try_exec);
738 cma->exec_valid = _e_int_menus_app_finder(cma->try_exec);
739 }
740 else
741 {
742 if (!strchr(cma->exec, '\0'))
743 cma->exec_valid = _e_int_menus_app_finder(cma->exec);
744 else
745 {
746 char **split;
747 split = eina_str_split(cma->exec, " ", 0);
748 cma->exec_valid = _e_int_menus_app_finder(split[0]);
749 free(split[0]);
750 free(split);
751 }
752 }
753
754 e_config->menu_applications = eina_list_append(e_config->menu_applications, cma);
755 return cma->exec_valid;
756}
757
647static void 758static void
648_e_int_menus_apps_scan(E_Menu *m, Efreet_Menu *menu) 759_e_int_menus_apps_scan(E_Menu *m, Efreet_Menu *menu)
649{ 760{
@@ -656,8 +767,11 @@ _e_int_menus_apps_scan(E_Menu *m, Efreet_Menu *menu)
656 767
657 EINA_LIST_FOREACH(menu->entries, l, entry) 768 EINA_LIST_FOREACH(menu->entries, l, entry)
658 { 769 {
659 mi = e_menu_item_new(m); 770 if ((entry->type == EFREET_MENU_ENTRY_DESKTOP) &&
771 (!_e_int_menus_app_config_append(entry->desktop)))
772 continue;
660 773
774 mi = e_menu_item_new(m);
661 _e_int_menus_item_label_set(entry, mi); 775 _e_int_menus_item_label_set(entry, mi);
662 776
663 if (entry->icon) 777 if (entry->icon)
diff --git a/src/bin/e_int_menus.h b/src/bin/e_int_menus.h
index 047be9ef9..757678c05 100644
--- a/src/bin/e_int_menus.h
+++ b/src/bin/e_int_menus.h
@@ -1,6 +1,7 @@
1#ifdef E_TYPEDEFS 1#ifdef E_TYPEDEFS
2 2
3typedef struct _E_Int_Menu_Augmentation E_Int_Menu_Augmentation; 3typedef struct _E_Int_Menu_Augmentation E_Int_Menu_Augmentation;
4typedef struct _E_Int_Menu_Applications E_Int_Menu_Applications;
4 5
5#else 6#else
6#ifndef E_INT_MENUS_H 7#ifndef E_INT_MENUS_H
@@ -38,6 +39,15 @@ typedef enum
38 39
39#define E_CLIENTLIST_MAX_CAPTION_LEN 256 40#define E_CLIENTLIST_MAX_CAPTION_LEN 256
40 41
42struct _E_Int_Menu_Applications
43{
44 const char *orig_path;
45 const char *try_exec;
46 const char *exec;
47 long long load_time;
48 int exec_valid;
49};
50
41struct _E_Int_Menu_Augmentation 51struct _E_Int_Menu_Augmentation
42{ 52{
43 const char *sort_key; 53 const char *sort_key;