|
|
b31790 |
From 916d9ba86cf2020ffedff331397ed02b5e53f030 Mon Sep 17 00:00:00 2001
|
|
|
b31790 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
b31790 |
Date: Wed, 8 Mar 2017 16:36:44 -0500
|
|
|
b31790 |
Subject: [PATCH 18/19] manager: port away from dbus-glib to GDBus
|
|
|
b31790 |
|
|
|
b31790 |
---
|
|
|
b31790 |
capplet/gsm-properties-dialog.c | 52 +++++++++++++++++++++--------------------
|
|
|
b31790 |
configure.ac | 2 +-
|
|
|
b31790 |
gnome-session/gsm-manager.c | 16 ++++++-------
|
|
|
b31790 |
gnome-session/gsm-manager.h | 3 ++-
|
|
|
b31790 |
tools/gnome-session-selector.c | 48 ++++++++++++++++++++-----------------
|
|
|
b31790 |
5 files changed, 64 insertions(+), 57 deletions(-)
|
|
|
b31790 |
|
|
|
b31790 |
diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c
|
|
|
b31790 |
index 51fa5106..04452c1a 100644
|
|
|
b31790 |
--- a/capplet/gsm-properties-dialog.c
|
|
|
b31790 |
+++ b/capplet/gsm-properties-dialog.c
|
|
|
b31790 |
@@ -1,66 +1,66 @@
|
|
|
b31790 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
|
|
b31790 |
*
|
|
|
b31790 |
* Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
b31790 |
* Copyright (C) 2007 Vincent Untz.
|
|
|
b31790 |
* Copyright (C) 2008 Lucas Rocha.
|
|
|
b31790 |
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
|
|
|
b31790 |
*
|
|
|
b31790 |
* This program is free software; you can redistribute it and/or modify
|
|
|
b31790 |
* it under the terms of the GNU General Public License as published by
|
|
|
b31790 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
b31790 |
* (at your option) any later version.
|
|
|
b31790 |
*
|
|
|
b31790 |
* This program is distributed in the hope that it will be useful,
|
|
|
b31790 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b31790 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b31790 |
* GNU General Public License for more details.
|
|
|
b31790 |
*
|
|
|
b31790 |
* You should have received a copy of the GNU General Public License
|
|
|
b31790 |
* along with this program; if not, write to the Free Software
|
|
|
b31790 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
b31790 |
*
|
|
|
b31790 |
*/
|
|
|
b31790 |
|
|
|
b31790 |
#include "config.h"
|
|
|
b31790 |
|
|
|
b31790 |
#include <glib.h>
|
|
|
b31790 |
#include <glib/gi18n.h>
|
|
|
b31790 |
#include <gtk/gtk.h>
|
|
|
b31790 |
|
|
|
b31790 |
+#include <gio/gio.h>
|
|
|
b31790 |
+
|
|
|
b31790 |
#include "gsm-properties-dialog.h"
|
|
|
b31790 |
#include "gsm-app-dialog.h"
|
|
|
b31790 |
#include "gsm-util.h"
|
|
|
b31790 |
#include "gsp-app.h"
|
|
|
b31790 |
#include "gsp-app-manager.h"
|
|
|
b31790 |
-#include <dbus/dbus-glib.h>
|
|
|
b31790 |
-#include <dbus/dbus-glib-lowlevel.h>
|
|
|
b31790 |
|
|
|
b31790 |
#define GSM_SERVICE_DBUS "org.gnome.SessionManager"
|
|
|
b31790 |
#define GSM_PATH_DBUS "/org/gnome/SessionManager"
|
|
|
b31790 |
#define GSM_INTERFACE_DBUS "org.gnome.SessionManager"
|
|
|
b31790 |
|
|
|
b31790 |
#define GSM_PROPERTIES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_PROPERTIES_DIALOG, GsmPropertiesDialogPrivate))
|
|
|
b31790 |
|
|
|
b31790 |
#define GTKBUILDER_FILE "session-properties.ui"
|
|
|
b31790 |
|
|
|
b31790 |
#define CAPPLET_TREEVIEW_WIDGET_NAME "session_properties_treeview"
|
|
|
b31790 |
#define CAPPLET_ADD_WIDGET_NAME "session_properties_add_button"
|
|
|
b31790 |
#define CAPPLET_DELETE_WIDGET_NAME "session_properties_delete_button"
|
|
|
b31790 |
#define CAPPLET_EDIT_WIDGET_NAME "session_properties_edit_button"
|
|
|
b31790 |
#define CAPPLET_SAVE_WIDGET_NAME "session_properties_save_button"
|
|
|
b31790 |
#define CAPPLET_SESSION_SAVED_WIDGET_NAME "session_properties_session_saved_label"
|
|
|
b31790 |
#define CAPPLET_REMEMBER_WIDGET_NAME "session_properties_remember_toggle"
|
|
|
b31790 |
|
|
|
b31790 |
#define STARTUP_APP_ICON "system-run"
|
|
|
b31790 |
|
|
|
b31790 |
#define SPC_SETTINGS_SCHEMA "org.gnome.SessionManager"
|
|
|
b31790 |
#define SPC_SETTINGS_AUTOSAVE_KEY "auto-save-session"
|
|
|
b31790 |
|
|
|
b31790 |
struct GsmPropertiesDialogPrivate
|
|
|
b31790 |
{
|
|
|
b31790 |
GtkBuilder *xml;
|
|
|
b31790 |
GtkListStore *list_store;
|
|
|
b31790 |
GtkTreeModel *tree_filter;
|
|
|
b31790 |
|
|
|
b31790 |
GtkTreeView *treeview;
|
|
|
b31790 |
GtkWidget *add_button;
|
|
|
b31790 |
@@ -454,101 +454,103 @@ on_edit_app_clicked (GtkWidget *widget,
|
|
|
b31790 |
g_object_unref (app);
|
|
|
b31790 |
}
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
on_row_activated (GtkTreeView *tree_view,
|
|
|
b31790 |
GtkTreePath *path,
|
|
|
b31790 |
GtkTreeViewColumn *column,
|
|
|
b31790 |
GsmPropertiesDialog *dialog)
|
|
|
b31790 |
{
|
|
|
b31790 |
on_edit_app_clicked (NULL, dialog);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
session_saved_message (GsmPropertiesDialog *dialog,
|
|
|
b31790 |
const char *msg,
|
|
|
b31790 |
gboolean is_error)
|
|
|
b31790 |
{
|
|
|
b31790 |
GtkLabel *label;
|
|
|
b31790 |
gchar *markup;
|
|
|
b31790 |
label = GTK_LABEL (gtk_builder_get_object (dialog->priv->xml, CAPPLET_SESSION_SAVED_WIDGET_NAME));
|
|
|
b31790 |
if (is_error)
|
|
|
b31790 |
markup = g_markup_printf_escaped ("%s", msg);
|
|
|
b31790 |
else
|
|
|
b31790 |
markup = g_markup_escape_text (msg, -1);
|
|
|
b31790 |
gtk_label_set_markup (label, markup);
|
|
|
b31790 |
g_free (markup);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
-session_saved_cb (DBusGProxy *proxy,
|
|
|
b31790 |
- DBusGProxyCall *call_id,
|
|
|
b31790 |
- void *user_data)
|
|
|
b31790 |
+session_saved_cb (GDBusConnection *conn,
|
|
|
b31790 |
+ GAsyncResult *result,
|
|
|
b31790 |
+ gpointer user_data)
|
|
|
b31790 |
{
|
|
|
b31790 |
- gboolean res;
|
|
|
b31790 |
+ GVariant *reply;
|
|
|
b31790 |
GsmPropertiesDialog *dialog = user_data;
|
|
|
b31790 |
+ GError *error = NULL;
|
|
|
b31790 |
|
|
|
b31790 |
- res = dbus_g_proxy_end_call (proxy, call_id, NULL, G_TYPE_INVALID);
|
|
|
b31790 |
- if (res)
|
|
|
b31790 |
+ reply = g_dbus_connection_call_finish (conn, result, &error);
|
|
|
b31790 |
+ if (error == NULL)
|
|
|
b31790 |
session_saved_message (dialog, _("Your session has been saved."), FALSE);
|
|
|
b31790 |
else
|
|
|
b31790 |
session_saved_message (dialog, _("Failed to save session"), TRUE);
|
|
|
b31790 |
|
|
|
b31790 |
- g_object_unref (proxy);
|
|
|
b31790 |
+ g_clear_error (&error);
|
|
|
b31790 |
+
|
|
|
b31790 |
+ g_variant_unref (reply);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
save_session_directly (GsmPropertiesDialog *dialog)
|
|
|
b31790 |
{
|
|
|
b31790 |
- DBusGConnection *conn;
|
|
|
b31790 |
- DBusGProxy *proxy;
|
|
|
b31790 |
- DBusGProxyCall *call;
|
|
|
b31790 |
+ GDBusConnection *conn;
|
|
|
b31790 |
|
|
|
b31790 |
- conn = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
|
|
b31790 |
+ conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
|
|
b31790 |
if (conn == NULL) {
|
|
|
b31790 |
session_saved_message (dialog, _("Could not connect to the session bus"), TRUE);
|
|
|
b31790 |
return;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
- proxy = dbus_g_proxy_new_for_name (conn, GSM_SERVICE_DBUS, GSM_PATH_DBUS, GSM_INTERFACE_DBUS);
|
|
|
b31790 |
- if (proxy == NULL) {
|
|
|
b31790 |
- session_saved_message (dialog, _("Could not connect to the session manager"), TRUE);
|
|
|
b31790 |
- return;
|
|
|
b31790 |
- }
|
|
|
b31790 |
-
|
|
|
b31790 |
- call = dbus_g_proxy_begin_call (proxy, "SaveSession", session_saved_cb, dialog, NULL, G_TYPE_INVALID);
|
|
|
b31790 |
- if (call == NULL) {
|
|
|
b31790 |
- session_saved_message (dialog, _("Failed to save session"), TRUE);
|
|
|
b31790 |
- g_object_unref (proxy);
|
|
|
b31790 |
- return;
|
|
|
b31790 |
- }
|
|
|
b31790 |
+ g_dbus_connection_call (conn,
|
|
|
b31790 |
+ GSM_SERVICE_DBUS,
|
|
|
b31790 |
+ GSM_PATH_DBUS,
|
|
|
b31790 |
+ GSM_INTERFACE_DBUS,
|
|
|
b31790 |
+ "SaveSession",
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ G_DBUS_CALL_FLAGS_NONE,
|
|
|
b31790 |
+ -1,
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ (GAsyncReadyCallback)
|
|
|
b31790 |
+ session_saved_cb,
|
|
|
b31790 |
+ dialog);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
save_session_from_selector (GsmPropertiesDialog *dialog,
|
|
|
b31790 |
const char *program_path)
|
|
|
b31790 |
{
|
|
|
b31790 |
char *command_line = g_strdup_printf ("%s --action save", program_path);
|
|
|
b31790 |
|
|
|
b31790 |
g_spawn_command_line_sync (command_line, NULL, NULL, NULL, NULL);
|
|
|
b31790 |
|
|
|
b31790 |
g_free (command_line);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
on_save_session_clicked (GtkWidget *widget,
|
|
|
b31790 |
GsmPropertiesDialog *dialog)
|
|
|
b31790 |
{
|
|
|
b31790 |
char *program_path;
|
|
|
b31790 |
|
|
|
b31790 |
program_path = g_find_program_in_path ("gnome-session-selector");
|
|
|
b31790 |
|
|
|
b31790 |
if (program_path != NULL) {
|
|
|
b31790 |
save_session_from_selector (dialog, program_path);
|
|
|
b31790 |
g_free (program_path);
|
|
|
b31790 |
} else {
|
|
|
b31790 |
save_session_directly (dialog);
|
|
|
b31790 |
}
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
diff --git a/configure.ac b/configure.ac
|
|
|
b31790 |
index d0eeab8a..5182c09e 100644
|
|
|
b31790 |
--- a/configure.ac
|
|
|
b31790 |
+++ b/configure.ac
|
|
|
b31790 |
@@ -21,61 +21,61 @@ LT_PREREQ([2.2.6])
|
|
|
b31790 |
LT_INIT([dlopen disable-static])
|
|
|
b31790 |
|
|
|
b31790 |
GNOME_MAINTAINER_MODE_DEFINES
|
|
|
b31790 |
GNOME_COMPILE_WARNINGS([maximum])
|
|
|
b31790 |
|
|
|
b31790 |
AC_ARG_ENABLE(deprecation_flags,
|
|
|
b31790 |
[AS_HELP_STRING([--enable-deprecation-flags],
|
|
|
b31790 |
[use *_DISABLE_DEPRECATED flags @<:@default=no@:>@])],,
|
|
|
b31790 |
[enable_deprecation_flags=no])
|
|
|
b31790 |
|
|
|
b31790 |
if test "x$enable_deprecation_flags" = "xyes"; then
|
|
|
b31790 |
DISABLE_DEPRECATED_CFLAGS=$DISABLE_DEPRECATED
|
|
|
b31790 |
AC_SUBST([DISABLE_DEPRECATED_CFLAGS])
|
|
|
b31790 |
fi
|
|
|
b31790 |
|
|
|
b31790 |
GLIB_REQUIRED=2.46.0
|
|
|
b31790 |
GTK3_REQUIRED=3.18.0
|
|
|
b31790 |
DBUS_GLIB_REQUIRED=0.76
|
|
|
b31790 |
UPOWER_REQUIRED=0.9.0
|
|
|
b31790 |
JSON_GLIB_REQUIRED=0.10
|
|
|
b31790 |
GNOME_DESKTOP_REQUIRED=3.18.0
|
|
|
b31790 |
|
|
|
b31790 |
AC_ARG_ENABLE(session-selector, AS_HELP_STRING([--enable-session-selector],
|
|
|
b31790 |
[enable building a custom session selector dialog]),
|
|
|
b31790 |
enable_session_selector=$enableval,enable_session_selector=no)
|
|
|
b31790 |
|
|
|
b31790 |
AM_CONDITIONAL(BUILD_SESSION_SELECTOR,
|
|
|
b31790 |
[test "$enable_session_selector" = yes])
|
|
|
b31790 |
|
|
|
b31790 |
if test "$enable_session_selector" = yes; then
|
|
|
b31790 |
- PKG_CHECK_MODULES(SESSION_SELECTOR, gtk+-3.0 gio-2.0 dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
|
|
|
b31790 |
+ PKG_CHECK_MODULES(SESSION_SELECTOR, gtk+-3.0 gio-2.0)
|
|
|
b31790 |
fi
|
|
|
b31790 |
|
|
|
b31790 |
dnl ====================================================================
|
|
|
b31790 |
dnl Dependency Checks
|
|
|
b31790 |
dnl ====================================================================
|
|
|
b31790 |
|
|
|
b31790 |
dnl Standard vertical stacks
|
|
|
b31790 |
PKG_CHECK_MODULES(GIO, gio-2.0)
|
|
|
b31790 |
PKG_CHECK_MODULES(GIOUNIX, gio-unix-2.0 >= $GLIB_REQUIRED)
|
|
|
b31790 |
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= $GTK3_REQUIRED)
|
|
|
b31790 |
|
|
|
b31790 |
PKG_CHECK_MODULES(GNOME_SESSION,
|
|
|
b31790 |
glib-2.0 >= $GLIB_REQUIRED
|
|
|
b31790 |
gio-2.0 >= $GLIB_REQUIRED
|
|
|
b31790 |
json-glib-1.0 >= $JSON_GLIB_REQUIRED
|
|
|
b31790 |
gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED
|
|
|
b31790 |
)
|
|
|
b31790 |
|
|
|
b31790 |
dnl We can only support old upower
|
|
|
b31790 |
dnl https://bugzilla.gnome.org/show_bug.cgi?id=710383
|
|
|
b31790 |
PKG_CHECK_MODULES(UPOWER, upower-glib < 0.99.0, have_old_upower=yes, have_old_upower=no)
|
|
|
b31790 |
AS_IF([test x$have_old_upower = xyes], [
|
|
|
b31790 |
AC_DEFINE([HAVE_OLD_UPOWER], [1], [Define if we have an older upower])
|
|
|
b31790 |
])
|
|
|
b31790 |
AM_CONDITIONAL(HAVE_OLD_UPOWER, test x$have_old_upower = xyes)
|
|
|
b31790 |
|
|
|
b31790 |
PKG_CHECK_MODULES(SESSION_PROPERTIES,
|
|
|
b31790 |
glib-2.0 >= $GLIB_REQUIRED
|
|
|
b31790 |
gtk+-3.0 >= $GTK3_REQUIRED
|
|
|
b31790 |
)
|
|
|
b31790 |
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
|
|
|
b31790 |
index 135392fd..29c3054d 100644
|
|
|
b31790 |
--- a/gnome-session/gsm-manager.c
|
|
|
b31790 |
+++ b/gnome-session/gsm-manager.c
|
|
|
b31790 |
@@ -1210,78 +1210,78 @@ _client_request_save (GsmClient *client,
|
|
|
b31790 |
|
|
|
b31790 |
error = NULL;
|
|
|
b31790 |
ret = gsm_client_request_save (client, data->flags, &error);
|
|
|
b31790 |
if (ret) {
|
|
|
b31790 |
g_debug ("GsmManager: adding client to query clients: %s", gsm_client_peek_id (client));
|
|
|
b31790 |
data->manager->priv->query_clients = g_slist_prepend (data->manager->priv->query_clients,
|
|
|
b31790 |
client);
|
|
|
b31790 |
} else if (error) {
|
|
|
b31790 |
g_debug ("GsmManager: unable to query client: %s", error->message);
|
|
|
b31790 |
g_error_free (error);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
return FALSE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static gboolean
|
|
|
b31790 |
_client_request_save_helper (const char *id,
|
|
|
b31790 |
GsmClient *client,
|
|
|
b31790 |
ClientEndSessionData *data)
|
|
|
b31790 |
{
|
|
|
b31790 |
return _client_request_save (client, data);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
fail_pending_save_invocations (GsmManager *manager,
|
|
|
b31790 |
GError *error)
|
|
|
b31790 |
{
|
|
|
b31790 |
GSList *l;
|
|
|
b31790 |
|
|
|
b31790 |
for (l = manager->priv->pending_save_invocations; l != NULL; l = l->next) {
|
|
|
b31790 |
- DBusGMethodInvocation *context = l->data;
|
|
|
b31790 |
+ GDBusMethodInvocation *invocation = l->data;
|
|
|
b31790 |
|
|
|
b31790 |
- dbus_g_method_return_error (context, error);
|
|
|
b31790 |
+ g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
g_slist_free (manager->priv->pending_save_invocations);
|
|
|
b31790 |
manager->priv->pending_save_invocations = NULL;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
finish_pending_save_invocations (GsmManager *manager)
|
|
|
b31790 |
{
|
|
|
b31790 |
GSList *l;
|
|
|
b31790 |
|
|
|
b31790 |
for (l = manager->priv->pending_save_invocations; l != NULL; l = l->next) {
|
|
|
b31790 |
- DBusGMethodInvocation *context = l->data;
|
|
|
b31790 |
+ GDBusMethodInvocation *invocation = l->data;
|
|
|
b31790 |
|
|
|
b31790 |
- dbus_g_method_return (context);
|
|
|
b31790 |
+ g_dbus_method_invocation_return_value (invocation, NULL);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
g_slist_free (manager->priv->pending_save_invocations);
|
|
|
b31790 |
manager->priv->pending_save_invocations = NULL;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
query_save_session_complete (GsmManager *manager)
|
|
|
b31790 |
{
|
|
|
b31790 |
GError *error = NULL;
|
|
|
b31790 |
|
|
|
b31790 |
if (g_slist_length (manager->priv->next_query_clients) > 0) {
|
|
|
b31790 |
ClientEndSessionData data;
|
|
|
b31790 |
|
|
|
b31790 |
data.manager = manager;
|
|
|
b31790 |
data.flags = GSM_CLIENT_END_SESSION_FLAG_LAST;
|
|
|
b31790 |
|
|
|
b31790 |
g_slist_foreach (manager->priv->next_query_clients,
|
|
|
b31790 |
(GFunc)_client_request_save,
|
|
|
b31790 |
&data);
|
|
|
b31790 |
|
|
|
b31790 |
g_slist_free (manager->priv->next_query_clients);
|
|
|
b31790 |
manager->priv->next_query_clients = NULL;
|
|
|
b31790 |
|
|
|
b31790 |
return;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
if (manager->priv->query_timeout_id > 0) {
|
|
|
b31790 |
g_source_remove (manager->priv->query_timeout_id);
|
|
|
b31790 |
manager->priv->query_timeout_id = 0;
|
|
|
b31790 |
@@ -2790,96 +2790,96 @@ gsm_manager_initialization_error (GsmExportedManager *skeleton,
|
|
|
b31790 |
{
|
|
|
b31790 |
if (manager->priv->phase != GSM_MANAGER_PHASE_INITIALIZATION) {
|
|
|
b31790 |
g_dbus_method_invocation_return_error (invocation,
|
|
|
b31790 |
GSM_MANAGER_ERROR,
|
|
|
b31790 |
GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION,
|
|
|
b31790 |
"InitializationError interface is only available during the Initialization phase");
|
|
|
b31790 |
return TRUE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
gsm_util_init_error (fatal, "%s", message);
|
|
|
b31790 |
gsm_exported_manager_complete_initialization_error (skeleton, invocation);
|
|
|
b31790 |
|
|
|
b31790 |
return TRUE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
user_logout (GsmManager *manager,
|
|
|
b31790 |
GsmManagerLogoutMode mode)
|
|
|
b31790 |
{
|
|
|
b31790 |
if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
|
|
|
b31790 |
manager->priv->logout_mode = mode;
|
|
|
b31790 |
end_session_or_show_shell_dialog (manager);
|
|
|
b31790 |
return;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
request_logout (manager, mode);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
gboolean
|
|
|
b31790 |
gsm_manager_save_session (GsmManager *manager,
|
|
|
b31790 |
- DBusGMethodInvocation *context)
|
|
|
b31790 |
+ GDBusMethodInvocation *invocation)
|
|
|
b31790 |
{
|
|
|
b31790 |
ClientEndSessionData data;
|
|
|
b31790 |
GError *error;
|
|
|
b31790 |
|
|
|
b31790 |
g_debug ("GsmManager: SaveSession called");
|
|
|
b31790 |
|
|
|
b31790 |
g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
|
|
|
b31790 |
|
|
|
b31790 |
if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) {
|
|
|
b31790 |
error = g_error_new (GSM_MANAGER_ERROR,
|
|
|
b31790 |
GSM_MANAGER_ERROR_NOT_IN_RUNNING,
|
|
|
b31790 |
"SaveSession interface is only available during the Running phase");
|
|
|
b31790 |
- dbus_g_method_return_error (context, error);
|
|
|
b31790 |
+ g_dbus_method_invocation_return_gerror (invocation, error);
|
|
|
b31790 |
g_error_free (error);
|
|
|
b31790 |
return FALSE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
data.manager = manager;
|
|
|
b31790 |
data.flags = 0;
|
|
|
b31790 |
gsm_store_foreach (manager->priv->clients,
|
|
|
b31790 |
(GsmStoreFunc)_client_request_save_helper,
|
|
|
b31790 |
&data);
|
|
|
b31790 |
|
|
|
b31790 |
if (manager->priv->query_clients) {
|
|
|
b31790 |
manager->priv->query_timeout_id = g_timeout_add_seconds (GSM_MANAGER_SAVE_SESSION_TIMEOUT,
|
|
|
b31790 |
(GSourceFunc)_on_query_save_session_timeout,
|
|
|
b31790 |
manager);
|
|
|
b31790 |
|
|
|
b31790 |
manager->priv->pending_save_invocations = g_slist_prepend (manager->priv->pending_save_invocations,
|
|
|
b31790 |
- context);
|
|
|
b31790 |
+ invocation);
|
|
|
b31790 |
|
|
|
b31790 |
return TRUE;
|
|
|
b31790 |
} else {
|
|
|
b31790 |
g_debug ("GsmManager: Nothing to save");
|
|
|
b31790 |
- dbus_g_method_return (context);
|
|
|
b31790 |
+ g_dbus_method_invocation_return_value (invocation, NULL);
|
|
|
b31790 |
return TRUE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
return TRUE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
gboolean
|
|
|
b31790 |
gsm_manager_logout (GsmManager *manager,
|
|
|
b31790 |
guint logout_mode,
|
|
|
b31790 |
GError **error)
|
|
|
b31790 |
{
|
|
|
b31790 |
if (manager->priv->phase < GSM_MANAGER_PHASE_RUNNING) {
|
|
|
b31790 |
g_set_error (error,
|
|
|
b31790 |
GSM_MANAGER_ERROR,
|
|
|
b31790 |
GSM_MANAGER_ERROR_NOT_IN_RUNNING,
|
|
|
b31790 |
"Logout interface is only available after the Running phase starts");
|
|
|
b31790 |
return FALSE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
if (_log_out_is_locked_down (manager)) {
|
|
|
b31790 |
g_set_error (error,
|
|
|
b31790 |
GSM_MANAGER_ERROR,
|
|
|
b31790 |
GSM_MANAGER_ERROR_LOCKED_DOWN,
|
|
|
b31790 |
"Logout has been locked down");
|
|
|
b31790 |
return FALSE;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
switch (logout_mode) {
|
|
|
b31790 |
case GSM_MANAGER_LOGOUT_MODE_NORMAL:
|
|
|
b31790 |
case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION:
|
|
|
b31790 |
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
|
|
|
b31790 |
index fcf36019..88a88ccc 100644
|
|
|
b31790 |
--- a/gnome-session/gsm-manager.h
|
|
|
b31790 |
+++ b/gnome-session/gsm-manager.h
|
|
|
b31790 |
@@ -1,54 +1,55 @@
|
|
|
b31790 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
|
|
b31790 |
*
|
|
|
b31790 |
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
|
|
|
b31790 |
*
|
|
|
b31790 |
* This program is free software; you can redistribute it and/or modify
|
|
|
b31790 |
* it under the terms of the GNU General Public License as published by
|
|
|
b31790 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
b31790 |
* (at your option) any later version.
|
|
|
b31790 |
*
|
|
|
b31790 |
* This program is distributed in the hope that it will be useful,
|
|
|
b31790 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b31790 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b31790 |
* GNU General Public License for more details.
|
|
|
b31790 |
*
|
|
|
b31790 |
* You should have received a copy of the GNU General Public License
|
|
|
b31790 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
b31790 |
*
|
|
|
b31790 |
*/
|
|
|
b31790 |
|
|
|
b31790 |
|
|
|
b31790 |
#ifndef __GSM_MANAGER_H
|
|
|
b31790 |
#define __GSM_MANAGER_H
|
|
|
b31790 |
|
|
|
b31790 |
#include <glib-object.h>
|
|
|
b31790 |
+#include <gio/gio.h>
|
|
|
b31790 |
|
|
|
b31790 |
#include "gsm-store.h"
|
|
|
b31790 |
#include "gsm-manager-logout-mode.h"
|
|
|
b31790 |
|
|
|
b31790 |
G_BEGIN_DECLS
|
|
|
b31790 |
|
|
|
b31790 |
#define GSM_TYPE_MANAGER (gsm_manager_get_type ())
|
|
|
b31790 |
#define GSM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_MANAGER, GsmManager))
|
|
|
b31790 |
#define GSM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_MANAGER, GsmManagerClass))
|
|
|
b31790 |
#define GSM_IS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_MANAGER))
|
|
|
b31790 |
#define GSM_IS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_MANAGER))
|
|
|
b31790 |
#define GSM_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_MANAGER, GsmManagerClass))
|
|
|
b31790 |
|
|
|
b31790 |
typedef struct GsmManagerPrivate GsmManagerPrivate;
|
|
|
b31790 |
|
|
|
b31790 |
typedef struct
|
|
|
b31790 |
{
|
|
|
b31790 |
GObject parent;
|
|
|
b31790 |
GsmManagerPrivate *priv;
|
|
|
b31790 |
} GsmManager;
|
|
|
b31790 |
|
|
|
b31790 |
typedef struct
|
|
|
b31790 |
{
|
|
|
b31790 |
GObjectClass parent_class;
|
|
|
b31790 |
|
|
|
b31790 |
void (* phase_changed) (GsmManager *manager,
|
|
|
b31790 |
const char *phase);
|
|
|
b31790 |
} GsmManagerClass;
|
|
|
b31790 |
|
|
|
b31790 |
typedef enum {
|
|
|
b31790 |
@@ -98,42 +99,42 @@ GType gsm_manager_get_type (void);
|
|
|
b31790 |
GsmManager * gsm_manager_new (GsmStore *client_store,
|
|
|
b31790 |
gboolean failsafe);
|
|
|
b31790 |
GsmManager * gsm_manager_get (void);
|
|
|
b31790 |
|
|
|
b31790 |
gboolean gsm_manager_get_failsafe (GsmManager *manager);
|
|
|
b31790 |
|
|
|
b31790 |
gboolean gsm_manager_add_autostart_app (GsmManager *manager,
|
|
|
b31790 |
const char *path,
|
|
|
b31790 |
const char *provides);
|
|
|
b31790 |
gboolean gsm_manager_add_required_app (GsmManager *manager,
|
|
|
b31790 |
const char *path,
|
|
|
b31790 |
const char *provides);
|
|
|
b31790 |
gboolean gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
|
|
|
b31790 |
const char *path);
|
|
|
b31790 |
gboolean gsm_manager_add_legacy_session_apps (GsmManager *manager,
|
|
|
b31790 |
const char *path);
|
|
|
b31790 |
|
|
|
b31790 |
void gsm_manager_start (GsmManager *manager);
|
|
|
b31790 |
|
|
|
b31790 |
const char * _gsm_manager_get_default_session (GsmManager *manager);
|
|
|
b31790 |
char * _gsm_manager_get_saved_session (GsmManager *manager);
|
|
|
b31790 |
|
|
|
b31790 |
void _gsm_manager_set_active_session (GsmManager *manager,
|
|
|
b31790 |
const char *session_name,
|
|
|
b31790 |
gboolean is_fallback);
|
|
|
b31790 |
|
|
|
b31790 |
void _gsm_manager_set_renderer (GsmManager *manager,
|
|
|
b31790 |
const char *renderer);
|
|
|
b31790 |
|
|
|
b31790 |
gboolean gsm_manager_save_session (GsmManager *manager,
|
|
|
b31790 |
- DBusGMethodInvocation *context);
|
|
|
b31790 |
+ GDBusMethodInvocation *context);
|
|
|
b31790 |
|
|
|
b31790 |
gboolean gsm_manager_logout (GsmManager *manager,
|
|
|
b31790 |
guint logout_mode,
|
|
|
b31790 |
GError **error);
|
|
|
b31790 |
|
|
|
b31790 |
gboolean gsm_manager_set_phase (GsmManager *manager,
|
|
|
b31790 |
GsmManagerPhase phase);
|
|
|
b31790 |
|
|
|
b31790 |
G_END_DECLS
|
|
|
b31790 |
|
|
|
b31790 |
#endif /* __GSM_MANAGER_H */
|
|
|
b31790 |
diff --git a/tools/gnome-session-selector.c b/tools/gnome-session-selector.c
|
|
|
b31790 |
index a41cd260..6ad307b0 100644
|
|
|
b31790 |
--- a/tools/gnome-session-selector.c
|
|
|
b31790 |
+++ b/tools/gnome-session-selector.c
|
|
|
b31790 |
@@ -7,63 +7,60 @@
|
|
|
b31790 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
b31790 |
* (at your option) any later version.
|
|
|
b31790 |
*
|
|
|
b31790 |
* This program is distributed in the hope that it will be useful,
|
|
|
b31790 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b31790 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b31790 |
* GNU General Public License for more details.
|
|
|
b31790 |
*
|
|
|
b31790 |
* You should have received a copy of the GNU General Public License
|
|
|
b31790 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
b31790 |
*
|
|
|
b31790 |
* Written by: Matthias Clasen <mclasen@redhat.com>
|
|
|
b31790 |
*/
|
|
|
b31790 |
|
|
|
b31790 |
#include "config.h"
|
|
|
b31790 |
|
|
|
b31790 |
#include <fcntl.h>
|
|
|
b31790 |
#include <stdlib.h>
|
|
|
b31790 |
#include <string.h>
|
|
|
b31790 |
#include <sys/types.h>
|
|
|
b31790 |
#include <sys/stat.h>
|
|
|
b31790 |
#include <unistd.h>
|
|
|
b31790 |
|
|
|
b31790 |
#include <glib.h>
|
|
|
b31790 |
#include <gtk/gtk.h>
|
|
|
b31790 |
#include <gio/gio.h>
|
|
|
b31790 |
|
|
|
b31790 |
#include <glib/gi18n.h>
|
|
|
b31790 |
#include <glib/gstdio.h>
|
|
|
b31790 |
|
|
|
b31790 |
-#include <dbus/dbus-glib.h>
|
|
|
b31790 |
-#include <dbus/dbus-glib-lowlevel.h>
|
|
|
b31790 |
-
|
|
|
b31790 |
#define GSM_SERVICE_DBUS "org.gnome.SessionManager"
|
|
|
b31790 |
#define GSM_PATH_DBUS "/org/gnome/SessionManager"
|
|
|
b31790 |
#define GSM_INTERFACE_DBUS "org.gnome.SessionManager"
|
|
|
b31790 |
|
|
|
b31790 |
#define GSM_MANAGER_SCHEMA "org.gnome.SessionManager"
|
|
|
b31790 |
#define KEY_AUTOSAVE_ONE_SHOT "auto-save-session-one-shot"
|
|
|
b31790 |
#define DEFAULT_SESSION_NAME "gnome-classic"
|
|
|
b31790 |
|
|
|
b31790 |
static GtkBuilder *builder;
|
|
|
b31790 |
static GtkWidget *session_list;
|
|
|
b31790 |
static GtkListStore *store;
|
|
|
b31790 |
static GtkTreeModelSort *sort_model;
|
|
|
b31790 |
static char *info_text;
|
|
|
b31790 |
|
|
|
b31790 |
static void select_session (const char *name);
|
|
|
b31790 |
static gboolean make_session_current (const char *name);
|
|
|
b31790 |
|
|
|
b31790 |
static char *
|
|
|
b31790 |
get_session_path (const char *name)
|
|
|
b31790 |
{
|
|
|
b31790 |
return g_build_filename (g_get_user_config_dir (), "gnome-session", name, NULL);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static char *
|
|
|
b31790 |
find_new_session_name (void)
|
|
|
b31790 |
{
|
|
|
b31790 |
char *name;
|
|
|
b31790 |
char *path;
|
|
|
b31790 |
int i;
|
|
|
b31790 |
|
|
|
b31790 |
@@ -694,86 +691,93 @@ on_row_activated (GtkTreeView *tree_view,
|
|
|
b31790 |
gtk_main_quit ();
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
auto_save_next_session (void)
|
|
|
b31790 |
{
|
|
|
b31790 |
GSettings *settings;
|
|
|
b31790 |
|
|
|
b31790 |
settings = g_settings_new (GSM_MANAGER_SCHEMA);
|
|
|
b31790 |
g_settings_set_boolean (settings, KEY_AUTOSAVE_ONE_SHOT, TRUE);
|
|
|
b31790 |
g_object_unref (settings);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
auto_save_next_session_if_needed (void)
|
|
|
b31790 |
{
|
|
|
b31790 |
char *marker;
|
|
|
b31790 |
|
|
|
b31790 |
marker = g_build_filename (g_get_user_config_dir (),
|
|
|
b31790 |
"gnome-session", "saved-session",
|
|
|
b31790 |
".new-session", NULL);
|
|
|
b31790 |
|
|
|
b31790 |
if (g_file_test (marker, G_FILE_TEST_EXISTS)) {
|
|
|
b31790 |
auto_save_next_session ();
|
|
|
b31790 |
unlink (marker);
|
|
|
b31790 |
}
|
|
|
b31790 |
g_free (marker);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
-save_session (void)
|
|
|
b31790 |
+session_saved_cb (GDBusConnection *conn,
|
|
|
b31790 |
+ GAsyncResult *result)
|
|
|
b31790 |
{
|
|
|
b31790 |
- DBusGConnection *conn;
|
|
|
b31790 |
- DBusGProxy *proxy;
|
|
|
b31790 |
- GError *error;
|
|
|
b31790 |
+ GVariant *reply;
|
|
|
b31790 |
|
|
|
b31790 |
- conn = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
|
|
b31790 |
- if (conn == NULL) {
|
|
|
b31790 |
- g_warning ("Could not connect to the session bus");
|
|
|
b31790 |
- return;
|
|
|
b31790 |
- }
|
|
|
b31790 |
+ reply = g_dbus_connection_call_finish (conn, result, NULL);
|
|
|
b31790 |
|
|
|
b31790 |
- proxy = dbus_g_proxy_new_for_name (conn, GSM_SERVICE_DBUS, GSM_PATH_DBUS, GSM_INTERFACE_DBUS);
|
|
|
b31790 |
- if (proxy == NULL) {
|
|
|
b31790 |
- g_warning ("Could not connect to the session manager");
|
|
|
b31790 |
- return;
|
|
|
b31790 |
- }
|
|
|
b31790 |
+ g_variant_unref (reply);
|
|
|
b31790 |
+}
|
|
|
b31790 |
|
|
|
b31790 |
- error = NULL;
|
|
|
b31790 |
- if (!dbus_g_proxy_call (proxy, "SaveSession", &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
|
|
|
b31790 |
- g_warning ("Failed to save session: %s", error->message);
|
|
|
b31790 |
- g_error_free (error);
|
|
|
b31790 |
+static void
|
|
|
b31790 |
+save_session (void)
|
|
|
b31790 |
+{
|
|
|
b31790 |
+ GDBusConnection *conn;
|
|
|
b31790 |
+
|
|
|
b31790 |
+ conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
|
|
b31790 |
+ if (conn == NULL) {
|
|
|
b31790 |
return;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
- g_object_unref (proxy);
|
|
|
b31790 |
+ g_dbus_connection_call (conn,
|
|
|
b31790 |
+ GSM_SERVICE_DBUS,
|
|
|
b31790 |
+ GSM_PATH_DBUS,
|
|
|
b31790 |
+ GSM_INTERFACE_DBUS,
|
|
|
b31790 |
+ "SaveSession",
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ G_DBUS_CALL_FLAGS_NONE,
|
|
|
b31790 |
+ -1,
|
|
|
b31790 |
+ NULL,
|
|
|
b31790 |
+ (GAsyncReadyCallback)
|
|
|
b31790 |
+ session_saved_cb,
|
|
|
b31790 |
+ NULL);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static int
|
|
|
b31790 |
compare_sessions (GtkTreeModel *model,
|
|
|
b31790 |
GtkTreeIter *a,
|
|
|
b31790 |
GtkTreeIter *b,
|
|
|
b31790 |
gpointer data)
|
|
|
b31790 |
{
|
|
|
b31790 |
char *name_a, *name_b;
|
|
|
b31790 |
int result;
|
|
|
b31790 |
|
|
|
b31790 |
gtk_tree_model_get (model, a, 0, &name_a, -1);
|
|
|
b31790 |
gtk_tree_model_get (model, b, 0, &name_b, -1);
|
|
|
b31790 |
|
|
|
b31790 |
result = g_utf8_collate (name_a, name_b);
|
|
|
b31790 |
|
|
|
b31790 |
g_free (name_a);
|
|
|
b31790 |
g_free (name_b);
|
|
|
b31790 |
|
|
|
b31790 |
return result;
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
static void
|
|
|
b31790 |
on_map (GtkWidget *widget,
|
|
|
b31790 |
gpointer data)
|
|
|
b31790 |
{
|
|
|
b31790 |
gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME);
|
|
|
b31790 |
}
|
|
|
b31790 |
|
|
|
b31790 |
int
|
|
|
b31790 |
--
|
|
|
b31790 |
2.14.2
|
|
|
b31790 |
|