cleanup
This commit is contained in:
parent
a6c5b3b0b4
commit
04b4b88534
3 changed files with 32 additions and 21 deletions
|
|
@ -5,30 +5,36 @@ mod window;
|
|||
use gtk::gdk::Display;
|
||||
use gtk::prelude::*;
|
||||
use gtk4 as gtk;
|
||||
use gtk4::CssProvider;
|
||||
use gtk4::StyleContext;
|
||||
|
||||
use window::Window;
|
||||
|
||||
fn main() {
|
||||
let application = gtk::Application::new(
|
||||
Some("com.github.gtk-rs.examples.apps_launcher"),
|
||||
Default::default(),
|
||||
);
|
||||
let app = gtk::Application::new(Some("com.cosmic.app_library"), Default::default());
|
||||
app.connect_startup(|_app| load_css());
|
||||
|
||||
application.connect_activate(|app| {
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_data(include_bytes!("style.css"));
|
||||
gtk::StyleContext::add_provider_for_display(
|
||||
&Display::default().expect("Error initializing gtk css provider."),
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
new_build_ui(app);
|
||||
app.connect_activate(|app| {
|
||||
build_ui(app);
|
||||
});
|
||||
|
||||
application.run();
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn new_build_ui(app: >k::Application) {
|
||||
fn load_css() {
|
||||
// Load the css file and add it to the provider
|
||||
let provider = CssProvider::new();
|
||||
provider.load_from_data(include_bytes!("style.css"));
|
||||
|
||||
// Add the provider to the default screen
|
||||
StyleContext::add_provider_for_display(
|
||||
&Display::default().expect("Error initializing GTK CSS provider."),
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
|
||||
fn build_ui(app: >k::Application) {
|
||||
// Create a new custom window and show it
|
||||
let window = Window::new(app);
|
||||
window.show();
|
||||
|
|
|
|||
|
|
@ -34,12 +34,18 @@ impl Window {
|
|||
Object::new(&[("application", app)]).expect("Failed to create `Window`.")
|
||||
}
|
||||
|
||||
fn model(&self) -> &gio::ListStore {
|
||||
fn app_model(&self) -> &gio::ListStore {
|
||||
// Get state
|
||||
let imp = imp::Window::from_instance(self);
|
||||
imp.app_model.get().expect("Could not get model")
|
||||
}
|
||||
|
||||
fn group_model(&self) -> &gio::ListStore {
|
||||
// Get state
|
||||
let imp = imp::Window::from_instance(self);
|
||||
imp.group_model.get().expect("Could not get model")
|
||||
}
|
||||
|
||||
fn setup_model(&self) {
|
||||
// Create new model
|
||||
let app_model = gio::ListStore::new(gio::DesktopAppInfo::static_type());
|
||||
|
|
@ -94,7 +100,6 @@ impl Window {
|
|||
let filter = gtk::CustomFilter::new(|_obj| true);
|
||||
let group_filter_model =
|
||||
gtk::FilterListModel::new(Some(&search_filter_model), Some(filter).as_ref());
|
||||
// TODO add app group filter model
|
||||
let sorted_model = gtk::SortListModel::new(Some(&group_filter_model), Some(&sorter));
|
||||
let selection_model = gtk::SingleSelection::new(Some(&sorted_model));
|
||||
|
||||
|
|
@ -132,7 +137,7 @@ impl Window {
|
|||
}),
|
||||
AppGroup::new(AppGroupData {
|
||||
id: 0,
|
||||
name: "Web".to_string(),
|
||||
name: "Custom Web".to_string(),
|
||||
icon: "folder".to_string(),
|
||||
mutable: true,
|
||||
app_names: vec!["Firefox Web Browser".to_string()],
|
||||
|
|
@ -210,7 +215,7 @@ impl Window {
|
|||
group_grid_view.connect_activate(glib::clone!(@weak app_filter_model => move |grid_view, position| {
|
||||
// if last item in the model, don't change filter, instead show dialog for adding new group!
|
||||
if position == grid_view.model().unwrap().n_items() - 1 {
|
||||
println!("TODO: launch action to show the Add/Edit Group Window");
|
||||
println!("TODO: launch action to show the Add/Edit Group Overlay");
|
||||
return;
|
||||
};
|
||||
// update the application filter
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ fn load_css() {
|
|||
|
||||
fn main() {
|
||||
let app = gtk::Application::builder()
|
||||
.application_id("com.system76.Launcher")
|
||||
.application_id("com.cosmic.Launcher")
|
||||
.build();
|
||||
|
||||
app.connect_startup(|app| {
|
||||
|
|
@ -99,7 +99,7 @@ fn main() {
|
|||
|
||||
let window = Window::new(app);
|
||||
let wclone = window.clone();
|
||||
window.show();
|
||||
window.show();
|
||||
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
while let Some(event) = rx.recv().await {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue