[Xfce4-commits] [panel-plugins/xfce4-cpufreq-plugin] 04/07: Clean up and resolve -Wall warnings

noreply at xfce.org noreply at xfce.org
Fri Sep 21 15:21:40 CEST 2018


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-cpufreq-plugin.

commit ebe93cf4581a87a72c1a109b3c89ab267c99a1ae
Author: Andre Miranda <andreldm at xfce.org>
Date:   Wed Sep 19 20:09:48 2018 -0300

    Clean up and resolve -Wall warnings
---
 panel-plugin/xfce4-cpufreq-configure.c    |   3 +-
 panel-plugin/xfce4-cpufreq-linux-procfs.c |  11 ++-
 panel-plugin/xfce4-cpufreq-linux-pstate.c |  17 ++--
 panel-plugin/xfce4-cpufreq-linux-sysfs.c  |  57 +++++++------
 panel-plugin/xfce4-cpufreq-linux-sysfs.h  |   2 +-
 panel-plugin/xfce4-cpufreq-linux.c        |   6 +-
 panel-plugin/xfce4-cpufreq-overview.c     |  36 ++++-----
 panel-plugin/xfce4-cpufreq-plugin.c       | 129 +++++++++++++++---------------
 panel-plugin/xfce4-cpufreq-plugin.h       |   8 +-
 9 files changed, 135 insertions(+), 134 deletions(-)

diff --git a/panel-plugin/xfce4-cpufreq-configure.c b/panel-plugin/xfce4-cpufreq-configure.c
index 8675301..1205fc9 100644
--- a/panel-plugin/xfce4-cpufreq-configure.c
+++ b/panel-plugin/xfce4-cpufreq-configure.c
@@ -200,7 +200,6 @@ cpufreq_configure_response (GtkWidget *dialog, int response, CpuFreqPluginConfig
 void
 cpufreq_configure (XfcePanelPlugin *plugin)
 {
-  gint i;
   gchar *cpu_name;
   GtkWidget *dialog, *dialog_vbox;
   GtkWidget *frame, *align, *label, *vbox, *hbox;
@@ -342,7 +341,7 @@ cpufreq_configure (XfcePanelPlugin *plugin)
   gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, TRUE, 0);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
 
-  for (i = 0; i < cpuFreq->cpus->len; ++i)
+  for (guint i = 0; i < cpuFreq->cpus->len; ++i)
   {
     cpu_name = g_strdup_printf ("%d", i);
     gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), cpu_name);
diff --git a/panel-plugin/xfce4-cpufreq-linux-procfs.c b/panel-plugin/xfce4-cpufreq-linux-procfs.c
index 551cfe1..acff94b 100644
--- a/panel-plugin/xfce4-cpufreq-linux-procfs.c
+++ b/panel-plugin/xfce4-cpufreq-linux-procfs.c
@@ -29,7 +29,7 @@
 
 
 gboolean
-cpufreq_procfs_is_available ()
+cpufreq_procfs_is_available (void)
 {
   return g_file_test (PROCFS_BASE, G_FILE_TEST_EXISTS);
 }
@@ -37,12 +37,12 @@ cpufreq_procfs_is_available ()
 
 
 gboolean
