[pitivi] Port PreferencesDialog to GtkBuilder
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Port PreferencesDialog to GtkBuilder
- Date: Wed, 15 Jun 2011 16:45:53 +0000 (UTC)
commit d34a5e46435280f257b12f560462b906fd796c38
Author: StÃphane Maniaci <stephane maniaci gmail com>
Date: Mon Jun 6 00:36:14 2011 -0700
Port PreferencesDialog to GtkBuilder
data/ui/Makefile.am | 1 +
data/ui/preferences.ui | 182 +++++++++++++++++++++++++++++++++++++++++++++++
pitivi/ui/mainwindow.py | 9 +--
pitivi/ui/prefs.py | 96 ++++++-------------------
po/POTFILES.in | 1 +
5 files changed, 209 insertions(+), 80 deletions(-)
---
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
index 3a9aa2c..6e9a2ef 100644
--- a/data/ui/Makefile.am
+++ b/data/ui/Makefile.am
@@ -5,6 +5,7 @@ ui_DATA = \
encodingprogress.ui \
filelisterrordialog.ui \
mainwindow.xml \
+ preferences.ui \
projectsettings.ui \
pluginmanagerdialog.ui \
startupwizard.ui
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
new file mode 100644
index 0000000..e78f0af
--- /dev/null
+++ b/data/ui/preferences.ui
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <object class="GtkDialog" id="dialog1">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="type_hint">dialog</property>
+ <signal name="configure-event" handler="_configureCb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkHPaned" id="paned1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection3">
+ <signal name="changed" handler="_treeSelectionChangedCb" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="title" translatable="yes">Section</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <child>
+ <object class="GtkViewport" id="viewport1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="restartWarning">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes"><b>Some changes will not take effect until you restart PiTiVi</b></property>
+ <property name="use_markup">True</property>
+ <property name="justify">center</property>
+ <property name="max_width_chars">40</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="resetButton">
+ <property name="label" translatable="yes">Reset to Factory Settings</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="clicked" handler="_factorySettingsButtonCb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="revertButton">
+ <property name="label" translatable="yes">Revert</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <signal name="clicked" handler="_revertButtonCb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="acceptButton">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="_acceptButtonCb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">resetButton</action-widget>
+ <action-widget response="0">revertButton</action-widget>
+ <action-widget response="0">acceptButton</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name column1 -->
+ <column type="gchararray"/>
+ <!-- column-name column2 -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 6923836..72446a8 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -698,17 +698,12 @@ class PitiviMainWindow(gtk.Window, Loggable):
from pluginmanagerdialog import PluginManagerDialog
PluginManagerDialog(self.app.plugin_manager)
- 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.show()
+ self.prefsdialog.dialog.set_transient_for(self)
+ self.prefsdialog.run()
def rewind(self, unused_action):
pass
diff --git a/pitivi/ui/prefs.py b/pitivi/ui/prefs.py
index aee7970..98a66b5 100644
--- a/pitivi/ui/prefs.py
+++ b/pitivi/ui/prefs.py
@@ -24,10 +24,14 @@ Dialog box for user preferences.
"""
import gtk
-from gettext import gettext as _
+import os
+
import pitivi.ui.dynamic as dynamic
+
+from pitivi.configure import get_ui_dir
from pitivi.settings import GlobalSettings
from pitivi.ui.common import SPACING
+from gettext import gettext as _
GlobalSettings.addConfigOption('prefsDialogWidth',
section = "user-interface",
@@ -39,14 +43,12 @@ GlobalSettings.addConfigOption('prefsDialogHeight',
key = "prefs-dialog-height",
default = 400)
-class PreferencesDialog(gtk.Window):
+class PreferencesDialog():
prefs = {}
original_values = {}
def __init__(self, instance):
- gtk.Window.__init__(self)
- self.app = instance
self.settings = instance.settings
self.widgets = {}
self.resets = {}
@@ -56,76 +58,24 @@ class PreferencesDialog(gtk.Window):
min_width, min_height = self.contents.size_request()
width = max(min_width, self.settings.prefsDialogWidth)
height = max(min_height, self.settings.prefsDialogHeight)
- self.set_default_size(width, height)
+ self.dialog.set_default_size(width, height)
+
+ def run(self):
+ self.dialog.run()
def _createUi(self):
- self.set_title(_("Preferences"))
- self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
- self.set_border_width(12)
- self.connect("configure-event", self._configureCb)
-
- # basic layout
- vbox = gtk.VBox()
- vbox.set_spacing(SPACING)
- button_box = gtk.HBox()
- button_box.set_spacing(SPACING)
- button_box.set_homogeneous(False)
- pane = gtk.HPaned()
- vbox.pack_start(pane, True, True)
- vbox.pack_end(button_box, False, False)
- pane.show()
- self.add(vbox)
- vbox.show()
-
- # 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)
- scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- self.treeview.props.headers_visible = False
- self.treeview.show()
- pane.pack1(scrolled)
- scrolled.show()
-
- # preferences content region
- self.contents = gtk.VBox()
- scrolled = gtk.ScrolledWindow()
- scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
- scrolled.add_with_viewport(self.contents)
- pane.pack2(scrolled)
- scrolled.show()
- self.contents.show()
-
- # revert, close buttons
- self.factory_settings = gtk.Button(label=_("Reset to Factory Settings"))
- self.factory_settings.connect("clicked", self._factorySettingsButtonCb)
- self.factory_settings.set_sensitive(self._canReset())
- self.factory_settings.show()
- self.revert_button = gtk.Button(_("Revert"))
- self.revert_button.connect("clicked", self._revertButtonCb)
- self.revert_button.show()
- self.revert_button.set_sensitive(False)
- accept_button = gtk.Button(stock=gtk.STOCK_CLOSE)
- accept_button.connect("clicked", self._acceptButtonCb)
- accept_button.show()
- button_box.pack_start(self.factory_settings, False, True)
- button_box.pack_end(accept_button, False, True)
- button_box.pack_end(self.revert_button, False, True)
- button_box.show()
-
- # restart warning
- self.restart_warning = gtk.Label()
- self.restart_warning.set_markup(
- "<b>%s</b>" % _("Some changes will not take effect until you "
- "restart PiTiVi"))
- vbox.pack_end(self.restart_warning, False, False)
+ builder = gtk.Builder()
+ builder.add_from_file(os.path.join(get_ui_dir(), "preferences.ui"))
+ builder.connect_signals(self)
+
+ # widgets we'll need
+ self.dialog = builder.get_object("dialog1")
+ self.model = builder.get_object("liststore1")
+ self.treeview = builder.get_object("treeview1")
+ self.contents = builder.get_object("box1")
+ self.revert_button = builder.get_object("revertButton")
+ self.factory_settings = builder.get_object("resetButton")
+ self.restart_warning = builder.get_object("restartWarning")
## Public API
@@ -377,7 +327,7 @@ class PreferencesDialog(gtk.Window):
def _acceptButtonCb(self, unused_button):
self._clearHistory()
- self.hide()
+ self.dialog.hide()
def _valueChanged(self, fake_widget, real_widget, attrname):
value = getattr(self.settings, attrname)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6c7196f..9d0d6e4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,6 +7,7 @@ data/ui/encodingdialog.ui
data/ui/encodingprogress.ui
data/ui/filelisterrordialog.ui
data/ui/pluginmanagerdialog.ui
+data/ui/preferences.ui
data/ui/projectsettings.ui
data/ui/startupwizard.ui
pitivi/application.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]