[Xfce4-commits] [panel-plugins/xfce4-cpugraph-plugin] 01/01: Add option to disable the graph (Bug #15163)

noreply at xfce.org noreply at xfce.org
Sat Jun 22 19:26:00 CEST 2019


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

a   n   d   r   e       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-cpugraph-plugin.

commit dc8e3dbd28893d309fd7bf86fc0184299bc870f6
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sat Jun 22 14:25:19 2019 -0300

    Add option to disable the graph (Bug #15163)
---
 panel-plugin/cpu.c        | 18 ++++++++++++++++++
 panel-plugin/cpu.h        |  2 +-
 panel-plugin/properties.c | 15 ++++++++++++---
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index 6d36797..9b934f6 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -372,6 +372,12 @@ update_cb (CPUGraph *base)
         }
     }
 
+    if (base->mode == -1)
+    {
+        /* Disabled mode, skip updating history and drawing the graph */
+        return TRUE;
+    }
+
     if (base->non_linear)
     {
         i = base->history_size - 1;
@@ -559,6 +565,18 @@ void
 set_mode (CPUGraph *base, guint mode)
 {
     base->mode = mode;
+
+    if (mode == -1)
+    {
+        /* 'Disabled' mode, hide graph and clear history */
+        gtk_widget_hide (base->frame_widget);
+        for (gint i = 0; i < base->history_size; i++)
+            base->history[i] = 0;
+    }
+    else
+    {
+        gtk_widget_show (base->frame_widget);
+    }
 }
 
 void
diff --git a/panel-plugin/cpu.h b/panel-plugin/cpu.h
index 4a76184..71c90a2 100644
--- a/panel-plugin/cpu.h
+++ b/panel-plugin/cpu.h
@@ -49,7 +49,7 @@ typedef struct
     guint update_interval; /* Number of ms between updates. */
     gboolean non_linear;
     guint size;
-    guint mode;
+    gint mode;
     guint color_mode;
     gboolean has_frame;
     gboolean has_border;
diff --git a/panel-plugin/properties.c b/panel-plugin/properties.c
index 8873dcb..5d91a5e 100644
--- a/panel-plugin/properties.c
+++ b/panel-plugin/properties.c
@@ -334,14 +334,19 @@ setup_color_option (GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base,
 static void
 setup_mode_option (GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base)
 {
-    const gchar *items[] = { _("Normal"),
+    const gchar *items[] = { _("Disabled"),
+                             _("Normal"),
                              _("LED"),
                              _("No history"),
                              _("Grid")
                            };
     gsize nb_items = sizeof (items) / sizeof (gchar*);
 
-    create_drop_down (vbox, sg, _("Mode:"), items, nb_items, base->mode, change_mode, base);
+    /* 'Disabled' mode was introduced in 1.1.0 as '-1'
+     * for this reason we need to increment the selected value */
+    gint selected = base->mode + 1;
+
+    create_drop_down (vbox, sg, _("Mode:"), items, nb_items, selected, change_mode, base);
 }
 
 static void
@@ -439,7 +444,11 @@ select_active_barscolors (CPUGraph *base)
 static void
 change_mode (GtkComboBox *combo, CPUGraph *base)
 {
-    set_mode (base, gtk_combo_box_get_active (combo));
+    /* 'Disabled' mode was introduced in 1.1.0 as '-1'
+     * for this reason we need to decrement the selected value */
+    gint selected = gtk_combo_box_get_active (combo) - 1;
+
+    set_mode (base, selected);
     select_active_colors (base);
 }
 

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


More information about the Xfce4-commits mailing list