Merge pull request #87 from matbme/main

Better internet connection error
main
Mirko Brombin 2 years ago committed by GitHub
commit d044c3e409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,8 +46,18 @@
<property name="halign">center</property> <property name="halign">center</property>
<property name="valign">center</property> <property name="valign">center</property>
<style> <style>
<class name="pill" /> <class name="pill"/>
<class name="suggested-action" /> <class name="suggested-action"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="btn_retry">
<property name="label">Retry</property>
<property name="halign">center</property>
<property name="visible">false</property>
<style>
<class name="pill"/>
</style> </style>
</object> </object>
</child> </child>
@ -57,8 +67,8 @@
<property name="halign">center</property> <property name="halign">center</property>
<property name="visible">false</property> <property name="visible">false</property>
<style> <style>
<class name="pill" /> <class name="pill"/>
<class name="suggested-action" /> <class name="suggested-action"/>
</style> </style>
</object> </object>
</child> </child>

@ -44,7 +44,7 @@ class Processor:
stderr=subprocess.DEVNULL) stderr=subprocess.DEVNULL)
if cn.returncode != 0: if cn.returncode != 0:
logger.critical("No internet connection") logger.critical("No internet connection")
return False, "No internet connection." return False, "No internet connection.", True
# nextBoot commands are collected in ~/.local/org.vanillaos.FirstSetup.nextBoot # nextBoot commands are collected in ~/.local/org.vanillaos.FirstSetup.nextBoot
# and executed at the next boot by a desktop entry # and executed at the next boot by a desktop entry

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import subprocess import subprocess
from sys import intern
from gi.repository import Gtk, Adw from gi.repository import Gtk, Adw
@ -24,6 +25,7 @@ class VanillaDone(Adw.Bin):
status_page = Gtk.Template.Child() status_page = Gtk.Template.Child()
btn_reboot = Gtk.Template.Child() btn_reboot = Gtk.Template.Child()
btn_retry = Gtk.Template.Child()
btn_close = Gtk.Template.Child() btn_close = Gtk.Template.Child()
log_box = Gtk.Template.Child() log_box = Gtk.Template.Child()
log_output = Gtk.Template.Child() log_output = Gtk.Template.Child()
@ -49,16 +51,29 @@ class VanillaDone(Adw.Bin):
else: else:
self.btn_reboot.set_visible(False) self.btn_reboot.set_visible(False)
self.btn_close.set_visible(True) self.btn_close.set_visible(True)
self.btn_close.connect("clicked", self.__on_close_clicked) self.btn_close.connect("clicked", self.__on_close_clicked)
self.btn_retry.connect("clicked", self.__on_retry_clicked)
def set_result(self, result): def set_result(self, result):
res, msg = result res, msg, *internet_fail = result
# Default to false if internet_fail wasn't passed with result
internet_fail = internet_fail[0] if len(internet_fail) > 0 else False
if res: if res:
return return
self.status_page.set_icon_name("dialog-error-symbolic") if internet_fail:
if not self.__fail_title and not self.__fail_description: self.status_page.set_icon_name("network-offline-symbolic")
else:
self.status_page.set_icon_name("dialog-error-symbolic")
if internet_fail:
self.status_page.set_title(_("No internet connection"))
self.status_page.set_description(_("Please ensure your system is connected to the internet and try again."))
self.log_box.set_visible(False)
elif not self.__fail_title and not self.__fail_description:
self.status_page.set_title(_("Something went wrong")) self.status_page.set_title(_("Something went wrong"))
self.status_page.set_description(_("Please contact the distribution developers.")) self.status_page.set_description(_("Please contact the distribution developers."))
self.log_box.set_visible(True) self.log_box.set_visible(True)
@ -67,11 +82,20 @@ class VanillaDone(Adw.Bin):
self.status_page.set_title(self.__fail_title) self.status_page.set_title(self.__fail_title)
self.status_page.set_description(self.__fail_description) self.status_page.set_description(self.__fail_description)
self.log_box.set_visible(False) self.log_box.set_visible(False)
self.btn_reboot.set_visible(False) self.btn_reboot.set_visible(False)
self.btn_close.set_visible(True) if internet_fail:
self.btn_retry.set_visible(True)
self.btn_close.set_visible(False)
else:
self.btn_retry.set_visible(False)
self.btn_close.set_visible(True)
def __on_reboot_clicked(self, button): def __on_reboot_clicked(self, button):
subprocess.run(['gnome-session-quit', '--reboot']) subprocess.run(['gnome-session-quit', '--reboot'])
def __on_close_clicked(self, button): def __on_close_clicked(self, button):
self.__window.close() self.__window.close()
def __on_retry_clicked(self, button):
self.__window.back()

Loading…
Cancel
Save