Rev 456: Split plugins page out into a separate file. in file:///data/jelmer/bzr-gtk/preferences/

Jelmer Vernooij jelmer at samba.org
Fri Mar 28 19:30:28 GMT 2008


At file:///data/jelmer/bzr-gtk/preferences/

------------------------------------------------------------
revno: 456
revision-id: jelmer at samba.org-20080328193027-gs7n8tsbwv31nmry
parent: jelmer at samba.org-20080328192653-trzptkwahx1tulz9
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: preferences
timestamp: Fri 2008-03-28 20:30:27 +0100
message:
  Split plugins page out into a separate file.
added:
  preferences/plugins.py         plugins.py-20080328193019-jhdtj2h9foskjijv-1
modified:
  preferences/__init__.py        preferences.py-20070313153956-vcdqjrfal0wuk0vb-1
=== modified file 'preferences/__init__.py'
--- a/preferences/__init__.py	2008-03-28 19:26:53 +0000
+++ b/preferences/__init__.py	2008-03-28 19:30:27 +0000
@@ -23,6 +23,7 @@
 import gtk
 
 from bzrlib.config import GlobalConfig
+from plugins import PluginsPage
 
 class PreferencesWindow(gtk.Dialog):
     """Displays global preferences windows."""
@@ -105,104 +106,11 @@
 
         return table
 
-    def _create_pluginpage(self):
-        paned = gtk.VPaned()
-        scrolledwindow = gtk.ScrolledWindow()
-        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-        model = gtk.ListStore(str, str)
-        treeview = gtk.TreeView()
-        scrolledwindow.add(treeview)
-        paned.pack1(scrolledwindow, resize=True, shrink=False)
-
-        table = gtk.Table(columns=2)
-        table.set_row_spacings(6)
-        table.set_col_spacings(6)
-
-        def row_selected(tv, path, tvc):
-            p = bzrlib.plugin.plugins()[model[path][0]]
-            from inspect import getdoc
-
-            for w in table.get_children():
-                table.remove(w)
-
-            if getattr(p, '__author__', None) is not None:
-                align = gtk.Alignment(1.0, 0.5)
-                label = gtk.Label()
-                label.set_markup("<b>Author:</b>")
-                align.add(label)
-                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
-                align.show()
-                label.show()
-
-                align = gtk.Alignment(0.0, 0.5)
-                author = gtk.Label()
-                author.set_text(p.__author__)
-                author.set_selectable(True)
-                align.add(author)
-                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
-
-            if getattr(p, '__version__', None) is not None:
-                align = gtk.Alignment(1.0, 0.5)
-                label = gtk.Label()
-                label.set_markup("<b>Version:</b>")
-                align.add(label)
-                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
-                align.show()
-                label.show()
-
-                align = gtk.Alignment(0.0, 0.5)
-                author = gtk.Label()
-                author.set_text(p.__version__)
-                author.set_selectable(True)
-                align.add(author)
-                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
-
-            if getdoc(p) is not None:
-                align = gtk.Alignment(0.0, 0.5)
-                description = gtk.Label()
-                description.set_text(getdoc(p))
-                description.set_selectable(True)
-                align.add(description)
-                table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
-
-            table.show_all()
-
-        treeview.set_headers_visible(False)
-        treeview.set_model(model)
-        treeview.connect("row-activated", row_selected)
-
-        cell = gtk.CellRendererText()
-        column = gtk.TreeViewColumn()
-        column.pack_start(cell, expand=True)
-        column.add_attribute(cell, "text", 0)
-        treeview.append_column(column)
-
-        cell = gtk.CellRendererText()
-        column = gtk.TreeViewColumn()
-        column.pack_start(cell, expand=True)
-        column.add_attribute(cell, "text", 1)
-        treeview.append_column(column)
-        
-        import bzrlib.plugin
-        plugins = bzrlib.plugin.plugins()
-        plugin_names = plugins.keys()
-        plugin_names.sort()
-        for name in plugin_names:
-            model.append([name, getattr(plugins[name], '__file__', None)])
-                 
-        scrolledwindow = gtk.ScrolledWindow()
-        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-        scrolledwindow.add_with_viewport(table)
-        paned.pack2(scrolledwindow, resize=False, shrink=True)
-        paned.show()
-
-        return paned
-
     def _create(self):
         self.set_default_size(600, 600)
         notebook = gtk.Notebook()
         notebook.insert_page(self._create_mainpage(), gtk.Label("Main"))
