[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 05/10: call tacho member functions; better documentation; removed outcommented code; remove unused function close_window_requested

noreply at xfce.org noreply at xfce.org
Sat Mar 18 18:26:45 CET 2017


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

timystery pushed a commit to branch master
in repository panel-plugins/xfce4-sensors-plugin.

commit 8f744c09348d3d5f4d6bdeff9adee4ea2641585b
Author: Fabian <timystery at arcor.de>
Date:   Sat Mar 18 01:26:38 2017 +0100

    call tacho member functions; better documentation; removed outcommented code; remove unused function close_window_requested
---
 src/actions.c   | 22 +++++++++++-----------
 src/actions.h   | 10 ++++++++++
 src/callbacks.c | 10 ----------
 src/callbacks.h | 15 +++++++++++++--
 src/interface.c |  1 -
 src/interface.h |  5 +++++
 src/main.c      | 22 ++++++++++++++++++++--
 7 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index 9517a6f..9308cf1 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -38,6 +38,9 @@
 #include "interface.h"
 
 /* Local definitions */
+/**
+ *  Default size of the tacho widgets
+ */
 #define DEFAULT_SIZE_TACHOS 48
 
 /* foward declaration */
@@ -48,6 +51,11 @@ refresh_sensor_data (t_sensors_dialog *sd);
 /* actual implementations */
 
 /* -------------------------------------------------------------------------- */
+/** Internal function to refresh all sensors data for updating the displayed
+ * tachos
+ * @param ptr_sensors_dialog_structure: Pointer to sensors dialog structure
+ * @return TRUE: on success
+ */
 gboolean
 refresh_sensor_data (t_sensors_dialog *ptr_sensors_dialog_structure)
 {
@@ -160,17 +168,9 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
                     ptr_sensors_structure->tachos[idx_chip][idx_feature] = ptr_sensorstachowidget = gtk_sensorstacho_new(ptr_sensors_structure->orientation, DEFAULT_SIZE_TACHOS);
                     ptr_sensorstacho = GTK_SENSORSTACHO(ptr_sensorstachowidget);
 
-                    /* TODO: use ...set_text */
-                    if (ptr_sensorstacho->text != NULL)
-                      g_free(ptr_sensorstacho->text);
-
-                    ptr_sensorstacho->text = g_strdup(ptr_chipfeature_structure->name);
-
-                    /* TODO: use gtk_sensorstacho_set_color */
-                    if (ptr_sensorstacho->color != NULL)
-                      g_free(ptr_sensorstacho->color);
+                    gtk_sensorstacho_set_text(ptr_sensorstacho, ptr_chipfeature_structure->name);
 
-                    ptr_sensorstacho->color = g_strdup(ptr_chipfeature_structure->color);
+                    gtk_sensorstacho_set_color(ptr_sensorstacho, ptr_chipfeature_structure->color);
                 }
 
                 val_fill_degree = (ptr_chipfeature_structure->raw_value - ptr_chipfeature_structure->min_value) / ( ptr_chipfeature_structure->max_value - ptr_chipfeature_structure->min_value);
@@ -179,7 +179,7 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
                 else if (val_fill_degree>1.0)
                     val_fill_degree=1.0;
 
-                ptr_sensorstacho->sel = val_fill_degree;
+                gtk_sensorstacho_set_value(ptr_sensorstacho, val_fill_degree);
                 snprintf(str_widget_tooltip_text, 128, "<b>%s</b>\n%s: %s", ptr_chip_structure->sensorId, ptr_chipfeature_structure->name, ptr_chipfeature_structure->formatted_value);
                 gtk_widget_set_tooltip_markup (GTK_WIDGET(ptr_sensors_structure->tachos [idx_chip][idx_feature]), str_widget_tooltip_text);
 
diff --git a/src/actions.h b/src/actions.h
index b31369c..7fb9638 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -29,7 +29,17 @@
 #include <sensors-interface-common.h>
 #include <tacho.h>
 
+/**
+ * Shall refresh the entire view of the application
+ * @param data: pointer to sensors dialog structure
+ * @return TRUE: argument is valid
+ */
 gboolean refresh_view (gpointer data);
+
+/**
+ * refreshes the tacho view of the application
+ * @param ptr_sensors_dialog_structure: pointer to sensors dialog structure
+ */
 void refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure);
 
 #endif /* ACTIONS_H */
