[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 01/01: Added hue and alpha value settings to tacho displays so that darker themes are better supported and intensity can also be reduced to more smoothly fit the Xfce desktop

noreply at xfce.org noreply at xfce.org
Tue Oct 16 00:55:59 CEST 2018


This is an automated email from the git hooks/post-receive script.

t   i   m   y   s   t   e   r   y       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-sensors-plugin.

commit bf8691c24d87d0a9d47de8417366cf4ebf386c3b
Author: Fabian <timystery at arcor.de>
Date:   Tue Oct 16 00:54:45 2018 +0200

    Added hue and alpha value settings to tacho displays so that darker themes are better supported and intensity can also be reduced to more smoothly fit the Xfce desktop
---
 include/sensors-interface-common.h |   6 ++
 include/sensors-interface-plugin.h |   7 ++
 include/tacho.h                    |  18 +++++
 lib/configuration.c                |  16 +++++
 lib/sensors-interface-common.c     |   3 +
 lib/tacho.c                        |  20 +++---
 panel-plugin/sensors-plugin.c      | 130 ++++++++++++++++++++++++++++++++-----
 panel-plugin/sensors-plugin.h      |   1 +
 8 files changed, 173 insertions(+), 28 deletions(-)

diff --git a/include/sensors-interface-common.h b/include/sensors-interface-common.h
index 09144da..bcd3735 100644
--- a/include/sensors-interface-common.h
+++ b/include/sensors-interface-common.h
@@ -121,6 +121,12 @@ typedef struct {
     /** used to enable 'show labels' option when using graphical view */
     GtkWidget *labels_Box;
 
+    /** used to customize hue value when using graphical view */
+    GtkWidget *hue_slider_box;
+
+    /** used to customize alpha value when using graphical view */
+    GtkWidget *alpha_slider_box;
+
     /**
      * pointer to GtkCheckbox whether to colorize the checkboxes over the Gtk
      * theme
diff --git a/include/sensors-interface-plugin.h b/include/sensors-interface-plugin.h
index 879fe76..c2bfbbc 100644
--- a/include/sensors-interface-plugin.h
+++ b/include/sensors-interface-plugin.h
@@ -162,6 +162,13 @@ typedef struct {
 
     /** preferred dialog height */
     gint preferred_height;
+
+    /** hue value for the tachometers, useful for dark themes where lower brightness is required */
+    gfloat val_tachos_hue;
+
+    /** desired alpha value for the tachometers */
+    gfloat val_tachos_alpha;
+
 }
 t_sensors;
 
diff --git a/include/tacho.h b/include/tacho.h
index 9eedaf5..05f405b 100644
--- a/include/tacho.h
+++ b/include/tacho.h
@@ -108,6 +108,24 @@ void gtk_sensorstacho_set_size(GtkSensorsTacho *ptr_sensorstacho, guint size);
  */
 extern gchar *font;
 
+
+#define MAX_HUE 0.8
+#define ALPHA_CHANNEL_VALUE 0.8
+
+/**
+ * directly exhibited internal value describing the desired hue value for the
+ * tacho elements.
+ * TODO: Introduce getter/setter functions
+ */
+extern gfloat val_hue;
+
+/**
+ * directly exhibited internal value describing the desired alpha value for the
+ * tacho elements.
+ * TODO: Introduce getter/setter functions
+ */
+extern gfloat val_alpha;
+
 G_END_DECLS
 
 #endif /* __TACHO_H */
diff --git a/lib/configuration.c b/lib/configuration.c
index b5e9658..54d9a27 100644
--- a/lib/configuration.c
+++ b/lib/configuration.c
@@ -143,6 +143,14 @@ sensors_write_config (XfcePanelPlugin *plugin,t_sensors *ptr_sensors)
             xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Width", ptr_sensors->preferred_width);
             xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Height", ptr_sensors->preferred_height);
 
+            str_tmp = g_strdup_printf("%.2f", ptr_sensors->val_tachos_hue);
+            xfce_rc_write_entry (ptr_xfcerc, "Tachos_Hue", str_tmp);
+            g_free (str_tmp);
+
+            str_tmp = g_strdup_printf("%.2f", ptr_sensors->val_tachos_alpha);
+            xfce_rc_write_entry (ptr_xfcerc, "Tachos_Alpha", str_tmp);
+            g_free (str_tmp);
+
             for (idx_chips=0; idx_chips<ptr_sensors->num_sensorchips; idx_chips++) {
 
                 ptr_chip = (t_chip *) g_ptr_array_index(ptr_sensors->chips, idx_chips);
@@ -270,6 +278,14 @@ sensors_read_general_config (XfceRc *ptr_xfceresources, t_sensors *ptr_sensors)
         ptr_sensors->preferred_width = xfce_rc_read_int_entry (ptr_xfceresources, "Preferred_Width", 400);
         ptr_sensors->preferred_height = xfce_rc_read_int_entry (ptr_xfceresources, "Preferred_Height", 400);
 
+        if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "Tachos_Hue", NULL))
+                && *str_value)
+            ptr_sensors->val_tachos_hue = atof (str_value);
+
+        if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "Tachos_Alpha", NULL))
+                && *str_value)
+            ptr_sensors->val_tachos_alpha = atof (str_value);
+
         //num_chips = xfce_rc_read_int_entry (ptr_xfceresources, "Number_Chips", 0);
         /* or could use 1 or the always existent dummy entry */
     }
