Commit 83222372 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Export Dialog: use a HdyDialog

parent 0ff0c222
This diff is collapsed.
......@@ -5,13 +5,13 @@ authors = ["Bilal Elmoussaoui <bilal.elmoussaoui@gnome.org>"]
edition = "2018"
[dependencies]
gtk = { version = "0.6.0", features = ["v3_22"] }
glib = "0.7"
gio = { version = "0.6.0", features = ["v2_56"] }
gdk = "0.10.0"
gtk = { version = "0.7.0", features = ["v3_24"] }
glib = "0.8.1"
gio = "0.7.0"
gdk = "0.11.0"
log = "0.4"
gettext-rs= { version = "0.4.1", features = ["gettext-system"] }
libhandy = "0.3.0"
libhandy = "0.4.0"
serde = "1.0.97"
serde_json = "1.0.40"
serde_derive = "1.0.97"
......
......@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/design/IconLibrary/">
<file compressed="true" preprocess="xml-stripblanks">about_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="export_window.ui">resources/ui/export_window.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="export_dialog.ui">resources/ui/export_dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="shortcuts.ui">resources/ui/shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="menu.ui">resources/ui/menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
......
......@@ -12,7 +12,7 @@ pub struct Application {
impl Application {
pub fn new() -> Self {
let app = gtk::Application::new(config::APP_ID, gio::ApplicationFlags::FLAGS_NONE).unwrap();
let app = gtk::Application::new(Some(config::APP_ID), gio::ApplicationFlags::FLAGS_NONE).unwrap();
let window = Window::new();
glib::set_application_name(&format!("Icon Library{}", config::NAME_SUFFIX));
......@@ -33,40 +33,36 @@ impl Application {
pub fn setup_gactions(&self) {
// Quit
let app = self.app.clone();
self.add_gaction("quit", move |_, _| app.quit());
let simple_action = gio::SimpleAction::new("quit", None);
simple_action.connect_activate(move |_, _| app.quit());
self.app.add_action(&simple_action);
self.app.set_accels_for_action("app.quit", &["<primary>q"]);
// About
let window = self.window.widget.clone();
self.add_gaction("about", move |_, _| {
let simple_action = gio::SimpleAction::new("about", None);
simple_action.connect_activate(move |_, _| {
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/about_dialog.ui");
let about_dialog: gtk::AboutDialog = builder.get_object("about_dialog").unwrap();
about_dialog.set_transient_for(&window);
about_dialog.set_transient_for(Some(&window));
about_dialog.connect_response(|dialog, _| dialog.destroy());
about_dialog.show();
});
self.app.add_action(&simple_action);
self.app.set_accels_for_action("app.about", &["<primary>comma"]);
}
pub fn setup_signals(&self) {
let window = self.window.widget.clone();
self.app.connect_activate(move |app| {
window.set_application(app);
window.set_application(Some(app));
app.add_window(&window);
window.present();
});
}
fn add_gaction<F>(&self, name: &str, action: F)
where
for<'r, 's> F: Fn(&'r gio::SimpleAction, &'s Option<glib::Variant>) + 'static,
{
let simple_action = gio::SimpleAction::new(name, None);
simple_action.connect_activate(action);
self.app.add_action(&simple_action);
}
pub fn setup_css(&self) {
let p = gtk::CssProvider::new();
gtk::CssProvider::load_from_resource(&p, "/org/gnome/design/IconLibrary/style.css");
......
......@@ -8,8 +8,8 @@ use std::fs;
use std::path::Path;
pub struct ExportDialog {
pub widget: gtk::Window,
headerbar: gtk::HeaderBar,
pub widget: libhandy::Dialog,
icon_size_16: gtk::Image,
icon_size_32: gtk::Image,
icon_size_64: gtk::Image,
......@@ -17,12 +17,11 @@ pub struct ExportDialog {
impl ExportDialog {
pub fn new(icon: Icon) -> ExportDialog {
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/export_window.ui");
let widget: gtk::Window = builder.get_object("export_window").unwrap();
let builder = gtk::Builder::new_from_resource("/org/gnome/design/IconLibrary/export_dialog.ui");
let widget: libhandy::Dialog = builder.get_object("export_dialog").unwrap();
let icon_size_16: gtk::Image = builder.get_object("icon_size_16").unwrap();
let icon_size_32: gtk::Image = builder.get_object("icon_size_32").unwrap();
let icon_size_64: gtk::Image = builder.get_object("icon_size_64").unwrap();
let headerbar: gtk::HeaderBar = builder.get_object("headerbar").unwrap();
let is_system_infobar: gtk::InfoBar = builder.get_object("is_system_infobar").unwrap();
is_system_infobar.set_visible(icon.is_system);
......@@ -30,7 +29,6 @@ impl ExportDialog {
let export_dialog = ExportDialog {
widget,
headerbar,
icon_size_16,
icon_size_32,
icon_size_64,
......@@ -47,14 +45,14 @@ impl ExportDialog {
self.icon_size_64.set_from_icon_name(icon_str, gtk::IconSize::Dialog);
let window_title = icon.name.replace("-symbolic", "");
self.headerbar.set_title(Some(window_title.as_str()));
self.widget.set_title(window_title.as_str());
}
fn setup_actions(&self, icon: &Icon) {
// setup actions
let actions = gio::SimpleActionGroup::new();
self.widget.insert_action_group("export", &actions);
self.widget.insert_action_group("export", Some(&actions));
// Copy Icon Name action
let icon_name = icon.name.clone();
let copy_icon_name = gio::SimpleAction::new("copy-icon-name", None);
......@@ -69,7 +67,7 @@ impl ExportDialog {
let save_as = gio::SimpleAction::new("save-as", None);
let window = self.widget.clone();
save_as.connect_activate(move |_, _| {
let export_dialog = gtk::FileChooserNative::new("Export a symbolic icon", &window, gtk::FileChooserAction::Save, "Export", "Cancel");
let export_dialog = gtk::FileChooserNative::new(Some("Export a symbolic icon"), Some(&window), gtk::FileChooserAction::Save, Some("Export"), Some("Cancel"));
let file_name = format!("{}.svg", icon_name.clone());
export_dialog.set_current_name(Path::new(&file_name));
let icon_name = icon_name.clone();
......
......@@ -46,10 +46,10 @@ impl IconsView {
no_results_view.set_valign(gtk::Align::Center);
no_results_view.set_halign(gtk::Align::Center);
let no_results_image = gtk::Image::new_from_icon_name("system-search-symbolic", gtk::IconSize::Dialog);
let no_results_image = gtk::Image::new_from_icon_name(Some("system-search-symbolic"), gtk::IconSize::Dialog);
no_results_image.set_pixel_size(96);
let no_results_label = gtk::Label::new(gettext("No results found").as_str());
let no_results_label = gtk::Label::new(Some(gettext("No results found").as_str()));
no_results_label.get_style_context().add_class("no-results-label");
no_results_view.pack_start(&no_results_image, false, false, 0);
......@@ -106,7 +106,7 @@ impl IconsView {
}
let mut icons: Vec<Icon> = theme
.list_icons(context_str)
.list_icons(Some(context_str))
.into_iter()
.filter(|icon_name| {
// filter out uneeded icons
......@@ -244,7 +244,7 @@ impl IconView {
self.widget.connect_button_press_event(move |_, _| {
let export_dialog = ExportDialog::new(icon.clone());
export_dialog.widget.set_transient_for(&parent_window);
export_dialog.widget.set_transient_for(Some(&parent_window));
export_dialog.widget.show_all();
gtk::Inhibit(true)
});
......
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