1280.2.24
by Julián Unrrein
Add copyright notice to Application.vala. |
1 |
/***
|
1811.1.1
by Jeremy Wootten
Code clean: tabs, trailing space, headers, comments |
2 |
Copyright (C) 1999, 2000 Red Hat, Inc.
|
3 |
Copyright (C) 2000, 2001 Eazel, Inc.
|
|
4 |
Copyright (C) 2013 Julián Unrrein <junrrein@gmail.com>
|
|
5 |
||
6 |
This program is free software: you can redistribute it and/or modify it
|
|
7 |
under the terms of the GNU Lesser General Public License version 3, as published
|
|
8 |
by the Free Software Foundation.
|
|
9 |
||
10 |
This program is distributed in the hope that it will be useful, but
|
|
11 |
WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
12 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
13 |
PURPOSE. See the GNU General Public License for more details.
|
|
14 |
||
15 |
You should have received a copy of the GNU General Public License along
|
|
16 |
with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
||
18 |
Authors: Elliot Lee <sopwith@redhat.com>,
|
|
19 |
Darin Adler <darin@bentspoon.com>,
|
|
20 |
Julián Unrrein <junrrein@gmail.com>
|
|
1280.2.24
by Julián Unrrein
Add copyright notice to Application.vala. |
21 |
***/
|
22 |
||
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
23 |
private Marlin.Application application_singleton = null; |
1280.2.1
by Julián Unrrein
Replace marlin-application header and source files with a Vala file. Ensure everything compiles. |
24 |
|
25 |
public class Marlin.Application : Granite.Application { |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
26 |
|
1280.2.1
by Julián Unrrein
Replace marlin-application header and source files with a Vala file. Ensure everything compiles. |
27 |
private VolumeMonitor volume_monitor; |
28 |
private Marlin.Progress.UIHandler progress_handler; |
|
1459.1.41
by jeremy at elementaryos
Convert Columns view to Vala - basic functionality, no menus |
29 |
private Marlin.ClipboardManager clipboard; |
1280.2.1
by Julián Unrrein
Replace marlin-application header and source files with a Vala file. Ensure everything compiles. |
30 |
private Marlin.Thumbnailer thumbnailer; |
1740.1.39
by Fabio Zaramella
Use appropriate references with Recent Manager to prevent Files from crashing |
31 |
private Gtk.RecentManager recent; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
32 |
|
1280.2.19
by Julián Unrrein
Small style improvement. |
33 |
private const int MARLIN_ACCEL_MAP_SAVE_DELAY = 15; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
34 |
|
1504.1.2
by jeremy at elementaryos
Set initial geometry of new windows, other than the first, based on and offset from the active window |
35 |
public int window_count { get; private set; } |
1504.1.1
by jeremy at elementaryos
Prevent multiple simultaneous thumbnail threads, restrict access to Async directory functions, guard directory cache with mutex, set maximum windows and tabs |
36 |
|
1459.1.45
by jeremy at elementaryos
Window menus complete |
37 |
bool quitting = false; |
1459.1.43
by jeremy at elementaryos
Menus - stage 1 |
38 |
|
1280.2.6
by Julián Unrrein
More changes. |
39 |
construct { |
1331.1.1
by Julián Unrrein
Initialize info for the About dialog in Marlin.Application. |
40 |
/* Needed by Glib.Application */
|
41 |
this.application_id = "org.pantheon.files"; //Ensures an unique instance. |
|
42 |
this.flags = ApplicationFlags.HANDLES_COMMAND_LINE; |
|
43 |
||
44 |
/* Needed by Granite.Application */
|
|
45 |
this.program_name = Marlin.APP_TITLE; |
|
1405.1.1
by Niclas Lockner
Set exec_name |
46 |
this.exec_name = Marlin.APP_TITLE.down ().replace (" ", "-"); |
1331.1.1
by Julián Unrrein
Initialize info for the About dialog in Marlin.Application. |
47 |
this.build_version = Config.VERSION; |
48 |
||
49 |
this.app_copyright = Marlin.COPYRIGHT; |
|
50 |
this.app_years = Marlin.APP_YEARS; |
|
51 |
this.about_license_type = Gtk.License.GPL_3_0; |
|
52 |
this.app_icon = Marlin.ICON_ABOUT_LOGO; |
|
53 |
||
54 |
this.main_url = Marlin.LAUNCHPAD_URL; |
|
55 |
this.bug_url = Marlin.BUG_URL; |
|
56 |
this.help_url = Marlin.HELP_URL; |
|
57 |
this.translate_url = Marlin.TRANSLATE_URL; |
|
58 |
||
59 |
this.about_authors = Marlin.AUTHORS; |
|
60 |
this.about_documenters = { null }; |
|
61 |
this.about_artists = Marlin.ARTISTS; |
|
62 |
this.about_comments = Marlin.COMMENTS; |
|
63 |
this.about_translators = Marlin.TRANSLATORS; |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
64 |
|
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
65 |
application_singleton = this; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
66 |
}
|
67 |
||
1280.5.33
by Julián Unrrein
Solve a bug where Unity quicklist items weren't hidden after cancelling file operations. |
68 |
public static new unowned Application get () { |
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
69 |
if (application_singleton == null) |
70 |
application_singleton = new Marlin.Application (); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
71 |
|
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
72 |
return application_singleton; |
1280.2.1
by Julián Unrrein
Replace marlin-application header and source files with a Vala file. Ensure everything compiles. |
73 |
}
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
74 |
|
1280.2.6
by Julián Unrrein
More changes. |
75 |
~Application () { |
76 |
Notify.uninit (); |
|
77 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
78 |
|
79 |
public override void startup () { |
|
80 |
base.startup (); |
|
81 |
||
1280.2.16
by Julián Unrrein
Fix debug mode. |
82 |
if (Granite.Services.Logger.DisplayLevel != Granite.Services.LogLevel.DEBUG) |
83 |
Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.INFO; |
|
84 |
||
1459.1.55
by jeremy at elementaryos
commit prior to merging trunk |
85 |
message ("Report any issues/bugs you might find to http://bugs.launchpad.net/pantheon-files"); |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
86 |
|
87 |
init_schemas (); |
|
88 |
||
1280.2.23
by Julián Unrrein
Improve code style. |
89 |
Gtk.IconTheme.get_default ().changed.connect (() => { |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
90 |
Marlin.IconInfo.clear_caches (); |
91 |
});
|
|
92 |
||
93 |
Notify.init (Config.GETTEXT_PACKAGE); |
|
94 |
this.progress_handler = new Marlin.Progress.UIHandler (); |
|
1459.1.41
by jeremy at elementaryos
Convert Columns view to Vala - basic functionality, no menus |
95 |
this.clipboard = new Marlin.ClipboardManager.get_for_display (Gdk.Display.get_default ()); |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
96 |
this.thumbnailer = Marlin.Thumbnailer.get (); |
1740.1.39
by Fabio Zaramella
Use appropriate references with Recent Manager to prevent Files from crashing |
97 |
this.recent = new Gtk.RecentManager (); |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
98 |
|
1459.1.67
by jeremy at elementaryos
Implement add-remove helper in icon view, fix adding multiple new tabs |
99 |
plugins = new Marlin.PluginManager (Config.PLUGIN_DIR); |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
100 |
|
1811.1.1
by Jeremy Wootten
Code clean: tabs, trailing space, headers, comments |
101 |
/**TODO** move the volume manager here? */
|
102 |
/**TODO** gio: This should be using the UNMOUNTED feature of GFileMonitor instead */
|
|
103 |
||
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
104 |
this.volume_monitor = VolumeMonitor.get (); |
105 |
this.volume_monitor.mount_removed.connect (mount_removed_callback); |
|
106 |
||
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
107 |
#if HAVE_UNITY |
1280.3.1
by Julián Unrrein
Delete unity-quicklist-handler's source and header files. Add Vala source file replacement. Add enough code to make everything compile. |
108 |
QuicklistHandler.get_singleton (); |
1280.2.8
by Julián Unrrein
Conditionally compile Vala files with support for Unity quicklists. |
109 |
#endif |
1504.1.2
by jeremy at elementaryos
Set initial geometry of new windows, other than the first, based on and offset from the active window |
110 |
|
111 |
window_count = 0; |
|
112 |
this.window_added.connect (() => {window_count++;}); |
|
113 |
this.window_removed.connect (() => {window_count--;}); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
114 |
}
|
115 |
||
1459.1.46
by jeremy at elementaryos
Miller view: Complete menu actions - fix scrolling |
116 |
public unowned Marlin.ClipboardManager get_clipboard_manager () { |
117 |
return this.clipboard; |
|
118 |
}
|
|
119 |
||
1740.1.39
by Fabio Zaramella
Use appropriate references with Recent Manager to prevent Files from crashing |
120 |
public unowned Gtk.RecentManager get_recent_manager () { |
121 |
return this.recent; |
|
122 |
}
|
|
123 |
||
1280.2.6
by Julián Unrrein
More changes. |
124 |
public override int command_line (ApplicationCommandLine cmd) { |
125 |
this.hold (); |
|
126 |
int result = _command_line (cmd); |
|
127 |
this.release (); |
|
128 |
return result; |
|
129 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
130 |
|
131 |
/* The array that holds the file commandline arguments
|
|
1280.2.9
by Julián Unrrein
Small changes. |
132 |
needs some boilerplate so its size gets updated. */
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
133 |
[CCode (array_length = false, array_null_terminated = true)] |
1382.2.5
by Jeremy Wootten
BookmarkList and Bookmark implemented in Vala - first draft not debugged |
134 |
private string[]? remaining = null; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
135 |
|
1280.2.6
by Julián Unrrein
More changes. |
136 |
private int _command_line (ApplicationCommandLine cmd) { |
1280.2.13
by Julián Unrrein
Make debug mode work. |
137 |
/* Setup the argument parser */
|
1280.2.2
by Julián Unrrein
Continue with porting. |
138 |
bool version = false; |
1280.2.17
by Julián Unrrein
Tidy up code. |
139 |
bool open_in_tab = false; |
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
140 |
bool create_new_window = false; |
1280.2.2
by Julián Unrrein
Continue with porting. |
141 |
bool kill_shell = false; |
1280.2.18
by Julián Unrrein
Use config.h instead of Config.vala. Fix debug mode again. |
142 |
bool debug = false; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
143 |
|
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
144 |
OptionEntry[] options = new OptionEntry [7]; |
1280.2.2
by Julián Unrrein
Continue with porting. |
145 |
options [0] = { "version", '\0', 0, OptionArg.NONE, ref version, |
146 |
N_("Show the version of the program."), null }; |
|
1280.2.17
by Julián Unrrein
Tidy up code. |
147 |
options [1] = { "tab", 't', 0, OptionArg.NONE, ref open_in_tab, |
1280.2.2
by Julián Unrrein
Continue with porting. |
148 |
N_("Open uri(s) in new tab"), null }; |
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
149 |
options [2] = { "new-window", 'n', 0, OptionArg.NONE, out create_new_window, |
150 |
N_("New Window"), null }; |
|
151 |
options [3] = { "quit", 'q', 0, OptionArg.NONE, ref kill_shell, |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
152 |
N_("Quit Files."), null }; |
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
153 |
options [4] = { "debug", 'd', 0, OptionArg.NONE, ref debug, |
1280.2.18
by Julián Unrrein
Use config.h instead of Config.vala. Fix debug mode again. |
154 |
N_("Enable debug logging"), null }; |
1280.2.11
by Julián Unrrein
Small changes. |
155 |
/* "" = G_OPTION_REMAINING: Catches the remaining arguments */
|
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
156 |
options [5] = { "", 0, 0, OptionArg.STRING_ARRAY, ref remaining, |
1280.2.2
by Julián Unrrein
Continue with porting. |
157 |
null, N_("[URI...]") }; |
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
158 |
options [6] = { null }; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
159 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
160 |
var context = new OptionContext (_("\n\nBrowse the file system with the file manager")); |
161 |
context.add_main_entries (options, null); |
|
162 |
context.add_group (Gtk.get_option_group (true)); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
163 |
|
1280.2.6
by Julián Unrrein
More changes. |
164 |
string[] args = cmd.get_arguments (); |
1280.2.13
by Julián Unrrein
Make debug mode work. |
165 |
/* We need to store arguments in an unowned variable for context.parse */
|
1280.2.9
by Julián Unrrein
Small changes. |
166 |
unowned string[] args_aux = args; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
167 |
|
1280.2.13
by Julián Unrrein
Make debug mode work. |
168 |
/* Parse arguments */
|
1280.2.2
by Julián Unrrein
Continue with porting. |
169 |
try { |
1280.2.9
by Julián Unrrein
Small changes. |
170 |
context.parse (ref args_aux); |
1280.2.2
by Julián Unrrein
Continue with porting. |
171 |
} catch (OptionError error) { |
1280.2.13
by Julián Unrrein
Make debug mode work. |
172 |
cmd.printerr ("Could not parse arguments: %s\n", error.message); |
1280.2.2
by Julián Unrrein
Continue with porting. |
173 |
return Posix.EXIT_FAILURE; |
174 |
}
|
|
1280.2.16
by Julián Unrrein
Fix debug mode. |
175 |
|
1280.2.13
by Julián Unrrein
Make debug mode work. |
176 |
/* Handle arguments */
|
1280.2.18
by Julián Unrrein
Use config.h instead of Config.vala. Fix debug mode again. |
177 |
if (debug) |
178 |
Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
|
1280.2.25
by Julián Unrrein
Added authors to copyright notive in Application.vala. |
179 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
180 |
if (version) { |
1280.2.17
by Julián Unrrein
Tidy up code. |
181 |
cmd.print ("pantheon-files %s\n", Config.VERSION); |
1280.2.2
by Julián Unrrein
Continue with porting. |
182 |
return Posix.EXIT_SUCCESS; |
183 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
184 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
185 |
if (kill_shell) { |
186 |
if (remaining != null) { |
|
1280.2.12
by Julián Unrrein
Small change. |
187 |
cmd.printerr ("%s\n", _("--quit cannot be used with URIs.")); |
1280.2.2
by Julián Unrrein
Continue with porting. |
188 |
return Posix.EXIT_FAILURE; |
189 |
} else { |
|
190 |
this.quit (); |
|
191 |
return Posix.EXIT_SUCCESS; |
|
192 |
}
|
|
193 |
}
|
|
194 |
||
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
195 |
File[] files = null; |
1280.2.16
by Julián Unrrein
Fix debug mode. |
196 |
|
1280.2.13
by Julián Unrrein
Make debug mode work. |
197 |
/* Convert remaining arguments to GFiles */
|
1280.2.21
by Julián Unrrein
Tidy up code. |
198 |
foreach (string filepath in remaining) { |
199 |
var file = File.new_for_commandline_arg (filepath); |
|
1280.2.25
by Julián Unrrein
Added authors to copyright notive in Application.vala. |
200 |
|
1280.2.21
by Julián Unrrein
Tidy up code. |
201 |
if (file != null) |
202 |
files += (file); |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
203 |
}
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
204 |
|
1280.2.9
by Julián Unrrein
Small changes. |
205 |
/* Open application */
|
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
206 |
if (create_new_window) |
1459.1.43
by jeremy at elementaryos
Menus - stage 1 |
207 |
create_window (); |
1503.1.2
by jeremy at elementaryos
Implement creaion of new default window from command line or from the dock |
208 |
else if (open_in_tab) |
1280.2.17
by Julián Unrrein
Tidy up code. |
209 |
open_tabs (files); |
210 |
else
|
|
211 |
open_windows (files); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
212 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
213 |
return Posix.EXIT_SUCCESS; |
214 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
215 |
|
1280.2.5
by Julián Unrrein
Mostly finished. |
216 |
public override void quit_mainloop () { |
1504.1.2
by jeremy at elementaryos
Set initial geometry of new windows, other than the first, based on and offset from the active window |
217 |
debug ("Quitting mainloop"); |
1280.2.5
by Julián Unrrein
Mostly finished. |
218 |
Marlin.IconInfo.clear_caches (); |
1280.2.16
by Julián Unrrein
Fix debug mode. |
219 |
|
1280.2.9
by Julián Unrrein
Small changes. |
220 |
base.quit_mainloop (); |
1280.2.5
by Julián Unrrein
Mostly finished. |
221 |
}
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
222 |
|
223 |
public new void quit () { |
|
1459.1.45
by jeremy at elementaryos
Window menus complete |
224 |
/* Protect against holding Ctrl-Q down */
|
225 |
if (quitting) |
|
226 |
return; |
|
227 |
||
228 |
quitting = true; |
|
229 |
unowned List<Gtk.Window> window_list = this.get_windows (); |
|
230 |
window_list.@foreach ((window) => { |
|
231 |
((Marlin.View.Window)window).quit (); |
|
232 |
});
|
|
233 |
||
234 |
base.quit (); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
235 |
}
|
236 |
||
1679.5.1
by jeremy at elementaryos
Remove all tabs showing deleted folders |
237 |
public void folder_deleted (GLib.File file) { |
238 |
unowned List<Gtk.Window> window_list = this.get_windows (); |
|
239 |
window_list.@foreach ((window) => { |
|
240 |
((Marlin.View.Window)window).folder_deleted (file); |
|
241 |
});
|
|
242 |
}
|
|
243 |
||
1402.2.12
by Jeremy Wootten
Remove inessential and debugging changes to other files |
244 |
private void mount_removed_callback (VolumeMonitor monitor, Mount mount) { |
1459.1.55
by jeremy at elementaryos
commit prior to merging trunk |
245 |
/* Notify each window */
|
246 |
foreach (var window in this.get_windows ()) { |
|
247 |
((Marlin.View.Window)window).mount_removed (mount); |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
248 |
}
|
249 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
250 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
251 |
private void init_schemas () { |
252 |
/* GSettings parameters */
|
|
253 |
Preferences.settings = new Settings ("org.pantheon.files.preferences"); |
|
254 |
Preferences.marlin_icon_view_settings = new Settings ("org.pantheon.files.icon-view"); |
|
255 |
Preferences.marlin_list_view_settings = new Settings ("org.pantheon.files.list-view"); |
|
256 |
Preferences.marlin_column_view_settings = new Settings ("org.pantheon.files.column-view"); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
257 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
258 |
/* Bind settings with GOFPreferences */
|
259 |
Preferences.settings.bind ("show-hiddenfiles", |
|
1459.1.45
by jeremy at elementaryos
Window menus complete |
260 |
GOF.Preferences.get_default (), "show-hidden-files", GLib.SettingsBindFlags.DEFAULT); |
1280.2.2
by Julián Unrrein
Continue with porting. |
261 |
Preferences.settings.bind ("confirm-trash", |
1459.1.45
by jeremy at elementaryos
Window menus complete |
262 |
GOF.Preferences.get_default (), "confirm-trash", GLib.SettingsBindFlags.DEFAULT); |
1280.2.2
by Julián Unrrein
Continue with porting. |
263 |
Preferences.settings.bind ("date-format", |
1459.1.45
by jeremy at elementaryos
Window menus complete |
264 |
GOF.Preferences.get_default (), "date-format", GLib.SettingsBindFlags.DEFAULT); |
1280.2.2
by Julián Unrrein
Continue with porting. |
265 |
Preferences.settings.bind ("interpret-desktop-files", |
1459.1.45
by jeremy at elementaryos
Window menus complete |
266 |
GOF.Preferences.get_default (), "interpret-desktop-files", GLib.SettingsBindFlags.DEFAULT); |
1922.1.5
by Jeremy Wootten
Make force-icon-size setting |
267 |
Preferences.settings.bind ("force-icon-size", |
268 |
GOF.Preferences.get_default (), "force-icon-size", GLib.SettingsBindFlags.DEFAULT); |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
269 |
}
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
270 |
|
1280.2.17
by Julián Unrrein
Tidy up code. |
271 |
private void open_windows (File[]? files) { |
1488.1.1
by Jeremy Wootten
First draft - only works with icon-view, does not restore active tab |
272 |
if (files == null) |
273 |
open_tabs (files); |
|
274 |
else { |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
275 |
/* Open windows at each requested location. */
|
276 |
foreach (var file in files) |
|
1280.2.17
by Julián Unrrein
Tidy up code. |
277 |
open_window (file); |
1280.2.2
by Julián Unrrein
Continue with porting. |
278 |
}
|
279 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
280 |
|
1459.1.45
by jeremy at elementaryos
Window menus complete |
281 |
public void create_window (File location = File.new_for_path (Environment.get_home_dir ()), |
282 |
Gdk.Screen screen = Gdk.Screen.get_default (), |
|
283 |
Marlin.ViewMode viewmode = Marlin.ViewMode.PREFERRED) { |
|
284 |
||
285 |
open_window (location, screen, viewmode); |
|
286 |
}
|
|
287 |
||
288 |
private void open_window (File? location, Gdk.Screen screen = Gdk.Screen.get_default (), Marlin.ViewMode viewmode = Marlin.ViewMode.PREFERRED) { |
|
289 |
(add_view_window (screen)).add_tab (location, viewmode); |
|
290 |
}
|
|
291 |
||
292 |
private Marlin.View.Window add_view_window (Gdk.Screen screen) { |
|
293 |
var window = new Marlin.View.Window (this, screen); |
|
294 |
this.add_window (window as Gtk.Window); |
|
1459.1.67
by jeremy at elementaryos
Implement add-remove helper in icon view, fix adding multiple new tabs |
295 |
plugins.interface_loaded (window as Gtk.Widget); |
1459.1.45
by jeremy at elementaryos
Window menus complete |
296 |
return window; |
297 |
}
|
|
298 |
||
1280.2.17
by Julián Unrrein
Tidy up code. |
299 |
private void open_tabs (File[]? files, Gdk.Screen screen = Gdk.Screen.get_default ()) { |
1280.2.9
by Julián Unrrein
Small changes. |
300 |
Marlin.View.Window window = null; |
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
301 |
|
1503.1.1
by jeremy at elementaryos
Restore tabs only once and only for the first window |
302 |
/* Get the first window, if any, else create a new window */
|
303 |
if (windows_exist ()) |
|
304 |
window = (this.get_windows ()).data as Marlin.View.Window; |
|
1504.1.2
by jeremy at elementaryos
Set initial geometry of new windows, other than the first, based on and offset from the active window |
305 |
else
|
306 |
window = add_view_window (screen); |
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
307 |
|
1280.2.2
by Julián Unrrein
Continue with porting. |
308 |
if (files == null) { |
1488.1.8
by Jeremy Wootten
Fix code style, restore default start in user home directory |
309 |
/* Restore session if settings allow */
|
1488.1.3
by Jeremy Wootten
Add restore-tabs preference |
310 |
if (!Preferences.settings.get_boolean ("restore-tabs") || window.restore_tabs () < 1) { |
1488.1.1
by Jeremy Wootten
First draft - only works with icon-view, does not restore active tab |
311 |
/* Open a tab pointing at the default location if no tabs restored*/
|
312 |
var location = File.new_for_path (Environment.get_home_dir ()); |
|
1459.1.37
by jeremy at elementaryos
Fix several bugs including handling of merge and unmerge action groups |
313 |
window.add_tab (location, Marlin.ViewMode.PREFERRED); |
1488.1.1
by Jeremy Wootten
First draft - only works with icon-view, does not restore active tab |
314 |
}
|
1280.2.2
by Julián Unrrein
Continue with porting. |
315 |
} else { |
1280.2.6
by Julián Unrrein
More changes. |
316 |
/* Open tabs at each requested location */
|
1280.2.2
by Julián Unrrein
Continue with porting. |
317 |
foreach (var file in files) |
1459.1.37
by jeremy at elementaryos
Fix several bugs including handling of merge and unmerge action groups |
318 |
window.add_tab (file, Marlin.ViewMode.PREFERRED); |
1280.2.2
by Julián Unrrein
Continue with porting. |
319 |
}
|
320 |
}
|
|
1280.2.7
by Julián Unrrein
Correctly handle command line parameters. |
321 |
|
1503.1.1
by jeremy at elementaryos
Restore tabs only once and only for the first window |
322 |
private bool windows_exist () { |
1504.1.2
by jeremy at elementaryos
Set initial geometry of new windows, other than the first, based on and offset from the active window |
323 |
unowned List<weak Gtk.Window> windows = this.get_windows (); |
1503.1.1
by jeremy at elementaryos
Restore tabs only once and only for the first window |
324 |
return (windows != null && windows.data != null); |
1280.2.9
by Julián Unrrein
Small changes. |
325 |
}
|
1280.2.1
by Julián Unrrein
Replace marlin-application header and source files with a Vala file. Ensure everything compiles. |
326 |
}
|