[pitivi] overlay: Show error when cursor is not found.



commit 11f72171a82e8576528f26cf79d216324b560369
Author: Lubosz Sarnecki <lubosz sarnecki collabora co uk>
Date:   Sat Apr 30 16:51:47 2016 +0200

    overlay: Show error when cursor is not found.
    
    Lookup all cursors by names as the Gdk.CursorType doc says:
    "The recommended way to create cursors is to use Gdk.Cursor.new_from_name()".
    
    Fixes https://phabricator.freedesktop.org/T7377
    
    Differential Revision: https://phabricator.freedesktop.org/D922

 pitivi/viewer/move_scale_overlay.py |   16 ++++++++--------
 pitivi/viewer/overlay_stack.py      |   11 +++++++----
 2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/pitivi/viewer/move_scale_overlay.py b/pitivi/viewer/move_scale_overlay.py
index afe222e..a953053 100644
--- a/pitivi/viewer/move_scale_overlay.py
+++ b/pitivi/viewer/move_scale_overlay.py
@@ -43,14 +43,14 @@ class Handle:
     INITIAL_RADIUS = 15
     MINIMAL_RADIUS = 5
     CURSORS = {
-        (Edge.top, Edge.left): Gdk.CursorType.TOP_LEFT_CORNER,
-        (Edge.bottom, Edge.left): Gdk.CursorType.BOTTOM_LEFT_CORNER,
-        (Edge.bottom, Edge.right): Gdk.CursorType.BOTTOM_RIGHT_CORNER,
-        (Edge.top, Edge.right): Gdk.CursorType.TOP_RIGHT_CORNER,
-        (Edge.top,): Gdk.CursorType.TOP_SIDE,
-        (Edge.bottom,): Gdk.CursorType.BOTTOM_SIDE,
-        (Edge.left,): Gdk.CursorType.LEFT_SIDE,
-        (Edge.right,): Gdk.CursorType.RIGHT_SIDE
+        (Edge.top, Edge.left): "nw-resize",
+        (Edge.bottom, Edge.left): "sw-resize",
+        (Edge.bottom, Edge.right): "se-resize",
+        (Edge.top, Edge.right): "ne-resize",
+        (Edge.top,): "n-resize",
+        (Edge.bottom,): "s-resize",
+        (Edge.left,): "w-resize",
+        (Edge.right,): "e-resize"
     }
 
     def __init__(self, overlay):
diff --git a/pitivi/viewer/overlay_stack.py b/pitivi/viewer/overlay_stack.py
index 962515f..ac9e3b8 100644
--- a/pitivi/viewer/overlay_stack.py
+++ b/pitivi/viewer/overlay_stack.py
@@ -26,11 +26,13 @@ from gi.repository import Gtk
 
 from pitivi.viewer.move_scale_overlay import MoveScaleOverlay
 from pitivi.viewer.title_overlay import TitleOverlay
+from pitivi.utils.loggable import Loggable
 
 
-class OverlayStack(Gtk.Overlay):
+class OverlayStack(Gtk.Overlay, Loggable):
     def __init__(self, app, sink_widget):
         Gtk.Overlay.__init__(self)
+        Loggable.__init__(self)
         self.__overlays = {}
         self.__visible_overlays = []
         self.app = app
@@ -136,11 +138,12 @@ class OverlayStack(Gtk.Overlay):
         self.selected_overlay.queue_draw()
 
     def set_cursor(self, name):
+        cursor = None
         display = Gdk.Display.get_default()
-        if isinstance(name, Gdk.CursorType):
-            cursor = Gdk.Cursor.new_for_display(display, name)
-        else:
+        try:
             cursor = Gdk.Cursor.new_from_name(display, name)
+        except TypeError:
+            self.warning ("Cursor '%s' not found.", name)
         self.app.gui.get_window().set_cursor(cursor)
 
     def reset_cursor(self):


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