desklock title was wrongish (comapred to control panel)


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 16 years ago
parent eb8bc97c1e
commit 13af2cc288
  1. 92
      src/bin/e_exehist.c
  2. 5
      src/bin/e_exehist.h
  3. 129
      src/bin/e_fwin.c
  4. 2
      src/bin/e_int_config_desklock.c

@ -12,6 +12,7 @@ typedef struct _E_Exehist_Item E_Exehist_Item;
struct _E_Exehist
{
Evas_List *history;
Evas_List *mimes;
};
struct _E_Exehist_Item
@ -53,6 +54,7 @@ e_exehist_init(void)
#define T E_Exehist
#define D _e_exehist_config_edd
E_CONFIG_LIST(D, T, history, _e_exehist_config_item_edd);
E_CONFIG_LIST(D, T, mimes, _e_exehist_config_item_edd);
return 1;
}
@ -73,7 +75,11 @@ e_exehist_add(const char *launch_method, const char *exe)
_e_exehist_load();
if (!_e_exehist) return;
ei = E_NEW(E_Exehist_Item, 1);
if (!ei) return;
if (!ei)
{
_e_exehist_unload_queue();
return;
}
ei->launch_method = evas_stringshare_add(launch_method);
ei->exe = evas_stringshare_add(exe);
ei->exetime = ecore_time_get();
@ -156,15 +162,85 @@ e_exehist_list_get(void)
break;
}
}
if (!(bad)) {
if (!(bad))
{
list = evas_list_append(list, ei->exe);
count++;
}
}
if (count > max) break;
}
return list;
}
EAPI void
e_exehist_mime_app_add(const char *mime, E_App *a)
{
const char *f;
E_Exehist_Item *ei;
Evas_List *l;
if ((!mime) || (!a)) return;
_e_exehist_load();
if (!_e_exehist) return;
f = ecore_file_get_file(a->path);
for (l = _e_exehist->mimes; l; l = l->next)
{
ei = l->data;
if ((ei->launch_method) && (!strcmp(mime, ei->launch_method)))
{
if ((ei->exe) && (!strcmp(f, ei->exe)))
{
_e_exehist_unload_queue();
return;
}
if (ei->exe) evas_stringshare_del(ei->exe);
if (ei->launch_method) evas_stringshare_del(ei->launch_method);
free(ei);
_e_exehist->mimes = evas_list_remove_list(_e_exehist->mimes, l);
break;
}
}
ei = E_NEW(E_Exehist_Item, 1);
if (!ei)
{
_e_exehist_unload_queue();
return;
}
ei->launch_method = evas_stringshare_add(mime);
ei->exe = evas_stringshare_add(f);
ei->exetime = ecore_time_get();
_e_exehist->mimes = evas_list_append(_e_exehist->mimes, ei);
_e_exehist_limit();
e_config_domain_save("exehist", _e_exehist_config_edd, _e_exehist);
_e_exehist_unload_queue();
}
EAPI E_App *
e_exehist_mime_app_get(const char *mime)
{
E_App *a;
E_Exehist_Item *ei;
Evas_List *l;
if (!mime) return NULL;
_e_exehist_load();
if (!_e_exehist) return;
for (l = _e_exehist->mimes; l; l = l->next)
{
ei = l->data;
if ((ei->launch_method) && (!strcmp(mime, ei->launch_method)))
{
a = NULL;
if (ei->exe) a = e_app_file_find(ei->exe);
_e_exehist_unload_queue();
return a;
}
}
_e_exehist_unload_queue();
return NULL;
}
/* local subsystem functions */
static void
_e_exehist_unload_queue(void)
@ -197,6 +273,16 @@ _e_exehist_clear(void)
free(ei);
_e_exehist->history = evas_list_remove_list(_e_exehist->history, _e_exehist->history);
}
while (_e_exehist->mimes)
{
E_Exehist_Item *ei;
ei = _e_exehist->mimes->data;
if (ei->exe) evas_stringshare_del(ei->exe);
if (ei->launch_method) evas_stringshare_del(ei->launch_method);
free(ei);
_e_exehist->mimes = evas_list_remove_list(_e_exehist->mimes, _e_exehist->mimes);
}
}
}

