enlightenment/src/modules/conf_applications/e_int_config_defapps.c

787 lines
25 KiB
C
Raw Normal View History

#include "e.h"
typedef struct _Config_Glob Config_Glob;
typedef struct _Config_Mime Config_Mime;
struct _Config_Glob
{
const char *name;
};
struct _Config_Mime
{
const char *mime;
2012-06-22 00:30:50 -07:00
Eina_List *globs;
};
struct _E_Config_Dialog_Data
{
2012-06-22 00:30:50 -07:00
struct
{
Evas_Object *deflist, *mimelist, *entry;
} obj;
2012-06-22 00:30:50 -07:00
Efreet_Ini *ini;
Eina_List *mimes;
Eina_List *desks;
const char *selmime;
const char *selapp;
const char **seldest;
char *browser_custom;
const char *browser_desktop;
const char *mailto_desktop;
const char *file_desktop;
const char *trash_desktop;
const char *terminal_desktop;
2012-06-22 00:30:50 -07:00
Ecore_Event_Handler *desk_change_handler;
2012-06-22 00:30:50 -07:00
int gen;
};
/* local function prototypes */
2012-06-22 00:30:50 -07:00
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata);
2012-06-22 00:30:50 -07:00
static int _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
2012-06-22 00:30:50 -07:00
static Eina_Bool _desks_update(void *data, int ev_type __UNUSED__, void *ev __UNUSED__);
static void _load_mimes(E_Config_Dialog_Data *cfdata, char *file);
static void _load_globs(E_Config_Dialog_Data *cfdata, char *file);
static int _sort_mimes(const void *data1, const void *data2);
static Config_Mime *_find_mime(E_Config_Dialog_Data *cfdata, char *mime);
static Config_Glob *_find_glob(Config_Mime *mime, char *glob);
2012-06-22 00:30:50 -07:00
static int _cb_desks_sort(const void *data1, const void *data2);
static void _fill_apps_list(E_Config_Dialog_Data *cfdata, Evas_Object *il, const char **desktop, int general);
E_Config_Dialog *
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
e_int_config_defapps(E_Comp *comp, const char *params __UNUSED__)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
2012-06-22 00:30:50 -07:00
if (e_config_dialog_find("E", "applications/default_applications"))
2012-06-22 00:30:50 -07:00
return NULL;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.create_widgets = _basic_create;
v->basic.apply_cfdata = _basic_apply;
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: ivan.briano@intel.com feature: new compositor removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
cfd = e_config_dialog_new(comp, _("Default Applications"),
"E", "applications/default_applications",
"preferences-desktop-default-applications", 0, v, NULL);
return cfd;
}
static void *
_create_data(E_Config_Dialog *cfd __UNUSED__)
{
E_Config_Dialog_Data *cfdata;
Efreet_Ini *ini, *myini;
Eina_Iterator *it;
char buf[PATH_MAX];
const char *key, *s, *homedir;
Eina_List *l;
E_Config_Env_Var *evr;
2012-06-22 00:30:50 -07:00
cfdata = E_NEW(E_Config_Dialog_Data, 1);
if (!cfdata) return NULL;
2012-06-22 00:30:50 -07:00
cfdata->desk_change_handler = ecore_event_handler_add
2012-06-22 00:30:50 -07:00
(EFREET_EVENT_DESKTOP_CACHE_UPDATE, _desks_update, cfdata);
snprintf(buf, sizeof(buf), "%s/applications/defaults.list",
efreet_data_home_get());
myini = efreet_ini_new(buf);
if (myini)
{
cfdata->ini = myini;
if (!efreet_ini_section_set(myini, "Default Applications"))
{
efreet_ini_section_add(myini, "Default Applications");
efreet_ini_section_set(myini, "Default Applications");
}
EINA_LIST_FOREACH(efreet_data_dirs_get(), l, s)
{
snprintf(buf, sizeof(buf), "%s/applications/defaults.list", s);
ini = efreet_ini_new(buf);
if ((ini) &&
(efreet_ini_section_set(ini, "Default Applications")) &&
(ini->section) &&
(it = eina_hash_iterator_key_new(ini->section)))
{
EINA_ITERATOR_FOREACH(it, key)
{
if (!efreet_ini_string_get(myini, key))
{
s = efreet_ini_string_get(ini, key);
if (s) efreet_ini_string_set(myini, key, s);
}
}
eina_iterator_free(it);
}
if (ini) efreet_ini_free(ini);
}
s = efreet_ini_string_get(myini, "x-scheme-handler/http");
if (!s) s = efreet_ini_string_get(myini, "x-scheme-handler/https");
if (s) cfdata->browser_desktop = eina_stringshare_add(s);
s = efreet_ini_string_get(myini, "x-scheme-handler/mailto");
if (s) cfdata->mailto_desktop = eina_stringshare_add(s);
s = efreet_ini_string_get(myini, "x-scheme-handler/file");
if (s) cfdata->file_desktop = eina_stringshare_add(s);
s = efreet_ini_string_get(myini, "x-scheme-handler/trash");
if (s) cfdata->trash_desktop = eina_stringshare_add(s);
s = efreet_ini_string_get(myini, "x-scheme-handler/terminal");
if (s) cfdata->terminal_desktop = eina_stringshare_add(s);
}
EINA_LIST_FOREACH(e_config->env_vars, l, evr)
{
if (!strcmp(evr->var, "BROWSER"))
{
if ((evr->val) && (!evr->unset))
2012-06-22 00:30:50 -07:00
cfdata->browser_custom = strdup(evr->val);
break;
}
}
2012-06-22 00:30:50 -07:00
homedir = e_user_homedir_get();
2012-06-22 00:30:50 -07:00
snprintf(buf, sizeof(buf), "/usr/local/etc/mime.types");
if (ecore_file_exists(buf)) _load_mimes(cfdata, buf);
snprintf(buf, sizeof(buf), "/etc/mime.types");
if (ecore_file_exists(buf)) _load_mimes(cfdata, buf);
2012-06-22 00:30:50 -07:00
EINA_LIST_FOREACH(efreet_config_dirs_get(), l, s)
{
snprintf(buf, sizeof(buf), "%s/mime/globs", s);
if (ecore_file_exists(buf)) _load_globs(cfdata, buf);
}
2012-06-22 00:30:50 -07:00
snprintf(buf, sizeof(buf), "%s/.mime.types", homedir);
if (ecore_file_exists(buf)) _load_mimes(cfdata, buf);
2012-06-22 00:30:50 -07:00
snprintf(buf, sizeof(buf), "%s/mime/globs", efreet_data_home_get());
if (ecore_file_exists(buf)) _load_globs(cfdata, buf);
2012-06-22 00:30:50 -07:00
cfdata->mimes = eina_list_sort(cfdata->mimes, 0, _sort_mimes);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Config_Mime *m;
Efreet_Desktop *desk;
if (cfdata->selmime) eina_stringshare_del(cfdata->selmime);
if (cfdata->selapp) eina_stringshare_del(cfdata->selapp);
free(cfdata->browser_custom);
if (cfdata->browser_desktop) eina_stringshare_del(cfdata->browser_desktop);
if (cfdata->mailto_desktop) eina_stringshare_del(cfdata->mailto_desktop);
if (cfdata->file_desktop) eina_stringshare_del(cfdata->file_desktop);
if (cfdata->trash_desktop) eina_stringshare_del(cfdata->trash_desktop);
if (cfdata->terminal_desktop) eina_stringshare_del(cfdata->terminal_desktop);
EINA_LIST_FREE(cfdata->mimes, m)
{
Config_Glob *g;
2012-06-22 00:30:50 -07:00
if (!m) continue;
EINA_LIST_FREE(m->globs, g)
{
if (!g) continue;
eina_stringshare_del(g->name);
E_FREE(g);
}
eina_stringshare_del(m->mime);
E_FREE(m);
}
if (cfdata->ini) efreet_ini_free(cfdata->ini);
EINA_LIST_FREE(cfdata->desks, desk)
2012-06-22 00:30:50 -07:00
efreet_desktop_free(desk);
if (cfdata->desk_change_handler)
2012-06-22 00:30:50 -07:00
ecore_event_handler_del(cfdata->desk_change_handler);
E_FREE(cfdata);
}
static Eina_Bool
_desks_update(void *data, int ev_type __UNUSED__, void *ev __UNUSED__)
{
E_Config_Dialog_Data *cfdata = data;
Efreet_Desktop *desk;
EINA_LIST_FREE(cfdata->desks, desk)
2012-06-22 00:30:50 -07:00
efreet_desktop_free(desk);
if (cfdata->gen)
2012-06-22 00:30:50 -07:00
_fill_apps_list(cfdata, cfdata->obj.deflist, &(cfdata->selapp), 1);
else
2012-06-22 00:30:50 -07:00
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
return ECORE_CALLBACK_PASS_ON;
}
static void
_def_browser_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->seldest = &(cfdata->browser_desktop);
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
cfdata->gen = 0;
}
static void
_def_mailto_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->seldest = &(cfdata->mailto_desktop);
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
cfdata->gen = 0;
}
static void
_def_file_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->seldest = &(cfdata->file_desktop);
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
cfdata->gen = 0;
}
static void
_def_trash_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->seldest = &(cfdata->trash_desktop);
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
cfdata->gen = 0;
}
static void
_def_terminal_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->seldest = &(cfdata->terminal_desktop);
_fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0);
cfdata->gen = 0;
}
static void
_sel_mime_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
if (cfdata->selapp) eina_stringshare_del(cfdata->selapp);
cfdata->selapp = NULL;
if (cfdata->selmime)
{
const char *s = efreet_ini_string_get(cfdata->ini, cfdata->selmime);
if (s) cfdata->selapp = eina_stringshare_add(s);
}
_fill_apps_list(cfdata, cfdata->obj.mimelist, &(cfdata->selapp), 1);
cfdata->gen = 1;
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *otb, *ot, *ob, *of, *il;
Eina_List *l;
Config_Mime *m;
2012-06-22 00:30:50 -07:00
otb = e_widget_toolbook_add(evas, 24, 24);
2012-06-22 00:30:50 -07:00
ot = e_widget_table_add(evas, EINA_FALSE);
2012-06-22 00:30:50 -07:00
ob = e_widget_label_add(evas, _("Custom Browser Command"));
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 1, 0, 0);
2012-06-22 00:30:50 -07:00
ob = e_widget_entry_add(evas, &(cfdata->browser_custom), NULL, NULL, NULL);
cfdata->obj.entry = ob;
e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 1, 1, 1, 0);
2012-06-22 00:30:50 -07:00
of = e_widget_framelist_add(evas, _("Default Applications"), 0);
il = e_widget_ilist_add(evas, 24, 24, NULL);
evas_event_freeze(evas);
edje_freeze();
e_widget_ilist_freeze(il);
e_widget_ilist_selector_set(il, 1);
e_widget_ilist_append(il, NULL, _("Browser"), _def_browser_cb, cfdata, NULL);
e_widget_ilist_append(il, NULL, _("E-Mail"), _def_mailto_cb, cfdata, NULL);
e_widget_ilist_append(il, NULL, _("File"), _def_file_cb, cfdata, NULL);
e_widget_ilist_append(il, NULL, _("Trash"), _def_trash_cb, cfdata, NULL);
e_widget_ilist_append(il, NULL, _("Terminal"), _def_terminal_cb, cfdata, NULL);
e_widget_ilist_go(il);
e_widget_ilist_thaw(il);
edje_thaw();
evas_event_thaw(evas);
e_widget_framelist_object_append_full(of, il, 1, 1, 1, 1, 0.5, 0.5, 120, 200, 9999, 9999);
e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 0, 1);
2012-06-22 00:30:50 -07:00
of = e_widget_framelist_add(evas, _("Selected Application"), 0);
il = e_widget_ilist_add(evas, 24, 24, &(cfdata->selapp));
cfdata->obj.deflist = il;
e_widget_ilist_selector_set(il, 1);
e_widget_ilist_go(il);
e_widget_framelist_object_append_full(of, il, 1, 1, 1, 1, 0.5, 0.5, 120, 200, 9999, 9999);
e_widget_table_object_append(ot, of, 1, 1, 1, 1, 1, 1, 1, 1);
e_widget_toolbook_page_append(otb, NULL, _("Core"), ot,
1, 1, 1, 1, 0.5, 0.0);
2012-06-22 00:30:50 -07:00
ot = e_widget_table_add(evas, EINA_FALSE);
2012-06-22 00:30:50 -07:00
of = e_widget_framelist_add(evas, _("Types"), 0);
il = e_widget_ilist_add(evas, 24, 24, &(cfdata->selmime));
evas_event_freeze(evas);
edje_freeze();
e_widget_ilist_freeze(il);
e_widget_ilist_selector_set(il, 1);
EINA_LIST_FOREACH(cfdata->mimes, l, m)
2012-06-22 00:30:50 -07:00
e_widget_ilist_append(il, NULL, m->mime, _sel_mime_cb, cfdata, m->mime);
e_widget_ilist_go(il);
e_widget_ilist_thaw(il);
edje_thaw();
evas_event_thaw(evas);
e_widget_framelist_object_append_full(of, il, 1, 1, 1, 1, 0.5, 0.5, 120, 200, 9999, 9999);
e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1);
2012-06-22 00:30:50 -07:00
of = e_widget_framelist_add(evas, _("Selected Application"), 0);
il = e_widget_ilist_add(evas, 24, 24, &(cfdata->selapp));
cfdata->obj.mimelist = il;
e_widget_ilist_selector_set(il, 1);
e_widget_ilist_go(il);
e_widget_framelist_object_append_full(of, il, 1, 1, 1, 1, 0.5, 0.5, 120, 200, 9999, 9999);
e_widget_table_object_append(ot, of, 1, 0, 1, 1, 1, 1, 1, 1);
e_widget_toolbook_page_append(otb, NULL, _("General"), ot,
1, 1, 1, 1, 0.5, 0.0);
2012-06-22 00:30:50 -07:00
e_widget_toolbook_page_show(otb, 0);
e_win_centered_set(cfd->dia->win, 1);
return otb;
}
static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
E_Config_Env_Var *evr = NULL;
if (cfdata->ini)
{
char buf[PATH_MAX];
2012-06-22 00:30:50 -07:00
if ((cfdata->browser_desktop) && (cfdata->browser_desktop[0]))
{
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/http",
cfdata->browser_desktop);
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/https",
cfdata->browser_desktop);
}
if ((cfdata->mailto_desktop) && (cfdata->mailto_desktop[0]))
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/mailto",
cfdata->mailto_desktop);
if ((cfdata->file_desktop) && (cfdata->file_desktop[0]))
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/file",
cfdata->file_desktop);
if ((cfdata->trash_desktop) && (cfdata->trash_desktop[0]))
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/trash",
cfdata->trash_desktop);
if ((cfdata->terminal_desktop) && (cfdata->terminal_desktop[0]))
efreet_ini_string_set(cfdata->ini, "x-scheme-handler/terminal",
cfdata->terminal_desktop);
snprintf(buf, sizeof(buf), "%s/applications/defaults.list",
efreet_data_home_get());
efreet_ini_save(cfdata->ini, buf);
}
if ((cfdata->browser_custom) && (cfdata->browser_custom[0]))
{
EINA_LIST_FOREACH(e_config->env_vars, l, evr)
{
if (!strcmp(evr->var, "BROWSER")) break;
evr = NULL;
}
if (evr)
{
2012-06-22 00:30:50 -07:00
evr->unset = 0;
if (evr->val) eina_stringshare_del(evr->val);
}
else
{
evr = E_NEW(E_Config_Env_Var, 1);
if (evr)
{
evr->var = eina_stringshare_add("BROWSER");
evr->unset = 0;
e_config->env_vars = eina_list_append(e_config->env_vars, evr);
}
}
if (evr)
{
evr->val = eina_stringshare_add(cfdata->browser_custom);
e_env_set(evr->var, evr->val);
}
}
else
{
EINA_LIST_FOREACH(e_config->env_vars, l, evr)
{
Dear all, I'm attaching a patch for some minor bugs in the e17. Please take a look at attached patch. 01. missing E_FREE(inst) File: src/bin/e_exec.c: 347 Function: _e_exec_cb_exec 02. missing null check File: src/bin/e_fm.c: 10173 Function: _e_fm_error_dialog I'm not sure, but all other codes always check the return value of e_fm2_op_registry_entry_get except here. 03. missing free(slave) File: src/bin/e_fm_ipc.c: 804 Function: _e_fm_ipc_slave_run 04. eina_list_remove after free File: src/bin/e_fm/e_fm_ipc.c :1325 Function: _e_fm_ipc_cb_fop_trash_idler 05. invalid check for _udisks_del, it might be _udisks_chg. File: src/bin/e_fm/e_fm_main_udisks.c : 162 Function: _e_fm_main_udisks_test 06. uninitialized gx and gy values File: src/bin/e_gadcon_popup.c: 172 Function: _e_gadcon_popup_position These could be changed in e_gadcon_client_geometry_get if gcc->o_base is null. 07. unnecessary code 'evas = e_win_evas_get(dia->win)' File: src/bin/e_import_config_dialog.c: 456 Function: e_import_config_dialog_show 08. missing free(sizes) src/bin/e_randr_11_serialization.c: 136 Function: _11_try_restore_configuration() 09. unnecessary variable output_info File: src/bin/e_randr_12.c: 560 Function: _output_property_change_event_cb 10. eina_list_remove after free File: src/bin/e_randr_12_serialization.c : 357 Function: _12_serialized_setup_update 11. no check of the return value of symlink. File: src/bin/e_widget_fsel.c: 84 Function: _e_wid_fsel_favorites_add 12. no evr->var check before comparing string values File: src/modules/conf_applications/e_int_config_defapps.c: 432 Function: _basic_apply 13. missing error message or check return value of edje_file_group_exists File: src/modules/conf_theme/e_int_config_theme.c: 333 Function: _open_test_cb Anyway, I've added e_util_dialog_show if failed. Is it okay? 14. missing index range check File: src/modules/gadman/e_mod_config.c: 153 Function: _cb_config It could read negative array index, because return value of e_widget_ilist_selected_get might be negative. BR, Gwanglim SVN revision: 80020
2012-12-02 23:54:07 -08:00
if (!e_util_strcmp(evr->var, "BROWSER"))
{
e_config->env_vars = eina_list_remove_list(e_config->env_vars, l);
if (evr->val) eina_stringshare_del(evr->val);
if (evr->var) eina_stringshare_del(evr->var);
free(evr);
break;
}
}
e_env_unset("BROWSER");
}
e_config_save_queue();
return 1;
}
static void
_load_mimes(E_Config_Dialog_Data *cfdata, char *file)
{
FILE *f;
char buf[4096], mimetype[4096], ext[4096];
char *p, *pp;
Config_Mime *config_mime;
Config_Glob *config_glob;
2012-06-22 00:30:50 -07:00
if (!cfdata) return;
2012-06-22 00:30:50 -07:00
f = fopen(file, "rb");
if (!f) return;
while (fgets(buf, sizeof(buf), f))
{
p = buf;
2012-06-22 00:30:50 -07:00
while (isblank(*p) && (*p != 0) && (*p != '\n'))
p++;
if (*p == '#') continue;
if ((*p == '\n') || (*p == 0)) continue;
pp = p;
2012-06-22 00:30:50 -07:00
while (!isblank(*p) && (*p != 0) && (*p != '\n'))
p++;
if ((*p == '\n') || (*p == 0)) continue;
strncpy(mimetype, pp, (p - pp));
mimetype[p - pp] = 0;
do
{
2012-06-22 00:30:50 -07:00
while (isblank(*p) && (*p != 0) && (*p != '\n'))
p++;
if ((*p == '\n') || (*p == 0)) continue;
pp = p;
2012-06-22 00:30:50 -07:00
while (!isblank(*p) && (*p != 0) && (*p != '\n'))
p++;
strncpy(ext, pp, (p - pp));
ext[p - pp] = 0;
config_mime = _find_mime(cfdata, mimetype);
if (!config_mime)
{
config_mime = E_NEW(Config_Mime, 1);
if (config_mime)
{
config_mime->mime = eina_stringshare_add(mimetype);
if (!config_mime->mime)
2012-06-22 00:30:50 -07:00
free(config_mime);
else
{
config_glob = E_NEW(Config_Glob, 1);
config_glob->name = eina_stringshare_add(ext);
config_mime->globs = eina_list_append(config_mime->globs, config_glob);
cfdata->mimes = eina_list_append(cfdata->mimes, config_mime);
}
}
}
else
{
config_glob = _find_glob(config_mime, ext);
if (!config_glob)
{
config_glob = E_NEW(Config_Glob, 1);
config_glob->name = eina_stringshare_add(ext);
config_mime->globs = eina_list_append(config_mime->globs, config_glob);
}
}
}
while ((*p != '\n') && (*p != 0));
}
fclose(f);
}
static void
_load_globs(E_Config_Dialog_Data *cfdata, char *file)
{
FILE *f;
char buf[4096], mimetype[4096], ext[4096];
char *p, *pp;
Config_Mime *config_mime;
Config_Glob *config_glob;
2012-06-22 00:30:50 -07:00
if (!cfdata) return;
2012-06-22 00:30:50 -07:00
f = fopen(file, "rb");
if (!f) return;
while (fgets(buf, sizeof(buf), f))
{
p = buf;
2012-06-22 00:30:50 -07:00
while (isblank(*p) && (*p != 0) && (*p != '\n'))
p++;
if (*p == '#') continue;
if ((*p == '\n') || (*p == 0)) continue;
pp = p;
2012-06-22 00:30:50 -07:00
while ((*p != ':') && (*p != 0) && (*p != '\n'))
p++;
if ((*p == '\n') || (*p == 0)) continue;
strncpy(mimetype, pp, (p - pp));
mimetype[p - pp] = 0;
p++;
pp = ext;
while ((*p != 0) && (*p != '\n'))
{
*pp = *p;
pp++;
p++;
}
*pp = 0;
config_mime = _find_mime(cfdata, mimetype);
if (!config_mime)
{
config_mime = E_NEW(Config_Mime, 1);
if (config_mime)
{
config_mime->mime = eina_stringshare_add(mimetype);
if (!config_mime->mime)
2012-06-22 00:30:50 -07:00
free(config_mime);
else
{
config_glob = E_NEW(Config_Glob, 1);
config_glob->name = eina_stringshare_add(ext);
config_mime->globs = eina_list_append(config_mime->globs, config_glob);
cfdata->mimes = eina_list_append(cfdata->mimes, config_mime);
}
}
}
else
{
config_glob = _find_glob(config_mime, ext);
if (!config_glob)
{
config_glob = E_NEW(Config_Glob, 1);
config_glob->name = eina_stringshare_add(ext);
config_mime->globs = eina_list_append(config_mime->globs, config_glob);
}
}
}
fclose(f);
}
static int
_sort_mimes(const void *data1, const void *data2)
{
const Config_Mime *m1 = data1, *m2 = data2;
if (!m1) return 1;
if (!m2) return -1;
2012-06-22 00:30:50 -07:00
return strcmp(m1->mime, m2->mime);
}
static Config_Mime *
_find_mime(E_Config_Dialog_Data *cfdata, char *mime)
{
Config_Mime *cm;
Eina_List *l;
2012-06-22 00:30:50 -07:00
if (!cfdata) return NULL;
EINA_LIST_FOREACH(cfdata->mimes, l, cm)
{
if (!cm) continue;
if (!strcmp(cm->mime, mime)) return cm;
}
return NULL;
}
static Config_Glob *
_find_glob(Config_Mime *mime, char *globbing)
{
Config_Glob *g;
Eina_List *l;
2012-06-22 00:30:50 -07:00
if (!mime) return NULL;
EINA_LIST_FOREACH(mime->globs, l, g)
{
if (!g) continue;
if (strcmp(g->name, globbing)) continue;
return g;
}
return NULL;
}
static int
_cb_desks_sort(const void *data1, const void *data2)
{
const Efreet_Desktop *d1, *d2;
2012-06-22 00:30:50 -07:00
if (!(d1 = data1)) return 1;
if (!d1->name) return 1;
if (!(d2 = data2)) return -1;
if (!d2->name) return -1;
return strcmp(d1->name, d2->name);
}
static void
_sel_desk_gen_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
const char *s = e_widget_ilist_selected_value_get(cfdata->obj.mimelist);
if ((s) && (cfdata->selmime))
{
if (cfdata->ini)
2012-06-22 00:30:50 -07:00
efreet_ini_string_set(cfdata->ini, cfdata->selmime, s);
}
}
static void
_sel_desk_cb(void *data)
{
E_Config_Dialog_Data *cfdata = data;
if (cfdata->seldest)
{
const char *s = e_widget_ilist_selected_value_get(cfdata->obj.deflist);
if (*(cfdata->seldest)) eina_stringshare_del(*(cfdata->seldest));
*(cfdata->seldest) = NULL;
if (s) *(cfdata->seldest) = eina_stringshare_add(s);
if ((*(cfdata->seldest)) &&
(cfdata->seldest == &(cfdata->browser_desktop)))
{
Eina_List *l;
Efreet_Desktop *desk;
2012-06-22 00:30:50 -07:00
EINA_LIST_FOREACH(cfdata->desks, l, desk)
{
if ((!strcmp(desk->orig_path, *(cfdata->seldest))) ||
(!strcmp(ecore_file_file_get(desk->orig_path), *(cfdata->seldest))))
{
if (desk->exec)
{
char *p;
2012-06-22 00:30:50 -07:00
free(cfdata->browser_custom);
cfdata->browser_custom = strdup(desk->exec);
for (p = cfdata->browser_custom; *p; p++)
{
if (p > cfdata->browser_custom)
{
if ((isspace(*p)) &&
(p[-1] != '\\'))
{
*p = 0;
break;
}
}
}
p = strdup(cfdata->browser_custom);
if (p)
{
e_widget_entry_text_set(cfdata->obj.entry, p);
free(p);
}
}
break;
}
}
}
}
}
static void
_fill_apps_list(E_Config_Dialog_Data *cfdata, Evas_Object *il, const char **desktop, int general)
{
Eina_List *desks = NULL, *l;
Efreet_Desktop *desk = NULL;
Evas *evas;
int sel, i;
2012-06-22 00:30:50 -07:00
if (!cfdata->desks)
{
desks = efreet_util_desktop_name_glob_list("*");
EINA_LIST_FREE(desks, desk)
{
Eina_List *ll;
2012-06-22 00:30:50 -07:00
if (desk->no_display)
{
efreet_desktop_free(desk);
continue;
}
ll = eina_list_search_unsorted_list(cfdata->desks, _cb_desks_sort, desk);
if (ll)
{
Efreet_Desktop *old;
2012-06-22 00:30:50 -07:00
old = eina_list_data_get(ll);
/*
* This fixes when we have several .desktop with the same name,
* and the only difference is that some of them are for specific
* desktops.
*/
if ((old->only_show_in) && (!desk->only_show_in))
{
efreet_desktop_free(old);
eina_list_data_set(ll, desk);
}
else
2012-06-22 00:30:50 -07:00
efreet_desktop_free(desk);
}
else
2012-06-22 00:30:50 -07:00
cfdata->desks = eina_list_append(cfdata->desks, desk);
}
cfdata->desks = eina_list_sort(cfdata->desks, -1, _cb_desks_sort);
}
2012-06-22 00:30:50 -07:00
evas = evas_object_evas_get(il);
evas_event_freeze(evas);
edje_freeze();
e_widget_ilist_freeze(il);
e_widget_ilist_clear(il);
sel = -1;
i = 0;
EINA_LIST_FOREACH(cfdata->desks, l, desk)
{
Evas_Object *icon = NULL;
2012-06-22 00:30:50 -07:00
if ((desktop) && (*desktop))
{
if ((!strcmp(desk->orig_path, *desktop)) ||
(!strcmp(ecore_file_file_get(desk->orig_path), *desktop)))
2012-06-22 00:30:50 -07:00
sel = i;
}
2012-06-22 00:30:50 -07:00
icon = e_util_desktop_icon_add(desk, 24, evas);
if (general)
2012-06-22 00:30:50 -07:00
e_widget_ilist_append(il, icon, desk->name,
_sel_desk_gen_cb, cfdata,
ecore_file_file_get(desk->orig_path));
else
2012-06-22 00:30:50 -07:00
e_widget_ilist_append(il, icon, desk->name,
_sel_desk_cb, cfdata,
ecore_file_file_get(desk->orig_path));
i++;
}
2012-06-22 00:30:50 -07:00
e_widget_ilist_go(il);
e_widget_ilist_thaw(il);
edje_thaw();
evas_event_thaw(evas);
if (sel >= 0)
{
e_widget_ilist_selected_set(il, sel);
e_widget_ilist_nth_show(il, sel, 0);
}
}
2012-06-22 00:30:50 -07:00