fix: fixing one of the last few err (i think so)
This commit is contained in:
@@ -854,23 +854,24 @@ fn initialize_window<B: DisplayBackend>(
|
||||
|
||||
window.set_title(Some(&format!("Ewwii - {}", window_init.name)));
|
||||
// window.set_position(gtk4::WindowPosition::None);
|
||||
window.set_gravity(gdk::Gravity::Center);
|
||||
// window.set_gravity(gdk::Gravity::Center);
|
||||
|
||||
if let Some(actual_window_rect) = actual_window_rect {
|
||||
window.set_size_request(actual_window_rect.width(), actual_window_rect.height());
|
||||
window.set_default_size(actual_window_rect.width(), actual_window_rect.height());
|
||||
}
|
||||
window.set_decorated(false);
|
||||
window.set_skip_taskbar_hint(true);
|
||||
window.set_skip_pager_hint(true);
|
||||
// window.set_skip_taskbar_hint(true);
|
||||
// window.set_skip_pager_hint(true);
|
||||
|
||||
// run on_screen_changed to set the visual correctly initially.
|
||||
on_screen_changed(&window, None);
|
||||
window.connect_screen_changed(on_screen_changed);
|
||||
// on_screen_changed(&window, None);
|
||||
// window.connect_screen_changed(on_screen_changed);
|
||||
|
||||
window.add(&root_widget);
|
||||
window.set_child(Some(&root_widget));
|
||||
|
||||
window.realize();
|
||||
// i dont think its needed in gtk4
|
||||
// window.realize();
|
||||
|
||||
#[cfg(feature = "x11")]
|
||||
if B::IS_X11 {
|
||||
@@ -908,7 +909,7 @@ fn initialize_window<B: DisplayBackend>(
|
||||
display_backend::set_xprops(&window, monitor, window_init)?;
|
||||
}
|
||||
|
||||
window.show_all();
|
||||
window.show();
|
||||
|
||||
Ok(EwwiiWindow {
|
||||
name: window_init.name.clone(),
|
||||
@@ -968,7 +969,6 @@ fn apply_window_position(
|
||||
monitor_geometry: gdk::Rectangle,
|
||||
window: &Window,
|
||||
) -> Result<()> {
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::{ConfigureWindowAux, ConnectionExt, Window as XWindow};
|
||||
|
||||
let gdk_surface = window.surface().context("Failed to get gdk surface from gtk window")?;
|
||||
@@ -990,12 +990,12 @@ fn apply_window_position(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_screen_changed(window: &Window, _old_screen: Option<&gdk::Screen>) {
|
||||
let visual = window.screen().and_then(|screen| {
|
||||
screen.rgba_visual().filter(|_| screen.is_composited()).or_else(|| screen.system_visual())
|
||||
});
|
||||
window.set_visual(visual.as_ref());
|
||||
}
|
||||
// fn on_screen_changed(window: &Window, _old_screen: Option<&gdk::Screen>) {
|
||||
// let visual = window.screen().and_then(|screen| {
|
||||
// screen.rgba_visual().filter(|_| screen.is_composited()).or_else(|| screen.system_visual())
|
||||
// });
|
||||
// window.set_visual(visual.as_ref());
|
||||
// }
|
||||
|
||||
/// Get the monitor geometry of a given monitor, or the default if none is given
|
||||
fn get_gdk_monitor(identifier: Option<MonitorIdentifier>) -> Result<Monitor> {
|
||||
|
||||
@@ -38,7 +38,8 @@ impl DisplayBackend for NoBackend {
|
||||
) -> Option<Window> {
|
||||
// top level
|
||||
let window = Window::new();
|
||||
window.move_(x, y);
|
||||
|
||||
// window.move_(x, y);
|
||||
|
||||
Some(window)
|
||||
}
|
||||
|
||||
@@ -198,16 +198,6 @@ impl WidgetRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn remove_widget(&mut self, widget_id: u64) {
|
||||
// if let Some(entry) = self.widgets.remove(&widget_id) {
|
||||
// if let Some(parent) = entry.widget.parent() {
|
||||
// if let Ok(container) = parent.downcast::<gtk4::Container>() {
|
||||
// container.remove(&entry.widget);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn remove_widget(&mut self, widget_id: u64, parent_id: u64) {
|
||||
log::trace!("Removing '{}' from '{}'", widget_id, parent_id);
|
||||
if let Some(entry) = self.widgets.remove(&widget_id) {
|
||||
@@ -305,13 +295,10 @@ pub(super) fn build_gtk_overlay(
|
||||
|
||||
// we have more than one child, we can unwrap
|
||||
let first = children.next().unwrap()?;
|
||||
gtk_widget.add(&first);
|
||||
first.show();
|
||||
gtk_widget.set_child(Some(&first));
|
||||
for child in children {
|
||||
let child = child?;
|
||||
gtk_widget.add_overlay(&child);
|
||||
gtk_widget.set_overlay_pass_through(&child, true);
|
||||
child.show();
|
||||
}
|
||||
|
||||
resolve_rhai_widget_attrs(>k_widget.clone().upcast::<gtk4::Widget>(), &props)?;
|
||||
@@ -393,13 +380,19 @@ pub(super) fn build_center_box(
|
||||
)?;
|
||||
|
||||
let gtk_widget = gtk4::Box::new(orientation, 0);
|
||||
gtk_widget.pack_start(&first, true, true, 0);
|
||||
gtk_widget.set_center_widget(Some(¢er));
|
||||
gtk_widget.pack_end(&end, true, true, 0);
|
||||
|
||||
first.show();
|
||||
center.show();
|
||||
end.show();
|
||||
first.set_hexpand(true);
|
||||
first.set_halign(gtk4::Align::Start);
|
||||
|
||||
center.set_hexpand(true);
|
||||
center.set_halign(gtk4::Align::Center);
|
||||
|
||||
end.set_hexpand(true);
|
||||
end.set_halign(gtk4::Align::End);
|
||||
|
||||
gtk_widget.append(&first);
|
||||
gtk_widget.append(¢er);
|
||||
gtk_widget.append(&end);
|
||||
|
||||
let gtk_widget_clone = gtk_widget.clone();
|
||||
|
||||
@@ -682,7 +675,6 @@ pub(super) fn build_event_box(
|
||||
gtk_widget.add_controller(drag_source_ctl);
|
||||
|
||||
let apply_props = |props: &Map,
|
||||
widget: >k4::Box,
|
||||
controller_data: Rc<RefCell<EventBoxCtrlData>>|
|
||||
-> Result<()> {
|
||||
// timeout - timeout of the command. Default: "200ms"
|
||||
@@ -740,11 +732,11 @@ pub(super) fn build_event_box(
|
||||
Ok(())
|
||||
};
|
||||
|
||||
apply_props(&props, >k_widget, controller_data.clone())?;
|
||||
apply_props(&props, controller_data.clone())?;
|
||||
|
||||
let gtk_widget_clone = gtk_widget.clone();
|
||||
let update_fn: UpdateFn = Box::new(move |props: &Map| {
|
||||
let _ = apply_props(props, >k_widget_clone, controller_data.clone());
|
||||
let _ = apply_props(props, controller_data.clone());
|
||||
|
||||
// now re-apply generic widget attrs
|
||||
if let Err(err) =
|
||||
@@ -757,9 +749,9 @@ pub(super) fn build_event_box(
|
||||
let count = children.len();
|
||||
|
||||
if count < 1 {
|
||||
bail!("expander must contain exactly one element");
|
||||
bail!("event box must contain exactly one element");
|
||||
} else if count > 1 {
|
||||
bail!("expander must contain exactly one element, but got more");
|
||||
bail!("event box must contain exactly one element, but got more");
|
||||
}
|
||||
|
||||
let child = children.get(0).cloned().ok_or_else(|| anyhow!("missing child 0"))?;
|
||||
@@ -808,8 +800,8 @@ pub(super) fn build_gtk_stack(
|
||||
let transition = get_string_prop(&props, "transition", Some("crossfade"))?;
|
||||
widget.set_transition_type(parse_stack_transition(&transition)?);
|
||||
|
||||
let same_size = get_bool_prop(&props, "same_size", Some(false))?;
|
||||
widget.set_homogeneous(same_size);
|
||||
// let same_size = get_bool_prop(&props, "same_size", Some(false))?;
|
||||
// widget.set_homogeneous(same_size);
|
||||
|
||||
Ok(())
|
||||
};
|
||||
@@ -1122,7 +1114,6 @@ pub(super) fn build_gtk_image(
|
||||
widget.set_from_pixbuf(Some(&frame_pixbuf));
|
||||
|
||||
let widget_clone = widget.clone();
|
||||
let animation_clone = pixbuf_animation.clone();
|
||||
|
||||
if let Some(delay) = iter.delay_time() {
|
||||
glib::timeout_add_local(delay, move || {
|
||||
@@ -1168,9 +1159,7 @@ pub(super) fn build_gtk_image(
|
||||
}
|
||||
|
||||
if let Ok(icon_name) = get_string_prop(&props, "icon", None) {
|
||||
let icon_size = get_string_prop(&props, "icon-size", Some("button"))?;
|
||||
widget.set_from_icon_name(Some(&icon_name), parse_icon_size(&icon_size)?);
|
||||
// return Ok(widget);
|
||||
widget.set_icon_name(Some(&icon_name));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -2147,6 +2136,10 @@ pub(super) fn resolve_rhai_widget_attrs(gtk_widget: >k4::Widget, props: &Map)
|
||||
gtk_widget.set_tooltip_text(Some(&tooltip));
|
||||
}
|
||||
|
||||
if let Ok(can_target) = get_bool_prop(&props, "can_target", None) {
|
||||
gtk_widget.set_can_target(can_target);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -187,16 +187,6 @@ pub(super) fn parse_revealer_transition(t: &str) -> Result<gtk4::RevealerTransit
|
||||
}
|
||||
}
|
||||
|
||||
/// Gtk Image
|
||||
// icon-size - "normal", "large"
|
||||
pub(super) fn parse_icon_size(o: &str) -> Result<gtk4::IconSize> {
|
||||
match o.to_ascii_lowercase().as_str() {
|
||||
"normal" => Ok(gtk4::IconSize::Normal),
|
||||
"large" => Ok(gtk4::IconSize::Large),
|
||||
_ => Err(anyhow!("Invalid icon size: '{}'", o)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Event box
|
||||
// dragtype - "file", "text"
|
||||
pub(super) enum DragEntryType {
|
||||
|
||||
Reference in New Issue
Block a user