[pitivi] mainwindow, prefs: basic layout of preferences dialog



commit 3840d7f7bf31e0f063f53a8dc78bea00d29f7a45
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Mon Apr 13 16:46:44 2009 -0700

    mainwindow, prefs: basic layout of preferences dialog
---
 pitivi/ui/mainwindow.py  |   19 +++++++-
 pitivi/ui/mainwindow.xml |    1 +
 pitivi/ui/prefs.py       |  119 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 138 insertions(+), 1 deletions(-)

diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 10f10b3..02729e8 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -151,6 +151,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
         self.is_fullscreen = self.settings.mainWindowFullScreen
         self.missing_plugins = []
         self.timelinepos = 0
+        self.prefsdialog = None
         create_stock_icons()
         self._setActions(instance)
         self._createUi(instance)
@@ -215,6 +216,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
             ("PluginManager", gtk.STOCK_PREFERENCES ,
              _("_Plugins..."),
              None, _("Manage plugins"), self._pluginManagerCb),
+            ("Preferences", gtk.STOCK_PREFERENCES, _("_Preferences"),
+              None, None, self._prefsCb),
             ("ImportfromCam", gtk.STOCK_ADD ,
              _("Import from _Webcam..."),
              None, _("Import Camera stream"), self._ImportWebcam),
@@ -276,6 +279,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         # deactivating non-functional actions
         # FIXME : reactivate them
+
         for action in self.actiongroup.list_actions():
             action_name = action.get_name()
             if action_name == "RenderProject":
@@ -297,7 +301,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
                 "ShowHideMainToolbar", "ShowHideTimelineToolbar", "Library",
                 "Timeline", "Viewer", "FrameForward", "FrameBackward",
                 "SecondForward", "SecondBackward", "EdgeForward",
-                "EdgeBackward"]:
+                "EdgeBackward", "Preferences"]:
                 action.set_sensitive(True)
             elif action_name in ["SaveProject", "SaveProjectAs",
                     "NewProject", "OpenProject"]:
@@ -643,6 +647,19 @@ class PitiviMainWindow(gtk.Window, Loggable):
         else:
             self.webcam_button.set_sensitive(True)
 
+    def _hideChildWindow(self, window, event):
+        window.hide()
+        return True
+
+    def _prefsCb(self, unused_action):
+        if not self.prefsdialog:
+            from pitivi.ui.prefs import PreferencesDialog
+            self.prefsdialog = PreferencesDialog(self.app)
+            self.prefsdialog.set_transient_for(self)
+            self.prefsdialog.connect("delete-event", self._hideChildWindow)
+            self.prefsdialog.set_default_size(400, 300)
+        self.prefsdialog.show_all()
+
     def rewind(self, unused_action):
         pass
 
diff --git a/pitivi/ui/mainwindow.xml b/pitivi/ui/mainwindow.xml
index 040e00d..394be9f 100644
--- a/pitivi/ui/mainwindow.xml
+++ b/pitivi/ui/mainwindow.xml
@@ -10,6 +10,7 @@
     </menu>
     <menu action="Edit">
       <menuitem action="PluginManager" />
+      <menuitem action="Preferences" />
     </menu>
     <menu action="View">
       <menuitem action="ShowHideMainToolbar" />
diff --git a/pitivi/ui/prefs.py b/pitivi/ui/prefs.py
new file mode 100644
index 0000000..34f7631
--- /dev/null
+++ b/pitivi/ui/prefs.py
@@ -0,0 +1,119 @@
+# PiTiVi , Non-linear video editor
+#
+#       ui/prefs.py
+#
+# Copyright (c) 2005, Edward Hervey <bilboed bilboed com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser 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.
+
+"""
+Dialog box for project settings
+"""
+
+import gtk
+from gettext import gettext as _
+
+class PreferencesDialog(gtk.Window):
+
+    def __init__(self, instance):
+        gtk.Window.__init__(self)
+        self.app = instance
+        self.settings = instance.settings
+        self._createUi()
+        self._fillContents()
+        self._current = None
+        self.set_border_width(12)
+
+    def _createUi(self):
+        self.set_title(_("Preferences"))
+        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+
+        # basic layout
+        vbox = gtk.VBox()
+        vbox.set_spacing(6)
+        button_box = gtk.HBox()
+        button_box.set_spacing(5)
+        button_box.set_homogeneous(False)
+        pane = gtk.HPaned()
+        vbox.pack_start(pane, True, True)
+        vbox.pack_end(button_box, False, False)
+        self.add(vbox)
+
+        # left-side list view
+        self.model = gtk.ListStore(str, str)
+        self.treeview = gtk.TreeView(self.model)
+        self.treeview.get_selection().connect("changed",
+            self._treeSelectionChangedCb)
+        ren = gtk.CellRendererText()
+        col = gtk.TreeViewColumn(_("Section"), ren, text=0)
+        self.treeview.append_column(col)
+        scrolled = gtk.ScrolledWindow()
+        scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+        scrolled.add(self.treeview)
+        pane.pack1(scrolled)
+
+        # preferences content region
+        self.contents = gtk.ScrolledWindow()
+        self.contents.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        pane.pack2(self.contents)
+
+        # revert, close buttons
+        factory_settings = gtk.Button(label=_("Restore Factory Settings"))
+        factory_settings.connect("clicked", self._factorySettingsButtonCb)
+        factory_settings.set_sensitive(False)
+        revert_button = gtk.Button(_("Revert"))
+        revert_button.connect("clicked", self._revertButtonCb)
+        revert_button.set_sensitive(False)
+        accept_button = gtk.Button(stock=gtk.STOCK_CLOSE)
+        accept_button.connect("clicked", self._acceptButtonCb)
+        button_box.pack_start(factory_settings, False, True)
+        button_box.pack_end(accept_button, False, True)
+        button_box.pack_end(revert_button, False, True)
+
+    def _fillContents(self):
+        self.sections = {}
+        for section, options in self.settings.prefs.iteritems():
+            self.model.append((_(section), section))
+            widgets = gtk.Table()
+            vp = gtk.Viewport()
+            vp.add(widgets)
+            self.sections[section] = vp
+            for y, (attrname, (label, description)) in enumerate(options.iteritems()):
+                widgets.attach(gtk.Label(_(label)), 0, 1, y, y + 1,
+                    xoptions=0, yoptions=0)
+
+    def _treeSelectionChangedCb(self, selection):
+        model, iter = selection.get_selected()
+        new = self.sections[model[iter][1]]
+        if self._current != new:
+            if self._current:
+                self.contents.remove(self._current)
+            self.contents.add(new)
+            self._current = new
+            new.show_all()
+
+    def _clearHistory(self):
+        pass
+
+    def _factorySettingsButtonCb(self, unused_button):
+        pass
+
+    def _revertButtonCb(self, unused_button):
+        pass
+
+    def _acceptButtonCb(self, unused_button):
+        self._clearHistory()
+        self.hide()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]