ColorButton
Object Hierarchy:
Description:
[ CCode ( type_id = "gtk_color_button_get_type ()" ) ]
public class ColorButton : Button, Implementor, Actionable, Activatable, Buildable, ColorChooser
public class ColorButton : Button, Implementor, Actionable, Activatable, Buildable, ColorChooser
The ColorButton is a button which displays the currently selected color and allows to open a color selection dialog to change the color.
It is suitable widget for selecting a color in a preference dialog.
CSS nodes
GtkColorButton has a single CSS node with name button. To differentiate it from a plain Button, it gets the .color style class.
Example: ColorButton:
public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.ColorButton";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
// The button:
Gtk.ColorButton button = new Gtk.ColorButton ();
// Use alpha channel
button.set_use_alpha (true);
// Set value to blue:
Gdk.RGBA rgba = Gdk.RGBA ();
bool tmp = rgba.parse ("#0066FF");
assert (tmp == true);
button.rgba = rgba;
// Sets the title for the color selection dialog:
button.set_title ("Select your favourite color");
// Catch color-changes:
button.color_set.connect (() => {
uint16 alpha = button.get_alpha ();
print ("%s, %hu\n", button.rgba.to_string (), alpha);
});
this.add (button);
}
public static int main (string[] args) {
Gtk.init (ref args);
Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}
valac --pkg gtk+-3.0 Gtk.ColorButton.vala
Namespace: Gtk
Package: gtk+-3.0
Content:
Properties:
Creation methods:
Methods:
Signals:
Inherited Members:
All known members inherited from class Gtk.Button
All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Container
All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.Actionable
All known members inherited from interface Gtk.Activatable
All known members inherited from interface Gtk.Buildable
All known members inherited from interface Gtk.ColorChooser