@@ -30,6 +30,8 @@ mod imp {
3030 pub list_box : gtk:: ListBox ,
3131 pub binaries_list_box : gtk:: ListBox ,
3232 pub binary_name_entry : adw:: EntryRow ,
33+ pub export_apps_group : adw:: PreferencesGroup ,
34+ pub export_binaries_group : adw:: PreferencesGroup ,
3335 }
3436
3537 #[ derived_properties]
@@ -65,13 +67,13 @@ mod imp {
6567
6668 self . list_box . add_css_class ( "boxed-list" ) ;
6769 self . list_box . set_selection_mode ( gtk:: SelectionMode :: None ) ;
68- let export_apps_group = adw :: PreferencesGroup :: new ( ) ;
69- export_apps_group. set_margin_start ( 12 ) ;
70- export_apps_group. set_margin_end ( 12 ) ;
71- export_apps_group. set_margin_top ( 12 ) ;
72- export_apps_group. set_margin_bottom ( 12 ) ;
73- export_apps_group. set_title ( "Exportable Apps" ) ;
74- export_apps_group. add ( & self . list_box ) ;
70+ self . export_apps_group . set_margin_start ( 12 ) ;
71+ self . export_apps_group . set_margin_end ( 12 ) ;
72+ self . export_apps_group . set_margin_top ( 12 ) ;
73+ self . export_apps_group . set_margin_bottom ( 12 ) ;
74+ self . export_apps_group . set_title ( "Exportable Apps" ) ;
75+ self . export_apps_group . set_description ( Some ( "No exportable apps found" ) ) ;
76+ self . export_apps_group . add ( & self . list_box ) ;
7577
7678 // Setup binary export input
7779 self . binary_name_entry . set_title ( "Export New Binary" ) ;
@@ -83,26 +85,20 @@ mod imp {
8385 self . binaries_list_box . set_selection_mode ( gtk:: SelectionMode :: None ) ;
8486 self . binaries_list_box . set_margin_top ( 12 ) ;
8587
86- let export_binaries_group = adw :: PreferencesGroup :: new ( ) ;
87- export_binaries_group. set_margin_start ( 12 ) ;
88- export_binaries_group. set_margin_end ( 12 ) ;
89- export_binaries_group. set_margin_top ( 0 ) ;
90- export_binaries_group. set_margin_bottom ( 12 ) ;
91- export_binaries_group. set_title ( "Exported Binaries" ) ;
92- export_binaries_group. add ( & self . binary_name_entry ) ;
93- export_binaries_group. add ( & self . binaries_list_box ) ;
88+ self . export_binaries_group . set_margin_start ( 12 ) ;
89+ self . export_binaries_group . set_margin_end ( 12 ) ;
90+ self . export_binaries_group . set_margin_top ( 0 ) ;
91+ self . export_binaries_group . set_margin_bottom ( 12 ) ;
92+ self . export_binaries_group . set_title ( "Exported Binaries" ) ;
93+ self . export_binaries_group . set_description ( Some ( "No exported binaries" ) ) ;
94+ self . export_binaries_group . add ( & self . binary_name_entry ) ;
95+ self . export_binaries_group . add ( & self . binaries_list_box ) ;
9496
9597 let content_box = gtk:: Box :: new ( gtk:: Orientation :: Vertical , 0 ) ;
96- content_box. append ( & export_apps_group) ;
97- content_box. append ( & export_binaries_group) ;
98+ content_box. append ( & self . export_apps_group ) ;
99+ content_box. append ( & self . export_binaries_group ) ;
98100 self . stack . add_named ( & content_box, Some ( "apps" ) ) ;
99101
100- let empty_page = adw:: StatusPage :: new ( ) ;
101- empty_page. set_title ( "No Exportable Items" ) ;
102- empty_page. set_description ( Some ( "No applications or binaries found in this container" ) ) ;
103-
104- self . stack . add_named ( & empty_page, Some ( "empty" ) ) ;
105-
106102 self . content . append ( & self . scrolled_window ) ;
107103 self . toolbar_view . set_content ( Some ( & self . content ) ) ;
108104 self . toast_overlay . set_child ( Some ( & self . toolbar_view ) ) ;
@@ -166,15 +162,6 @@ impl ExportableAppsDialog {
166162 . property ( "container" , container)
167163 . build ( ) ;
168164
169- let apps = this. container ( ) . apps ( ) ;
170- let binaries = this. container ( ) . binaries ( ) ;
171-
172- let is_empty = move || -> bool {
173- let n_apps = apps. data :: < gio:: ListStore > ( ) . map ( |s| s. n_items ( ) ) . unwrap_or ( 0 ) ;
174- let n_binaries = binaries. data :: < gio:: ListStore > ( ) . map ( |s| s. n_items ( ) ) . unwrap_or ( 0 ) ;
175- n_apps == 0 && n_binaries == 0
176- } ;
177-
178165 let this_clone = this. clone ( ) ;
179166 let apps = this. container ( ) . apps ( ) ;
180167 let binaries = this. container ( ) . binaries ( ) ;
@@ -192,6 +179,14 @@ impl ExportableAppsDialog {
192179 let apps = this. container ( ) . apps ( ) ;
193180 let render_apps = move || {
194181 let apps = apps. data :: < gio:: ListStore > ( ) ;
182+ let n_apps = apps. as_ref ( ) . map ( |s| s. n_items ( ) ) . unwrap_or ( 0 ) ;
183+
184+ // Update description based on whether there are apps
185+ if n_apps == 0 {
186+ this_clone. imp ( ) . export_apps_group . set_description ( Some ( "No exportable apps found" ) ) ;
187+ } else {
188+ this_clone. imp ( ) . export_apps_group . set_description ( None ) ;
189+ }
195190
196191 this_clone. imp ( ) . stack . set_visible_child_name ( "apps" ) ;
197192 let this = this_clone. clone ( ) ;
@@ -212,6 +207,14 @@ impl ExportableAppsDialog {
212207 let binaries = this. container ( ) . binaries ( ) ;
213208 let render_binaries = move || {
214209 let binaries = binaries. data :: < gio:: ListStore > ( ) ;
210+ let n_binaries = binaries. as_ref ( ) . map ( |s| s. n_items ( ) ) . unwrap_or ( 0 ) ;
211+
212+ // Update description based on whether there are binaries
213+ if n_binaries == 0 {
214+ this_clone. imp ( ) . export_binaries_group . set_description ( Some ( "No exported binaries" ) ) ;
215+ } else {
216+ this_clone. imp ( ) . export_binaries_group . set_description ( None ) ;
217+ }
215218
216219 this_clone. imp ( ) . stack . set_visible_child_name ( "apps" ) ;
217220 let this = this_clone. clone ( ) ;
@@ -235,8 +238,6 @@ impl ExportableAppsDialog {
235238 move |( b1, b2) : ( bool , bool ) | {
236239 if b1 || b2 {
237240 this_clone. imp( ) . stack. set_visible_child_name( "loading" ) ;
238- } else if is_empty( ) {
239- this_clone. imp( ) . stack. set_visible_child_name( "empty" ) ;
240241 } else {
241242 render_apps( ) ;
242243 render_binaries( ) ;
0 commit comments