Merge lp:~artem-anufrij/webby-browser/edit-functionality into lp:webby-browser
- edit-functionality
- Merge into trunk
Proposed by
Artem Anufrij
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Erasmo Marín | ||||
Approved revision: | 14 | ||||
Merged at revision: | 14 | ||||
Proposed branch: | lp:~artem-anufrij/webby-browser/edit-functionality | ||||
Merge into: | lp:webby-browser | ||||
Diff against target: |
396 lines (+169/-55) 4 files modified
src/AppWindow.vala (+17/-2) src/ApplicationsView.vala (+114/-48) src/Assistant.vala (+27/-5) src/DesktopFile.vala (+11/-0) |
||||
To merge this branch: | bzr merge lp:~artem-anufrij/webby-browser/edit-functionality | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Erasmo Marín | all | Approve | |
Review via email: mp+274189@code.launchpad.net |
Commit message
edit functionality was implemented
Description of the change
edit functionality was implemented
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/AppWindow.vala' | |||
2 | --- src/AppWindow.vala 2015-10-11 13:32:10 +0000 | |||
3 | +++ src/AppWindow.vala 2015-10-12 21:56:20 +0000 | |||
4 | @@ -4,6 +4,8 @@ | |||
5 | 4 | private Gtk.HeaderBar headerbar; | 4 | private Gtk.HeaderBar headerbar; |
6 | 5 | private Gtk.Button back_button; | 5 | private Gtk.Button back_button; |
7 | 6 | 6 | ||
8 | 7 | private WebbyAssistant assistant; | ||
9 | 8 | |||
10 | 7 | public AppWindow () { | 9 | public AppWindow () { |
11 | 8 | 10 | ||
12 | 9 | set_default_size (700, 500); | 11 | set_default_size (700, 500); |
13 | @@ -19,7 +21,7 @@ | |||
14 | 19 | back_button.get_style_context().add_class("back-button"); | 21 | back_button.get_style_context().add_class("back-button"); |
15 | 20 | 22 | ||
16 | 21 | var apps_view = new ApplicationsView(); | 23 | var apps_view = new ApplicationsView(); |
18 | 22 | var assistant = new WebbyAssistant(); | 24 | assistant = new WebbyAssistant(); |
19 | 23 | stack = new Gtk.Stack (); | 25 | stack = new Gtk.Stack (); |
20 | 24 | stack.set_transition_duration (500); | 26 | stack.set_transition_duration (500); |
21 | 25 | 27 | ||
22 | @@ -33,12 +35,21 @@ | |||
23 | 33 | show_assistant (); | 35 | show_assistant (); |
24 | 34 | }); | 36 | }); |
25 | 35 | 37 | ||
26 | 38 | apps_view.edit_request.connect ((desktop_file) => { | ||
27 | 39 | show_assistant (desktop_file); | ||
28 | 40 | }); | ||
29 | 41 | |||
30 | 36 | assistant.application_created.connect ((new_file) => { | 42 | assistant.application_created.connect ((new_file) => { |
31 | 37 | show_apps_view (); | 43 | show_apps_view (); |
32 | 38 | apps_view.add_button (new_file); | 44 | apps_view.add_button (new_file); |
33 | 39 | apps_view.select_last_item (); | 45 | apps_view.select_last_item (); |
34 | 40 | }); | 46 | }); |
35 | 41 | 47 | ||
36 | 48 | assistant.application_edited.connect ((edited_file) => { | ||
37 | 49 | show_apps_view (); | ||
38 | 50 | apps_view.update_button (edited_file); | ||
39 | 51 | }); | ||
40 | 52 | |||
41 | 42 | back_button.clicked.connect (() => { | 53 | back_button.clicked.connect (() => { |
42 | 43 | show_apps_view (); | 54 | show_apps_view (); |
43 | 44 | }); | 55 | }); |
44 | @@ -46,18 +57,22 @@ | |||
45 | 46 | this.destroy.connect (Gtk.main_quit); | 57 | this.destroy.connect (Gtk.main_quit); |
46 | 47 | } | 58 | } |
47 | 48 | 59 | ||
49 | 49 | private void show_assistant () { | 60 | private void show_assistant (DesktopFile? desktop_file = null) { |
50 | 50 | stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT); | 61 | stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT); |
51 | 51 | stack.set_visible_child_name("assistant"); | 62 | stack.set_visible_child_name("assistant"); |
52 | 52 | headerbar.pack_start (back_button); | 63 | headerbar.pack_start (back_button); |
53 | 53 | back_button.show_all (); | 64 | back_button.show_all (); |
54 | 54 | //fix ugly border at the bottom of headerbar | 65 | //fix ugly border at the bottom of headerbar |
55 | 55 | queue_draw (); | 66 | queue_draw (); |
56 | 67 | |||
57 | 68 | if (desktop_file != null) | ||
58 | 69 | assistant.edit_desktop_file (desktop_file); | ||
59 | 56 | } | 70 | } |
60 | 57 | 71 | ||
61 | 58 | private void show_apps_view () { | 72 | private void show_apps_view () { |
62 | 59 | stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT); | 73 | stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT); |
63 | 60 | stack.set_visible_child_name("apps_view"); | 74 | stack.set_visible_child_name("apps_view"); |
64 | 61 | headerbar.remove (back_button); | 75 | headerbar.remove (back_button); |
65 | 76 | assistant.reset_fields (); | ||
66 | 62 | } | 77 | } |
67 | 63 | } | 78 | } |
68 | 64 | 79 | ||
69 | === modified file 'src/ApplicationsView.vala' | |||
70 | --- src/ApplicationsView.vala 2015-10-11 13:32:10 +0000 | |||
71 | +++ src/ApplicationsView.vala 2015-10-12 21:56:20 +0000 | |||
72 | @@ -1,6 +1,7 @@ | |||
73 | 1 | public class ApplicationsView : Gtk.Box { | 1 | public class ApplicationsView : Gtk.Box { |
74 | 2 | 2 | ||
75 | 3 | public signal void add_request(); | 3 | public signal void add_request(); |
76 | 4 | public signal void edit_request(DesktopFile desktop_file); | ||
77 | 4 | 5 | ||
78 | 5 | private Gtk.FlowBox icon_view; | 6 | private Gtk.FlowBox icon_view; |
79 | 6 | private Gee.HashMap<string, GLib.DesktopAppInfo> applications; | 7 | private Gee.HashMap<string, GLib.DesktopAppInfo> applications; |
80 | @@ -51,10 +52,14 @@ | |||
81 | 51 | } | 52 | } |
82 | 52 | 53 | ||
83 | 53 | public void add_button (GLib.DesktopAppInfo app) { | 54 | public void add_button (GLib.DesktopAppInfo app) { |
88 | 54 | var image = new ApplicationIcon(app.get_icon ().to_string (), app.get_display_name ()); | 55 | var image = new ApplicationIcon (app); |
89 | 55 | var desktop_file = new DesktopFile.from_desktopappinfo (app); | 56 | image.edit_request.connect ((desktop_file) => { |
90 | 56 | image.delete_request.connect (()=>{ | 57 | edit_request (desktop_file); |
91 | 57 | desktop_file.delete_file(); | 58 | icon_view.unselect_all (); |
92 | 59 | }); | ||
93 | 60 | image.deleted.connect ((parent) => { | ||
94 | 61 | this.icon_view.remove (parent); | ||
95 | 62 | this.select_first_item (); | ||
96 | 58 | }); | 63 | }); |
97 | 59 | icon_view.add (image); | 64 | icon_view.add (image); |
98 | 60 | icon_view.show_all (); | 65 | icon_view.show_all (); |
99 | @@ -63,6 +68,24 @@ | |||
100 | 63 | public void select_last_item () { | 68 | public void select_last_item () { |
101 | 64 | icon_view.select_child (icon_view.get_child_at_index ((int)icon_view.get_children ().length () - 1)); | 69 | icon_view.select_child (icon_view.get_child_at_index ((int)icon_view.get_children ().length () - 1)); |
102 | 65 | } | 70 | } |
103 | 71 | |||
104 | 72 | public void select_first_item () { | ||
105 | 73 | icon_view.select_child (icon_view.get_child_at_index (0)); | ||
106 | 74 | } | ||
107 | 75 | |||
108 | 76 | public void update_button (GLib.DesktopAppInfo app) { | ||
109 | 77 | foreach (var item in icon_view.get_children ()) { | ||
110 | 78 | if ((item as Gtk.FlowBoxChild).get_child () is ApplicationIcon) { | ||
111 | 79 | var app_icon = (item as Gtk.FlowBoxChild).get_child () as ApplicationIcon; | ||
112 | 80 | |||
113 | 81 | if (app_icon.desktop_file.name == app.get_display_name ()) { | ||
114 | 82 | app_icon.set_new_desktopfile (new DesktopFile.from_desktopappinfo (app)); | ||
115 | 83 | icon_view.select_child (item as Gtk.FlowBoxChild); | ||
116 | 84 | break; | ||
117 | 85 | } | ||
118 | 86 | } | ||
119 | 87 | } | ||
120 | 88 | } | ||
121 | 66 | } | 89 | } |
122 | 67 | 90 | ||
123 | 68 | 91 | ||
124 | @@ -74,14 +97,63 @@ | |||
125 | 74 | Gtk.Box box; | 97 | Gtk.Box box; |
126 | 75 | Gtk.ActionGroup action_group; | 98 | Gtk.ActionGroup action_group; |
127 | 76 | 99 | ||
131 | 77 | public signal void delete_request (); | 100 | internal DesktopFile desktop_file { get; private set; } |
132 | 78 | 101 | ||
133 | 79 | public ApplicationIcon (string icon, string label_str) { | 102 | public signal void deleted (Gtk.Container? parent); |
134 | 103 | public signal void edit_request (DesktopFile desktop_file); | ||
135 | 104 | |||
136 | 105 | public ApplicationIcon (GLib.DesktopAppInfo app) { | ||
137 | 106 | this.desktop_file = new DesktopFile.from_desktopappinfo (app); | ||
138 | 107 | |||
139 | 80 | hexpand = false; | 108 | hexpand = false; |
140 | 81 | vexpand = false; | 109 | vexpand = false; |
141 | 82 | 110 | ||
144 | 83 | label = new Gtk.Label (label_str); | 111 | label = new Gtk.Label (this.desktop_file.name); |
145 | 84 | 112 | ||
146 | 113 | set_icon (this.desktop_file.icon); | ||
147 | 114 | |||
148 | 115 | this.margin = 6; | ||
149 | 116 | this.margin_start = 20; | ||
150 | 117 | this.margin_end = 20; | ||
151 | 118 | |||
152 | 119 | var menu = new ActionMenu (); | ||
153 | 120 | menu.halign = Gtk.Align.CENTER; | ||
154 | 121 | menu.delete_clicked.connect (() => { remove_application (); }); | ||
155 | 122 | menu.edit_clicked.connect (() => { edit_request (desktop_file); }); | ||
156 | 123 | |||
157 | 124 | box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
158 | 125 | box.pack_start (image, false, false, 0); | ||
159 | 126 | box.pack_start (label, false, false, 0); | ||
160 | 127 | box.pack_start (menu, false, false, 0); | ||
161 | 128 | |||
162 | 129 | box.hexpand = false; | ||
163 | 130 | box.vexpand = false; | ||
164 | 131 | |||
165 | 132 | var event_box = new Gtk.EventBox (); | ||
166 | 133 | event_box.add (box); | ||
167 | 134 | event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK; | ||
168 | 135 | |||
169 | 136 | event_box.enter_notify_event.connect ((event) => { | ||
170 | 137 | menu.set_reveal_child (true); | ||
171 | 138 | return false; | ||
172 | 139 | }); | ||
173 | 140 | |||
174 | 141 | event_box.leave_notify_event.connect ((event) => { | ||
175 | 142 | if (event.detail == Gdk.NotifyType.INFERIOR) | ||
176 | 143 | return false; | ||
177 | 144 | menu.set_reveal_child (false); | ||
178 | 145 | return false; | ||
179 | 146 | }); | ||
180 | 147 | |||
181 | 148 | this.add (event_box); | ||
182 | 149 | } | ||
183 | 150 | |||
184 | 151 | public void set_new_desktopfile (DesktopFile desktop_file) { | ||
185 | 152 | this.desktop_file = desktop_file; | ||
186 | 153 | set_icon (this.desktop_file.icon); | ||
187 | 154 | } | ||
188 | 155 | |||
189 | 156 | private void set_icon (string icon) { | ||
190 | 85 | if (File.new_for_path (icon).query_exists ()) { | 157 | if (File.new_for_path (icon).query_exists ()) { |
191 | 86 | var pix = new Gdk.Pixbuf.from_file (icon); | 158 | var pix = new Gdk.Pixbuf.from_file (icon); |
192 | 87 | 159 | ||
193 | @@ -97,7 +169,11 @@ | |||
194 | 97 | new_height = new_height * pix.height / pix.width; | 169 | new_height = new_height * pix.height / pix.width; |
195 | 98 | margin_vertical = (new_width - new_height) / 2; | 170 | margin_vertical = (new_width - new_height) / 2; |
196 | 99 | } | 171 | } |
198 | 100 | image = new Gtk.Image.from_pixbuf (pix.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR)); | 172 | if (image == null) |
199 | 173 | image = new Gtk.Image.from_pixbuf (pix.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR)); | ||
200 | 174 | else | ||
201 | 175 | image.set_from_pixbuf (pix.scale_simple (new_width, new_height, Gdk.InterpType.BILINEAR)); | ||
202 | 176 | |||
203 | 101 | image.margin_top = margin_vertical; | 177 | image.margin_top = margin_vertical; |
204 | 102 | image.margin_bottom = margin_vertical; | 178 | image.margin_bottom = margin_vertical; |
205 | 103 | image.margin_right = margin_horizontal; | 179 | image.margin_right = margin_horizontal; |
206 | @@ -107,48 +183,38 @@ | |||
207 | 107 | image.icon_name = icon; | 183 | image.icon_name = icon; |
208 | 108 | image.pixel_size = 64; | 184 | image.pixel_size = 64; |
209 | 109 | } | 185 | } |
210 | 110 | |||
211 | 111 | this.margin = 5; | ||
212 | 112 | this.margin_start = 20; | ||
213 | 113 | this.margin_end = 20; | ||
214 | 114 | |||
215 | 115 | box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
216 | 116 | box.pack_start (image, false, false, 0); | ||
217 | 117 | box.pack_start (label, false, false, 0); | ||
218 | 118 | box.hexpand = false; | ||
219 | 119 | box.vexpand = false; | ||
220 | 120 | |||
221 | 121 | conf_btn = new Gtk.MenuButton(); | ||
222 | 122 | conf_btn.valign = Gtk.Align.START; | ||
223 | 123 | conf_btn.halign = Gtk.Align.END; | ||
224 | 124 | conf_btn.get_style_context ().remove_class ("button"); | ||
225 | 125 | conf_btn.get_style_context ().add_class ("titlebutton"); | ||
226 | 126 | conf_btn.set_image (new Gtk.Image.from_icon_name("document-properties", Gtk.IconSize.MENU)); | ||
227 | 127 | |||
228 | 128 | build_menu (); | ||
229 | 129 | |||
230 | 130 | this.add (box); | ||
231 | 131 | this.add_overlay (conf_btn); | ||
232 | 132 | } | 186 | } |
233 | 133 | 187 | ||
234 | 134 | private void remove_application () { | 188 | private void remove_application () { |
237 | 135 | delete_request (); | 189 | desktop_file.delete_file (); |
238 | 136 | this.get_parent().get_parent().remove(this.get_parent()); | 190 | deleted (this.get_parent()); |
239 | 137 | this.destroy (); | 191 | this.destroy (); |
240 | 138 | } | 192 | } |
255 | 139 | 193 | } | |
256 | 140 | private void build_menu () { | 194 | |
257 | 141 | 195 | public class ActionMenu : Gtk.Revealer { | |
258 | 142 | Gtk.Menu menu = new Gtk.Menu (); | 196 | |
259 | 143 | 197 | public signal void delete_clicked (); | |
260 | 144 | Gtk.MenuItem remove_app = new Gtk.MenuItem.with_label (_("Remove Application")); | 198 | public signal void edit_clicked (); |
261 | 145 | menu.add (remove_app); | 199 | |
262 | 146 | 200 | public ActionMenu () { | |
263 | 147 | remove_app.activate.connect( () => { | 201 | var delete_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.BUTTON); |
264 | 148 | remove_application (); | 202 | delete_button.tooltip_text = _("Delete Webapp"); |
265 | 149 | }); | 203 | delete_button.relief = Gtk.ReliefStyle.NONE; |
266 | 150 | 204 | delete_button.clicked.connect (() => { delete_clicked (); }); | |
267 | 151 | menu.show_all(); | 205 | |
268 | 152 | conf_btn.set_popup (menu); | 206 | var edit_button = new Gtk.Button.from_icon_name ("edit-symbolic", Gtk.IconSize.BUTTON); |
269 | 207 | edit_button.tooltip_text = _("Edit Webapp Properties"); | ||
270 | 208 | edit_button.relief = Gtk.ReliefStyle.NONE; | ||
271 | 209 | edit_button.clicked.connect (() => { edit_clicked (); }); | ||
272 | 210 | |||
273 | 211 | var buttons = new Gtk.Grid (); | ||
274 | 212 | buttons.orientation = Gtk.Orientation.HORIZONTAL; | ||
275 | 213 | buttons.add (edit_button); | ||
276 | 214 | buttons.add (delete_button); | ||
277 | 215 | buttons.opacity = 0.5; | ||
278 | 216 | |||
279 | 217 | this.transition_type = Gtk.RevealerTransitionType.CROSSFADE; | ||
280 | 218 | this.add (buttons); | ||
281 | 153 | } | 219 | } |
282 | 154 | } | 220 | } |
283 | 155 | 221 | ||
284 | === modified file 'src/Assistant.vala' | |||
285 | --- src/Assistant.vala 2015-10-07 20:47:50 +0000 | |||
286 | +++ src/Assistant.vala 2015-10-12 21:56:20 +0000 | |||
287 | @@ -1,6 +1,9 @@ | |||
288 | 1 | public class WebbyAssistant : Gtk.Box { | 1 | public class WebbyAssistant : Gtk.Box { |
289 | 2 | 2 | ||
290 | 3 | public enum assistant_mode { new_app, edit_app } | ||
291 | 4 | |||
292 | 3 | public signal void application_created (GLib.DesktopAppInfo? new_file); | 5 | public signal void application_created (GLib.DesktopAppInfo? new_file); |
293 | 6 | public signal void application_edited (GLib.DesktopAppInfo? new_file); | ||
294 | 4 | 7 | ||
295 | 5 | private Gtk.Label message; | 8 | private Gtk.Label message; |
296 | 6 | private Gtk.Button icon_button; | 9 | private Gtk.Button icon_button; |
297 | @@ -22,6 +25,8 @@ | |||
298 | 22 | private bool app_url_valid = false; | 25 | private bool app_url_valid = false; |
299 | 23 | private bool app_icon_valid = true; | 26 | private bool app_icon_valid = true; |
300 | 24 | 27 | ||
301 | 28 | private assistant_mode mode { get; set; default = assistant_mode.new_app; } | ||
302 | 29 | |||
303 | 25 | public WebbyAssistant () { | 30 | public WebbyAssistant () { |
304 | 26 | 31 | ||
305 | 27 | GLib.Object (orientation: Gtk.Orientation.VERTICAL); | 32 | GLib.Object (orientation: Gtk.Orientation.VERTICAL); |
306 | @@ -102,7 +107,7 @@ | |||
307 | 102 | 107 | ||
308 | 103 | 108 | ||
309 | 104 | //create button | 109 | //create button |
311 | 105 | accept_button = new Gtk.Button.with_label(_("Create app")); | 110 | accept_button = new Gtk.Button.with_label(_("Save app")); |
312 | 106 | accept_button.halign = Gtk.Align.END; | 111 | accept_button.halign = Gtk.Align.END; |
313 | 107 | accept_button.get_style_context ().add_class ("suggested-action"); | 112 | accept_button.get_style_context ().add_class ("suggested-action"); |
314 | 108 | accept_button.set_sensitive (false); | 113 | accept_button.set_sensitive (false); |
315 | @@ -134,7 +139,7 @@ | |||
316 | 134 | }); | 139 | }); |
317 | 135 | 140 | ||
318 | 136 | app_name_entry.changed.connect (()=>{ | 141 | app_name_entry.changed.connect (()=>{ |
320 | 137 | if (DesktopFile.get_applications().has_key (app_name_entry.get_text()) ) { | 142 | if (mode == assistant_mode.new_app && DesktopFile.get_applications().has_key (app_name_entry.get_text()) ) { |
321 | 138 | app_name_entry.get_style_context ().add_class ("error"); | 143 | app_name_entry.get_style_context ().add_class ("error"); |
322 | 139 | app_name_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "dialog-information"); | 144 | app_name_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "dialog-information"); |
323 | 140 | app_name_entry.set_icon_tooltip_text (Gtk.EntryIconPosition.SECONDARY, _("App already exist")); | 145 | app_name_entry.set_icon_tooltip_text (Gtk.EntryIconPosition.SECONDARY, _("App already exist")); |
324 | @@ -247,13 +252,15 @@ | |||
325 | 247 | } | 252 | } |
326 | 248 | 253 | ||
327 | 249 | 254 | ||
329 | 250 | private void reset_fields () { | 255 | public void reset_fields () { |
330 | 251 | icon_name_entry.set_text (""); | 256 | icon_name_entry.set_text (""); |
331 | 252 | app_name_entry.set_text (""); | 257 | app_name_entry.set_text (""); |
332 | 258 | app_name_entry.set_sensitive (true); | ||
333 | 253 | app_url_entry.set_text (""); | 259 | app_url_entry.set_text (""); |
334 | 254 | app_name_entry.get_style_context ().remove_class ("error"); | 260 | app_name_entry.get_style_context ().remove_class ("error"); |
335 | 255 | app_url_entry.get_style_context ().remove_class ("error"); | 261 | app_url_entry.get_style_context ().remove_class ("error"); |
336 | 256 | icon_button.set_image (new Gtk.Image.from_icon_name (default_app_icon, Gtk.IconSize.DIALOG) ); | 262 | icon_button.set_image (new Gtk.Image.from_icon_name (default_app_icon, Gtk.IconSize.DIALOG) ); |
337 | 263 | mode = assistant_mode.new_app; | ||
338 | 257 | } | 264 | } |
339 | 258 | 265 | ||
340 | 259 | private void on_accept () { | 266 | private void on_accept () { |
341 | @@ -267,8 +274,23 @@ | |||
342 | 267 | 274 | ||
343 | 268 | if (app_icon_valid && app_name_valid && app_url_valid) { | 275 | if (app_icon_valid && app_name_valid && app_url_valid) { |
344 | 269 | var desktop_file = new DesktopFile (name, url, icon); | 276 | var desktop_file = new DesktopFile (name, url, icon); |
347 | 270 | reset_fields (); | 277 | switch (mode) { |
348 | 271 | application_created (desktop_file.save_to_file ()); | 278 | case assistant_mode.new_app: |
349 | 279 | application_created (desktop_file.save_to_file ()); | ||
350 | 280 | break; | ||
351 | 281 | case assistant_mode.edit_app: | ||
352 | 282 | application_edited (desktop_file.save_to_file ()); | ||
353 | 283 | break; | ||
354 | 284 | } | ||
355 | 272 | } | 285 | } |
356 | 273 | } | 286 | } |
357 | 287 | |||
358 | 288 | public void edit_desktop_file (DesktopFile desktop_file) { | ||
359 | 289 | mode = assistant_mode.edit_app; | ||
360 | 290 | app_name_entry.text = desktop_file.name; | ||
361 | 291 | app_name_entry.set_sensitive (false); | ||
362 | 292 | app_url_entry.text = desktop_file.url; | ||
363 | 293 | icon_name_entry.text = desktop_file.icon; | ||
364 | 294 | update_app_icon (); | ||
365 | 295 | } | ||
366 | 274 | } | 296 | } |
367 | 275 | 297 | ||
368 | === modified file 'src/DesktopFile.vala' | |||
369 | --- src/DesktopFile.vala 2015-10-07 20:47:50 +0000 | |||
370 | +++ src/DesktopFile.vala 2015-10-12 21:56:20 +0000 | |||
371 | @@ -19,7 +19,15 @@ | |||
372 | 19 | 19 | ||
373 | 20 | private GLib.KeyFile file; | 20 | private GLib.KeyFile file; |
374 | 21 | 21 | ||
375 | 22 | public string name { get; private set; } | ||
376 | 23 | public string url { get; private set; } | ||
377 | 24 | public string icon { get; private set; } | ||
378 | 25 | |||
379 | 22 | public DesktopFile (string name, string url, string icon) { | 26 | public DesktopFile (string name, string url, string icon) { |
380 | 27 | this.name = name; | ||
381 | 28 | this.url = url; | ||
382 | 29 | this.icon = icon; | ||
383 | 30 | |||
384 | 23 | file = new GLib.KeyFile(); | 31 | file = new GLib.KeyFile(); |
385 | 24 | file.load_from_data (template, -1, GLib.KeyFileFlags.NONE); | 32 | file.load_from_data (template, -1, GLib.KeyFileFlags.NONE); |
386 | 25 | //TODO: Category | 33 | //TODO: Category |
387 | @@ -34,6 +42,9 @@ | |||
388 | 34 | public DesktopFile.from_desktopappinfo(GLib.DesktopAppInfo info) { | 42 | public DesktopFile.from_desktopappinfo(GLib.DesktopAppInfo info) { |
389 | 35 | file = new GLib.KeyFile(); | 43 | file = new GLib.KeyFile(); |
390 | 36 | file.load_from_file (info.filename, KeyFileFlags.NONE); | 44 | file.load_from_file (info.filename, KeyFileFlags.NONE); |
391 | 45 | this.name = info.get_display_name (); | ||
392 | 46 | this.icon = info.get_icon ().to_string (); | ||
393 | 47 | this.url = file.get_string ("Desktop Entry", "Exec").substring (6); | ||
394 | 37 | } | 48 | } |
395 | 38 | 49 | ||
396 | 39 | public bool edit_propertie (string propertie, string val) { | 50 | public bool edit_propertie (string propertie, string val) { |
I like your approach with enum