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 522245 - Need documentation for GtkMountOperation
Need documentation for GtkMountOperation
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Christian Kellner
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-03-13 15:28 UTC by Christian Kellner
Modified: 2008-05-26 05:29 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Implemention GtkMountOperation (32.54 KB, patch)
2008-03-13 15:35 UTC, Christian Kellner
none Details | Review
Implement gtk_mount_operation_set_screen (5.33 KB, patch)
2008-03-14 22:42 UTC, Christian Kellner
none Details | Review
New version of the bug (29.25 KB, patch)
2008-03-15 11:14 UTC, Christian Kellner
none Details | Review
New version of the patch (35.53 KB, patch)
2008-03-15 11:18 UTC, Christian Kellner
none Details | Review
Next attempt ;-) (33.20 KB, patch)
2008-03-16 20:50 UTC, Christian Kellner
none Details | Review
And another round ... (36.47 KB, patch)
2008-03-17 16:20 UTC, Christian Kellner
committed Details | Review

Description Christian Kellner 2008-03-13 15:28:44 UTC
GtkMountOperation is a subclass of GMountOperation which can be passed into g_file_mount_enclosing_volume () and will then present a password dialog or a question dialog. Its meant to be used by at least nautilus and the file selector.
I'll attach a patch for an initial attempt on it in a second.
Comment 1 Christian Kellner 2008-03-13 15:35:00 UTC
Created attachment 107227 [details] [review]
Implemention GtkMountOperation

This implementation does not use a seperate GtkPasswordDialog thingy that libgnomeui has, but just builds up a custom dialog in the way it needs it to be. If we are going to add own GtkPasswordDialog later replace the current code with the GtkPasswordDialog.
Comment 2 David Zeuthen (not reading bugmail) 2008-03-14 00:23:26 UTC
Reading the patch it looks like this runs in-process? There's a couple of reasons related to password hygiene for not doing this. Specifically it's not a good idea to leak the passwords into the address space of any random process that happens to use gtk+ especially as you don't always have the source to the application.

Anyway, I summarized the concerns here

 http://mail.gnome.org/archives/gtk-devel-list/2007-December/msg00149.html

in a handwavey way. Alex's reply

 http://mail.gnome.org/archives/gtk-devel-list/2007-December/msg00169.html

has much more concrete ideas on how to achieve this. Thoughts?
Comment 3 Christian Kellner 2008-03-14 02:16:05 UTC
I must say I really like the idea of having a trusted channel but I don't think it is that big of a problem right now since: 1) we don't don't have that now with the eel based password dialog nor 2) did we have such a secure path with gnome-vfs. Also we lack that whole GSecureMountOperation stuff right now. And with GSecureMountOperation being an interface we wouldn't break API/ABI if we later added that secure path functionality to GtkMountOperation (for Unix based systems). So we could have the not-so-secure version now, especially since we need that for the file-chooser gio-port, and also having it as a fallback when we dont have a GSecureMountOperation, and add the more secure version later. Opinions?
Comment 4 David Zeuthen (not reading bugmail) 2008-03-14 03:24:50 UTC
Personally I think it's probably fine to punt on the secure stuff as long as we can implement it later. I just wanted to raise the issue.
Comment 5 Alexander Larsson 2008-03-14 10:50:05 UTC
Punt the secure version for now. But this API should let us transparently add it.

Maybe we want a gtk_mount_operation_set_screen() ?
In case parent is NULL but you still want to specify where to pop up things?
Comment 6 Christian Kellner 2008-03-14 22:42:06 UTC
Created attachment 107322 [details] [review]
Implement gtk_mount_operation_set_screen

Incremental patch to add gtk_mount_operation_[set|get]_screen. I think it also fixes minor stuff.
Comment 7 Matthias Clasen 2008-03-15 06:00:44 UTC
Looking over the first patch:

Some erroneous whitespace, like duplicate empty lines

+
+

which we generally avoid inside functions.


+  if (entry_widget == NULL)
+    return TRUE;
+
+  if (! GTK_IS_ENTRY (entry_widget))
+    return FALSE;

GTK_IS_ENTRY already checks for NULL, so the first check is redundant.


+  is_valid &= entry_has_valid_input (priv->username_entry);
+
+  if (is_valid)
+    is_valid &= entry_has_valid_input (priv->domain_entry);
+
+  if (is_valid)
+    is_valid &= entry_has_valid_input (priv->password_entry);

I'd probably write this as a single assignment, but not a big deal.


+  if (priv->anonymous == TRUE)

I hate comparisons involving booleans. This should just be

   if (priv->anonymous)


+  if ((can_anonymous = (flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED)))

Please no assignments hidden in ifs


+  primary = strstr (message, "\n");

Hmm, slightly icky. Is this required by the GMountOperation api ?


+      primary = g_strndup (message, strlen (message) - strlen (primary));

primary - message  would give you the length of the first line without so
much strlen'ing, no ?


Looking at the incremental patch next:

