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 107597 - GnomeColorPicker style button
GnomeColorPicker style button
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.2.x
Other other
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2003-03-05 01:17 UTC by Matthias Clasen
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
gtkcolorpicker.h (3.84 KB, text/plain)
2003-03-05 01:17 UTC, Matthias Clasen
  Details
gtkcolorpicker.c (29.70 KB, text/plain)
2003-03-05 01:18 UTC, Matthias Clasen
  Details
gtkcolorpickerbutton.h (3.70 KB, text/plain)
2003-03-05 22:03 UTC, Matthias Clasen
  Details
gtkcolorpickerbutton.c (28.23 KB, text/plain)
2003-03-05 22:04 UTC, Matthias Clasen
  Details
patch (3.91 KB, patch)
2003-03-05 22:04 UTC, Matthias Clasen
none Details | Review
gtkcolorselbutton.h (4.07 KB, text/plain)
2003-03-17 20:08 UTC, Matthias Clasen
  Details
gtkcolorselbutton.c (33.00 KB, text/plain)
2003-03-17 20:08 UTC, Matthias Clasen
  Details
gtkcolorbutton.h (3.44 KB, text/plain)
2003-03-18 01:21 UTC, Matthias Clasen
  Details
gtkcolorbutton.c (27.81 KB, text/plain)
2003-03-18 01:21 UTC, Matthias Clasen
  Details
gtkcolorbutton.h (3.59 KB, text/plain)
2003-06-29 13:58 UTC, Matthias Clasen
  Details
gtkcolorbutton.c (28.57 KB, text/plain)
2003-06-29 13:58 UTC, Matthias Clasen
  Details
gtkcolorbutton.h - taken into account comments on font picker (3.78 KB, text/plain)
2003-06-30 20:05 UTC, Matthias Clasen
  Details
gtkcolorbutton.c - taken comments on font button into account (29.89 KB, text/plain)
2003-06-30 20:06 UTC, Matthias Clasen
  Details

Description Matthias Clasen 2003-03-05 01:17:04 UTC
I took Federicos color picker found in libgnomeui and adapted it to the gtk
coding style and interface conventions (e.g. use GdkColor for color
arguments, not doubles, guint8s or guint16s). One thing that might be nice
to add would be a way to make the swatch size somehow correspond to the
font size or stock icon size or at least be settable.
Comment 1 Matthias Clasen 2003-03-05 01:17:52 UTC
Created attachment 14777 [details]
gtkcolorpicker.h
Comment 2 Matthias Clasen 2003-03-05 01:18:42 UTC
Created attachment 14778 [details]
gtkcolorpicker.c
Comment 3 Havoc Pennington 2003-03-05 01:45:03 UTC
I'd like to see "Button" in the name - GtkColorButton or
GtkColorPickerButton or something like that. Maybe others have 
better ideas. As-is it's kind of hard to remember how this is 
different from GtkColorSelection.

Agree that the swatch should scale - even if the size request never
changes, it really needs to grow with the size allocation,
GnomeColorPicker right now looks a little silly if you get allocation
> request.

I don't understand the "dither" property (don't know when 
you would use it) - maybe at least needs docs that suggest 
when to use it.
Comment 4 Matthias Clasen 2003-03-05 08:03:55 UTC
CCing Federico, maybe he remembers a use case for dithering.
I'll look into 
renaming and making it scale.
Comment 5 Matthias Clasen 2003-03-05 22:02:42 UTC
Here is a simplified version. I decided to drop the dither property
and renamed it to GtkColorPickerButton. Maybe GtkColorSelectionButton
would be nicer, to go along with GtkColorSelection and
GtkColorSelectionDialog. There is also a little testgtk addition to
try it out.
Comment 6 Matthias Clasen 2003-03-05 22:03:36 UTC
Created attachment 14801 [details]
gtkcolorpickerbutton.h
Comment 7 Matthias Clasen 2003-03-05 22:04:21 UTC
Created attachment 14802 [details]
gtkcolorpickerbutton.c
Comment 8 Matthias Clasen 2003-03-05 22:04:57 UTC
Created attachment 14803 [details] [review]
patch
Comment 9 Matthias Clasen 2003-03-17 20:07:06 UTC
Here are the latest versions; I decided to rename it to
GtkColorSelectionButton.
Comment 10 Matthias Clasen 2003-03-17 20:08:07 UTC
Created attachment 15079 [details]
gtkcolorselbutton.h
Comment 11 Matthias Clasen 2003-03-17 20:08:50 UTC
Created attachment 15080 [details]
gtkcolorselbutton.c
Comment 12 Havoc Pennington 2003-03-17 23:13:55 UTC
Just noticed playing with gnome-terminal - GTK_WIN_POS_MOUSE
must die ;-) 

  gtk_window_set_position (GTK_WINDOW (priv->cs_dialog),
GTK_WIN_POS_MOUSE);

