@@ -118,14 +118,8 @@ impl cosmic::Application for AppModel {
118118 let menu_items = get_menu_items ( ) ;
119119
120120 // get custom logo status and path
121- let custom_logo_active = match load_config ( "custom_logo_active" , CONFIG_VER ) {
122- Some ( val) => val,
123- None => false ,
124- } ;
125- let custom_logo_path = match load_config ( "custom_logo_path" , CONFIG_VER ) {
126- Some ( val) => val,
127- None => "" . to_owned ( ) ,
128- } ;
121+ let custom_logo_active = load_config ( "custom_logo_active" , CONFIG_VER ) . unwrap_or_default ( ) ;
122+ let custom_logo_path = load_config ( "custom_logo_path" , CONFIG_VER ) . unwrap_or_default ( ) ;
129123
130124 let menu_types = vec ! [ MenuItemType :: LaunchAction , MenuItemType :: PowerAction ] ;
131125 let menu_type_labels: Vec < String > =
@@ -222,17 +216,16 @@ impl cosmic::Application for AppModel {
222216 page_content = page_content. push ( Space :: with_height ( padding) ) ;
223217
224218 // Set currently selected logo
225- let logo_widget =
226- if self . custom_logo_active == true && Path :: new ( & self . custom_logo_path ) . exists ( ) {
227- widget:: svg ( widget:: svg:: Handle :: from_path ( & self . custom_logo_path ) )
228- . symbolic ( false )
229- . width ( 150 )
230- } else {
231- let logo_bytes = IMAGES [ & self . selected_logo_name ] ;
232- widget:: svg ( widget:: svg:: Handle :: from_memory ( logo_bytes. 0 ) )
233- . symbolic ( logo_bytes. 1 )
234- . width ( 150 )
235- } ;
219+ let logo_widget = if self . custom_logo_active && Path :: new ( & self . custom_logo_path ) . exists ( ) {
220+ widget:: svg ( widget:: svg:: Handle :: from_path ( & self . custom_logo_path ) )
221+ . symbolic ( false )
222+ . width ( 150 )
223+ } else {
224+ let logo_bytes = IMAGES [ & self . selected_logo_name ] ;
225+ widget:: svg ( widget:: svg:: Handle :: from_memory ( logo_bytes. 0 ) )
226+ . symbolic ( logo_bytes. 1 )
227+ . width ( 150 )
228+ } ;
236229
237230 // Display logo header
238231 page_content = page_content. push (
@@ -248,14 +241,12 @@ impl cosmic::Application for AppModel {
248241 // Menu settings
249242 let mut menu_settings = settings:: section ( ) . add ( {
250243 Element :: from (
251- settings:: item:: builder ( fl ! ( "use-custom-logo" ) ) . control (
252- toggler ( self . custom_logo_active )
253- . on_toggle ( |value| Message :: ToggleCustomLogo ( value) ) ,
254- ) ,
244+ settings:: item:: builder ( fl ! ( "use-custom-logo" ) )
245+ . control ( toggler ( self . custom_logo_active ) . on_toggle ( Message :: ToggleCustomLogo ) ) ,
255246 )
256247 } ) ;
257- if self . custom_logo_active == true {
258- let file_name = if & self . custom_logo_path != "" {
248+ if self . custom_logo_active {
249+ let file_name = if ! & self . custom_logo_path . is_empty ( ) {
259250 Path :: new ( & self . custom_logo_path )
260251 . file_name ( )
261252 . unwrap ( )
@@ -348,7 +339,7 @@ impl cosmic::Application for AppModel {
348339 let mut label_string = label;
349340 let command_string = menu_item. command ( ) . unwrap_or_default ( ) ;
350341
351- if command_string != "" {
342+ if !command_string . is_empty ( ) {
352343 label_string. push_str ( " :: " ) ;
353344 label_string. push_str ( & command_string) ;
354345 }
@@ -645,19 +636,16 @@ impl cosmic::Application for AppModel {
645636 . set_directory ( "~/" )
646637 . pick_file ( ) ;
647638
648- match file {
649- Some ( path) => {
650- let path_string = path. to_str ( ) . unwrap_or ( "" ) ;
651- update_config ( self . config . clone ( ) , "custom_logo_path" , & path_string) ;
652- self . custom_logo_path = path_string. to_owned ( ) ;
653- }
654- None => { }
639+ if let Some ( path) = file {
640+ let path_string = path. to_str ( ) . unwrap_or ( "" ) ;
641+ update_config ( self . config . clone ( ) , "custom_logo_path" , & path_string) ;
642+ self . custom_logo_path = path_string. to_owned ( ) ;
655643 } ;
656644 }
657645
658646 Message :: AddItem ( item_type) => {
659647 let new_item = MenuItem {
660- item_type : item_type . clone ( ) ,
648+ item_type,
661649 label : match & item_type {
662650 MenuItemType :: LaunchAction => Some ( fl ! ( "new-launcher" ) ) ,
663651 _ => None ,
0 commit comments