nautilus-cd-burner r2128 - in trunk: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-cd-burner r2128 - in trunk: . src
- Date: Mon, 21 Jan 2008 16:08:20 +0000 (GMT)
Author: mccann
Date: Mon Jan 21 16:08:20 2008
New Revision: 2128
URL: http://svn.gnome.org/viewvc/nautilus-cd-burner?rev=2128&view=rev
Log:
2008-01-21 William Jon McCann <mccann jhu edu>
* src/ncb-operation.c: (inhibit_suspend), (uninhibit_suspend),
(burn_cd):
Inihibit power management while burning.
Patch from: Martin Schoen <martin_schoen gmx de>
Fixes #344949
Modified:
trunk/ChangeLog
trunk/src/ncb-operation.c
Modified: trunk/src/ncb-operation.c
==============================================================================
--- trunk/src/ncb-operation.c (original)
+++ trunk/src/ncb-operation.c Mon Jan 21 16:08:20 2008
@@ -34,6 +34,8 @@
#include <gconf/gconf-client.h>
+#include <dbus/dbus-glib.h>
+
#include "nautilus-burn-drive.h"
#include "nautilus-burn-drive-monitor.h"
#include "nautilus-burn-recorder.h"
@@ -1588,6 +1590,101 @@
return TRUE;
}
+static guint
+inhibit_suspend (NcbOperation *operation) {
+ DBusGProxy *proxy;
+ DBusGConnection *conn = NULL;
+ gboolean result;
+ GError *error = NULL;
+ guint inhibit_cookie = 0;
+
+ conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_warning ("DBUS cannot connect : %s", error->message);
+ g_error_free (error);
+ }
+ if (conn != NULL) {
+ char *disc_name;
+ char *message;
+ NautilusBurnDrive *drive;
+ NautilusBurnMediaType media_type;
+
+ proxy = dbus_g_proxy_new_for_name (conn,
+ "org.freedesktop.PowerManagement",
+ "/org/freedesktop/PowerManagement/Inhibit",
+ "org.freedesktop.PowerManagement.Inhibit");
+ if (proxy != NULL) {
+ ncb_selection_get_label (operation->priv->selection, &disc_name);
+ drive = ncb_selection_peek_drive (operation->priv->selection);
+
+ if (nautilus_burn_drive_get_drive_type (drive) == NAUTILUS_BURN_DRIVE_TYPE_FILE) {
+ message = g_strdup_printf (_("Writing CD/DVD-Image \'%s\'."), disc_name);
+ }
+ media_type = nautilus_burn_drive_get_media_type (drive);
+ if (media_type == NAUTILUS_BURN_MEDIA_TYPE_BUSY
+ || media_type == NAUTILUS_BURN_MEDIA_TYPE_ERROR) {
+ message = g_strdup_printf (_("Writing disc \'%s\'."), disc_name);
+ } else {
+ message = g_strdup_printf (_("Writing %s \'%s\'."), nautilus_burn_drive_media_type_get_string (media_type), disc_name);
+ }
+
+ result = dbus_g_proxy_call (proxy,
+ "Inhibit",
+ &error,
+ G_TYPE_STRING,
+ _("CD/DVD Creator"),
+ G_TYPE_STRING,
+ message,
+ G_TYPE_INVALID,
+ G_TYPE_UINT,
+ &inhibit_cookie,
+ G_TYPE_INVALID);
+ g_free (message);
+ g_free (disc_name);
+ if (! result) {
+ g_warning ("Failed to inhibit the system from suspending: %s.", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (G_OBJECT (proxy));
+ }
+ }
+ return inhibit_cookie;
+}
+
+static void
+uninhibit_suspend (guint inhibit_cookie) {
+ DBusGProxy *proxy;
+ DBusGConnection *conn = NULL;
+ gboolean result;
+ GError *error = NULL;
+
+ conn = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_warning ("DBUS cannot connect : %s", error->message);
+ g_error_free (error);
+ }
+ if (conn != NULL) {
+ proxy = dbus_g_proxy_new_for_name (conn,
+ "org.freedesktop.PowerManagement",
+ "/org/freedesktop/PowerManagement/Inhibit",
+ "org.freedesktop.PowerManagement.Inhibit");
+ if (proxy != NULL) {
+ result = dbus_g_proxy_call (proxy,
+ "UnInhibit",
+ &error,
+ G_TYPE_UINT,
+ inhibit_cookie,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (! result) {
+ g_warning ("Failed to deactivate suspending inhibition: %s.", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (G_OBJECT (proxy));
+ }
+ }
+}
+
static int
burn_cd (NcbOperation *operation)
{
@@ -1595,6 +1692,9 @@
NautilusBurnDrive *drive;
NcbSelectionSource source_type;
char *source_name;
+ int inhibit_cookie;
+
+ inhibit_cookie = inhibit_suspend (operation);
drive = ncb_selection_peek_drive (operation->priv->selection);
@@ -1643,6 +1743,8 @@
out:
+ uninhibit_suspend (inhibit_cookie);
+
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]