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 626457 - Add a lock button widget
Add a lock button widget
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal enhancement
: 3.2
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 640732 640733
 
 
Reported: 2010-08-09 17:00 UTC by Matthias Clasen
Modified: 2011-05-07 02:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
implementation (20.60 KB, patch)
2010-08-09 17:00 UTC, Matthias Clasen
none Details | Review
add a non-homogeneous child property in gtkbuttonbox (9.97 KB, patch)
2011-05-01 01:08 UTC, Matthias Clasen
committed Details | Review
add GtkLockButton (51.67 KB, patch)
2011-05-01 01:09 UTC, Matthias Clasen
none Details | Review

Description Matthias Clasen 2010-08-09 17:00:08 UTC
Created attachment 167437 [details] [review]
implementation

Similar to the widget provided by the polkit-gtk library in PolicyKit-gnome.
A lock button is commonly used on dialogs which make 'privileged' changes. The lockbutton 'unlocks' the rest of the ui (and also allows to lock it again).

GIO now provides an abstract GPermission interface that allows us to implement such a widget in GTK+ without linking directly against PolicyKit. PolicyKit contains an implementation (PolkitPermission) of GPermission, that can be used with the lock button.
Comment 1 David Zeuthen (not reading bugmail) 2010-08-10 15:47:54 UTC
Hey Matthias,

I like this widget, it looks good and I think having such a widget in GTK+ makes a lot of sense. FWIW, I just tested it with

 http://hal.freedesktop.org/docs/polkit/PolkitPermission.html

and it works great.

See

 http://people.freedesktop.org/~david/testlockbutton.c
 http://people.freedesktop.org/~david/GtkLockButton-1.png
 http://people.freedesktop.org/~david/GtkLockButton-2.png

Notes

 - Do we want getters/setters for the properties?
   - text-lock
   - text-unlock
   - text-not-authorized
   - tooltip-lock
   - tooltip-unlock
   - tooltip-not-authorized

   My guess is that we probably don't want that.

 - We hide the widget when the GPermission has the state
   (allowed && !can_release) which I think makes a lot of
   sense. We need to point that out in the docs though.

   (Maybe we want to control that behavior later on by
    adding a flags property.)

   In fact, it looks like you are missing an entire
   introductory SECTION:GtkLockButton entry.

 - The widget is implemented as a hbox containing a GtkButton
   and a GtkLabel where the button only has an image. One
   side-effect with that setup, is that the clickable area is
   confined to the button - maybe we want to make GtkLockButton
   a GtkButton subclass instead?

 - There's some concerns here

 http://lists.freedesktop.org/archives/polkit-devel/2009-September/000226.html
 http://lists.freedesktop.org/archives/polkit-devel/2009-October/000231.html

   about sizing. Any thoughts on what to do with that?

Thanks,
David
Comment 2 Matthias Clasen 2010-08-10 18:48:12 UTC
>   My guess is that we probably don't want that.

Right, I wanted to leave those out for now, to not drown the api in rarely used getters and setters.

> In fact, it looks like you are missing an entire
> introductory SECTION:GtkLockButton entry.

Right, I've added some docs now (heavily borrowing from your PolkitLockButton docs).

> The widget is implemented as a hbox containing a GtkButton and a GtkLabel...

Not sure, we could also make it so that the extra label can be hidden, for space-constrained situations. I'll just go with the current approach for now. 

> sizing

I don't think we need to make the widget fixed-size. In most situations, the lock button should be right-aligned in the action area, by itself (right ?), so the size change should not by itself mess up the layout of the action area, except for the second point. But that is really a bug in GtkButtonBox that it needs to be smarter about enforcing homogeneity without making a mess. I'll have a look at that, perhaps.
Comment 3 Allison Karlitskaya (desrt) 2010-09-07 21:36:05 UTC
my biggest concern is the lack of guidelines for use of this button

where does it go in a dialog with buttons for example?

  - above action area?

  - left side of action area?
    - what if there is also a help button?

  - some "windicator" crack?
Comment 4 Matthias Clasen 2011-05-01 01:08:33 UTC
Created attachment 186955 [details] [review]
add a non-homogeneous child property in gtkbuttonbox
Comment 5 Matthias Clasen 2011-05-01 01:09:08 UTC
Created attachment 186956 [details] [review]
add GtkLockButton
Comment 6 Matthias Clasen 2011-05-01 01:09:38 UTC
These patches update the implementation to whats currently used in the control-center, and add some more documentation.