centralise getting icon evas object from app

SVN revision: 19038
This commit is contained in:
Carsten Haitzler 2005-12-15 07:12:00 +00:00
parent 9e16ed30e9
commit 912cf96418
9 changed files with 60 additions and 69 deletions

View File

@ -17,6 +17,7 @@ AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
AC_FUNC_ALLOCA
AC_C___ATTRIBUTE__
AC_CHECK_FUNCS(setenv)

View File

@ -39,6 +39,10 @@
#include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#if HAVE___ATTRIBUTE__
#define __UNUSED__ __attribute__((unused))
#else

View File

@ -1242,6 +1242,17 @@ e_app_valid_exe_get(E_App *a)
return ok;
}
EAPI Evas_Object *
e_app_icon_add(Evas *evas, E_App *a)
{
Evas_Object *o;
o = edje_object_add(evas);
if (!e_util_edje_icon_list_set(o, a->icon_class))
edje_object_file_set(o, a->path, "icon");
return o;
}
/* local subsystem functions */

View File

@ -106,12 +106,13 @@ EAPI Evas_List *e_app_generic_glob_list (char *generic);
EAPI Evas_List *e_app_exe_glob_list (char *exe);
EAPI Evas_List *e_app_comment_glob_list (char *comment);
EAPI void e_app_fields_fill (E_App *a, const char *path);
EAPI void e_app_fields_save (E_App *a);
EAPI E_App *e_app_raw_new (void);
EAPI Ecore_List *e_app_dir_file_list_get (E_App *a);
EAPI void e_app_fields_empty (E_App *a);
EAPI int e_app_valid_exe_get (E_App *a);
EAPI void e_app_fields_fill (E_App *a, const char *path);
EAPI void e_app_fields_save (E_App *a);
EAPI E_App *e_app_raw_new (void);
EAPI Ecore_List *e_app_dir_file_list_get (E_App *a);
EAPI void e_app_fields_empty (E_App *a);
EAPI int e_app_valid_exe_get (E_App *a);
EAPI Evas_Object *e_app_icon_add (Evas *evas, E_App *a);
#endif
#endif

View File

@ -2336,13 +2336,9 @@ e_border_icon_add(E_Border *bd, Evas *evas)
}
if (a)
{
o = edje_object_add(evas);
if (!e_util_edje_icon_list_set(o, a->icon_class))
{
edje_object_file_set(o, a->path, "icon");
bd->app = a;
e_object_ref(E_OBJECT(bd->app));
}
o = e_app_icon_add(evas, a);
bd->app = a;
e_object_ref(E_OBJECT(bd->app));
return o;
}
else if (bd->client.netwm.icons)

View File

