Skip to content

Commit 4e5d080

Browse files
committed
Transfer ownership of clipboard and recent manager to slot toplevel interface
1 parent 08f619b commit 4e5d080

5 files changed

Lines changed: 24 additions & 12 deletions

File tree

libcore/Interfaces/SlotToplevelInterface.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
*/
2424

2525
public interface Files.SlotToplevelInterface : Gtk.Window {
26-
/* Parent interface (ViewContainer or Window) */
2726
public virtual void folder_deleted (GLib.File file) {}
28-
// public abstract unowned Gtk.Window? get_window (); // Should return main window
2927
public abstract unowned AbstractSlot? get_view (); // Should return current slot
3028
public abstract AbstractSlot? prepare_reload ();
3129
public abstract void free_space_change ();
3230
public abstract bool can_bookmark_uri (string uri);
31+
public abstract unowned ClipboardManager get_clipboard_manager ();
32+
public abstract unowned Gtk.RecentManager get_recent_manager ();
3333
}

libcore/View/BasicAbstractDirectoryView.vala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ namespace Files {
173173
protected Gtk.ScrolledWindow scrolled_window;
174174
protected Gtk.Label empty_label;
175175
protected Gtk.Overlay overlay;
176-
protected ClipboardManager clipboard;
176+
protected unowned ClipboardManager clipboard;
177+
protected unowned Gtk.RecentManager recent;
177178
protected Files.ListModel model;
178179
protected Files.IconRenderer icon_renderer;
179180
public BasicSlot slot { get; construct; }
@@ -230,7 +231,8 @@ namespace Files {
230231

231232
child = overlay;
232233

233-
clipboard = ClipboardManager.get_for_display ();
234+
clipboard = slot.top_level.get_clipboard_manager ();
235+
recent = slot.top_level.get_recent_manager ();
234236

235237
thumbnailer = Thumbnailer.get ();
236238
thumbnailer.finished.connect ((req) => {

src/Application.vala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class Files.Application : Gtk.Application {
3232

3333
private VolumeMonitor volume_monitor;
3434
private Progress.UIHandler progress_handler;
35-
private Gtk.RecentManager recent;
3635

3736
private const int MARLIN_ACCEL_MAP_SAVE_DELAY = 15;
3837
private const uint MAX_WINDOWS = 25;
@@ -135,7 +134,6 @@ public class Files.Application : Gtk.Application {
135134

136135
progress_handler = new Progress.UIHandler ();
137136

138-
this.recent = new Gtk.RecentManager ();
139137

140138
/* Global static variable "plugins" declared in PluginManager.vala */
141139
plugins = new PluginManager (Config.PLUGIN_DIR, (uint)(Posix.getuid ()));
@@ -172,9 +170,6 @@ public class Files.Application : Gtk.Application {
172170
set_accels_for_action ("app.quit", { "<Ctrl>Q" });
173171
}
174172

175-
public unowned Gtk.RecentManager get_recent_manager () {
176-
return this.recent;
177-
}
178173

179174
public override int command_line (GLib.ApplicationCommandLine cmd) {
180175
unowned var options = cmd.get_options_dict ();

src/View/AbstractDirectoryView.vala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,13 @@ namespace Files {
160160
}
161161
}
162162

163-
protected unowned Gtk.RecentManager recent;
164-
165163
protected AbstractDirectoryView (View.Slot _slot) {
166164
base (_slot);
167165
}
168166

169167
construct {
170168
set_up_additional_menu_actions ();
171169
var app = (Files.Application)(GLib.Application.get_default ());
172-
recent = app.get_recent_manager ();
173170
app.set_accels_for_action ("common.select-all", {"<Ctrl>A"});
174171
app.set_accels_for_action ("selection.invert-selection", {"<Shift><Ctrl>A"});
175172

src/View/Window.vala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,4 +1527,22 @@ public class Files.View.Window : Hdy.ApplicationWindow, SlotToplevelInterface {
15271527
public AbstractSlot? prepare_reload () {
15281528
return current_container.prepare_reload ();
15291529
}
1530+
1531+
private ClipboardManager? clipboard_manager = null;
1532+
public unowned ClipboardManager get_clipboard_manager () {
1533+
if (clipboard_manager == null) {
1534+
clipboard_manager = ClipboardManager.get_for_display ();
1535+
}
1536+
1537+
return clipboard_manager;
1538+
}
1539+
1540+
private Gtk.RecentManager? recent_manager;
1541+
public unowned Gtk.RecentManager get_recent_manager () {
1542+
if (recent_manager == null) {
1543+
recent_manager = new Gtk.RecentManager ();
1544+
}
1545+
1546+
return recent_manager;
1547+
}
15301548
}

0 commit comments

Comments
 (0)