aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/wizard/page_020.c
blob: e72331047bf96d59f431a5fed1c10cd69d233200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"
#include "e_mod_main.h"

static char *profile = NULL;
static Evas_Object *textblock = NULL;

static void
_profile_change(void *data, Evas_Object *obj)
{
   char buf[PATH_MAX], *dir;
   Efreet_Desktop *desk = NULL;
   
   dir = e_prefix_data_get();
   snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, profile);
   dir = strdup(buf);
   if (!dir)
     {
	e_widget_textblock_markup_set(textblock, _("Unknown"));
	return;
     }
   snprintf(buf, sizeof(buf), "%s/profile.desktop", dir);
   desk = efreet_desktop_get(buf);
   if (desk)
     {
	e_widget_textblock_markup_set(textblock, desk->comment);
     }
   else
     e_widget_textblock_markup_set(textblock, _("Unknown"));
   if (desk) efreet_desktop_free(desk);
   free(dir);
}

EAPI int
wizard_page_init(E_Wizard_Page *pg)
{
   return 1;
}
EAPI int
wizard_page_shutdown(E_Wizard_Page *pg)
{
   return 1;
}
EAPI int
wizard_page_show(E_Wizard_Page *pg)
{
   Evas_Object *o, *of, *ob;
   Eina_List *l, *profiles;
   int i, sel = -1;
   Evas_Object *ilist;
   
   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);
   e_widget_min_size_set(ob, 140 * e_scale, 70 * e_scale);
   ilist = ob;
   e_widget_on_change_hook_set(ob, _profile_change, NULL);
   
   e_widget_ilist_freeze(ob);
   
   profiles = e_config_profile_list();
   for (i = 0, l = profiles; l; l = l->next, i++)
     {
        Efreet_Desktop *desk = NULL;
	char buf[PATH_MAX], *prof, *dir;
	const char *label;
	Evas_Object *ic;
	
	prof = l->data;
	dir = e_prefix_data_get();
	snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, prof);
	dir = strdup(buf);
	if (!dir)
	  {
	     free(prof);
	     continue;
	  }
	
	snprintf(buf, sizeof(buf), "%s/profile.desktop", dir);
        desk = efreet_desktop_get(buf);
	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);
	ic = e_util_icon_add(buf, pg->evas);
	
	e_widget_ilist_append(ob, ic, label, NULL, NULL, prof);
	if (e_config_profile_get())
	  {
	     if (!strcmp(prof, e_config_profile_get())) sel = i;
	  }
	free(dir);
	free(prof);
        if (desk) efreet_desktop_free(desk);
     }
   if (profiles) evas_list_free(profiles);

   e_widget_ilist_go(ob);
   e_widget_ilist_thaw(ob);
   
   e_widget_framelist_object_append(of, ob);
   
   ob = e_widget_textblock_add(pg->evas);
   e_widget_min_size_set(ob, 140 * e_scale, 70 * e_scale);
   e_widget_textblock_markup_set(ob, _("Select a profile"));
   textblock = ob;
   
   e_widget_framelist_object_append(of, ob);
   
   e_widget_list_object_append(o, of, 0, 0, 0.5);

   if (sel >= 0) e_widget_ilist_selected_set(ilist, sel);
   
   evas_object_show(ob);
   evas_object_show(of);
   e_wizard_page_show(o);
   pg->data = of;
   return 1; /* 1 == show ui, and wait for user, 0 == just continue */
}
EAPI int
wizard_page_hide(E_Wizard_Page *pg)
{
   evas_object_del(pg->data);
   return 1;
}
EAPI int
wizard_page_apply(E_Wizard_Page *pg)
{
   // FIXME: actually apply profile
   return 1;
}