[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 01/02: Removed old comments from code, some more structure, less duplicate code for removing the tacho widgets in standalone app, some helpful debug printing; and finally found some unused code in form of draw_callback

noreply at xfce.org noreply at xfce.org
Thu Mar 9 21:28:57 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 e9d17b20d8783d086792ab46ea089ba27d766722
Author: Fabian <timystery at arcor.de>
Date:   Thu Mar 9 21:26:00 2017 +0100

    Removed old comments from code, some more structure, less duplicate code for removing the tacho widgets in standalone app, some helpful debug printing; and finally found some unused code in form of draw_callback
---
 src/actions.c   |  4 ++++
 src/callbacks.c | 40 +++++++++++++++++-----------------------
 src/callbacks.h |  7 -------
 src/interface.c | 50 +++-----------------------------------------------
 src/interface.h |  4 ----
 src/main.c      |  5 +++++
 6 files changed, 29 insertions(+), 81 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index f7c5fc1..9517a6f 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -106,6 +106,7 @@ refresh_sensor_data (t_sensors_dialog *ptr_sensors_dialog_structure)
     return TRUE;
 }
 
+
 /* -------------------------------------------------------------------------- */
 void
 refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
@@ -155,6 +156,7 @@ 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);
                     ptr_sensorstacho = GTK_SENSORSTACHO(ptr_sensorstachowidget);
 
@@ -206,6 +208,7 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
             else if ( ptr_sensorstachowidget != NULL &&
              gtk_widget_get_parent(ptr_sensorstachowidget) != NULL )
             {
+                DBG("Removing deselected widget from container.");
                 gtk_container_remove(GTK_CONTAINER(ptr_wdgt_table), ptr_sensorstachowidget);
                 if (ptr_sensorstacho->text)
                     g_free(ptr_sensorstacho->text);
@@ -223,6 +226,7 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
     TRACE ("leaves refresh_tacho_view");
 }
 
+
 /* -------------------------------------------------------------------------- */
 gboolean
 refresh_view (gpointer data)
diff --git a/src/callbacks.c b/src/callbacks.c
index 829fe20..8bf1b02 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -38,6 +38,7 @@
 #include "actions.h"
 
 
+/* -------------------------------------------------------------------------- */
 void on_font_set (GtkWidget *widget, gpointer data)
 {
     if (font!=NULL)
@@ -48,6 +49,7 @@ void on_font_set (GtkWidget *widget, gpointer data)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 on_main_window_response (GtkWidget *dlg, int response, t_sensors_dialog *sd)
 {
@@ -75,6 +77,7 @@ on_main_window_response (GtkWidget *dlg, int response, t_sensors_dialog *sd)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 sensor_entry_changed_ (GtkWidget *widget, t_sensors_dialog *sd)
 {
@@ -97,6 +100,7 @@ sensor_entry_changed_ (GtkWidget *widget, t_sensors_dialog *sd)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 list_cell_text_edited_ (GtkCellRendererText *cellrenderertext,
                       gchar *path_str, gchar *new_text, t_sensors_dialog *sd)
@@ -157,6 +161,7 @@ list_cell_text_edited_ (GtkCellRendererText *cellrenderertext,
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 list_cell_toggle_ (GtkCellRendererToggle *cell, gchar *path_str,
                   t_sensors_dialog *sd)
@@ -188,25 +193,7 @@ list_cell_toggle_ (GtkCellRendererToggle *cell, gchar *path_str,
     /* do something with the value */
     toggle_item ^= 1;
 
-    /* remove previously existing cpu widget from memory */
-    if (toggle_item==FALSE)
-    {
-      //tacho = sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)];
-      // gtk_container_remove also destroys the widget when there are no more references!
-      gtk_container_remove(GTK_CONTAINER(sd->sensors->widget_sensors),
-                                      sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]);
-      //gtk_widget_destroy(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]);
-      if (GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->text)
-        g_free(GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->text);
-      if (GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->color)
-        g_free(GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->color);
-      sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)] = NULL;
-     }
-     //else
-     //{
-       ////if (sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]==NULL)
-                //sd->sensors->tachos[gtk_combo_box_active][atoi(path_str)] = gtk_sensorstacho_new();
-     //}
+    DBG("toggle item is %d.", toggle_item);
 
     /* set new value */
     gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 2, toggle_item, -1);
@@ -225,11 +212,13 @@ list_cell_toggle_ (GtkCellRendererToggle *cell, gchar *path_str,
     TRACE ("leaves list_cell_toggle");//~
 }
 
+
+/* -------------------------------------------------------------------------- */
 void
 list_cell_color_edited_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
                        gchar *new_color, t_sensors_dialog *sd)
 {
-      gint gtk_combo_box_active;
+    gint gtk_combo_box_active;
     GtkTreeModel *model;
     GtkTreePath *path;
     GtkTreeIter iter;
@@ -284,6 +273,7 @@ list_cell_color_edited_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 minimum_changed_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
                  gchar *new_value, t_sensors_dialog *sd)
@@ -331,6 +321,8 @@ minimum_changed_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
     TRACE ("leaves minimum_changed");
 }
 
+
+/* -------------------------------------------------------------------------- */
 void
 maximum_changed_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
             gchar *new_value, t_sensors_dialog *sd)
@@ -373,12 +365,13 @@ maximum_changed_ (GtkCellRendererText *cellrenderertext, gchar *path_str,
 
     /* update panel */
     if (sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]!=NULL)
-      //res =
-            refresh_view ((gpointer) sd);
+      refresh_view ((gpointer) sd);
 
     TRACE ("leaves maximum_changed");
 }
 
+
+/* -------------------------------------------------------------------------- */
 void
 adjustment_value_changed_ (GtkWidget *widget, t_sensors_dialog* sd)
 {
@@ -397,6 +390,8 @@ adjustment_value_changed_ (GtkWidget *widget, t_sensors_dialog* sd)
     TRACE ("leaves adjustment_value_changed ");
 }
 
+
+/* -------------------------------------------------------------------------- */
 void
 temperature_unit_change_ (GtkWidget *widget, t_sensors_dialog *sd)
 {
@@ -406,7 +401,6 @@ temperature_unit_change_ (GtkWidget *widget, t_sensors_dialog *sd)
     sd->sensors->scale = 1 - sd->sensors->scale;
 
     /* refresh the panel content */
-
     reload_listbox (sd);
 
     TRACE ("laeves temperature_unit_change ");
diff --git a/src/callbacks.h b/src/callbacks.h
index 0a9b93a..0a0251c 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -26,15 +26,8 @@
 #include <sensors-interface-common.h>
 
 /* Global includes */
-/* #include <glib.h> */
 #include <gtk/gtk.h>
 
-/*
-void sensor_entry_changed (GtkWidget *widget, t_sensors_dialog *sd);
-
-void list_cell_text_edited (GtkCellRendererText *cellrenderertext,
-                            gchar *path_str, gchar *new_text, t_sensors_dialog *sd);
-*/
 
 /* there should also be some "private" callbacks such as closing/qutting
  * the application.
diff --git a/src/interface.c b/src/interface.c
index b17f611..7759d1f 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -49,12 +49,12 @@ void add_notebook (GtkWidget *box, t_sensors_dialog *sd);
 
 /* actual implementations */
 
+/* -------------------------------------------------------------------------- */
 void
 add_tachos_box (GtkWidget *child, t_sensors_dialog *sd)
 {
     GtkWidget *table;
 
-    //table = gtk_table_new (5, 4, TRUE);
     table = gtk_grid_new();
     gtk_grid_set_row_spacing(GTK_GRID(table), BORDER);
     gtk_grid_set_column_spacing(GTK_GRID(table), BORDER);
@@ -64,6 +64,7 @@ add_tachos_box (GtkWidget *child, t_sensors_dialog *sd)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 add_notebook (GtkWidget *box, t_sensors_dialog *sd)
 {
@@ -110,12 +111,11 @@ add_notebook (GtkWidget *box, t_sensors_dialog *sd)
 }
 
 
+/* -------------------------------------------------------------------------- */
 GtkWidget *
 create_main_window (t_sensors_dialog *sd)
 {
     GtkWidget *dlg, *vbox;
-    //GtkWidget *tacho;
-    //GtkWidget *drawing_area;
 
     /* start and populate */
     dlg = xfce_titled_dialog_new_with_buttons(
@@ -146,20 +146,8 @@ create_main_window (t_sensors_dialog *sd)
 
     gtk_combo_box_set_active (GTK_COMBO_BOX(sd->myComboBox), 0);
 
-
     add_notebook (vbox, sd);
 
-    //tacho = gtk_sensorstacho_new();
-    //gtk_box_pack_end(GTK_BOX(vbox), tacho, TRUE, TRUE, 4);
-    //gtk_widget_set_realized(tacho, TRUE);
-    //gtk_widget_show(tacho);
-
-  //drawing_area = gtk_drawing_area_new ();
-  //gtk_widget_set_size_request (drawing_area, 100, 100);
-  //g_signal_connect (G_OBJECT (drawing_area), "draw",
-                    //G_CALLBACK (draw_callback), NULL);
-    //gtk_box_pack_end(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 4);
-
     gtk_window_set_default_size (GTK_WINDOW(dlg), sd->sensors->preferred_width, sd->sensors->preferred_height);
 
 
@@ -168,35 +156,3 @@ create_main_window (t_sensors_dialog *sd)
 
     return dlg;
 }
-
-gboolean draw_callback(GtkWidget    *widget,
-                       cairo_t *cr,
-                       gpointer      user_data)
-{
-  guint width, height;
-  GdkRGBA color;
-  GtkStyleContext *context;
-
-  context = gtk_widget_get_style_context (widget);
-
-  width = gtk_widget_get_allocated_width (widget);
-  height = gtk_widget_get_allocated_height (widget);
-
-  //gtk_render_background (context, cr, 0, 0, width, height);
-
-
-  gtk_style_context_get_color (context,
-                               gtk_style_context_get_state (context),
-                               &color);
-  color.red = 1.0;
-  gdk_cairo_set_source_rgba (cr, &color);
-
-  cairo_arc (cr,
-             width / 2.0, height / 2.0,
-             MIN (width, height) / 2.0,
-             0, 2 * G_PI);
-
-  cairo_fill (cr);
-
-   return FALSE;
-}
diff --git a/src/interface.h b/src/interface.h
index 0d89f6d..7f80885 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -26,7 +26,3 @@
 #include <sensors-interface-common.h>
 
 GtkWidget * create_main_window (t_sensors_dialog *sd);
-
-gboolean draw_callback(GtkWidget    *widget,
-               cairo_t *cr,
-               gpointer      user_data);
diff --git a/src/main.c b/src/main.c
index f18f6a3..0891317 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,6 +52,7 @@ void print_usage (void);
 void print_version (void);
 t_sensors_dialog * initialize_sensors_structures (void);
 
+/* -------------------------------------------------------------------------- */
 void
 print_license (void)
 {
@@ -64,6 +65,7 @@ print_license (void)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 print_usage (void)
 {
@@ -82,6 +84,7 @@ print_usage (void)
 }
 
 
+/* -------------------------------------------------------------------------- */
 void
 print_version (void)
 {
@@ -89,6 +92,7 @@ print_version (void)
 }
 
 
+/* -------------------------------------------------------------------------- */
 t_sensors_dialog *
 initialize_sensors_structures (void)
 {
@@ -113,6 +117,7 @@ initialize_sensors_structures (void)
 }
 
 
+/* -------------------------------------------------------------------------- */
 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