Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Session.vala #265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ shared_module(
'src/Widgets/AppEntry.vala',
'src/Services/NotificationsMonitor.vala',
'src/Services/Notification.vala',
'src/Services/Session.vala',
'src/Services/Interfaces.vala',
gresource,
config_vala,
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ src/Widgets/NotificationEntry.vala
src/Widgets/AppEntry.vala
src/Services/NotificationsMonitor.vala
src/Services/Notification.vala
src/Services/Session.vala
src/Services/Interfaces.vala
22 changes: 4 additions & 18 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class Notifications.Indicator : Wingpanel.Indicator {
private Gtk.ModelButton clear_all_btn;
private Gtk.Spinner? dynamic_icon = null;
private NotificationsList nlist;
private List<Notification> previous_session = null;

public Indicator () {
Object (
Expand Down Expand Up @@ -77,27 +76,14 @@ public class Notifications.Indicator : Wingpanel.Indicator {
return Gdk.EVENT_PROPAGATE;
});

previous_session = Session.get_instance ().get_session_notifications ();
Timeout.add (2000, () => { // Do not block animated drawing of wingpanel
load_session_notifications.begin (() => { // load asynchromously so spinner continues to rotate
set_display_icon_name ();
nlist.add.connect (set_display_icon_name);
nlist.remove.connect (set_display_icon_name);
});

return Source.REMOVE;
});
set_display_icon_name ();
nlist.add.connect (set_display_icon_name);
nlist.remove.connect (set_display_icon_name);
}

return dynamic_icon;
}

private async void load_session_notifications () {
foreach (var notification in previous_session) {
yield nlist.add_entry (notification, false); // This is slow as NotificationEntry is complex
}
}

public override Gtk.Widget? get_widget () {
if (main_box == null) {
var not_disturb_switch = new Granite.SwitchModelButton (_("Do Not Disturb"));
Expand Down Expand Up @@ -177,7 +163,7 @@ public class Notifications.Indicator : Wingpanel.Indicator {
}

if (app_settings == null || app_settings.get_boolean (REMEMBER_KEY)) {
nlist.add_entry.begin (notification, true);
nlist.add_entry (notification);
}

set_display_icon_name ();
Expand Down
24 changes: 0 additions & 24 deletions src/Services/Notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class Notifications.Notification : Object {
public string[] actions;
public uint32 replaces_id;
public uint32 id;
public bool has_temp_file;
public GLib.DateTime timestamp;
public GLib.Icon badge_icon { get; construct set; }

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

public Notification (
uint32 _id, string _app_name, string _app_icon, string _summary, string _message_body, string _image_path,
string[] _actions, string _desktop_id, int64 _unix_time, uint64 _replaces_id, string _sender, bool _has_temp_file
) {
app_name = _app_name;
app_icon = _app_icon;
summary = _summary;
message_body = _message_body;
image_path = _image_path;
replaces_id = (uint32) _replaces_id;
id = _id;
sender = _sender;

actions = _actions;
timestamp = new GLib.DateTime.from_unix_local (_unix_time);

desktop_id = _desktop_id;
app_info = new DesktopAppInfo (desktop_id);

has_temp_file = _has_temp_file;
}

public Notification.from_message (DBusMessage message, uint32 _id) {
var body = message.get_body ();

Expand Down Expand Up @@ -131,7 +108,6 @@ public class Notifications.Notification : Object {
var tmpfile = store_pixbuf (buf);
if (tmpfile != null) {
image_path = tmpfile;
has_temp_file = true;
}
}

Expand Down
173 changes: 0 additions & 173 deletions src/Services/Session.vala

This file was deleted.

2 changes: 0 additions & 2 deletions src/Widgets/AppEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
app_notifications.remove (entry);
entry.dismiss ();

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

app_notifications = new List<NotificationEntry> ();
Session.get_instance ().remove_notifications (to_remove);
}
}
13 changes: 1 addition & 12 deletions src/Widgets/NotificationsList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Notifications.NotificationsList : Gtk.ListBox {
row_activated.connect (on_row_activated);
}

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

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

show_all ();

Idle.add (add_entry.callback);
yield;

if (add_to_session) { // If notification was obtained from session do not write it back
Session.get_instance ().add_notification (notification);
}
}

public uint count_notifications (out uint number_of_apps) {
Expand Down Expand Up @@ -121,10 +114,6 @@ public class Notifications.NotificationsList : Gtk.ListBox {
app_entries.unset (app_entry.app_id);
app_entry.clear_all_notification_entries ();
app_entry.destroy ();

if (app_entries.size == 0) {
Session.get_instance ().clear ();
}
}

private void on_row_activated (Gtk.ListBoxRow row) {
Expand Down