[connections/indicate-active-connections-with-thumbnail] thumbnail: Indicate active connection by showing the thumbnail
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [connections/indicate-active-connections-with-thumbnail] thumbnail: Indicate active connection by showing the thumbnail
- Date: Thu, 29 Jul 2021 14:05:57 +0000 (UTC)
commit 3ee04f040851ba9a396efb970d3d51038a1240e6
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Jul 29 15:52:19 2021 +0200
thumbnail: Indicate active connection by showing the thumbnail
When a connection is open we present a thumbnail of it, updated
every 3 seconds.
When a connection is closed we set an icon as thumbnail.
Fixes #55
src/collection-view-child.vala | 35 ++++++++++++---------
src/connection.vala | 5 ---
src/meson.build | 1 -
src/thumbnailer.vala | 71 ------------------------------------------
4 files changed, 21 insertions(+), 91 deletions(-)
---
diff --git a/src/collection-view-child.vala b/src/collection-view-child.vala
index 1df4dfa..0467e38 100644
--- a/src/collection-view-child.vala
+++ b/src/collection-view-child.vala
@@ -30,33 +30,40 @@ namespace Connections {
[GtkChild]
public unowned Gtk.Image thumbnail;
+ private uint thumbnail_id = 0;
+
public CollectionViewChild (Connection connection) {
this.connection = connection;
update_display_name ();
connection.notify["display-name"].connect (update_display_name);
- connection.thumbnailer.update.connect (() => {
- thumbnail.set_from_pixbuf (connection.thumbnail.scale_simple (180, 134,
Gdk.InterpType.BILINEAR));
- });
-
- update_thumbnail.begin ();
+ connection.show.connect (update_thumbnail);
}
private void update_display_name () {
connection_name.set_text (connection.get_visible_name ());
}
- private async void update_thumbnail () {
- var file = GLib.File.new_for_path (connection.thumbnailer.thumbnail_path);
- if (file.query_exists ()) {
- try {
- var pixbuf = new Gdk.Pixbuf.from_file_at_scale (file.get_path (), 180, 134, true);
- thumbnail.set_from_pixbuf (pixbuf);
- } catch (GLib.Error error) {
- debug ("Failed to update thumbnail: %s", error.message);
+ private void update_thumbnail () {
+ thumbnail_id = Timeout.add_seconds (3, () => {
+ if (!connection.connected) {
+ thumbnail_id = 0;
+ thumbnail.set_from_icon_name ("org.gnome.Connections-symbolic",
+ Gtk.IconSize.LARGE_TOOLBAR);
+ return false;
}
- }
+
+ thumbnail.set_from_pixbuf (connection.thumbnail.scale_simple (180, 134,
+ Gdk.InterpType.BILINEAR));
+
+ return true;
+ });
+ }
+
+ ~CollectionViewChild () {
+ if (thumbnail_id != 0)
+ Source.remove (thumbnail_id);
}
}
}
diff --git a/src/connection.vala b/src/connection.vala
index 53c63b8..7248cd4 100644
--- a/src/connection.vala
+++ b/src/connection.vala
@@ -51,7 +51,6 @@ namespace Connections {
public abstract void send_keys (uint[] keys);
- public Thumbnailer thumbnailer;
public abstract Gdk.Pixbuf? thumbnail { set; owned get; }
public async void take_screenshot () {
@@ -150,10 +149,6 @@ namespace Connections {
}
construct {
- thumbnailer = new Connections.Thumbnailer (this);
-
- show.connect (() => { thumbnailer.update_thumbnail (); });
-
notify.connect (save);
}
diff --git a/src/meson.build b/src/meson.build
index bee8184..de1100b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -15,7 +15,6 @@ connections_sources = [
'preferences-widgets.vala',
'rdp-connection.vala',
'rdp-preferences-window.vala',
- 'thumbnailer.vala',
'topbar.vala',
'vnc-connection.vala',
'vnc-preferences-window.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]