From e2873cbdddc0d25af3df7b4616c611801a21dff9 Mon Sep 17 00:00:00 2001 From: Murilo Venturoso Date: Sat, 22 Aug 2020 10:50:52 -0300 Subject: [PATCH] Replace libunit with granite when displaying badges. Close #100 --- README.md | 1 - debian/control | 1 - meson.build | 6 +---- meson_options.txt | 1 - snapcraft.yaml | 3 +-- src/MainWindow.vala | 43 ++++++++++++++++++++++++++++++++++++ src/Widgets/TerminalBox.vala | 17 ++++---------- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 235a9f8e..37333906 100755 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ If you want to hack on and build EasySSH yourself, you'll need the following dep * libgranite-dev * libvte-2.91-dev * libjson-glib-dev -* libunity-dev * meson * valac * gpg diff --git a/debian/control b/debian/control index 0c9693d4..6e5f7777 100755 --- a/debian/control +++ b/debian/control @@ -11,7 +11,6 @@ Build-Depends: cmake (>= 2.8), libvte-2.91-dev, libgranite-dev, libgee-0.8-dev, - libunity-dev, gpg Standards-Version: 3.9.3 diff --git a/meson.build b/meson.build index 96496425..da1bca7b 100755 --- a/meson.build +++ b/meson.build @@ -26,11 +26,7 @@ dependencies = [ dependency('gee-0.8'), meson.get_compiler('c').find_library('m', required : false) ] -if get_option('libunity') - unity_dep = dependency('unity') - add_project_arguments('--define=UNITY_SUPPORT=1', language : 'vala') - dependencies += unity_dep -endif + if with_gpg gpg = find_program('gpg', 'gpg2', required: true) diff --git a/meson_options.txt b/meson_options.txt index 53643f63..0995c745 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,2 @@ -option ('libunity', type : 'boolean', value : true) option ('ubuntu-bionic-patched-vte', type : 'boolean', value : true) option ('with-gpg', type : 'boolean', value : true) \ No newline at end of file diff --git a/snapcraft.yaml b/snapcraft.yaml index d6ad88d7..e667660d 100755 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -16,7 +16,7 @@ apps: easyssh: command: desktop-launch $SNAP/usr/bin/com.github.muriloventuroso.easyssh desktop: usr/share/applications/com.github.muriloventuroso.easyssh.desktop - plugs: [network, home, x11, unity7, gsettings, locale-control] + plugs: [network, home, x11, gsettings, locale-control] slots: [ dbus-easyssh ] plugs: @@ -53,7 +53,6 @@ parts: - debhelper - libgtk-3-dev - libjson-glib-dev - - libunity-dev stage-packages: - gobject-introspection - libgee-0.8-2 diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 568ff5ed..50edba1b 100755 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -33,6 +33,7 @@ namespace EasySSH { public HeaderBar header; private bool is_fullscreen = false; public Gtk.Application application { get; construct; } + public int64 count_badge = 0; public const string ACTION_PREFIX = "win."; public const string ACTION_CLOSE_TAB = "action-close-tab"; @@ -375,6 +376,48 @@ namespace EasySSH { main_actions.get_action ("Paste").set_sensitive (can_paste); } + + public void add_badge(){ + count_badge += 1; + Granite.Services.Application.set_badge_visible.begin (true, (obj, res) => { + try { + Granite.Services.Application.set_badge_visible.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + Granite.Services.Application.set_badge.begin (count_badge, (obj, res) => { + try { + Granite.Services.Application.set_badge.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + } + public void remove_badge(){ + if(count_badge <= 0){ + return; + } + count_badge -= 1; + Granite.Services.Application.set_badge.begin (count_badge, (obj, res) => { + try { + Granite.Services.Application.set_badge.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + + if(count_badge == 0){ + Granite.Services.Application.set_badge_visible.begin (false, (obj, res) => { + try { + Granite.Services.Application.set_badge_visible.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + } + + } public void action_edit_conn (string name) { sourcelist.edit_conn(name); } diff --git a/src/Widgets/TerminalBox.vala b/src/Widgets/TerminalBox.vala index 2c504996..a69057a9 100755 --- a/src/Widgets/TerminalBox.vala +++ b/src/Widgets/TerminalBox.vala @@ -109,25 +109,16 @@ namespace EasySSH { } public void add_badge (){ - #if UNITY_SUPPORT - var entry = Unity.LauncherEntry.get_for_desktop_id ("com.github.muriloventuroso.easyssh.desktop"); - entry.count_visible = true; - entry.count = entry.count + 1; - #endif + window.add_badge(); unread_changes = true; dataHost.item.icon = new GLib.ThemedIcon ("mail-mark-important"); tab.icon = new GLib.ThemedIcon ("mail-mark-important"); } public void remove_badge (){ - #if UNITY_SUPPORT - var entry = Unity.LauncherEntry.get_for_desktop_id ("com.github.muriloventuroso.easyssh.desktop"); - if(entry.count_visible == true){ - entry.count = entry.count - 1; - if(entry.count == 0){ - entry.count_visible = false; - } + if(unread_changes){ + window.remove_badge(); } - #endif + unread_changes = false; dataHost.item.icon = null; tab.icon = null;