Merge lp:~dylanmccall/ubiquity/ubiquity-slideshow-quantal-beta-1 into lp:ubiquity

Proposed by Dylan McCall
Status: Merged
Merged at revision: 5604
Proposed branch: lp:~dylanmccall/ubiquity/ubiquity-slideshow-quantal-beta-1
Merge into: lp:ubiquity
Diff against target: 108 lines (+35/-32)
3 files modified
ubiquity/frontend/base.py (+13/-15)
ubiquity/frontend/gtk_ui.py (+12/-9)
ubiquity/frontend/kde_ui.py (+10/-8)
To merge this branch: bzr merge lp:~dylanmccall/ubiquity/ubiquity-slideshow-quantal-beta-1
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+119280@code.launchpad.net

Description of the change

This change brings Ubiquity in line with the upcoming changes to ubiquity-slideshow. It involves the following:

- Translations for ubiquity-slideshow are arranged differently now, and there's a funny hack in Ubiquity that looks up translations so it can correctly tell the slideshow whether text should flow right-to-left or left-to-right. It would be nice to actually remove that hack, but for the time being I just cleaned it up a little and made it use the new directory structure.

- New format for parameters sent to the slideshow, removing crazy and unnecessary '?' characters.

In addition, I cleaned up my code in some places, using os.path.join instead of hard-coded '/' characters where appropriate.

Old versions of ubiquity-slideshow will behave strangely with Ubiquity with this patch, and vice-versa. I'd like to get everything in place before beta 1 :)

To post a comment you must log in.
5586. By Dylan McCall

Tweaks to support ubiquity-slideshow's new file structure and parameter format (LP: #1035806)

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I did not test LTR/RTL.
I did test translations and they are ok.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubiquity/frontend/base.py'
2--- ubiquity/frontend/base.py 2012-07-16 14:29:13 +0000
3+++ ubiquity/frontend/base.py 2012-08-12 22:56:19 +0000
4@@ -437,24 +437,22 @@
5
6 def slideshow_get_available_locale(self, slideshow_dir, locale):
7 # Returns the ideal locale for the given slideshow, based on the
8- # given locale, or 'c' if an ideal one is not available.
9+ # given locale, or 'C' if an ideal one is not available.
10 # For example, with locale=en_CA, this returns en if en_CA is not
11 # available. If en is not available this would return c.
12
13- slides_dir = '%s/slides' % slideshow_dir
14- locale_choice = 'c'
15-
16- if os.path.exists('%s/loc.%s' % (slides_dir, locale)):
17- locale_choice = locale
18- else:
19- ll_cc = locale.split('.')[0]
20- ll = ll_cc.split('_')[0]
21- if os.path.exists('%s/loc.%s' % (slides_dir, ll_cc)):
22- locale_choice = ll_cc
23- elif os.path.exists('%s/loc.%s' % (slides_dir, ll)):
24- locale_choice = ll
25-
26- return locale_choice
27+ base_slides_dir = os.path.join(slideshow_dir, 'slides', 'l10n')
28+ extra_slides_dir = os.path.join(base_slides_dir, 'extra')
29+
30+ ll_cc = locale.split('.')[0]
31+ ll = ll_cc.split('_')[0]
32+
33+ for slides_dir in [extra_slides_dir, base_slides_dir]:
34+ for test_locale in [locale, ll_cc, ll]:
35+ locale_dir = os.path.join(slides_dir, test_locale)
36+ if os.path.exists(locale_dir):
37+ return test_locale
38+ return 'C'
39
40 def check_returncode(self, *args):
41 if self.wget_retcode is not None or self.wget_proc is None:
42
43=== modified file 'ubiquity/frontend/gtk_ui.py'
44--- ubiquity/frontend/gtk_ui.py 2012-07-16 14:29:13 +0000
45+++ ubiquity/frontend/gtk_ui.py 2012-08-12 22:56:19 +0000
46@@ -803,17 +803,20 @@
47 return
48
49 self.page_section.hide()
50+
51 slideshow_locale = self.slideshow_get_available_locale(
52 self.slideshow, self.locale)
53- slideshow_main = self.slideshow + '/slides/index.html'
54-
55- slides = 'file://' + slideshow_main
56- if slideshow_locale != 'c': # slideshow will use default automatically
57- slides += '#?locale=' + slideshow_locale
58- ltr = i18n.get_string(
59- 'default-ltr', slideshow_locale, 'ubiquity/imported')
60- if ltr == 'default:RTL':
61- slides += '?rtl'
62+ slideshow_main = os.path.join(self.slideshow, 'slides', 'index.html')
63+
64+ parameters = []
65+ parameters.append('locale=%s' % slideshow_locale)
66+ ltr = i18n.get_string(
67+ 'default-ltr', slideshow_locale, 'ubiquity/imported')
68+ if ltr == 'default:RTL':
69+ parameters.append('rtl')
70+ parameters_encoded = '&'.join(parameters)
71+
72+ slides = 'file://%s#%s' % (slideshow_main, parameters_encoded)
73
74 from gi.repository import WebKit
75 # We have no significant browsing interface, so there isn't much point
76
77=== modified file 'ubiquity/frontend/kde_ui.py'
78--- ubiquity/frontend/kde_ui.py 2012-07-16 14:29:13 +0000
79+++ ubiquity/frontend/kde_ui.py 2012-08-12 22:56:19 +0000
80@@ -568,18 +568,20 @@
81 slideshow_dir = '/usr/share/ubiquity-slideshow'
82 slideshow_locale = self.slideshow_get_available_locale(slideshow_dir,
83 self.locale)
84- slideshow_main = slideshow_dir + '/slides/index.html'
85+ slideshow_main = os.path.join(slideshow_dir, 'slides', 'index.html')
86 if not os.path.exists(slideshow_main) or self.hide_slideshow:
87 self.ui.pageMode.hide()
88 return
89
90- slides = 'file://' + slideshow_main
91- if slideshow_locale != 'c': # slideshow will use default automatically
92- slides += '#?locale=' + slideshow_locale
93- ltr = i18n.get_string('default-ltr', slideshow_locale,
94- 'ubiquity/imported')
95- if ltr == 'default:RTL':
96- slides += '?rtl'
97+ parameters = []
98+ parameters.append('locale=%s' % slideshow_locale)
99+ ltr = i18n.get_string(
100+ 'default-ltr', slideshow_locale, 'ubiquity/imported')
101+ if ltr == 'default:RTL':
102+ parameters.append('rtl')
103+ parameters_encoded = '&'.join(parameters)
104+
105+ slides = 'file://%s#%s' % (slideshow_main, parameters_encoded)
106
107 from PyQt4.QtWebKit import QWebView
108 from PyQt4.QtWebKit import QWebPage

Subscribers

People subscribed via source and target branches

to status/vote changes: