mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-21 15:43:18 +03:00
put hostname + port into one row
This commit is contained in:
@@ -121,7 +121,31 @@
|
|||||||
-->
|
-->
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwActionRow">
|
<object class="AdwActionRow">
|
||||||
<property name="title">port</property>
|
<property name="title">hostname &amp; port</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="copy-hostname-button">
|
||||||
|
<!--<property name="icon-name">edit-copy-symbolic</property>-->
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="clicked" handler="handle_copy_hostname" swapped="true"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="spacing">30</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="hostname_label">
|
||||||
|
<property name="label"><span font_style="italic" font_weight="light" foreground="darkgrey">could not determine hostname</span></property>
|
||||||
|
<property name="use-markup">true</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="hostname_copy_icon">
|
||||||
|
<property name="icon-name">edit-copy-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="port_entry">
|
<object class="GtkEntry" id="port_entry">
|
||||||
<property name="max-width-chars">5</property>
|
<property name="max-width-chars">5</property>
|
||||||
@@ -159,25 +183,6 @@
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="AdwActionRow">
|
|
||||||
<property name="title">hostname</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="hostname_label">
|
|
||||||
<property name="label"><span font_style="italic" font_weight="light" foreground="darkgrey">could not determine hostname</span></property>
|
|
||||||
<property name="use-markup">true</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="copy-hostname-button">
|
|
||||||
<property name="icon-name">edit-copy-symbolic</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<signal name="clicked" handler="handle_copy_hostname" swapped="true"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwActionRow" id="fingerprint_row">
|
<object class="AdwActionRow" id="fingerprint_row">
|
||||||
<property name="title">certificate fingerprint</property>
|
<property name="title">certificate fingerprint</property>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use adw::subclass::prelude::*;
|
|||||||
use adw::{prelude::*, ActionRow, PreferencesGroup, ToastOverlay};
|
use adw::{prelude::*, ActionRow, PreferencesGroup, ToastOverlay};
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use gtk::glib::clone;
|
use gtk::glib::clone;
|
||||||
use gtk::{gdk, gio, glib, Button, CompositeTemplate, Entry, Label, ListBox};
|
use gtk::{gdk, gio, glib, Button, CompositeTemplate, Entry, Image, Label, ListBox};
|
||||||
|
|
||||||
use lan_mouse_ipc::{FrontendRequestWriter, DEFAULT_PORT};
|
use lan_mouse_ipc::{FrontendRequestWriter, DEFAULT_PORT};
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@ pub struct Window {
|
|||||||
#[template_child]
|
#[template_child]
|
||||||
pub port_entry: TemplateChild<Entry>,
|
pub port_entry: TemplateChild<Entry>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
pub hostname_copy_icon: TemplateChild<Image>,
|
||||||
|
#[template_child]
|
||||||
pub hostname_label: TemplateChild<Label>,
|
pub hostname_label: TemplateChild<Label>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub toast_overlay: TemplateChild<ToastOverlay>,
|
pub toast_overlay: TemplateChild<ToastOverlay>,
|
||||||
@@ -76,20 +78,21 @@ impl Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn handle_copy_hostname(&self, button: &Button) {
|
fn handle_copy_hostname(&self, _: &Button) {
|
||||||
if let Ok(hostname) = hostname::get() {
|
if let Ok(hostname) = hostname::get() {
|
||||||
let display = gdk::Display::default().unwrap();
|
let display = gdk::Display::default().unwrap();
|
||||||
let clipboard = display.clipboard();
|
let clipboard = display.clipboard();
|
||||||
clipboard.set_text(hostname.to_str().expect("hostname: invalid utf8"));
|
clipboard.set_text(hostname.to_str().expect("hostname: invalid utf8"));
|
||||||
button.set_icon_name("emblem-ok-symbolic");
|
let icon = self.hostname_copy_icon.clone();
|
||||||
button.set_css_classes(&["success"]);
|
icon.set_icon_name(Some("emblem-ok-symbolic"));
|
||||||
|
icon.set_css_classes(&["success"]);
|
||||||
glib::spawn_future_local(clone!(
|
glib::spawn_future_local(clone!(
|
||||||
#[weak]
|
#[weak]
|
||||||
button,
|
icon,
|
||||||
async move {
|
async move {
|
||||||
glib::timeout_future_seconds(1).await;
|
glib::timeout_future_seconds(1).await;
|
||||||
button.set_icon_name("edit-copy-symbolic");
|
icon.set_icon_name(Some("edit-copy-symbolic"));
|
||||||
button.set_css_classes(&[]);
|
icon.set_css_classes(&[]);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user