mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
Merge branch 'color-dialog-button-activate' into 'main'
Make new-style dialog buttons activatable See merge request GNOME/gtk!6255
This commit is contained in:
commit
0cdd2e7008
@ -45,6 +45,7 @@ static GdkContentProvider *
|
||||
double x,
|
||||
double y,
|
||||
GtkColorDialogButton *self);
|
||||
static void activated (GtkColorDialogButton *self);
|
||||
static void button_clicked (GtkColorDialogButton *self);
|
||||
static void update_button_sensitivity
|
||||
(GtkColorDialogButton *self);
|
||||
@ -96,8 +97,17 @@ enum
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
enum
|
||||
{
|
||||
SIGNAL_ACTIVATE = 1,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
static unsigned int color_dialog_button_signals[NUM_SIGNALS] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkColorDialogButton, gtk_color_dialog_button, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
@ -108,6 +118,8 @@ gtk_color_dialog_button_init (GtkColorDialogButton *self)
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
g_signal_connect_swapped (self, "activate", G_CALLBACK (activated), self);
|
||||
|
||||
self->color = GDK_RGBA ("00000000");
|
||||
|
||||
self->button = gtk_button_new ();
|
||||
@ -278,6 +290,27 @@ gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
|
||||
/**
|
||||
* GtkColorDialogButton::activate:
|
||||
* @widget: the object which received the signal
|
||||
*
|
||||
* Emitted when the color dialog button is activated.
|
||||
*
|
||||
* The `::activate` signal on `GtkColorDialogButton` is an action signal
|
||||
* and emitting it causes the button to pop up its dialog.
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
color_dialog_button_signals[SIGNAL_ACTIVATE] =
|
||||
g_signal_new (I_ ("activate"),
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
||||
0,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gtk_widget_class_set_activate_signal (widget_class, color_dialog_button_signals[SIGNAL_ACTIVATE]);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "colorbutton");
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
|
||||
@ -366,6 +399,12 @@ color_chosen (GObject *source,
|
||||
update_button_sensitivity (self);
|
||||
}
|
||||
|
||||
static void
|
||||
activated (GtkColorDialogButton *self)
|
||||
{
|
||||
gtk_widget_activate (self->button);
|
||||
}
|
||||
|
||||
static void
|
||||
button_clicked (GtkColorDialogButton *self)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
||||
|
||||
static void activated (GtkFontDialogButton *self);
|
||||
static void button_clicked (GtkFontDialogButton *self);
|
||||
static void update_button_sensitivity
|
||||
(GtkFontDialogButton *self);
|
||||
@ -100,8 +100,17 @@ enum
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
enum
|
||||
{
|
||||
SIGNAL_ACTIVATE = 1,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
static unsigned int font_dialog_button_signals[NUM_SIGNALS] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkFontDialogButton, gtk_font_dialog_button, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
@ -110,6 +119,8 @@ gtk_font_dialog_button_init (GtkFontDialogButton *self)
|
||||
GtkWidget *box;
|
||||
PangoFontDescription *font_desc;
|
||||
|
||||
g_signal_connect_swapped (self, "activate", G_CALLBACK (activated), self);
|
||||
|
||||
self->button = gtk_button_new ();
|
||||
g_signal_connect_swapped (self->button, "clicked", G_CALLBACK (button_clicked), self);
|
||||
self->font_label = gtk_label_new (_("Font"));
|
||||
@ -383,6 +394,27 @@ gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
|
||||
/**
|
||||
* FontDialogButton::activate:
|
||||
* @widget: The object which received the signal
|
||||
*
|
||||
* Emitted when the font dialog button is activated.
|
||||
*
|
||||
* The `::activate` signal on `GtkFontDialogButton` is an action signal
|
||||
* and emitting it causes the button to pop up its dialog.
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
font_dialog_button_signals[SIGNAL_ACTIVATE] =
|
||||
g_signal_new (I_ ("activate"),
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
||||
0,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
gtk_widget_class_set_activate_signal (widget_class, font_dialog_button_signals[SIGNAL_ACTIVATE]);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "fontbutton");
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
|
||||
@ -499,6 +531,12 @@ font_and_features_chosen (GObject *source,
|
||||
update_button_sensitivity (self);
|
||||
}
|
||||
|
||||
static void
|
||||
activated (GtkFontDialogButton *self)
|
||||
{
|
||||
gtk_widget_activate (self->button);
|
||||
}
|
||||
|
||||
static void
|
||||
button_clicked (GtkFontDialogButton *self)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user