@@ -72,6 +72,8 @@ mod imp {
7272 pub message_scroll : TemplateChild < gtk:: ScrolledWindow > ,
7373 #[ template_child]
7474 pub banner : TemplateChild < adw:: Banner > ,
75+ #[ template_child]
76+ pub send_btn : TemplateChild < gtk:: Button > ,
7577 pub notifier : OnceCell < system_notifier:: Client > ,
7678 pub conn : OnceCell < gio:: SocketConnection > ,
7779 pub settings : gio:: Settings ,
@@ -81,24 +83,25 @@ mod imp {
8183 impl Default for NotifyWindow {
8284 fn default ( ) -> Self {
8385 let this = Self {
84- headerbar : TemplateChild :: default ( ) ,
85- message_list : TemplateChild :: default ( ) ,
86- entry : TemplateChild :: default ( ) ,
87- subscription_view : TemplateChild :: default ( ) ,
88- navigation_split_view : TemplateChild :: default ( ) ,
89- subscription_menu_btn : TemplateChild :: default ( ) ,
90- subscription_list : TemplateChild :: default ( ) ,
91- toast_overlay : TemplateChild :: default ( ) ,
92- stack : TemplateChild :: default ( ) ,
93- welcome_view : TemplateChild :: default ( ) ,
94- list_view : TemplateChild :: default ( ) ,
95- message_scroll : TemplateChild :: default ( ) ,
96- banner : TemplateChild :: default ( ) ,
86+ headerbar : Default :: default ( ) ,
87+ message_list : Default :: default ( ) ,
88+ entry : Default :: default ( ) ,
89+ subscription_view : Default :: default ( ) ,
90+ navigation_split_view : Default :: default ( ) ,
91+ subscription_menu_btn : Default :: default ( ) ,
92+ subscription_list : Default :: default ( ) ,
93+ toast_overlay : Default :: default ( ) ,
94+ stack : Default :: default ( ) ,
95+ welcome_view : Default :: default ( ) ,
96+ list_view : Default :: default ( ) ,
97+ message_scroll : Default :: default ( ) ,
98+ banner : Default :: default ( ) ,
9799 subscription_list_model : gio:: ListStore :: new :: < Subscription > ( ) ,
98100 settings : gio:: Settings :: new ( APP_ID ) ,
99- notifier : OnceCell :: new ( ) ,
100- conn : OnceCell :: new ( ) ,
101- banner_binding : Cell :: new ( None ) ,
101+ notifier : Default :: default ( ) ,
102+ conn : Default :: default ( ) ,
103+ banner_binding : Default :: default ( ) ,
104+ send_btn : Default :: default ( ) ,
102105 } ;
103106
104107 this
@@ -139,7 +142,6 @@ mod imp {
139142 this. show_subscription_info ( ) ;
140143 } ) ;
141144 klass. install_action ( "win.clear-notifications" , None , |this, _, _| {
142- /*spawn_local(this.subscription().clear_notifications().map_err(this.near_toast_overlay().error_handler()));*/
143145 this. selected_subscription ( ) . map ( |sub| {
144146 this. spawn_with_near_toast ( sub. clear_notifications ( ) ) ;
145147 } ) ;
@@ -203,23 +205,27 @@ impl NotifyWindow {
203205 // Load latest window state
204206 obj. load_window_size ( ) ;
205207 obj. bind_message_list ( ) ;
206- obj. connect_entry_changed ( ) ;
208+ obj. connect_entry_and_send_btn ( ) ;
207209 obj. connect_items_changed ( ) ;
208210 obj. selected_subscription_changed ( None ) ;
209211 obj. bind_flag_read ( ) ;
210212
211213 obj
212214 }
213- fn connect_entry_changed ( & self ) {
215+ fn connect_entry_and_send_btn ( & self ) {
214216 let imp = self . imp ( ) ;
215217 let this = self . clone ( ) ;
216- imp. entry . connect_activate ( move |entry| {
218+ let entry = imp. entry . clone ( ) ;
219+ let publish = move || {
217220 let p = this
218221 . selected_subscription ( )
219222 . unwrap ( )
220223 . publish ( entry. text ( ) . as_str ( ) ) ;
221224 entry. spawn_with_near_toast ( async move { p. await } ) ;
222- } ) ;
225+ } ;
226+ let publishc = publish. clone ( ) ;
227+ imp. entry . connect_activate ( move |_| publishc ( ) ) ;
228+ imp. send_btn . connect_clicked ( move |_| publish ( ) ) ;
223229 }
224230 fn show_subscription_info ( & self ) {
225231 let sub = SubscriptionInfoDialog :: new ( self . selected_subscription ( ) . unwrap ( ) ) ;
0 commit comments