Skip to content
Closed
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
5 changes: 5 additions & 0 deletions data/io.github.wpkelso.slate.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ Type=Application
StartupNotify=true
Categories=Utility;GTK;Office;Development;TextTools;TextEditor;
MimeType=text/plain;
Actions=NewDocument;

[Desktop Action NewDocument]
Exec=io.github.wpkelso.slate --new-document
Name=New Document
25 changes: 23 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ public class Application : Gtk.Application {
public static uint created_documents = 1;
public static string data_dir_path = Environment.get_user_data_dir () + "/slate";


public Application () {
Object (
application_id: APP_ID,
flags: ApplicationFlags.DEFAULT_FLAGS | ApplicationFlags.HANDLES_OPEN
flags: ApplicationFlags.DEFAULT_FLAGS | ApplicationFlags.HANDLES_OPEN | ApplicationFlags.HANDLES_COMMAND_LINE
);
}

Expand Down Expand Up @@ -178,4 +177,26 @@ public class Application : Gtk.Application {
}
});
}

protected override int command_line (ApplicationCommandLine command_line) {
string[] args = command_line.get_arguments ();

switch (args[1]) {
case "--new-document":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on adding a check to look for unsaved new documents so we can skip over them and always create a new blank one? Currently, we just open the first unsaved document — which might already contain something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to count the number of unsaved documents in the folder, add 1, and start from there.
Else we may not give it a proper number (Ex: New Document, overwriting current New Document)

Another hurdle would be that, what if while im editing my cool new document i want to open another unsaved document ?
We would need to expose something in the UI, which is out of scope, or close all windows and open normally. Which is pretty much what a quick desktop action was supposed to save from

on_new_document ();
break;

case (null):
activate ();
break;

default:
foreach (var arg in args[1:args.length]) {
open_window_with_file (File.new_for_commandline_arg (arg));
}
break;
}
return 0;

}
}