cleanup
This commit is contained in:
parent
e6ef9a5357
commit
e48f501b0d
18 changed files with 151 additions and 166 deletions
|
|
@ -1,11 +1,10 @@
|
|||
use gdk4::Display;
|
||||
use gio::DesktopAppInfo;
|
||||
use gtk::gio;
|
||||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Application;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::Application;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::gio;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::StyleContext;
|
||||
use once_cell::sync::OnceCell;
|
||||
use pop_launcher_service::IpcClient;
|
||||
|
|
@ -27,7 +26,7 @@ const NUM_LAUNCHER_ITEMS: u8 = 10;
|
|||
static TX: OnceCell<Sender<Event>> = OnceCell::new();
|
||||
static X11_CONN: OnceCell<RustConnection> = OnceCell::new();
|
||||
|
||||
fn icon_source(icon: >k::Image, source: &Option<pop_launcher::IconSource>) {
|
||||
fn icon_source(icon: >k4::Image, source: &Option<pop_launcher::IconSource>) {
|
||||
match source {
|
||||
Some(pop_launcher::IconSource::Name(name)) => {
|
||||
icon.set_from_icon_name(Some(name));
|
||||
|
|
@ -80,12 +79,12 @@ fn load_css() {
|
|||
StyleContext::add_provider_for_display(
|
||||
&Display::default().expect("Error initializing GTK CSS provider."),
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = gtk::Application::builder()
|
||||
let app = gtk4::Application::builder()
|
||||
.application_id("com.cosmic.Launcher")
|
||||
.build();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +1,28 @@
|
|||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::CompositeTemplate;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::CompositeTemplate;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(file = "application_row.ui")]
|
||||
pub struct SearchResultRow {
|
||||
#[template_child]
|
||||
pub name: TemplateChild<gtk::Label>,
|
||||
pub name: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub description: TemplateChild<gtk::Label>,
|
||||
pub description: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub shortcut: TemplateChild<gtk::Label>,
|
||||
pub shortcut: TemplateChild<gtk4::Label>,
|
||||
#[template_child]
|
||||
pub image: TemplateChild<gtk::Image>,
|
||||
pub image: TemplateChild<gtk4::Image>,
|
||||
#[template_child]
|
||||
pub categoryimage: TemplateChild<gtk::Image>,
|
||||
pub categoryimage: TemplateChild<gtk4::Image>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SearchResultRow {
|
||||
const NAME: &'static str = "SearchResultRow";
|
||||
type Type = super::SearchResultRow;
|
||||
type ParentType = gtk::Box;
|
||||
type ParentType = gtk4::Box;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
Self::bind_template(klass);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
use gtk::glib;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::glib;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
|
||||
use crate::icon_source;
|
||||
use crate::BoxedSearchResult;
|
||||
use crate::icon_source;
|
||||
use crate::SearchResultObject;
|
||||
|
||||
mod imp;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct SearchResultRow(ObjectSubclass<imp::SearchResultRow>)
|
||||
@extends gtk::Widget, gtk::Box;
|
||||
@extends gtk4::Widget, gtk4::Box;
|
||||
}
|
||||
|
||||
impl Default for SearchResultRow {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
use glib::subclass::InitializingObject;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{CompositeTemplate, Entry, ListView};
|
||||
use gtk4 as gtk;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{CompositeTemplate, Entry, ListView};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
// Object holding the state
|
||||
|
|
@ -23,7 +22,7 @@ impl ObjectSubclass for Window {
|
|||
// `NAME` needs to match `class` attribute of template
|
||||
const NAME: &'static str = "LauncherWindow";
|
||||
type Type = super::Window;
|
||||
type ParentType = gtk::ApplicationWindow;
|
||||
type ParentType = gtk4::ApplicationWindow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
Self::bind_template(klass);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ use gdk4::Rectangle;
|
|||
use gdk4_x11::X11Display;
|
||||
use gdk4_x11::X11Surface;
|
||||
use glib::Object;
|
||||
use gtk::prelude::*;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
use gtk::{Application, SignalListItemFactory};
|
||||
use gtk4 as gtk;
|
||||
use gtk4::{gio, glib};
|
||||
use gtk4::{Application, SignalListItemFactory};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use postage::prelude::Sink;
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto;
|
||||
|
|
@ -23,9 +22,9 @@ mod imp;
|
|||
|
||||
glib::wrapper! {
|
||||
pub struct Window(ObjectSubclass<imp::Window>)
|
||||
@extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
|
||||
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
|
||||
gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
|
||||
@extends gtk4::ApplicationWindow, gtk4::Window, gtk4::Widget,
|
||||
@implements gio::ActionGroup, gio::ActionMap, gtk4::Accessible, gtk4::Buildable,
|
||||
gtk4::ConstraintTarget, gtk4::Native, gtk4::Root, gtk4::ShortcutManager;
|
||||
}
|
||||
|
||||
const NUM_LAUNCHER_ITEMS: u8 = 9;
|
||||
|
|
@ -47,8 +46,8 @@ impl Window {
|
|||
let imp = imp::Window::from_instance(self);
|
||||
let model = gio::ListStore::new(SearchResultObject::static_type());
|
||||
|
||||
let slice_model = gtk::SliceListModel::new(Some(&model), 0, NUM_LAUNCHER_ITEMS.into());
|
||||
let selection_model = gtk::SingleSelection::builder()
|
||||
let slice_model = gtk4::SliceListModel::new(Some(&model), 0, NUM_LAUNCHER_ITEMS.into());
|
||||
let selection_model = gtk4::SingleSelection::builder()
|
||||
.model(&slice_model)
|
||||
.autoselect(false)
|
||||
.can_unselect(true)
|
||||
|
|
@ -63,7 +62,7 @@ impl Window {
|
|||
fn setup_callbacks(&self) {
|
||||
// Get state
|
||||
let imp = imp::Window::from_instance(self);
|
||||
let window = self.clone().upcast::<gtk::Window>();
|
||||
let window = self.clone().upcast::<gtk4::Window>();
|
||||
let list_view = &imp.list_view;
|
||||
let entry = &imp.entry;
|
||||
let lv = list_view.get();
|
||||
|
|
@ -94,7 +93,7 @@ impl Window {
|
|||
let app_selection_model = list_view
|
||||
.model()
|
||||
.expect("List view missing selection model")
|
||||
.downcast::<gtk::SingleSelection>()
|
||||
.downcast::<gtk4::SingleSelection>()
|
||||
.expect("could not downcast listview model to single selection model");
|
||||
|
||||
app_selection_model.connect_selected_notify(glib::clone!(@weak window => move |model| {
|
||||
|
|
@ -117,7 +116,7 @@ impl Window {
|
|||
}
|
||||
}));
|
||||
|
||||
entry.connect_changed(glib::clone!(@weak lv => move |search: >k::Entry| {
|
||||
entry.connect_changed(glib::clone!(@weak lv => move |search: >k4::Entry| {
|
||||
let search = search.text().to_string();
|
||||
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
|
|
@ -128,7 +127,7 @@ impl Window {
|
|||
});
|
||||
}));
|
||||
|
||||
entry.connect_realize(glib::clone!(@weak lv => move |search: >k::Entry| {
|
||||
entry.connect_realize(glib::clone!(@weak lv => move |search: >k4::Entry| {
|
||||
let search = search.text().to_string();
|
||||
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue