2009-11-20 08:12:16 -08:00
|
|
|
/* Profile chooser */
|
2007-09-14 09:57:01 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2009-03-11 08:13:42 -07:00
|
|
|
static const char *profile = NULL;
|
2008-10-25 01:53:44 -07:00
|
|
|
static Evas_Object *textblock = NULL;
|
|
|
|
|
|
|
|
static void
|
2010-08-19 09:52:09 -07:00
|
|
|
_profile_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
|
2008-10-25 01:53:44 -07:00
|
|
|
{
|
2008-11-11 10:30:59 -08:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
const char *dir;
|
2008-10-25 01:53:44 -07:00
|
|
|
Efreet_Desktop *desk = NULL;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
|
|
|
e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", profile);
|
2008-10-25 01:53:44 -07:00
|
|
|
dir = strdup(buf);
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
e_widget_textblock_markup_set(textblock, _("Unknown"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
snprintf(buf, sizeof(buf), "%s/profile.desktop", dir);
|
2010-03-03 14:10:55 -08:00
|
|
|
desk = efreet_desktop_new(buf);
|
2008-10-25 01:53:44 -07:00
|
|
|
if (desk)
|
2011-08-19 22:11:38 -07:00
|
|
|
{
|
|
|
|
e_widget_textblock_markup_set(textblock, desk->comment);
|
|
|
|
efreet_desktop_free(desk);
|
|
|
|
}
|
2008-10-25 01:53:44 -07:00
|
|
|
else
|
|
|
|
e_widget_textblock_markup_set(textblock, _("Unknown"));
|
2008-11-11 10:30:59 -08:00
|
|
|
|
2008-10-26 02:04:05 -07:00
|
|
|
// enable next once you choose a profile
|
|
|
|
e_wizard_button_next_enable_set(1);
|
2008-10-25 01:53:44 -07:00
|
|
|
}
|
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
EAPI int
|
2010-08-19 09:52:09 -07:00
|
|
|
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
|
2007-09-14 09:57:01 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
EAPI int
|
2010-08-19 09:52:09 -07:00
|
|
|
wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
|
2007-09-14 09:57:01 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
EAPI int
|
|
|
|
wizard_page_show(E_Wizard_Page *pg)
|
|
|
|
{
|
2008-10-25 01:53:44 -07:00
|
|
|
Evas_Object *o, *of, *ob;
|
|
|
|
Eina_List *l, *profiles;
|
|
|
|
int i, sel = -1;
|
|
|
|
Evas_Object *ilist;
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
o = e_widget_list_add(pg->evas, 1, 0);
|
|
|
|
e_wizard_title_set(_("Profile"));
|
|
|
|
of = e_widget_framelist_add(pg->evas, _("Select one"), 0);
|
|
|
|
|
|
|
|
ob = e_widget_ilist_add(pg->evas, 32 * e_scale, 32 * e_scale, &profile);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(ob, 140 * e_scale, 70 * e_scale);
|
2008-10-25 01:53:44 -07:00
|
|
|
ilist = ob;
|
|
|
|
e_widget_on_change_hook_set(ob, _profile_change, NULL);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
e_widget_ilist_freeze(ob);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
profiles = e_config_profile_list();
|
|
|
|
for (i = 0, l = profiles; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
Efreet_Desktop *desk = NULL;
|
2008-11-11 10:30:59 -08:00
|
|
|
char buf[PATH_MAX], *prof;
|
|
|
|
const char *label, *dir;
|
2008-10-25 01:53:44 -07:00
|
|
|
Evas_Object *ic;
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
prof = l->data;
|
2008-10-26 02:04:05 -07:00
|
|
|
if (e_config_profile_get())
|
|
|
|
{
|
|
|
|
if (!strcmp(prof, e_config_profile_get()))
|
|
|
|
{
|
|
|
|
free(prof);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2009-04-13 07:56:38 -07:00
|
|
|
e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", prof);
|
2008-10-26 02:04:05 -07:00
|
|
|
// if it's not a system profile - don't offer it
|
|
|
|
if (!ecore_file_is_dir(buf))
|
|
|
|
{
|
|
|
|
free(prof);
|
|
|
|
continue;
|
|
|
|
}
|
2008-10-25 01:53:44 -07:00
|
|
|
dir = strdup(buf);
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
free(prof);
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-15 02:21:12 -07:00
|
|
|
if (!strcmp(prof, "standard")) sel = i;
|
2008-10-25 01:53:44 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/profile.desktop", dir);
|
2010-03-03 14:10:55 -08:00
|
|
|
desk = efreet_desktop_new(buf);
|
2008-10-25 01:53:44 -07:00
|
|
|
label = prof;
|
|
|
|
if ((desk) && (desk->name)) label = desk->name;
|
|
|
|
snprintf(buf, sizeof(buf), "%s/icon.edj", dir);
|
|
|
|
if ((desk) && (desk->icon))
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", dir, desk->icon);
|
2008-10-25 01:58:06 -07:00
|
|
|
else
|
2009-04-13 07:56:38 -07:00
|
|
|
e_prefix_data_concat_static(buf, "data/images/enlightenment.png");
|
2008-10-25 01:53:44 -07:00
|
|
|
ic = e_util_icon_add(buf, pg->evas);
|
|
|
|
e_widget_ilist_append(ob, ic, label, NULL, NULL, prof);
|
|
|
|
free(prof);
|
|
|
|
if (desk) efreet_desktop_free(desk);
|
|
|
|
}
|
2009-02-25 09:05:46 -08:00
|
|
|
if (profiles) eina_list_free(profiles);
|
2008-10-25 01:53:44 -07:00
|
|
|
|
|
|
|
e_widget_ilist_go(ob);
|
|
|
|
e_widget_ilist_thaw(ob);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
e_widget_framelist_object_append(of, ob);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
ob = e_widget_textblock_add(pg->evas);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(ob, 140 * e_scale, 70 * e_scale);
|
2008-10-25 01:53:44 -07:00
|
|
|
e_widget_textblock_markup_set(ob, _("Select a profile"));
|
|
|
|
textblock = ob;
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
e_widget_framelist_object_append(of, ob);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 08:38:27 -07:00
|
|
|
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
2008-10-25 01:53:44 -07:00
|
|
|
|
|
|
|
if (sel >= 0) e_widget_ilist_selected_set(ilist, sel);
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2008-10-25 01:53:44 -07:00
|
|
|
evas_object_show(ob);
|
|
|
|
evas_object_show(of);
|
|
|
|
e_wizard_page_show(o);
|
2011-08-30 17:05:44 -07:00
|
|
|
// pg->data = o;
|
2008-10-26 02:04:05 -07:00
|
|
|
e_wizard_button_next_enable_set(0);
|
2007-09-14 09:57:01 -07:00
|
|
|
return 1; /* 1 == show ui, and wait for user, 0 == just continue */
|
|
|
|
}
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
EAPI int
|
2011-09-04 10:04:58 -07:00
|
|
|
wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
|
2007-09-14 09:57:01 -07:00
|
|
|
{
|
2011-08-30 17:05:44 -07:00
|
|
|
// evas_object_del(pg->data);
|
2008-10-26 02:04:05 -07:00
|
|
|
// actually apply profile
|
|
|
|
if (!profile) profile = "standard";
|
|
|
|
e_config_profile_set(profile);
|
2011-08-15 02:21:12 -07:00
|
|
|
e_config_profile_del(e_config_profile_get());
|
|
|
|
e_config_load();
|
|
|
|
e_config_save();
|
2007-09-14 09:57:01 -07:00
|
|
|
return 1;
|
|
|
|
}
|
2009-11-25 10:55:15 -08:00
|
|
|
|
2007-09-14 09:57:01 -07:00
|
|
|
EAPI int
|
2010-08-19 09:52:09 -07:00
|
|
|
wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
|
2007-09-14 09:57:01 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|