upgrade gtkrs
This commit is contained in:
parent
6b53c2cded
commit
57263e77c7
12 changed files with 159 additions and 254 deletions
|
|
@ -45,7 +45,7 @@ impl ApplicationImpl for PanelAppInner {
|
|||
self.activated.set(true);
|
||||
|
||||
let display = gdk::Display::default().unwrap();
|
||||
let monitors = display.monitors().unwrap();
|
||||
let monitors = display.monitors();
|
||||
|
||||
for i in 0..monitors.n_items() {
|
||||
obj.add_window_for_monitor(monitors.item(i).unwrap().downcast().unwrap());
|
||||
|
|
|
|||
|
|
@ -19,5 +19,7 @@ mod window;
|
|||
use application::PanelApp;
|
||||
|
||||
fn main() {
|
||||
glib::MainContext::default().with_thread_default(|| PanelApp::new().run());
|
||||
glib::MainContext::default()
|
||||
.with_thread_default(|| PanelApp::new().run())
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl ObjectImpl for MprisPlayerInner {
|
|||
..set_max_width_chars(20);
|
||||
..set_attributes(Some(&cascade! {
|
||||
pango::AttrList::new();
|
||||
..insert(pango::Attribute::new_weight(pango::Weight::Bold));
|
||||
..insert(pango::AttrInt::new_weight(pango::Weight::Bold));
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
@ -63,17 +63,17 @@ impl ObjectImpl for MprisPlayerInner {
|
|||
};
|
||||
|
||||
let backward_button = cascade! {
|
||||
gtk4::Button::from_icon_name(Some("media-skip-backward-symbolic"));
|
||||
gtk4::Button::from_icon_name("media-skip-backward-symbolic");
|
||||
..connect_clicked(clone!(@strong obj => move |_| obj.call("Previous")));
|
||||
};
|
||||
|
||||
let play_pause_button = cascade! {
|
||||
gtk4::Button::from_icon_name(Some("media-playback-start-symbolic"));
|
||||
gtk4::Button::from_icon_name("media-playback-start-symbolic");
|
||||
..connect_clicked(clone!(@strong obj => move |_| obj.call("PlayPause")));
|
||||
};
|
||||
|
||||
let forward_button = cascade! {
|
||||
gtk4::Button::from_icon_name(Some("media-skip-forward-symbolic"));
|
||||
gtk4::Button::from_icon_name("media-skip-forward-symbolic");
|
||||
..connect_clicked(clone!(@strong obj => move |_| obj.call("Next")));
|
||||
};
|
||||
|
||||
|
|
@ -168,10 +168,8 @@ impl MprisPlayer {
|
|||
let pixbuf = async {
|
||||
// TODO: Security?
|
||||
let file = gio::File::for_uri(&arturl?);
|
||||
let stream = file.read_async_future(glib::PRIORITY_DEFAULT).await.ok()?;
|
||||
gdk_pixbuf::Pixbuf::from_stream_async_future(&stream)
|
||||
.await
|
||||
.ok()
|
||||
let stream = file.read_future(glib::PRIORITY_DEFAULT).await.ok()?;
|
||||
gdk_pixbuf::Pixbuf::from_stream_future(&stream).await.ok()
|
||||
}
|
||||
.await;
|
||||
if let Some(pixbuf) = pixbuf {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ impl NotificationPopover {
|
|||
|
||||
fn stop_timer(&self) {
|
||||
if let Some(source) = self.inner().source.borrow_mut().take() {
|
||||
glib::source_remove(source);
|
||||
source.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl ObjectImpl for NotificationWidgetInner {
|
|||
..set_max_width_chars(20);
|
||||
..set_attributes(Some(&cascade! {
|
||||
pango::AttrList::new();
|
||||
..insert(pango::Attribute::new_weight(pango::Weight::Bold));
|
||||
..insert(pango::AttrInt::new_weight(pango::Weight::Bold));
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ impl ObjectImpl for NotificationWidgetInner {
|
|||
..style_context().add_class("flat");
|
||||
..set_valign(gtk4::Align::Start);
|
||||
..set_child(Some(&cascade! {
|
||||
gtk4::Image::from_icon_name(Some("window-close-symbolic"));
|
||||
gtk4::Image::from_icon_name("window-close-symbolic");
|
||||
..set_pixel_size(8);
|
||||
}));
|
||||
..connect_clicked(clone!(@weak obj => move |_| {
|
||||
|
|
|
|||
|
|
@ -268,8 +268,8 @@ impl fmt::Debug for Hints {
|
|||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Clone, Copy, Hash, glib::GBoxed, PartialEq, Eq)]
|
||||
#[gboxed(type_name = "S76NotificationId")]
|
||||
#[derive(Debug, Clone, Copy, Hash, glib::Boxed, PartialEq, Eq)]
|
||||
#[boxed_type(name = "S76NotificationId")]
|
||||
pub struct NotificationId(NonZeroU32);
|
||||
|
||||
impl Default for NotificationId {
|
||||
|
|
@ -331,7 +331,7 @@ impl Notifications {
|
|||
if let Some(event) = receiver.next().await {
|
||||
match event {
|
||||
Event::NotificationReceived(id) => {
|
||||
notifications.emit_by_name("notification-received", &[&id]).unwrap();
|
||||
notifications.emit_by_name::<()>("notification-received", &[&id]);
|
||||
}
|
||||
Event::CloseNotification(id) => {
|
||||
notifications.close_notification(id, CloseReason::Call).await
|
||||
|
|
@ -356,7 +356,7 @@ impl Notifications {
|
|||
.unwrap()
|
||||
.remove(&id);
|
||||
|
||||
self.emit_by_name("notification-closed", &[&id]).unwrap();
|
||||
self.emit_by_name::<()>("notification-closed", &[&id]);
|
||||
|
||||
if let Some(connection) = self.inner().connection.get() {
|
||||
let ctxt = SignalContext::new(connection, PATH).unwrap(); // XXX unwrap?
|
||||
|
|
@ -401,7 +401,6 @@ impl Notifications {
|
|||
}
|
||||
None
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn connect_notification_closed<F: Fn(NotificationId) + 'static>(
|
||||
|
|
@ -413,6 +412,5 @@ impl Notifications {
|
|||
cb(id);
|
||||
None
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,15 +44,8 @@ impl WidgetImpl for PopoverContainerInner {
|
|||
}
|
||||
|
||||
fn size_allocate(&self, _obj: &PopoverContainer, width: i32, height: i32, baseline: i32) {
|
||||
self.child.size_allocate(
|
||||
>k4::Allocation {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width,
|
||||
height,
|
||||
},
|
||||
baseline,
|
||||
);
|
||||
self.child
|
||||
.size_allocate(>k4::Allocation::new(0, 0, width, height), baseline);
|
||||
self.popover.present();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ impl StatusMenu {
|
|||
}
|
||||
glib::MainContext::default().spawn_local(clone!(@strong self_ => async move {
|
||||
let _ = self_.inner().dbus_menu.event(id, "clicked", &0.into(), 0).await;
|
||||
}))
|
||||
}));
|
||||
}));
|
||||
};
|
||||
box_.append(&button);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl ObjectImpl for TimeButtonInner {
|
|||
gtk4::Label::new(None);
|
||||
..set_attributes(Some(&cascade! {
|
||||
pango::AttrList::new();
|
||||
..insert(pango::Attribute::new_weight(pango::Weight::Bold));
|
||||
..insert(pango::AttrInt::new_weight(pango::Weight::Bold));
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ impl TimeButton {
|
|||
}
|
||||
|
||||
fn opening(&self) {
|
||||
let date = glib::DateTime::new_now(&glib::TimeZone::new_local()).unwrap();
|
||||
let date = glib::DateTime::now(&glib::TimeZone::local()).unwrap();
|
||||
self.inner().calendar.clear_marks();
|
||||
self.inner().calendar.select_day(&date);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ fn button(text: &str) -> gtk4::Button {
|
|||
gtk4::Label::new(Some(text));
|
||||
..set_attributes(Some(&cascade! {
|
||||
pango::AttrList::new();
|
||||
..insert(pango::Attribute::new_weight(pango::Weight::Bold));
|
||||
..insert(pango::AttrInt::new_weight(pango::Weight::Bold));
|
||||
}));
|
||||
};
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ impl WidgetImpl for PanelWindowInner {
|
|||
fn realize(&self, obj: &PanelWindow) {
|
||||
self.parent_realize(obj);
|
||||
|
||||
let surface = obj.surface().unwrap();
|
||||
let surface = obj.surface();
|
||||
surface.connect_layout(clone!(@weak obj => move |_surface, width, height| {
|
||||
let size = Some((width, height));
|
||||
if obj.inner().size.replace(size) != size {
|
||||
|
|
@ -180,7 +180,7 @@ impl PanelWindow {
|
|||
|
||||
monitor.connect_invalidate(clone!(@weak obj => move |_| obj.close()));
|
||||
|
||||
obj.set_size_request(monitor.geometry().width, 0);
|
||||
obj.set_size_request(monitor.geometry().width(), 0);
|
||||
obj.inner().monitor.set(monitor);
|
||||
|
||||
obj.inner()
|
||||
|
|
@ -198,7 +198,7 @@ impl PanelWindow {
|
|||
|
||||
fn monitor_geometry_changed(&self) {
|
||||
let geometry = self.inner().monitor.geometry();
|
||||
self.set_size_request(geometry.width, 0);
|
||||
self.set_size_request(geometry.width(), 0);
|
||||
|
||||
let height = if let Some((_width, height)) = self.inner().size.get() {
|
||||
height as x::c_ulong
|
||||
|
|
@ -207,12 +207,12 @@ impl PanelWindow {
|
|||
};
|
||||
|
||||
if let Some((display, surface)) = x::get_window_x11(self) {
|
||||
let start_x = geometry.x as x::c_ulong;
|
||||
let end_x = start_x + geometry.width as x::c_ulong - 1;
|
||||
let start_x = geometry.x() as x::c_ulong;
|
||||
let end_x = start_x + geometry.width() as x::c_ulong - 1;
|
||||
|
||||
unsafe {
|
||||
let y = if BOTTOM {
|
||||
geometry.height as x::c_int - height as x::c_int
|
||||
geometry.height() as x::c_int - height as x::c_int
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue