Merge lp:~laszlok/jokosher/main into lp:jokosher

Proposed by Laszlo Pandy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~laszlok/jokosher/main
Merge into: lp:jokosher
Diff against target: 142 lines (+70/-6)
4 files modified
Jokosher/Extension.py (+6/-1)
Jokosher/PlatformUtils/Unix.py (+7/-0)
Jokosher/ui/StatusBar.py (+35/-5)
extensions/Fullscreen.py (+22/-0)
To merge this branch: bzr merge lp:~laszlok/jokosher/main
Reviewer Review Type Date Requested Status
Jokosher Code Pending
Review via email: mp+17990@code.launchpad.net
To post a comment you must log in.
lp:~laszlok/jokosher/main updated
1193. By Laszlo Pandy

Fix unicode handling of paths.
This fix only changes the unix module. This same bug needs to be tested on Windows.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Jokosher/Extension.py'
2--- Jokosher/Extension.py 2009-05-29 00:49:54 +0000
3+++ Jokosher/Extension.py 2010-01-26 05:33:14 +0000
4@@ -145,6 +145,7 @@
5 mainapp -- reference the MainApp Jokosher window.
6 """
7 self.mainapp = mainapp
8+ self.jokosher = mainapp
9
10 self.CONFIGPATH = os.path.join(EXTENSION_DIR_USER, '../extension-config')
11 self.DATAPATH = os.path.join(EXTENSION_DIR_USER, '../extension-data')
12@@ -181,7 +182,11 @@
13 reference to the new menu item.
14 """
15 extensions_menu = self.mainapp.wTree.get_widget("extensionsmenu").get_submenu()
16- new_menu_item = gtk.MenuItem(menu_item_name)
17+ if isinstance(menu_item_name, gtk.MenuItem):
18+ new_menu_item = menu_item_name
19+ else:
20+ new_menu_item = gtk.MenuItem(menu_item_name)
21+
22 new_menu_item.connect("activate", callback_function)
23 extensions_menu.prepend(new_menu_item)
24 new_menu_item.show()
25
26=== modified file 'Jokosher/PlatformUtils/Unix.py'
27--- Jokosher/PlatformUtils/Unix.py 2009-03-19 23:39:14 +0000
28+++ Jokosher/PlatformUtils/Unix.py 2010-01-26 05:33:14 +0000
29@@ -23,6 +23,13 @@
30 return urllib.url2pathname(url)
31
32 def pathname2url(path):
33+ # urllib.pathname2url uses urllib.quote(), which cannot handle unicode.
34+ # See http://bugs.python.org/issue1712522 for details.
35+ # Basically its fixed in Python 3.0+ because all strings are utf8
36+ # and a safe assumption can be made. But here in Python 2.x urllib.quote()
37+ # expects *bytes* so we have to convert it explicitly.
38+ path = path.encode('utf8')
39+
40 return "file://%s" % urllib.pathname2url(path)
41
42 def GetRecordingDefaults():
43
44=== modified file 'Jokosher/ui/StatusBar.py'
45--- Jokosher/ui/StatusBar.py 2009-11-14 17:58:08 +0000
46+++ Jokosher/ui/StatusBar.py 2010-01-26 05:33:14 +0000
47@@ -10,6 +10,7 @@
48 #-------------------------------------------------------------------------------
49
50 import gtk
51+import pango
52
53 #=========================================================================
54
55@@ -24,9 +25,32 @@
56 Creates a new instance of StatusBar with no messages shown.
57 """
58 gtk.Statusbar.__init__(self)
59- # gtk.Statusbar contains a label inside a frame inside itself
60- self.label = self.get_children()[0].get_children()[0]
61- self.label.set_use_markup(True)
62+ # gtk.Statusbar contains a label somewhere inside itself
63+ self.label = self.get_label_in_hierarchy()
64+ if self.label:
65+ self.label.set_use_markup(True)
66+
67+ #_____________________________________________________________________
68+
69+ def get_label_in_hierarchy(self):
70+ """
71+ In Gtk+ 2.19 Statusbar was changed to keep a the Label inside an
72+ HBox inside a frame. In previous versions the Label was directly
73+ inside the frame.
74+
75+ Here we search the entire container hierarchy and hope it will
76+ continue to work even if another container is added in the
77+ future.
78+ """
79+ unchecked = [self]
80+ while unchecked:
81+ widget = unchecked.pop(0)
82+ if isinstance(widget, gtk.Label):
83+ return widget
84+ elif isinstance(widget, gtk.Container):
85+ unchecked.extend(widget.get_children())
86+
87+ return None
88
89 #_____________________________________________________________________
90
91@@ -40,8 +64,13 @@
92 Return:
93 the value of the next valid message ID.
94 """
95+ if not self.label:
96+ pango_attr_list, text_without_markup, accel_char = pango.parse_markup(message)
97+ message = text_without_markup
98+
99 message_id = self.push(0, message)
100- self.label.set_use_markup(True)
101+ if self.label:
102+ self.label.set_use_markup(True)
103 return message_id
104
105 #_____________________________________________________________________
106@@ -54,7 +83,8 @@
107 message_id -- numerical id of the message to be removed from the StatusBar.
108 """
109 self.remove_message(0, message_id)
110- self.label.set_use_markup(True)
111+ if self.label:
112+ self.label.set_use_markup(True)
113
114 #_____________________________________________________________________
115
116
117=== added file 'extensions/Fullscreen.py'
118--- extensions/Fullscreen.py 1970-01-01 00:00:00 +0000
119+++ extensions/Fullscreen.py 2010-01-26 05:33:14 +0000
120@@ -0,0 +1,22 @@
121+import Jokosher.Extension
122+import gtk
123+
124+EXTENSION_NAME = "Fullscreen"
125+EXTENSION_DESCRIPTION = "Make the Jokosher window fullscreen"
126+EXTENSION_VERSION = "1"
127+
128+API = None
129+
130+def do_fullscreen(menu_item):
131+ if menu_item.get_active():
132+ API.jokosher.window.fullscreen()
133+ else:
134+ API.jokosher.window.unfullscreen()
135+
136+def startup(api):
137+ global API
138+ API = api
139+ api.add_menu_item(gtk.CheckMenuItem("View fullscreen"), do_fullscreen)
140+
141+def shutdown():
142+ pass

Subscribers

People subscribed via source and target branches