Since you add a setter and getter, and handle overwriting an existing value,
it doesn't make much sense to restrict the screen property to be construct-only, I think.

And once you made the screen a regular property, it becomes obvious that maybe
parent doesn't need to be a construct-only either.


Next step: building and trying it, tomorrow...


Comment 8 Christian Kellner 2008-03-15 11:14:16 UTC
Created attachment 107333 [details] [review]
New version of the bug

I hopefully addressed the most issues you raised with this new incarnation of the patch.
The "slightly icky" "primary = strstr (message, "\n");" statement is there to make the first line being bold and thus the "caption" of the dialog since you can only pass one string as message to GMountOperation::ask_question ().

Thanks for reviewing! ;-)
Comment 9 Christian Kellner 2008-03-15 11:18:14 UTC
Created attachment 107334 [details] [review]
New version of the patch

Ewk, svn diff in the wrong directory. Sorry.
Comment 10 Matthias Clasen 2008-03-15 18:58:07 UTC
Few more comments from playing around with testmountoperation:

(lt-testmountoperation:29308): Gtk-CRITICAL **: gtk_mount_operation_set_parent: assertion `GTK_IS_WINDOW (parent)' failed

Should probably be   parent == NULL || GTK_IS_WINDOW (parent)
(and similar for screen)


Shouldn't the password entry be a _password entry_ ? (ie show invisible characters instead of what I type)


Running it with --no-pw-save still shows the pw saving options ? Similar for
--no-username and --no-password.
Comment 11 Christian Kellner 2008-03-16 20:50:12 UTC
Created attachment 107398 [details] [review]
Next attempt ;-)
Comment 12 Matthias Clasen 2008-03-17 16:01:10 UTC
This one misses gtkmountoperation.h...

I managed to try it anyway, and it seems to work as expected now.
One further comments:

entry_has_valid_input doesn't really validate anything, so maybe it would be
more appropriately named entry_has_input ?
Comment 13 Christian Kellner 2008-03-17 16:20:49 UTC
Created attachment 107457 [details] [review]
And another round ...

Yeah, I agree on the has_valid_input vs has_input naming. I fixed that. This time the header should also be included (I switch to using git and messed up obviously, sorry for that)
Comment 14 Matthias Clasen 2008-03-17 16:47:30 UTC
Looks fine now, as far as I'm concerned.
It is missing docs, but we can handle that afterwards.
Comment 15 Christian Kellner 2008-03-17 17:32:22 UTC
Committed. Rename bug to reflect the need for documentation.

2008-03-17  Christian Kellner  <gicmo@gnome.org>

	Implement GtkMountOperation, a subclass of GMountOperation
	to be used with gio wherever there is the need to ask the
	user for credentials or questions while mounting a volume.
	This is bug #522245

	* gtk/gtkmountoperation.c:
	* gtk/gtkmountoperation.h:
	Implement GtkMountOperation.
	
	* gtk/gtk.h: Add gtkmountoperation.h
	* gtk/Makefile.am: Add gtkmountoperation.[hc]
	* gtk/gtk.symbols: Add symbols of GtkMountOperation.
	* tests/testmountoperation.c: Test program for it.
	* tests/Makefile.am: Add testmountoperation.
Comment 16 Sven Neumann 2008-03-18 16:58:37 UTC
Looks good, works nicely. In order to be able to play with it, I have copied this code over to the URI plug-in in GIMP until we start to depend on the next GTK+ release.

There is one thing that I am unhappy with. In GIMP we are dealing with multiple processes and the password dialog raised by the URI plug-in should be transient to the progress window that is running in the main GIMP process. We have code to do this in libgimpui but it needs access to the dialog. Would it hurt much to add gtk_mount_operation_get_dialog()? We could then connect to "is-showing", retrieve the dialog and make it transient for the foreign window.
Comment 17 David Zeuthen (not reading bugmail) 2008-03-18 17:42:27 UTC
(In reply to comment #16)
> Would it hurt much
> to add gtk_mount_operation_get_dialog()? We could then connect to "is-showing",
> retrieve the dialog and make it transient for the foreign window.

For reasons stated in comment 2 you cannot assume the dialog runs in-process (it does right now but not in the future). What would work, however, is somehow the XID of the window you want it to be transient for (it's what I do for the PolicyKit-gnome auth dialogs).

So I think this is possible but the API would have to be a bit different.
Comment 18 Alexander Larsson 2008-03-20 09:35:49 UTC
Certainly it makes more sense to set the parent window on the GtkMountOperation object, and then it will use that to automatically set the transient for on the dialogs it shows?
Comment 19 Sven Neumann 2008-03-20 10:18:16 UTC
Alexander, this doesn't work for out-of-process parent windows, at least not with the current API.
Comment 20 Alexander Larsson 2008-03-25 11:19:05 UTC
Why? Can't you get the xid of the out-of-process window?
Comment 21 Matthias Clasen 2008-05-26 05:29:34 UTC
Documentation has been added. 
If things are still unclear on the out-of-process front, please open another bug to track that.