summaryrefslogtreecommitdiff
path: root/libmate-desktop/mate-colorbutton.c
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2021-07-18 08:46:46 +0800
committerVictor Kareh <[email protected]>2021-07-19 15:30:33 -0400
commit81dacb6e8cdbc8e9a505140fb83a9653e368b5bb (patch)
tree13cd23895c89993e710493574765a4dc700faf3f /libmate-desktop/mate-colorbutton.c
parent4b92d782d84f9bf543a1661218e333b27c43b0d0 (diff)
downloadmate-desktop-81dacb6e8cdbc8e9a505140fb83a9653e368b5bb.tar.bz2
mate-desktop-81dacb6e8cdbc8e9a505140fb83a9653e368b5bb.tar.xz
Fix compilation warning
Diffstat (limited to 'libmate-desktop/mate-colorbutton.c')
-rw-r--r--libmate-desktop/mate-colorbutton.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/libmate-desktop/mate-colorbutton.c b/libmate-desktop/mate-colorbutton.c
index 249860a..9596735 100644
--- a/libmate-desktop/mate-colorbutton.c
+++ b/libmate-desktop/mate-colorbutton.c
@@ -260,7 +260,10 @@ draw (GtkWidget *widget,
{
MateColorButton *color_button = MATE_COLOR_BUTTON (data);
cairo_pattern_t *checkered;
+ GtkStyleContext *context;
+ GdkRGBA rgba;
+ mate_color_button_get_rgba (color_button, &rgba);
if (mate_color_button_has_alpha (color_button))
{
cairo_save (cr);
@@ -278,21 +281,23 @@ draw (GtkWidget *widget,
cairo_restore (cr);
cairo_set_source_rgba (cr,
- color_button->priv->color.red / 65535.,
- color_button->priv->color.green / 65535.,
- color_button->priv->color.blue / 65535.,
- color_button->priv->alpha / 65535.);
+ rgba.red,
+ rgba.green,
+ rgba.blue,
+ rgba.alpha);
}
else
{
- gdk_cairo_set_source_color (cr, &color_button->priv->color);
+ gdk_cairo_set_source_rgba (cr, &rgba);
}
cairo_paint (cr);
if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button)))
{
- gdk_cairo_set_source_color (cr, &gtk_widget_get_style (GTK_WIDGET(color_button))->bg[GTK_STATE_INSENSITIVE]);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_color (context, GTK_STATE_INSENSITIVE, &rgba);
+ gdk_cairo_set_source_rgba (cr, &rgba);
checkered = mate_color_button_get_checkered ();
cairo_mask (cr, checkered);
cairo_pattern_destroy (checkered);
@@ -402,7 +407,6 @@ mate_color_button_drag_data_get (GtkWidget *widget,
static void
mate_color_button_init (MateColorButton *color_button)
{
- GtkWidget *alignment;
GtkWidget *frame;
PangoLayout *layout;
PangoRectangle rect;
@@ -412,18 +416,17 @@ mate_color_button_init (MateColorButton *color_button)
/* Create the widgets */
color_button->priv = mate_color_button_get_instance_private (color_button);
- alignment = gtk_alignment_new (0.5, 0.5, 0.5, 1.0);
- gtk_container_set_border_width (GTK_CONTAINER (alignment), 1);
- gtk_container_add (GTK_CONTAINER (color_button), alignment);
- gtk_widget_show (alignment);
-
frame = gtk_frame_new (NULL);
+ gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
- gtk_container_add (GTK_CONTAINER (alignment), frame);
+ gtk_container_add (GTK_CONTAINER (color_button), frame);
gtk_widget_show (frame);
/* Just some widget we can hook to expose-event on */
- color_button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ color_button->priv->draw_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_set_valign (color_button->priv->draw_area, GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (color_button->priv->draw_area, GTK_ALIGN_CENTER);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
pango_layout_get_pixel_extents (layout, NULL, &rect);