[fractal/ui-refactor: 8/15] Use UI and AppRuntime directly in connect




commit 8b3580ee7a5d421702515f60e881c1bb56e24c59
Author: Alejandro Domínguez <adomu net-c com>
Date:   Fri Oct 16 02:48:09 2020 +0200

    Use UI and AppRuntime directly in connect

 fractal-gtk/src/appop/connect/account.rs           | 67 ++++++----------------
 fractal-gtk/src/appop/connect/autocomplete.rs      | 15 ++---
 fractal-gtk/src/appop/connect/direct.rs            | 21 +++----
 fractal-gtk/src/appop/connect/directory.rs         | 48 ++++++----------
 fractal-gtk/src/appop/connect/headerbar.rs         | 11 ++--
 fractal-gtk/src/appop/connect/invite.rs            | 33 ++++-------
 fractal-gtk/src/appop/connect/join_room.rs         | 18 +++---
 fractal-gtk/src/appop/connect/language.rs          |  9 ++-
 fractal-gtk/src/appop/connect/leave_room.rs        | 15 ++---
 fractal-gtk/src/appop/connect/markdown.rs          | 21 +++----
 fractal-gtk/src/appop/connect/mod.rs               | 33 ++++++-----
 fractal-gtk/src/appop/connect/new_room.rs          | 23 +++-----
 fractal-gtk/src/appop/connect/roomlist_search.rs   | 15 ++---
 fractal-gtk/src/appop/connect/send.rs              | 19 +++---
 fractal-gtk/src/appop/connect/swipeable_widgets.rs | 11 ++--
 15 files changed, 138 insertions(+), 221 deletions(-)
---
diff --git a/fractal-gtk/src/appop/connect/account.rs b/fractal-gtk/src/appop/connect/account.rs
index a665ab5e..12a6ad6c 100644
--- a/fractal-gtk/src/appop/connect/account.rs
+++ b/fractal-gtk/src/appop/connect/account.rs
@@ -1,80 +1,53 @@
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 use gio::ActionMapExt;
 use glib::clone;
 use gtk::prelude::*;
 
-use crate::appop::AppOp;
-
 use crate::actions::{AccountSettings, StateExt};
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let builder = &appop.ui.builder;
-    let cancel_password = appop
-        .ui
-        .builder
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let builder = &ui.builder;
+    let cancel_password = builder
         .get_object::<gtk::Button>("password-dialog-cancel")
         .expect("Can't find password-dialog-cancel in ui file.");
-    let confirm_password = appop
-        .ui
-        .builder
+    let confirm_password = builder
         .get_object::<gtk::Button>("password-dialog-apply")
         .expect("Can't find password-dialog-apply in ui file.");
-    let password_dialog = appop
-        .ui
-        .builder
+    let password_dialog = builder
         .get_object::<gtk::Dialog>("password_dialog")
         .expect("Can't find password_dialog in ui file.");
-    let avatar_btn = appop
-        .ui
-        .builder
+    let avatar_btn = builder
         .get_object::<gtk::Button>("account_settings_avatar_button")
         .expect("Can't find account_settings_avatar_button in ui file.");
-    let name_entry = appop
-        .ui
-        .builder
+    let name_entry = builder
         .get_object::<gtk::Entry>("account_settings_name")
         .expect("Can't find account_settings_name in ui file.");
-    let name_btn = appop
-        .ui
-        .builder
+    let name_btn = builder
         .get_object::<gtk::Button>("account_settings_name_button")
         .expect("Can't find account_settings_name_button in ui file.");
-    let password_btn = appop
-        .ui
-        .builder
+    let password_btn = builder
         .get_object::<gtk::Button>("account_settings_password")
         .expect("Can't find account_settings_password in ui file.");
-    let old_password = appop
-        .ui
-        .builder
+    let old_password = builder
         .get_object::<gtk::Entry>("password-dialog-old-entry")
         .expect("Can't find password-dialog-old-entry in ui file.");
-    let new_password = appop
-        .ui
-        .builder
+    let new_password = builder
         .get_object::<gtk::Entry>("password-dialog-entry")
         .expect("Can't find password-dialog-entry in ui file.");
-    let verify_password = appop
-        .ui
-        .builder
+    let verify_password = builder
         .get_object::<gtk::Entry>("password-dialog-verify-entry")
         .expect("Can't find password-dialog-verify-entry in ui file.");
-    let destruction_entry = appop
-        .ui
-        .builder
+    let destruction_entry = builder
         .get_object::<gtk::Entry>("account_settings_delete_password_confirm")
         .expect("Can't find account_settings_delete_password_confirm in ui file.");
-    let destruction_btn = appop
-        .ui
-        .builder
+    let destruction_btn = builder
         .get_object::<gtk::Button>("account_settings_delete_btn")
         .expect("Can't find account_settings_delete_btn in ui file.");
 
-    let window = appop.ui.main_window.upcast_ref::<gtk::Window>();
+    let window = ui.main_window.upcast_ref::<gtk::Window>();
     let actions = AccountSettings::new(&window, app_runtime.clone());
-    let container = appop
-        .ui
-        .builder
+    let container = builder
         .get_object::<gtk::Box>("account_settings_box")
         .expect("Can't find account_settings_box in ui file.");
     container.insert_action_group("user-settings", Some(&actions));
@@ -83,9 +56,7 @@ pub fn connect(appop: &AppOp) {
     if let Some(action) = actions.lookup_action("change-avatar") {
         action.bind_button_state(&avatar_btn);
         avatar_btn.set_action_name(Some("user-settings.change-avatar"));
-        let avatar_spinner = appop
-            .ui
-            .builder
+        let avatar_spinner = builder
             .get_object::<gtk::Spinner>("account_settings_avatar_spinner")
             .expect("Can't find account_settings_avatar_spinner in ui file.");
         avatar_btn.connect_property_sensitive_notify(
diff --git a/fractal-gtk/src/appop/connect/autocomplete.rs b/fractal-gtk/src/appop/connect/autocomplete.rs
index a3c64474..a55ac8bf 100644
--- a/fractal-gtk/src/appop/connect/autocomplete.rs
+++ b/fractal-gtk/src/appop/connect/autocomplete.rs
@@ -2,24 +2,21 @@ use gtk::prelude::*;
 
 use crate::widgets;
 
-use crate::appop::AppOp;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let popover = appop
-        .ui
+pub fn connect(ui: &UI) {
+    let popover = ui
         .builder
         .get_object::<gtk::Popover>("autocomplete_popover")
         .expect("Can't find autocomplete_popover in ui file.");
-    let listbox = appop
-        .ui
+    let listbox = ui
         .builder
         .get_object::<gtk::ListBox>("autocomplete_listbox")
         .expect("Can't find autocomplete_listbox in ui file.");
-    let window: gtk::Window = appop
-        .ui
+    let window: gtk::Window = ui
         .builder
         .get_object("main_window")
         .expect("Can't find main_window in ui file.");
 
-    widgets::Autocomplete::new(window, appop.ui.sventry.view.clone(), popover, listbox).connect();
+    widgets::Autocomplete::new(window, ui.sventry.view.clone(), popover, listbox).connect();
 }
diff --git a/fractal-gtk/src/appop/connect/direct.rs b/fractal-gtk/src/appop/connect/direct.rs
index 58eeb800..512ab99b 100644
--- a/fractal-gtk/src/appop/connect/direct.rs
+++ b/fractal-gtk/src/appop/connect/direct.rs
@@ -4,32 +4,27 @@ use gtk::prelude::*;
 use glib::source::Continue;
 use std::sync::{Arc, Mutex};
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let cancel = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let cancel = ui
         .builder
         .get_object::<gtk::Button>("cancel_direct_chat")
         .expect("Can't find cancel_direct_chat in ui file.");
-    let invite = appop
-        .ui
+    let invite = ui
         .builder
         .get_object::<gtk::Button>("direct_chat_button")
         .expect("Can't find direct_chat_button in ui file.");
-    let to_chat_entry_box = appop
-        .ui
+    let to_chat_entry_box = ui
         .builder
         .get_object::<gtk::Box>("to_chat_entry_box")
         .expect("Can't find to_chat_entry_box in ui file.");
-    let to_chat_entry = appop
-        .ui
+    let to_chat_entry = ui
         .builder
         .get_object::<gtk::TextView>("to_chat_entry")
         .expect("Can't find to_chat_entry in ui file.");
-    let dialog = appop
-        .ui
+    let dialog = ui
         .builder
         .get_object::<gtk::Dialog>("direct_chat_dialog")
         .expect("Can't find direct_chat_dialog in ui file.");
diff --git a/fractal-gtk/src/appop/connect/directory.rs b/fractal-gtk/src/appop/connect/directory.rs
index 3b0eb330..77918f3e 100644
--- a/fractal-gtk/src/appop/connect/directory.rs
+++ b/fractal-gtk/src/appop/connect/directory.rs
@@ -5,18 +5,17 @@ use crate::util::i18n::i18n;
 use gtk::prelude::*;
 use libhandy::prelude::*;
 
-use crate::appop::{AppOp, RoomSearchPagination};
+use crate::app::AppRuntime;
+use crate::appop::RoomSearchPagination;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let q = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let q = ui
         .builder
         .get_object::<gtk::Entry>("directory_search_entry")
         .expect("Can't find directory_search_entry in ui file.");
 
-    let directory_stack = appop
-        .ui
+    let directory_stack = ui
         .builder
         .get_object::<gtk::Stack>("directory_stack")
         .expect("Can't find directory_stack in ui file.");
@@ -41,65 +40,52 @@ pub fn connect(appop: &AppOp) {
     clamp.show();
     directory_stack.add_named(&clamp, "directory_clamp");
 
-    appop
-        .ui
-        .builder
+    ui.builder
         .expose_object::<gtk::ListBox>("directory_room_list", &listbox);
-    appop
-        .ui
-        .builder
+    ui.builder
         .expose_object::<libhandy::Clamp>("directory_clamp", &clamp);
 
-    let directory_choice_label = appop
-        .ui
+    let directory_choice_label = ui
         .builder
         .get_object::<gtk::Label>("directory_choice_label")
         .expect("Can't find directory_choice_label in ui file.");
 
-    let default_matrix_server_radio = appop
-        .ui
+    let default_matrix_server_radio = ui
         .builder
         .get_object::<gtk::RadioButton>("default_matrix_server_radio")
         .expect("Can't find default_matrix_server_radio in ui file.");
 
-    let other_protocol_radio = appop
-        .ui
+    let other_protocol_radio = ui
         .builder
         .get_object::<gtk::RadioButton>("other_protocol_radio")
         .expect("Can't find other_protocol_radio in ui file.");
 
-    let protocol_combo = appop
-        .ui
+    let protocol_combo = ui
         .builder
         .get_object::<gtk::ComboBox>("protocol_combo")
         .expect("Can't find protocol_combo in ui file.");
 
-    let protocol_model = appop
-        .ui
+    let protocol_model = ui
         .builder
         .get_object::<gtk::ListStore>("protocol_model")
         .expect("Can't find protocol_model in ui file.");
 
-    let other_homeserver_radio = appop
-        .ui
+    let other_homeserver_radio = ui
         .builder
         .get_object::<gtk::RadioButton>("other_homeserver_radio")
         .expect("Can't find other_homeserver_radio in ui file.");
 
-    let other_homeserver_url_entry = appop
-        .ui
+    let other_homeserver_url_entry = ui
         .builder
         .get_object::<gtk::Entry>("other_homeserver_url_entry")
         .expect("Can't find other_homeserver_url_entry in ui file.");
 
-    let other_homeserver_url = appop
-        .ui
+    let other_homeserver_url = ui
         .builder
         .get_object::<gtk::EntryBuffer>("other_homeserver_url")
         .expect("Can't find other_homeserver_url in ui file.");
 
-    let scroll = appop
-        .ui
+    let scroll = ui
         .builder
         .get_object::<gtk::ScrolledWindow>("directory_scroll")
         .expect("Can't find directory_scroll in ui file.");
diff --git a/fractal-gtk/src/appop/connect/headerbar.rs b/fractal-gtk/src/appop/connect/headerbar.rs
index f09c47da..643f6f40 100644
--- a/fractal-gtk/src/appop/connect/headerbar.rs
+++ b/fractal-gtk/src/appop/connect/headerbar.rs
@@ -1,19 +1,16 @@
+use crate::uibuilder::UI;
 use glib::clone;
 use gtk::prelude::*;
 use libhandy::HeaderBarExt;
 
-use crate::appop::AppOp;
-
-pub fn connect(appop: &AppOp) {
+pub fn connect(ui: &UI) {
     if let Some(set) = gtk::Settings::get_default() {
-        let left_header: libhandy::HeaderBar = appop
-            .ui
+        let left_header: libhandy::HeaderBar = ui
             .builder
             .get_object("left-header")
             .expect("Can't find left-header in ui file.");
 
-        let right_header: libhandy::HeaderBar = appop
-            .ui
+        let right_header: libhandy::HeaderBar = ui
             .builder
             .get_object("room_header_bar")
             .expect("Can't find room_header_bar in ui file.");
diff --git a/fractal-gtk/src/appop/connect/invite.rs b/fractal-gtk/src/appop/connect/invite.rs
index 9117c00b..dd4417ed 100644
--- a/fractal-gtk/src/appop/connect/invite.rs
+++ b/fractal-gtk/src/appop/connect/invite.rs
@@ -4,22 +4,19 @@ use gtk::prelude::*;
 use glib::source::Continue;
 use std::sync::{Arc, Mutex};
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect_dialog(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let dialog = appop
-        .ui
+pub fn connect_dialog(ui: &UI, app_runtime: AppRuntime) {
+    let dialog = ui
         .builder
         .get_object::<gtk::MessageDialog>("invite_dialog")
         .expect("Can't find invite_dialog in ui file.");
-    let accept = appop
-        .ui
+    let accept = ui
         .builder
         .get_object::<gtk::Button>("invite_accept")
         .expect("Can't find invite_accept in ui file.");
-    let reject = appop
-        .ui
+    let reject = ui
         .builder
         .get_object::<gtk::Button>("invite_reject")
         .expect("Can't find invite_reject in ui file.");
@@ -40,30 +37,24 @@ pub fn connect_dialog(appop: &AppOp) {
     }));
 }
 
-pub fn connect_user(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let cancel = appop
-        .ui
+pub fn connect_user(ui: &UI, app_runtime: AppRuntime) {
+    let cancel = ui
         .builder
         .get_object::<gtk::Button>("cancel_invite")
         .expect("Can't find cancel_invite in ui file.");
-    let invite = appop
-        .ui
+    let invite = ui
         .builder
         .get_object::<gtk::Button>("invite_button")
         .expect("Can't find invite_button in ui file.");
-    let invite_entry_box = appop
-        .ui
+    let invite_entry_box = ui
         .builder
         .get_object::<gtk::Box>("invite_entry_box")
         .expect("Can't find invite_entry_box in ui file.");
-    let invite_entry = appop
-        .ui
+    let invite_entry = ui
         .builder
         .get_object::<gtk::TextView>("invite_entry")
         .expect("Can't find invite_entry in ui file.");
-    let dialog = appop
-        .ui
+    let dialog = ui
         .builder
         .get_object::<gtk::Dialog>("invite_user_dialog")
         .expect("Can't find invite_user_dialog in ui file.");
diff --git a/fractal-gtk/src/appop/connect/join_room.rs b/fractal-gtk/src/appop/connect/join_room.rs
index 18518801..b7b4ebf7 100644
--- a/fractal-gtk/src/appop/connect/join_room.rs
+++ b/fractal-gtk/src/appop/connect/join_room.rs
@@ -1,27 +1,23 @@
 use glib::clone;
 use gtk::prelude::*;
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let dialog = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let dialog = ui
         .builder
         .get_object::<gtk::Dialog>("join_room_dialog")
         .expect("Can't find join_room_dialog in ui file.");
-    let cancel = appop
-        .ui
+    let cancel = ui
         .builder
         .get_object::<gtk::Button>("cancel_join_room")
         .expect("Can't find cancel_join_room in ui file.");
-    let confirm = appop
-        .ui
+    let confirm = ui
         .builder
         .get_object::<gtk::Button>("join_room_button")
         .expect("Can't find join_room_button in ui file.");
-    let entry = appop
-        .ui
+    let entry = ui
         .builder
         .get_object::<gtk::Entry>("join_room_name")
         .expect("Can't find join_room_name in ui file.");
diff --git a/fractal-gtk/src/appop/connect/language.rs b/fractal-gtk/src/appop/connect/language.rs
index f1915742..c50626a8 100644
--- a/fractal-gtk/src/appop/connect/language.rs
+++ b/fractal-gtk/src/appop/connect/language.rs
@@ -1,15 +1,14 @@
-use crate::app::RUNTIME;
-use crate::appop::AppOp;
+use crate::app::{AppRuntime, RUNTIME};
 use crate::backend::{room, HandleError};
+use crate::uibuilder::UI;
 use glib::object::Cast;
 use gtk::prelude::*;
 
 // The TextBufferExt alias is necessary to avoid conflict with gtk's TextBufferExt
 use gspell::{CheckerExt, TextBuffer, TextBufferExt as GspellTextBufferExt};
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let textview = appop.ui.sventry.view.upcast_ref::<gtk::TextView>();
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let textview = ui.sventry.view.upcast_ref::<gtk::TextView>();
     if let Some(checker) = textview
         .get_buffer()
         .and_then(|gtk_buffer| TextBuffer::get_from_gtk_text_buffer(&gtk_buffer))
diff --git a/fractal-gtk/src/appop/connect/leave_room.rs b/fractal-gtk/src/appop/connect/leave_room.rs
index 6c33e5c3..749ece4b 100644
--- a/fractal-gtk/src/appop/connect/leave_room.rs
+++ b/fractal-gtk/src/appop/connect/leave_room.rs
@@ -1,22 +1,19 @@
 use glib::clone;
 use gtk::prelude::*;
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let dialog = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let dialog = ui
         .builder
         .get_object::<gtk::Dialog>("leave_room_dialog")
         .expect("Can't find leave_room_dialog in ui file.");
-    let cancel = appop
-        .ui
+    let cancel = ui
         .builder
         .get_object::<gtk::Button>("leave_room_cancel")
         .expect("Can't find leave_room_cancel in ui file.");
-    let confirm = appop
-        .ui
+    let confirm = ui
         .builder
         .get_object::<gtk::Button>("leave_room_confirm")
         .expect("Can't find leave_room_confirm in ui file.");
diff --git a/fractal-gtk/src/appop/connect/markdown.rs b/fractal-gtk/src/appop/connect/markdown.rs
index 03af0a75..9e6a3225 100644
--- a/fractal-gtk/src/appop/connect/markdown.rs
+++ b/fractal-gtk/src/appop/connect/markdown.rs
@@ -4,28 +4,25 @@ use sourceview4::prelude::*;
 
 use crate::util;
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let md_popover_btn = &appop.ui.sventry.markdown;
-    let md_img = appop.ui.sventry.markdown_img.clone();
-    let buffer = appop.ui.sventry.buffer.clone();
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let md_popover_btn = &ui.sventry.markdown;
+    let md_img = ui.sventry.markdown_img.clone();
+    let buffer = ui.sventry.buffer.clone();
 
-    let popover: gtk::Popover = appop
-        .ui
+    let popover: gtk::Popover = ui
         .builder
         .get_object("markdown_popover")
         .expect("Couldn't find markdown_popover in ui file.");
 
-    let markdown_switch: gtk::Switch = appop
-        .ui
+    let markdown_switch: gtk::Switch = ui
         .builder
         .get_object("markdown_switch")
         .expect("Couldn't find markdown_switch in ui file.");
 
-    let txt: gtk::Grid = appop
-        .ui
+    let txt: gtk::Grid = ui
         .builder
         .get_object("tutorial_text_box")
         .expect("Couldn't find tutorial_text_box in ui file.");
diff --git a/fractal-gtk/src/appop/connect/mod.rs b/fractal-gtk/src/appop/connect/mod.rs
index 144d1c3a..20e0b11e 100644
--- a/fractal-gtk/src/appop/connect/mod.rs
+++ b/fractal-gtk/src/appop/connect/mod.rs
@@ -17,20 +17,23 @@ use crate::appop::AppOp;
 
 impl AppOp {
     pub fn connect_gtk(&self) {
-        headerbar::connect(self);
-        send::connect(self);
-        markdown::connect(self);
-        autocomplete::connect(self);
-        language::connect(self);
-        directory::connect(self);
-        leave_room::connect(self);
-        new_room::connect(self);
-        join_room::connect(self);
-        account::connect(self);
-        invite::connect_dialog(self);
-        invite::connect_user(self);
-        direct::connect(self);
-        roomlist_search::connect(self);
-        swipeable_widgets::connect(self);
+        let ui = &self.ui;
+        let app_runtime = self.app_runtime.clone();
+
+        headerbar::connect(ui);
+        send::connect(ui, app_runtime.clone());
+        markdown::connect(ui, app_runtime.clone());
+        autocomplete::connect(ui);
+        language::connect(ui, app_runtime.clone());
+        directory::connect(ui, app_runtime.clone());
+        leave_room::connect(ui, app_runtime.clone());
+        new_room::connect(ui, app_runtime.clone());
+        join_room::connect(ui, app_runtime.clone());
+        account::connect(ui, app_runtime.clone());
+        invite::connect_dialog(ui, app_runtime.clone());
+        invite::connect_user(ui, app_runtime.clone());
+        direct::connect(ui, app_runtime.clone());
+        roomlist_search::connect(ui, app_runtime);
+        swipeable_widgets::connect(ui);
     }
 }
diff --git a/fractal-gtk/src/appop/connect/new_room.rs b/fractal-gtk/src/appop/connect/new_room.rs
index 15ae479e..22d7fd82 100644
--- a/fractal-gtk/src/appop/connect/new_room.rs
+++ b/fractal-gtk/src/appop/connect/new_room.rs
@@ -1,32 +1,27 @@
 use glib::clone;
 use gtk::prelude::*;
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let dialog = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let dialog = ui
         .builder
         .get_object::<gtk::Dialog>("new_room_dialog")
         .expect("Can't find new_room_dialog in ui file.");
-    let cancel = appop
-        .ui
+    let cancel = ui
         .builder
         .get_object::<gtk::Button>("cancel_new_room")
         .expect("Can't find cancel_new_room in ui file.");
-    let confirm = appop
-        .ui
+    let confirm = ui
         .builder
         .get_object::<gtk::Button>("new_room_button")
         .expect("Can't find new_room_button in ui file.");
-    let entry = appop
-        .ui
+    let entry = ui
         .builder
         .get_object::<gtk::Entry>("new_room_name")
         .expect("Can't find new_room_name in ui file.");
-    let private = appop
-        .ui
+    let private = ui
         .builder
         .get_object::<gtk::ToggleButton>("private_visibility_button")
         .expect("Can't find private_visibility_button in ui file.");
@@ -64,6 +59,6 @@ pub fn connect(appop: &AppOp) {
         private.set_active(true);
     }));
     entry.connect_changed(clone!(@strong confirm => move |entry| {
-            confirm.set_sensitive(entry.get_buffer().get_length() > 0);
+        confirm.set_sensitive(entry.get_buffer().get_length() > 0);
     }));
 }
diff --git a/fractal-gtk/src/appop/connect/roomlist_search.rs 
b/fractal-gtk/src/appop/connect/roomlist_search.rs
index f657b6aa..5a2024eb 100644
--- a/fractal-gtk/src/appop/connect/roomlist_search.rs
+++ b/fractal-gtk/src/appop/connect/roomlist_search.rs
@@ -1,22 +1,19 @@
 use glib::clone;
 use gtk::prelude::*;
 
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    let search_btn = appop
-        .ui
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    let search_btn = ui
         .builder
         .get_object::<gtk::ToggleButton>("room_search_button")
         .expect("Can't find room_search_button in ui file.");
-    let search_bar = appop
-        .ui
+    let search_bar = ui
         .builder
         .get_object::<gtk::SearchBar>("room_list_searchbar")
         .expect("Can't find room_list_searchbar in ui file.");
-    let search_entry = appop
-        .ui
+    let search_entry = ui
         .builder
         .get_object::<gtk::SearchEntry>("room_list_search")
         .expect("Can't find room_list_search in ui file.");
diff --git a/fractal-gtk/src/appop/connect/send.rs b/fractal-gtk/src/appop/connect/send.rs
index c00cdb6d..183b8ee9 100644
--- a/fractal-gtk/src/appop/connect/send.rs
+++ b/fractal-gtk/src/appop/connect/send.rs
@@ -3,21 +3,21 @@ use gtk::prelude::*;
 use sourceview4::BufferExt;
 
 use crate::actions::activate_action;
-use crate::appop::AppOp;
+use crate::app::AppRuntime;
+use crate::uibuilder::UI;
 
 const MAX_INPUT_HEIGHT: i32 = 100;
 
-pub fn connect(appop: &AppOp) {
-    let app_runtime = appop.app_runtime.clone();
-    appop.ui.sventry.container.set_redraw_on_allocate(true);
-    let msg_entry = appop.ui.sventry.view.clone();
-    let buffer = &appop.ui.sventry.buffer;
+pub fn connect(ui: &UI, app_runtime: AppRuntime) {
+    ui.sventry.container.set_redraw_on_allocate(true);
+    let msg_entry = ui.sventry.view.clone();
+    let buffer = &ui.sventry.buffer;
     buffer.set_highlight_matching_brackets(false);
 
-    let msg_entry_box = appop.ui.sventry.entry_box.clone();
+    let msg_entry_box = ui.sventry.entry_box.clone();
     msg_entry_box.set_redraw_on_allocate(true);
 
-    if let Some(adjustment) = appop.ui.sventry.scroll.get_vadjustment() {
+    if let Some(adjustment) = ui.sventry.scroll.get_vadjustment() {
         adjustment.connect_value_changed(clone!(@strong msg_entry => move |adj| {
             if msg_entry.get_allocated_height() < MAX_INPUT_HEIGHT {
                 adj.set_value(0.0);
@@ -25,8 +25,7 @@ pub fn connect(appop: &AppOp) {
         }));
     }
 
-    let autocomplete_popover = appop
-        .ui
+    let autocomplete_popover = ui
         .builder
         .get_object::<gtk::Popover>("autocomplete_popover")
         .expect("Can't find autocomplete_popover in ui file.");
diff --git a/fractal-gtk/src/appop/connect/swipeable_widgets.rs 
b/fractal-gtk/src/appop/connect/swipeable_widgets.rs
index 16315db8..a38f98fa 100644
--- a/fractal-gtk/src/appop/connect/swipeable_widgets.rs
+++ b/fractal-gtk/src/appop/connect/swipeable_widgets.rs
@@ -1,19 +1,16 @@
+use crate::uibuilder::UI;
 use gio::prelude::*;
 use gtk::prelude::*;
 use libhandy::prelude::*;
 
-use crate::appop::AppOp;
-
 // Set up HdyDeck and HdyLeaflet so that swipes trigger the
 // same behaviour as the back button.
-pub fn connect(appop: &AppOp) {
-    let deck: libhandy::Deck = appop
-        .ui
+pub fn connect(ui: &UI) {
+    let deck: libhandy::Deck = ui
         .builder
         .get_object("main_deck")
         .expect("Can't find main_deck in UI file");
-    let leaflet: libhandy::Leaflet = appop
-        .ui
+    let leaflet: libhandy::Leaflet = ui
         .builder
         .get_object("chat_page")
         .expect("Can't find chat_page in UI file");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]