Shares most of the code with WelcomeLanguageSpoke and transfers the selection ListView and label between the two display variants as needed. --- pyanaconda/ui/gui/spokes/welcome.py | 110 +++++++++++++++++++++++++++++------ pyanaconda/ui/gui/spokes/welcome.ui | 63 +++++++++++++++++++- 2 files changed, 153 insertions(+), 20 deletions(-) diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py index b80ccb9..741d291 100644 --- a/pyanaconda/ui/gui/spokes/welcome.py +++ b/pyanaconda/ui/gui/spokes/welcome.py @@ -23,33 +23,34 @@ import sys import gettext _ = lambda x: gettext.ldgettext("anaconda", x) +N_ = lambda x: x from gi.repository import AnacondaWidgets, Gtk from pyanaconda.ui.gui.hubs.summary import SummaryHub -from pyanaconda.ui.gui.spokes import StandaloneSpoke +from pyanaconda.ui.gui.spokes import StandaloneSpoke, NormalSpoke from pyanaconda.ui.gui.utils import enlightbox +from pyanaconda.ui.gui.categories.localization import LocalizationCategory from pyanaconda.localization import Language, LOCALE_PREFERENCES from pyanaconda.product import productName, productVersion from pyanaconda import xklavier from pyanaconda import localization -__all__ = ["WelcomeLanguageSpoke"] +__all__ = ["WelcomeLanguageSpoke", "LanguageSpoke"] -class WelcomeLanguageSpoke(StandaloneSpoke): - mainWidgetName = "welcomeWindow" - uiFile = "spokes/welcome.ui" - - preForHub = SummaryHub - priority = 0 +class LanguageMixIn(object): + builderObjects = ["languageStore"] - def __init__(self, *args): - StandaloneSpoke.__init__(self, *args) + def __init__(self, labelName = "welcomeLabel", + viewName = "languageView", selectionName = "languageViewSelection"): self._xklwrapper = xklavier.XklWrapper.get_instance() self._origStrings = {} + self._labelName = labelName + self._viewName = viewName + self._selectionName = selectionName def apply(self): - selected = self.builder.get_object("languageViewSelection") + selected = self.builder.get_object(self._selectionName) (store, itr) = selected.get_selected() lang = store[itr][2] @@ -87,8 +88,6 @@ class WelcomeLanguageSpoke(StandaloneSpoke): return self.data.lang.lang and self.data.lang.lang != "" def initialize(self): - StandaloneSpoke.initialize(self) - store = self.builder.get_object("languageStore") # TODO We can use the territory from geoip here @@ -106,8 +105,7 @@ class WelcomeLanguageSpoke(StandaloneSpoke): self._selectLanguage(store, self.language.preferred_translation.short_name) def retranslate(self): - StandaloneSpoke.retranslate(self) - welcomeLabel = self.builder.get_object("welcomeLabel") + welcomeLabel = self.builder.get_object(self._labelName) if not welcomeLabel in self._origStrings: self._origStrings[welcomeLabel] = welcomeLabel.get_label() @@ -116,11 +114,25 @@ class WelcomeLanguageSpoke(StandaloneSpoke): xlated = _(before) % (productName.upper(), productVersion) welcomeLabel.set_label(xlated) - def refresh(self): - StandaloneSpoke.refresh(self) + def refresh(self, displayArea): store = self.builder.get_object("languageStore") self._selectLanguage(store, self.data.lang.lang) + # Rip the label and language selection window + # from where it is right now and add it to this + # spoke. + # This way we can share the dialog and code + # between Welcome and Language spokes + langList = self.builder.get_object("languageWindow") + langList.get_parent().remove(langList) + langLabel = self.builder.get_object("pickLanguageLabel") + langLabel.get_parent().remove(langLabel) + + content = self.builder.get_object(displayArea) + content.pack_start(child = langLabel, fill = True, expand = False, padding = 0) + content.pack_start(child = langList, fill = True, expand = True, padding = 0) + + def _addLanguage(self, store, native, english, setting): store.append([native, english, setting]) @@ -133,7 +145,7 @@ class WelcomeLanguageSpoke(StandaloneSpoke): if not itr: return - treeview = self.builder.get_object("languageView") + treeview = self.builder.get_object(self._viewName) selection = treeview.get_selection() selection.select_iter(itr) path = store.get_path(itr) @@ -142,7 +154,8 @@ class WelcomeLanguageSpoke(StandaloneSpoke): # Signal handlers. def on_selection_changed(self, selection): (store, selected) = selection.get_selected_rows() - self.window.set_may_continue(len(selected) > 0) + if hasattr(self.window, "set_may_continue"): + self.window.set_may_continue(len(selected) > 0) if selected: lang = store[selected[0]][2] @@ -150,6 +163,27 @@ class WelcomeLanguageSpoke(StandaloneSpoke): self.language.set_system_lang(lang) self.retranslate() + +class WelcomeLanguageSpoke(LanguageMixIn, StandaloneSpoke): + mainWidgetName = "welcomeWindow" + uiFile = "spokes/welcome.ui" + builderObjects = LanguageMixIn.builderObjects + [mainWidgetName, "betaWarnDialog"] + + preForHub = SummaryHub + priority = 0 + + def __init__(self, *args): + StandaloneSpoke.__init__(self, *args) + LanguageMixIn.__init__(self) + + def retranslate(self): + StandaloneSpoke.retranslate(self) + LanguageMixIn.retranslate(self) + + def refresh(self): + StandaloneSpoke.refresh(self) + LanguageMixIn.refresh(self, "welcomeWindowContentBox") + # Override the default in StandaloneSpoke so we can display the beta # warning dialog first. def _on_continue_clicked(self, cb): @@ -163,3 +197,41 @@ class WelcomeLanguageSpoke(StandaloneSpoke): sys.exit(0) else: StandaloneSpoke._on_continue_clicked(self, cb) + + +class LanguageSpoke(LanguageMixIn, NormalSpoke): + mainWidgetName = "languageSpokeWindow" + uiFile = "spokes/welcome.ui" + builderObjects = LanguageMixIn.builderObjects + [mainWidgetName, WelcomeLanguageSpoke.mainWidgetName] + + category = LocalizationCategory + + icon = "accessories-character-map-symbolic" + title = N_("LANGUAGE") + + + def __init__(self, *args): + NormalSpoke.__init__(self, *args) + LanguageMixIn.__init__(self) + + def retranslate(self): + print "retranslate" + NormalSpoke.retranslate(self) + LanguageMixIn.retranslate(self) + + def refresh(self): + NormalSpoke.refresh(self) + LanguageMixIn.refresh(self, "languageSpokeWindowContentBox") + + @property + def completed(self): + # The language spoke is always completed, as it does not require you do + # anything. There's always a default selected. + return True + + @property + def status(self): + selected = self.builder.get_object(self._selectionName) + (store, itr) = selected.get_selected() + + return store[itr][0] diff --git a/pyanaconda/ui/gui/spokes/welcome.ui b/pyanaconda/ui/gui/spokes/welcome.ui index 0d64ffc..655f9f7 100644 --- a/pyanaconda/ui/gui/spokes/welcome.ui +++ b/pyanaconda/ui/gui/spokes/welcome.ui @@ -119,6 +119,15 @@ OS you can rely on. It's for testing purposes only.</property> <child> <placeholder/> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">True</property> @@ -133,6 +142,58 @@ OS you can rely on. It's for testing purposes only.</property> <action-widget response="1">continueButton</action-widget> </action-widgets> </object> + <object class="AnacondaSpokeWindow" id="languageSpokeWindow"> + <property name="startup_id">filler</property> + <property name="can_focus">False</property> + <property name="startup_id">filler</property> + <signal name="back-clicked" handler="on_back_clicked" swapped="no"/> + <child internal-child="main_box"> + <object class="GtkBox" id="AnacondaSpokeWindow-main_box1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child internal-child="nav_area"> + <object class="GtkGrid" id="AnacondaSpokeWindow-nav_area1"> + <property name="can_focus">False</property> + <property name="margin_left">6</property> + <property name="margin_right">6</property> + <property name="margin_top">6</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child internal-child="alignment"> + <object class="GtkAlignment" id="AnacondaSpokeWindow-alignment1"> + <property name="can_focus">False</property> + <property name="yalign">0</property> + <property name="xscale">0</property> + <property name="yscale">0.5</property> + <child internal-child="action_area"> + <object class="GtkBox" id="languageSpokeWindowContentBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <placeholder/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + </object> <object class="GtkListStore" id="languageStore"> <columns> <!-- column-name nativeName --> @@ -174,7 +235,7 @@ OS you can rely on. It's for testing purposes only.</property> <property name="xscale">0</property> <property name="yscale">0.5</property> <child internal-child="action_area"> - <object class="GtkBox" id="welcomeWindow-actionArea"> + <object class="GtkBox" id="welcomeWindowContentBox"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">6</property> -- 1.7.10.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list