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 765900 - Add g_drive_is_removable() support
Add g_drive_is_removable() support
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 765457 765924
 
 
Reported: 2016-05-02 11:08 UTC by Ondrej Holy
Modified: 2016-05-20 11:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: Add g_drive_is_removable() support (3.62 KB, patch)
2016-05-02 11:08 UTC, Ondrej Holy
none Details | Review
gio: Add g_drive_is_removable() support (3.73 KB, patch)
2016-05-12 14:36 UTC, Ondrej Holy
committed Details | Review
Fix ABI compatibility (1.32 KB, patch)
2016-05-20 10:43 UTC, Ondrej Holy
committed Details | Review

Description Ondrej Holy 2016-05-02 11:08:10 UTC
Created attachment 327142 [details] [review]
gio: Add g_drive_is_removable() support

Nautilus wants to show entries in the sidebar only for removable devices. It uses currently sort of conditions to determine which devices should be shown. Those condition fails in some cases unfortunatelly. Lets provide g_drive_is_removable() which uses udisks Removable property to determine which devices should be shown. It should return true for all drives with removable media, or flash media, or drives on usb and firewire buses.
Comment 1 Emmanuele Bassi (:ebassi) 2016-05-12 08:55:54 UTC
Review of attachment 327142 [details] [review]:

::: gio/gdrive.c
@@ +287,3 @@
+  iface = G_DRIVE_GET_IFACE (drive);
+
+ **/

You cannot really do this unconditionally: what happens if a newer GLib is used with an older version of GVfs?

This should be:

  iface = G_DRIVE_GET_IFACE (drive);
  if (iface->is_removable != NULL)
    return iface->is_removable (drive);

  return FALSE;

Also, don't use the `(* vtable->vfunc)` style: it's just noise.

::: gio/gdrive.h
@@ +174,3 @@
 GList *  g_drive_get_volumes              (GDrive               *drive);
+GLIB_AVAILABLE_IN_2_50
+gboolean g_drive_is_removable       (GDrive               *drive);

Coding style: tab vs spaces.
Comment 2 Ondrej Holy 2016-05-12 14:36:16 UTC
Created attachment 327717 [details] [review]
gio: Add g_drive_is_removable() support

Thanks for the review!
Comment 3 Emmanuele Bassi (:ebassi) 2016-05-12 14:47:56 UTC
Review of attachment 327717 [details] [review]:

Looks good to me, and it's simple enough, but I'm not the GIO maintainer so I'll just put 'reviewed' in the status, and a +1 from me for pushing it to master.
Comment 4 Allison Karlitskaya (desrt) 2016-05-16 12:28:34 UTC
Review of attachment 327717 [details] [review]:

Please go ahead.  Thanks for the look, Emmanuele.

::: gio/gdrive.c
@@ +286,3 @@
+
+  iface = G_DRIVE_GET_IFACE (drive);
+  if (iface->is_removable != NULL)

Yuck.

Normally I'd complain about how this should be done with a default "real_" vfunc instead but, well, the entire file is this way, so, +1 for consistency. :)
Comment 5 Ondrej Holy 2016-05-19 12:57:24 UTC
Thanks for review, I want to push also the GTK/GVfs patches which depends on it, I added requirement for GLib 2.49.1, but it seems GLib is using prerelease bump, so it is 2.49.0 currently. Should I wait with GTK/GVFS patches for the release, or it is possible to bump the GLib version earlier, or what is recommended workflow in such case?
Comment 6 Matthias Clasen 2016-05-19 13:51:56 UTC
sure, we can bump the release in git, if it helps
Comment 7 Ondrej Holy 2016-05-20 08:51:08 UTC
Comment on attachment 327717 [details] [review]
gio: Add g_drive_is_removable() support

commit 7b3f6da
Comment 8 Ondrej Holy 2016-05-20 08:51:33 UTC
(In reply to Matthias Clasen from comment #6)
> sure, we can bump the release in git, if it helps

Thanks, so I bumped the version by the commit 931483a.
Comment 9 Ondrej Holy 2016-05-20 10:40:10 UTC
#gtk+:
gregier	oholy: hey looking at commit: https://git.gnome.org/browse/glib/commit/?id=7b3f6da30718c443d64169813b4ae1b3a28ba934
the new vfunc should be added to the end otherwise the ABI is broken
Comment 10 Ondrej Holy 2016-05-20 10:43:16 UTC
Created attachment 328249 [details] [review]
Fix ABI compatibility

Is this enough to fix the ABI? Should I move also another code to corresponding places?
Comment 11 Christian Hergert 2016-05-20 11:07:24 UTC
Review of attachment 328249 [details] [review]:

Yes this is good.

For interfaces, you can add new functions all you want (without requiring padding), but they must be at the end of the interface otherwise previously compiled code against that interface will have the wrong pointer offset.
Comment 12 Ondrej Holy 2016-05-20 11:11:42 UTC
Comment on attachment 328249 [details] [review]
Fix ABI compatibility

Thanks, pushed as commit 17e5281.