From 45a78a20469002dafaacd9ef7903086b3cb6dec9 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 18 Jan 2009 14:45:54 +0000 Subject: [PATCH] New gramplet method to turn word wrap on/off svn: r11656 --- src/DataViews/GrampletView.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/DataViews/GrampletView.py b/src/DataViews/GrampletView.py index 0bff156c4..2255590ff 100644 --- a/src/DataViews/GrampletView.py +++ b/src/DataViews/GrampletView.py @@ -296,13 +296,29 @@ class Gramplet(object): def set_use_markup(self, value): self.gui.set_use_markup(value) - def no_wrap(self): + def set_wrap(self, value): """ - The view in gramplet should not wrap. + Set the textview to wrap or not. """ self.gui.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.gui.textview.set_wrap_mode(gtk.WRAP_NONE) + # gtk.WRAP_NONE, gtk.WRAP_CHAR, gtk.WRAP_WORD or gtk.WRAP_WORD_CHAR. + if value in [True, 1]: + self.gui.textview.set_wrap_mode(gtk.WRAP_WORD) + elif value in [False, 0, None]: + self.gui.textview.set_wrap_mode(gtk.WRAP_NONE) + elif value in ["char"]: + self.gui.textview.set_wrap_mode(gtk.WRAP_CHAR) + elif value in ["word char"]: + self.gui.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR) + else: + raise Exception("Unknown wrap mode: '%s': use 0,1,'char' or 'word char')" % value) + + def no_wrap(self): + """ + The view in gramplet should not wrap. DEPRICATED: use set_wrap instead. + """ + self.set_wrap(False) # Other functions of the gramplet: