[gnome-tweak-tool] Notifications with the logout option
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Notifications with the logout option
- Date: Sun, 18 Aug 2013 19:47:18 +0000 (UTC)
commit 27dd59e928ddc3ba1d9f553452caedbfab268c7c
Author: Alex Muñoz <alexmudoz gmail com>
Date: Sun Jul 21 00:30:07 2013 -0400
Notifications with the logout option
gtweak/tweakview.py | 7 ++++++-
gtweak/utils.py | 20 ++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
index 6b3633b..cb772d5 100644
--- a/gtweak/tweakview.py
+++ b/gtweak/tweakview.py
@@ -22,6 +22,7 @@ from gi.repository import Gtk, Gdk, GObject
import gtweak.tweakmodel
from gtweak.tweakmodel import TweakModel
+from gtweak.utils import Notification
DEFAULT_TWEAKGROUP = gtweak.tweakmodel.TWEAK_GROUP_APPEARANCE
WIDGET_SORT_ORDER = (Gtk.Switch, Gtk.SpinButton, Gtk.ComboBox, Gtk.Box, Gtk.VBox, Gtk.HBox)
@@ -116,7 +117,11 @@ class TweakView:
def _on_tweak_notify(self, tweak, desc, error, btn, func, need_logout):
#if need to log out, do this as a notification area thing, not a note inside
#the main window
-
+
+ if need_logout:
+ notification = Notification()
+ notification.show()
+
info = Gtk.InfoBar()
info.get_content_area().add(Gtk.Label(desc))
diff --git a/gtweak/utils.py b/gtweak/utils.py
index 2a29ffe..c20da41 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -20,6 +20,7 @@ import logging
import tempfile
import shutil
import subprocess
+import dbus
import gtweak
from gtweak.gsettings import GSettingsSetting
@@ -27,6 +28,8 @@ from gtweak.gsettings import GSettingsSetting
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
+from gi.repository import Notify
+
def singleton(cls):
"""
Singleton decorator that works with GObject derived types. The 'recommended'
@@ -309,6 +312,23 @@ class XSettingsOverrides:
def get_enable_primary_paste(self):
self._get_override('Gtk/EnablePrimaryPaste', True)
+class Notification:
+ def __init__(self):
+ self.notification = None
+ if Notify.is_initted() or Notify.init("GNOME Tweak Tool"):
+ self.notification = Notify.Notification.new("Configuration changes requiere restart","Your
session needs to be restarted for settings to take effect", 'gnome-tweak-tool')
+ self.notification.add_action("restart", "Restart Session",self.logout,None,None)
+ else:
+ print "Error: Could not create the notification"
+
+ def show(self):
+ if self.notification:
+ self.notification.show()
+
+ def logout(self, btn, action, unknown):
+ bus = dbus.SessionBus()
+ serviceManager = bus.get_object('org.gnome.SessionManager', '/org/gnome/SessionManager')
+ serviceManager.Logout(dbus.UInt32(0))
if __name__ == "__main__":
gtweak.DATA_DIR = "/usr/share"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]