Merge lp:~matttbe/ubuntu/raring/alacarte/lp1086369 into lp:ubuntu/raring/alacarte

Proposed by Matthieu Baerts
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~matttbe/ubuntu/raring/alacarte/lp1086369
Merge into: lp:ubuntu/raring/alacarte
Diff against target: 272 lines (+215/-4)
6 files modified
.pc/applied-patches (+1/-0)
.pc/git_use_glib-gerror.patch/Alacarte/util.py (+174/-0)
Alacarte/util.py (+1/-4)
debian/changelog (+7/-0)
debian/patches/git_use_glib-gerror.patch (+31/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~matttbe/ubuntu/raring/alacarte/lp1086369
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+145762@code.launchpad.net

Description of the change

Hello,

This branch fixes the bug #1086369
Without this tiny modification (patch from upstream devs), it's not possible to launch Alacarte on Raring. I guess this bug can be considered as critical :)

Regards,

Matt

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the patch!

review: Approve
Revision history for this message
Matthieu Baerts (matttbe) wrote :

Thank you for your help! :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2012-11-08 12:07:16 +0000
3+++ .pc/applied-patches 2013-01-31 01:48:22 +0000
4@@ -2,3 +2,4 @@
5 30-python_private_dir.patch
6 40-call-exo-d-i-e-on-xfce.patch
7 50-xdg-menu-prefix.patch
8+git_use_glib-gerror.patch
9
10=== added directory '.pc/git_use_glib-gerror.patch'
11=== added directory '.pc/git_use_glib-gerror.patch/Alacarte'
12=== added file '.pc/git_use_glib-gerror.patch/Alacarte/util.py'
13--- .pc/git_use_glib-gerror.patch/Alacarte/util.py 1970-01-01 00:00:00 +0000
14+++ .pc/git_use_glib-gerror.patch/Alacarte/util.py 2013-01-31 01:48:22 +0000
15@@ -0,0 +1,174 @@
16+# -*- coding: utf-8 -*-
17+# Alacarte Menu Editor - Simple fd.o Compliant Menu Editor
18+# Copyright (C) 2006 Travis Watkins
19+#
20+# This library is free software; you can redistribute it and/or
21+# modify it under the terms of the GNU Library General Public
22+# License as published by the Free Software Foundation; either
23+# version 2 of the License, or (at your option) any later version.
24+#
25+# This library is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28+# Library General Public License for more details.
29+#
30+# You should have received a copy of the GNU Library General Public
31+# License along with this library; if not, write to the Free Software
32+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33+
34+import os
35+import xml.dom.minidom
36+from collections import Sequence
37+from gi.repository import Gtk, GdkPixbuf, GMenu, GLib
38+
39+# XXX: look into pygobject error marshalling
40+from gi._glib import GError
41+
42+DESKTOP_GROUP = GLib.KEY_FILE_DESKTOP_GROUP
43+KEY_FILE_FLAGS = GLib.KeyFileFlags.KEEP_COMMENTS | GLib.KeyFileFlags.KEEP_TRANSLATIONS
44+
45+def fillKeyFile(keyfile, items):
46+ for key, item in items.iteritems():
47+ if item is None:
48+ continue
49+
50+ if isinstance(item, bool):
51+ keyfile.set_boolean(DESKTOP_GROUP, key, item)
52+ elif isinstance(item, Sequence):
53+ keyfile.set_string_list(DESKTOP_GROUP, key, item)
54+ elif isinstance(item, basestring):
55+ keyfile.set_string(DESKTOP_GROUP, key, item)
56+
57+def getUniqueFileId(name, extension):
58+ append = 0
59+ while 1:
60+ if append == 0:
61+ filename = name + extension
62+ else:
63+ filename = name + '-' + str(append) + extension
64+ if extension == '.desktop':
65+ path = getUserItemPath()
66+ if not os.path.isfile(os.path.join(path, filename)) and not getItemPath(filename):
67+ break
68+ elif extension == '.directory':
69+ path = getUserDirectoryPath()
70+ if not os.path.isfile(os.path.join(path, filename)) and not getDirectoryPath(filename):
71+ break
72+ append += 1
73+ return filename
74+
75+def getUniqueRedoFile(filepath):
76+ append = 0
77+ while 1:
78+ new_filepath = filepath + '.redo-' + str(append)
79+ if not os.path.isfile(new_filepath):
80+ break
81+ else:
82+ append += 1
83+ return new_filepath
84+
85+def getUniqueUndoFile(filepath):
86+ filename, extension = os.path.split(filepath)[1].rsplit('.', 1)
87+ append = 0
88+ while 1:
89+ if extension == 'desktop':
90+ path = getUserItemPath()
91+ elif extension == 'directory':
92+ path = getUserDirectoryPath()
93+ elif extension == 'menu':
94+ path = getUserMenuPath()
95+ new_filepath = os.path.join(path, filename + '.' + extension + '.undo-' + str(append))
96+ if not os.path.isfile(new_filepath):
97+ break
98+ else:
99+ append += 1
100+ return new_filepath
101+
102+def getItemPath(file_id):
103+ for path in GLib.get_system_data_dirs():
104+ file_path = os.path.join(path, 'applications', file_id)
105+ if os.path.isfile(file_path):
106+ return file_path
107+ return None
108+
109+def getUserItemPath():
110+ item_dir = os.path.join(GLib.get_user_data_dir(), 'applications')
111+ if not os.path.isdir(item_dir):
112+ os.makedirs(item_dir)
113+ return item_dir
114+
115+def getDirectoryPath(file_id):
116+ for path in GLib.get_system_data_dirs():
117+ file_path = os.path.join(path, 'desktop-directories', file_id)
118+ if os.path.isfile(file_path):
119+ return file_path
120+ return None
121+
122+def getUserDirectoryPath():
123+ menu_dir = os.path.join(GLib.get_user_data_dir(), 'desktop-directories')
124+ if not os.path.isdir(menu_dir):
125+ os.makedirs(menu_dir)
126+ return menu_dir
127+
128+def getUserMenuPath():
129+ menu_dir = os.path.join(GLib.get_user_config_dir(), 'menus')
130+ if not os.path.isdir(menu_dir):
131+ os.makedirs(menu_dir)
132+ return menu_dir
133+
134+def getSystemMenuPath(file_id):
135+ for path in GLib.get_system_config_dirs():
136+ file_path = os.path.join(path, 'menus', file_id)
137+ if os.path.isfile(file_path):
138+ return file_path
139+ return None
140+
141+def getUserMenuXml(tree):
142+ system_file = getSystemMenuPath(os.path.basename(tree.get_canonical_menu_path()))
143+ name = tree.get_root_directory().get_menu_id()
144+ menu_xml = "<!DOCTYPE Menu PUBLIC '-//freedesktop//DTD Menu 1.0//EN' 'http://standards.freedesktop.org/menu-spec/menu-1.0.dtd'>\n"
145+ menu_xml += "<Menu>\n <Name>" + name + "</Name>\n "
146+ menu_xml += "<MergeFile type=\"parent\">" + system_file + "</MergeFile>\n</Menu>\n"
147+ return menu_xml
148+
149+def getIcon(item):
150+ pixbuf = None
151+ if item is None:
152+ return None
153+
154+ if isinstance(item, GMenu.TreeDirectory):
155+ gicon = item.get_icon()
156+ elif isinstance(item, GMenu.TreeEntry):
157+ app_info = item.get_app_info()
158+ gicon = app_info.get_icon()
159+ else:
160+ return None
161+
162+ if gicon is None:
163+ return None
164+
165+ icon_theme = Gtk.IconTheme.get_default()
166+ info = icon_theme.lookup_by_gicon(gicon, 24, 0)
167+ if info is None:
168+ return None
169+ try:
170+ pixbuf = info.load_icon()
171+ except GError:
172+ return None
173+ if pixbuf is None:
174+ return None
175+ if pixbuf.get_width() != 24 or pixbuf.get_height() != 24:
176+ pixbuf = pixbuf.scale_simple(24, 24, GdkPixbuf.InterpType.HYPER)
177+ return pixbuf
178+
179+def removeWhitespaceNodes(node):
180+ remove_list = []
181+ for child in node.childNodes:
182+ if child.nodeType == xml.dom.minidom.Node.TEXT_NODE:
183+ child.data = child.data.strip()
184+ if not child.data.strip():
185+ remove_list.append(child)
186+ elif child.hasChildNodes():
187+ removeWhitespaceNodes(child)
188+ for node in remove_list:
189+ node.parentNode.removeChild(node)
190
191=== modified file 'Alacarte/util.py'
192--- Alacarte/util.py 2012-06-25 11:56:36 +0000
193+++ Alacarte/util.py 2013-01-31 01:48:22 +0000
194@@ -21,9 +21,6 @@
195 from collections import Sequence
196 from gi.repository import Gtk, GdkPixbuf, GMenu, GLib
197
198-# XXX: look into pygobject error marshalling
199-from gi._glib import GError
200-
201 DESKTOP_GROUP = GLib.KEY_FILE_DESKTOP_GROUP
202 KEY_FILE_FLAGS = GLib.KeyFileFlags.KEEP_COMMENTS | GLib.KeyFileFlags.KEEP_TRANSLATIONS
203
204@@ -153,7 +150,7 @@
205 return None
206 try:
207 pixbuf = info.load_icon()
208- except GError:
209+ except GLib.GError:
210 return None
211 if pixbuf is None:
212 return None
213
214=== modified file 'debian/changelog'
215--- debian/changelog 2012-11-08 12:07:16 +0000
216+++ debian/changelog 2013-01-31 01:48:22 +0000
217@@ -1,3 +1,10 @@
218+alacarte (3.6.1-0ubuntu3) raring; urgency=low
219+
220+ * debian/patches/git_use_glib-gerror.patch:
221+ - Use GLib.GError for catching errors (LP: #1086369)
222+
223+ -- Matthieu Baerts (matttbe) <matttbe@ubuntu.com> Thu, 31 Jan 2013 02:38:20 +0100
224+
225 alacarte (3.6.1-0ubuntu2) raring; urgency=low
226
227 * debian/patches/50-xdg-menu-prefix.patch:
228
229=== added file 'debian/patches/git_use_glib-gerror.patch'
230--- debian/patches/git_use_glib-gerror.patch 1970-01-01 00:00:00 +0000
231+++ debian/patches/git_use_glib-gerror.patch 2013-01-31 01:48:22 +0000
232@@ -0,0 +1,31 @@
233+From 2f2e0b0bac463f545f409c67f1a15f5bf672529f Mon Sep 17 00:00:00 2001
234+From: Jasper St. Pierre <jstpierre@mecheye.net>
235+Date: Wed, 16 Jan 2013 15:55:43 +0000
236+Subject: Use GLib.Error for catching errors
237+
238+While gi._glib.GError works on my machine, it seems it's on track
239+to be removed, or doesn't work on some PyGObject builds.
240+---
241+Index: alacarte/Alacarte/util.py
242+===================================================================
243+--- alacarte.orig/Alacarte/util.py 2013-01-31 02:34:04.466464660 +0100
244++++ alacarte/Alacarte/util.py 2013-01-31 02:34:04.422464661 +0100
245+@@ -21,9 +21,6 @@
246+ from collections import Sequence
247+ from gi.repository import Gtk, GdkPixbuf, GMenu, GLib
248+
249+-# XXX: look into pygobject error marshalling
250+-from gi._glib import GError
251+-
252+ DESKTOP_GROUP = GLib.KEY_FILE_DESKTOP_GROUP
253+ KEY_FILE_FLAGS = GLib.KeyFileFlags.KEEP_COMMENTS | GLib.KeyFileFlags.KEEP_TRANSLATIONS
254+
255+@@ -153,7 +150,7 @@
256+ return None
257+ try:
258+ pixbuf = info.load_icon()
259+- except GError:
260++ except GLib.GError:
261+ return None
262+ if pixbuf is None:
263+ return None
264
265=== modified file 'debian/patches/series'
266--- debian/patches/series 2012-11-08 12:07:16 +0000
267+++ debian/patches/series 2013-01-31 01:48:22 +0000
268@@ -2,3 +2,4 @@
269 30-python_private_dir.patch
270 40-call-exo-d-i-e-on-xfce.patch
271 50-xdg-menu-prefix.patch
272+git_use_glib-gerror.patch

Subscribers

People subscribed via source and target branches