Add send btn

This commit is contained in:
ranfdev
2023-10-24 16:19:19 +02:00
parent a88308d67a
commit 82c205b150
5 changed files with 44 additions and 23 deletions

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 15 8 l -14 -7 v 6 l 8 1 l -8 1 v 6 z m 0 0" fill="#222222"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -760 -764)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -760 -764)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -760 -764)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -10,5 +10,6 @@
</gresource>
<gresource prefix="/com/ranfdev/Notify/icons/16x16/status/">
<file preprocess="xml-stripblanks" alias="dice3-symbolic.svg">../icons/dice3-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="paper-plane-symbolic.svg">../icons/paper-plane-symbolic.svg</file>
</gresource>
</gresources>

View File

@ -132,8 +132,19 @@ template $NotifyWindow : Adw.ApplicationWindow {
margin-start: 8;
margin-end: 8;
Adw.Clamp {
Entry entry {
placeholder-text: "Message...";
Gtk.Box {
spacing: 8;
Entry entry {
placeholder-text: "Message...";
hexpand: true;
}
Gtk.Button send_btn {
styles [
"circular",
"suggested-action"
]
icon-name: "paper-plane-symbolic";
}
}
}
}

View File

@ -126,6 +126,7 @@ impl AddSubscriptionDialog {
add_css_class: "suggested-action",
add_css_class: "pill",
set_halign: gtk::Align::Center,
set_sensitive: false,
connect_clicked[obj] => move |_| {
obj.emit_subscribe_request();
obj.close();

View File

@ -72,6 +72,8 @@ mod imp {
pub message_scroll: TemplateChild<gtk::ScrolledWindow>,
#[template_child]
pub banner: TemplateChild<adw::Banner>,
#[template_child]
pub send_btn: TemplateChild<gtk::Button>,
pub notifier: OnceCell<system_notifier::Client>,
pub conn: OnceCell<gio::SocketConnection>,
pub settings: gio::Settings,
@ -81,24 +83,25 @@ mod imp {
impl Default for NotifyWindow {
fn default() -> Self {
let this = Self {
headerbar: TemplateChild::default(),
message_list: TemplateChild::default(),
entry: TemplateChild::default(),
subscription_view: TemplateChild::default(),
navigation_split_view: TemplateChild::default(),
subscription_menu_btn: TemplateChild::default(),
subscription_list: TemplateChild::default(),
toast_overlay: TemplateChild::default(),
stack: TemplateChild::default(),
welcome_view: TemplateChild::default(),
list_view: TemplateChild::default(),
message_scroll: TemplateChild::default(),
banner: TemplateChild::default(),
headerbar: Default::default(),
message_list: Default::default(),
entry: Default::default(),
subscription_view: Default::default(),
navigation_split_view: Default::default(),
subscription_menu_btn: Default::default(),
subscription_list: Default::default(),
toast_overlay: Default::default(),
stack: Default::default(),
welcome_view: Default::default(),
list_view: Default::default(),
message_scroll: Default::default(),
banner: Default::default(),
subscription_list_model: gio::ListStore::new::<Subscription>(),
settings: gio::Settings::new(APP_ID),
notifier: OnceCell::new(),
conn: OnceCell::new(),
banner_binding: Cell::new(None),
notifier: Default::default(),
conn: Default::default(),
banner_binding: Default::default(),
send_btn: Default::default(),
};
this
@ -139,7 +142,6 @@ mod imp {
this.show_subscription_info();
});
klass.install_action("win.clear-notifications", None, |this, _, _| {
/*spawn_local(this.subscription().clear_notifications().map_err(this.near_toast_overlay().error_handler()));*/
this.selected_subscription().map(|sub| {
this.spawn_with_near_toast(sub.clear_notifications());
});
@ -203,23 +205,27 @@ impl NotifyWindow {
// Load latest window state
obj.load_window_size();
obj.bind_message_list();
obj.connect_entry_changed();
obj.connect_entry_and_send_btn();
obj.connect_items_changed();
obj.selected_subscription_changed(None);
obj.bind_flag_read();
obj
}
fn connect_entry_changed(&self) {
fn connect_entry_and_send_btn(&self) {
let imp = self.imp();
let this = self.clone();
imp.entry.connect_activate(move |entry| {
let entry = imp.entry.clone();
let publish = move || {
let p = this
.selected_subscription()
.unwrap()
.publish(entry.text().as_str());
entry.spawn_with_near_toast(async move { p.await });
});
};
let publishc = publish.clone();
imp.entry.connect_activate(move |_| publishc());
imp.send_btn.connect_clicked(move |_| publish());
}
fn show_subscription_info(&self) {
let sub = SubscriptionInfoDialog::new(self.selected_subscription().unwrap());