[pitivi] Replace our custom detachable tabs with regular gtk (detachable) tabs.



commit 165bdb8004a0b36178bd3e79421d95cdc9ea81ce
Author: Alessandro Decina <alessandro d gmail com>
Date:   Tue Aug 18 17:00:29 2009 +0200

    Replace our custom detachable tabs with regular gtk (detachable) tabs.
    
    Gtk now supports detachable tabs so we can remove our custom code. This makes us
    look more consistent with other apps like empathy epiphany etc that have the
    same functionality.

 pitivi/ui/mainwindow.py  |    9 +++-
 pitivi/ui/projecttabs.py |  104 ++++++++++++---------------------------------
 2 files changed, 34 insertions(+), 79 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 7f4fe0f..df1cf0b 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -54,6 +54,7 @@ from pitivi.settings import GlobalSettings
 from pitivi.receiver import receiver, handler
 import pitivi.formatters.format as formatter
 from pitivi.sourcelist import SourceListError
+from pitivi.ui.sourcelist import SourceList
 
 if HAVE_GCONF:
     D_G_INTERFACE = "/desktop/gnome/interface"
@@ -375,7 +376,10 @@ class PitiviMainWindow(gtk.Window, Loggable):
         vpaned.pack2(self.timeline, resize=False, shrink=False)
         hpaned = gtk.HPaned()
         vpaned.pack1(hpaned, resize=True, shrink=False)
-        self.projecttabs = ProjectTabs(instance, self.uimanager)
+        self.projecttabs = ProjectTabs()
+
+        self.sourcelist = SourceList(instance, self.uimanager)
+        self.projecttabs.append_page(self.sourcelist, gtk.Label(_("Clip Library")))
         self._connectToSourceList()
 
         hpaned.pack1(self.projecttabs, resize=True, shrink=False)
@@ -435,8 +439,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
     def _connectToSourceList(self):
         # FIXME: projecttabs creates the "components" but then has no API to get
         # them back
-        sourcelist = self.projecttabs._full_list[0]
-        sourcelist.connect('play', self._sourceListPlayCb)
+        self.sourcelist.connect('play', self._sourceListPlayCb)
 
     def toggleFullScreen(self):
         """ Toggle the fullscreen mode of the application """
diff --git a/pitivi/ui/projecttabs.py b/pitivi/ui/projecttabs.py
index 93a1a31..4ffd697 100644
--- a/pitivi/ui/projecttabs.py
+++ b/pitivi/ui/projecttabs.py
@@ -19,93 +19,45 @@
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-"""
-Source and effects list widgets
-"""
-
 import gtk
-from gettext import gettext as _
-from sourcelist import SourceList
-from audiofxlist import AudioFxList
-from videofxlist import VideoFxList
-from propertyeditor import PropertyEditor
-
-class DetachLabel(gtk.HBox):
-
-    def __init__(self, parent, child, label, *args, **kwargs):
-        gtk.HBox.__init__(self, *args, **kwargs)
-
-        self.label = gtk.Label(label)
-        self.child = child
-        self.button = gtk.Button()
-        image = gtk.Image()
-        image.set_from_stock(gtk.STOCK_LEAVE_FULLSCREEN,
-            gtk.ICON_SIZE_SMALL_TOOLBAR)
-        self.button.set_image(image)
-        self.button.connect("clicked", self._windowize)
-        self.pack_start(self.button, False, False)
-        self.pack_start(self.label)
-        self.show_all()
-
-    def select(self):
-        self.button.set_sensitive(True)
-
-    def deselect(self):
-        self.button.set_sensitive(False)
-
-    def _windowize(self, unused_button):
-        self.parent.windowizeComponent(self.child, self)
 
 class ProjectTabs(gtk.Notebook):
-    """
-    Widget for the various source factories (files, effects, live,...)
-    """
-
-    __DEFAULT_COMPONENTS__ = (
-        (SourceList, _("Clip Library")),
-        # (AudioFxList, _("Audio Effects")),
-        # (VideoFxList, _("Video Effects")),
-        # FIXME : Property editor disabled for 0.11.3 release, re-enable after
-        # (PropertyEditor, _("Properties")),
-    )
-
-    def __init__(self, instance, uiman):
+    def __init__(self):
         """ initialize """
         gtk.Notebook.__init__(self)
-        self.app = instance
-        self.uiman = uiman
-        self._full_list = []
-        self.connect("switch-page", self._switchPage)
+        self.connect("create-window", self._createWindowCb)
         self._createUi()
 
     def _createUi(self):
         """ set up the gui """
+        settings = self.get_settings()
+        settings.props.gtk_dnd_drag_threshold = 1
         self.set_tab_pos(gtk.POS_TOP)
-        for component, label in self.__DEFAULT_COMPONENTS__:
-            self.addComponent(component(self.app, self.uiman), label)
 
-    def addComponent(self, component, label):
-        self.append_page(component, DetachLabel(self, component, label))
-        self._full_list.append(component)
-
-    def windowizeComponent(self, component, label):
-        self.remove_page(self.page_num(component))
+    def append_page(self, child, label):
+        gtk.Notebook.append_page(self, child, label)
+        self.child_set_property(child, "detachable", True)
+
+    def _detachedComponentWindowDestroyCb(self, window, component,
+            original_position, label):
+        notebook = window.child
+        position = notebook.child_get_property(component, "position")
+        notebook.remove_page(position)
+        label = gtk.Label(label)
+        self.insert_page(component, label, original_position)
+        self.child_set_property(component, "detachable", True)
+
+    def _createWindowCb(self, from_notebook, component, x, y):
+        original_position = self.child_get_property(component, "position")
+        label = self.child_get_property(component, "tab-label")
         window = gtk.Window()
-        window.add(component)
-        window.show_all()
-        window.connect("destroy", self._replaceComponent, component, label)
-        window.resize(200, 200)
-        if not self.get_n_pages():
-            self.hide()
+        window.connect("destroy", self._detachedComponentWindowDestroyCb,
+                component, original_position, label)
+        notebook = gtk.Notebook()
+        window.add(notebook)
 
-    def _replaceComponent(self, window, component, label):
-        window.remove(component)
-        self.set_current_page(self.insert_page(component, label,
-            self._full_list.index(component)))
-        self.show()
+        window.show_all()
+        # set_uposition is deprecated but what should I use instead?
+        window.set_uposition(x, y)
 
-    def _switchPage(self, unused_widget, unused_page, num):
-        for child in (self.get_nth_page(i) for i in xrange(self.get_n_pages())):
-            self.get_tab_label(child).deselect()
-        cur = self.get_tab_label(self.get_nth_page(num))
-        cur.select()
+        return notebook



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