Verified Commit a536a433 authored by Todd Weaver's avatar Todd Weaver
Browse files

Adding initial error handling screen

parent 32ded0c2
......@@ -63,11 +63,14 @@ class Search:
try:
results = urllib.request.urlopen(url, timeout=5)
except (urllib.error.HTTPError, timeout):
self.app_window.error_box.set_visible(True)
self.app_window.error_heading.set_label("Service Failure")
self.app_window.error_text.set_label("There is no response from the streaming servers.")
print("URL did not respond")
try:
self.json = json.loads(results.read())
except UnboundLocalError:
except:
print("json did not load from url results")
self.get_poster_url()
......
......@@ -36,6 +36,8 @@
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="resource">/sm/puri/Stream/ui/video-placeholder-332x186.png</property>
</object>
<packing>
......@@ -239,7 +241,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">1x</property>
<property name="label">1x</property>
<property name="justify">center</property>
<attributes>
<attribute name="weight" value="bold"/>
......@@ -377,7 +379,7 @@
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">...</property>
<property name="label">...</property>
<property name="ellipsize">end</property>
<attributes>
<attribute name="weight" value="bold"/>
......@@ -400,7 +402,7 @@
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">...</property>
<property name="label">...</property>
<property name="ellipsize">end</property>
</object>
<packing>
......@@ -414,7 +416,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">...</property>
<property name="label">...</property>
<property name="justify">right</property>
<property name="ellipsize">end</property>
<attributes>
......
......@@ -4,13 +4,11 @@
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="1.2"/>
<template class="StreamWindow" parent="HdyApplicationWindow">
<property name="width-request">360</property>
<property name="height-request">720</property>
<property name="can-focus">False</property>
<property name="hexpand">False</property>
<property name="vexpand">True</property>
<property name="default-width">360</property>
<property name="default-height">720</property>
<property name="default-width">882</property>
<property name="default-height">652</property>
<signal name="key-press-event" handler="keypress_listener" swapped="no"/>
<child>
<object class="GtkBox">
......@@ -118,6 +116,9 @@
<property name="title" translatable="yes">Search Web Videos</property>
<property name="description" translatable="yes">Use the &lt;b&gt;Search&lt;/b&gt; button to find videos online.</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="spinner">
......@@ -127,6 +128,9 @@
<property name="valign">center</property>
<property name="active">True</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="results_window">
......@@ -151,9 +155,64 @@
</child>
</object>
<packing>
<property name="position">1</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="error_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="error_image">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">network-error-symbolic</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="error_heading">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">12</property>
<property name="label" translatable="yes">...</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.2"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="error_text">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">6</property>
<property name="label" translatable="yes">...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
......
......@@ -36,6 +36,9 @@ class StreamWindow(Handy.ApplicationWindow):
status_page = Gtk.Template.Child()
spinner = Gtk.Template.Child()
error_box = Gtk.Template.Child()
error_heading = Gtk.Template.Child()
error_text = Gtk.Template.Child()
results_window = Gtk.Template.Child()
results_list = Gtk.Template.Child()
......@@ -47,6 +50,9 @@ class StreamWindow(Handy.ApplicationWindow):
@Gtk.Template.Callback()
def search_entry(self, search_box):
self.status_page.set_visible(False)
self.error_box.set_visible(False)
self.error_heading.set_label("...")
self.error_text.set_label("...")
self.results_window.set_visible(False)
self.spinner.set_visible(True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment