open webapp by clicking desktop notification
This commit is contained in:
parent
7c41b22881
commit
0acf8f77ba
4 changed files with 24 additions and 12 deletions
|
@ -48,6 +48,15 @@ namespace Webpin {
|
|||
app_launcher = application_id + ".desktop";
|
||||
flags |= GLib.ApplicationFlags.HANDLES_OPEN;
|
||||
app_list = new GLib.List<WebWindow> ();
|
||||
|
||||
var open_web_app = new SimpleAction ("open-web-app", GLib.VariantType.STRING);
|
||||
add_action (open_web_app);
|
||||
open_web_app.activate.connect ((parameter) => {
|
||||
if (parameter != null) {
|
||||
debug ("start web app over action: '%s'", parameter.get_string ());
|
||||
start_webapp (parameter.get_string ());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Gtk.Window mainwindow;
|
||||
|
@ -64,24 +73,27 @@ namespace Webpin {
|
|||
}
|
||||
|
||||
public override void open (File[] files, string hint) {
|
||||
debug (files [0].get_uri ());
|
||||
debug ("%s", files [0].get_uri ());
|
||||
start_webapp (files [0].get_uri ());
|
||||
}
|
||||
|
||||
public void start_webapp (string url) {
|
||||
foreach (var item in app_list) {
|
||||
debug ("running webapp: %s", item.desktop_file.url);
|
||||
if (item.desktop_file.url == url) {
|
||||
debug ("open runing app: %s", url);
|
||||
item.present ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
debug ("create a new web app: %s", url);
|
||||
var app_info = Webpin.DesktopFile.get_app_by_url (url);
|
||||
var desktop_file = new Webpin.DesktopFile.from_desktopappinfo(app_info);
|
||||
var app = new WebWindow(desktop_file);
|
||||
var app = new WebWindow (desktop_file);
|
||||
app_list.append (app);
|
||||
app.destroy.connect (() => { app_list.remove (app); });
|
||||
app.set_application (this);
|
||||
app_list.append (app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,10 +180,13 @@ namespace Webpin {
|
|||
|
||||
var desktop_app = new GLib.DesktopAppInfo(app.get_id ());
|
||||
|
||||
var exec = desktop_app.get_string ("Exec").replace ("%%", "%");
|
||||
var exec = desktop_app.get_string ("Exec");
|
||||
|
||||
if (exec != null && exec.contains (url)) {
|
||||
return desktop_app;
|
||||
if (exec != null) {
|
||||
exec = exec.replace ("%%", "%");
|
||||
if (exec.contains (url)) {
|
||||
return desktop_app;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -37,7 +37,6 @@ namespace Webpin {
|
|||
Gtk.Spinner spinner;
|
||||
|
||||
public DesktopFile desktop_file { get; private set; }
|
||||
private Notification desktop_notification;
|
||||
|
||||
public WebWindow (DesktopFile desktop_file) {
|
||||
this.desktop_file = desktop_file;
|
||||
|
@ -46,8 +45,6 @@ namespace Webpin {
|
|||
set_wmclass (desktop_file.url, desktop_file.url);
|
||||
web_app = new WebApp (desktop_file.url);
|
||||
|
||||
desktop_notification = new Notification ("");
|
||||
|
||||
var headerbar = new Gtk.HeaderBar ();
|
||||
headerbar.title = desktop_file.name;
|
||||
headerbar.show_close_button = true;
|
||||
|
@ -105,9 +102,10 @@ namespace Webpin {
|
|||
});
|
||||
|
||||
web_app.desktop_notification.connect ((title, body, icon) => {
|
||||
desktop_notification.set_title (title);
|
||||
var desktop_notification = new Notification (title);
|
||||
desktop_notification.set_body (body);
|
||||
desktop_notification.set_icon (icon);
|
||||
desktop_notification.add_button_with_target_value (_("Open %s").printf (desktop_file.name), "app.open-web-app", new GLib.Variant.string (desktop_file.url));
|
||||
WebpinApp.instance.send_notification (null, desktop_notification);
|
||||
});
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@ namespace Webpin {
|
|||
try {
|
||||
icon = new Gtk.Image.from_pixbuf (new Gdk.Pixbuf.from_file_at_scale (file.icon, 48, 48, true));
|
||||
icon_for_notification = GLib.Icon.new_for_string (file.icon);
|
||||
|
||||
} catch (Error e) {
|
||||
warning (e.message);
|
||||
icon = new Gtk.Image.from_icon_name ("artemanufrij.webpin", Gtk.IconSize.DIALOG);
|
||||
|
|
Loading…
Reference in a new issue