@ -293,8 +293,7 @@ _e_exebuf_update(void)
if (!a) a = e_app_generic_find(cmd_buf);
if (a)
{
o = edje_object_add(exebuf->evas);
edje_object_file_set(o, a->path, "icon");
o = e_app_icon_add(exebuf->evas, a);
icon_object = o;
edje_object_part_swallow(bg_object, "icon_swallow", o);
evas_object_show(o);
@ -742,8 +741,7 @@ _e_exebuf_matches_update(void)
evas_object_show(o);
if (edje_object_part_exists(exe->bg_object, "icon_swallow"))
{
o = edje_object_add(exebuf->evas);
edje_object_file_set(o, exe->app->path, "icon");
o = e_app_icon_add(exebuf->evas, exe->app);
exe->icon_object = o;
edje_object_part_swallow(exe->bg_object, "icon_swallow", o);
evas_object_show(o);
@ -787,8 +785,7 @@ _e_exebuf_matches_update(void)
a = e_app_exe_find(exe->file);
if (a)
{
o = edje_object_add(exebuf->evas);
edje_object_file_set(o, a->path, "icon");
o = e_app_icon_add(exebuf->evas, a);
exe->icon_object = o;
edje_object_part_swallow(exe->bg_object, "icon_swallow", o);
evas_object_show(o);

View File

@ -216,8 +216,7 @@ e_init_icons_app_add(E_App *app)
evas_object_show(o);
}
o = edje_object_add(_e_init_evas);
edje_object_file_set(o,app->path, "icon");
o = e_app_icon_add(_e_init_evas, app);
evas_object_resize(o, _e_init_icon_size, _e_init_icon_size);
e_box_pack_end(_e_init_icon_box, o);
e_box_pack_options_set(o,

View File

@ -443,7 +443,9 @@ _e_int_menus_apps_scan(E_Menu *m)
e_menu_item_label_set(mi, label);
if (a->exe)
{
e_menu_item_icon_edje_set(mi, a->path, "icon");
if (!((a->icon_class) &&
(e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
e_menu_item_icon_edje_set(mi, a->path, "icon");
e_menu_item_callback_set(mi, _e_int_menus_apps_run, a);
app_count++;
}
@ -452,7 +454,9 @@ _e_int_menus_apps_scan(E_Menu *m)
char buf[4096];
snprintf(buf, sizeof(buf), "%s/.directory.eap", a->path);
e_menu_item_icon_edje_set(mi, buf, "icon");
if (!((a->icon_class) &&
(e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
e_menu_item_icon_edje_set(mi, buf, "icon");
e_menu_item_submenu_set(mi, e_int_menus_apps_new(a->path));
app_count++;
}
@ -711,11 +715,13 @@ _e_int_menus_clients_pre_cb(void *data, E_Menu *m)
// e_object_breadcrumb_add(E_OBJECT(bd), "clients_menu");
e_menu_item_callback_set(mi, _e_int_menus_clients_item_cb, bd);
if (!bd->iconic) e_menu_item_toggle_set(mi, 1);
a = e_app_window_name_class_title_role_find(bd->client.icccm.name,
bd->client.icccm.class,
title,
bd->client.icccm.window_role);
if (a) e_menu_item_icon_edje_set(mi, a->path, "icon");
a = bd->app;
if (a)
{
if (!((a->icon_class) &&
(e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
e_menu_item_icon_edje_set(mi, a->path, "icon");
}
}
mi = e_menu_item_new(m);
e_menu_item_separator_set(mi, 1);
@ -996,11 +1002,13 @@ _e_int_menus_lost_clients_pre_cb(void *data, E_Menu *m)
e_object_ref(E_OBJECT(bd));
// e_object_breadcrumb_add(E_OBJECT(bd), "lost_clients_menu");
e_menu_item_callback_set(mi, _e_int_menus_lost_clients_item_cb, bd);
a = e_app_window_name_class_title_role_find(bd->client.icccm.name,
bd->client.icccm.class,
title,
bd->client.icccm.window_role);
if (a) e_menu_item_icon_edje_set(mi, a->path, "icon");
a = bd->app;
if (a)
{
if (!((a->icon_class) &&
(e_util_menu_item_edje_icon_list_set(mi, a->icon_class))))
e_menu_item_icon_edje_set(mi, a->path, "icon");
}
}
e_object_free_attach_func_set(E_OBJECT(m), _e_int_menus_lost_clients_free_hook);
e_object_data_set(E_OBJECT(m), borders);

View File

@ -307,7 +307,7 @@ e_util_edje_icon_list_set(Evas_Object *obj, char *list)
char *p, *c;
if ((!list) || (!list[0])) return 0;
buf = malloc(strlen(list) + 1);
buf = alloca(strlen(list) + 1);
p = list;
while (p)
{
@ -316,31 +316,17 @@ e_util_edje_icon_list_set(Evas_Object *obj, char *list)
{
strncpy(buf, p, c - p);
buf[c - p] = 0;
if (e_util_edje_icon_set(obj, buf))
{
free(buf);
return 1;
}
if (e_util_edje_icon_set(obj, buf)) return 1;
p = c + 1;
if (!*p)
{
free(buf);
return 0;
}
if (!*p) return 0;
}
else
{
strcpy(buf, p);
if (e_util_edje_icon_set(obj, buf))
{
free(buf);
return 1;
}
free(buf);
if (e_util_edje_icon_set(obj, buf)) return 1;
return 0;
}
}
free(buf);
return 0;
}
@ -351,7 +337,7 @@ e_util_menu_item_edje_icon_list_set(E_Menu_Item *mi, char *list)
char *p, *c;
if ((!list) || (!list[0])) return 0;
buf = malloc(strlen(list) + 1);
buf = alloca(strlen(list) + 1);
p = list;
while (p)
{
@ -360,29 +346,17 @@ e_util_menu_item_edje_icon_list_set(E_Menu_Item *mi, char *list)
{
strncpy(buf, p, c - p);
buf[c - p] = 0;
if (e_util_menu_item_edje_icon_set(mi, buf))
{
free(buf);
return 1;
}
if (e_util_menu_item_edje_icon_set(mi, buf)) return 1;
p = c + 1;
if (!*p)
{
free(buf);
return 0;
}
if (!*p) return 0;
}
else
{
strcpy(buf, p);
if (e_util_menu_item_edje_icon_set(mi, buf))
{
free(buf);
return 1;
}
if (e_util_menu_item_edje_icon_set(mi, buf)) return 1;
return 0;
}
}
free(buf);
return 0;
}