Delegate activate_action
to UI thread
This commit is contained in:
parent
839d2a5316
commit
f2c689fa12
|
@ -7,6 +7,8 @@ using Gee;
|
||||||
namespace Dino.Plugins.WindowsNotification {
|
namespace Dino.Plugins.WindowsNotification {
|
||||||
public class WindowsNotificationProvider : NotificationProvider, Object {
|
public class WindowsNotificationProvider : NotificationProvider, Object {
|
||||||
|
|
||||||
|
private delegate void DelegateToUi();
|
||||||
|
|
||||||
private static uint notification_counter = 0;
|
private static uint notification_counter = 0;
|
||||||
private ToastNotifier notifier;
|
private ToastNotifier notifier;
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
|
@ -63,11 +65,13 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
|
|
||||||
var notification_id = generate_id();
|
var notification_id = generate_id();
|
||||||
notification.Activated((argument, user_input) => {
|
notification.Activated((argument, user_input) => {
|
||||||
|
run_on_ui(() => {
|
||||||
if (argument != null) {
|
if (argument != null) {
|
||||||
app.activate_action(argument, conversation.id);
|
app.activate_action(argument, conversation.id);
|
||||||
} else {
|
} else {
|
||||||
app.activate_action("open-conversation", conversation.id);
|
app.activate_action("open-conversation", conversation.id);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
marked_for_removal.add(notification_id);
|
marked_for_removal.add(notification_id);
|
||||||
});
|
});
|
||||||
|
@ -137,11 +141,13 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
var notification_id = generate_id();
|
var notification_id = generate_id();
|
||||||
var group_conversation_id = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(room_jid, account, Conversation.Type.GROUPCHAT).id;
|
var group_conversation_id = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(room_jid, account, Conversation.Type.GROUPCHAT).id;
|
||||||
notification.Activated((argument, user_input) => {
|
notification.Activated((argument, user_input) => {
|
||||||
|
run_on_ui(() => {
|
||||||
if (argument != null) {
|
if (argument != null) {
|
||||||
app.activate_action(argument, group_conversation_id);
|
app.activate_action(argument, group_conversation_id);
|
||||||
} else {
|
} else {
|
||||||
app.activate_action("open-muc-join", group_conversation_id);
|
app.activate_action("open-muc-join", group_conversation_id);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
marked_for_removal.add(notification_id);
|
marked_for_removal.add(notification_id);
|
||||||
});
|
});
|
||||||
|
@ -172,7 +178,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
var notification_id = generate_id();
|
var notification_id = generate_id();
|
||||||
notification.Activated((argument, user_input) => {
|
notification.Activated((argument, user_input) => {
|
||||||
if (argument != null) {
|
if (argument != null) {
|
||||||
app.activate_action(argument, conversation.id);
|
run_on_ui(() => app.activate_action(argument, conversation.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
marked_for_removal.add(notification_id);
|
marked_for_removal.add(notification_id);
|
||||||
|
@ -203,7 +209,7 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
|
|
||||||
var notification_id = generate_id();
|
var notification_id = generate_id();
|
||||||
notification.Activated((argument, user_input) => {
|
notification.Activated((argument, user_input) => {
|
||||||
app.activate_action("open-conversation", conversation.id);
|
run_on_ui(() => app.activate_action("open-conversation", conversation.id));
|
||||||
marked_for_removal.add(notification_id);
|
marked_for_removal.add(notification_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -255,5 +261,9 @@ namespace Dino.Plugins.WindowsNotification {
|
||||||
private uint generate_id() {
|
private uint generate_id() {
|
||||||
return AtomicUint.add(ref notification_counter, 1);
|
return AtomicUint.add(ref notification_counter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void run_on_ui(DelegateToUi func) {
|
||||||
|
Idle.add(() => { func(); return false; }, GLib.Priority.HIGH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue