update
This commit is contained in:
parent
2eaca282bd
commit
dbcd7c11b2
44
src/main.rs
44
src/main.rs
@ -54,7 +54,6 @@ fn main() {
|
||||
.application_id("org.example.HelloWorld")
|
||||
.build();
|
||||
app.connect_activate(|app| {
|
||||
|
||||
let provider = CssProvider::new();
|
||||
provider.load_from_data(include_bytes!("style.css"));
|
||||
StyleContext::add_provider_for_display(
|
||||
@ -71,7 +70,6 @@ fn main() {
|
||||
.build();
|
||||
|
||||
|
||||
|
||||
let ui_layout_main_box = gtk4::Box::new(Orientation::Vertical, 1);
|
||||
let ui_main_scroller_window = ScrolledWindow::builder().build();
|
||||
let ui_command_editor = gtk4::Entry::new();
|
||||
@ -82,15 +80,13 @@ fn main() {
|
||||
ui_log_view.set_css_classes(&["textview1"]);
|
||||
ui_log_view.set_vexpand(true);
|
||||
ui_main_scroller_window.set_child(Some(&ui_log_view));
|
||||
|
||||
ui_main_window.set_child(Some(&ui_layout_main_box));
|
||||
|
||||
ui_layout_main_box.append(&ui_main_scroller_window);
|
||||
ui_layout_main_box.append(&ui_command_editor);
|
||||
|
||||
ui_command_editor.add_css_class("entry1");
|
||||
ui_command_editor.show();
|
||||
ui_layout_main_box.show();
|
||||
ui_log_view.show();
|
||||
|
||||
|
||||
let ui_receive_windows = ApplicationWindow::builder()
|
||||
@ -99,19 +95,33 @@ fn main() {
|
||||
.title("log")
|
||||
.build();
|
||||
ui_receive_windows.set_hide_on_close(true);
|
||||
let ui_receive_box = gtk4::Box::new(Orientation::Vertical, 1);
|
||||
let menu_bar = gtk4::PopoverMenuBar::builder().build();
|
||||
let ui_receive_scroll_window = ScrolledWindow::builder().build();
|
||||
let ui_receive_view = gtk4::TextView::new();
|
||||
let menu_item_first = gtk4::MenuButton::new();
|
||||
menu_item_first.set_label("hello");
|
||||
menu_bar.add_child(&menu_item_first,"first");
|
||||
menu_bar.show();
|
||||
ui_receive_box.append(&menu_bar);
|
||||
ui_receive_box.append(&ui_receive_scroll_window);
|
||||
ui_receive_scroll_window.set_child(Some(&ui_receive_view));
|
||||
|
||||
ui_receive_view.set_vexpand(true);
|
||||
ui_receive_view.set_vscroll_policy(ScrollablePolicy::Natural);
|
||||
ui_receive_view.set_editable(false);
|
||||
ui_receive_view.show();
|
||||
ui_receive_windows.set_child(Some(&ui_receive_view));
|
||||
|
||||
|
||||
|
||||
// ui_receive_windows.set_child(Some(&ui_receive_scroll_window));
|
||||
ui_receive_windows.set_child(Some(&ui_receive_box));
|
||||
ui_receive_windows.show();
|
||||
ui_main_window.show();
|
||||
ui_log_view.show();
|
||||
|
||||
|
||||
|
||||
// add short cut to open command panel.
|
||||
// ui_receive_windows.
|
||||
let trigger = gtk4::ShortcutTrigger::parse_string("<Control>P").unwrap();
|
||||
let shortcut = gtk4::Shortcut::builder().trigger(&trigger).build();
|
||||
|
||||
|
||||
let (sender_ui_upd, receiver_ui_upd) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
||||
@ -338,11 +348,23 @@ fn main_proc(to_main_tx: Sender<Message>, rx: Receiver<Message>, ui_upd: glib::S
|
||||
}
|
||||
}
|
||||
Message::PortHaveData(data) => {
|
||||
ui_upd.send(Message::UiUpdateReceiveMsg(String::from_utf8_lossy(&*data).parse().unwrap())).unwrap();
|
||||
let mut message_show = String::new();
|
||||
for i in data {
|
||||
// let char = i as char;
|
||||
// // let char = 'i';
|
||||
if i.is_ascii_alphanumeric() || i.is_ascii_whitespace() || i.is_ascii_punctuation() || i.is_ascii_graphic() {
|
||||
message_show.push(i as char);
|
||||
}
|
||||
}
|
||||
// ui_upd.send(Message::UiUpdateReceiveMsg(String::from_utf8_lossy(&*data).parse().unwrap())).unwrap();
|
||||
ui_upd.send(Message::UiUpdateReceiveMsg(message_show)).unwrap();
|
||||
}
|
||||
Message::PortCloseSucceed => {
|
||||
ui_upd.send(Message::UiUpdateLog("Close port succeed\n".to_string())).unwrap();
|
||||
}
|
||||
Message::PortError(msg) => {
|
||||
ui_upd.send(Message::UiUpdateLog(format!("port closed by error: {}", msg))).unwrap();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user