-        notebook.insert_page(self._create_pluginpage(), gtk.Label("Plugins"))
+        notebook.insert_page(PluginsPage(), gtk.Label("Plugins"))
         self.vbox.pack_start(notebook, True, True)
         self.vbox.show_all()
 

=== added file 'preferences/plugins.py'
--- a/preferences/plugins.py	1970-01-01 00:00:00 +0000
+++ b/preferences/plugins.py	2008-03-28 19:30:27 +0000
@@ -0,0 +1,117 @@
+# Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+try:
+    import pygtk
+    pygtk.require("2.0")
+except:
+    pass
+
+import gtk
+
+class PluginsPage(gtk.VPaned):
+    def __init__(self):
+        gtk.VPaned.__init__(self)
+        scrolledwindow = gtk.ScrolledWindow()
+        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        model = gtk.ListStore(str, str)
+        treeview = gtk.TreeView()
+        scrolledwindow.add(treeview)
+        self.pack1(scrolledwindow, resize=True, shrink=False)
+
+        table = gtk.Table(columns=2)
+        table.set_row_spacings(6)
+        table.set_col_spacings(6)
+
+        treeview.set_headers_visible(False)
+        treeview.set_model(model)
+        treeview.connect("row-activated", self.row_selected)
+
+        cell = gtk.CellRendererText()
+        column = gtk.TreeViewColumn()
+        column.pack_start(cell, expand=True)
+        column.add_attribute(cell, "text", 0)
+        treeview.append_column(column)
+
+        cell = gtk.CellRendererText()
+        column = gtk.TreeViewColumn()
+        column.pack_start(cell, expand=True)
+        column.add_attribute(cell, "text", 1)
+        treeview.append_column(column)
+        
+        import bzrlib.plugin
+        plugins = bzrlib.plugin.plugins()
+        plugin_names = plugins.keys()
+        plugin_names.sort()
+        for name in plugin_names:
+            model.append([name, getattr(plugins[name], '__file__', None)])
+                 
+        scrolledwindow = gtk.ScrolledWindow()
+        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        scrolledwindow.add_with_viewport(table)
+        self.pack2(scrolledwindow, resize=False, shrink=True)
+        self.show()
+
+    def row_selected(self, tv, path, tvc):
+        p = bzrlib.plugin.plugins()[model[path][0]]
+        from inspect import getdoc
+
+        for w in table.get_children():
+            table.remove(w)
+
+        if getattr(p, '__author__', None) is not None:
+            align = gtk.Alignment(1.0, 0.5)
+            label = gtk.Label()
+            label.set_markup("<b>Author:</b>")
+            align.add(label)
+            table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
+            align.show()
+            label.show()
+
+            align = gtk.Alignment(0.0, 0.5)
+            author = gtk.Label()
+            author.set_text(p.__author__)
+            author.set_selectable(True)
+            align.add(author)
+            table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
+
+        if getattr(p, '__version__', None) is not None:
+            align = gtk.Alignment(1.0, 0.5)
+            label = gtk.Label()
+            label.set_markup("<b>Version:</b>")
+            align.add(label)
+            table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
+            align.show()
+            label.show()
+
+            align = gtk.Alignment(0.0, 0.5)
+            author = gtk.Label()
+            author.set_text(p.__version__)
+            author.set_selectable(True)
+            align.add(author)
+            table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
+
+        if getdoc(p) is not None:
+            align = gtk.Alignment(0.0, 0.5)
+            description = gtk.Label()
+            description.set_text(getdoc(p))
+            description.set_selectable(True)
+            align.add(description)
+            table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
+
+        table.show_all()
+
+




More information about the bazaar-commits mailing list