gnome-power-manager r3113 - in trunk: . src



Author: rhughes
Date: Tue Dec  2 15:11:36 2008
New Revision: 3113
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3113&view=rev

Log:
2008-12-02  Richard Hughes  <richard hughsie com>

* src/egg-string.c: (egg_strequal):
* src/egg-test.c: (egg_test_init), (egg_test_title),
(egg_test_success), (egg_test_failed):
Trivial egg updates.

* src/gpm-control.h:
Remove unused code.

* src/gpm-button.c: (gpm_button_emit_type),
(gpm_button_is_lid_closed), (gpm_button_reset_time):
* src/gpm-button.h:
* src/gpm-manager.c: (gpm_manager_action_suspend),
(gpm_manager_action_hibernate):
Ensure we reset the event time after resume to properly filter
duplicate keypresses.


Modified:
   trunk/ChangeLog
   trunk/src/egg-string.c
   trunk/src/egg-test.c
   trunk/src/gpm-button.c
   trunk/src/gpm-button.h
   trunk/src/gpm-control.h
   trunk/src/gpm-manager.c

Modified: trunk/src/egg-string.c
==============================================================================
--- trunk/src/egg-string.c	(original)
+++ trunk/src/egg-string.c	Tue Dec  2 15:11:36 2008
@@ -189,10 +189,8 @@
 gboolean
 egg_strequal (const gchar *id1, const gchar *id2)
 {
-	if (id1 == NULL || id2 == NULL) {
-		egg_debug ("string compare invalid '%s' and '%s'", id1, id2);
+	if (id1 == NULL || id2 == NULL)
 		return FALSE;
-	}
 	return (strcmp (id1, id2) == 0);
 }
 

Modified: trunk/src/egg-test.c
==============================================================================
--- trunk/src/egg-test.c	(original)
+++ trunk/src/egg-test.c	Tue Dec  2 15:11:36 2008
@@ -32,6 +32,7 @@
 	guint		 total;
 	guint		 succeeded;
 	gboolean	 started;
+	gboolean	 titled;
 	gchar		*type;
 	GTimer		*timer;
 	GMainLoop	*loop;
@@ -51,6 +52,7 @@
 	test->succeeded = 0;
 	test->type = NULL;
 	test->started = FALSE;
+	test->titled = FALSE;
 	test->timer = g_timer_new ();
 	test->loop = g_main_loop_new (NULL, FALSE);
 	test->hang_loop_id = 0;
@@ -207,6 +209,12 @@
 	va_list args;
 	gchar *va_args_buffer = NULL;
 
+	/* already titled? */
+	if (test->titled) {
+		g_print ("Already titled!\n");
+		exit (1);
+	}
+
 	/* reset the value egg_test_elapsed replies with */
 	g_timer_reset (test->timer);
 
@@ -214,8 +222,9 @@
 	g_vasprintf (&va_args_buffer, format, args);
 	va_end (args);
 	g_print ("> check #%u\t%s: \t%s...", test->total+1, test->type, va_args_buffer);
-	g_free(va_args_buffer);
+	g_free (va_args_buffer);
 
+	test->titled = TRUE;
 	test->total++;
 }
 
@@ -228,6 +237,11 @@
 	va_list args;
 	gchar *va_args_buffer = NULL;
 
+	/* not titled? */
+	if (!test->titled) {
+		g_print ("Not titled!\n");
+		exit (1);
+	}
 	if (format == NULL) {
 		g_print ("...OK\n");
 		goto finish;
@@ -236,8 +250,9 @@
 	g_vasprintf (&va_args_buffer, format, args);
 	va_end (args);
 	g_print ("...OK [%s]\n", va_args_buffer);
-	g_free(va_args_buffer);
+	g_free (va_args_buffer);
 finish:
+	test->titled = FALSE;
 	test->succeeded++;
 }
 
@@ -249,6 +264,12 @@
 {
 	va_list args;
 	gchar *va_args_buffer = NULL;
+
+	/* not titled? */
+	if (!test->titled) {
+		g_print ("Not titled!\n");
+		exit (1);
+	}
 	if (format == NULL) {
 		g_print ("FAILED\n");
 		goto failed;
@@ -257,7 +278,7 @@
 	g_vasprintf (&va_args_buffer, format, args);
 	va_end (args);
 	g_print ("FAILED [%s]\n", va_args_buffer);
-	g_free(va_args_buffer);
+	g_free (va_args_buffer);
 failed:
 	exit (1);
 }

Modified: trunk/src/gpm-button.c
==============================================================================
--- trunk/src/gpm-button.c	(original)
+++ trunk/src/gpm-button.c	Tue Dec  2 15:11:36 2008
@@ -75,7 +75,6 @@
 gboolean
 gpm_button_emit_type (GpmButton *button, const gchar *type)
 {
-	g_return_val_if_fail (button != NULL, FALSE);
 	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
 
 	/* did we just have this button before the timeout? */
@@ -262,12 +261,25 @@
 gboolean
 gpm_button_is_lid_closed (GpmButton *button)
 {
-	g_return_val_if_fail (button != NULL, FALSE);
 	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
 	return button->priv->lid_is_closed;
 }
 
 /**
+ * gpm_button_reset_time:
+ *
+ * We have to refresh the event time on resume to handle duplicate buttons
+ * properly when the time is significant when we suspend.
+ **/
+gboolean
+gpm_button_reset_time (GpmButton *button)
+{
+	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
+	g_timer_reset (button->priv->timer);
+	return TRUE;
+}
+
+/**
  * emit_button_pressed:
  *
  * @udi: The HAL UDI

Modified: trunk/src/gpm-button.h
==============================================================================
--- trunk/src/gpm-button.h	(original)
+++ trunk/src/gpm-button.h	Tue Dec  2 15:11:36 2008
@@ -66,6 +66,7 @@
 GType		 gpm_button_get_type		(void);
 GpmButton	*gpm_button_new			(void);
 gboolean	 gpm_button_is_lid_closed	(GpmButton *button);
+gboolean	 gpm_button_reset_time		(GpmButton *button);
 
 G_END_DECLS
 

Modified: trunk/src/gpm-control.h
==============================================================================
--- trunk/src/gpm-control.h	(original)
+++ trunk/src/gpm-control.h	Tue Dec  2 15:11:36 2008
@@ -94,18 +94,6 @@
 						 	 GError		**error);
 gboolean	 gpm_control_reboot			(GpmControl	*control,
 						 	 GError		**error);
-
-void		 gpm_control_register			(GpmControl	*control,
-							 const gchar	*application,
-							 DBusGMethodInvocation *context,
-							 GError		**error);
-gboolean	 gpm_control_un_register		(GpmControl	*control,
-							 guint32	 cookie,
-							 GError		**error);
-gboolean	 gpm_control_policy			(GpmControl	*control,
-							 guint32	 cookie,
-							 gboolean	 allowed,
-							 GError		**error);
 gboolean	 gpm_control_get_lock_policy		(GpmControl	*control,
 							 const gchar	*policy);
 

Modified: trunk/src/gpm-manager.c
==============================================================================
--- trunk/src/gpm-manager.c	(original)
+++ trunk/src/gpm-manager.c	Tue Dec  2 15:11:36 2008
@@ -456,6 +456,7 @@
 				_("Suspending computer."), reason);
 #endif
 	gpm_control_suspend (manager->priv->control, &error);
+	gpm_button_reset_time (manager->priv->button);
 	if (error != NULL)
 		g_error_free (error);
 	return TRUE;
@@ -505,6 +506,7 @@
 				_("Hibernating computer."), reason);
 #endif
 	gpm_control_hibernate (manager->priv->control, &error);
+	gpm_button_reset_time (manager->priv->button);
 	if (error != NULL)
 		g_error_free (error);
 	return TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]