[gnome-tweak-tool] Add tweak.notify_info
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Add tweak.notify_info
- Date: Wed, 4 May 2011 22:03:11 +0000 (UTC)
commit 35df99a3deadf41c41ab937eadbfb08cad2df500
Author: John Stowers <john stowers gmail com>
Date: Thu May 5 09:59:55 2011 +1200
Add tweak.notify_info
gtweak/tweakmodel.py | 10 +++++++---
gtweak/tweaks/tweak_test.py | 9 +++++++--
gtweak/tweakview.py | 9 ++++++---
3 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/gtweak/tweakmodel.py b/gtweak/tweakmodel.py
index 7a7411f..0167ab2 100644
--- a/gtweak/tweakmodel.py
+++ b/gtweak/tweakmodel.py
@@ -46,13 +46,17 @@ class Tweak:
def set_notify_cb(self, func):
self._notify_cb = func
- def notify_action_required(self, desc, btn, func):
+ def notify_action_required(self, desc, btn, func, error=False):
if self._notify_cb:
- self._notify_cb(self, desc, btn, func)
+ self._notify_cb(self, desc, error, btn, func)
def notify_error(self, desc):
if self._notify_cb:
- self._notify_cb(self, desc, None, None)
+ self._notify_cb(self, desc, True, None, None)
+
+ def notify_info(self, desc):
+ if self._notify_cb:
+ self._notify_cb(self, desc, False, None, None)
class TweakGroup:
def __init__(self, name, *tweaks):
diff --git a/gtweak/tweaks/tweak_test.py b/gtweak/tweaks/tweak_test.py
index 5e02a24..1f74a28 100644
--- a/gtweak/tweaks/tweak_test.py
+++ b/gtweak/tweaks/tweak_test.py
@@ -32,6 +32,7 @@ class _TestButtonTweak(Tweak):
self.widget = Gtk.Button(name)
self.widget.connect("clicked", self._on_click)
self._need_action = options.get("need_action")
+ self._action_error = options.get("action_error")
def _on_click(self, sender):
if self._need_action:
@@ -40,7 +41,10 @@ class _TestButtonTweak(Tweak):
Gtk.STOCK_OK,
lambda : print("GOT CALLBACK"))
else:
- self.notify_error(self.name)
+ if self._action_error:
+ self.notify_error(self.name)
+ else:
+ self.notify_info(self.name)
TWEAK_GROUPS = (
TweakGroup(
@@ -48,7 +52,8 @@ TWEAK_GROUPS = (
_TestTweak("foo bar", "does foo bar"),
_TestTweak("foo baz", "does foo baz"),
_TestButtonTweak("Need Action", "foo bar", need_action=True),
- _TestButtonTweak("Report Error", "foo baz", need_action=False)),
+ _TestButtonTweak("Report Error", "foo baz", action_error=True),
+ _TestButtonTweak("Report Info", "foo bob", action_error=False)),
TweakGroup(
"Test Many Settings",
*[_TestTweak("name: " + str(d), "desc: " + str(d)) for d in range(50)]),
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
index 5aa79f6..ab80908 100644
--- a/gtweak/tweakview.py
+++ b/gtweak/tweakview.py
@@ -88,17 +88,20 @@ class TweakView:
self._detail_vbox.remove(info)
func()
- def _on_tweak_notify(self, tweak, desc, btn, func):
+ def _on_tweak_notify(self, tweak, desc, error, btn, func):
info = Gtk.InfoBar()
info.get_content_area().add(Gtk.Label(desc))
self._detail_vbox.pack_end(info, False, False, 0)
- if btn and func:
+ if error:
+ info.props.message_type = Gtk.MessageType.ERROR
+ else:
info.props.message_type = Gtk.MessageType.INFO
+
+ if btn and func:
info.add_button(btn, Gtk.ResponseType.OK)
info.connect("response", self._on_tweak_notify_response, func)
else:
- info.props.message_type = Gtk.MessageType.ERROR
GObject.timeout_add_seconds(2, lambda box, widget: box.remove(widget), self._detail_vbox, info)
info.show_all()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]