diff --git a/lib/sensors-interface-common.c b/lib/sensors-interface-common.c
index a0d7c22..137182a 100644
--- a/lib/sensors-interface-common.c
+++ b/lib/sensors-interface-common.c
@@ -127,6 +127,9 @@ sensors_init_default_values  (t_sensors *ptr_sensors, XfcePanelPlugin *ptr_xfcep
 
     ptr_sensors->show_smallspacings = FALSE;
 
+    ptr_sensors->val_tachos_hue = MAX_HUE;
+    ptr_sensors->val_tachos_alpha = ALPHA_CHANNEL_VALUE;
+
     font = g_strdup("Sans 11");
 
     TRACE ("leaves sensors_init_default_values");
diff --git a/lib/tacho.c b/lib/tacho.c
index 0c53976..3ec978f 100644
--- a/lib/tacho.c
+++ b/lib/tacho.c
@@ -64,6 +64,9 @@ void gtk_sensorstacho_destroy(GtkWidget *widget);
 
 gchar *font = NULL; // declared as extern in tacho.h
 
+gfloat val_hue = MAX_HUE; // declared as extern in tacho.h
+gfloat val_alpha = ALPHA_CHANNEL_VALUE; // declared as extern in tacho.h
+
 G_DEFINE_TYPE( GtkSensorsTacho, gtk_sensorstacho, GTK_TYPE_DRAWING_AREA )
 
 
@@ -266,9 +269,6 @@ gtk_sensorstacho_size_allocate (GtkWidget *ptr_widget, GtkAllocation *ptr_alloca
   TRACE("leave gtk_sensorstacho_size_allocate\n");
 }
 
-#define MAX_HUE 0.8
-#define MAX_HUE_DOUBLE 2*MAX_HUE
-#define ALPHA_CHANNEL_VALUE 0.8
 
 /* -------------------------------------------------------------------------- */
 gboolean
@@ -308,16 +308,16 @@ gtk_sensorstacho_paint (GtkWidget *widget,
     pos_ycenter = height / 2;
 
     /* initialize color values appropriately */
-    color.red = MAX_HUE;
-    color.green = MAX_HUE;
+    color.red = val_hue;
+    color.green = val_hue;
     color.blue = 0.0;
-    color.alpha = ALPHA_CHANNEL_VALUE;
+    color.alpha = val_alpha;
 
     if (percent < 0.5)
-        color.red = MAX_HUE_DOUBLE * percent;
+        color.red = 2*val_hue * percent;
 
     if (percent > 0.5)
-        color.green = MAX_HUE_DOUBLE - MAX_HUE_DOUBLE * percent;
+        color.green = 2*val_hue * (1 - percent);
 
     /* draw circular gradient */
     for (i=(1-percent)*THREE_QUARTER_CIRCLE; i<THREE_QUARTER_CIRCLE; i++)
@@ -340,10 +340,10 @@ gtk_sensorstacho_paint (GtkWidget *widget,
         cairo_fill (ptr_cairo);
 
         if (i>(0.5*THREE_QUARTER_CIRCLE - 1))
-            color.red -= MAX_HUE_DOUBLE * COLOR_STEP;
+            color.red -= 2*val_hue * COLOR_STEP;
 
         if (i<(0.5*THREE_QUARTER_CIRCLE - 1))
-            color.green += MAX_HUE_DOUBLE * COLOR_STEP;
+            color.green += 2*val_hue * COLOR_STEP;
     }
 
     /* white right part */
diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c
index e0797ab..33c286e 100644
--- a/panel-plugin/sensors-plugin.c
+++ b/panel-plugin/sensors-plugin.c
@@ -658,6 +658,9 @@ sensors_show_tacho_display (t_sensors *ptr_sensors)
     g_return_val_if_fail(ptr_sensors != NULL, FALSE);
 
     if (ptr_sensors->tachos_created == FALSE) {
+        val_hue = ptr_sensors->val_tachos_hue;
+        val_alpha = ptr_sensors->val_tachos_alpha;
+
         sensors_add_tacho_display (ptr_sensors);
     }
 
@@ -1353,8 +1356,10 @@ display_style_changed_text (GtkWidget *widget, t_sensors_dialog *sd)
     gtk_widget_hide(sd->fontSettings_Box);
     gtk_widget_show(sd->font_Box);
     gtk_widget_show(sd->Lines_Box);
-    gtk_widget_show (sd->unit_checkbox);
-    gtk_widget_show (sd->smallspacing_checkbox);
+    gtk_widget_show(sd->unit_checkbox);
+    gtk_widget_show(sd->smallspacing_checkbox);
+    gtk_widget_hide(sd->hue_slider_box);
+    gtk_widget_hide(sd->alpha_slider_box);
 
     sd->sensors->display_values_type = DISPLAY_TEXT;
 
@@ -1381,8 +1386,10 @@ display_style_changed_bars (GtkWidget *widget, t_sensors_dialog *sd)
     gtk_widget_hide(sd->fontSettings_Box);
     gtk_widget_hide(sd->font_Box);
     gtk_widget_hide(sd->Lines_Box);
-    gtk_widget_hide (sd->unit_checkbox);
-    gtk_widget_hide (sd->smallspacing_checkbox);
+    gtk_widget_hide(sd->unit_checkbox);
+    gtk_widget_hide(sd->smallspacing_checkbox);
+    gtk_widget_hide(sd->hue_slider_box);
+    gtk_widget_hide(sd->alpha_slider_box);
 
     sd->sensors->display_values_type = DISPLAY_BARS;
 
@@ -1427,8 +1434,10 @@ display_style_changed_tacho (GtkWidget *widget, t_sensors_dialog *sd)
     gtk_widget_show(sd->fontSettings_Box);
     gtk_widget_hide(sd->font_Box);
     gtk_widget_hide(sd->Lines_Box);
-    gtk_widget_hide (sd->unit_checkbox);
-    gtk_widget_hide (sd->smallspacing_checkbox);
+    gtk_widget_hide(sd->unit_checkbox);
+    gtk_widget_hide(sd->smallspacing_checkbox);
+    gtk_widget_show(sd->hue_slider_box);
+    gtk_widget_show(sd->alpha_slider_box);
 
     sd->sensors->display_values_type = DISPLAY_TACHO;
 
@@ -1912,20 +1921,58 @@ list_cell_toggle_ (GtkCellRendererToggle *cell, gchar *path_str,
 static void
 on_font_set (GtkWidget *widget, gpointer data)
 {
-        t_sensors *sensors;
-        sensors = (t_sensors *) data;
-        g_assert (sensors!=NULL);
+    t_sensors *sensors;
+    sensors = (t_sensors *) data;
+    g_assert (sensors!=NULL);
 
-        if (font)
-            g_free (font);
+    if (font)
+        g_free (font);
 
-        font = g_strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget)));
+    font = g_strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget)));
 
-        if (sensors->display_values_type==DISPLAY_TACHO)
-        {
-            /* refresh the panel content */
-            sensors_update_tacho_panel (sensors);
-        }
+    if (sensors->display_values_type==DISPLAY_TACHO)
+    {
+        /* refresh the panel content */
+        sensors_update_tacho_panel (sensors);
+    }
+}
+
+
+/* -------------------------------------------------------------------------- */
+static void
+tachos_hue_changed_ (GtkWidget *ptr_widget, GtkScrollType type, gdouble value, t_sensors_dialog *ptr_sensorsdialog)
+{
+    t_sensors *sensors;
+    sensors = ptr_sensorsdialog->sensors;
+    g_assert (sensors!=NULL);
+
+    sensors->val_tachos_hue = val_hue = value; //gtk_scale_button_get_value(GTK_SCALE_BUTTON(ptr_widget));
+    DBG("new hue value is %f.", val_hue);
+
+    if (sensors->display_values_type==DISPLAY_TACHO)
+    {
+        /* refresh the panel content */
+        sensors_update_tacho_panel (sensors);
+    }
+}
+
+
+/* -------------------------------------------------------------------------- */
+static void
+tachos_alpha_changed_ (GtkWidget *ptr_widget, GtkScrollType type, gdouble value, t_sensors_dialog *ptr_sensorsdialog)
+{
+    t_sensors *sensors;
+    sensors = ptr_sensorsdialog->sensors;
+    g_assert (sensors!=NULL);
+
+    sensors->val_tachos_alpha = val_alpha = value; //gtk_scale_button_get_value(GTK_SCALE_BUTTON(ptr_widget));
+    DBG("new alpha value is %f.", val_alpha);
+
+    if (sensors->display_values_type==DISPLAY_TACHO)
+    {
+        /* refresh the panel content */
+        sensors_update_tacho_panel (sensors);
+    }
 }
 
 
@@ -2260,6 +2307,52 @@ add_smallspacings_box (GtkWidget * vbox, t_sensors_dialog * sd)
 
 /* -------------------------------------------------------------------------- */
 static void
+add_tachos_appearance_boxes(GtkWidget * vbox, t_sensors_dialog * sd)
+{
+    GtkWidget *widget_hscale;
+    GtkWidget *widget_label;
+    TRACE ("enters add_tachos_appearance_boxes");
+
+    sd->alpha_slider_box = gtk_hbox_new(FALSE, INNER_BORDER);
+    widget_label = gtk_label_new(_("Tacho color alpha value:"));
+    gtk_widget_show (widget_label);
+    gtk_box_pack_start (GTK_BOX (sd->alpha_slider_box), widget_label, FALSE, TRUE, 0);
+    widget_hscale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 1.0, 0.01);
+    gtk_range_set_value(GTK_RANGE(widget_hscale), sd->sensors->val_tachos_alpha);
+    gtk_widget_show (widget_hscale);
+    g_signal_connect   (G_OBJECT (widget_hscale), "change-value",
+                        G_CALLBACK (tachos_alpha_changed_), sd );
+    gtk_box_pack_start (GTK_BOX (sd->alpha_slider_box), widget_hscale, TRUE, TRUE, 0);
+    gtk_widget_show (sd->alpha_slider_box);
+
+
+    sd->hue_slider_box = gtk_hbox_new(FALSE, INNER_BORDER);
+    widget_label = gtk_label_new(_("Tacho color hue value:"));
+    gtk_widget_show (widget_label);
+    gtk_box_pack_start (GTK_BOX (sd->hue_slider_box), widget_label, FALSE, TRUE, 0);
+    widget_hscale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 1.0, 0.01);
+    gtk_range_set_value(GTK_RANGE(widget_hscale), sd->sensors->val_tachos_hue);
+    gtk_widget_show (widget_hscale);
+    g_signal_connect   (G_OBJECT (widget_hscale), "change-value",
+                        G_CALLBACK (tachos_hue_changed_), sd );
+    gtk_box_pack_start (GTK_BOX (sd->hue_slider_box), widget_hscale, TRUE, TRUE, 0);
+    gtk_widget_show (sd->hue_slider_box);
+
+    gtk_box_pack_start (GTK_BOX (vbox), sd->alpha_slider_box, FALSE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), sd->hue_slider_box, FALSE, TRUE, 0);
+
+    if (sd->sensors->display_values_type!=DISPLAY_TACHO)
+    {
+        gtk_widget_hide(sd->alpha_slider_box);
+        gtk_widget_hide(sd->hue_slider_box);
+    }
+
+    TRACE ("leaves add_tachos_appearance_boxes");
+}
+
+
+/* -------------------------------------------------------------------------- */
+static void
 add_suppressmessage_box (GtkWidget * vbox, t_sensors_dialog * sd)
 {
     TRACE ("enters add_suppressmessage_box");
@@ -2364,13 +2457,14 @@ add_view_frame (GtkWidget * notebook, t_sensors_dialog * sd)
 
     add_ui_style_box (_vbox, sd);
     add_labels_box (_vbox, sd);
+    add_cover_rows_box(_vbox, sd);
     add_str_fontsize_box (_vbox, sd);
     add_font_settings_box (_vbox, sd);
     add_lines_box (_vbox, sd);
-    add_cover_rows_box(_vbox, sd);
     add_colored_bars_box (_vbox, sd);
     add_units_box (_vbox, sd);
     add_smallspacings_box(_vbox, sd);
+    add_tachos_appearance_boxes(_vbox, sd);
 
     TRACE ("leaves add_view_frame");
 }
diff --git a/panel-plugin/sensors-plugin.h b/panel-plugin/sensors-plugin.h
index 3d9c228..ac4b563 100644
--- a/panel-plugin/sensors-plugin.h
+++ b/panel-plugin/sensors-plugin.h
@@ -54,4 +54,5 @@ void maximum_changed_ (GtkCellRendererText *cellrenderertext, gchar *ptr_str_pat
 
 void temperature_unit_change_ (GtkWidget *ptr_widget, t_sensors_dialog *ptr_sensorsdialog);
 
+
 #endif /* XFCE4_SENSORS_SENSORS_H */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list