diff --git a/src/callbacks.c b/src/callbacks.c
index 8bf1b02..73216be 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -61,16 +61,6 @@ on_main_window_response (GtkWidget *dlg, int response, t_sensors_dialog *sd)
     // dialog OK button or close keybinding or window close button
     if (response==GTK_RESPONSE_OK) // || response==GTK_RESPONSE_DELETE_EVENT)
     {
-        //xfce_titled_dialog_close(GTK_DIALOG(dlg)); // not implemented in libxfcegui4/xfce-titled-dialog.h rev 21491 -- stay compatible
-
-        // g_free (sd->sensors)
-        //g_free(sd);
-
-        //gtk_widget_destroy (sd->sensors->widget_sensors);
-
-        //gtk_widget_destroy (sd->dialog);
-
-        //gtk_widget_destroy (sd->dialog);
     }
 
     TRACE ("leaves on_main_window_response");
diff --git a/src/callbacks.h b/src/callbacks.h
index 0a0251c..e2b79d0 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -32,10 +32,21 @@
 /* there should also be some "private" callbacks such as closing/qutting
  * the application.
  */
-void close_window_requested ();
-
+/**
+ * Callback when main window is closed; shall quit the Gtk main routine and
+ * perhaps also free some further allocated structures.
+ * @param dlg: pointer to dialog widget to be destroyed
+ * @param response: event number of close event
+ * @param sd: pointer to helpful sensors dialog structure
+ */
 void on_main_window_response (GtkWidget *dlg, int response, t_sensors_dialog *sd);
 
+/**
+ * Callback when new font is set in application and must be updated for the
+ * tacho widgets.
+ * @param widget: pointer to font button widget
+ * @param data: pointer to sensors dialog structure
+ */
 void on_font_set (GtkWidget *widget, gpointer data);
 
 /* Functions for implementing the sensors interface common callback functions */
diff --git a/src/interface.c b/src/interface.c
index 7759d1f..de7b133 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -152,7 +152,6 @@ create_main_window (t_sensors_dialog *sd)
 
 
     g_signal_connect (G_OBJECT(dlg), "response", G_CALLBACK(on_main_window_response), sd); // also captures the dialog-destroy event and the closekeybinding-pressed event
-    //g_signal_connect (G_OBJECT(dlg), "destroy", G_CALLBACK(on_main_window_response), sd);
 
     return dlg;
 }
diff --git a/src/interface.h b/src/interface.h
index 7f80885..e9388c4 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -25,4 +25,9 @@
 /* Package includes */
 #include <sensors-interface-common.h>
 
+/**
+ * Populate the application's main window
+ * @param sd: pointers to already filled sensors dialog structure
+ * @return newly allocated GtkWidget of main window
+ */
 GtkWidget * create_main_window (t_sensors_dialog *sd);
diff --git a/src/main.c b/src/main.c
index 0891317..e0fa20d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -53,6 +53,9 @@ void print_version (void);
 t_sensors_dialog * initialize_sensors_structures (void);
 
 /* -------------------------------------------------------------------------- */
+/**
+ * Prints license information
+ */
 void
 print_license (void)
 {
@@ -66,6 +69,9 @@ print_license (void)
 
 
 /* -------------------------------------------------------------------------- */
+/**
+ * Prints help/usage information
+ */
 void
 print_usage (void)
 {
@@ -73,8 +79,8 @@ print_usage (void)
                       "Displays information about your hardware sensors, ACPI "
                                             "status, harddisk temperatures and Nvidia GPU's temperature.\n"
                       "Synopsis: \n"
-                      "  xfce4-sensors options\n"
-                      "where options are one or more of the following:\n"
+                      "  xfce4-sensors [options]\n"
+                      "where [options] are one or more of the following:\n"
                       "  -h, --help    Print this help dialog.\n"
                       "  -l, --license Print license information.\n"
                       "  -V, --version Print version information.\n"
@@ -85,6 +91,9 @@ print_usage (void)
 
 
 /* -------------------------------------------------------------------------- */
+/**
+ * Prints version information as requested by "xfce4-sensors -V"
+ */
 void
 print_version (void)
 {
@@ -93,6 +102,10 @@ print_version (void)
 
 
 /* -------------------------------------------------------------------------- */
+/**
+ * Initializes the required sensor structures.
+ * @return pointer to newly allocated sensors dialog information
+ */
 t_sensors_dialog *
 initialize_sensors_structures (void)
 {
@@ -118,6 +131,11 @@ initialize_sensors_structures (void)
 
 
 /* -------------------------------------------------------------------------- */
+/**
+ * Main routine.
+ * @param argc: number of arguments
+ * @param argv: array of strings passed as arguments
+ */
 int
 main (int argc, char **argv)
 {

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


More information about the Xfce4-commits mailing list