[Xfce4-commits] <xfce4-power-manager:devkit-power> Support for shutdown via the session manager.

Ali Abdallah noreply at xfce.org
Fri Nov 6 14:40:02 CET 2009


Updating branch refs/heads/devkit-power
         to 23116a1fca688d481ed8f7d3448b829d0f54eb32 (commit)
       from cdc132a83cd7785319170eef508338bedf52fc21 (commit)

commit 23116a1fca688d481ed8f7d3448b829d0f54eb32
Author: Ali Abdallah <ali at ali-xfce.org>
Date:   Fri Nov 6 13:05:34 2009 +0100

    Support for shutdown via the session manager.

 Makefile.am                                  |    2 +-
 TODO                                         |    1 -
 configure.ac.in                              |    2 +-
 panel-plugins/brightness/brightness-button.c |    2 +-
 src/xfpm-dkp.c                               |   46 +++++++++++++++++++++++---
 src/xfpm-dkp.h                               |    2 +
 src/xfpm-manager.c                           |   15 ++++++++-
 7 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dc3cd5c..7827b2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,8 +10,8 @@ endif
 
 SUBDIRS =        	\
 	data		\
-	$(libhal_dir)	\
 	libdbus		\
+	$(libhal_dir)	\
 	common		\
 	src		\
 	settings	\
diff --git a/TODO b/TODO
index 23a6f0a..c1a5c9e 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-* Make xrandr brightness control working.
 * Reimplement the org.freedesktop.PowerManagement interface.
 * Hard drive spinning.
 * Survive D-Bus restarts.
diff --git a/configure.ac.in b/configure.ac.in
index 3e0c3ca..2d80340 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -190,8 +190,8 @@ XDT_FEATURE_DEBUG
 
 AC_OUTPUT([
 Makefile
-libhal/Makefile
 libdbus/Makefile
+libhal/Makefile
 common/Makefile
 src/Makefile
 settings/Makefile
diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c
index 0318c95..8574ec9 100644
--- a/panel-plugins/brightness/brightness-button.c
+++ b/panel-plugins/brightness/brightness-button.c
@@ -445,7 +445,7 @@ brightness_button_up (BrightnessButton *button)
 static void
 brightness_button_down (BrightnessButton *button)
 {
-    guint level;
+    gint level;
     xfpm_brightness_get_level (button->priv->brightness, &level);
     
     if ( level != 0 )
diff --git a/src/xfpm-dkp.c b/src/xfpm-dkp.c
index 13b83ba..e2ad3e2 100644
--- a/src/xfpm-dkp.c
+++ b/src/xfpm-dkp.c
@@ -110,6 +110,7 @@ enum
     WAKING_UP,
     SLEEPING,
     ASK_SHUTDOWN,
+    SHUTDOWN,
     LAST_SIGNAL
 };
 
@@ -396,6 +397,14 @@ xfpm_dkp_suspend_clicked (XfpmDkp *dkp)
 }
 
 static void
+xfpm_dkp_shutdown_clicked (XfpmDkp *dkp)
+{
+    gtk_widget_destroy (dkp->priv->dialog );
+    dkp->priv->dialog = NULL;
+    g_signal_emit (G_OBJECT (dkp), signals [SHUTDOWN], 0);
+}
+
+static void
 xfpm_dkp_battery_info_cb (GtkStatusIcon *icon)
 {
     xfpm_battery_show_info (XFPM_BATTERY (icon));
@@ -570,12 +579,11 @@ static void
 xfpm_dkp_notify_action_callback (NotifyNotification *n, gchar *action, XfpmDkp *dkp)
 {
     if ( !g_strcmp0 (action, "Shutdown") )
-	;
+	g_signal_emit (G_OBJECT (dkp), signals [SHUTDOWN], 0);
     else
 	xfpm_dkp_sleep (dkp, action, TRUE);
 }
 
-
 static void
 xfpm_dkp_add_actions_to_notification (XfpmDkp *dkp, NotifyNotification *n)
 {
@@ -600,7 +608,14 @@ xfpm_dkp_add_actions_to_notification (XfpmDkp *dkp, NotifyNotification *n)
                                (NotifyActionCallback)xfpm_dkp_notify_action_callback,
                                dkp);      
     }
-    //FIXME, Shutdown
+    
+    xfpm_notify_add_action_to_notification(
+			       dkp->priv->notify,
+			       n,
+                               "Shutdown",
+                               _("Shutdown the system"),
+                               (NotifyActionCallback)xfpm_dkp_notify_action_callback,
+                               dkp);    
 }
 
 static void
