Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallpaper: replace deprecated FileChooserNative with FileDialog #398

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You'll need the following dependencies:
* libswitchboard-3-dev
* libgee-0.8-dev
* libgexiv2-dev
* libgtk-4-dev (>=4.8)
* libgtk-4-dev (>=4.10)
* libgranite-7-dev (>=7.5.0)
* meson
* valac
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gio_dep = dependency('gio-2.0')
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
granite_dep = dependency('granite-7', version: '>=7.5.0')
gtk_dep = dependency('gtk4', version: '>=4.8')
gtk_dep = dependency('gtk4', version: '>=4.10')
hdy_dep = dependency ('libadwaita-1')
posix_dep = meson.get_compiler('vala').find_library('posix')

Expand Down
27 changes: 12 additions & 15 deletions src/Views/Wallpaper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,18 @@ public class PantheonShell.Wallpaper : Gtk.Box {
var filter = new Gtk.FileFilter ();
filter.add_mime_type ("image/*");

var chooser = new Gtk.FileChooserNative (
_("Import Photo"), null, Gtk.FileChooserAction.OPEN,
_("Import"),
_("Cancel")
);
chooser.filter = filter;
chooser.select_multiple = true;

chooser.show ();
chooser.response.connect ((response) => {
if (response == Gtk.ResponseType.ACCEPT) {
var files = chooser.get_files ();
for (var i = 0; i <= files.get_n_items (); i++) {
var file = (File) files.get_item (i);
var file_dialog = new Gtk.FileDialog () {
accept_label = _("Import"),
default_filter = filter,
modal = true,
title = _("Import Photos")
};

file_dialog.open_multiple.begin ((Gtk.Window) get_root (), null, (obj, res) => {
var list_model = file_dialog.open_multiple.end (res);
if (list_model != null) {
for (var i = 0; i <= list_model.get_n_items (); i++) {
var file = (File) list_model.get_item (i);

if (WallpaperOperation.get_is_file_in_bg_dir (file)) {
continue;
Expand All @@ -176,7 +174,6 @@ public class PantheonShell.Wallpaper : Gtk.Box {
add_wallpaper_from_file (file, local_uri);
}
}
chooser.destroy ();
});
}

Expand Down
Loading