@ -15,9 +15,8 @@ EAPI void e_exehist_clear(void);
EAPI int e_exehist_popularity_get(const char *exe);
EAPI double e_exehist_newest_run_get(const char *exe);
EAPI Evas_List *e_exehist_list_get(void);
/*
EAPI double e_exehist_last_run_get(const char *exe);
*/
EAPI void e_exehist_mime_app_add(const char *mime, E_App *a);
EAPI E_App *e_exehist_mime_app_get(const char *mime);
#endif
#endif

@ -17,6 +17,8 @@ static void _e_fwin_changed(void *data, Evas_Object *obj, void *event_info);
static void _e_fwin_selected(void *data, Evas_Object *obj, void *event_info);
static void _e_fwin_menu_extend(void *data, Evas_Object *obj, E_Menu *m, E_Fm2_Icon_Info *info);
static void _e_fwin_parent(void *data, E_Menu *m, E_Menu_Item *mi);
static void _e_fwin_cb_menu_extend_start(void *data, Evas_Object *obj, E_Menu *m, E_Fm2_Icon_Info *info);
static void _e_fwin_cb_menu_open(void *data, E_Menu *m);
static void _e_fwin_file_open_app(E_Fwin *fwin, E_App *a, const char *file);
static void _e_fwin_cb_ilist_change(void *data);
@ -27,7 +29,7 @@ static void _e_fwin_cb_open(void *data, E_Dialog *dia);
static void _e_fwin_cb_close(void *data, E_Dialog *dia);
static void _e_fwin_cb_dialog_free(void *obj);
static Evas_Bool _e_fwin_cb_hash_foreach(Evas_Hash *hash, const char *key, void *data, void *fdata);
static void _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files);
static void _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files, int always);
/* local subsystem globals */
static Evas_List *fwins = NULL;
@ -102,6 +104,7 @@ e_fwin_new(E_Container *con, const char *dev, const char *path)
_e_fwin_deleted, fwin);
evas_object_smart_callback_add(o, "selected",
_e_fwin_selected, fwin);
e_fm2_icon_menu_start_extend_callback_set(o, _e_fwin_cb_menu_extend_start, fwin);
e_fm2_path_set(o, dev, path);
e_fm2_icon_menu_end_extend_callback_set(o, _e_fwin_menu_extend, fwin);
evas_object_show(o);
@ -209,7 +212,7 @@ _e_fwin_selected(void *data, Evas_Object *obj, void *event_info)
fwin = data;
selected = e_fm2_selected_list_get(fwin->fm_obj);
if (!selected) return;
_e_fwin_file_open_dialog(fwin, selected);
_e_fwin_file_open_dialog(fwin, selected, 0);
evas_list_free(selected);
}
@ -241,6 +244,35 @@ _e_fwin_parent(void *data, E_Menu *m, E_Menu_Item *mi)
e_fm2_parent_go(data);
}
static void
_e_fwin_cb_menu_extend_start(void *data, Evas_Object *obj, E_Menu *m, E_Fm2_Icon_Info *info)
{
E_Menu_Item *mi;
E_Fwin *fwin;
fwin = data;
mi = e_menu_item_new(m);
e_menu_item_label_set(mi, _("Open"));
e_menu_item_icon_edje_set(mi,
e_theme_edje_file_get("base/theme/fileman",
"e/fileman/button/open"),
"e/fileman/button/open");
e_menu_item_callback_set(mi, _e_fwin_cb_menu_open, fwin);
}
static void
_e_fwin_cb_menu_open(void *data, E_Menu *m)
{
E_Fwin *fwin;
Evas_List *selected;
fwin = data;
selected = e_fm2_selected_list_get(fwin->fm_obj);
if (!selected) return;
_e_fwin_file_open_dialog(fwin, selected, 1);
evas_list_free(selected);
}
/* KILL: this func will die as soon as ecore_desktops's cmd thing works
* perfectly */
static void
@ -373,6 +405,7 @@ _e_fwin_cb_open(void *data, E_Dialog *dia)
/* FIXME: save desktop file as most recently used for the mime
* types of the selected files so it can be used as a default
*/
e_exehist_add(buf, cmd);
selected = e_fm2_selected_list_get(fad->fwin->fm_obj);
if (selected)
{
@ -401,6 +434,8 @@ _e_fwin_cb_open(void *data, E_Dialog *dia)
}
if (buf[0] != 0)
{
if (ici->mime)
e_exehist_mime_app_add(ici->mime, a);
// /* FIXME: use ecore_desktop_get_command() */
// printf("a->exe = %s, ici->file = %s\n", a->exe, ici->file);
// _e_fwin_file_open_app(fad->fwin, a, ici->file);
@ -413,7 +448,10 @@ _e_fwin_cb_open(void *data, E_Dialog *dia)
{
ecore_list_goto_first(cmds);
while ((cmd = ecore_list_next(cmds)))
e_zone_exec(fad->fwin->win->border->zone, cmd);
{
e_zone_exec(fad->fwin->win->border->zone, cmd);
e_exehist_add("fwin", cmd);
}
ecore_list_destroy(cmds);
}
ecore_list_destroy(files);
@ -457,7 +495,7 @@ _e_fwin_cb_hash_foreach(Evas_Hash *hash, const char *key, void *data, void *fdat
}
static void
_e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files)
_e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files, int always)
{
E_Dialog *dia;
Evas_Coord mw, mh;
@ -479,29 +517,33 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files)
e_object_del(E_OBJECT(fwin->fad->dia));
fwin->fad = NULL;
}
for (l = files; l; l = l->next)
if (!always)
{
ici = l->data;
if ((ici->link) && (ici->mount))
e_fwin_new(fwin->win->container, ici->link, "/");
else if (ici->link)
for (l = files; l; l = l->next)
{
if (S_ISDIR(ici->statinfo.st_mode))
e_fwin_new(fwin->win->container, NULL, ici->link);
else
need_dia = 1;
}
else
{
snprintf(buf, sizeof(buf), "%s/%s",
e_fm2_real_path_get(fwin->fm_obj), ici->file);
if (S_ISDIR(ici->statinfo.st_mode))
e_fwin_new(fwin->win->container, NULL, buf);
ici = l->data;
if ((ici->link) && (ici->mount))
e_fwin_new(fwin->win->container, ici->link, "/");
else if (ici->link)
{
if (S_ISDIR(ici->statinfo.st_mode))
e_fwin_new(fwin->win->container, NULL, ici->link);
else
need_dia = 1;
}
else
need_dia = 1;
{
snprintf(buf, sizeof(buf), "%s/%s",
e_fm2_real_path_get(fwin->fm_obj), ici->file);
if (S_ISDIR(ici->statinfo.st_mode))
e_fwin_new(fwin->win->container, NULL, buf);
else
need_dia = 1;
}
}
if (!need_dia) return;
need_dia = 0;
}
if (!need_dia) return;
/* 1. build hash of mimetypes */
for (l = files; l; l = l->next)
@ -540,7 +582,6 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files)
evas_list_free(al);
}
}
evas_list_free(mlist);
}
/* FIXME: check all the mimes - if there is only 1 mime - then open with
@ -548,6 +589,48 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Evas_List *files)
* are multiple or no previously used app for this mime - then open
* dialog
*/
if (!always)
{
if (evas_list_count(mlist) == 1)
{
a = e_exehist_mime_app_get(mlist->data);
if (a)
{
char pcwd[4096], buf[4096], *cmd;
Ecore_List *files_list = NULL, *cmds = NULL;
getcwd(pcwd, sizeof(pcwd));
chdir(e_fm2_real_path_get(fwin->fm_obj));
files_list = ecore_list_new();
ecore_list_set_free_cb(files_list, free);
for (l = files; l; l = l->next)
{
ici = l->data;
ecore_list_append(files_list, strdup(ici->file));
}
cmds = ecore_desktop_get_command(a->desktop, files_list, 1);
if (cmds)
{
ecore_list_goto_first(cmds);
while ((cmd = ecore_list_next(cmds)))
{
e_zone_exec(fwin->win->border->zone, cmd);
e_exehist_add("fwin", cmd);
}
ecore_list_destroy(cmds);
}
ecore_list_destroy(files_list);
if (apps) evas_list_free(apps);
chdir(pcwd);
evas_list_free(mlist);
return;
}
}
}
evas_list_free(mlist);
fad = E_NEW(E_Fwin_Apps_Dialog, 1);
dia = e_dialog_new(fwin->win->border->zone->container,

@ -111,7 +111,7 @@ e_int_config_desklock(E_Container *con)
v->override_auto_apply = 1;
cfd = e_config_dialog_new(con,
_("Desktop Lock Settings"),
_("Screen Lock Settings"),
"E", "_config_desklock_dialog",
"enlightenment/desklock", 0, v, NULL);
return cfd;

Loading…
Cancel
Save