Replace libunit with granite when displaying badges. Close #100

This commit is contained in:
Murilo Venturoso 2020-08-22 10:50:52 -03:00
parent d43a52d760
commit e2873cbddd
7 changed files with 49 additions and 23 deletions

View File

@ -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

1
debian/control vendored
View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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);
}

View File

@ -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;