Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from gi.repository import Gtk 

2 

3 

4class LoadError(Gtk.Box): 

5 def __init__( 

6 self, entity_name: str, action: str, has_data: bool, offline_mode: bool 

7 ): 

8 Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) 

9 

10 self.pack_start(Gtk.Box(), True, True, 0) 

11 

12 inner_box = Gtk.Box( 

13 orientation=Gtk.Orientation.HORIZONTAL, name="load-error-box" 

14 ) 

15 

16 inner_box.pack_start(Gtk.Box(), True, True, 0) 

17 

18 error_and_button_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) 

19 

20 icon_and_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) 

21 

22 if offline_mode: 

23 icon_name = "cloud-offline-symbolic" 

24 label = f"{entity_name} may be incomplete.\n" if has_data else "" 

25 label += f"Go online to {action}." 

26 else: 

27 icon_name = "network-error-symbolic" 

28 label = f"Error attempting to {action}." 

29 

30 self.image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DIALOG) 

31 self.image.set_name("load-error-image") 

32 icon_and_button_box.add(self.image) 

33 

34 self.label = Gtk.Label(label=label, name="load-error-label") 

35 icon_and_button_box.add(self.label) 

36 

37 error_and_button_box.add(icon_and_button_box) 

38 

39 button_centerer_box = Gtk.Box() 

40 button_centerer_box.pack_start(Gtk.Box(), True, True, 0) 

41 

42 if offline_mode: 

43 go_online_button = Gtk.Button(label="Go Online") 

44 go_online_button.set_action_name("app.go-online") 

45 button_centerer_box.add(go_online_button) 

46 else: 

47 retry_button = Gtk.Button(label="Retry") 

48 retry_button.set_action_name("app.refresh-window") 

49 button_centerer_box.add(retry_button) 

50 

51 button_centerer_box.pack_start(Gtk.Box(), True, True, 0) 

52 error_and_button_box.add(button_centerer_box) 

53 

54 inner_box.add(error_and_button_box) 

55 

56 inner_box.pack_start(Gtk.Box(), True, True, 0) 

57 

58 self.add(inner_box) 

59 

60 self.pack_start(Gtk.Box(), True, True, 0)