After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689037 - need helper for creating a GFile from a remote commandline arg
need helper for creating a GFile from a remote commandline arg
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-11-25 18:27 UTC by Allison Karlitskaya (desrt)
Modified: 2012-11-27 15:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: New API for GFile from remote commandline arg (6.85 KB, patch)
2012-11-25 19:28 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
gio: New API for GFile from remote commandline arg (7.67 KB, patch)
2012-11-27 15:10 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2012-11-25 18:27:16 UTC
something like g_application_command_line_create_file_for_arg() that calls a variant of g_file_new_for_commandline_arg() that takes the cwd from the GApplicationCommandLine instead of the process cwd.

blocking the gedit port.
Comment 1 Allison Karlitskaya (desrt) 2012-11-25 19:28:22 UTC
Created attachment 229832 [details] [review]
gio: New API for GFile from remote commandline arg

Add a pair of new APIs: one to GFile to create a new file from a
commandline arg relative to a given cwd and one to
GApplicationCommandLine to create a GFile from an arg, relative to the
cwd of the invoking commandline.
Comment 2 Paolo Borelli 2012-11-26 00:47:55 UTC
Review of attachment 229832 [details] [review]:

"create file" sounds a bit strange in the name... Apart from that, these API would work for me (I can also just settle for the gfile one and just get the cwd from the command line object)
Comment 3 Matthias Clasen 2012-11-26 01:40:44 UTC
Review of attachment 229832 [details] [review]:

::: gio/gapplicationcommandline.c
@@ +642,3 @@
+                                                const gchar             *arg)
+{
+  return g_file_new_for_commandline_arg_and_cwd (arg, cmdline->priv->cwd);

Dunno why, but one-line functions that just call other public API don't really turn me on.

::: gio/gfile.c
@@ +6219,3 @@
+ * g_file_new_for_commandline_arg_and_cwd:
+ * @arg: a command line string
+ * @cwd: (allow none): the current working directory of the commandline

Why allow none here ? It would seem more natural to me to pass the current cwd in in g_file_new_for_commandline_arg, instead of passing NULL and having this extra special case in this function.
Comment 4 Allison Karlitskaya (desrt) 2012-11-26 16:34:13 UTC
The NULL thing is an optimisation: if we want to pass the cwd in explicitly then we need to query is ahead of time and that would be wasteful in the case that the filename is absolute or a URI.

I like the idea of having the API on GApplicationCommandLine on the principle of making it easy to do the right thing (and making the right thing visible).  If anything I'd consider making the _and_cwd variant in GFile private... would also address your complaint about the oddity with the NULL thing.
Comment 5 Christian Persch 2012-11-26 16:55:41 UTC
Creating a GFile from a cmdline arg and chosen cwd is an operation not limited to cases using gapplication+gapplicationcommandline, so IMHO it would be good to keep the _and_cwd variant public.
Comment 6 Allison Karlitskaya (desrt) 2012-11-27 15:10:26 UTC
Created attachment 230008 [details] [review]
gio: New API for GFile from remote commandline arg

Add a pair of new APIs: one to GFile to create a new file from a
commandline arg relative to a given cwd and one to
GApplicationCommandLine to create a GFile from an arg, relative to the
cwd of the invoking commandline.
Comment 7 Allison Karlitskaya (desrt) 2012-11-27 15:10:54 UTC
Attachment 230008 [details] pushed as 3baf256 - gio: New API for GFile from remote commandline arg