[pitivi] Better keyboard handling in effectlist and clipproperties



commit 713c18e890d843c365324ae59e9db5bb3f0cb6dc
Author: Thibault Saunier <tsaunier gnome org>
Date:   Wed Jul 14 10:46:34 2010 -0400

    Better keyboard handling in effectlist and clipproperties

 pitivi/ui/clipproperties.py |    6 +++++-
 pitivi/ui/effectlist.py     |    9 +++++++++
 pitivi/ui/mainwindow.py     |   26 +++++++++++++++++++++++---
 3 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/ui/clipproperties.py b/pitivi/ui/clipproperties.py
index 7f3c8fe..ba6def7 100644
--- a/pitivi/ui/clipproperties.py
+++ b/pitivi/ui/clipproperties.py
@@ -315,7 +315,11 @@ class EffectProperties(gtk.Expander):
         self.explain_label.show()
 
     def _treeviewSelectionChangedCb(self, treeview):
-        print "Selection changed"
+        if self.selection.count_selected_rows() == 0 and self.timeline_object:
+                self.app.gui.setActionsSensitive(['DeleteObj'], True)
+        else:
+            self.app.gui.setActionsSensitive(['DeleteObj'], False)
+
         self._updateEffectConfigUi()
 
     def _updateEffectConfigUi(self):
diff --git a/pitivi/ui/effectlist.py b/pitivi/ui/effectlist.py
index fecae4e..f35a4de 100644
--- a/pitivi/ui/effectlist.py
+++ b/pitivi/ui/effectlist.py
@@ -135,6 +135,8 @@ class EffectList(gtk.VBox, Loggable):
         self.effectCategory.connect ("changed", self._effectCategoryChangedCb)
 
         self.searchEntry.connect ("changed", self.searchEntryChangedCb)
+        self.searchEntry.connect ("button-press-event", self.searchEntryActivateCb)
+        self.searchEntry.connect ("focus-out-event", self.searchEntryDesactvateCb)
         self.searchEntry.connect ("icon-press", self.searchEntryIconClickedCb)
 
         self.treeview.connect("button-press-event", self._treeViewButtonPressEventCb)
@@ -312,11 +314,18 @@ class EffectList(gtk.VBox, Loggable):
         self.modelFilter.refilter()
 
     def searchEntryChangedCb (self, entry):
+        self.searchEntry.grab_focus()
         self.modelFilter.refilter()
 
     def searchEntryIconClickedCb (self, entry, unused, unsed1):
         entry.set_text("")
 
+    def searchEntryDesactvateCb(self, entry, event):
+        self.app.gui.setShortcutsSensitive(['FullScreen', 'Split',], True)
+
+    def searchEntryActivateCb(self, entry, event):
+        self.app.gui.setShortcutsSensitive(['FullScreen', 'Split',], False)
+
     def _setRowVisible(self, model, iter, data):
         if self.effectType.get_active() == model.get_value(iter, COL_EFFECT_TYPE):
             if model.get_value(iter, COL_EFFECT_CATEGORIES) is None:
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 7b8d6e1..f987cc1 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -265,7 +265,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
             ("SaveProjectAs", gtk.STOCK_SAVE_AS, None,
              None, _("Save the current project"), self._saveProjectAsCb),
             ("RevertToSavedProject", gtk.STOCK_REVERT_TO_SAVED, None,
-             None, _("Reload the current project"), self._revertToSavedProjectCb),             
+             None, _("Reload the current project"), self._revertToSavedProjectCb),
             ("ProjectSettings", gtk.STOCK_PROPERTIES, _("Project Settings"),
              None, _("Edit the project settings"), self._projectSettingsCb),
             ("RenderProject", 'pitivi-render' , _("_Render project"),
@@ -504,8 +504,28 @@ class PitiviMainWindow(gtk.Window, Loggable):
             self.viewer.window.unfullscreen()
             self.is_fullscreen = False
 
-## PlayGround callback
+    #TODO check if it is the way to go
+    def setActionsSensitive(self, action_names, sensitive):
+        """
+        Permit to get the focus for the keyboard letter keys
+        for other operation as typing text in an entry, or loose it
+        @param action_names: The name of actions we
+                             want to set to sensitive or not
+        @type action_names: A {list} of action names
+        @param sensitiive: %True if actions must be sensitive False otherwise
+        @type action_names: C{Bool}
+        """
+        for action in self.actiongroup.list_actions():
+            if action.get_name() in action_names:
+                action.set_sensitive(sensitive)
+
+        if self.timeline:
+            for action_group in self.timeline.ui_manager.get_action_groups():
+                for action in action_group.list_actions():
+                    if action.get_name() in action_names:
+                        action.set_sensitive(sensitive)
 
+## PlayGround callback
     def _windowizeViewer(self, button, pane):
         # FIXME: the viewer can't seem to handle being unparented/reparented
         pane.remove(self.viewer)
@@ -866,7 +886,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
                                         gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_YES)
             dialog.set_title(_("Revert to saved project"))
             dialog.set_resizable(False)
-            dialog.set_property("secondary-text", 
+            dialog.set_property("secondary-text",
                                             _("All unsaved changes will be lost.")
                                         )
             dialog.set_default_response(gtk.RESPONSE_NO)



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