allow to directly edit .desktop files

SVN revision: 51761
This commit is contained in:
Miculcy Brian 2010-08-30 17:54:18 +00:00
parent eebc1b3ee1
commit 586632efd1
2 changed files with 55 additions and 18 deletions

View File

@ -265,6 +265,7 @@ _e_desktop_edit_create_data(E_Config_Dialog *cfd)
cfdata->editor = cfd->data;
/*
* If we can't write to the file on it's current location,
* we always save to the user's applications dir.
* If the file is already there, then edit it directly. Otherwise, create
* a new empty desktop entry there.
@ -279,23 +280,28 @@ _e_desktop_edit_create_data(E_Config_Dialog *cfd)
char dir[PATH_MAX];
const char *file;
snprintf(dir, sizeof(dir), "%s/applications", efreet_data_home_get());
if (!strncmp(dir, cfdata->editor->desktop->orig_path, strlen(dir)))
if (ecore_file_can_write (cfdata->editor->desktop->orig_path))
cfdata->desktop = efreet_desktop_uncached_new(cfdata->editor->desktop->orig_path);
else
{
/* file not in user's dir, so create new desktop that points there */
if (!ecore_file_exists(dir)) ecore_file_mkdir(dir);
file = ecore_file_file_get(cfdata->editor->desktop->orig_path);
snprintf(path, sizeof(path), "%s/%s", dir, file);
/*
* if a file already exists in the user dir with this name, we
* fetch the pointer to it, so the caches stay consistent (this
* probably will never return non null, since the ui shouldn't
* provide a means to edit a file in a system dir when one
* exists in the user's
*/
cfdata->desktop = efreet_desktop_uncached_new(path);
snprintf(dir, sizeof(dir), "%s/applications", efreet_data_home_get());
if (!strncmp(dir, cfdata->editor->desktop->orig_path, strlen(dir)))
cfdata->desktop = efreet_desktop_uncached_new(cfdata->editor->desktop->orig_path);
else
{
/* file not in user's dir, so create new desktop that points there */
if (!ecore_file_exists(dir)) ecore_file_mkdir(dir);
file = ecore_file_file_get(cfdata->editor->desktop->orig_path);
snprintf(path, sizeof(path), "%s/%s", dir, file);
/*
* if a file already exists in the user dir with this name, we
* fetch the pointer to it, so the caches stay consistent (this
* probably will never return non null, since the ui shouldn't
* provide a means to edit a file in a system dir when one
* exists in the user's
*/
cfdata->desktop = efreet_desktop_uncached_new(path);
}
}
desktop = cfdata->editor->desktop;
}

View File

@ -328,6 +328,7 @@ static void _e_fm2_file_rename(void *data, E_Menu *m, E_Menu_Item *mi);
static void _e_fm2_file_rename_delete_cb(void *obj);
static void _e_fm2_file_rename_yes_cb(char *text, void *data);
static void _e_fm2_file_rename_no_cb(void *data);
static void _e_fm2_file_application_properties(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__);
static void _e_fm2_file_properties(void *data, E_Menu *m, E_Menu_Item *mi);
static void _e_fm2_file_properties_delete_cb(void *obj);
static void _e_fm2_file_do_rename(const char *text, E_Fm2_Icon *ic);
@ -8079,11 +8080,19 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
e_menu_item_separator_set(mi, 1);
}
}
if (!strcmp(ic->info.mime, "application/x-desktop"))
{
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Application Properties"));
e_util_menu_item_theme_icon_set(mi, "configure");
e_menu_item_callback_set(mi, _e_fm2_file_application_properties, ic);
}
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Properties"));
e_util_menu_item_theme_icon_set(mi, "document-properties");
e_menu_item_callback_set(mi, _e_fm2_file_properties, ic);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("File Properties"));
e_util_menu_item_theme_icon_set(mi, "document-properties");
e_menu_item_callback_set(mi, _e_fm2_file_properties, ic);
if (ic->info.mime)
{
@ -9195,6 +9204,28 @@ _e_fm_dbus_error_dialog(const char *title, const char *msg, const char *pstr)
e_dialog_show(dialog);
}
static void
_e_fm2_file_application_properties(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
{
Efreet_Desktop *desktop;
E_Fm2_Icon *ic;
E_Manager *man;
E_Container *con;
char buf[PATH_MAX];
ic = data;
if (!_e_fm2_icon_realpath(ic, buf, sizeof(buf)))
return;
desktop = efreet_desktop_get(buf);
man = e_manager_current_get();
if (!man) return;
con = e_container_current_get(man);
if (!con) return;
e_desktop_edit(con, desktop);
}
static void
_e_fm2_file_properties(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
{