summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Hughart <mekius@mekius.net>2012-09-08 03:19:16 +0000
committerNicholas Hughart <mekius@mekius.net>2012-09-08 03:19:16 +0000
commitdda7d97dd07409f37049aa2ae9eae44fa23a7aa5 (patch)
treeeb7641c56ec0bd520d20ad1488f9d3e2fc6973e6
parent9c861b341fe2cd9f6c6a292e4e17412093c98939 (diff)
Massive interface improvement, seriously massive.
Ok, this is much better. I'd like to thank elm_grid for making all this possible. Without you being pretty much the only widget in all of Elementary that makes any sense to me, none of this would be possible. Anyway, give it a try, let me know if it's good, bad, terrible, etc. SVN revision: 76327
-rw-r--r--src/bin/gui.c168
-rw-r--r--src/bin/main.c3
2 files changed, 76 insertions, 95 deletions
diff --git a/src/bin/gui.c b/src/bin/gui.c
index 0a1e2f8..f6d28a0 100644
--- a/src/bin/gui.c
+++ b/src/bin/gui.c
@@ -8,27 +8,23 @@ static Eina_Bool _gui_grab_keyboard(void *data);
8 8
9static struct 9static struct
10{ 10{
11 unsigned int h;
12 unsigned int w;
11 Evas_Object *win; // elm_win 13 Evas_Object *win; // elm_win
12 Evas_Object *frame; // elm_frame
13 Evas_Object *password; // elm_entry 14 Evas_Object *password; // elm_entry
14 Evas_Object *icon; // elm_icon 15 Evas_Object *icon; // elm_icon
15 Evas_Object *message; // elm_label 16 Evas_Object *message; // evas_object_text
16 Evas_Object *identity; // elm_hoversel 17 Evas_Object *identity; // elm_hoversel
18 Evas_Object *grid; // elm_grid
17 Empower_Identity *id; 19 Empower_Identity *id;
18} _gui; 20} _gui;
19 21
20Eina_Bool gui_init() 22Eina_Bool gui_init()
21{ 23{
22 char buf[PATH_MAX]; 24 char buf[PATH_MAX];
23 Evas_Object *vbox;
24 Evas_Object *vbox2;
25 Evas_Object *hbox;
26 Evas_Object *bg; 25 Evas_Object *bg;
27 Evas_Object *frame; 26 Evas_Object *o;
28 Evas_Object *frame2; 27 unsigned int w,h;
29 Evas_Object *frame3;
30 Evas_Object *label;
31 Evas_Object *grid;
32 28
33 _gui.win = elm_win_add(NULL, "Empower", ELM_WIN_DIALOG_BASIC); 29 _gui.win = elm_win_add(NULL, "Empower", ELM_WIN_DIALOG_BASIC);
34 elm_win_title_set(_gui.win, "Empower"); 30 elm_win_title_set(_gui.win, "Empower");
@@ -39,116 +35,73 @@ Eina_Bool gui_init()
39 elm_win_fullscreen_set(_gui.win, 1); 35 elm_win_fullscreen_set(_gui.win, 1);
40 elm_win_keyboard_mode_set(_gui.win, ELM_WIN_KEYBOARD_ON); 36 elm_win_keyboard_mode_set(_gui.win, ELM_WIN_KEYBOARD_ON);
41 37
38 elm_win_screen_size_get(_gui.win, NULL, NULL, &_gui.w, &_gui.h);
39
42 bg = elm_image_add(_gui.win); 40 bg = elm_image_add(_gui.win);
43 snprintf(buf, sizeof(buf), "%s/data/trans.png", PACKAGE_DATA_DIR); 41 snprintf(buf, sizeof(buf), "%s/data/trans.png", PACKAGE_DATA_DIR);
44 elm_image_file_set(bg, buf, NULL); 42 elm_image_file_set(bg, buf, NULL);
45 elm_win_resize_object_add(_gui.win, bg); 43 elm_win_resize_object_add(_gui.win, bg);
46 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
47 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
48 elm_image_fill_outside_set(bg, 1); 44 elm_image_fill_outside_set(bg, 1);
49 evas_object_show(bg); 45 evas_object_show(bg);
50 46
51 grid = elm_gengrid_add(_gui.win); 47 _gui.grid = elm_grid_add(_gui.win);
52 48 elm_grid_size_set(_gui.grid, _gui.w, _gui.h);
53 vbox2 = elm_box_add(_gui.win); 49 elm_win_resize_object_add(_gui.win, _gui.grid);
54 evas_object_size_hint_weight_set(vbox2, 0.5, 0.25); 50 evas_object_show(_gui.grid);
55 evas_object_size_hint_align_set(vbox2, 0.5, 0.5);
56 elm_win_resize_object_add(_gui.win, vbox2);
57 evas_object_show(vbox2);
58
59 _gui.frame = elm_frame_add(_gui.win);
60 evas_object_size_hint_weight_set(_gui.frame, 0.25, 0.25);
61 evas_object_size_hint_align_set(_gui.frame, 0.5, 0.5);
62 elm_box_pack_end(vbox2, _gui.frame);
63 elm_object_text_set(_gui.frame, _("Empower"));
64
65 frame2 = elm_frame_add(_gui.win);
66 evas_object_size_hint_weight_set(frame2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 evas_object_size_hint_align_set(frame2, EVAS_HINT_FILL, EVAS_HINT_FILL);
68 elm_object_style_set(frame2, "pad_medium");
69
70 vbox = elm_box_add(_gui.win);
71 elm_box_horizontal_set(vbox, EINA_FALSE);
72 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73 evas_object_size_hint_align_set(vbox, 0.5, 0.5);
74 elm_box_homogeneous_set(vbox, EINA_TRUE);
75
76 hbox = elm_box_add(_gui.win);
77 elm_box_horizontal_set(hbox, EINA_TRUE);
78 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
79 evas_object_size_hint_align_set(hbox, 0.0, 0.0);
80 51
81 _gui.icon = elm_icon_add(_gui.win); 52 _gui.icon = elm_icon_add(_gui.win);
82 elm_image_file_set(_gui.icon, "", "");
83 elm_image_aspect_fixed_set(_gui.icon, EINA_TRUE); 53 elm_image_aspect_fixed_set(_gui.icon, EINA_TRUE);
84 elm_image_fill_outside_set(_gui.icon, EINA_FALSE); 54 elm_image_fill_outside_set(_gui.icon, EINA_TRUE);
85 evas_object_size_hint_weight_set(_gui.icon, 0.2, EVAS_HINT_EXPAND); 55 evas_object_size_hint_weight_set(_gui.icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86 elm_box_pack_end(hbox, _gui.icon); 56 evas_object_size_hint_align_set(_gui.icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
57 elm_grid_pack(_gui.grid, _gui.icon, (_gui.w/2)-64, (_gui.h/2) - 256, 128, 128);
87 evas_object_show(_gui.icon); 58 evas_object_show(_gui.icon);
88 59
89 _gui.message = elm_label_add(_gui.win); 60 _gui.message = evas_object_text_add(evas_object_evas_get(_gui.win));
90 elm_object_text_set(_gui.message, ""); 61 evas_object_text_font_set(_gui.message, "sans-serif", 18);
91 evas_object_size_hint_weight_set(_gui.message, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 62 evas_object_text_style_set(_gui.message, EVAS_TEXT_STYLE_GLOW);
92 elm_box_pack_end(hbox, _gui.message); 63 evas_object_color_set(_gui.message, 0xff, 0xff, 0xff, 0xff);
64 evas_object_text_glow_color_set(_gui.message, 0x60, 0x60, 0x60, 0xff);
65 elm_grid_pack(_gui.grid, _gui.message, (_gui.w/2), (_gui.h/2) - 120, 0, 0);
93 evas_object_show(_gui.message); 66 evas_object_show(_gui.message);
94 67
95 elm_box_pack_end(vbox, hbox); 68 o = evas_object_text_add(evas_object_evas_get(_gui.win));
96 evas_object_show(hbox); 69 evas_object_text_font_set(o, "sans-serif", 14);
97 70 evas_object_text_style_set(o, EVAS_TEXT_STYLE_GLOW);
98 hbox = elm_box_add(_gui.win); 71 evas_object_color_set(o, 0xff, 0xff, 0xff, 0xff);
99 elm_box_horizontal_set(hbox, EINA_TRUE); 72 evas_object_text_glow_color_set(o, 0x60, 0x60, 0x60, 0xff);
100 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 73 evas_object_text_text_set(o, "Identity");
101 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 74 evas_object_geometry_get(o, NULL, NULL, &w, &h);
102 75 elm_grid_pack(_gui.grid, o, (_gui.w/2) - (w/2), ((_gui.h/2) - h - 24), w, h);
103 label = elm_label_add(_gui.win); 76 evas_object_show(o);
104 elm_object_text_set(label, "User: ");
105 evas_object_size_hint_weight_set(label, 0.0, EVAS_HINT_EXPAND);
106 evas_object_size_hint_align_set(label, 0.0, 0.5);
107 elm_box_pack_end(hbox, label);
108 evas_object_show(label);
109 77
110 _gui.identity = elm_hoversel_add(_gui.win); 78 _gui.identity = elm_hoversel_add(_gui.win);
111 evas_object_size_hint_weight_set(_gui.identity, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 79 evas_object_name_set(_gui.identity, "identity");
112 evas_object_size_hint_align_set(_gui.identity, EVAS_HINT_FILL, EVAS_HINT_FILL); 80 elm_grid_pack(_gui.grid, _gui.identity, (_gui.w/2) - (_gui.w/8), (_gui.h/2) - 16, (_gui.w/4), 32);
113 elm_box_pack_end(hbox, _gui.identity);
114 evas_object_show(_gui.identity); 81 evas_object_show(_gui.identity);
115 82
116 elm_box_pack_end(vbox, hbox); 83 o = evas_object_text_add(evas_object_evas_get(_gui.win));
117 evas_object_show(hbox); 84 evas_object_text_font_set(o, "sans-serif", 14);
118 85 evas_object_text_style_set(o, EVAS_TEXT_STYLE_GLOW);
119 hbox = elm_box_add(_gui.win); 86 evas_object_color_set(o, 0xff, 0xff, 0xff, 0xff);
120 elm_box_horizontal_set(hbox, EINA_TRUE); 87 evas_object_text_glow_color_set(o, 0x60, 0x60, 0x60, 0xff);
121 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 88 evas_object_text_text_set(o, "Password");
122 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 89 evas_object_geometry_get(o, NULL, NULL, &w, &h);
123 90 elm_grid_pack(_gui.grid, o, (_gui.w/2) - (w/2), ((_gui.h/2) + 24), w, h);
124 label = elm_label_add(_gui.win); 91 evas_object_show(o);
125 elm_object_text_set(label, "Password: ");
126 evas_object_size_hint_weight_set(label, 0.0, EVAS_HINT_EXPAND);
127 evas_object_size_hint_align_set(label, 0.0, 0.5);
128 elm_box_pack_end(hbox, label);
129 evas_object_show(label);
130 92
131 _gui.password = elm_entry_add(_gui.win); 93 _gui.password = elm_entry_add(_gui.win);
132 elm_entry_scrollable_set(_gui.password, EINA_TRUE); 94 elm_entry_scrollable_set(_gui.password, EINA_TRUE);
133 evas_object_size_hint_weight_set(_gui.password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134 evas_object_size_hint_align_set(_gui.password, EVAS_HINT_FILL, EVAS_HINT_FILL);
135 evas_object_name_set(_gui.password, "password"); 95 evas_object_name_set(_gui.password, "password");
136 elm_entry_editable_set(_gui.password, EINA_TRUE); 96 elm_entry_editable_set(_gui.password, EINA_TRUE);
137 elm_entry_single_line_set(_gui.password, EINA_TRUE); 97 elm_entry_single_line_set(_gui.password, EINA_TRUE);
138 elm_entry_password_set(_gui.password, EINA_TRUE); 98 elm_entry_password_set(_gui.password, EINA_TRUE);
139 elm_box_pack_end(hbox, _gui.password); 99 elm_entry_input_panel_layout_set(_gui.password, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
100 elm_entry_autocapital_type_set(_gui.password, ELM_AUTOCAPITAL_TYPE_NONE);
101 elm_entry_text_style_user_push(_gui.password, "DEFAULT='font=Sans font_size=20 align=middle valign=baseline linesize=16 color=#ffffff glow_color=#606060 style=glow'");
102 elm_grid_pack(_gui.grid, _gui.password, (_gui.w/2) - (_gui.w/8), (_gui.h/2) + 24 + h, (_gui.w/4), 32);
140 evas_object_show(_gui.password); 103 evas_object_show(_gui.password);
141 104
142 elm_box_pack_end(vbox, hbox);
143 evas_object_show(hbox);
144
145 elm_object_content_set(frame2, vbox);
146 evas_object_show(frame2);
147
148 elm_object_content_set(_gui.frame, frame2);
149 evas_object_show(vbox);
150 evas_object_show(_gui.frame);
151
152 return EINA_TRUE; 105 return EINA_TRUE;
153} 106}
154 107
@@ -156,11 +109,34 @@ void gui_show(Empower_Auth_Info *info)
156{ 109{
157 Eina_List *l; 110 Eina_List *l;
158 Empower_Identity *id; 111 Empower_Identity *id;
112 Efreet_Icon_Theme *theme;
113 const char *icon_path;
114 unsigned int x, y, w, h;
115
116 // Reposition message so it's centered.
117 evas_object_text_text_set(_gui.message, info->message);
118 evas_object_geometry_get(_gui.message, &x, &y, &w, &h);
119 elm_grid_pack_set(_gui.message, (_gui.w/2) - (w/2), (_gui.h/2) - (h/2) - 112, w, h);
159 120
160 elm_object_text_set(_gui.message, info->message); 121 // Clear password field here. Should already be clear, but be sure.
161 elm_icon_standard_set(_gui.icon, info->icon);
162 elm_entry_entry_set(_gui.password, ""); 122 elm_entry_entry_set(_gui.password, "");
163 123
124 // Set icon if it's specified. I've used efreet directly as
125 // elm_icon_standard_set is no good.
126 if (info->icon && info->icon[0])
127 {
128 theme = efreet_icon_theme_find(getenv("E_ICON_THEME"));
129 if (theme)
130 {
131 icon_path = efreet_icon_path_find(theme->name.internal, info->icon, 128);
132
133 if (icon_path)
134 elm_image_file_set(_gui.icon, icon_path, NULL);
135 }
136 }
137
138 // Setup hoversel
139 // TODO: Come up with a face browser of sorts instead of this.
164 elm_hoversel_clear(_gui.identity); 140 elm_hoversel_clear(_gui.identity);
165 _gui.id = NULL; 141 _gui.id = NULL;
166 EINA_LIST_FOREACH(info->identities, l, id) 142 EINA_LIST_FOREACH(info->identities, l, id)
@@ -169,6 +145,8 @@ void gui_show(Empower_Auth_Info *info)
169 { 145 {
170 case EMPOWER_IDENTITY_USER: 146 case EMPOWER_IDENTITY_USER:
171 elm_hoversel_item_add(_gui.identity, id->details.user.name, NULL, 0, _gui_id_change, id); 147 elm_hoversel_item_add(_gui.identity, id->details.user.name, NULL, 0, _gui_id_change, id);
148
149 // If we find the current user in the list then use that as default
172 if (id->details.user.uid == empower_uid) 150 if (id->details.user.uid == empower_uid)
173 { 151 {
174 _gui.id = id; 152 _gui.id = id;
diff --git a/src/bin/main.c b/src/bin/main.c
index 75133d7..fbf7a92 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -54,6 +54,9 @@ int elm_main(int argc, char** argv)
54 ecore_idle_enterer_add(_auth_idler, NULL); 54 ecore_idle_enterer_add(_auth_idler, NULL);
55 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _exit_cb, NULL); 55 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _exit_cb, NULL);
56 56
57 // Allow use of svg icons
58 efreet_icon_extension_add(".svg");
59
57 // Grab UID of the process. This will be used to set 60 // Grab UID of the process. This will be used to set
58 // the default user when the UI is first shown. 61 // the default user when the UI is first shown.
59 empower_uid = getuid(); 62 empower_uid = getuid();