From 8bb8abb2ab11de7f4592d11fcf04edabc83a2fc0 Mon Sep 17 00:00:00 2001 From: torikul habib Date: Sat, 27 Jul 2019 06:55:33 +0700 Subject: [PATCH] fix --- meson.build | 1 + po/id.po | 4 +- po/nl.po | 4 +- src/Objects/Converter.vala | 20 +++--- src/Widgets/AplicaitonView.vala | 124 ++++++++++++++++++++++++++++++++ src/Window.vala | 2 +- 6 files changed, 140 insertions(+), 15 deletions(-) create mode 100644 src/Widgets/AplicaitonView.vala diff --git a/meson.build b/meson.build index c92eeb5..153be91 100644 --- a/meson.build +++ b/meson.build @@ -34,6 +34,7 @@ code_files = files( 'src/Widgets/Toast.vala', 'src/Widgets/LightDark.vala', 'src/Widgets/Notify.vala', + 'src/Widgets/AplicaitonView.vala', 'src/Widgets/StreamPc.vala', 'src/Objects/Converter.vala', 'src/Objects/Remover.vala', diff --git a/po/id.po b/po/id.po index 841fbaa..3f4b62c 100644 --- a/po/id.po +++ b/po/id.po @@ -135,8 +135,8 @@ msgid "Where you want to save the audio file" msgstr "Dimana kamu ingin menyimpan file suara" #: src/Window.vala:329 -msgid "Choose a video file…" -msgstr "Pilih sebuah berkas vidio" +msgid "Video file…" +msgstr "Berkas vidio" #: src/Window.vala:337 msgid "Select Video" diff --git a/po/nl.po b/po/nl.po index a18fd47..f440f1c 100644 --- a/po/nl.po +++ b/po/nl.po @@ -135,8 +135,8 @@ msgid "Where you want to save the audio file" msgstr "Waar wil je het audiobestand opslaan?" #: src/Window.vala:329 -msgid "Choose a video file…" -msgstr "Kies een videobestand…" +msgid "Video file…" +msgstr "Videobestand…" #: src/Window.vala:337 msgid "Select Video" diff --git a/src/Objects/Converter.vala b/src/Objects/Converter.vala index 66dd8ef..2dab1e6 100644 --- a/src/Objects/Converter.vala +++ b/src/Objects/Converter.vala @@ -22,7 +22,7 @@ using Gtk; using Mindi.Configs; using GLib; -using Granite; + namespace Mindi { public class ObjectConverter : Grid { static ObjectConverter _instance = null; @@ -440,16 +440,16 @@ namespace Mindi { } private void mindi_desktop (int64 badge, double progress) { - Granite.Services.Application.set_progress.begin (progress, (obj, res) => { + Mindi.Services.Application.set_progress.begin (progress, (obj, res) => { try { - Granite.Services.Application.set_progress.end (res); + Mindi.Services.Application.set_progress.end (res); } catch (GLib.Error e) { critical (e.message); } }); - Granite.Services.Application.set_badge.begin (badge, (obj, res) => { + Mindi.Services.Application.set_badge.begin (badge, (obj, res) => { try { - Granite.Services.Application.set_badge.end (res); + Mindi.Services.Application.set_badge.end (res); } catch (GLib.Error e) { critical (e.message); } @@ -461,17 +461,17 @@ namespace Mindi { } public void mindi_desktop_visible () { - timer = Timeout.add (400, () => { - Granite.Services.Application.set_progress_visible.begin (!is_active, (obj, res) => { + timer = Timeout.add (100, () => { + Mindi.Services.Application.set_progress_visible.begin (!is_active, (obj, res) => { try { - Granite.Services.Application.set_progress_visible.end (res); + Mindi.Services.Application.set_progress_visible.end (res); } catch (GLib.Error e) { critical (e.message); } }); - Granite.Services.Application.set_badge_visible.begin (!is_active, (obj, res) => { + Mindi.Services.Application.set_badge_visible.begin (!is_active, (obj, res) => { try { - Granite.Services.Application.set_badge_visible.end (res); + Mindi.Services.Application.set_badge_visible.end (res); } catch (GLib.Error e) { critical (e.message); } diff --git a/src/Widgets/AplicaitonView.vala b/src/Widgets/AplicaitonView.vala new file mode 100644 index 0000000..31b39c6 --- /dev/null +++ b/src/Widgets/AplicaitonView.vala @@ -0,0 +1,124 @@ +/* + * Copyright 2019 elementary, Inc. (https://elementary.io) + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + */ + +[CCode (gir_namespace = "GraniteServices", gir_version = "1.0")] +namespace Mindi.Services { + /** + * Utilities for Applications + */ + namespace Application { + [DBus (name = "com.canonical.Unity.LauncherEntry")] + private class UnityLauncherEntry : GLib.Object { + private static UnityLauncherEntry instance; + internal static async unowned UnityLauncherEntry get_instance () throws GLib.Error { + lock (instance) { + if (instance != null) + return instance; + + weak GLib.Application app = GLib.Application.get_default (); + if (app == null) { + throw new GLib.IOError.FAILED ("No GApplication has been defined"); + } + + if (app.application_id == null) { + throw new GLib.IOError.FAILED ("The GApplication has no application-id defined"); + } + + var local_instance = new UnityLauncherEntry (); + local_instance.app_uri = "application://%s.desktop".printf (app.application_id); + var object_path = new GLib.ObjectPath ("/com/canonical/unity/launcherentry/%u".printf (local_instance.app_uri.hash ())); + try { + var session_connection = yield GLib.Bus.@get (GLib.BusType.SESSION, null); + session_connection.register_object (object_path, local_instance); + instance = local_instance; + } catch (GLib.Error e) { + throw e; + } + } + + return instance; + } + + construct { + properties = new GLib.HashTable (str_hash, str_equal); + properties["urgent"] = new GLib.Variant.boolean (false); + properties["count"] = new GLib.Variant.int64 (0); + properties["count-visible"] = new GLib.Variant.boolean (false); + properties["progress"] = new GLib.Variant.double (0.0); + properties["progress-visible"] = new GLib.Variant.boolean (false); + } + + private string app_uri; + private GLib.HashTable properties; + + internal void set_app_property (string property, GLib.Variant var) { + var updated_properties = new GLib.HashTable (str_hash, str_equal); + updated_properties[property] = var; + properties[property] = var; + update (app_uri, updated_properties); + } + + public signal void update (string app_uri, GLib.HashTable properties); + + public GLib.HashTable query () throws GLib.Error { + return properties; + } + } + + /** + * Set the badge count, usually visible with the dock in the desktop. There is no guarantee + * that the target environment supports it in any way. + * For it to be visible, one has to make sure to call set_badge_visible(). + */ + public static async bool set_badge (int64 count) throws GLib.Error { + unowned UnityLauncherEntry instance = yield UnityLauncherEntry.get_instance (); + instance.set_app_property ("count", new GLib.Variant.int64 (count)); + return false; + } + + /** + * Set the badge visibility. + */ + public static async bool set_badge_visible (bool visible) throws GLib.Error { + unowned UnityLauncherEntry instance = yield UnityLauncherEntry.get_instance (); + instance.set_app_property ("count-visible", new GLib.Variant.boolean (visible)); + return false; + } + + /** + * Set the progress of the application, usually visible with the dock in the desktop. + * There is no guarantee that the target environment supports it in any way. + * For it to be visible, one has to make sure to call set_progress_visible(). + */ + public static async bool set_progress (double progress) throws GLib.Error { + unowned UnityLauncherEntry instance = yield UnityLauncherEntry.get_instance (); + instance.set_app_property ("progress", new GLib.Variant.double (progress)); + return false; + } + + /** + * Set the progress visibility. + */ + public static async bool set_progress_visible (bool visible) throws GLib.Error { + unowned UnityLauncherEntry instance = yield UnityLauncherEntry.get_instance (); + instance.set_app_property ("progress-visible", new GLib.Variant.boolean (visible)); + return false; + } + } +} diff --git a/src/Window.vala b/src/Window.vala index 03c1242..128403f 100755 --- a/src/Window.vala +++ b/src/Window.vala @@ -326,7 +326,7 @@ namespace Mindi { video_icon = new ThemedIcon ("applications-multimedia"); video_container.attach (video_logo, 0, 1, 1, 1); - video_name = new Gtk.Label ("%s".printf (_("Choose a video file…"))); + video_name = new Gtk.Label ("%s".printf (_("Video file…"))); video_name.max_width_chars = 15; video_name.use_markup = true; video_name.ellipsize = Pango.EllipsizeMode.END;