2 # -*- coding: utf-8 -*-
6 # Copyright © 2013-2018 Antergos
8 # This file is part of Cnchi.
10 # Cnchi is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Cnchi is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # The following additional terms are in effect as per Section 7 of the license:
22 # The preservation of all legal notices and author attributions in
23 # the material or in the Appropriate Legal Notices displayed
24 # by works containing it is required.
26 # You should have received a copy of the GNU General Public License
27 # along with Cnchi; If not, see <http://www.gnu.org/licenses/>.
29 """ Welcome screen """
33 import multiprocessing
37 gi.require_version('GdkPixbuf', '2.0')
38 from gi.repository import GdkPixbuf
40 import misc.extra as misc
41 from pages.gtkbasebox import GtkBaseBox
43 # When testing, no _() is available
46 except NameError as err:
51 class Welcome(GtkBaseBox):
52 """ Welcome screen class """
54 def __init__(self, params, prev_page=None, next_page="language"):
55 super().__init__(self, params, "welcome", prev_page, next_page)
57 data_dir = self.settings.get('data')
58 welcome_dir = os.path.join(data_dir, "images", "welcome")
60 self.main_window = params['main_window']
62 self.labels = {'welcome': self.gui.get_object("welcome_label"),
63 'tryit': self.gui.get_object("tryit_welcome_label"),
64 'installit': self.gui.get_object("installit_welcome_label"),
65 'loading': self.gui.get_object("loading_label")}
67 self.buttons = {'tryit': self.gui.get_object("tryit_button"),
68 # 'cli': self.gui.get_object("cli_button"),
69 'graph': self.gui.get_object("graph_button")}
71 for key in self.buttons:
72 btn = self.buttons[key]
73 btn.set_name(key + "_btn")
75 self.images = {'tryit': self.gui.get_object("tryit_image"),
76 # 'cli': self.gui.get_object("cli_image"),
77 'graph': self.gui.get_object("graph_image")}
81 'path': os.path.join(welcome_dir, "try-it.svg"),
85 'path': os.path.join(welcome_dir, "install-it.svg"),
90 self.labels['tryit'].set_mnemonic_widget(self.buttons['tryit'])
91 self.labels['installit'].set_mnemonic_widget(self.buttons['graph'])
93 for key in self.images:
94 image = self.filenames[key]
95 pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
99 self.images[key].set_from_pixbuf(pixbuf)
101 def translate_ui(self):
102 """ Translates all ui elements """
103 if not self.no_tryit:
104 txt = _("Use RebornOS without making any changes to your system.")
107 self.labels['tryit'].set_markup(txt)
108 self.labels['tryit'].set_name('tryit_label')
110 txt = _("Create a permanent place for RebornOS on your system.")
111 self.labels['installit'].set_markup(txt)
112 self.labels['installit'].set_name('installit_label')
115 self.buttons['tryit'].set_label(txt)
117 # txt = _("CLI Installer")
118 # self.buttons['cli'].set_label(txt)
120 txt = _("Install It")
121 self.buttons['graph'].set_label(txt)
123 txt = _("Welcome to RebornOS!")
124 self.header.set_subtitle(txt)
126 def quit_cnchi(self):
127 """ Quits installer """
128 misc.remove_temp_files(self.settings.get('temp'))
129 for proc in multiprocessing.active_children():
134 def on_tryit_button_clicked(self, _widget, _data=None):
135 """ Try live CD, quits installer """
138 def on_graph_button_clicked(self, _widget, _data=None):
139 """ User wants to install """
140 self.show_loading_message()
141 # Tell timezone process to start searching now
142 self.settings.set('timezone_start', True)
143 # Simulate a forward button click
144 self.forward_button.clicked()
146 def show_loading_message(self, do_show=True):
147 """ Shows a message so the user knows Cnchi is loading pages
148 only when running from liveCD """
150 txt = _("Loading, please wait...")
153 self.labels['loading'].set_markup(txt)
154 self.labels['loading'].queue_draw()
157 def store_values(self):
158 """ Store changes (none in this page) """
159 self.forward_button.show()
162 def prepare(self, direction):
163 """ Prepare page before showing it """
166 self.forward_button.hide()
168 # a11y Set install option as default if ENTER is pressed
169 self.buttons['graph'].set_can_default(True)
170 self.main_window.set_default(self.buttons['graph'])
173 self.buttons['tryit'].set_sensitive(False)
174 if direction == "backwards":
175 self.show_loading_message(do_show=False)