[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 01/03: Beginning fixes toward crashes when hovering mouse over tacho panels

noreply at xfce.org noreply at xfce.org
Wed May 21 21:44:42 CEST 2014


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 c8fed3d2c31277cd319fa09072de2ddb2d621107
Author: Fabian <timystery at arcor.de>
Date:   Tue May 13 22:31:36 2014 +0200

    Beginning fixes toward crashes when hovering mouse over tacho panels
---
 lib/cpu.c                      |   31 +++++++++++++++++++++------
 lib/sensors-interface-common.c |    2 +-
 panel-plugin/sensors-plugin.c  |   46 +++++++++++++++++++++++-----------------
 3 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/lib/cpu.c b/lib/cpu.c
index 3199046..4fbf386 100644
--- a/lib/cpu.c
+++ b/lib/cpu.c
@@ -43,6 +43,8 @@ static void gtk_cpu_realize(GtkWidget *widget);
 static gboolean gtk_cpu_expose(GtkWidget *widget,
     GdkEventExpose *event);
 static void gtk_cpu_destroy(GtkObject *object);
+static gboolean gtk_cpu_button_press (GtkWidget      *widget,
+                       GdkEventButton *event);
 
 
 gchar *font = NULL; // declared as extern in cpu.h
@@ -114,14 +116,16 @@ gtk_cpu_unset_text (GtkCpu *cpu)
 }
 
 
-GtkWidget * gtk_cpu_new(void)
+GtkWidget * 
+gtk_cpu_new(void)
 {
   TRACE("enter gtk_cpu_new\n");
    return GTK_WIDGET(gtk_type_new(gtk_cpu_get_type()));
 }
 
 
