profile config now offers reset and is spruiced up to be like the wizard one

supportign the profile.desktop descriptions and icons.



SVN revision: 38872
devs/princeamd/enlightenment-0.17-elive
Carsten Haitzler 14 years ago
parent 05d1563e4e
commit ca0d7dfcfc
  1. 4
      data/themes/default.edc
  2. 11
      src/bin/e_widget_table.c
  3. 1
      src/bin/e_widget_table.h
  4. 179
      src/modules/conf_profiles/e_int_config_profiles.c

@ -22451,6 +22451,10 @@ ICON("widget/close","icon_close.png",64)
ICON("enlightenment/engine","icon_dummy.png",64)
ICON("enlightenment/toolbar","icon_dummy.png",64)
ICON("enlightenment/settings","icon_dummy.png",64)
ICON("enlightenment/warning","icon_dummy.png",64)
ICON("widget/open","icon_dummy.png",64)
ICON("widget/close","icon_dummy.png",64)
ICON("widget/reset","icon_dummy.png",64)
/// Normal Icons ///

@ -38,6 +38,15 @@ e_widget_table_add(Evas *evas, int homogenous)
EAPI void
e_widget_table_object_append(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h)
{
e_widget_table_object_align_append(obj, sobj,
col, row, colspan, rowspan,
fill_w, fill_h, expand_w, expand_h,
0.5, 0.5);
}
EAPI void
e_widget_table_object_align_append(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h, double ax, double ay)
{
E_Widget_Data *wd;
Evas_Coord mw = 0, mh = 0;
@ -49,7 +58,7 @@ e_widget_table_object_append(Evas_Object *obj, Evas_Object *sobj, int col, int r
e_table_pack_options_set(sobj,
fill_w, fill_h, /* fill */
expand_w, expand_h, /* expand */
0.5, 0.5, /* align */
ax, ay, /* align */
mw, mh, /* min */
99999, 99999 /* max */
);

@ -8,6 +8,7 @@
EAPI Evas_Object *e_widget_table_add(Evas *evas, int homogenous);
EAPI void e_widget_table_object_append(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h);
EAPI void e_widget_table_object_align_append(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h, double ax, double ay);
EAPI void e_widget_table_object_repack(Evas_Object *obj, Evas_Object *sobj, int col, int row, int colspan, int rowspan, int fill_w, int fill_h, int expand_w, int expand_h);
EAPI void e_widget_table_unpack(Evas_Object *obj, Evas_Object *sobj);

@ -9,6 +9,7 @@ static void _ilist_cb_selected(void *data);
static void _cb_add(void *data, void *data2);
static void _cb_select(void *data, void *data2);
static void _cb_delete(void *data, void *data2);
static void _cb_reset(void *data, void *data2);
static void _cb_dialog_yes(void *data);
static void _cb_dialog_destroy(void *data);
@ -23,11 +24,12 @@ struct _E_Config_Dialog_Data
E_Config_Dialog *cfd;
Evas_Object *o_list;
Evas_Object *o_delete;
Evas_Object *o_reset;
Evas_Object *o_text;
char *sel_profile;
E_Dialog *dia_new_profile;
char *new_profile;
int new_profile_type;
};
typedef struct _Del_Profile_Confirm_Data Del_Profile_Confirm_Data;
@ -98,21 +100,40 @@ static Evas_Object *
_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *of, *ot, *ob;
const char *dir;
char buf[PATH_MAX];
o = e_widget_list_add(evas, 0, 1);
o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("Available Profiles"), 0);
cfdata->o_list = e_widget_ilist_add(evas, 24, 24, &(cfdata->sel_profile));
e_widget_min_size_set(cfdata->o_list, 155, 150);
e_widget_min_size_set(cfdata->o_list, 140 * e_scale, 50 * e_scale);
e_widget_framelist_object_append(of, cfdata->o_list);
e_widget_list_object_append(o, of, 1, 1, 0.5);
ob = e_widget_textblock_add(evas);
e_widget_min_size_set(ob, 140 * e_scale, 50 * e_scale);
e_widget_textblock_markup_set(ob, _("Select a profile"));
e_widget_list_object_append(o, ob, 1, 0, 0.5);
cfdata->o_text = ob;
ot = e_widget_table_add(evas, 0);
ob = e_widget_button_add(evas, _("Add"), "widget/add", _cb_add, cfdata, NULL);
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 1, 0, 0);
cfdata->o_delete = e_widget_button_add(evas, _("Delete"), "widget/del", _cb_delete, cfdata, NULL);
e_widget_table_object_append(ot, cfdata->o_delete, 0, 1, 1, 1, 1, 1, 0, 0);
e_widget_table_object_append(ot, cfdata->o_delete, 1, 0, 1, 1, 1, 1, 0, 0);
cfdata->o_reset = e_widget_button_add(evas, _("Reset"), "widget/reset", _cb_reset, cfdata, NULL);
e_widget_table_object_align_append(ot, cfdata->o_reset, 2, 0, 1, 1, 0, 1, 1, 1, 1.0, 0.5);
// if there is a system version of the profile - allow reset
dir = e_prefix_data_get();
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, e_config_profile_get());
if (ecore_file_is_dir(buf))
e_widget_disabled_set(cfdata->o_reset, 0);
else
e_widget_disabled_set(cfdata->o_reset, 1);
e_widget_disabled_set(cfdata->o_delete, 1);
e_widget_list_object_append(o, ot, 1, 0, 0.0);
@ -127,9 +148,10 @@ static void
_ilist_fill(E_Config_Dialog_Data *cfdata)
{
Evas *evas;
Eina_List *l;
Eina_List *l, *profiles;
const char *cur_profile;
int selected = -1, i;
if (!cfdata) return;
if (!cfdata->o_list) return;
@ -142,19 +164,51 @@ _ilist_fill(E_Config_Dialog_Data *cfdata)
e_widget_ilist_go(cfdata->o_list);
cur_profile = e_config_profile_get();
for (l = e_config_profile_list(); l; l = l->next)
profiles = e_config_profile_list();
for (i = 0, l = profiles; l; l = l->next, i++)
{
Evas_Object *ob;
ob = edje_object_add(evas);
e_widget_ilist_append(cfdata->o_list, ob, l->data, _ilist_cb_selected, cfdata, l->data);
if (!strcmp(cur_profile, l->data))
{
e_util_edje_icon_set(ob, "enlightenment/check");
e_widget_ilist_selected_set(cfdata->o_list, e_widget_ilist_count(cfdata->o_list));
}
Efreet_Desktop *desk = NULL;
Evas_Object *ic;
char buf[PATH_MAX], *prof, *pdir;
const char *label, *dir;
prof = l->data;
if (e_config_profile_get())
{
if (!strcmp(prof, e_config_profile_get())) selected = i;
}
pdir = e_config_profile_dir_get(prof);
snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
desk = efreet_desktop_get(buf);
if (!desk)
{
dir = e_prefix_data_get();
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, prof);
pdir = strdup(buf);
if (pdir)
{
snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
desk = efreet_desktop_get(buf);
}
}
label = prof;
if ((desk) && (desk->name)) label = desk->name;
buf[0] = 0;
if (pdir)
snprintf(buf, sizeof(buf), "%s/icon.edj", pdir);
if ((desk) && (desk->icon) && (pdir))
snprintf(buf, sizeof(buf), "%s/%s", pdir, desk->icon);
else
snprintf(buf, sizeof(buf), "%s/data/images/enlightenment.png", e_prefix_data_get());
ic = e_util_icon_add(buf, evas);
e_widget_ilist_append(cfdata->o_list, ic, label, _ilist_cb_selected, cfdata, prof);
if (pdir) free(pdir);
free(prof);
if (desk) efreet_desktop_free(desk);
}
if (profiles) evas_list_free(profiles);
if (selected >= 0)
e_widget_ilist_selected_set(cfdata->o_list, selected);
e_widget_min_size_set(cfdata->o_list, 155, 250);
e_widget_ilist_go(cfdata->o_list);
@ -167,17 +221,39 @@ static void
_ilist_cb_selected(void *data)
{
E_Config_Dialog_Data *cfdata;
const char *cur_profile;
const char *cur_profile, *dir;
unsigned char v;
Efreet_Desktop *desk = NULL;
char *pdir, buf[PATH_MAX];
cfdata = data;
if (!cfdata) return;
cur_profile = e_config_profile_get();
v = strcmp(cur_profile, cfdata->sel_profile) == 0;
v = (strcmp(cur_profile, cfdata->sel_profile) == 0);
e_widget_disabled_set(cfdata->o_delete, v);
e_config_dialog_changed_set(cfdata->cfd, !v);
pdir = e_config_profile_dir_get(cfdata->sel_profile);
snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
desk = efreet_desktop_get(buf);
if (!desk)
{
dir = e_prefix_data_get();
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, cfdata->sel_profile);
pdir = strdup(buf);
if (pdir)
{
snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
desk = efreet_desktop_get(buf);
}
}
if (desk)
e_widget_textblock_markup_set(cfdata->o_text, desk->comment);
else
e_widget_textblock_markup_set(cfdata->o_text, _("Unknown"));
if (desk) efreet_desktop_free(desk);
}
static void
@ -205,12 +281,33 @@ _cb_delete(void *data, void *data2)
d->cfdata = data;
if (!d->cfdata) return;
snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br><br>"
"Are you sure you want to delete this profile?"),
d->cfdata->sel_profile);
e_confirm_dialog_show(_("Are you sure you want to delete this profile?"),
"enlightenment/exit", buf, NULL, NULL, _cb_dialog_yes, NULL, d, NULL,
_cb_dialog_destroy, d);
snprintf(buf, sizeof(buf),
_("You want to delete the \"%s\" profile.<br><br>"
"Are you sure?"),
d->cfdata->sel_profile);
e_confirm_dialog_show
(_("Delete OK?"),
"enlightenment/warning", buf, NULL, NULL, _cb_dialog_yes, NULL, d, NULL,
_cb_dialog_destroy, d);
}
static void
_cb_reset(void *data, void *data2)
{
E_Action *a;
char *pdir;
e_config_save_flush();
e_config_save_block_set(1);
pdir = e_config_profile_dir_get(e_config_profile_get());
if (pdir)
{
ecore_file_recursive_rm(pdir);
free(pdir);
}
a = e_action_find("restart");
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
}
static void
@ -241,7 +338,6 @@ EAPI E_Dialog *
_dia_new_profile(E_Config_Dialog_Data *cfdata)
{
E_Dialog *dia;
E_Radio_Group *rg;
Evas *evas;
Evas_Coord mw, mh;
Evas_Object *ot, *ob;
@ -267,17 +363,6 @@ _dia_new_profile(E_Config_Dialog_Data *cfdata)
e_widget_table_object_append(ot, ob,
1, 0, 1, 1,
1, 1, 1, 0);
rg = e_widget_radio_group_new(&cfdata->new_profile_type);
ob = e_widget_radio_add(evas, _("Plain Profile"), 0, rg);
e_widget_table_object_append(ot, ob,
0, 1, 2, 1,
1, 1, 1, 0);
ob = e_widget_radio_add(evas, _("Clone Current Profile"), 1, rg);
e_widget_table_object_append(ot, ob,
0, 2, 2, 1,
1, 1, 1, 0);
e_widget_min_size_get(ot, &mw, &mh);
e_dialog_content_set(dia, ot, mw, mh);
@ -300,7 +385,6 @@ _new_profile_cb_close(void *data, E_Dialog *dia)
e_object_unref(E_OBJECT(dia));
cfdata->dia_new_profile = NULL;
cfdata->new_profile = NULL;
cfdata->new_profile_type = 0;
}
static void
@ -312,25 +396,19 @@ _new_profile_cb_ok(void *data, E_Dialog *dia)
cfdata = data;
if (!cfdata) return;
snprintf(cur_profile, sizeof (cur_profile), "%s", e_config_profile_get());
snprintf(cur_profile, sizeof(cur_profile), "%s", e_config_profile_get());
if (cfdata->new_profile)
{
e_config_profile_add(cfdata->new_profile);
// FIXME: if we DONT run the below we start with an empty profile which ends
// up inheriting from default... whihc runs the wizard! should copy standard
// if (cfdata->new_profile_type)
{
e_config_profile_set(cfdata->new_profile);
e_config_save();
e_config_profile_set(cur_profile);
}
e_config_profile_set(cfdata->new_profile);
e_config_save();
e_config_profile_set(cur_profile);
}
e_object_unref(E_OBJECT(dia));
cfdata->dia_new_profile = NULL;
cfdata->new_profile = NULL;
cfdata->new_profile_type = 0;
_ilist_fill(cfdata);
}
@ -342,6 +420,5 @@ _new_profile_cb_dia_del(void *obj)
cfdata->dia_new_profile = NULL;
cfdata->new_profile = NULL;
cfdata->new_profile_type = 0;
e_object_unref(E_OBJECT(dia));
}

Loading…
Cancel
Save