[Pkg-wmaker-commits] [wmshutdown] 126/173: configure.ac, wmshutdown.c: Add --with-consolekit configure option to enable users wanting to use ConsoleKit instead of logind.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 02:46:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmshutdown.

commit bd277cf87c35dc8d71462bb104ad549cdd814155
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Sun Aug 17 05:13:08 2014 -0500

    configure.ac, wmshutdown.c: Add --with-consolekit configure option to enable
    users wanting to use ConsoleKit instead of logind.
---
 configure.ac | 10 ++++++++++
 wmshutdown.c | 28 ++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index ea209cd..e1b4222 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,6 +2,16 @@ AC_INIT([wmshutdown], [1.1], [dtorrance at monmouthcollege.edu])
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_HEADER([config.h])
+
+AC_ARG_WITH([consolekit],
+	[AS_HELP_STRING([--with-consolekit],
+		[use ConsoleKit instead of logind])],
+	[AC_DEFINE([CONSOLEKIT], 1,
+		[Define to 1 if ConsoleKit is used instead of logind.])
+	AC_MSG_NOTICE([use ConsoleKit])
+	],
+	[AC_MSG_NOTICE([use logind])])
+
 AC_PROG_CC
 PKG_CHECK_MODULES([gtk],[gtk+-3.0])
 PKG_CHECK_MODULES([x11],[x11])
diff --git a/wmshutdown.c b/wmshutdown.c
index 90d251a..964bf8d 100644
--- a/wmshutdown.c
+++ b/wmshutdown.c
@@ -24,6 +24,20 @@
 #include <config.h>
 #endif
 
+#ifdef CONSOLEKIT
+#define HALT_METHOD      "Stop"
+#define REBOOT_METHOD    "Restart"
+#define DBUS_PATH        "/org/freedesktop/ConsoleKit/Manager"
+#define DBUS_INTERFACE   "org.freedesktop.ConsoleKit.Manager"
+#define DBUS_DESTINATION "org.freedesktop.ConsoleKit"
+#else
+#define HALT_METHOD      "PowerOff"
+#define REBOOT_METHOD    "Reboot"
+#define DBUS_PATH        "/org/freedesktop/login1"
+#define DBUS_INTERFACE   "org.freedesktop.login1.Manager"
+#define DBUS_DESTINATION "org.freedesktop.login1"
+#endif
+
 static int showVersion = 0;
 GtkWidget *dialog = NULL;
 
@@ -92,15 +106,18 @@ void handle_click(GtkWidget *widget, gpointer data) {
 	connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
 	message = g_dbus_message_new_method_call(
 			NULL,
-			"/org/freedesktop/login1",
-			"org.freedesktop.login1.Manager",
+			DBUS_PATH,
+			DBUS_INTERFACE,
 			method);
+
+#ifndef CONSOLEKIT
 	g_dbus_message_set_body(message, g_variant_new("(b)", TRUE));
+#endif
 	gchar *status = g_dbus_message_print(message, 0);
 	g_printerr("sending following message:\n%s", status);
 	g_free(status);
 
-	g_dbus_message_set_destination(message, "org.freedesktop.login1");
+	g_dbus_message_set_destination(message, DBUS_DESTINATION);
 
 	reply = g_dbus_connection_send_message_with_reply_sync(
 		connection, message, 0, -1, NULL, NULL, &error);
@@ -143,11 +160,11 @@ void button_press(GtkWidget *widget, GdkEvent *event) {
 		g_signal_connect(halt_button,
 				 "clicked",
 				 G_CALLBACK(handle_click),
-				 "PowerOff");
+				 HALT_METHOD);
 		g_signal_connect(reboot_button,
 				 "clicked",
 				 G_CALLBACK(handle_click),
-				 "Reboot");
+				 REBOOT_METHOD);
 		gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(
 							GTK_DIALOG(dialog))),
 				  halt_button);
@@ -174,7 +191,6 @@ int main(int argc, char *argv[]) {
 
 	gtk_init(&argc, &argv);
 
-
 	context = g_option_context_new ("- dockapp to shutdown or reboot your "
 					"machine");
 	g_option_context_add_main_entries (context, entries, NULL);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmshutdown.git



More information about the Pkg-wmaker-commits mailing list