88from .lib .utils import get_element_without_overscroll , get_gsettings , gio_copy
99from .lib .constants import APP_ID , APP_NAME , APP_DATA
1010
11- class WelcomeScreen (Gtk . Window ):
11+ class WelcomeScreen (Adw . Dialog ):
1212
1313 def __init__ (self ):
1414 super ().__init__ ()
15- self .set_default_size (700 , 700 )
16- self .set_resizable (False )
1715
1816 pkgdatadir = APP_DATA ['PKGDATADIR' ]
1917
20- container = Gtk .Box (orientation = Gtk .Orientation .VERTICAL , valign = Gtk .Align .CENTER )
21- self .carousel = Adw .Carousel ()
22- self .carousel .connect ('page-changed' , self .on_page_changed )
18+ self .set_content_height (600 )
19+ self .set_content_width (600 )
20+
21+ toolbar_view = Adw .ToolbarView ()
2322
24- self .titlebar = Adw .HeaderBar (show_end_title_buttons = False )
25- self .left_button = Gtk .Button (icon_name = 'go-previous' , visible = True , sensitive = False )
26- self .right_button = Gtk .Button (label = 'Next' , visible = True , css_classes = ['suggested-action' ])
23+ self .titlebar = Adw .HeaderBar ()
24+ toolbar_view .add_top_bar (self .titlebar )
2725
28- self .titlebar .set_title_widget (Gtk .Label (label = 'Tutorial' ))
29- self .titlebar .pack_start (self .left_button )
30- self .titlebar .pack_end (self .right_button )
26+ overlay = Gtk .Overlay ()
27+
28+ self .carousel = Adw .Carousel (spacing = 200 )
29+ self .carousel .connect ('page-changed' , self .on_page_changed )
3130
32- self .set_titlebar (self .titlebar )
31+ dots = Adw .CarouselIndicatorDots ()
32+ dots .set_carousel (self .carousel )
33+ self .titlebar .set_title_widget (dots )
34+
35+ overlay .set_child (self .carousel )
36+
37+ self .left_button = Gtk .Button (icon_name = 'go-previous' )
38+ self .left_button .add_css_class ('circular' )
39+ self .left_button .set_sensitive (False )
40+ self .left_button .set_halign (Gtk .Align .START )
41+ self .left_button .set_valign (Gtk .Align .CENTER )
42+ self .left_button .set_margin_start (20 )
43+
44+ self .right_button = Gtk .Button (icon_name = 'go-next' )
45+ self .right_button .add_css_class ('circular' )
46+ self .right_button .set_halign (Gtk .Align .END )
47+ self .right_button .set_valign (Gtk .Align .CENTER )
48+ self .right_button .set_margin_end (20 )
49+
50+ overlay .add_overlay (self .left_button )
51+ overlay .add_overlay (self .right_button )
3352
3453 first_page = Gtk .Builder .new_from_resource (f'/it/mijorus/{ APP_NAME } /gtk/tutorial/1.ui' )
3554 second_page = Gtk .Builder .new_from_resource (f'/it/mijorus/{ APP_NAME } /gtk/tutorial/2.ui' )
@@ -46,7 +65,7 @@ def __init__(self):
4665 self .left_button .connect ('clicked' , lambda w : self .carousel .scroll_to (get_element_without_overscroll (pages , int (self .carousel .get_position ()) - 1 ), True ))
4766 self .right_button .connect ('clicked' , lambda w : self .carousel .scroll_to (get_element_without_overscroll (pages , int (self .carousel .get_position ()) + 1 ), True ))
4867
49- container . append ( self . carousel )
68+ toolbar_view . set_content ( overlay )
5069
5170 self .demo_folder = os .path .join (GLib .get_user_cache_dir (), APP_ID , 'demo' )
5271 demo_app = Gio .File .new_for_path (os .path .join (pkgdatadir , APP_NAME , 'assets' , 'demo.AppImage' ))
@@ -63,7 +82,7 @@ def __init__(self):
6382 third_page .get_object ('open-demo-folder' ).connect ('clicked' , self .on_open_demo_folder_clicked )
6483 second_page .get_object ('open-preferences' ).connect ('clicked' , self .on_default_localtion_btn_clicked )
6584
66- self .set_child (container )
85+ self .set_child (toolbar_view )
6786
6887
6988 def on_page_changed (self , widget , index ):
@@ -98,7 +117,7 @@ def on_default_localtion_btn_clicked(self, widget):
98117 dialog = Gtk .FileDialog (title = _ ('Select a folder' ), modal = True )
99118
100119 dialog .select_folder (
101- parent = self ,
120+ parent = self . get_root () ,
102121 cancellable = None ,
103122 callback = self .on_select_default_location_response
104- )
123+ )
0 commit comments