@@ -680,6 +695,18 @@ xfpm_dkp_show_critical_action_gtk (XfpmDkp *dkp)
 			          G_CALLBACK (xfpm_dkp_suspend_clicked), dkp);
     }
     
+    {
+	GtkWidget *shutdown;
+	
+	shutdown = gtk_button_new_with_label (_("Shutdown"));
+	img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_BUTTON);
+	gtk_button_set_image (GTK_BUTTON (shutdown), img);
+	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), shutdown, GTK_RESPONSE_NONE);
+	
+	g_signal_connect_swapped (shutdown, "clicked",
+			          G_CALLBACK (xfpm_dkp_shutdown_clicked), dkp);
+    }
+    
     cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
     gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancel, GTK_RESPONSE_NONE);
     
@@ -722,8 +749,8 @@ xfpm_dkp_process_critical_action (XfpmDkp *dkp, XfpmShutdownRequest req)
 	xfpm_dkp_sleep (dkp, "Suspend", TRUE);
     else if ( req == XFPM_DO_HIBERNATE )
 	xfpm_dkp_sleep (dkp, "Hibernate", TRUE);
-    //FIXME, Shutdown also.
-    
+    else if ( req == XFPM_DO_SHUTDOWN )
+	g_signal_emit (G_OBJECT (dkp), signals [SHUTDOWN], 0);
 }
 
 static void
@@ -1019,6 +1046,15 @@ xfpm_dkp_class_init (XfpmDkpClass *klass)
                       g_cclosure_marshal_VOID__VOID,
                       G_TYPE_NONE, 0, G_TYPE_NONE);
 
+    signals [SHUTDOWN] = 
+        g_signal_new ("shutdown",
+                      XFPM_TYPE_DKP,
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET(XfpmDkpClass, shutdown),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE, 0, G_TYPE_NONE);
+
     g_object_class_install_property (object_class,
                                      PROP_ON_BATTERY,
                                      g_param_spec_boolean ("on-battery",
diff --git a/src/xfpm-dkp.h b/src/xfpm-dkp.h
index e928831..8c5714b 100644
--- a/src/xfpm-dkp.h
+++ b/src/xfpm-dkp.h
@@ -89,6 +89,8 @@ typedef struct
     
     void		(*ask_shutdown)			(XfpmDkp *dkp);
     
+    void		(*shutdown)			(XfpmDkp *dkp);
+    
 } XfpmDkpClass;
 
 GType        		xfpm_dkp_get_type        	(void) G_GNUC_CONST;
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index 5366637..38b41da 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -169,6 +169,14 @@ xfpm_manager_reserve_names (XfpmManager *manager)
 }
 
 static void
+xfpm_manager_shutdown (XfpmManager *manager)
+{
+    //FIXME, try other solutions.
+    if ( manager->priv->session_managed )
+	xfce_sm_client_request_shutdown (manager->priv->client, XFCE_SM_CLIENT_SHUTDOWN_HINT_HALT);
+}
+
+static void
 xfpm_manager_ask_shutdown (XfpmManager *manager)
 {
     if ( manager->priv->session_managed )
@@ -189,7 +197,7 @@ xfpm_manager_sleep_request (XfpmManager *manager, XfpmShutdownRequest req, gbool
 	    xfpm_dkp_hibernate (manager->priv->dkp, force);
 	    break;
 	case XFPM_DO_SHUTDOWN:
-	    /*FIXME ConsoleKit*/
+	    xfpm_manager_shutdown (manager);
 	    break;
 	case XFPM_ASK:
 	    xfpm_manager_ask_shutdown (manager);
@@ -342,6 +350,7 @@ xfpm_manager_new (DBusGConnection *bus, const gchar *client_id)
     
     xfpm_manager_dbus_class_init (XFPM_MANAGER_GET_CLASS (manager));
     xfpm_manager_dbus_init (manager);
+    
     return manager;
 }
 
@@ -378,6 +387,10 @@ void xfpm_manager_start (XfpmManager *manager)
 			      
     g_signal_connect_swapped (manager->priv->dkp, "ask-shutdown",
 			      G_CALLBACK (xfpm_manager_ask_shutdown), manager);
+    
+    g_signal_connect_swapped (manager->priv->dkp, "shutdown",
+			      G_CALLBACK (xfpm_manager_shutdown), manager);
+			      
 out:
 	;
 }



More information about the Xfce4-commits mailing list