Merge lp:~artem-anufrij/webby-browser/reload-apps-after-added-new-app into lp:webby-browser

Proposed by Artem Anufrij
Status: Merged
Approved by: Erasmo Marín
Approved revision: 14
Merged at revision: 13
Proposed branch: lp:~artem-anufrij/webby-browser/reload-apps-after-added-new-app
Merge into: lp:webby-browser
Diff against target: 207 lines (+66/-39)
4 files modified
src/AppWindow.vala (+35/-18)
src/ApplicationsView.vala (+23/-10)
src/Assistant.vala (+5/-7)
src/DesktopFile.vala (+3/-4)
To merge this branch: bzr merge lp:~artem-anufrij/webby-browser/reload-apps-after-added-new-app
Reviewer Review Type Date Requested Status
Erasmo Marín code & functionality Pending
Review via email: mp+274070@code.launchpad.net

This proposal supersedes a proposal from 2015-10-07.

Commit message

Reload preview after adding a new app.

Description of the change

Reload preview after adding a new app.

To post a comment you must log in.
Revision history for this message
Erasmo Marín (erasmo-marin) wrote : Posted in a previous version of this proposal

This is great, just 2 details:

1) Can you explicitly declare the new attributes as private please?
2) Would be cool if the new added app is selected when you are back to the icon view.

Thanks! :)

review: Needs Fixing (code & functionality)
Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal

1) done
2) done

Revision history for this message
Erasmo Marín (erasmo-marin) wrote :

