remove template for dock_item
This commit is contained in:
parent
e48f501b0d
commit
71273ec430
16 changed files with 82 additions and 87 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
use gtk4::CompositeTemplate;
|
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
use gtk4::CompositeTemplate;
|
||||||
|
|
||||||
#[derive(Debug, Default, CompositeTemplate)]
|
#[derive(Debug, Default, CompositeTemplate)]
|
||||||
#[template(file = "grid_item.ui")]
|
#[template(file = "grid_item.ui")]
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ use gdk4::ContentProvider;
|
||||||
use gdk4::Display;
|
use gdk4::Display;
|
||||||
use gio::File;
|
use gio::File;
|
||||||
use gio::Icon;
|
use gio::Icon;
|
||||||
use gtk4::{gio, glib};
|
|
||||||
use gtk4::DragSource;
|
|
||||||
use gtk4::IconTheme;
|
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::traits::WidgetExt;
|
use gtk4::traits::WidgetExt;
|
||||||
|
use gtk4::DragSource;
|
||||||
|
use gtk4::IconTheme;
|
||||||
|
use gtk4::{gio, glib};
|
||||||
|
|
||||||
use crate::app_group::AppGroup;
|
use crate::app_group::AppGroup;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use gtk4::CssProvider;
|
|
||||||
use gtk4::gdk::Display;
|
use gtk4::gdk::Display;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
|
use gtk4::CssProvider;
|
||||||
use gtk4::StyleContext;
|
use gtk4::StyleContext;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use x11rb::rust_connection::RustConnection;
|
use x11rb::rust_connection::RustConnection;
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ use gdk4_x11::X11Surface;
|
||||||
use glib::FromVariant;
|
use glib::FromVariant;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use glib::Variant;
|
use glib::Variant;
|
||||||
use gtk4::{gio, glib};
|
use gtk4::prelude::*;
|
||||||
use gtk4::{Application, SignalListItemFactory};
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::Dialog;
|
use gtk4::Dialog;
|
||||||
use gtk4::Entry;
|
use gtk4::Entry;
|
||||||
use gtk4::Label;
|
use gtk4::Label;
|
||||||
use gtk4::prelude::*;
|
use gtk4::{gio, glib};
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::{Application, SignalListItemFactory};
|
||||||
use x11rb::connection::Connection;
|
use x11rb::connection::Connection;
|
||||||
use x11rb::protocol::xproto;
|
use x11rb::protocol::xproto;
|
||||||
use x11rb::protocol::xproto::ConnectionExt;
|
use x11rb::protocol::xproto::ConnectionExt;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<interface>
|
|
||||||
<template class="DockItem" parent="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="image">
|
|
||||||
<property name="margin-start">4</property>
|
|
||||||
<property name="margin-end">4</property>
|
|
||||||
<property name="margin-top">4</property>
|
|
||||||
<property name="pixel-size">48</property>
|
|
||||||
<property name="icon-size">large</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="dots">
|
|
||||||
<property name="hexpand">true</property>
|
|
||||||
<property name="halign">center</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</template>
|
|
||||||
</interface>
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::CompositeTemplate;
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[derive(Debug, Default, CompositeTemplate)]
|
#[derive(Debug, Default)]
|
||||||
#[template(file = "dock_item.ui")]
|
|
||||||
pub struct DockItem {
|
pub struct DockItem {
|
||||||
#[template_child]
|
pub image: Rc<RefCell<gtk4::Image>>,
|
||||||
pub image: TemplateChild<gtk4::Image>,
|
pub dots: Rc<RefCell<gtk4::Label>>,
|
||||||
#[template_child]
|
|
||||||
pub dots: TemplateChild<gtk4::Label>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
|
@ -17,14 +14,6 @@ impl ObjectSubclass for DockItem {
|
||||||
const NAME: &'static str = "DockItem";
|
const NAME: &'static str = "DockItem";
|
||||||
type Type = super::DockItem;
|
type Type = super::DockItem;
|
||||||
type ParentType = gtk4::Box;
|
type ParentType = gtk4::Box;
|
||||||
|
|
||||||
fn class_init(klass: &mut Self::Class) {
|
|
||||||
Self::bind_template(klass);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
|
||||||
obj.init_template();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for DockItem {}
|
impl ObjectImpl for DockItem {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
|
use cascade::cascade;
|
||||||
use gio::DesktopAppInfo;
|
use gio::DesktopAppInfo;
|
||||||
use gio::Icon;
|
use gio::Icon;
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
use gtk4::Align;
|
||||||
|
use gtk4::Image;
|
||||||
|
use gtk4::Label;
|
||||||
|
|
||||||
use crate::dock_object::DockObject;
|
use crate::dock_object::DockObject;
|
||||||
use crate::utils::BoxedWindowList;
|
use crate::utils::BoxedWindowList;
|
||||||
|
|
@ -11,7 +15,9 @@ mod imp;
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct DockItem(ObjectSubclass<imp::DockItem>)
|
pub struct DockItem(ObjectSubclass<imp::DockItem>)
|
||||||
@extends gtk4::Widget, gtk4::Box;
|
@extends gtk4::Widget, gtk4::Box,
|
||||||
|
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget, gtk4::Orientable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DockItem {
|
impl Default for DockItem {
|
||||||
|
|
@ -23,6 +29,25 @@ impl Default for DockItem {
|
||||||
impl DockItem {
|
impl DockItem {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let self_: DockItem = glib::Object::new(&[]).expect("Failed to create DockItem");
|
let self_: DockItem = glib::Object::new(&[]).expect("Failed to create DockItem");
|
||||||
|
self_.set_orientation(gtk4::Orientation::Vertical);
|
||||||
|
let image = cascade! {
|
||||||
|
Image::new();
|
||||||
|
..set_margin_start(4);
|
||||||
|
..set_margin_end(4);
|
||||||
|
..set_margin_top(4);
|
||||||
|
..set_pixel_size(48);
|
||||||
|
};
|
||||||
|
let dots = cascade! {
|
||||||
|
Label::new(Some(""));
|
||||||
|
..set_hexpand(true);
|
||||||
|
..set_halign(Align::Center);
|
||||||
|
};
|
||||||
|
self_.append(&image);
|
||||||
|
self_.append(&dots);
|
||||||
|
let imp = imp::DockItem::from_instance(&self_);
|
||||||
|
imp.image.replace(image);
|
||||||
|
imp.dots.replace(dots);
|
||||||
|
self_.show();
|
||||||
self_
|
self_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,24 +56,26 @@ impl DockItem {
|
||||||
let self_ = imp::DockItem::from_instance(self);
|
let self_ = imp::DockItem::from_instance(self);
|
||||||
if let Ok(app_info_value) = dock_object.property("appinfo") {
|
if let Ok(app_info_value) = dock_object.property("appinfo") {
|
||||||
if let Ok(Some(app_info)) = app_info_value.get::<Option<DesktopAppInfo>>() {
|
if let Ok(Some(app_info)) = app_info_value.get::<Option<DesktopAppInfo>>() {
|
||||||
self_.image.set_tooltip_text(Some(&app_info.name()));
|
self_
|
||||||
|
.image
|
||||||
|
.borrow()
|
||||||
|
.set_tooltip_text(Some(&app_info.name()));
|
||||||
|
|
||||||
let icon = app_info.icon().unwrap_or(
|
let icon = app_info.icon().unwrap_or(
|
||||||
Icon::for_string("image-missing").expect("Failed to set default icon"),
|
Icon::for_string("image-missing").expect("Failed to set default icon"),
|
||||||
);
|
);
|
||||||
|
|
||||||
self_.image.set_from_gicon(&icon);
|
self_.image.borrow().set_from_gicon(&icon);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("initializing dock item failed...");
|
println!("initializing dock item failed...");
|
||||||
}
|
}
|
||||||
if let Ok(active_value) = dock_object.property("active") {
|
if let Ok(active_value) = dock_object.property("active") {
|
||||||
if let Ok(active) = active_value.get::<BoxedWindowList>() {
|
if let Ok(active) = active_value.get::<BoxedWindowList>() {
|
||||||
self_.dots.set_text("");
|
let dots = self_.dots.borrow();
|
||||||
|
dots.set_text("");
|
||||||
for _ in active.0 {
|
for _ in active.0 {
|
||||||
self_
|
dots.set_text(format!("{}{}", dots.text(), " · ").as_str());
|
||||||
.dots
|
|
||||||
.set_text(format!("{}{}", self_.dots.text(), " · ").as_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ use std::time::Duration;
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
use gdk4::Display;
|
use gdk4::Display;
|
||||||
use gio::DesktopAppInfo;
|
use gio::DesktopAppInfo;
|
||||||
use gtk4::Application;
|
|
||||||
use gtk4::CssProvider;
|
|
||||||
use gtk4::gio;
|
use gtk4::gio;
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
|
use gtk4::Application;
|
||||||
|
use gtk4::CssProvider;
|
||||||
use gtk4::StyleContext;
|
use gtk4::StyleContext;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use postage::mpsc::Sender;
|
use postage::mpsc::Sender;
|
||||||
|
|
@ -131,7 +131,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");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,15 @@ use gio::Icon;
|
||||||
// use crate::application_row::ApplicationRow;
|
// use crate::application_row::ApplicationRow;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use glib::Type;
|
use glib::Type;
|
||||||
use gtk4::{gio, glib};
|
use gtk4::prelude::ListModelExt;
|
||||||
use gtk4::{Application, SignalListItemFactory};
|
use gtk4::prelude::*;
|
||||||
use gtk4::{DragSource, GestureClick};
|
use gtk4::subclass::prelude::*;
|
||||||
use gtk4::DropTarget;
|
use gtk4::DropTarget;
|
||||||
use gtk4::EventControllerMotion;
|
use gtk4::EventControllerMotion;
|
||||||
use gtk4::IconTheme;
|
use gtk4::IconTheme;
|
||||||
use gtk4::prelude::*;
|
use gtk4::{gio, glib};
|
||||||
use gtk4::prelude::ListModelExt;
|
use gtk4::{Application, SignalListItemFactory};
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::{DragSource, GestureClick};
|
||||||
use postage::prelude::Sink;
|
use postage::prelude::Sink;
|
||||||
use x11rb::connection::Connection;
|
use x11rb::connection::Connection;
|
||||||
use x11rb::protocol::xproto;
|
use x11rb::protocol::xproto;
|
||||||
|
|
@ -32,10 +32,10 @@ use crate::BoxedWindowList;
|
||||||
// use crate::ApplicationObject;
|
// use crate::ApplicationObject;
|
||||||
use crate::dock_item::DockItem;
|
use crate::dock_item::DockItem;
|
||||||
use crate::dock_object::DockObject;
|
use crate::dock_object::DockObject;
|
||||||
|
use crate::utils::data_path;
|
||||||
use crate::Event;
|
use crate::Event;
|
||||||
use crate::Item;
|
use crate::Item;
|
||||||
use crate::TX;
|
use crate::TX;
|
||||||
use crate::utils::data_path;
|
|
||||||
use crate::X11_CONN;
|
use crate::X11_CONN;
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use gdk4::Display;
|
use gdk4::Display;
|
||||||
use gio::DesktopAppInfo;
|
use gio::DesktopAppInfo;
|
||||||
use gtk4::Application;
|
|
||||||
use gtk4::CssProvider;
|
|
||||||
use gtk4::gio;
|
use gtk4::gio;
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
|
use gtk4::Application;
|
||||||
|
use gtk4::CssProvider;
|
||||||
use gtk4::StyleContext;
|
use gtk4::StyleContext;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use pop_launcher_service::IpcClient;
|
use pop_launcher_service::IpcClient;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use gtk4::CompositeTemplate;
|
|
||||||
use gtk4::glib;
|
use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
use gtk4::CompositeTemplate;
|
||||||
|
|
||||||
#[derive(Debug, Default, CompositeTemplate)]
|
#[derive(Debug, Default, CompositeTemplate)]
|
||||||
#[template(file = "application_row.ui")]
|
#[template(file = "application_row.ui")]
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ use gtk4::glib;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
|
||||||
use crate::BoxedSearchResult;
|
|
||||||
use crate::icon_source;
|
use crate::icon_source;
|
||||||
|
use crate::BoxedSearchResult;
|
||||||
use crate::SearchResultObject;
|
use crate::SearchResultObject;
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use gtk4::{gio, glib};
|
|
||||||
use gtk4::{CompositeTemplate, Entry, ListView};
|
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
use gtk4::{gio, glib};
|
||||||
|
use gtk4::{CompositeTemplate, Entry, ListView};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
|
|
||||||
// Object holding the state
|
// Object holding the state
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ 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 gtk4::{gio, glib};
|
|
||||||
use gtk4::{Application, SignalListItemFactory};
|
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
use gtk4::{gio, glib};
|
||||||
|
use gtk4::{Application, SignalListItemFactory};
|
||||||
use postage::prelude::Sink;
|
use postage::prelude::Sink;
|
||||||
use x11rb::connection::Connection;
|
use x11rb::connection::Connection;
|
||||||
use x11rb::protocol::xproto;
|
use x11rb::protocol::xproto;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue