Skip to content

Commit b326092

Browse files
committed
remove Session.vala
session storage while using the org.freedesktop.Notifications interface is flawed and broken. notifications can't be closed by apps and actions cannot be activated after the application exits or there's a system reset. so remove the between session capabilities from the indicator. Signed-off-by: Gustavo Marques <pushstarttocontinue@outlook.com>
1 parent fa7956c commit b326092

7 files changed

Lines changed: 5 additions & 231 deletions

File tree

meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ shared_module(
4545
'src/Widgets/AppEntry.vala',
4646
'src/Services/NotificationsMonitor.vala',
4747
'src/Services/Notification.vala',
48-
'src/Services/Session.vala',
4948
'src/Services/Interfaces.vala',
5049
gresource,
5150
config_vala,

po/POTFILES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ src/Widgets/NotificationEntry.vala
44
src/Widgets/AppEntry.vala
55
src/Services/NotificationsMonitor.vala
66
src/Services/Notification.vala
7-
src/Services/Session.vala
87
src/Services/Interfaces.vala

src/Indicator.vala

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class Notifications.Indicator : Wingpanel.Indicator {
2727
private Gtk.ModelButton clear_all_btn;
2828
private Gtk.Spinner? dynamic_icon = null;
2929
private NotificationsList nlist;
30-
private List<Notification> previous_session = null;
3130

3231
public Indicator () {
3332
Object (
@@ -77,27 +76,14 @@ public class Notifications.Indicator : Wingpanel.Indicator {
7776
return Gdk.EVENT_PROPAGATE;
7877
});
7978

80-
previous_session = Session.get_instance ().get_session_notifications ();
81-
Timeout.add (2000, () => { // Do not block animated drawing of wingpanel
82-
load_session_notifications.begin (() => { // load asynchromously so spinner continues to rotate
83-
set_display_icon_name ();
84-
nlist.add.connect (set_display_icon_name);
85-
nlist.remove.connect (set_display_icon_name);
86-
});
87-
88-
return Source.REMOVE;
89-
});
79+
set_display_icon_name ();
80+
nlist.add.connect (set_display_icon_name);
81+
nlist.remove.connect (set_display_icon_name);
9082
}
9183

9284
return dynamic_icon;
9385
}
9486

95-
private async void load_session_notifications () {
96-
foreach (var notification in previous_session) {
97-
yield nlist.add_entry (notification, false); // This is slow as NotificationEntry is complex
98-
}
99-
}
100-
10187
public override Gtk.Widget? get_widget () {
10288
if (main_box == null) {
10389
var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb"));
@@ -177,7 +163,7 @@ public class Notifications.Indicator : Wingpanel.Indicator {
177163
}
178164

179165
if (app_settings == null || app_settings.get_boolean (REMEMBER_KEY)) {
180-
nlist.add_entry.begin (notification, true);
166+
nlist.add_entry (notification);
181167
}
182168

183169
set_display_icon_name ();

src/Services/Notification.vala

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class Notifications.Notification : Object {
3535
public string[] actions;
3636
public uint32 replaces_id;
3737
public uint32 id;
38-
public bool has_temp_file;
3938
public GLib.DateTime timestamp;
4039
public GLib.Icon badge_icon { get; construct set; }
4140

@@ -59,28 +58,6 @@ public class Notifications.Notification : Object {
5958
private const string DESKTOP_ENTRY_KEY = "desktop-entry";
6059
private const string FALLBACK_DESKTOP_ID = "gala-other" + DESKTOP_ID_EXT;
6160

62-
public Notification (
63-
uint32 _id, string _app_name, string _app_icon, string _summary, string _message_body, string _image_path,
64-
string[] _actions, string _desktop_id, int64 _unix_time, uint64 _replaces_id, string _sender, bool _has_temp_file
65-
) {
66-
app_name = _app_name;
67-
app_icon = _app_icon;
68-
summary = _summary;
69-
message_body = _message_body;
70-
image_path = _image_path;
71-
replaces_id = (uint32) _replaces_id;
72-
id = _id;
73-
sender = _sender;
74-
75-
actions = _actions;
76-
timestamp = new GLib.DateTime.from_unix_local (_unix_time);
77-
78-
desktop_id = _desktop_id;
79-
app_info = new DesktopAppInfo (desktop_id);
80-
81-
has_temp_file = _has_temp_file;
82-
}
83-
8461
public Notification.from_message (DBusMessage message, uint32 _id) {
8562
var body = message.get_body ();
8663

@@ -131,7 +108,6 @@ public class Notifications.Notification : Object {
131108
var tmpfile = store_pixbuf (buf);
132109
if (tmpfile != null) {
133110
image_path = tmpfile;
134-
has_temp_file = true;
135111
}
136112
}
137113

src/Services/Session.vala

Lines changed: 0 additions & 173 deletions
This file was deleted.

src/Widgets/AppEntry.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
7676
app_notifications.remove (entry);
7777
entry.dismiss ();
7878

79-
Session.get_instance ().remove_notification (entry.notification);
8079
if (app_notifications.length () == 0) {
8180
clear ();
8281
}
@@ -90,6 +89,5 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
9089
});
9190

9291
app_notifications = new List<NotificationEntry> ();
93-
Session.get_instance ().remove_notifications (to_remove);
9492
}
9593
}

src/Widgets/NotificationsList.vala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class Notifications.NotificationsList : Gtk.ListBox {
4646
row_activated.connect (on_row_activated);
4747
}
4848

49-
public async void add_entry (Notification notification, bool add_to_session = true, bool write_file = true) {
49+
public void add_entry (Notification notification) {
5050
var entry = new NotificationEntry (notification);
5151

5252
if (app_entries[notification.desktop_id] != null) {
@@ -70,13 +70,6 @@ public class Notifications.NotificationsList : Gtk.ListBox {
7070
}
7171

7272
show_all ();
73-
74-
Idle.add (add_entry.callback);
75-
yield;
76-
77-
if (add_to_session) { // If notification was obtained from session do not write it back
78-
Session.get_instance ().add_notification (notification);
79-
}
8073
}
8174

8275
public uint count_notifications (out uint number_of_apps) {
@@ -121,10 +114,6 @@ public class Notifications.NotificationsList : Gtk.ListBox {
121114
app_entries.unset (app_entry.app_id);
122115
app_entry.clear_all_notification_entries ();
123116
app_entry.destroy ();
124-
125-
if (app_entries.size == 0) {
126-
Session.get_instance ().clear ();
127-
}
128117
}
129118

130119
private void on_row_activated (Gtk.ListBoxRow row) {

0 commit comments

Comments
 (0)