11//! This modules handles the logic for each "app" that rustcast can load
22//!
33//! An "app" is effectively, one of the results that rustcast returns when you search for something
4- use std:: path:: Path ;
54
65use iced:: {
76 Alignment ,
@@ -14,9 +13,11 @@ use crate::{
1413 clipboard:: ClipBoardContentType ,
1514 commands:: Function ,
1615 styles:: { result_button_style, result_row_container_style} ,
17- utils:: handle_from_icns ,
16+ utils:: icns_data_to_handle ,
1817} ;
1918
19+ pub const ICNS_ICON : & [ u8 ] = include_bytes ! ( "../../docs/icon.icns" ) ;
20+
2021/// This tells each "App" what to do when it is clicked, whether it is a function, a message, or a display
2122#[ allow( dead_code) ]
2223#[ derive( Debug , Clone ) ]
@@ -69,58 +70,48 @@ impl App {
6970 pub fn basic_apps ( ) -> Vec < App > {
7071 let app_version = option_env ! ( "APP_VERSION" ) . unwrap_or ( "Unknown Version" ) ;
7172
73+ let icons = icns_data_to_handle ( ICNS_ICON . to_vec ( ) ) ;
74+
7275 vec ! [
7376 App {
7477 open_command: AppCommand :: Function ( Function :: Quit ) ,
7578 desc: RUSTCAST_DESC_NAME . to_string( ) ,
76- icons: handle_from_icns( Path :: new(
77- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
78- ) ) ,
79+ icons: icons. clone( ) ,
7980 name: "Quit RustCast" . to_string( ) ,
8081 name_lc: "quit" . to_string( ) ,
8182 } ,
8283 App {
8384 open_command: AppCommand :: Function ( Function :: OpenPrefPane ) ,
8485 desc: RUSTCAST_DESC_NAME . to_string( ) ,
85- icons: handle_from_icns( Path :: new(
86- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
87- ) ) ,
86+ icons: icons. clone( ) ,
8887 name: "Open RustCast Preferences" . to_string( ) ,
8988 name_lc: "settings" . to_string( ) ,
9089 } ,
9190 App {
9291 open_command: AppCommand :: Message ( Message :: SwitchToPage ( Page :: EmojiSearch ) ) ,
9392 desc: RUSTCAST_DESC_NAME . to_string( ) ,
94- icons: handle_from_icns( Path :: new(
95- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
96- ) ) ,
93+ icons: icons. clone( ) ,
9794 name: "Search for an Emoji" . to_string( ) ,
9895 name_lc: "emoji" . to_string( ) ,
9996 } ,
10097 App {
10198 open_command: AppCommand :: Message ( Message :: SwitchToPage ( Page :: ClipboardHistory ) ) ,
10299 desc: RUSTCAST_DESC_NAME . to_string( ) ,
103- icons: handle_from_icns( Path :: new(
104- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
105- ) ) ,
100+ icons: icons. clone( ) ,
106101 name: "Clipboard History" . to_string( ) ,
107102 name_lc: "clipboard" . to_string( ) ,
108103 } ,
109104 App {
110105 open_command: AppCommand :: Message ( Message :: ReloadConfig ) ,
111106 desc: RUSTCAST_DESC_NAME . to_string( ) ,
112- icons: handle_from_icns( Path :: new(
113- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
114- ) ) ,
107+ icons: icons. clone( ) ,
115108 name: "Reload RustCast" . to_string( ) ,
116109 name_lc: "refresh" . to_string( ) ,
117110 } ,
118111 App {
119112 open_command: AppCommand :: Display ,
120113 desc: RUSTCAST_DESC_NAME . to_string( ) ,
121- icons: handle_from_icns( Path :: new(
122- "/Applications/Rustcast.app/Contents/Resources/icon.icns" ,
123- ) ) ,
114+ icons: icons. clone( ) ,
124115 name: format!( "Current RustCast Version: {app_version}" ) ,
125116 name_lc: "version" . to_string( ) ,
126117 } ,
0 commit comments