-void gtk_cpu_set_color (GtkCpu *cpu, gchar *color)
+void 
+gtk_cpu_set_color (GtkCpu *cpu, gchar *color)
 {
   if (color==NULL) {
     gtk_cpu_unset_color(cpu);
@@ -135,7 +139,8 @@ void gtk_cpu_set_color (GtkCpu *cpu, gchar *color)
 }
 
 
-void gtk_cpu_unset_color (GtkCpu *cpu)
+void 
+gtk_cpu_unset_color (GtkCpu *cpu)
 {
   if (cpu->color!=NULL)
     g_free (cpu->color);
@@ -160,6 +165,7 @@ gtk_cpu_class_init (GtkCpuClass *klass)
   widget_class->size_request = gtk_cpu_size_request;
   widget_class->size_allocate = gtk_cpu_size_allocate;
   widget_class->expose_event = gtk_cpu_expose;
+  widget_class->button_press_event = gtk_cpu_button_press;
 
   object_class->destroy = gtk_cpu_destroy;
   
@@ -284,7 +290,7 @@ gtk_cpu_expose(GtkWidget *widget, GdkEventExpose *event)
   gtk_cpu_paint(widget);
 
   TRACE("leave gtk_cpu_expose\n");
-  return FALSE;
+  return TRUE;
 }
 
 
@@ -305,8 +311,12 @@ gtk_cpu_paint (GtkWidget *widget)
   
   if (GTK_CPU(widget)->gc==NULL)
   {
-    if (widget->window==NULL) /* safety checks to circumvent assertion failures when creating graphics contect */
+    // TODO FIXME: The following might be responsible for the widget not working in newly allocated sensors plugin
+    if (widget->window==NULL) /* safety checks to circumvent assertion failures when creating graphics context */
+    {
+      DBG("widget window is NULL.\n");
       return;
+    }
       
     GTK_CPU(widget)->gc = gdk_gc_new(widget->window);
   }
@@ -455,7 +465,7 @@ gtk_cpu_destroy (GtkObject *object)
 
   cpu = GTK_CPU(object);
   
-	/* gdk_gc_destroy(cpu->gc); */
+  /* gdk_gc_destroy(cpu->gc); */
   
   if (cpu->text!=NULL)
   {
@@ -496,3 +506,12 @@ gtk_cpu_set_value (GtkCpu *cpu, gdouble value)
   gtk_cpu_paint(GTK_WIDGET(cpu));
   TRACE("leave gtk_cpu_set_value\n");
 }
+
+static gboolean
+gtk_cpu_button_press (GtkWidget      *widget,
+                       GdkEventButton *event)
+{
+  DBG("obtained mouse event.\n");
+  // GTK_CPU(widget)->parent_class -> send event
+  return FALSE; // propagate event further
+}
diff --git a/lib/sensors-interface-common.c b/lib/sensors-interface-common.c
index 7647b62..5f0aca7 100644
--- a/lib/sensors-interface-common.c
+++ b/lib/sensors-interface-common.c
@@ -46,7 +46,7 @@ sensors_new (XfcePanelPlugin *plugin, gchar *plugin_config_file)
     sensors = g_new0 (t_sensors, 1);
     sensors->plugin_config_file = plugin_config_file; /* important as we check against NULL frequently */
 
-    /* init xfce sensors stuff width default values */
+    /* init xfce sensors stuff with default values */
     sensors_init_default_values (sensors, plugin);
 
     /* get suppressmessages */
diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c
index e25c951..fd64c06 100644
--- a/panel-plugin/sensors-plugin.c
+++ b/panel-plugin/sensors-plugin.c
@@ -284,8 +284,7 @@ sensors_add_graphical_display (t_sensors *sensors)
 
     TRACE ("enters sensors_add_graphical_display");
 
-    text = g_strdup (_("<span foreground=\"#000000\">"
-                                     "<b>Sensors</b></span>"));
+    text = g_strdup (_("<span><b>Sensors</b></span>"));
     gtk_label_set_markup (GTK_LABEL(sensors->panel_label_text), text);
     g_free (text);
 
@@ -381,8 +380,7 @@ sensors_add_tacho_display (t_sensors *sensors)
 
     TRACE ("enters sensors_add_tacho_display");
 
-    text = g_strdup (_("<span foreground=\"#000000\">"
-                                     "<b>Sensors</b></span>"));
+    text = g_strdup (_("<span><b>Sensors</b></span>"));
     gtk_label_set_markup (GTK_LABEL(sensors->panel_label_text), text);
     g_free (text);
 
@@ -622,9 +620,11 @@ sensors_set_text_panel_label (t_sensors *sensors, gint numCols, gint itemsToDisp
             
             if (chipfeature->show == TRUE) {
                 if(sensors->show_labels==TRUE) {
-                  tmpstring = g_strconcat (myLabelText, "<span size=\"", sensors->font_size, "\">",chipfeature->name, ":</span> ", NULL);
+                  tmpstring = g_strconcat (myLabelText, "<span size=\"", sensors->font_size, "\">",chipfeature->name, NULL);
+                  
                   g_free(myLabelText);
-                  myLabelText = tmpstring;
+                  myLabelText = g_strconcat (tmpstring, ":</span> ", NULL);
+                  g_free(tmpstring);
                 }
                 
                 if (sensors->show_units) {
@@ -633,18 +633,23 @@ sensors_set_text_panel_label (t_sensors *sensors, gint numCols, gint itemsToDisp
                                             chipfeature->color, "\" size=\"",
                                             sensors->font_size, "\">",
                                             chipfeature->formatted_value,
-                                            "</span>", NULL);
+                                            NULL);
+                                              
+                  myLabelText = g_strconcat (tmpstring,
+                                              "</span>", NULL);
+
+                  g_free (tmpstring);
                 }
                 else {
                     tmpstring = g_strdup_printf("%s<span foreground=\"%s\" size=\"%s\">%.1f</span>", myLabelText,
                             chipfeature->color, sensors->font_size,
                             chipfeature->raw_value);
                     //myLabelText = g_strconcat (myLabelText, tmpstring, NULL);
+                    g_free(myLabelText);
+                    myLabelText = tmpstring;
                 }
-
-                g_free (myLabelText);
-
-                myLabelText = tmpstring;
+                
+                  
 
                 if (sensors->orientation == GTK_ORIENTATION_VERTICAL) {
                     if (itemsToDisplay > 1) {
@@ -799,12 +804,12 @@ sensors_create_tooltip (gpointer data)
 
                     if (first == TRUE) {
                         g_free (myToolTipText);
-                        myToolTipText = g_strdup (chip->sensorId);
+                        myToolTipText = g_strconcat ("<b>", chip->sensorId, "</b>", NULL);
                         first = FALSE;
                     }
                     else {
-                        myToolTipText2 = g_strconcat (myToolTipText, " \n",
-                                                     chip->sensorId, NULL);
+                        myToolTipText2 = g_strconcat (myToolTipText, " \n<b>",
+                                                     chip->sensorId, "</b>", NULL);
                         TRACE ("freeing myToolTipText");
                         g_free (myToolTipText);
                         myToolTipText = myToolTipText2;
@@ -847,7 +852,7 @@ sensors_create_tooltip (gpointer data)
         }
     }
 
-    gtk_widget_set_tooltip_text (GTK_WIDGET(sensors->eventbox), myToolTipText);
+    gtk_widget_set_tooltip_markup (GTK_WIDGET(sensors->eventbox), myToolTipText);
     DBG("tooltip text: %s.\n", myToolTipText);
     
     gtk_widget_set_has_tooltip(GTK_WIDGET(sensors->eventbox), !sensors->suppresstooltip);
@@ -977,8 +982,7 @@ create_panel_widget (t_sensors * sensors)
     gtk_misc_set_padding (GTK_MISC(sensors->panel_label_text), INNER_BORDER, 0);
     gtk_misc_set_alignment(GTK_MISC(sensors->panel_label_text), 0.0, 0.5);
 
-    myLabelText = g_strdup (_("<span foreground=\"#000000\"><b>Sensors"
-                                    "</b></span>"));
+    myLabelText = g_strdup (_("<span><b>Sensors</b></span>"));
     gtk_label_set_markup(GTK_LABEL(sensors->panel_label_text), myLabelText);
     gtk_widget_show (sensors->panel_label_text);
     g_free(myLabelText);
@@ -1025,7 +1029,7 @@ execute_command (GtkWidget *widget, GdkEventButton *event, gpointer data)
     }
     else {
         TRACE ("leaves execute_command with FALSE");
-        return FALSE;
+        return TRUE;
     }
 }
 
@@ -2253,7 +2257,6 @@ add_event_box (t_sensors *sensors)
     /* create eventbox to catch events on widget */
     sensors->eventbox = gtk_event_box_new ();
     gtk_widget_set_name (sensors->eventbox, "xfce_sensors");
-    gtk_widget_show (sensors->eventbox);
 
     /* double-click improvement */
     sensors->doubleclick_id = g_signal_connect (G_OBJECT(sensors->eventbox),
@@ -2294,6 +2297,7 @@ create_sensors_control (XfcePanelPlugin *plugin)
     gtk_container_add (GTK_CONTAINER (sensors->eventbox),
                        sensors->widget_sensors);
 
+    
     /* sensors_set_size (control, settings.size); */
 
     TRACE ("leaves create_sensors_control");
@@ -2348,7 +2352,9 @@ sensors_plugin_construct (XfcePanelPlugin *plugin)
     gtk_container_add (GTK_CONTAINER(plugin), sensors->eventbox);
 
     xfce_panel_plugin_add_action_widget (plugin, sensors->eventbox);
-
+    
+    gtk_widget_show (sensors->eventbox);
+    
     TRACE ("leaves sensors_plugin_construct");
 }
 

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


More information about the Xfce4-commits mailing list