revert X Property change, and cleanup formatting

This commit is contained in:
Ashley Wulber 2021-12-29 17:31:01 -05:00
parent 5a4a802751
commit 65f43a9300
32 changed files with 459 additions and 429 deletions

View file

@ -1,12 +1,12 @@
use std::cell::RefCell;
use std::rc::Rc;
use glib::{FromVariant, ParamFlags, ParamSpec, ToVariant, Value, Variant, VariantTy}; use glib::{FromVariant, ParamFlags, ParamSpec, ToVariant, Value, Variant, VariantTy};
use gtk4::glib; use gtk4::glib;
use gtk4::prelude::*; use gtk4::prelude::*;
use gtk4::subclass::prelude::*; use gtk4::subclass::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::cell::RefCell;
use std::rc::Rc;
use super::AppGroupData; use super::AppGroupData;
// Object holding the state // Object holding the state
@ -142,7 +142,7 @@ impl ObjectImpl for AppGroup {
.get::<Variant>() .get::<Variant>()
.expect("The icon needs to be a Variant"), .expect("The icon needs to be a Variant"),
) )
.expect("The icon variant needs to be a Vec<String>"); .expect("The icon variant needs to be a Vec<String>");
self.data.borrow_mut().app_names = appnames; self.data.borrow_mut().app_names = appnames;
} }
_ => unimplemented!(), _ => unimplemented!(),

View file

