[Goodies-commits] r1766 - xfce4-battery-plugin/branches/XERVERIUS/panel-plugin

Nick Schermer nick at xfce.org
Thu Jul 13 22:25:00 CEST 2006


Author: nick
Date: 2006-07-13 20:24:59 +0000 (Thu, 13 Jul 2006)
New Revision: 1766

Modified:
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.h
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.h
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c
   xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h
Log:
* Fix some small issues


Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -61,7 +59,7 @@
 static gboolean
 battery_actions_run_timeout (gpointer data)
 {
-    gint           i, actions = 0;
+    guint          i, actions = 0;
     BatteryStatus *bat;
     BatteryPlugin *battery;
     GtkWidget     *messages;
@@ -69,12 +67,26 @@
     DBG ("Run timeout function");
 
     battery = (BatteryPlugin *) data;
+    
+    /* Don't run if there is still a dialog visible */
+    if (g_object_get_data (G_OBJECT (battery->plugin), "messages"))
+    {
+	DBG ("STILL VISIBLE");
+	return TRUE;
+    }
+    else
+    {
+	DBG ("NOT VISIBLE ANYMORE");
+    }
 
+    /* Increase the timeout counters */
     critical_counter++;
     low_counter++;
 
     messages = battery_actions_dialog_init ();
 
+    /* Walk through the batteries array to see if there are batteries with
+       a critical or low status */
     for (i = 0; i < battery->batteries->len; ++i)
     {
         bat = g_ptr_array_index (battery->batteries, i);
@@ -82,6 +94,8 @@
 	switch (bat->status)
         {
             case CRITICAL:
+		/* Only show the critical warning if the
+	           minute counter allows us to do so */
                 if (critical_counter == MAX_CRITICAL && (
 #ifdef HAVE_LIBNOTIFY
                     battery->action_critical == NOTIFICATION ||
@@ -98,6 +112,7 @@
                 break;
             
             case LOW:
+		/* Only allow low warnings if it's time to do so */
                 if (low_counter == MAX_LOW && (
 #ifdef HAVE_LIBNOTIFY
                     battery->action_critical == NOTIFICATION ||
@@ -152,8 +167,12 @@
 battery_actions_start_timeout (BatteryPlugin *battery)
 {
     if (!warning_timeout)
+    {
         warning_timeout =
             g_timeout_add (DIALOG_TIMEOUT, battery_actions_run_timeout, battery);
+	
+        DBG ("Timeout %d started", warning_timeout);
+    }
 }
 
 void
@@ -259,6 +278,7 @@
 
     if (GPOINTER_TO_UINT (data) == 0)
     {
+	DBG ("No items in the dialog, destroy it");
         gtk_widget_destroy (messages);
         return;
     }

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-actions.h	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.h	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-calc.h	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,8 +1,6 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
- *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *  Copyright (c) 2006 Benedikt Meurer <benny at xfce.org>
  *
  *  This program is free software; you can redistribute it and/or modify

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.h	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-dialogs.h	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-hal.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery-overview.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -30,6 +30,7 @@
 #include "battery.h"
 #include "battery-calc.h"
 #include "battery-hal.h"
+#include "battery-overview.h"
 
 static const gchar *
 battery_get_status (BatteryStatus *bat)

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.c	2006-07-13 20:24:59 UTC (rev 1766)
@@ -371,7 +371,7 @@
     xfce_panel_plugin_add_action_widget (battery->plugin, battery->ebox);
 }
 
-void
+static void
 battery_error_widget (BatteryPlugin *battery)
 {
     guint      psize;
@@ -409,7 +409,7 @@
     tooltip = g_string_new ("");
 
     /* Destroy the old dialog and reset the counter */
-    battery_actions_dialog_destroy (battery);
+    //battery_actions_dialog_destroy (battery);
 
     /* Init new message dialog */
     messages = battery_actions_dialog_init ();
@@ -455,6 +455,8 @@
                 {
                     /* Battery is fully charged */
                     bat->status = CHARGED;
+		    actions++;
+		    DBG ("...");
                     battery_actions_check (bat,
                                            i,
                                            messages,
@@ -465,6 +467,8 @@
             else if (bat->status != NONE)
             {
                 /* Reset the status */
+		actions++;
+		DBG ("...");
                 bat->status = NONE;
             }
         }
@@ -477,6 +481,7 @@
                     /* Status is critical */
                     bat->status = CRITICAL;
                     actions++;
+		    DBG ("...");
                     battery_actions_check (bat,
                                            i,
                                            messages,
@@ -491,6 +496,7 @@
                     /* Status is low */
                     bat->status = LOW;
                     actions++;
+		    DBG ("...");
                     battery_actions_check (bat,
                                            i,
                                            messages,
@@ -501,12 +507,16 @@
             else if (bat->status != NONE)
             {
                 /* Reset the status */
+		actions++;
+		DBG ("...");
                 bat->status = NONE;
             }
         }
         else if (bat->status != NONE)
         {
             /* No battery, clear the status */
+	    actions++;
+	    DBG ("...");
             bat->status = NONE;
         }
     } /* for batteries */
@@ -518,12 +528,16 @@
                           NULL);
     g_string_free (tooltip, TRUE);
 
-    /* Create the message dialog, if there are any items */
     battery_actions_dialog_create (battery, messages);
-
-    /* Check if we need to reset the timeouts */
-    if (actions)
+    
+    if (actions > 0)
+    {
+	DBG ("...");
+        /* Create the message dialog, if there are any items */
+        battery_actions_dialog_create (battery, messages);
+    
         battery_actions_restart_timeout (battery);
+    }
 }
 
 static void

Modified: xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h
===================================================================
--- xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h	2006-07-13 20:16:38 UTC (rev 1765)
+++ xfce4-battery-plugin/branches/XERVERIUS/panel-plugin/battery.h	2006-07-13 20:24:59 UTC (rev 1766)
@@ -1,9 +1,7 @@
 /* vim: set expandtab ts=8 sw=4: */
 
-/*  $Id$
+/*  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
  *
- *  Copyright (c) 2006 Nick Schermer <nick at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -95,7 +93,7 @@
     gboolean           tip_time, tip_power;
 
     /* Settings: Battery Actions */
-    guint              perc_critical, perc_low;
+    gint               perc_critical, perc_low;
     BatteryAction      action_critical, action_low, action_charged;
     gchar             *command_critical, *command_low, *command_charged;
     




More information about the Goodies-commits mailing list