Adrian does have an interesting point; would it be better, in something 
like gnome-terminal, if clicking the button opened a little 
palette popup (like a combo), instead of the color dialog?
The popup is fewer user steps for common tasks, assuming people 
usually want one of the preset colors, but more user steps if 
people usually want a custom color. don't know.
Comment 13 Matthias Clasen 2003-03-18 01:20:11 UTC
New version, incorporating feedback from Owen and Havoc:

* shorter name: GtkColorButton
* avoid double<->guint16 conversion
* base widget size on font
* replace deprecated GTK_TYPE boilerplate with G_TYPE boilerplate
* only render in expose_event
* remove unnecessary keypress handler
* don't set GTK_WIN_POS_MOUSE
* fix indentation

Do we need gtk_color_button_set_use_palette() ?
Comment 14 Matthias Clasen 2003-03-18 01:21:06 UTC
Created attachment 15086 [details]
gtkcolorbutton.h
Comment 15 Matthias Clasen 2003-03-18 01:21:49 UTC
Created attachment 15087 [details]
gtkcolorbutton.c
Comment 16 Matthias Clasen 2003-03-18 01:25:21 UTC
Note that further cleanups would be possible by sharing the code to
draw the color swatch with GtkColorSelection, which contains similar
code for drawing the old/new color sample.
Comment 17 Havoc Pennington 2003-03-18 01:44:12 UTC
> Do we need gtk_color_button_set_use_palette() ?

If we want to go the combo route, I'd think it would just be covered
by Kris's combo widget, so we probably should not try to do that 
feature with this codebase.

I guess my gut instinct is that we should have this and the combo 
both. I'm not sure if GtkColorCombo is something that would come 
with GTK, or just something that would be easy to do with the new 
combo widget. But the use cases for the two widgets seem a bit
different, depending on whether you're likely to be picking the same 
color over and over for say different spreadsheet cells, or 
picking your favorite exact perfect color one time for your gnome-panel.
Comment 18 Matthias Clasen 2003-06-29 13:58:21 UTC
Created attachment 17892 [details]
gtkcolorbutton.h
Comment 19 Matthias Clasen 2003-06-29 13:58:53 UTC
Created attachment 17893 [details]
gtkcolorbutton.c
Comment 20 Matthias Clasen 2003-06-29 13:59:44 UTC
The new version has the following changes:
- moved to instance private data
- improved documentation
- fixed a few bugs noticed while doing the above
Comment 21 Jody Goldberg 2003-06-29 19:27:02 UTC
2 requests

1) Can you supply a screenshot
2) I'm about to rework the colour combo/palette objects in gnumeric to
support an alpha channel.  Using GdkColors as the only interface will
preclude support for that.  You may want to revisit that choice.
Comment 22 Matthias Clasen 2003-06-29 19:36:47 UTC
There is really no need for a screenshot here. This thing looks
exactly like the GnomeColorPicker currently found in libgnomeui... and
it opens a regular GtkColorSelectionDialog. I guess you've seen those
already.
This widget is really different from a color combo like you want. A
color combo like widget will probably arrive in gtk2.4 via the
combobox work of Kristian...

Regarding alpha support: There is gdk_color_button_[gs]et_alpha(), so
alpha is fully supported. Admittedly, you have to get the RGB and A in
two separate function calls.
Comment 23 Matthias Clasen 2003-06-30 20:05:45 UTC
Created attachment 17934 [details]
gtkcolorbutton.h - taken into account comments on font picker
Comment 24 Matthias Clasen 2003-06-30 20:06:39 UTC
Created attachment 17935 [details]
gtkcolorbutton.c - taken comments on font button into account
Comment 25 Matthias Clasen 2003-07-01 20:04:55 UTC
Committed.