summaryrefslogtreecommitdiff
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
parent4b92d782d84f9bf543a1661218e333b27c43b0d0 (diff)
downloadmate-desktop-81dacb6e8cdbc8e9a505140fb83a9653e368b5bb.tar.bz2
mate-desktop-81dacb6e8cdbc8e9a505140fb83a9653e368b5bb.tar.xz
Fix compilation warning
-rw-r--r--libmate-desktop/mate-colorbutton.c31
-rw-r--r--libmate-desktop/mate-colorseldialog.c41
-rw-r--r--libmate-desktop/mate-rr.c9
-rw-r--r--tools/mate-color-select.c6
4 files changed, 60 insertions, 27 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);
diff --git a/libmate-desktop/mate-colorseldialog.c b/libmate-desktop/mate-colorseldialog.c
index 2516be1..c947921 100644
--- a/libmate-desktop/mate-colorseldialog.c
+++ b/libmate-desktop/mate-colorseldialog.c
@@ -123,6 +123,23 @@ mate_color_selection_dialog_class_init (MateColorSelectionDialogClass *klass)
G_PARAM_READABLE));
}
+static GtkWidget*
+mate_add_dialog_button (GtkDialog *dialog,
+ const char *label,
+ const char *icon,
+ GtkResponseType response)
+{
+ GtkWidget *widget;
+ GtkWidget *image;
+
+ widget = gtk_button_new_with_mnemonic (label);
+ image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (GTK_BUTTON (widget), image);
+ gtk_dialog_add_action_widget (dialog, widget, response);
+
+ return widget;
+}
+
static void
mate_color_selection_dialog_init (MateColorSelectionDialog *colorseldiag)
{
@@ -142,21 +159,27 @@ mate_color_selection_dialog_init (MateColorSelectionDialog *colorseldiag)
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (colorseldiag))), colorseldiag->colorsel);
gtk_widget_show (colorseldiag->colorsel);
- colorseldiag->cancel_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL);
+ colorseldiag->cancel_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+ _("_Cancel"),
+ "gtk-cancel",
+ GTK_RESPONSE_CANCEL);
- colorseldiag->ok_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
- GTK_STOCK_OK,
- GTK_RESPONSE_OK);
+ colorseldiag->ok_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+ _("_OK"),
+ "gtk-ok",
+ GTK_RESPONSE_OK);
+ gtk_widget_set_can_default (colorseldiag->ok_button, TRUE);
gtk_widget_grab_default (colorseldiag->ok_button);
- colorseldiag->help_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
- GTK_STOCK_HELP,
- GTK_RESPONSE_HELP);
+ colorseldiag->help_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+ _("Help"),
+ "help-browser",
+ GTK_RESPONSE_HELP);
gtk_widget_hide (colorseldiag->help_button);
+ gtk_widget_show (colorseldiag->cancel_button);
+ gtk_widget_show (colorseldiag->ok_button);
gtk_window_set_title (GTK_WINDOW (colorseldiag),
_("Color Selection"));
diff --git a/libmate-desktop/mate-rr.c b/libmate-desktop/mate-rr.c
index 19d25ca..e856399 100644
--- a/libmate-desktop/mate-rr.c
+++ b/libmate-desktop/mate-rr.c
@@ -1153,7 +1153,11 @@ get_property (Display *dpy,
if (actual_type == XA_INTEGER && actual_format == 8)
{
+#ifdef GLIB_VERSION_2_68
+ result = g_memdup2 (prop, nitems);
+#else
result = g_memdup (prop, nitems);
+#endif
if (len)
*len = nitems;
}
@@ -1359,8 +1363,11 @@ output_copy (const MateRROutput *from)
output->modes = (MateRRMode**) g_ptr_array_free (array, FALSE);
output->edid_size = from->edid_size;
+#ifdef GLIB_VERSION_2_68
+ output->edid_data = g_memdup2 (from->edid_data, from->edid_size);
+#else
output->edid_data = g_memdup (from->edid_data, from->edid_size);
-
+#endif
return output;
}
diff --git a/tools/mate-color-select.c b/tools/mate-color-select.c
index b9c44b6..c222aa8 100644
--- a/tools/mate-color-select.c
+++ b/tools/mate-color-select.c
@@ -29,7 +29,7 @@
#include <libmate-desktop/mate-colorseldialog.h>
#include <libmate-desktop/mate-colorsel.h>
-gboolean
+static gboolean
copy_color (GtkWidget *widget, GdkEvent *event, MateColorSelectionDialog *color_dialog)
{
GdkColor color;
@@ -70,13 +70,13 @@ main (int argc, char **argv)
widget = gtk_button_new_with_mnemonic (_("_Copy"));
image = gtk_image_new_from_icon_name ("edit-copy", GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (widget), image);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (color_dialog))), widget);
+ gtk_dialog_add_action_widget (GTK_DIALOG (color_dialog), widget, GTK_RESPONSE_ACCEPT);
g_signal_connect (widget, "button-release-event", G_CALLBACK (copy_color), color_dialog);
widget = gtk_button_new_with_mnemonic (_("_Close"));
image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (widget), image);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (color_dialog))), widget);
+ gtk_dialog_add_action_widget (GTK_DIALOG (color_dialog), widget, GTK_RESPONSE_CLOSE);
g_signal_connect (widget, "button-release-event", gtk_main_quit, NULL);
gtk_widget_show_all (color_dialog);