Skip to content

Commit 3731110

Browse files
committed
Application: Remove unnecessary command_line override
1 parent f24e6d5 commit 3731110

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/Application.vala

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ namespace Cherrypick {
2323
public class Application : Gtk.Application {
2424
private Window? window;
2525
private Xdp.Portal portal;
26+
private static bool is_immediately_pick = false;
2627

2728
private OptionEntry[] CMD_OPTION_ENTRIES = {
28-
{"immediately-pick", 'p', OptionFlags.NONE, OptionArg.NONE, null, _("Immediately pick a colour and copy it to clipboard"), null}
29+
{"immediately-pick", 'p', OptionFlags.NONE, OptionArg.NONE, ref is_immediately_pick, _("Immediately pick a colour and copy it to clipboard"), null}
2930
};
3031

3132
public Application () {
3233
Object (
3334
application_id: "io.github.ellie_commons.cherrypick",
34-
flags: ApplicationFlags.HANDLES_COMMAND_LINE
35+
flags: ApplicationFlags.FLAGS_NONE
3536
);
3637
}
3738

@@ -75,6 +76,15 @@ namespace Cherrypick {
7576
}
7677

7778
public override void activate () {
79+
/* Opens and immediately starts picking color if the --immediately-pick
80+
flag is passed when launching from the command line. This could
81+
be helpful for the user to set up keybindings and stuff */
82+
if (Application.is_immediately_pick) {
83+
//FIXME: Prevent window from showing if we do an immediate pick
84+
//Quit or anything that makes Activate not do a window, end up in Picking failing
85+
immediately_pick ();
86+
}
87+
7888
/* Restricting to only one open instance of the application window.
7989
It doesn't make much sense to have multiple instances as there
8090
are no real valid use cases. And with the current architecture
@@ -98,23 +108,6 @@ namespace Cherrypick {
98108
}
99109
}
100110

101-
public override int command_line (ApplicationCommandLine command) {
102-
103-
/* Opens and immediately starts picking color if the --immediately-pick
104-
flag is passed when launching from the command line. This could
105-
be helpful for the user to set up keybindings and stuff */
106-
var options = command.get_options_dict ();
107-
if (options.contains ("immediately-pick")) {
108-
immediately_pick ();
109-
110-
}
111-
112-
//FIXME: Prevent window from showing if we do an immediate pick
113-
//Quit or anything that makes Activate not do a window, end up in Picking failing
114-
activate ();
115-
return 0;
116-
}
117-
118111
private void immediately_pick () {
119112
var notification = new Notification (_("Pick a color"));
120113
// TRANSLATORS: "%s%%" is replaced by a colour code

0 commit comments

Comments
 (0)