[pitivi] Select the proper context tab when a clip is selected
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Select the proper context tab when a clip is selected
- Date: Fri, 28 Feb 2014 03:13:30 +0000 (UTC)
commit 19910bd292cb4c988bfa6cdc62e30646a6d5f630
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Feb 17 09:03:45 2014 +0100
Select the proper context tab when a clip is selected
data/ui/titleeditor.ui | 2 +-
pitivi/clipproperties.py | 2 +-
pitivi/mainwindow.py | 25 +++++++++------------
pitivi/tabsmanager.py | 3 ++
pitivi/timeline/elements.py | 4 ++-
pitivi/titleeditor.py | 4 +++
pitivi/transitions.py | 5 +++-
tests/Makefile.am | 1 +
tests/runtests.py | 5 ++++
tests/test_mainwindow.py | 48 +++++++++++++++++++++++++++++++++++++++++++
10 files changed, 81 insertions(+), 18 deletions(-)
---
diff --git a/data/ui/titleeditor.ui b/data/ui/titleeditor.ui
index e0f2b32..43ab6ef 100644
--- a/data/ui/titleeditor.ui
+++ b/data/ui/titleeditor.ui
@@ -18,7 +18,7 @@
<object class="GtkLabel" id="info_bar_label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">No title clip selected. Select a clip to edit or
create a new one.</property>
+ <property name="label" translatable="yes">Select a title clip to edit or create a new
one.</property>
<property name="wrap">True</property>
</object>
<packing>
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 89ae642..2daea0c 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -68,7 +68,7 @@ def compare_type(track, effect_type):
class ClipProperties(Gtk.ScrolledWindow, Loggable):
"""
- Widget for configuring clips properties
+ Widget for configuring the selected clip.
"""
def __init__(self, instance, uiman):
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index caa778e..767b84a 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -166,7 +166,6 @@ class PitiviMainWindow(Gtk.Window, Loggable):
@type app: L{Pitivi}
"""
def __init__(self, app, allow_full_screen=True):
- """ initialize with the Pitivi object """
gtksettings = Gtk.Settings.get_default()
gtksettings.set_property("gtk-application-prefer-dark-theme", True)
# Pulseaudio "role" (http://0pointer.de/blog/projects/tagging-audio.htm)
@@ -457,26 +456,24 @@ class PitiviMainWindow(Gtk.Window, Loggable):
self.connect("delete-event", self._deleteCb)
self.connect("configure-event", self._configureCb)
- def switchContextTab(self, tab=None):
+ def switchContextTab(self, bElement):
"""
Switch the tab being displayed on the second set of tabs,
depending on the context.
- @param the name of the tab to switch to, or None to reset
+ @param bElement: The timeline element which has been focused.
+ @type bElement: GES.TrackElement
"""
- if not tab:
+ if isinstance(bElement, GES.TitleSource):
+ page = 2
+ elif isinstance(bElement, GES.Source):
+ # This covers: VideoUriSource, ImageSource, AudioUriSource.
page = 0
+ elif isinstance(bElement, GES.Transition):
+ page = 1
else:
- tab = tab.lower()
- if tab == "clip configuration":
- page = 0
- elif tab == "transitions":
- page = 1
- elif tab == "title editor":
- page = 2
- else:
- self.debug("Invalid context tab switch requested")
- return False
+ self.warning("Unknown element type: %s", bElement)
+ return
self.context_tabs.set_current_page(page)
def setFullScreen(self, fullscreen):
diff --git a/pitivi/tabsmanager.py b/pitivi/tabsmanager.py
index 46db674..08312d2 100644
--- a/pitivi/tabsmanager.py
+++ b/pitivi/tabsmanager.py
@@ -26,6 +26,9 @@ from pitivi.settings import GlobalSettings
class BaseTabs(Gtk.Notebook):
+ """
+ @type app: Pitivi
+ """
def __init__(self, app):
Gtk.Notebook.__init__(self)
self.set_border_width(SPACING)
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index bec223a..77b291e 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -323,6 +323,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
@ivar bElement: the backend element.
@type bElement: GES.TrackElement
@ivar timeline: the containing graphic timeline.
+ @type timeline: TimelineStage
"""
def __init__(self, bElement, timeline):
@@ -1025,7 +1026,7 @@ class URISourceElement(TimelineElement):
return background
# Callbacks
- def _clickedCb(self, action, actor):
+ def _clickedCb(self, unused_action, unused_actor):
#TODO : Let's be more specific, masks etc ..
mode = SELECT
if self.timeline._container._controlMask and not self.bElement.selected:
@@ -1038,6 +1039,7 @@ class URISourceElement(TimelineElement):
GES.Container.ungroup(self.timeline.current_group, False)
self.timeline.current_group = GES.Group()
self.timeline.current_group.add(self.bElement.get_toplevel_parent())
+ self.timeline._container.app.gui.switchContextTab(self.bElement)
children = self.bElement.get_toplevel_parent().get_children(True)
selection = filter(lambda elem: isinstance(elem, GES.Source), children)
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index bfd358c..b8fd421 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -570,6 +570,10 @@ class InteractivePangoBuffer(PangoBuffer):
class TitleEditor(Loggable):
+ """
+ Widget for configuring the selected title.
+ """
+
def __init__(self, instance, unused_uimap):
Loggable.__init__(self)
Signallable.__init__(self)
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index d056a09..798c064 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -41,6 +41,9 @@ from pitivi.utils.ui import SPACING, PADDING
class TransitionsListWidget(Signallable, Gtk.VBox, Loggable):
+ """
+ Widget for configuring the selected transition.
+ """
def __init__(self, instance, unused_uiman):
Gtk.VBox.__init__(self)
@@ -269,7 +272,7 @@ class TransitionsListWidget(Signallable, Gtk.VBox, Loggable):
self.props_widgets.show_all()
self.searchbar.show_all()
self.selectTransition(transition_asset)
- self.app.gui.switchContextTab("transitions")
+ self.app.gui.switchContextTab(element)
# We REALLY want the infobar to be hidden as space is really constrained
# and yet GTK 3.10 seems to be racy in showing/hiding infobars, so
# this must happen *after* the tab has been made visible/switched to:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3b966ce..ef94386 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ tests = \
test_application.py \
test_common.py \
test_log.py \
+ test_mainwindow.py \
test_misc.py \
test_prefs.py \
test_preset.py \
diff --git a/tests/runtests.py b/tests/runtests.py
index 6644e57..ed5dd95 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -52,6 +52,11 @@ def setup():
from pitivi.check import initialize_modules
initialize_modules()
+ try:
+ import mock
+ except ImportError, e:
+ raise Exception("Python mock library missing! www.voidspace.org.uk/python/mock", e)
+
if __name__ == "__main__":
setup()
diff --git a/tests/test_mainwindow.py b/tests/test_mainwindow.py
new file mode 100644
index 0000000..51615a0
--- /dev/null
+++ b/tests/test_mainwindow.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2013, Alex Băluț <alexandru balut gmail 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., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+import mock
+from unittest import TestCase
+
+from gi.repository import GES
+
+from pitivi.mainwindow import PitiviMainWindow
+
+
+class TestMainWindow(TestCase):
+
+ def setUp(self):
+ app = mock.MagicMock()
+ self.mainwindow = PitiviMainWindow(app)
+
+ def testSwitchContextTab(self):
+ for expected_tab, bElement in [
+ (2, GES.TitleSource()),
+ (1, GES.VideoTransition()),
+ (0, GES.VideoUriSource()),
+ (1, GES.VideoTransition()),
+ (0, GES.ImageSource()),
+ (1, GES.AudioTransition()),
+ (0, GES.AudioUriSource()),
+ (1, GES.AudioTransition())]:
+ self.mainwindow.switchContextTab(bElement)
+ self.assertEqual(expected_tab, self.mainwindow.context_tabs.get_current_page())
+ # Make sure the tab does not change when using an invalid argument.
+ self.mainwindow.switchContextTab("invalid")
+ self.assertEqual(expected_tab, self.mainwindow.context_tabs.get_current_page())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]