[Xfce4-commits] [panel-plugins/xfce4-systemload-plugin] 02/02: Unroll the new_entry function to improve readability

noreply at xfce.org noreply at xfce.org
Sat Dec 23 00:01:02 CET 2017


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

o   c   h   o   s   i       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-systemload-plugin.

commit a7226c7294a526fc5186e09ed63193bf6cc2c163
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Sat Dec 23 00:00:53 2017 +0100

    Unroll the new_entry function to improve readability
---
 panel-plugin/systemload.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/panel-plugin/systemload.c b/panel-plugin/systemload.c
index 1b6a0d1..64b256a 100644
--- a/panel-plugin/systemload.c
+++ b/panel-plugin/systemload.c
@@ -871,22 +871,6 @@ static void new_monitor_setting(t_global_monitor *global, GtkGrid *grid, int pos
     gtk_grid_attach(GTK_GRID(subgrid), entry, 1, 0, 1, 1);
 }
 
-/* Adds an entry box to the grid, optionally with a checkbox to enable it.
- * Set boolvar to NULL if you do not want a checkbox. */
-static void new_entry(t_global_monitor *global, GtkGrid *grid, guint row,
-                      const gchar *labeltext, gchar **charvar,
-                      gboolean *boolvar)
-{
-    GtkWidget *entry;
-    entry = gtk_entry_new ();
-    g_object_set_data (G_OBJECT(entry), "charvar", charvar);
-    gtk_entry_set_text (GTK_ENTRY(entry), *charvar);
-    g_signal_connect (G_OBJECT(entry), "changed",
-                      G_CALLBACK(entry_changed_cb), global);
-    new_label_or_check_button(global, GTK_GRID(grid), row, labeltext, boolvar, entry);
-    gtk_grid_attach(grid, entry, 1, row, 1, 1);
-}
-
 /* Adds a new spin button, optionally with a checkbox to enable it.
  * Set boolvar to NULL if you do not want a checkbox. */
 static void new_spin_button(t_global_monitor *global, GtkGrid *grid, guint row,
@@ -907,7 +891,7 @@ monitor_create_options(XfcePanelPlugin *plugin, t_global_monitor *global)
 {
     GtkWidget           *dlg;
     GtkBox              *content;
-    GtkWidget           *grid, *label;
+    GtkWidget           *grid, *label, *entry;
     guint                count;
     t_monitor           *monitor;
     static const gchar *FRAME_TEXT[] = {
@@ -943,20 +927,28 @@ monitor_create_options(XfcePanelPlugin *plugin, t_global_monitor *global)
     gtk_widget_set_halign(label, GTK_ALIGN_START);
     gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
     gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
+    /* Update interval */
     new_spin_button(global, GTK_GRID(grid), 1,
             _("Update interval:"),
             (gfloat)global->timeout/1000.0, 0.100, 10.000, .050,
             G_CALLBACK(change_timeout_cb), NULL);
 #ifdef HAVE_UPOWER_GLIB
+    /* Power-saving interval */
     new_spin_button(global, GTK_GRID(grid), 2,
             _("Power-saving interval:"),
             (gfloat)global->timeout_seconds, 1, 10, 1,
             G_CALLBACK(change_timeout_seconds_cb),
             &global->use_timeout_seconds);
 #endif
-    new_entry(global, GTK_GRID(grid), 3,
-              _("System monitor:"),
-              &global->command.command_text, &global->command.enabled);
+    /* System Monitor */
+    entry = gtk_entry_new ();
+    g_object_set_data (G_OBJECT(entry), "charvar", &global->command.command_text);
+    gtk_entry_set_text (GTK_ENTRY(entry), global->command.command_text);
+    g_signal_connect (G_OBJECT(entry), "changed",
+                      G_CALLBACK(entry_changed_cb), global);
+    new_label_or_check_button(global, GTK_GRID (grid), 3, _("System monitor:"), &global->command.enabled, entry);
+    gtk_grid_attach (GTK_GRID (grid), entry, 1, 3, 1, 1);
+    /* Add options for the three monitors */
     for(count = 0; count < 3; count++)
     {
         monitor = global->monitor[count];
@@ -969,11 +961,10 @@ monitor_create_options(XfcePanelPlugin *plugin, t_global_monitor *global)
                            &monitor->options.label_text);
     }
 
-    /*uptime monitor options - start*/
+    /* Uptime monitor options */
     new_monitor_setting(global, GTK_GRID(grid), 11,
                       _(FRAME_TEXT[3]), &global->uptime->enabled,
                       NULL, NULL, NULL);
-    /*uptime monitor options - end*/
 
     gtk_widget_show_all (dlg);
 }

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


More information about the Xfce4-commits mailing list