Commit c31eec2f authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

bump gtk-rs

parent a3ab0594
This diff is collapsed.
......@@ -5,23 +5,23 @@ authors = ["Bilal Elmoussaoui <bilal.elmoussaoui@gnome.org>"]
edition = "2018"
[dependencies]
gtk = { version = "0.8", features = ["v3_24"] }
glib = "0.9"
gio = {version = "0.8", features = ["v2_56"] }
gdk = "0.12"
gdk-pixbuf = {version = "0.8", features = ["v2_32"] }
gtk = { version = "0.9", features = ["v3_24"] }
glib = "0.10"
gio = {version = "0.9", features = ["v2_56"] }
gdk = "0.13"
gdk-pixbuf = {version = "0.9", features = ["v2_32"] }
log = "0.4"
gettext-rs= { version = "0.4", features = ["gettext-system"] }
libhandy = "0.5"
libhandy = "0.6"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
pretty_env_logger = "0.3"
dbus = "0.8"
search-provider = { git = "https://gitlab.gnome.org/World/Rust/search-provider.git" }
search-provider = "0.2"
gtk-macros = "0.2"
anyhow = "1.0"
[dependencies.sourceview4]
git = "https://gitlab.gnome.org/World/Rust/sourceview4-rs.git"
rev = "fa8819fa7ecbe56f44d951656d3825f468915754"
rev = "275d8beb8a41b2a10321b0fd890a31de4700ed59"
......@@ -2,7 +2,6 @@ use crate::config;
use crate::models::{Icon, IconsModel};
use crate::search_provider::SearchProvider;
use crate::widgets::{ExportDialog, Window};
use anyhow::Result;
use gio::prelude::*;
use glib::Receiver;
use gtk::prelude::*;
......@@ -21,12 +20,12 @@ pub struct Application {
}
impl Application {
pub fn new() -> Result<Self> {
let app = gtk::Application::new(Some(config::APP_ID), Default::default())?;
pub fn new() -> Self {
let app = gtk::Application::new(Some(config::APP_ID), Default::default()).unwrap();
let (sender, r) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
let receiver = RefCell::new(Some(r));
let model = Rc::new(IconsModel::new()?);
let model = Rc::new(IconsModel::new());
let window = Window::new(sender.clone(), model.clone());
SearchProvider::new(model, window.widget.clone(), sender);
......@@ -36,7 +35,7 @@ impl Application {
application.setup_gactions();
application.setup_signals();
application.setup_css();
Ok(application)
application
}
fn setup_gactions(&self) {
......@@ -54,10 +53,10 @@ impl Application {
self.app,
"about",
clone!(@weak self.window.widget as window => move |_, _|{
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/about_dialog.ui");
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/about_dialog.ui");
get_widget!(builder, gtk::AboutDialog, about_dialog);
about_dialog.set_transient_for(Some(&window));
about_dialog.connect_response(|dialog, _| dialog.destroy());
about_dialog.connect_response(|dialog, _| dialog.close());
about_dialog.show();
})
);
......
......@@ -6,7 +6,7 @@ extern crate glib;
extern crate serde_derive;
#[macro_use]
extern crate gtk_macros;
use anyhow::Result;
use gettextrs::*;
use std::rc::Rc;
......@@ -21,10 +21,11 @@ mod window_state;
use application::Application;
use config::{GETTEXT_PACKAGE, LOCALEDIR, NAME_PREFIX};
fn main() -> Result<()> {
fn main() {
pretty_env_logger::init();
gtk::init()?;
gtk::init().expect("Failed to initalize gtk3");
libhandy::init().expect("Failed to initialize libhandy");
glib::set_application_name(&format!("{}Icon Library", NAME_PREFIX));
glib::set_prgname(Some("icon-library"));
......@@ -33,12 +34,9 @@ fn main() -> Result<()> {
setlocale(LocaleCategory::LcAll, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
textdomain(GETTEXT_PACKAGE);
libhandy::Column::new();
static_resources::init()?;
static_resources::init().expect("Failed to initialize the gresource");
let app = Rc::new(Application::new()?);
let app = Rc::new(Application::new());
app.run(app.clone());
Ok(())
}
......@@ -22,12 +22,12 @@ pub struct IconsModel {
}
impl IconsModel {
pub fn new() -> Result<Self> {
pub fn new() -> Self {
let system_icons = RefCell::new(BTreeMap::new());
let shipped_icons = RefCell::new(BTreeMap::new());
let model = Self { system_icons, shipped_icons };
model.init()?;
Ok(model)
model.init();
model
}
fn get_icons(&self) -> Vec<Icon> {
......@@ -74,11 +74,13 @@ impl IconsModel {
.collect()
}
fn init(&self) -> Result<()> {
self.init_shipped_icons()?;
self.init_system_icons()?;
Ok(())
fn init(&self) {
if let Err(err) = self.init_shipped_icons() {
error!("Failed to init the shipped icons?? {}", err);
}
if let Err(err) = self.init_system_icons() {
error!("Failed to init system icons?? {}", err)
}
}
fn init_shipped_icons(&self) -> Result<()> {
......
......@@ -19,7 +19,7 @@ pub struct ExportDialog {
impl ExportDialog {
pub fn new(icon: Icon) -> ExportDialog {
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/export_dialog.ui");
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/export_dialog.ui");
get_widget!(builder, gtk::Window, export_dialog);
let export_dialog_widget = ExportDialog {
......@@ -33,7 +33,7 @@ impl ExportDialog {
}
fn create_buffer(lang: &sourceview4::Language, content: &str, view: sourceview4::View) -> sourceview4::Buffer {
let buffer = sourceview4::Buffer::new_with_language(lang);
let buffer = sourceview4::Buffer::with_language(lang);
view.set_buffer(Some(&buffer));
buffer.set_highlight_syntax(true);
buffer.set_highlight_matching_brackets(false);
......@@ -268,12 +268,12 @@ impl ExportDialog {
// Quit
self.widget.connect_delete_event(|w, _| {
w.destroy();
w.close();
gtk::Inhibit(false)
});
self.widget.connect_key_press_event(|w, k| {
if k.get_keyval() == gdk::enums::key::Escape {
w.destroy();
if k.get_keyval() == gdk::keys::constants::Escape {
w.close();
}
gtk::Inhibit(false)
});
......
......@@ -16,7 +16,7 @@ pub struct IconsView {
impl IconsView {
pub fn new(sender: glib::Sender<Action>) -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/icons_view.ui");
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/icons_view.ui");
get_widget!(builder, gtk::Stack, icons_view);
Self {
......@@ -180,7 +180,7 @@ impl IconView {
event_box.show();
self.widget.add(&event_box);
let icon_img = gtk::Image::new_from_icon_name(Some(&self.icon.name), gtk::IconSize::Dnd);
let icon_img = gtk::Image::from_icon_name(Some(&self.icon.name), gtk::IconSize::Dnd);
icon_img.get_style_context().add_class("icon");
event_box.add(&icon_img);
}
......
......@@ -16,7 +16,7 @@ pub struct Window {
impl Window {
pub fn new(sender: glib::Sender<Action>, model: Rc<IconsModel>) -> Self {
let settings = gio::Settings::new(APP_ID);
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/window.ui");
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/window.ui");
get_widget!(builder, gtk::ApplicationWindow, window);
let window_widget = Window {
......@@ -55,7 +55,7 @@ impl Window {
Inhibit(false)
});
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/shortcuts.ui");
let builder = gtk::Builder::from_resource("/org/gnome/design/IconLibrary/shortcuts.ui");
get_widget!(builder, gtk::ShortcutsWindow, shortcuts);
self.widget.set_help_overlay(Some(&shortcuts));
......@@ -72,7 +72,7 @@ impl Window {
// Search
get_widget!(self.builder, gtk::SearchEntry, search_entry);
search_entry.connect_changed(move |entry| {
let search_text = entry.get_text().unwrap();
let search_text = entry.get_text();
icons_view.filter(&search_text);
});
search_entry.connect_stop_search(move |entry| {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment