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 01043f83028b9c677b23a8523fa3c5107c1711b3 Author: Fabian <[email protected]> Date: Sun Oct 21 18:47:14 2018 +0200 Added distinguishment for temperature vs. power/current/voltage vs. energy wrt. tacho coloring --- include/tacho.h | 18 +++++++++++++- lib/tacho.c | 56 +++++++++++++++++++++++++++++++++++-------- panel-plugin/sensors-plugin.c | 23 +++++++++++++++++- src/actions.c | 17 ++++++++++++- 4 files changed, 101 insertions(+), 13 deletions(-) diff --git a/include/tacho.h b/include/tacho.h index a4d917e..78d8c70 100644 --- a/include/tacho.h +++ b/include/tacho.h @@ -30,6 +30,18 @@ G_DECLARE_FINAL_TYPE (GtkSensorsTacho, gtk_sensorstacho, GTK, SENSORSTACHO, GtkD typedef struct _GtkSensorsTacho GtkSensorsTacho; /** + * Enumeration of possible style for sensors tacho. + */ +typedef enum _SensorsTachoStyle { + /** temperatures, ranging from green over yellow to red */ + style_MinGYR = 0, + /** voltage and power, from yellow over green to blue */ + style_MediumYGB = 1, + /** fill level, mostly used for energy from red ove ryellow to green */ + style_MaxRYG = 2 +} SensorsTachoStyle; + +/** * pseudo widget for drawing a tacho */ struct _GtkSensorsTacho { @@ -48,6 +60,9 @@ struct _GtkSensorsTacho { /** size of a side of the surrounding square area */ guint size; + /** color style of tacho */ + SensorsTachoStyle style; + /** orientation, used for vertical bars */ GtkOrientation orientation; }; @@ -63,9 +78,10 @@ void gtk_sensorstacho_set_value (GtkSensorsTacho *ptr_sensorstacho, gdouble valu * create a new sensorstacho with orientation and initial size * @param orientation: orientation of the tacho * @param size: initial size of the tacho object + * @param style: gradient style of the tacho object * @return allocated widget */ -GtkWidget * gtk_sensorstacho_new(GtkOrientation orientation, guint size); +GtkWidget * gtk_sensorstacho_new(GtkOrientation orientation, guint size, SensorsTachoStyle style); /** * set the text to be drawn. if NULL, no text is drawn. diff --git a/lib/tacho.c b/lib/tacho.c index 70745cb..f69a8f3 100644 --- a/lib/tacho.c +++ b/lib/tacho.c @@ -97,13 +97,14 @@ gtk_sensorstacho_unset_text (GtkSensorsTacho *ptr_sensorstacho) /* -------------------------------------------------------------------------- */ GtkWidget * -gtk_sensorstacho_new(GtkOrientation orientation, guint size) +gtk_sensorstacho_new(GtkOrientation orientation, guint size, SensorsTachoStyle style) { GtkSensorsTacho *ptr_sensorstacho = g_object_new(gtk_sensorstacho_get_type(), NULL); TRACE("enter gtk_sensorstacho_new\n"); ptr_sensorstacho->orientation = orientation; ptr_sensorstacho->size = size; + ptr_sensorstacho->style = style; return GTK_WIDGET(ptr_sensorstacho); } @@ -286,6 +287,7 @@ gtk_sensorstacho_paint (GtkWidget *widget, double degrees_45minusI; GtkAllocation allocation; GtkStyleContext *ptr_stylecontext = NULL; + GtkSensorsTacho *ptr_tacho = GTK_SENSORSTACHO(widget); TRACE("enter gtk_sensorstacho_paint\n"); @@ -293,7 +295,7 @@ gtk_sensorstacho_paint (GtkWidget *widget, gtk_widget_get_allocation(widget, &allocation); - percent = GTK_SENSORSTACHO(widget)->sel; + percent = ptr_tacho->sel; if (percent>1.0) percent = 1.0; @@ -308,16 +310,33 @@ gtk_sensorstacho_paint (GtkWidget *widget, pos_ycenter = height / 2; /* initialize color values appropriately */ - color.red = val_colorvalue; + color.red = (ptr_tacho->style != style_MediumYGB) ? val_colorvalue : 0; color.green = val_colorvalue; - color.blue = 0.0; + color.blue = 0; color.alpha = val_alpha; if (percent < 0.5) - color.red = 2*val_colorvalue * percent; + { + if (ptr_tacho->style == style_MinGYR) + color.red = 2*val_colorvalue * percent; + else if (ptr_tacho->style == style_MaxRYG) + color.green = 2*val_colorvalue * percent; + else + color.red = 2*val_colorvalue * (0.5 - percent); + } if (percent > 0.5) - color.green = 2*val_colorvalue * (1 - percent); + { + if (ptr_tacho->style == style_MinGYR) + color.green = 2*val_colorvalue * (1 - percent); + else if (ptr_tacho->style == style_MaxRYG) + color.red = 2*val_colorvalue * (1 - percent); + else + { + color.green = 2*val_colorvalue * (1.0 - percent); + color.blue = 2*val_colorvalue * (percent - 0.5); + } + } /* draw circular gradient */ for (i=(1-percent)*THREE_QUARTER_CIRCLE; i<THREE_QUARTER_CIRCLE; i++) @@ -340,10 +359,27 @@ gtk_sensorstacho_paint (GtkWidget *widget, cairo_fill (ptr_cairo); if (i>(0.5*THREE_QUARTER_CIRCLE - 1)) - color.red -= 2*val_colorvalue * COLOR_STEP; + { + if (ptr_tacho->style == style_MinGYR) + color.red -= 2*val_colorvalue * COLOR_STEP; + else if (ptr_tacho->style == style_MaxRYG) + color.green -= 2*val_colorvalue * COLOR_STEP; + else { + color.red += 2*val_colorvalue * COLOR_STEP; + } + } if (i<(0.5*THREE_QUARTER_CIRCLE - 1)) - color.green += 2*val_colorvalue * COLOR_STEP; + { + if (ptr_tacho->style == style_MinGYR) + color.green += 2*val_colorvalue * COLOR_STEP; + else if (ptr_tacho->style == style_MaxRYG) + color.red += 2*val_colorvalue * COLOR_STEP; + else { + color.green += 2*val_colorvalue * COLOR_STEP; + color.blue -= 2*val_colorvalue * COLOR_STEP; + } + } } /* white right part */ @@ -374,14 +410,14 @@ gtk_sensorstacho_paint (GtkWidget *widget, cairo_stroke (ptr_cairo); - if (GTK_SENSORSTACHO(widget)->text != NULL) { + if (ptr_tacho->text != NULL) { PangoContext *ptr_style_context = gtk_widget_get_pango_context (widget); PangoLayout *ptr_layout = pango_layout_new (ptr_style_context); pango_layout_set_alignment(ptr_layout, PANGO_ALIGN_CENTER); pango_layout_set_width (ptr_layout, width); - ptr_text = g_strdup_printf("<span color=\"%s\">%s</span>", GTK_SENSORSTACHO(widget)->color, GTK_SENSORSTACHO(widget)->text); + ptr_text = g_strdup_printf("<span color=\"%s\">%s</span>", ptr_tacho->color, ptr_tacho->text); pango_layout_set_markup (ptr_layout, ptr_text, -1); // with null-termination, no need to give length explicitly g_free(ptr_text); diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c index b9c7886..dd58d11 100644 --- a/panel-plugin/sensors-plugin.c +++ b/panel-plugin/sensors-plugin.c @@ -497,6 +497,7 @@ sensors_add_tacho_display (t_sensors *ptr_sensors) gboolean has_tachos = FALSE; GtkWidget *ptr_tacho; gchar *str_panellabeltext; + SensorsTachoStyle tacho_style = style_MinGYR; /* default as has been for 10 years */ gint size_panel = ptr_sensors->panel_size; @@ -524,7 +525,21 @@ sensors_add_tacho_display (t_sensors *ptr_sensors) if (ptr_chipfeature->show == TRUE) { has_tachos = TRUE; - ptr_tacho = gtk_sensorstacho_new(ptr_sensors->orientation, size_panel); + switch (ptr_chipfeature->class) { + case VOLTAGE: + case POWER: + case CURRENT: + //case TEMPERATURE: // activate for devlopping only + tacho_style = style_MediumYGB; + break; + case ENERGY: + tacho_style = style_MaxRYG; + break; + default: // tacho_style = style_MinGYR; // already set per default + break; + } + + ptr_tacho = gtk_sensorstacho_new(ptr_sensors->orientation, size_panel, tacho_style); /* create the label stuff only if needed - saves some memory! */ if (ptr_sensors->show_labels == TRUE) { @@ -2316,8 +2331,11 @@ add_tachos_appearance_boxes(GtkWidget * vbox, t_sensors_dialog * sd) { GtkWidget *widget_hscale; GtkWidget *widget_label; + //GtkWidget *widget_groupbox; TRACE ("enters add_tachos_appearance_boxes"); +//widget_groupbox = xfce_groub_box ... + sd->alpha_slider_box = gtk_hbox_new(FALSE, INNER_BORDER); widget_label = gtk_label_new(_("Tacho color alpha value:")); gtk_widget_show (widget_label); @@ -2347,10 +2365,13 @@ add_tachos_appearance_boxes(GtkWidget * vbox, t_sensors_dialog * sd) gtk_box_pack_start (GTK_BOX (vbox), sd->alpha_slider_box, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), sd->colorvalue_slider_box, FALSE, TRUE, 0); + //gtk_box_pack_start (GTK_BOX (vbox), widget_groupbox, FALSE, TRUE, 0); + if (sd->sensors->display_values_type!=DISPLAY_TACHO) { gtk_widget_hide(sd->alpha_slider_box); gtk_widget_hide(sd->colorvalue_slider_box); + //gtk_widget_hide(widget_groupbox); } TRACE ("leaves add_tachos_appearance_boxes"); diff --git a/src/actions.c b/src/actions.c index d7dfacb..bb63ee6 100644 --- a/src/actions.c +++ b/src/actions.c @@ -126,6 +126,7 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure) gdouble val_fill_degree; gchar str_widget_tooltip_text[128]; gint num_max_cols, num_max_rows; + SensorsTachoStyle tacho_style = style_MinGYR; /* default as has been for 10 years */ TRACE ("enters refresh_tacho_view"); @@ -163,7 +164,21 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure) if (ptr_sensorstachowidget == NULL) { DBG("Newly adding selected widget from container."); - ptr_sensors_structure->tachos[idx_chip][idx_feature] = ptr_sensorstachowidget = gtk_sensorstacho_new(ptr_sensors_structure->orientation, DEFAULT_SIZE_TACHOS); + + switch (ptr_chipfeature_structure->class) { + case VOLTAGE: + case POWER: + case CURRENT: + tacho_style = style_MediumYGB; + break; + case ENERGY: + tacho_style = style_MaxRYG; + break; + default: // tacho_style = style_MinGYR; // already set per default + break; + } + + ptr_sensors_structure->tachos[idx_chip][idx_feature] = ptr_sensorstachowidget = gtk_sensorstacho_new(ptr_sensors_structure->orientation, DEFAULT_SIZE_TACHOS, tacho_style); ptr_sensorstacho = GTK_SENSORSTACHO(ptr_sensorstachowidget); gtk_sensorstacho_set_text(ptr_sensorstacho, ptr_chipfeature_structure->name); -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
