From 37adf24f3766e16350a9151251c9c3662038983d Mon Sep 17 00:00:00 2001 From: teamcons Date: Thu, 14 Aug 2025 22:21:27 +0200 Subject: [PATCH 1/3] Allow Drag&Drop from Documents --- io.github.wpkelso.slate.yaml | 2 ++ src/Utils.vala | 1 + src/Window.vala | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/io.github.wpkelso.slate.yaml b/io.github.wpkelso.slate.yaml index f825a29..35018ae 100644 --- a/io.github.wpkelso.slate.yaml +++ b/io.github.wpkelso.slate.yaml @@ -12,6 +12,8 @@ finish-args: - --socket=wayland # GPU acceleration if needed - --device=dri + # Access files dropped from documents + - --filesystem=xdg-documents modules: - name: slate diff --git a/src/Utils.vala b/src/Utils.vala index 80b5c9f..f2eebc2 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -48,6 +48,7 @@ } catch (Error err) { warning ("Failed to get file information: %s", err.message); + return false; } return false; diff --git a/src/Window.vala b/src/Window.vala index e5e9da2..7e3054e 100644 --- a/src/Window.vala +++ b/src/Window.vala @@ -90,6 +90,9 @@ public class AppWindow : Gtk.Window { this.close_request.connect (on_close); buf.changed.connect (on_buffer_changed); + var drop_target = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY); + text_view.add_controller (drop_target); + drop_target.drop.connect (on_dropped); } @@ -205,4 +208,19 @@ public class AppWindow : Gtk.Window { return false; } + + public bool on_dropped (Gtk.DropTarget target, GLib.Value value, double x, double y) { + if (value.type () == typeof (Gdk.FileList)) { + var list = (Gdk.FileList)value; + File[] file_array = {}; + + foreach (unowned var file in list.get_files ()) { + file_array += file; + } + + application.open (file_array, ""); + return true; + } + return false; + } } From f078c27cc785a2611dca7d58cb9410b7b3957dd6 Mon Sep 17 00:00:00 2001 From: teamcons Date: Thu, 14 Aug 2025 22:31:55 +0200 Subject: [PATCH 2/3] Correct mistake --- io.github.wpkelso.slate.yaml | 2 -- src/Utils.vala | 1 - src/Window.vala | 19 ------------------- 3 files changed, 22 deletions(-) diff --git a/io.github.wpkelso.slate.yaml b/io.github.wpkelso.slate.yaml index 35018ae..f825a29 100644 --- a/io.github.wpkelso.slate.yaml +++ b/io.github.wpkelso.slate.yaml @@ -12,8 +12,6 @@ finish-args: - --socket=wayland # GPU acceleration if needed - --device=dri - # Access files dropped from documents - - --filesystem=xdg-documents modules: - name: slate diff --git a/src/Utils.vala b/src/Utils.vala index f2eebc2..80b5c9f 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -48,7 +48,6 @@ } catch (Error err) { warning ("Failed to get file information: %s", err.message); - return false; } return false; diff --git a/src/Window.vala b/src/Window.vala index 7e3054e..dc7feeb 100644 --- a/src/Window.vala +++ b/src/Window.vala @@ -89,10 +89,6 @@ public class AppWindow : Gtk.Window { save_as_button.clicked.connect (on_save_as); this.close_request.connect (on_close); buf.changed.connect (on_buffer_changed); - - var drop_target = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY); - text_view.add_controller (drop_target); - drop_target.drop.connect (on_dropped); } @@ -208,19 +204,4 @@ public class AppWindow : Gtk.Window { return false; } - - public bool on_dropped (Gtk.DropTarget target, GLib.Value value, double x, double y) { - if (value.type () == typeof (Gdk.FileList)) { - var list = (Gdk.FileList)value; - File[] file_array = {}; - - foreach (unowned var file in list.get_files ()) { - file_array += file; - } - - application.open (file_array, ""); - return true; - } - return false; - } } From 413c227864350ec24732fedb2341f5454ec154a3 Mon Sep 17 00:00:00 2001 From: teamcons Date: Thu, 14 Aug 2025 22:34:12 +0200 Subject: [PATCH 3/3] Translatable error dialog --- src/Application.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 82f4b18..7201a38 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -146,8 +146,8 @@ public class Application : Gtk.Application { var window = get_windows ().first ().data; var error_dialog = new Granite.MessageDialog.with_image_from_icon_name ( - "Couldn't open file", - "The specified file is not a valid text file", + _("Couldn't open file"), + _("The specified file is not a valid text file"), "dialog-error" ) { transient_for = window