Thanks, it just need to get the focus now, but I will do that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/AppWindow.vala'
--- src/AppWindow.vala 2015-02-26 20:16:44 +0000
+++ src/AppWindow.vala 2015-10-11 13:36:00 +0000
@@ -1,23 +1,27 @@
1public class AppWindow : Gtk.ApplicationWindow {1public class AppWindow : Gtk.ApplicationWindow {
22
3 private Gtk.Stack stack;
4 private Gtk.HeaderBar headerbar;
5 private Gtk.Button back_button;
6
3 public AppWindow () {7 public AppWindow () {
48
5 set_default_size (700, 500);9 set_default_size (700, 500);
6 set_wmclass("Webby", "Webby");10 set_wmclass("Webby", "Webby");
711
8 //headerbar12 //headerbar
9 var headerbar = new Gtk.HeaderBar ();13 headerbar = new Gtk.HeaderBar ();
10 headerbar.show_close_button = true;14 headerbar.show_close_button = true;
11 headerbar.title = "Webby";15 headerbar.title = "Webby";
12 this.set_titlebar (headerbar);16 this.set_titlebar (headerbar);
1317
14 var back_button = new Gtk.Button.with_label(_("Applications"));18 back_button = new Gtk.Button.with_label(_("Applications"));
15 back_button.get_style_context().add_class("back-button");19 back_button.get_style_context().add_class("back-button");
16 20
17 var apps_view = new ApplicationsView();21 var apps_view = new ApplicationsView();
18 var assistant = new WebbyAssistant();22 var assistant = new WebbyAssistant();
19 var stack = new Gtk.Stack ();23 stack = new Gtk.Stack ();
20 stack.set_transition_duration (500); 24 stack.set_transition_duration (500);
2125
22 stack.add_named (apps_view, "apps_view");26 stack.add_named (apps_view, "apps_view");
23 stack.add_named (assistant, "assistant");27 stack.add_named (assistant, "assistant");
@@ -25,22 +29,35 @@
2529
26 add (stack);30 add (stack);
2731
28 apps_view.add_request.connect( () => {32 apps_view.add_request.connect (() => {
29 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);33 show_assistant ();
30 stack.set_visible_child_name("assistant");34 });
31 headerbar.pack_start (back_button);35
32 back_button.show_all ();36 assistant.application_created.connect ((new_file) => {
33 //fix ugly border at the bottom of headerbar37 show_apps_view ();
34 queue_draw ();38 apps_view.add_button (new_file);
35 });39 apps_view.select_last_item ();
3640 });
37 back_button.clicked.connect ( () => {41
38 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT);42 back_button.clicked.connect (() => {
39 stack.set_visible_child_name("apps_view");43 show_apps_view ();
40 headerbar.remove (back_button);
41 });44 });
4245
43 this.destroy.connect (Gtk.main_quit);46 this.destroy.connect (Gtk.main_quit);
44 }47 }
4548
49 private void show_assistant () {
50 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);
51 stack.set_visible_child_name("assistant");
52 headerbar.pack_start (back_button);
53 back_button.show_all ();
54 //fix ugly border at the bottom of headerbar
55 queue_draw ();
56 }
57
58 private void show_apps_view () {
59 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT);
60 stack.set_visible_child_name("apps_view");
61 headerbar.remove (back_button);
62 }
46}63}
4764
=== modified file 'src/ApplicationsView.vala'
--- src/ApplicationsView.vala 2015-03-23 21:19:58 +0000
+++ src/ApplicationsView.vala 2015-10-11 13:36:00 +0000
@@ -19,6 +19,14 @@
19 icon_view.row_spacing = 15;19 icon_view.row_spacing = 15;
20 icon_view.margin = 15;20 icon_view.margin = 15;
2121
22 load_applications ();
23
24 scrolled.add(icon_view);
25 this.pack_start(scrolled, true, true, 0);
26
27 }
28
29 public void load_applications () {
2230
23 var add_button = new Gtk.Button ();31 var add_button = new Gtk.Button ();
24 var add_image = new Gtk.Image();32 var add_image = new Gtk.Image();
@@ -36,20 +44,25 @@
36 applications = DesktopFile.get_webby_applications();44 applications = DesktopFile.get_webby_applications();
3745
38 foreach (GLib.DesktopAppInfo app in applications.values) {46 foreach (GLib.DesktopAppInfo app in applications.values) {
39 var icon = app.get_icon ().to_string ();47 this.add_button (app);
40 var name = app.get_display_name ();
41 var image = new ApplicationIcon(icon, name);
42 var desktop_file = new DesktopFile.from_desktopappinfo (app);
43 image.delete_request.connect (()=>{
44 desktop_file.delete_file();
45 });
46 icon_view.add (image);
47 }48 }
4849
49 scrolled.add(icon_view);
50 this.pack_start(scrolled, true, true, 0);
51 this.show_all();50 this.show_all();
52 }51 }
52
53 public void add_button (GLib.DesktopAppInfo app) {
54 var image = new ApplicationIcon(app.get_icon ().to_string (), app.get_display_name ());
55 var desktop_file = new DesktopFile.from_desktopappinfo (app);
56 image.delete_request.connect (()=>{
57 desktop_file.delete_file();
58 });
59 icon_view.add (image);
60 icon_view.show_all ();
61 }
62
63 public void select_last_item () {
64 icon_view.select_child (icon_view.get_child_at_index ((int)icon_view.get_children ().length () - 1));
65 }
53}66}
5467
5568
5669
=== modified file 'src/Assistant.vala'
--- src/Assistant.vala 2015-02-27 02:49:54 +0000
+++ src/Assistant.vala 2015-10-11 13:36:00 +0000
@@ -1,5 +1,7 @@
1public class WebbyAssistant : Gtk.Box {1public class WebbyAssistant : Gtk.Box {
22
3 public signal void application_created (GLib.DesktopAppInfo? new_file);
4
3 private Gtk.Label message;5 private Gtk.Label message;
4 private Gtk.Button icon_button;6 private Gtk.Button icon_button;
5 private Gtk.Entry app_name_entry;7 private Gtk.Entry app_name_entry;
@@ -13,7 +15,7 @@
13 private Gtk.Button accept_button;15 private Gtk.Button accept_button;
14 private GLib.Regex protocol_regex;16 private GLib.Regex protocol_regex;
15 private Gee.HashMap<string, GLib.AppInfo> apps;17 private Gee.HashMap<string, GLib.AppInfo> apps;
16 18
17 private string default_app_icon = "application-default-icon";19 private string default_app_icon = "application-default-icon";
1820
19 private bool app_name_valid = false;21 private bool app_name_valid = false;
@@ -70,7 +72,7 @@
70 icon_chooser_button.grab_focus ();72 icon_chooser_button.grab_focus ();
7173
72 icon_selector_popover.add (popover_box);74 icon_selector_popover.add (popover_box);
73 75
74 //TODO: categories76 //TODO: categories
75 //combobox77 //combobox
7678
@@ -265,12 +267,8 @@
265267
266 if (app_icon_valid && app_name_valid && app_url_valid) {268 if (app_icon_valid && app_name_valid && app_url_valid) {
267 var desktop_file = new DesktopFile (name, url, icon);269 var desktop_file = new DesktopFile (name, url, icon);
268 desktop_file.save_to_file ();
269 reset_fields ();270 reset_fields ();
270 print("dialog");271 application_created (desktop_file.save_to_file ());
271 var dialog = new InfoDialog (_("App created"), _("The application shortcut was successfully created"), "dialog-information");
272 dialog.show_all ();
273 dialog.response.connect (()=>{dialog.destroy();});
274 }272 }
275 }273 }
276}274}
277275
=== modified file 'src/DesktopFile.vala'
--- src/DesktopFile.vala 2015-02-26 20:16:44 +0000
+++ src/DesktopFile.vala 2015-10-11 13:36:00 +0000
@@ -41,15 +41,14 @@
41 file = new GLib.KeyFile();41 file = new GLib.KeyFile();
42 file.load_from_file (filename, KeyFileFlags.NONE);42 file.load_from_file (filename, KeyFileFlags.NONE);
43 file.set_string ("Desktop Entry", propertie, val);43 file.set_string ("Desktop Entry", propertie, val);
44 file.save_to_file (filename);44 return file.save_to_file (filename);
45 return true;
46 }45 }
4746
48 public bool save_to_file () {47 public GLib.DesktopAppInfo save_to_file () {
49 string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webby.desktop";48 string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webby.desktop";
50 print("Desktop file created: " + filename);49 print("Desktop file created: " + filename);
51 file.save_to_file (filename);50 file.save_to_file (filename);
52 return true;51 return new GLib.DesktopAppInfo.from_filename (filename);
53 }52 }
5453
55 public bool delete_file () {54 public bool delete_file () {

Subscribers

People subscribed via source and target branches

to all changes: