add pin button for webapps

This commit is contained in:
Artem Anufrij 2017-09-03 19:16:39 +02:00
parent a1157abcef
commit eac57a1711
3 changed files with 14 additions and 8 deletions

View file

@ -50,7 +50,6 @@ namespace Webpin {
public string name { get; private set; }
public string url { get; private set; }
public string icon { get; private set; }
public bool stay_open { get; private set; }
public bool hide_on_close {
get {
this.file = new GLib.KeyFile();
@ -68,7 +67,6 @@ namespace Webpin {
this.name = name;
this.url = url.replace ("%", "%%");
this.icon = icon;
this.stay_open = stay_open;
file = new GLib.KeyFile();
try {
@ -98,7 +96,6 @@ namespace Webpin {
this.icon = info.get_icon ().to_string ();
try {
this.url = file.get_string ("Desktop Entry", "Exec").substring (31);
this.stay_open = file.get_string ("Desktop Entry", "WebpinStayOpen") == "true";
} catch (Error e) {
warning (e.message);
}

View file

@ -55,6 +55,15 @@ namespace Webpin {
spinner.set_size_request (16, 16);
headerbar.pack_end (spinner);
var stay_open = new Gtk.ToggleButton ();
stay_open.active = desktop_file.hide_on_close;
stay_open.toggled.connect (() => {
desktop_file.edit_propertie ("WebpinStayOpen", stay_open.active.to_string ());
desktop_file.save_to_file ();
});
stay_open.image = new Gtk.Image.from_icon_name ("view-pin-symbolic", Gtk.IconSize.MENU);
headerbar.pack_start (stay_open);
//style
if (web_app.ui_color != "none") {
try {
@ -63,7 +72,7 @@ namespace Webpin {
var style_provider = new Gtk.CssProvider ();
style_provider.load_from_data (style_cp, -1);
headerbar.get_style_context ().add_provider (style_provider, -1);
Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", should_use_dark_theme (web_app.ui_color));
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = should_use_dark_theme (web_app.ui_color);
} catch (GLib.Error err) {
warning("Loading style failed");
}
@ -76,7 +85,7 @@ namespace Webpin {
var style_provider = new Gtk.CssProvider ();
style_provider.load_from_data (style_cp, -1);
headerbar.get_style_context ().add_provider (style_provider, -1);
Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", should_use_dark_theme (color));
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = should_use_dark_theme (color);
} catch (GLib.Error err) {
warning("Loading style failed");
}
@ -106,7 +115,7 @@ namespace Webpin {
this.delete_event.connect (() => {
update_window_state(this.get_allocated_width (), this.get_allocated_height (), this.is_maximized);
if (desktop_file.hide_on_close) {
this.hide ();
this.hide_on_delete ();
}
return desktop_file.hide_on_close;
});

View file

@ -326,7 +326,7 @@ namespace Webpin {
app_name_entry.set_sensitive (false);
app_url_entry.text = desktop_file.url.replace ("%%", "%");
icon_name_entry.text = desktop_file.icon;
stay_open_when_closed.active = desktop_file.stay_open;
stay_open_when_closed.active = desktop_file.hide_on_close;
update_app_icon ();
}
}