Skip to content

Commit

Permalink
Replace libunit with granite when displaying badges. Close #100
Browse files Browse the repository at this point in the history
  • Loading branch information
muriloventuroso committed Aug 22, 2020
1 parent d43a52d commit e2873cb
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion debian/control
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions meson.build
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion 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)
3 changes: 1 addition & 2 deletions snapcraft.yaml
Expand Up @@ -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:
Expand Down Expand Up @@ -53,7 +53,6 @@ parts:
- debhelper
- libgtk-3-dev
- libjson-glib-dev
- libunity-dev
stage-packages:
- gobject-introspection
- libgee-0.8-2
Expand Down
43 changes: 43 additions & 0 deletions src/MainWindow.vala
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
17 changes: 4 additions & 13 deletions src/Widgets/TerminalBox.vala
Expand Up @@ -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;
Expand Down

0 comments on commit e2873cb

Please sign in to comment.