remove template for dock_item
This commit is contained in:
parent
e48f501b0d
commit
71273ec430
16 changed files with 82 additions and 87 deletions
|
|
@ -142,7 +142,7 @@ impl ObjectImpl for AppGroup {
|
|||
.get::<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;
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl AppGroup {
|
|||
("icon", &data.icon),
|
||||
("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()) {
|
||||
println!("failed to set category icon property");
|
||||
dbg!(e);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use gtk4::CompositeTemplate;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(file = "grid_item.ui")]
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ use gdk4::ContentProvider;
|
|||
use gdk4::Display;
|
||||
use gio::File;
|
||||
use gio::Icon;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::DragSource;
|
||||
use gtk4::IconTheme;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::traits::WidgetExt;
|
||||
use gtk4::DragSource;
|
||||
use gtk4::IconTheme;
|
||||
use gtk4::{gio, glib};
|
||||
|
||||
use crate::app_group::AppGroup;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use gtk4::CssProvider;
|
||||
use gtk4::gdk::Display;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
use once_cell::sync::OnceCell;
|
||||
use x11rb::rust_connection::RustConnection;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use gdk4_x11::X11Surface;
|
|||
use glib::FromVariant;
|
||||
use glib::Object;
|
||||
use glib::Variant;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::Dialog;
|
||||
use gtk4::Entry;
|
||||
use gtk4::Label;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto;
|
||||
use x11rb::protocol::xproto::ConnectionExt;
|
||||
|
|
@ -171,10 +171,10 @@ impl Window {
|
|||
category: "".to_string(),
|
||||
}),
|
||||
]
|
||||
.iter()
|
||||
.for_each(|group| {
|
||||
group_model.append(group);
|
||||
});
|
||||
.iter()
|
||||
.for_each(|group| {
|
||||
group_model.append(group);
|
||||
});
|
||||
let group_selection = gtk4::SingleSelection::new(Some(&group_model));
|
||||
imp.group_grid_view.set_model(Some(&group_selection));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(file = "dock_item.ui")]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DockItem {
|
||||
#[template_child]
|
||||
pub image: TemplateChild<gtk4::Image>,
|
||||
#[template_child]
|
||||
pub dots: TemplateChild<gtk4::Label>,
|
||||
pub image: Rc<RefCell<gtk4::Image>>,
|
||||
pub dots: Rc<RefCell<gtk4::Label>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
@ -17,14 +14,6 @@ impl ObjectSubclass for DockItem {
|
|||
const NAME: &'static str = "DockItem";
|
||||
type Type = super::DockItem;
|
||||
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 {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
use cascade::cascade;
|
||||
use gio::DesktopAppInfo;
|
||||
use gio::Icon;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::Align;
|
||||
use gtk4::Image;
|
||||
use gtk4::Label;
|
||||
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
|
@ -11,7 +15,9 @@ mod imp;
|
|||
|
||||
glib::wrapper! {
|
||||
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 {
|
||||
|
|
@ -23,6 +29,25 @@ impl Default for DockItem {
|
|||
impl DockItem {
|
||||
pub fn new() -> Self {
|
||||
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_
|
||||
}
|
||||
|
||||
|
|
@ -31,24 +56,26 @@ impl DockItem {
|
|||
let self_ = imp::DockItem::from_instance(self);
|
||||
if let Ok(app_info_value) = dock_object.property("appinfo") {
|
||||
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(
|
||||
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 {
|
||||
println!("initializing dock item failed...");
|
||||
}
|
||||
if let Ok(active_value) = dock_object.property("active") {
|
||||
if let Ok(active) = active_value.get::<BoxedWindowList>() {
|
||||
self_.dots.set_text("");
|
||||
let dots = self_.dots.borrow();
|
||||
dots.set_text("");
|
||||
for _ in active.0 {
|
||||
self_
|
||||
.dots
|
||||
.set_text(format!("{}{}", self_.dots.text(), " · ").as_str());
|
||||
dots.set_text(format!("{}{}", dots.text(), " · ").as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use std::time::Duration;
|
|||
use futures::executor::block_on;
|
||||
use gdk4::Display;
|
||||
use gio::DesktopAppInfo;
|
||||
use gtk4::Application;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::gio;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::Application;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
use once_cell::sync::OnceCell;
|
||||
use postage::mpsc::Sender;
|
||||
|
|
@ -131,7 +131,7 @@ fn main() {
|
|||
match event {
|
||||
Event::Activate(e) => {
|
||||
let _activate_window = zbus_conn
|
||||
.call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e, )))
|
||||
.call_method(Some(DEST), PATH, Some(DEST), "WindowFocus", &((e,)))
|
||||
.await
|
||||
.expect("Failed to focus selected window");
|
||||
}
|
||||
|
|
@ -225,16 +225,16 @@ fn main() {
|
|||
// skip if equal
|
||||
if cached_results.len() == results.len()
|
||||
&& results.iter().zip(cached_results.iter()).fold(
|
||||
0,
|
||||
|acc, z: (&Item, &Item)| {
|
||||
let (a, b) = z;
|
||||
if a.name == b.name {
|
||||
acc + 1
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
},
|
||||
) == cached_results.len()
|
||||
0,
|
||||
|acc, z: (&Item, &Item)| {
|
||||
let (a, b) = z;
|
||||
if a.name == b.name {
|
||||
acc + 1
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
},
|
||||
) == cached_results.len()
|
||||
{
|
||||
continue; // skip this update
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ use gio::Icon;
|
|||
// use crate::application_row::ApplicationRow;
|
||||
use glib::Object;
|
||||
use glib::Type;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use gtk4::{DragSource, GestureClick};
|
||||
use gtk4::prelude::ListModelExt;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::DropTarget;
|
||||
use gtk4::EventControllerMotion;
|
||||
use gtk4::IconTheme;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::prelude::ListModelExt;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use gtk4::{DragSource, GestureClick};
|
||||
use postage::prelude::Sink;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto;
|
||||
|
|
@ -32,10 +32,10 @@ use crate::BoxedWindowList;
|
|||
// use crate::ApplicationObject;
|
||||
use crate::dock_item::DockItem;
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::data_path;
|
||||
use crate::Event;
|
||||
use crate::Item;
|
||||
use crate::TX;
|
||||
use crate::utils::data_path;
|
||||
use crate::X11_CONN;
|
||||
|
||||
mod imp;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use gdk4::Display;
|
||||
use gio::DesktopAppInfo;
|
||||
use gtk4::Application;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::gio;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::Application;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
use once_cell::sync::OnceCell;
|
||||
use pop_launcher_service::IpcClient;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use gtk4::CompositeTemplate;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::CompositeTemplate;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(file = "application_row.ui")]
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use gtk4::glib;
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
|
||||
use crate::BoxedSearchResult;
|
||||
use crate::icon_source;
|
||||
use crate::BoxedSearchResult;
|
||||
use crate::SearchResultObject;
|
||||
|
||||
mod imp;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use glib::subclass::InitializingObject;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{CompositeTemplate, Entry, ListView};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{CompositeTemplate, Entry, ListView};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
// Object holding the state
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ use gdk4::Rectangle;
|
|||
use gdk4_x11::X11Display;
|
||||
use gdk4_x11::X11Surface;
|
||||
use glib::Object;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use postage::prelude::Sink;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue