diff --git a/src/bin/e_eap_editor.c b/src/bin/e_eap_editor.c index 8d3254f93..889cbb603 100644 --- a/src/bin/e_eap_editor.c +++ b/src/bin/e_eap_editor.c @@ -48,12 +48,71 @@ static void _e_desktop_editor_icon_update(E_Config_Dialog_Data *cfdata /* externally accessible functions */ +EAPI Efreet_Desktop * +e_desktop_border_create(E_Border *bd) +{ + Efreet_Desktop *desktop = NULL; + const char *desktop_dir, *icon_dir; + const char *bname, *bclass; + char path[PATH_MAX]; + + bname = bd->client.icccm.name; + if ((bname) && (bname[0] == 0)) bname = NULL; + bclass = bd->client.icccm.class; + if ((bclass) && (bclass[0] == 0)) bclass = NULL; + + desktop_dir = e_user_desktop_dir_get(); + + if (!desktop_dir || !e_util_dir_check(desktop_dir)) return NULL; + + icon_dir = e_user_icon_dir_get(); + if (!icon_dir || !e_util_dir_check(icon_dir)) return NULL; + + if (bname) + { + snprintf(path, sizeof(path), "%s/%s.desktop", desktop_dir, bname); + desktop = efreet_desktop_empty_new(path); + } + else + desktop = efreet_desktop_empty_new(NULL); + + if (!desktop) + { + //XXX out of memory? + return NULL; + } + if (bclass) desktop->name = strdup(bclass); + if (bclass) desktop->startup_wm_class = strdup(bclass); + if (bd->client.icccm.command.argc > 0) + // FIXME this should concat the entire argv array together + desktop->exec = strdup(bd->client.icccm.command.argv[0]); + else if (bname) + desktop->exec = strdup(bname); + + if (bd->client.netwm.startup_id > 0) + desktop->startup_notify = 1; + if (bd->client.netwm.icons) + { + /* FIXME + * - Find the icon with the best size + * - Should use mkstemp + */ + const char *tmp; + + snprintf(path, sizeof(path), "%s/%s-%.6f.png", icon_dir, bname, ecore_time_get()); + if (e_util_icon_save(&(bd->client.netwm.icons[0]), path)) + { + desktop->icon = strdup(path); + } + else + fprintf(stderr, "Could not save file from ARGB: %s\n", path); + } + return desktop; +} EAPI E_Desktop_Edit * e_desktop_border_edit(E_Container *con, E_Border *bd) { E_Desktop_Edit *editor; - const char *bname, *bclass; - char path[PATH_MAX]; if (!con) return NULL; editor = E_OBJECT_ALLOC(E_Desktop_Edit, E_DESKTOP_EDIT_TYPE, _e_desktop_edit_free); @@ -61,64 +120,13 @@ e_desktop_border_edit(E_Container *con, E_Border *bd) if (bd->desktop) editor->desktop = bd->desktop; - bname = bd->client.icccm.name; - if ((bname) && (bname[0] == 0)) bname = NULL; - bclass = bd->client.icccm.class; - if ((bclass) && (bclass[0] == 0)) bclass = NULL; - /* the border does not yet have a desktop entry. add one and pre-populate it with values from the border */ if (!editor->desktop) { - const char *desktop_dir, *icon_dir; - - desktop_dir = e_user_desktop_dir_get(); - - if (!desktop_dir || !e_util_dir_check(desktop_dir)) return; - - icon_dir = e_user_icon_dir_get(); - if (!icon_dir || !e_util_dir_check(icon_dir)) return; - - if (bname) - { - snprintf(path, sizeof(path), "%s/%s.desktop", desktop_dir, bname); - editor->desktop = efreet_desktop_empty_new(path); - } - else - editor->desktop = efreet_desktop_empty_new(NULL); - - if (!editor->desktop) - { - //XXX out of memory? - return; - } - if (bclass) editor->desktop->name = strdup(bclass); - if (bclass) editor->desktop->startup_wm_class = strdup(bclass); - if (bd->client.icccm.command.argc > 0) - // FIXME this should concat the entire argv array together - editor->desktop->exec = strdup(bd->client.icccm.command.argv[0]); - else if (bname) - editor->desktop->exec = strdup(bname); - - if (bd->client.netwm.startup_id > 0) - editor->desktop->startup_notify = 1; - if (bd->client.netwm.icons) - { - /* FIXME - * - Find the icon with the best size - * - Should use mkstemp - */ - const char *tmp; - - snprintf(path, sizeof(path), "%s/%s-%.6f.png", icon_dir, bname, ecore_time_get()); - if (e_util_icon_save(&(bd->client.netwm.icons[0]), path)) - { - editor->tmp_image_path = strdup(path); - editor->desktop->icon = strdup(path); - } - else - fprintf(stderr, "Could not save file from ARGB: %s\n", path); - } + editor->desktop = e_desktop_border_create(bd); + if (editor->desktop && editor->desktop->icon) + editor->tmp_image_path = strdup(editor->desktop->icon); } #if 0 diff --git a/src/bin/e_eap_editor.h b/src/bin/e_eap_editor.h index 91ee13a14..8327ed627 100644 --- a/src/bin/e_eap_editor.h +++ b/src/bin/e_eap_editor.h @@ -32,6 +32,7 @@ struct _E_Desktop_Edit E_Config_Dialog *cfd; }; +EAPI Efreet_Desktop *e_desktop_border_create(E_Border *bd); EAPI E_Desktop_Edit *e_desktop_border_edit(E_Container *con, E_Border *bd); EAPI E_Desktop_Edit *e_desktop_edit(E_Container *con, Efreet_Desktop *desktop); diff --git a/src/modules/ibar/e_mod_main.c b/src/modules/ibar/e_mod_main.c index 0b08bef96..b9e68de16 100644 --- a/src/modules/ibar/e_mod_main.c +++ b/src/modules/ibar/e_mod_main.c @@ -1068,55 +1068,12 @@ _ibar_inst_cb_drop(void *data, const char *type, void *event_info) bd = ev->data; app = bd->desktop; -#if 0 if (!app) { - char *bname = NULL, *bclass = NULL; - char path[4096]; - const char *homedir; - - homedir = e_user_homedir_get(); - - /* Create a new application icon */ - bname = bd->client.icccm.name; - if ((bname) && (bname[0] == 0)) bname = NULL; - bclass = bd->client.icccm.class; - if ((bclass) && (bclass[0] == 0)) bclass = NULL; - - if (bname) - { - snprintf(path, sizeof(path), "%s/.e/e/applications/all/%s.desktop", homedir, bname); - app = e_app_empty_new(path); - } - - if (app) - { - if (bd->client.netwm.icons) - { - char icon_path[4096]; - - snprintf(icon_path, sizeof(icon_path), "%s/.e/e/icons/%s-%.6f.png", homedir, bname, ecore_time_get()); - if (e_util_icon_save(&(bd->client.netwm.icons[0]), icon_path)) - { - app->icon_path = evas_stringshare_add(icon_path); - app->width = bd->client.netwm.icons[0].width; - app->height = bd->client.netwm.icons[0].height; - } - } - if (bname) app->win_name = evas_stringshare_add(bname); - if (bclass) app->win_class = evas_stringshare_add(bclass); - if (bd->client.icccm.window_role) - app->win_role = evas_stringshare_add(bd->client.icccm.window_role); - if (bclass) app->name = evas_stringshare_add(bclass); - if (bname) app->exe = evas_stringshare_add(bname); - if (bd->client.netwm.startup_id > 0) - app->startup_notify = 1; - - e_app_fields_save(app); - e_eap_edit_show(e_container_current_get(e_manager_current_get()), app); - } + app = e_desktop_border_create(bd); + efreet_desktop_save(app); + e_desktop_edit(e_container_current_get(e_manager_current_get()), app); } -#endif } else if (!strcmp(type, "text/uri-list")) {