ColorButton


Object Hierarchy:

Gtk.ColorButton Gtk.ColorButton Gtk.ColorButton Gtk.Button Gtk.Button Gtk.Button->Gtk.ColorButton Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.Button Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.ColorButton Atk.Implementor->Gtk.Button Atk.Implementor->Gtk.Bin Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.ColorButton Gtk.Buildable->Gtk.Button Gtk.Buildable->Gtk.Bin Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Actionable Gtk.Actionable Gtk.Actionable->Gtk.ColorButton Gtk.Actionable->Gtk.Button Gtk.Activatable Gtk.Activatable Gtk.Activatable->Gtk.ColorButton Gtk.Activatable->Gtk.Button Gtk.ColorChooser Gtk.ColorChooser Gtk.ColorChooser->Gtk.ColorButton

Description:

[ CCode ( type_id = "gtk_color_button_get_type ()" ) ]
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.Bin
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor
All known members inherited from interface Gtk.ColorChooser