diff options
author | rbuj <[email protected]> | 2020-12-04 23:18:42 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-12-05 13:34:56 +0100 |
commit | 78ea6fd61a3e6d0d4601b2595126eb9b0ed76a42 (patch) | |
tree | 5f8d146a4a3deb583bbdefd5e0ca5add61716aff | |
parent | f577f3b17ff60cc54ef28e7c449e9f0739147bb3 (diff) | |
download | mate-panel-78ea6fd61a3e6d0d4601b2595126eb9b0ed76a42.tar.bz2 mate-panel-78ea6fd61a3e6d0d4601b2595126eb9b0ed76a42.tar.xz |
Fix solid color controls after disabling compositor
-rw-r--r-- | mate-panel/Makefile.am | 3 | ||||
-rw-r--r-- | mate-panel/button-widget.c | 1 | ||||
-rw-r--r-- | mate-panel/panel-profile.c | 9 | ||||
-rw-r--r-- | mate-panel/panel-profile.h | 4 | ||||
-rw-r--r-- | mate-panel/panel-properties-dialog.c | 38 |
5 files changed, 25 insertions, 30 deletions
diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am index 6cd56ff1..9dd98897 100644 --- a/mate-panel/Makefile.am +++ b/mate-panel/Makefile.am @@ -158,8 +158,7 @@ mate_panel_LDADD = \ $(DCONF_LIBS) \ $(XRANDR_LIBS) \ $(X_LIBS) \ - $(WAYLAND_LIBS) \ - -lm + $(WAYLAND_LIBS) if ENABLE_WAYLAND mate_panel_LDADD += \ diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c index f2deb0e5..6b839bc6 100644 --- a/mate-panel/button-widget.c +++ b/mate-panel/button-widget.c @@ -1,5 +1,4 @@ #include <config.h> -#include <math.h> #include <string.h> #include <glib/gi18n.h> diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c index 7625f6a8..a89a027d 100644 --- a/mate-panel/panel-profile.c +++ b/mate-panel/panel-profile.c @@ -23,7 +23,6 @@ */ #include <config.h> -#include <math.h> #include "panel-profile.h" #include "panel-layout.h" @@ -267,20 +266,20 @@ panel_profile_get_background_color (PanelToplevel *toplevel, void panel_profile_set_background_opacity (PanelToplevel *toplevel, - guint16 opacity) + gdouble percentage) { GdkRGBA color; panel_profile_get_background_color (toplevel, &color); - color.alpha = opacity / 65535.0; + color.alpha = percentage / 100.0; panel_profile_set_background_color (toplevel, &color); } -guint16 +gdouble panel_profile_get_background_opacity (PanelToplevel *toplevel) { GdkRGBA color; panel_profile_get_background_color (toplevel, &color); - return (guint16) round (color.alpha * 65535); + return color.alpha * 100.0; } void diff --git a/mate-panel/panel-profile.h b/mate-panel/panel-profile.h index 359714b5..930d1ee4 100644 --- a/mate-panel/panel-profile.h +++ b/mate-panel/panel-profile.h @@ -115,8 +115,8 @@ void panel_profile_get_background_color (PanelToplevel *topl GdkRGBA *color); void panel_profile_set_background_opacity (PanelToplevel *toplevel, - guint16 opacity); -guint16 panel_profile_get_background_opacity (PanelToplevel *toplevel); + gdouble percentage); +gdouble panel_profile_get_background_opacity (PanelToplevel *toplevel); void panel_profile_set_background_image (PanelToplevel *toplevel, const char *image); diff --git a/mate-panel/panel-properties-dialog.c b/mate-panel/panel-properties-dialog.c index e9216bec..0475bc72 100644 --- a/mate-panel/panel-properties-dialog.c +++ b/mate-panel/panel-properties-dialog.c @@ -349,8 +349,11 @@ panel_properties_dialog_setup_color_button (PanelPropertiesDialog *dialog, panel_profile_get_background_color (dialog->toplevel, &color); + if (!gdk_screen_is_composited (gdk_screen_get_default ())) + color.alpha = 1.0; + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog->color_button), - &color); + &color); g_signal_connect_swapped (dialog->color_button, "color_set", G_CALLBACK (panel_properties_dialog_color_changed), @@ -416,7 +419,6 @@ static void panel_properties_dialog_opacity_changed (PanelPropertiesDialog *dialog) { gdouble percentage; - guint16 opacity; percentage = gtk_range_get_value (GTK_RANGE (dialog->opacity_scale)); @@ -425,16 +427,14 @@ panel_properties_dialog_opacity_changed (PanelPropertiesDialog *dialog) else if (percentage <= 2) percentage = 0; - opacity = (percentage / 100) * 65535; - - panel_profile_set_background_opacity (dialog->toplevel, opacity); + panel_profile_set_background_opacity (dialog->toplevel, percentage); } static void panel_properties_dialog_setup_opacity_scale (PanelPropertiesDialog *dialog, GtkBuilder *gui) { - guint16 opacity; + gboolean slider_active; gdouble percentage; dialog->opacity_scale = PANEL_GTK_BUILDER_GET (gui, "opacity_scale"); @@ -444,32 +444,30 @@ panel_properties_dialog_setup_opacity_scale (PanelPropertiesDialog *dialog, dialog->opacity_legend = PANEL_GTK_BUILDER_GET (gui, "opacity_legend"); g_return_if_fail (dialog->opacity_legend != NULL); - opacity = panel_profile_get_background_opacity (dialog->toplevel); + slider_active = gdk_screen_is_composited (gdk_screen_get_default ()); - percentage = (opacity * 100.0) / 65535; + if (slider_active) { + percentage = panel_profile_get_background_opacity (dialog->toplevel); + } else { + percentage = 100.0; + } gtk_range_set_value (GTK_RANGE (dialog->opacity_scale), percentage); - g_signal_connect_swapped (dialog->opacity_scale, "value_changed", - G_CALLBACK (panel_properties_dialog_opacity_changed), - dialog); - - gboolean slider_active = TRUE; - - if ( ! gdk_screen_is_composited(gdk_screen_get_default())) { - slider_active = FALSE; - } - - if ( ! panel_profile_background_key_is_writable (dialog->toplevel, "opacity")) { + if (!panel_profile_background_key_is_writable (dialog->toplevel, "opacity")) { slider_active = FALSE; gtk_widget_show (dialog->writability_warn_background); } - if ( ! slider_active) { + if (!slider_active) { gtk_widget_set_sensitive (dialog->opacity_scale, FALSE); gtk_widget_set_sensitive (dialog->opacity_label, FALSE); gtk_widget_set_sensitive (dialog->opacity_legend, FALSE); } + + g_signal_connect_swapped (dialog->opacity_scale, "value_changed", + G_CALLBACK (panel_properties_dialog_opacity_changed), + dialog); } static void |