-cpufreq_procfs_read_cpuinfo ()
+cpufreq_procfs_read_cpuinfo (void)
 {
   CpuInfo *cpu;
   FILE *file;
   gchar *freq, *filePath, *fileContent;
-  gint i = 0;
+  guint i = 0;
   gboolean add_cpu;
 
   filePath = g_strdup ("/proc/cpuinfo");
@@ -109,11 +109,10 @@ cpufreq_procfs_read_cpuinfo ()
 
 
 gboolean
-cpufreq_procfs_read ()
+cpufreq_procfs_read (void)
 {
   CpuInfo *cpu;
   FILE *file;
-  gint i;
   gchar *filePath, *fileContent;
 
   filePath = g_strdup (PROCFS_BASE);
@@ -157,7 +156,7 @@ cpufreq_procfs_read ()
 
   g_free (filePath);
 
-  for (i = 0; i < cpuFreq->cpus->len; i++)
+  for (guint i = 0; i < cpuFreq->cpus->len; i++)
   {
     cpu = g_ptr_array_index (cpuFreq->cpus, i);
     filePath = g_strdup_printf ("/proc/sys/cpu/%d/speed", i);
diff --git a/panel-plugin/xfce4-cpufreq-linux-pstate.c b/panel-plugin/xfce4-cpufreq-linux-pstate.c
index 5987b40..0c6da58 100644
--- a/panel-plugin/xfce4-cpufreq-linux-pstate.c
+++ b/panel-plugin/xfce4-cpufreq-linux-pstate.c
@@ -29,8 +29,10 @@
 
 static gboolean read_params ();
 
+
+
 gboolean
-cpufreq_pstate_is_available ()
+cpufreq_pstate_is_available (void)
 {
   return g_file_test (PSTATE_BASE, G_FILE_TEST_EXISTS);
 }
@@ -40,9 +42,6 @@ cpufreq_pstate_is_available ()
 gboolean
 cpufreq_pstate_read (void)
 {
-  CpuInfo *cpu;
-  gint i;
-
   /* gather intel pstate parameters */
   if (!read_params ())
     return FALSE;
@@ -58,9 +57,9 @@ cpufreq_pstate_read (void)
 
 
 static gboolean
-read_params ()
+read_params (void)
 {
-  gchar *file, *contents;
+  gchar *file;
   IntelPState *ips;
 
   ips = g_slice_new0(IntelPState);
@@ -69,15 +68,15 @@ read_params ()
     return FALSE;
 
   file = g_strdup (PSTATE_BASE "/min_perf_pct");
-  cpufreq_sysfs_read_int (file, contents, &ips->min_perf_pct);
+  cpufreq_sysfs_read_int (file, &ips->min_perf_pct);
   g_free (file);
 
   file = g_strdup (PSTATE_BASE "/max_perf_pct");
-  cpufreq_sysfs_read_int (file, contents, &ips->max_perf_pct);
+  cpufreq_sysfs_read_int (file, &ips->max_perf_pct);
   g_free (file);
 
   file = g_strdup (PSTATE_BASE "/no_turbo");
-  cpufreq_sysfs_read_int (file, contents, &ips->no_turbo);
+  cpufreq_sysfs_read_int (file, &ips->no_turbo);
   g_free (file);
 
   g_slice_free (IntelPState, cpuFreq->intel_pstate);
diff --git a/panel-plugin/xfce4-cpufreq-linux-sysfs.c b/panel-plugin/xfce4-cpufreq-linux-sysfs.c
index 5c418b5..c53fad9 100644
--- a/panel-plugin/xfce4-cpufreq-linux-sysfs.c
+++ b/panel-plugin/xfce4-cpufreq-linux-sysfs.c
@@ -26,11 +26,11 @@
 
 #define SYSFS_BASE  "/sys/devices/system/cpu"
 
-static void cpufreq_sysfs_read_int_list (gchar *file, gchar *contents, GList **list);
+static void cpufreq_sysfs_read_int_list (gchar *file, GList **list);
 
-static void cpufreq_sysfs_read_string (gchar *file, gchar *contents, gchar **string);
+static void cpufreq_sysfs_read_string (gchar *file, gchar **string);
 
-static void cpufreq_sysfs_read_string_list (gchar *file, gchar *contents, GList **list);
+static void cpufreq_sysfs_read_string_list (gchar *file, GList **list);
 
 static void parse_sysfs_init (gint cpu_number, CpuInfo *cpu);
 
@@ -41,27 +41,29 @@ static inline gboolean cpufreq_cpu_exists (gint num);
 
 
 gboolean
-cpufreq_sysfs_is_available ()
+cpufreq_sysfs_is_available (void)
 {
   return g_file_test (SYSFS_BASE"/cpu0/cpufreq", G_FILE_TEST_EXISTS);
 }
 
+
+
 void
 cpufreq_sysfs_read_current (gint cpu_number)
 {
   CpuInfo *cpu;
-  gchar	*file, *contents;
+  gchar	*file;
 
   cpu = g_ptr_array_index (cpuFreq->cpus, cpu_number);
 
   /* read current cpu freq */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_cur_freq", cpu_number);
-  cpufreq_sysfs_read_int (file, contents, &cpu->cur_freq);
+  cpufreq_sysfs_read_int (file, &cpu->cur_freq);
   g_free (file);
 
   /* read current cpu governor */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_governor", cpu_number);
-  cpufreq_sysfs_read_string (file, contents, &cpu->cur_governor);
+  cpufreq_sysfs_read_string (file, &cpu->cur_governor);
   g_free (file);
 }
 
@@ -71,7 +73,6 @@ gboolean
 cpufreq_sysfs_read (void)
 {
   gint count = 0, i = 0;
-  gchar *file;
 
   while (cpufreq_cpu_exists (count))
     count++;
@@ -88,9 +89,11 @@ cpufreq_sysfs_read (void)
 
 
 void
-cpufreq_sysfs_read_int (gchar *file, gchar *contents, gint *intval)
+cpufreq_sysfs_read_int (gchar *file, guint *intval)
 {
-  if (contents = read_file_contents (file)) {
+  gchar *contents = read_file_contents (file);
+
+  if (contents) {
     (*intval) = atoi (contents);
     g_free (contents);
   }
@@ -99,9 +102,11 @@ cpufreq_sysfs_read_int (gchar *file, gchar *contents, gint *intval)
 
 
 static void
-cpufreq_sysfs_read_int_list (gchar *file, gchar *contents, GList **list)
+cpufreq_sysfs_read_int_list (gchar *file, GList **list)
 {
-  if (contents = read_file_contents (file)) {
+  gchar *contents = read_file_contents (file);
+
+  if (contents) {
     gchar **tokens = NULL;
     gint i = 0;
     tokens = g_strsplit (contents, " ", 0);
@@ -118,9 +123,11 @@ cpufreq_sysfs_read_int_list (gchar *file, gchar *contents, GList **list)
 
 
 static void
-cpufreq_sysfs_read_string (gchar *file,gchar *contents, gchar **string)
+cpufreq_sysfs_read_string (gchar *file, gchar **string)
 {
-  if (contents = read_file_contents (file)) {
+  gchar *contents = read_file_contents (file);
+
+  if (contents) {
     g_free (*string);
     *string = contents;
   }
@@ -129,9 +136,11 @@ cpufreq_sysfs_read_string (gchar *file,gchar *contents, gchar **string)
 
 
 static void
-cpufreq_sysfs_read_string_list (gchar *file, gchar *contents, GList **list)
+cpufreq_sysfs_read_string_list (gchar *file, GList **list)
 {
-  if (contents = read_file_contents (file)) {
+  gchar *contents = read_file_contents (file);
+
+  if (contents) {
     gchar **tokens = NULL;
     gint i = 0;
     tokens = g_strsplit (contents, " ", 0);
@@ -150,7 +159,7 @@ cpufreq_sysfs_read_string_list (gchar *file, gchar *contents, GList **list)
 static void
 parse_sysfs_init (gint cpu_number, CpuInfo *cpu)
 {
-  gchar *file, *contents;
+  gchar *file;
   gboolean add_cpu = FALSE;
 
   if (cpu == NULL) {
@@ -161,38 +170,38 @@ parse_sysfs_init (gint cpu_number, CpuInfo *cpu)
   /* read available cpu freqs */
   if (cpuFreq->intel_pstate == NULL) {
     file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_available_frequencies", cpu_number);
-    cpufreq_sysfs_read_int_list (file, contents, &cpu->available_freqs);
+    cpufreq_sysfs_read_int_list (file, &cpu->available_freqs);
     g_free (file);
   }
 
   /* read available cpu governors */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_available_governors", cpu_number);
-  cpufreq_sysfs_read_string_list (file, contents, &cpu->available_governors);
+  cpufreq_sysfs_read_string_list (file, &cpu->available_governors);
   g_free (file);
 
   /* read cpu driver */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_driver", cpu_number);
-  cpufreq_sysfs_read_string (file, contents, &cpu->scaling_driver);
+  cpufreq_sysfs_read_string (file, &cpu->scaling_driver);
   g_free (file);
 
   /* read current cpu freq */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_cur_freq", cpu_number);
-  cpufreq_sysfs_read_int (file, contents, &cpu->cur_freq);
+  cpufreq_sysfs_read_int (file, &cpu->cur_freq);
   g_free (file);
 
   /* read current cpu governor */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_governor", cpu_number);
-  cpufreq_sysfs_read_string (file, contents, &cpu->cur_governor);
+  cpufreq_sysfs_read_string (file, &cpu->cur_governor);
   g_free (file);
 
   /* read max cpu freq */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_max_freq", cpu_number);
-  cpufreq_sysfs_read_int (file, contents, &cpu->max_freq);
+  cpufreq_sysfs_read_int (file, &cpu->max_freq);
   g_free (file);
 
   /* read min cpu freq */
   file = g_strdup_printf (SYSFS_BASE"/cpu%i/cpufreq/scaling_min_freq", cpu_number);
-  cpufreq_sysfs_read_int (file, contents, &cpu->min_freq);
+  cpufreq_sysfs_read_int (file, &cpu->min_freq);
   g_free (file);
 
   if (add_cpu)
diff --git a/panel-plugin/xfce4-cpufreq-linux-sysfs.h b/panel-plugin/xfce4-cpufreq-linux-sysfs.h
index 068c0d0..2749ef4 100644
--- a/panel-plugin/xfce4-cpufreq-linux-sysfs.h
+++ b/panel-plugin/xfce4-cpufreq-linux-sysfs.h
@@ -28,7 +28,7 @@ gboolean cpufreq_sysfs_read (void);
 
 void cpufreq_sysfs_read_current (gint cpu_number);
 
-void cpufreq_sysfs_read_int (gchar *file, gchar *contents, gint *intval);
+void cpufreq_sysfs_read_int (gchar *file, guint *intval);
 
 G_END_DECLS
 
diff --git a/panel-plugin/xfce4-cpufreq-linux.c b/panel-plugin/xfce4-cpufreq-linux.c
index 90d4529..00b0bff 100644
--- a/panel-plugin/xfce4-cpufreq-linux.c
+++ b/panel-plugin/xfce4-cpufreq-linux.c
@@ -82,17 +82,15 @@ cpufreq_linux_init (void)
 gboolean
 cpufreq_update_cpus (gpointer data)
 {
-  gint i;
-
   if (cpufreq_sysfs_is_available ())
   {
-    for (i = 0; i < cpuFreq->cpus->len; i++)
+    for (guint i = 0; i < cpuFreq->cpus->len; i++)
       cpufreq_sysfs_read_current (i);
   }
   else if (cpufreq_procfs_is_available ())
   {
     /* First we delete the cpus and then read the /proc/cpufreq file again */
-    for (i = 0; i < cpuFreq->cpus->len; i++)
+    for (guint i = 0; i < cpuFreq->cpus->len; i++)
     {
       CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, i);
       g_ptr_array_remove_fast (cpuFreq->cpus, cpu);
diff --git a/panel-plugin/xfce4-cpufreq-overview.c b/panel-plugin/xfce4-cpufreq-overview.c
index bdc902b..0cc8060 100644
--- a/panel-plugin/xfce4-cpufreq-overview.c
+++ b/panel-plugin/xfce4-cpufreq-overview.c
@@ -113,9 +113,9 @@ cpufreq_overview_add (CpuInfo *cpu, guint cpu_number, GtkWidget *dialog_hbox)
     j = 0;
     while (list)
     {
-      text = cpufreq_get_human_readable_freq (GPOINTER_TO_INT (list->data));
+      text = cpufreq_get_human_readable_freq (GPOINTER_TO_UINT (list->data));
 
-      if (GPOINTER_TO_INT (list->data) == cpu->cur_freq)
+      if (GPOINTER_TO_UINT (list->data) == cpu->cur_freq)
         i = j;
 
       gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), text);
@@ -230,28 +230,28 @@ cpufreq_overview_response (GtkWidget *dialog, gint response, gpointer data)
 
 
 gboolean
-cpufreq_overview (GtkWidget *widget, GdkEventButton *ev, CpuFreqPlugin *cpuFreq)
+cpufreq_overview (GtkWidget *widget, GdkEventButton *ev, CpuFreqPlugin *cpufreq)
 {
-  gint i, j, step;
+  gint step;
   GtkWidget *dialog, *dialog_vbox, *window;
   GtkWidget *dialog_hbox, *separator;
 
   if (ev->button != 1)
     return FALSE;
 
-  window = g_object_get_data (G_OBJECT (cpuFreq->plugin), "overview");
+  window = g_object_get_data (G_OBJECT (cpufreq->plugin), "overview");
 
   if (window) {
-    g_object_set_data (G_OBJECT (cpuFreq->plugin), "overview", NULL);
+    g_object_set_data (G_OBJECT (cpufreq->plugin), "overview", NULL);
     gtk_widget_destroy (window);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpuFreq->button), FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpufreq->button), FALSE);
     return TRUE;
   }
 
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpuFreq->button), TRUE);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpufreq->button), TRUE);
 
   dialog = xfce_titled_dialog_new_with_buttons (_("CPU Information"),
-    GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (cpuFreq->plugin))),
+    GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (cpufreq->plugin))),
     GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-close", GTK_RESPONSE_OK, NULL);
 
   xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog),
@@ -260,35 +260,35 @@ cpufreq_overview (GtkWidget *widget, GdkEventButton *ev, CpuFreqPlugin *cpuFreq)
   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
   gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-cpufreq-plugin");
 
-  g_object_set_data (G_OBJECT (cpuFreq->plugin), "overview", dialog);
+  g_object_set_data (G_OBJECT (cpufreq->plugin), "overview", dialog);
 
   dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 
   /* choose how many columns and rows depending on cpu count */
-  if (cpuFreq->cpus->len < 4)
+  if (cpufreq->cpus->len < 4)
     step = 1;
-  else if (cpuFreq->cpus->len < 9)
+  else if (cpufreq->cpus->len < 9)
     step = 2;
-  else if (cpuFreq->cpus->len % 3)
+  else if (cpufreq->cpus->len % 3)
     step = 4;
   else
     step = 3;
 
-  for (i = 0; i < cpuFreq->cpus->len; i += step) {
+  for (guint i = 0; i < cpufreq->cpus->len; i += step) {
     dialog_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER * 2);
     gtk_box_pack_start (GTK_BOX (dialog_vbox), dialog_hbox, FALSE, FALSE, BORDER * 2);
     gtk_container_set_border_width (GTK_CONTAINER (dialog_hbox), BORDER * 2);
 
-    for (j = i; j < cpuFreq->cpus->len && j < i + step; j++) {
-      CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, j);
+    for (guint j = i; j < cpufreq->cpus->len && j < i + step; j++) {
+      CpuInfo *cpu = g_ptr_array_index (cpufreq->cpus, j);
       cpufreq_overview_add (cpu, j, dialog_hbox);
 
-      if (j + 1 < cpuFreq->cpus->len && j + 1 == i + step) {
+      if (j + 1 < cpufreq->cpus->len && j + 1 == i + step) {
         separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
         gtk_box_pack_start (GTK_BOX (dialog_vbox), separator, FALSE, FALSE, 0);
       }
 
-      if (j + 1 < cpuFreq->cpus->len && j + 1 < i + step) {
+      if (j + 1 < cpufreq->cpus->len && j + 1 < i + step) {
         separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
         gtk_box_pack_start (GTK_BOX (dialog_hbox), separator, FALSE, FALSE, 0);
       }
diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index d30ddee..80723d3 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -39,13 +39,63 @@
 
 
 
-CpuInfo *
+void
+cpufreq_label_set_font (void)
+{
+  gchar *css = NULL, *css_font = NULL, *css_color = NULL;
+  GtkCssProvider *provider;
+  PangoFontDescription *font;
+
+  if (G_UNLIKELY (cpuFreq->label == NULL))
+    return;
+
+  if (cpuFreq->options->fontname)
+  {
+    font = pango_font_description_from_string(cpuFreq->options->fontname);
+
+    css_font = g_strdup_printf("font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s;",
+      pango_font_description_get_family (font),
+      pango_font_description_get_size (font) / PANGO_SCALE,
+      (pango_font_description_get_style (font) == PANGO_STYLE_ITALIC ||
+      pango_font_description_get_style (font) == PANGO_STYLE_OBLIQUE) ? "italic" : "normal",
+      (pango_font_description_get_weight (font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal");
+
+    pango_font_description_free (font);
+  }
+
+  if (cpuFreq->options->fontcolor)
+    css_color = g_strdup_printf ("color: %s;", cpuFreq->options->fontcolor);
+
+  if (css_font && css_color)
+    css = g_strdup_printf ("label { %s %s }", css_font, css_color);
+  else if (css_font)
+    css = g_strdup_printf ("label { %s }", css_font);
+  else if (css_color)
+    css = g_strdup_printf ("label { %s }", css_color);
+
+  if (css)
+  {
+    provider = gtk_css_provider_new ();
+
+    gtk_css_provider_load_from_data (provider, css, -1, NULL);
+    gtk_style_context_add_provider (
+      GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))),
+      GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  }
+
+  g_free (css);
+  g_free (css_font);
+  g_free (css_color);
+}
+
+
+
+static CpuInfo *
 cpufreq_cpus_calc_min (void)
 {
   guint freq = 0;
-  gint i;
 
-  for (i = 0; i < cpuFreq->cpus->len; i++)
+  for (guint i = 0; i < cpuFreq->cpus->len; i++)
   {
     CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, i);
 
@@ -63,13 +113,12 @@ cpufreq_cpus_calc_min (void)
 
 
 
-CpuInfo *
+static CpuInfo *
 cpufreq_cpus_calc_avg (void)
 {
   guint freq = 0;
-  gint i;
 
-  for (i = 0; i < cpuFreq->cpus->len; i++)
+  for (guint i = 0; i < cpuFreq->cpus->len; i++)
   {
     CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, i);
     freq += cpu->cur_freq;
@@ -86,13 +135,12 @@ cpufreq_cpus_calc_avg (void)
 
 
 
-CpuInfo *
+static CpuInfo *
 cpufreq_cpus_calc_max (void)
 {
   guint freq = 0;
-  gint i;
 
-  for (i = 0; i < cpuFreq->cpus->len; i++)
+  for (guint i = 0; i < cpuFreq->cpus->len; i++)
   {
     CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, i);
 
@@ -108,58 +156,9 @@ cpufreq_cpus_calc_max (void)
   return cpuFreq->cpu_max;
 }
 
-void
-cpufreq_label_set_font (void)
-{
-  gchar *css = NULL, *css_font = NULL, *css_color = NULL;
-  GtkCssProvider *provider;
-  PangoFontDescription *font;
-
-  if (G_UNLIKELY (cpuFreq->label == NULL))
-    return;
-
-  if (cpuFreq->options->fontname)
-  {
-    font = pango_font_description_from_string(cpuFreq->options->fontname);
-
-    css_font = g_strdup_printf("font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s;",
-      pango_font_description_get_family (font),
-      pango_font_description_get_size (font) / PANGO_SCALE,
-      (pango_font_description_get_style (font) == PANGO_STYLE_ITALIC ||
-      pango_font_description_get_style (font) == PANGO_STYLE_OBLIQUE) ? "italic" : "normal",
-      (pango_font_description_get_weight (font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal");
-
-    pango_font_description_free (font);
-  }
-
-  if (cpuFreq->options->fontcolor)
-    css_color = g_strdup_printf ("color: %s;", cpuFreq->options->fontcolor);
-
-  if (css_font && css_color)
-    css = g_strdup_printf ("label { %s %s }", css_font, css_color);
-  else if (css_font)
-    css = g_strdup_printf ("label { %s }", css_font);
-  else if (css_color)
-    css = g_strdup_printf ("label { %s }", css_color);
-
-  if (css)
-  {
-    provider = gtk_css_provider_new ();
-
-    gtk_css_provider_load_from_data (provider, css, -1, NULL);
-    gtk_style_context_add_provider (
-      GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))),
-      GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-  }
-
-  g_free (css);
-  g_free (css_font);
-  g_free (css_color);
-}
 
 
-
-gboolean
+static gboolean
 cpufreq_update_label (CpuInfo *cpu)
 {
   GtkRequisition label_size;
@@ -245,7 +244,7 @@ static void
 cpufreq_widgets_layout (void)
 {
   GtkRequisition icon_size, label_size;
-  GtkOrientation orientation;
+  GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
   gboolean small = cpuFreq->options->keep_compact;
   gboolean resized = FALSE;
   gboolean hide_label = (!cpuFreq->options->show_label_freq &&
@@ -370,8 +369,8 @@ cpufreq_widgets_layout (void)
 
 
 
-CpuInfo *
-cpufreq_current_cpu ()
+static CpuInfo *
+cpufreq_current_cpu (void)
 {
   CpuInfo *cpu = NULL;
 
@@ -532,7 +531,7 @@ cpufreq_update_icon (CpuFreqPlugin *cpufreq)
 
 
 
-void
+static void
 cpufreq_prepare_label (CpuFreqPlugin *cpufreq)
 {
   if (cpufreq->label)
@@ -693,14 +692,12 @@ cpuinfo_free (CpuInfo *cpu)
 static void
 cpufreq_free (XfcePanelPlugin *plugin)
 {
-  gint i;
-
   if (cpuFreq->timeoutHandle)
     g_source_remove (cpuFreq->timeoutHandle);
 
   g_slice_free (IntelPState, cpuFreq->intel_pstate);
 
-  for (i = 0; i < cpuFreq->cpus->len; i++)
+  for (guint i = 0; i < cpuFreq->cpus->len; i++)
   {
     CpuInfo *cpu = g_ptr_array_index (cpuFreq->cpus, i);
     g_ptr_array_remove_fast (cpuFreq->cpus, cpu);
diff --git a/panel-plugin/xfce4-cpufreq-plugin.h b/panel-plugin/xfce4-cpufreq-plugin.h
index 3ef0b86..8e84cd6 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.h
+++ b/panel-plugin/xfce4-cpufreq-plugin.h
@@ -45,9 +45,9 @@ typedef struct
 
 typedef struct
 {
-  gint min_perf_pct;
-  gint max_perf_pct;
-  gint no_turbo;
+  guint min_perf_pct;
+  guint max_perf_pct;
+  guint no_turbo;
 } IntelPState;
 
 typedef struct
@@ -69,7 +69,7 @@ typedef struct
   XfcePanelPlugin *plugin;
   XfcePanelPluginMode panel_mode;
   gint panel_size;
-  guint panel_rows;
+  gint panel_rows;
 
   /* Array with all CPUs */
   GPtrArray *cpus;

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


More information about the Xfce4-commits mailing list