@ -1,5 +1,3 @@
mod imp;
use glib::Object; use glib::Object;
use glib::ObjectExt; use glib::ObjectExt;
use glib::ToVariant; use glib::ToVariant;
@ -7,6 +5,8 @@ use gtk4::glib;
use gtk4::subclass::prelude::*; use gtk4::subclass::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct AppGroup(ObjectSubclass<imp::AppGroup>); pub struct AppGroup(ObjectSubclass<imp::AppGroup>);
} }
@ -20,7 +20,7 @@ impl AppGroup {
("icon", &data.icon), ("icon", &data.icon),
("category", &data.category), ("category", &data.category),
]) ])
.expect("Failed to create `ApplicationObject`."); .expect("Failed to create `ApplicationObject`.");
if let Err(e) = self_.set_property("appnames", data.app_names.to_variant()) { if let Err(e) = self_.set_property("appnames", data.app_names.to_variant()) {
println!("failed to set category icon property"); println!("failed to set category icon property");
dbg!(e); dbg!(e);

View file

@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="GridItem" parent="GtkBox"> <template class="GridItem" parent="GtkBox">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="hexpand">true</property>
<property name="margin-top">4</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="margin-bottom">4</property>
<child>
<object class="GtkImage" id="image">
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="pixel-size">64</property>
</object>
</child>
<child>
<object class="GtkLabel" id="name">
<property name="halign">center</property> <property name="halign">center</property>
<property name="ellipsize">end</property> <property name="hexpand">true</property>
<style> <property name="margin-top">4</property>
<class name="title-5" /> <property name="margin-start">4</property>
</style> <property name="margin-end">4</property>
</object> <property name="margin-bottom">4</property>
</child> <child>
</template> <object class="GtkImage" id="image">
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="pixel-size">64</property>
</object>
</child>
<child>
<object class="GtkLabel" id="name">
<property name="halign">center</property>
<property name="ellipsize">end</property>
<style>
<class name="title-5"/>
</style>
</object>
</child>
</template>
</interface> </interface>

View file

@ -1,10 +1,10 @@
use std::cell::Cell;
use gtk4 as gtk;
use gtk::CompositeTemplate;
use gtk::glib; use gtk::glib;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk4 as gtk;
use std::cell::Cell;
use gtk::CompositeTemplate;
#[derive(Debug, Default, CompositeTemplate)] #[derive(Debug, Default, CompositeTemplate)]
#[template(file = "grid_item.ui")] #[template(file = "grid_item.ui")]
@ -32,5 +32,7 @@ impl ObjectSubclass for GridItem {
} }
impl ObjectImpl for GridItem {} impl ObjectImpl for GridItem {}
impl WidgetImpl for GridItem {} impl WidgetImpl for GridItem {}
impl BoxImpl for GridItem {} impl BoxImpl for GridItem {}

View file

@ -1,17 +1,18 @@
use crate::app_group::AppGroup;
use gdk4::ContentProvider; use gdk4::ContentProvider;
use gdk4::Display; use gdk4::Display;
use gio::File; use gio::File;
use gio::Icon; use gio::Icon;
use gtk::{gio, glib};
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::traits::WidgetExt;
use gtk4::DragSource; use gtk4::DragSource;
use gtk4::IconTheme; use gtk4::IconTheme;
mod imp; use gtk4::traits::WidgetExt;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk::{gio, glib};
use crate::app_group::AppGroup;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct GridItem(ObjectSubclass<imp::GridItem>) pub struct GridItem(ObjectSubclass<imp::GridItem>)

View file

@ -1,18 +1,18 @@
mod app_group;
mod grid_item;
mod utils;
mod window;
use gtk::gdk::Display;
use gtk::prelude::*;
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::CssProvider; use gtk4::CssProvider;
use gtk4::StyleContext; use gtk4::StyleContext;
use gtk::gdk::Display;
use gtk::prelude::*;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use x11rb::rust_connection::RustConnection; use x11rb::rust_connection::RustConnection;
use window::Window; use window::Window;
mod app_group;
mod grid_item;
mod utils;
mod window;
static X11_CONN: OnceCell<RustConnection> = OnceCell::new(); static X11_CONN: OnceCell<RustConnection> = OnceCell::new();
fn main() { fn main() {

View file

@ -2,12 +2,15 @@ child:hover {
transition: 100ms; transition: 100ms;
background: #888888; background: #888888;
} }
child { child {
border-radius: 5px; border-radius: 5px;
} }
gridview { gridview {
background: #333333; background: #333333;
} }
window { window {
background: #333333; background: #333333;
border-radius: 15px; border-radius: 15px;

View file

@ -1,7 +1,7 @@
use gtk4::ScrolledWindow;
use std::path::PathBuf; use std::path::PathBuf;
use gtk4::glib; use gtk4::glib;
use gtk4::ScrolledWindow;
pub fn data_path() -> PathBuf { pub fn data_path() -> PathBuf {
let mut path = glib::user_data_dir(); let mut path = glib::user_data_dir();

View file

@ -1,13 +1,13 @@
use gtk4 as gtk;
use gtk4::ScrolledWindow;
use std::fs::File; use std::fs::File;
use glib::signal::Inhibit; use glib::signal::Inhibit;
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib}; use gtk::{gio, glib};
use gtk::{CompositeTemplate, GridView, SearchEntry}; use gtk::{CompositeTemplate, GridView, SearchEntry};
use gtk4 as gtk;
use gtk4::ScrolledWindow;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use crate::app_group::AppGroup; use crate::app_group::AppGroup;
@ -45,6 +45,7 @@ impl ObjectSubclass for Window {
obj.init_template(); obj.init_template();
} }
} }
// Trait shared by all GObjects // Trait shared by all GObjects
impl ObjectImpl for Window { impl ObjectImpl for Window {
fn constructed(&self, obj: &Self::Type) { fn constructed(&self, obj: &Self::Type) {
@ -58,6 +59,7 @@ impl ObjectImpl for Window {
obj.setup_factory(); obj.setup_factory();
} }
} }
// Trait shared by all widgets // Trait shared by all widgets
impl WidgetImpl for Window {} impl WidgetImpl for Window {}

View file

@ -1,31 +1,33 @@
mod imp; use std::fs::File;
use crate::app_group::AppGroup;
use crate::app_group::AppGroupData;
use crate::grid_item::GridItem;
use crate::utils::data_path;
use crate::utils::set_group_scroll_policy;
use crate::X11_CONN;
use gdk4::Rectangle; use gdk4::Rectangle;
use gdk4_x11::X11Display; use gdk4_x11::X11Display;
use gdk4_x11::X11Surface; use gdk4_x11::X11Surface;
use glib::FromVariant; use glib::FromVariant;
use glib::Object; use glib::Object;
use glib::Variant; use glib::Variant;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib}; use gtk::{gio, glib};
use gtk::{Application, SignalListItemFactory}; use gtk::{Application, SignalListItemFactory};
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::Dialog; use gtk4::Dialog;
use gtk4::Entry; use gtk4::Entry;
use gtk4::Label; use gtk4::Label;
use libcosmic::x; use gtk::prelude::*;
use std::fs::File; use gtk::subclass::prelude::*;
use x11rb::connection::Connection; use x11rb::connection::Connection;
use x11rb::protocol::xproto; use x11rb::protocol::xproto;
use x11rb::protocol::xproto::ConnectionExt as OtherConnectionExt; use x11rb::protocol::xproto::ConnectionExt;
use x11rb::protocol::xproto::*;
use x11rb::wrapper::ConnectionExt; use libcosmic::x;
use crate::app_group::AppGroup;
use crate::app_group::AppGroupData;
use crate::grid_item::GridItem;
use crate::utils::data_path;
use crate::utils::set_group_scroll_policy;
use crate::X11_CONN;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct Window(ObjectSubclass<imp::Window>) pub struct Window(ObjectSubclass<imp::Window>)
@ -170,10 +172,10 @@ impl Window {
category: "".to_string(), category: "".to_string(),
}), }),
] ]
.iter() .iter()
.for_each(|group| { .for_each(|group| {
group_model.append(group); group_model.append(group);
}); });
let group_selection = gtk4::SingleSelection::new(Some(&group_model)); let group_selection = gtk4::SingleSelection::new(Some(&group_model));
imp.group_grid_view.set_model(Some(&group_selection)); imp.group_grid_view.set_model(Some(&group_selection));
} }
@ -407,27 +409,15 @@ impl Window {
.downcast::<X11Display>() .downcast::<X11Display>()
.expect("Failed to downgrade X11 Display."); .expect("Failed to downgrade X11 Display.");
xdisplay.error_trap_push(); xdisplay.error_trap_push();
let conn = X11_CONN.get().expect("Failed to get X11 connection"); unsafe {
let window_type_atom = conn x::change_property(
.intern_atom(false, b"_NET_WM_WINDOW_TYPE") &display,
.unwrap() &surface,
.reply() "_NET_WM_WINDOW_TYPE",
.unwrap() x::PropMode::Replace,
.atom; &[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DIALOG").unwrap()],
let dock_type_atom = conn );
.intern_atom(false, b"_NET_WM_WINDOW_TYPE_DIALOG") }
.unwrap()
.reply()
.unwrap()
.atom;
conn.change_property32(
PropMode::REPLACE,
surface.xid().try_into().unwrap(),
window_type_atom,
AtomEnum::ATOM,
&[dock_type_atom],
)
.unwrap();
let resize = glib::clone!(@weak window => move || { let resize = glib::clone!(@weak window => move || {
let s = window.surface().expect("Failed to get Surface for Window"); let s = window.surface().expect("Failed to get Surface for Window");
let height = window.height(); let height = window.height();

View file

@ -1,66 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="LauncherWindow" parent="GtkApplicationWindow"> <template class="LauncherWindow" parent="GtkApplicationWindow">
<property name="width-request">1200</property> <property name="width-request">1200</property>
<property name="title">Pop App Library</property> <property name="title">Pop App Library</property>
<property name="decorated">false</property> <property name="decorated">false</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child> <child>
<object class="GtkSearchEntry" id="entry"> <object class="GtkBox">
<property name="width-request">300</property> <property name="orientation">vertical</property>
<property name="halign">center</property> <property name="margin-top">12</property>
<property name="margin-bottom">12</property> <property name="margin-bottom">12</property>
<property name="margin-top">12</property> <property name="margin-start">12</property>
</object> <property name="margin-end">12</property>
<child>
<object class="GtkSearchEntry" id="entry">
<property name="width-request">300</property>
<property name="halign">center</property>
<property name="margin-bottom">12</property>
<property name="margin-top">12</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">500</property>
<property name="vexpand">true</property>
<property name="margin-top">12</property>
<child>
<object class="GtkGridView" id="app_grid_view">
<property name="min-columns">7</property>
<property name="max-columns">7</property>
<property name="single-click-activate">false</property>
<property name="enable-rubberband">false</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="orientation">horizontal</property>
<property name="hexpand">true</property>
<property name="margin-bottom">12</property>
<property name="margin-top">12</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="group_scroll_window">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">never</property>
<property name="propagate-natural-height">true</property>
<property name="min-content-height">150</property>
<property name="max-content-height">300</property>
<child>
<object class="GtkGridView" id="group_grid_view">
<property name="min-columns">8</property>
<property name="max-columns">8</property>
<property name="single-click-activate">false</property>
<property name="enable-rubberband">false</property>
</object>
</child>
</object>
</child>
</object>
</child> </child>
<child> </template>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">500</property>
<property name="vexpand">true</property>
<property name="margin-top">12</property>
<child>
<object class="GtkGridView" id="app_grid_view">
<property name="min-columns">7</property>
<property name="max-columns">7</property>
<property name="single-click-activate">false</property>
<property name="enable-rubberband">false</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="orientation">horizontal</property>
<property name="hexpand">true</property>
<property name="margin-bottom">12</property>
<property name="margin-top">12</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="group_scroll_window">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">never</property>
<property name="propagate-natural-height">true</property>
<property name="min-content-height">150</property>
<property name="max-content-height">300</property>
<child>
<object class="GtkGridView" id="group_grid_view">
<property name="min-columns">8</property>
<property name="max-columns">8</property>
<property name="single-click-activate">false</property>
<property name="enable-rubberband">false</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface> </interface>

View file

@ -1,20 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="DockItem" parent="GtkBox"> <template class="DockItem" parent="GtkBox">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkImage" id="image"> <object class="GtkImage" id="image">
<property name="margin-start">4</property> <property name="margin-start">4</property>
<property name="margin-end">4</property> <property name="margin-end">4</property>
<property name="margin-top">4</property> <property name="margin-top">4</property>
<property name="pixel-size">48</property> <property name="pixel-size">48</property>
</object> <property name="icon-size">large</property>
</child> </object>
<child> </child>
<object class="GtkLabel" id="dots"> <child>
<property name="hexpand">true</property> <object class="GtkLabel" id="dots">
<property name="halign">center</property> <property name="hexpand">true</property>
</object> <property name="halign">center</property>
</child> </object>
</template> </child>
</template>
</interface> </interface>

View file

@ -1,9 +1,8 @@
use gtk4 as gtk;
use gtk::CompositeTemplate;
use gtk::glib; use gtk::glib;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk4 as gtk;
use gtk::CompositeTemplate;
#[derive(Debug, Default, CompositeTemplate)] #[derive(Debug, Default, CompositeTemplate)]
#[template(file = "dock_item.ui")] #[template(file = "dock_item.ui")]
@ -30,5 +29,7 @@ impl ObjectSubclass for DockItem {
} }
impl ObjectImpl for DockItem {} impl ObjectImpl for DockItem {}
impl WidgetImpl for DockItem {} impl WidgetImpl for DockItem {}
impl BoxImpl for DockItem {} impl BoxImpl for DockItem {}

View file

@ -1,14 +1,14 @@
use crate::utils::BoxedWindowList;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use gio::Icon; use gio::Icon;
use gtk4 as gtk; use gtk4 as gtk;
mod imp;
use gtk::glib; use gtk::glib;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use crate::dock_object::DockObject; use crate::dock_object::DockObject;
use crate::utils::BoxedWindowList;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct DockItem(ObjectSubclass<imp::DockItem>) pub struct DockItem(ObjectSubclass<imp::DockItem>)

View file

@ -1,12 +1,14 @@
use crate::utils::BoxedWindowList; use std::cell::Cell;
use std::cell::RefCell;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use glib::{ParamFlags, ParamSpec, Value}; use glib::{ParamFlags, ParamSpec, Value};
use gtk4::glib; use gtk4::glib;
use gtk4::prelude::*; use gtk4::prelude::*;
use gtk4::subclass::prelude::*; use gtk4::subclass::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::cell::Cell;
use std::cell::RefCell; use crate::utils::BoxedWindowList;
// Object holding the state // Object holding the state
#[derive(Default)] #[derive(Default)]

View file

@ -1,11 +1,13 @@
mod imp; use std::path::Path;
use crate::utils::BoxedWindowList;
use gdk4::glib::Object; use gdk4::glib::Object;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use gtk4::glib; use gtk4::glib;
use gtk4::prelude::AppInfoExt; use gtk4::prelude::AppInfoExt;
use std::path::Path;
use crate::utils::BoxedWindowList;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct DockObject(ObjectSubclass<imp::DockObject>); pub struct DockObject(ObjectSubclass<imp::DockObject>);

View file

@ -1,31 +1,34 @@
mod dock_item; use std::collections::BTreeMap;
mod dock_object; use std::time::Duration;
mod utils;
mod window;
use self::dock_object::DockObject;
use self::window::Window;
use crate::utils::BoxedWindowList;
use futures::executor::block_on; use futures::executor::block_on;
use gdk4::Display; use gdk4::Display;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use gtk::Application;
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::CssProvider; use gtk4::CssProvider;
use gtk4::StyleContext; use gtk4::StyleContext;
use gtk::Application;
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use postage::mpsc::Sender; use postage::mpsc::Sender;
use postage::prelude::*; use postage::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::time::Duration;
use x11rb::rust_connection::RustConnection; use x11rb::rust_connection::RustConnection;
use zbus::Connection; use zbus::Connection;
use zvariant_derive::Type; use zvariant_derive::Type;
use crate::utils::BoxedWindowList;
use self::dock_object::DockObject;
use self::window::Window;
mod dock_item;
mod dock_object;
mod utils;
mod window;
const DEST: &str = "com.System76.PopShell"; const DEST: &str = "com.System76.PopShell";
const PATH: &str = "/com/System76/PopShell"; const PATH: &str = "/com/System76/PopShell";
const NUM_LAUNCHER_ITEMS: u8 = 10; const NUM_LAUNCHER_ITEMS: u8 = 10;
@ -129,7 +132,7 @@ fn main() {
match event { match event {
Event::Activate(e) => { Event::Activate(e) => {
let _activate_window = zbus_conn let _activate_window = zbus_conn
.call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e,))) .call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e, )))
.await .await
.expect("Failed to focus selected window"); .expect("Failed to focus selected window");
} }
@ -223,16 +226,16 @@ fn main() {
// skip if equal // skip if equal
if cached_results.len() == results.len() if cached_results.len() == results.len()
&& results.iter().zip(cached_results.iter()).fold( && results.iter().zip(cached_results.iter()).fold(
0, 0,
|acc, z: (&Item, &Item)| { |acc, z: (&Item, &Item)| {
let (a, b) = z; let (a, b) = z;
if a.name == b.name { if a.name == b.name {
acc + 1 acc + 1
} else { } else {
acc acc
} }
}, },
) == cached_results.len() ) == cached_results.len()
{ {
continue; // skip this update continue; // skip this update
} }

View file

@ -3,17 +3,21 @@ row:hover {
background: #888888; background: #888888;
border-radius: 12px; border-radius: 12px;
} }
row { row {
background: #333333; background: #333333;
border-radius: 12px; border-radius: 12px;
} }
listview { listview {
border-radius: 12px; border-radius: 12px;
background: #333333; background: #333333;
} }
window { window {
background: rgba(50,50,50,0.0); background: rgba(50, 50, 50, 0.0);
} }
box#dock-container { box#dock-container {
border-radius: 12px; border-radius: 12px;
background: #333333; background: #333333;

View file

@ -1,11 +1,14 @@
use std::path::PathBuf;
use gtk4::glib;
use crate::DockObject; use crate::DockObject;
use crate::Item; use crate::Item;
use gtk4::glib;
use std::path::PathBuf;
#[derive(Clone, Debug, Default, glib::GBoxed)] #[derive(Clone, Debug, Default, glib::GBoxed)]
#[gboxed(type_name = "BoxedWindowList")] #[gboxed(type_name = "BoxedWindowList")]
pub struct BoxedWindowList(pub Vec<Item>); pub struct BoxedWindowList(pub Vec<Item>);
#[derive(Clone, Debug, Default, glib::GBoxed)] #[derive(Clone, Debug, Default, glib::GBoxed)]
#[gboxed(type_name = "BoxedDockObject")] #[gboxed(type_name = "BoxedDockObject")]
pub struct BoxedDockObject(pub Option<DockObject>); pub struct BoxedDockObject(pub Option<DockObject>);

View file

@ -1,18 +1,18 @@
use std::cell::RefCell;
use std::rc::Rc;
use glib::SignalHandlerId; use glib::SignalHandlerId;
use glib::subclass::InitializingObject;
use gtk::{gio, glib};
use gtk::{CompositeTemplate, ListView};
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::Box; use gtk4::Box;
use gtk4::DragSource; use gtk4::DragSource;
use gtk4::DropTarget; use gtk4::DropTarget;
use gtk4::EventControllerMotion; use gtk4::EventControllerMotion;
use gtk4::Revealer; use gtk4::Revealer;
use std::cell::RefCell;
use std::rc::Rc;
use glib::subclass::InitializingObject;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk::{gio, glib};
use gtk::{CompositeTemplate, ListView};
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
// Object holding the state // Object holding the state
@ -56,6 +56,7 @@ impl ObjectSubclass for Window {
obj.init_template(); obj.init_template();
} }
} }
// Trait shared by all GObjects // Trait shared by all GObjects
impl ObjectImpl for Window { impl ObjectImpl for Window {
fn constructed(&self, obj: &Self::Type) { fn constructed(&self, obj: &Self::Type) {
@ -72,6 +73,7 @@ impl ObjectImpl for Window {
obj.setup_factory(); obj.setup_factory();
} }
} }
// Trait shared by all widgets // Trait shared by all widgets
impl WidgetImpl for Window {} impl WidgetImpl for Window {}

View file

@ -1,12 +1,6 @@
mod imp; use std::fs::File;
// use crate::ApplicationObject; use std::path::Path;
use crate::dock_item::DockItem;
use crate::dock_object::DockObject;
use crate::utils::data_path;
use crate::BoxedWindowList;
use crate::Event;
use crate::TX;
use crate::X11_CONN;
use gdk4::ContentProvider; use gdk4::ContentProvider;
use gdk4::Display; use gdk4::Display;
use gdk4::Rectangle; use gdk4::Rectangle;
@ -14,28 +8,36 @@ use gdk4_x11::X11Display;
use gdk4_x11::X11Surface; use gdk4_x11::X11Surface;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use gio::Icon; use gio::Icon;
// use crate::application_row::ApplicationRow;
use glib::Object;
use glib::Type; use glib::Type;
use gtk::{gio, glib};
use gtk::{Application, SignalListItemFactory};
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::prelude::ListModelExt;
use gtk4::DragSource; use gtk4::DragSource;
use gtk4::DropTarget; use gtk4::DropTarget;
use gtk4::EventControllerMotion; use gtk4::EventControllerMotion;
use gtk4::IconTheme; use gtk4::IconTheme;
use postage::prelude::Sink; use gtk4::prelude::ListModelExt;
use std::fs::File;
use std::path::Path;
use x11rb::connection::Connection;
use x11rb::protocol::xproto::ConnectionExt as OtherConnectionExt;
use x11rb::protocol::xproto::*;
use x11rb::wrapper::ConnectionExt;
// use crate::application_row::ApplicationRow;
use glib::Object;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk::{gio, glib}; use postage::prelude::Sink;
use gtk::{Application, SignalListItemFactory}; use x11rb::connection::Connection;
use libcosmic::x;
use x11rb::protocol::xproto; use x11rb::protocol::xproto;
use x11rb::protocol::xproto::ConnectionExt;
use libcosmic::x;
use crate::BoxedWindowList;
// use crate::ApplicationObject;
use crate::dock_item::DockItem;
use crate::dock_object::DockObject;
use crate::Event;
use crate::TX;
use crate::utils::data_path;
use crate::X11_CONN;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct Window(ObjectSubclass<imp::Window>) pub struct Window(ObjectSubclass<imp::Window>)
@ -178,16 +180,15 @@ impl Window {
// ignore all x11 errors... // ignore all x11 errors...
let xdisplay = display.clone().downcast::<X11Display>().expect("Failed to downgrade X11 Display."); let xdisplay = display.clone().downcast::<X11Display>().expect("Failed to downgrade X11 Display.");
xdisplay.error_trap_push(); xdisplay.error_trap_push();
let conn = X11_CONN.get().expect("Failed to get X11 connection"); unsafe {
let window_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE").unwrap().reply().unwrap().atom; x::change_property(
let dock_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE_DOCK").unwrap().reply().unwrap().atom; &display,
conn.change_property32( &surface,
PropMode::REPLACE, "_NET_WM_WINDOW_TYPE",
surface.xid().try_into().unwrap(), x::PropMode::Replace,
window_type_atom, &[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DOCK").unwrap()],
AtomEnum::ATOM, );
&[dock_type_atom] }
).unwrap();
let resize = glib::clone!(@weak window, @weak revealer => move || { let resize = glib::clone!(@weak window, @weak revealer => move || {
let s = window.surface().expect("Failed to get Surface for Window"); let s = window.surface().expect("Failed to get Surface for Window");
let height = if revealer.reveals_child() { window.height() } else { 4 }; let height = if revealer.reveals_child() { window.height() } else { 4 };
@ -203,6 +204,8 @@ impl Window {
width: monitor_width, width: monitor_width,
height: monitor_height, height: monitor_height,
} = monitor.geometry(); } = monitor.geometry();
// dbg!(monitor_x);
// dbg!(monitor_y);
// dbg!(monitor_width); // dbg!(monitor_width);
// dbg!(monitor_height); // dbg!(monitor_height);
// dbg!(width); // dbg!(width);

View file

@ -1,69 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="LauncherWindow" parent="GtkApplicationWindow"> <template class="LauncherWindow" parent="GtkApplicationWindow">
<!-- drop controller seems to be buggy if window changes size --> <!-- drop controller seems to be buggy if window changes size -->
<property name="height-request">80</property> <property name="height-request">80</property>
<property name="width-request">128</property> <property name="width-request">128</property>
<property name="title">Gtk Pop Dock</property> <property name="title">Gtk Pop Dock</property>
<property name="decorated">false</property> <property name="decorated">false</property>
<property name="resizable">false</property> <property name="resizable">false</property>
<child>
<object class="GtkBox" id="cursor_handle">
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox" id="cursor_handle">
<property name="height-request">0</property>
<property name="vexpand">true</property>
</object>
</child>
<child>
<object class="GtkRevealer" id="revealer">
<property name="reveal-child">true</property>
<property name="transition-duration">300</property>
<property name="transition-type">slide-up</property>
<child>
<object class="GtkBox">
<property name="height-request">0</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">horizontal</property> <property name="height-request">0</property>
<property name="height-request">64</property> <property name="vexpand">true</property>
<property name="margin-start">4</property> </object>
<property name="margin-end">4</property>
<property name="spacing">4</property>
<property name="name">dock-container</property>
<child>
<object class="GtkListView" id="saved_app_list_view">
<property name="orientation">horizontal</property>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="orientation">vertical</property>
</object>
</child>
<child>
<object class="GtkListView" id="active_app_list_view">
<property name="orientation">horizontal</property>
</object>
</child>
</object>
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkRevealer" id="revealer">
<property name="height-request">4</property> <property name="reveal-child">true</property>
</object> <property name="transition-duration">300</property>
<property name="transition-type">slide-up</property>
<child>
<object class="GtkBox">
<property name="height-request">0</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="height-request">64</property>
<property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="spacing">4</property>
<property name="name">dock-container</property>
<child>
<object class="GtkListView" id="saved_app_list_view">
<property name="orientation">horizontal</property>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="orientation">vertical</property>
</object>
</child>
<child>
<object class="GtkListView" id="active_app_list_view">
<property name="orientation">horizontal</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="height-request">4</property>
</object>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
</child>
</object>
</child> </child>
</object> </template>
</child>
</template>
</interface> </interface>

View file

@ -1,26 +1,28 @@
mod search_result_object;
mod search_result_row;
mod utils;
mod window;
use self::search_result_object::SearchResultObject;
use self::window::Window;
use crate::utils::BoxedSearchResult;
use gdk4::Display; use gdk4::Display;
use gio::DesktopAppInfo; use gio::DesktopAppInfo;
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use gtk::Application;
use gtk4 as gtk; use gtk4 as gtk;
use gtk4::CssProvider; use gtk4::CssProvider;
use gtk4::StyleContext; use gtk4::StyleContext;
use gtk::Application;
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use pop_launcher_service::IpcClient; use pop_launcher_service::IpcClient;
use postage::mpsc::Sender; use postage::mpsc::Sender;
use postage::prelude::*; use postage::prelude::*;
use x11rb::rust_connection::RustConnection; use x11rb::rust_connection::RustConnection;
use crate::utils::BoxedSearchResult;
use self::search_result_object::SearchResultObject;
use self::window::Window;
mod search_result_object;
mod search_result_row;
mod utils;
mod window;
const NUM_LAUNCHER_ITEMS: u8 = 10; const NUM_LAUNCHER_ITEMS: u8 = 10;
static TX: OnceCell<Sender<Event>> = OnceCell::new(); static TX: OnceCell<Sender<Event>> = OnceCell::new();
static X11_CONN: OnceCell<RustConnection> = OnceCell::new(); static X11_CONN: OnceCell<RustConnection> = OnceCell::new();

View file

@ -1,12 +1,13 @@
use crate::utils::BoxedSearchResult; use std::cell::RefCell;
use std::rc::Rc;
use glib::{ParamFlags, ParamSpec, Value}; use glib::{ParamFlags, ParamSpec, Value};
use gtk4::glib; use gtk4::glib;
use gtk4::prelude::*; use gtk4::prelude::*;
use gtk4::subclass::prelude::*; use gtk4::subclass::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::cell::RefCell; use crate::utils::BoxedSearchResult;
use std::rc::Rc;
// Object holding the state // Object holding the state
#[derive(Default)] #[derive(Default)]

View file

@ -1,7 +1,9 @@
mod imp;
use crate::utils::BoxedSearchResult;
use gdk4::glib::Object; use gdk4::glib::Object;
use crate::utils::BoxedSearchResult;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct SearchResultObject(ObjectSubclass<imp::SearchResultObject>); pub struct SearchResultObject(ObjectSubclass<imp::SearchResultObject>);
} }

View file

@ -1,61 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="SearchResultRow" parent="GtkBox"> <template class="SearchResultRow" parent="GtkBox">
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="margin-start">4</property> <property name="margin-start">4</property>
<property name="margin-end">4</property>
<property name="hexpand">true</property>
<child>
<object class="GtkImage" id="categoryimage">
<property name="pixel-size">20</property>
</object>
</child>
<child>
<object class="GtkImage" id="image">
<property name="margin-top">4</property>
<property name="margin-bottom">4</property>
<property name="pixel-size">36</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="halign">fill</property>
<property name="hexpand">true</property>
<property name="margin-top">4</property>
<property name="margin-end">4</property> <property name="margin-end">4</property>
<property name="margin-bottom">4</property> <property name="hexpand">true</property>
<child> <child>
<object class="GtkLabel" id="name"> <object class="GtkImage" id="categoryimage">
<property name="halign">start</property> <property name="pixel-size">20</property>
<property name="ellipsize">end</property> </object>
<property name="max-width-chars">40</property>
<style>
<class name="title-4" />
</style>
</object>
</child> </child>
<child> <child>
<object class="GtkLabel" id="description"> <object class="GtkImage" id="image">
<property name="halign">start</property> <property name="margin-top">4</property>
<property name="ellipsize">end</property> <property name="margin-bottom">4</property>
<property name="max-width-chars">50</property> <property name="pixel-size">36</property>
<style> </object>
<class name="body" />
</style>
</object>
</child> </child>
</object> <child>
</child> <object class="GtkBox">
<child type="end"> <property name="orientation">vertical</property>
<object class="GtkLabel" id="shortcut"> <property name="halign">fill</property>
<property name="halign">end</property> <property name="hexpand">true</property>
<property name="wrap">false</property> <property name="margin-top">4</property>
<style> <property name="margin-end">4</property>
<class name="body" /> <property name="margin-bottom">4</property>
</style> <child>
</object> <object class="GtkLabel" id="name">
</child> <property name="halign">start</property>
</template> <property name="ellipsize">end</property>
<property name="max-width-chars">40</property>
<style>
<class name="title-4"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="description">
<property name="halign">start</property>
<property name="ellipsize">end</property>
<property name="max-width-chars">50</property>
<style>
<class name="body"/>
</style>
</object>
</child>
</object>
</child>
<child type="end">
<object class="GtkLabel" id="shortcut">
<property name="halign">end</property>
<property name="wrap">false</property>
<style>
<class name="body"/>
</style>
</object>
</child>
</template>
</interface> </interface>

View file

@ -1,9 +1,8 @@
use gtk4 as gtk;
use gtk::CompositeTemplate;
use gtk::glib; use gtk::glib;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use gtk4 as gtk;
use gtk::CompositeTemplate;
#[derive(Debug, Default, CompositeTemplate)] #[derive(Debug, Default, CompositeTemplate)]
#[template(file = "application_row.ui")] #[template(file = "application_row.ui")]
@ -36,5 +35,7 @@ impl ObjectSubclass for SearchResultRow {
} }
impl ObjectImpl for SearchResultRow {} impl ObjectImpl for SearchResultRow {}
impl WidgetImpl for SearchResultRow {} impl WidgetImpl for SearchResultRow {}
impl BoxImpl for SearchResultRow {} impl BoxImpl for SearchResultRow {}

View file

@ -1,13 +1,14 @@
use crate::icon_source;
use crate::BoxedSearchResult;
use gtk4 as gtk; use gtk4 as gtk;
mod imp;
use crate::SearchResultObject;
use gtk::glib; use gtk::glib;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::subclass::prelude::*; use gtk::subclass::prelude::*;
use crate::BoxedSearchResult;
use crate::icon_source;
use crate::SearchResultObject;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct SearchResultRow(ObjectSubclass<imp::SearchResultRow>) pub struct SearchResultRow(ObjectSubclass<imp::SearchResultRow>)
@extends gtk::Widget, gtk::Box; @extends gtk::Widget, gtk::Box;

View file

@ -2,12 +2,15 @@ row:hover {
transition: 100ms; transition: 100ms;
background: #888888; background: #888888;
} }
row { row {
background: #333333; background: #333333;
} }
listview { listview {
background: #333333; background: #333333;
} }
window { window {
background: #333333; background: #333333;
border-radius: 15px; border-radius: 15px;

View file

@ -1,10 +1,9 @@
use gtk4 as gtk;
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib}; use gtk::{gio, glib};
use gtk::{CompositeTemplate, Entry, ListView}; use gtk::{CompositeTemplate, Entry, ListView};
use gtk4 as gtk;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
// Object holding the state // Object holding the state
@ -34,6 +33,7 @@ impl ObjectSubclass for Window {
obj.init_template(); obj.init_template();
} }
} }
// Trait shared by all GObjects // Trait shared by all GObjects
impl ObjectImpl for Window { impl ObjectImpl for Window {
fn constructed(&self, obj: &Self::Type) { fn constructed(&self, obj: &Self::Type) {
@ -46,6 +46,7 @@ impl ObjectImpl for Window {
obj.setup_factory(); obj.setup_factory();
} }
} }
// Trait shared by all widgets // Trait shared by all widgets
impl WidgetImpl for Window {} impl WidgetImpl for Window {}

View file

@ -1,24 +1,25 @@
mod imp;
use crate::search_result_row::SearchResultRow;
use crate::SearchResultObject;
use crate::TX;
use crate::X11_CONN;
use gdk4::Rectangle; use gdk4::Rectangle;
use gdk4_x11::X11Display; use gdk4_x11::X11Display;
use gdk4_x11::X11Surface; use gdk4_x11::X11Surface;
use glib::Object; use glib::Object;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib}; use gtk::{gio, glib};
use gtk::{Application, SignalListItemFactory}; use gtk::{Application, SignalListItemFactory};
use gtk4 as gtk; use gtk4 as gtk;
use libcosmic::x; use gtk::prelude::*;
use gtk::subclass::prelude::*;
use postage::prelude::Sink; use postage::prelude::Sink;
use x11rb::connection::Connection; use x11rb::connection::Connection;
use x11rb::protocol::xproto; use x11rb::protocol::xproto;
use x11rb::protocol::xproto::ConnectionExt as OtherConnectionExt; use x11rb::protocol::xproto::ConnectionExt;
use x11rb::protocol::xproto::*;
use x11rb::wrapper::ConnectionExt; use libcosmic::x;
use crate::search_result_row::SearchResultRow;
use crate::SearchResultObject;
use crate::TX;
use crate::X11_CONN;
mod imp;
glib::wrapper! { glib::wrapper! {
pub struct Window(ObjectSubclass<imp::Window>) pub struct Window(ObjectSubclass<imp::Window>)
@ -143,16 +144,15 @@ impl Window {
// ignore all x11 errors... // ignore all x11 errors...
let xdisplay = display.clone().downcast::<X11Display>().expect("Failed to downgrade X11 Display."); let xdisplay = display.clone().downcast::<X11Display>().expect("Failed to downgrade X11 Display.");
xdisplay.error_trap_push(); xdisplay.error_trap_push();
let conn = X11_CONN.get().expect("Failed to get X11 connection"); unsafe {
let window_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE").unwrap().reply().unwrap().atom; x::change_property(
let dock_type_atom = conn.intern_atom(false, b"_NET_WM_WINDOW_TYPE_DIALOG").unwrap().reply().unwrap().atom; &display,
conn.change_property32( &surface,
PropMode::REPLACE, "_NET_WM_WINDOW_TYPE",
surface.xid().try_into().unwrap(), x::PropMode::Replace,
window_type_atom, &[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DIALOG").unwrap()],
AtomEnum::ATOM, );
&[dock_type_atom] }
).unwrap();
let resize = glib::clone!(@weak window => move || { let resize = glib::clone!(@weak window => move || {
let s = window.surface().expect("Failed to get Surface for Window"); let s = window.surface().expect("Failed to get Surface for Window");
let height = window.height(); let height = window.height();

View file

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="LauncherWindow" parent="GtkApplicationWindow"> <template class="LauncherWindow" parent="GtkApplicationWindow">
<property name="width-request">600</property> <property name="width-request">600</property>
<property name="title">Gtk Pop Launcher</property> <property name="title">Gtk Pop Launcher</property>
<property name="decorated">false</property> <property name="decorated">false</property>
<property name="resizable">false</property> <property name="resizable">false</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child> <child>
<object class="GtkEntry" id="entry"> <object class="GtkBox">
<property name="margin-bottom">12</property> <property name="orientation">vertical</property>
</object> <property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkEntry" id="entry">
<property name="margin-bottom">12</property>
</object>
</child>
<child>
<object class="GtkListView" id="list_view"/>
</child>
</object>
</child> </child>
<child> </template>
<object class="GtkListView" id="list_view"/>
</child>
</object>
</child>
</template>
</interface> </interface>