[pitivi] tabsmanager: Save/restore settings from detached tabs
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] tabsmanager: Save/restore settings from detached tabs
- Date: Thu, 8 Nov 2012 21:57:39 +0000 (UTC)
commit a4c367431d3ced3f741f293f90c8d8228cea0c10
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Tue Nov 6 12:06:24 2012 -0500
tabsmanager: Save/restore settings from detached tabs
For some reason, everything resets to defaults on startup.
First steps towards fixing bug #578672
pitivi/tabsmanager.py | 52 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 41 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/tabsmanager.py b/pitivi/tabsmanager.py
index bcc4257..f330928 100644
--- a/pitivi/tabsmanager.py
+++ b/pitivi/tabsmanager.py
@@ -31,10 +31,12 @@ class BaseTabs(Gtk.Notebook):
self.set_border_width(SPACING)
self.set_scrollable(True)
self.connect("create-window", self._createWindowCb)
- settings = self.get_settings()
- settings.props.gtk_dnd_drag_threshold = 1
+ self.settings = app.settings # To save/restore states of detached tabs
+ notebook_widget_settings = self.get_settings()
+ notebook_widget_settings.props.gtk_dnd_drag_threshold = 1
def append_page(self, child, label):
+ child_name = label.get_text()
Gtk.Notebook.append_page(self, child, label)
self._set_child_properties(child, label)
child.show()
@@ -42,6 +44,8 @@ class BaseTabs(Gtk.Notebook):
try:
docked = getattr(self.settings, child_name + "Docked")
+ if not docked:
+ self.createWindow(child)
except AttributeError:
# Create the default config ONLY if keys don't already exist
self._createDefaultConfig(child_name)
@@ -52,12 +56,15 @@ class BaseTabs(Gtk.Notebook):
self.child_set_property(child, "tab-fill", True)
label.props.xalign = 0.0
- def _detachedWindowDestroyCb(self, window, page, orig_pos, label):
- # We assume there's only one notebook and one tab per utility window
- notebook = window.get_children()[0]
- notebook.remove_page(0)
- self.insert_page(page, label, orig_pos)
- self._set_child_properties(page, label)
+ def _detachedComponentWindowDestroyCb(self, window, child,
+ original_position, child_name):
+ notebook = window.get_child()
+ position = notebook.page_num(child)
+ notebook.remove_page(position)
+ setattr(self.settings, child_name + "Docked", True)
+ label = Gtk.Label(child_name)
+ self.insert_page(child, label, original_position)
+ self._set_child_properties(child, label)
def _createWindowCb(self, from_notebook, child, unused_x, unused_y):
"""
@@ -78,17 +85,40 @@ class BaseTabs(Gtk.Notebook):
child_name = self.get_tab_label(child).get_text()
window = Gtk.Window()
window.set_type_hint(Gdk.WindowTypeHint.UTILITY)
- window.set_default_size(600, 400)
- window.connect("destroy", self._detachedWindowDestroyCb,
- page, original_position, label)
window.set_title(child_name)
+
+ # Get the previous window state settings
+ width = getattr(self.settings, child_name + "Width")
+ height = getattr(self.settings, child_name + "Height")
+ x = getattr(self.settings, child_name + "X")
+ y = getattr(self.settings, child_name + "Y")
+
+ # Save the fact that the window is now detached
+ setattr(self.settings, child_name + "Docked", False)
+
+ window.set_default_size(width, height)
notebook = Gtk.Notebook()
notebook.props.show_tabs = False
window.add(notebook)
window.show_all()
window.move(x, y)
+ window.connect("configure-event", self._detachedComponentWindowConfiguredCb, child_name)
+ window.connect("destroy", self._detachedComponentWindowDestroyCb, child,
+ original_position, child_name)
return notebook
+ def _detachedComponentWindowConfiguredCb(self, window, event, child_name):
+ """
+ When the user configures the detached window
+ (changes its size, position, etc.), save the settings.
+
+ The config key's name depends on the name (label) of the tab widget.
+ """
+ setattr(self.settings, child_name + "Width", event.width)
+ setattr(self.settings, child_name + "Height", event.height)
+ setattr(self.settings, child_name + "X", event.x)
+ setattr(self.settings, child_name + "Y", event.y)
+
def _createDefaultConfig(self, child_name):
"""
If they do not exist already, create default settings
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]