[gnome-settings-daemon] remote-display: Add plugin to disable animations on slow links



commit 3e3b99aef91cc122bea7d41daf7087d8d3d96faf
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Dec 17 12:19:29 2012 +0100

    remote-display: Add plugin to disable animations on slow links
    
    Disable animations when on slow VNC or spice remote displays.
    
    Currently only monitors if the display can be exported via VNC.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680195

 configure.ac                                       |    1 +
 ...gnome.settings-daemon.plugins.gschema.xml.in.in |   13 ++
 plugins/Makefile.am                                |    1 +
 plugins/remote-display/Makefile.am                 |   61 +++++++++
 .../remote-display/gsd-remote-display-manager.c    |  141 ++++++++++++++++++++
 .../remote-display/gsd-remote-display-manager.h    |   57 ++++++++
 plugins/remote-display/gsd-remote-display-plugin.c |   33 +++++
 plugins/remote-display/gsd-remote-display-plugin.h |   59 ++++++++
 .../remote-display.gnome-settings-plugin.in        |    8 +
 plugins/remote-display/test-remote-display.c       |    7 +
 10 files changed, 381 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2d6bdbd..e8bdd46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -491,6 +491,7 @@ plugins/media-keys/gvc/Makefile
 plugins/mouse/Makefile
 plugins/orientation/Makefile
 plugins/print-notifications/Makefile
+plugins/remote-display/Makefile
 plugins/screensaver-proxy/Makefile
 plugins/smartcard/Makefile
 plugins/sound/Makefile
diff --git a/data/org.gnome.settings-daemon.plugins.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.gschema.xml.in.in
index b2b3dc6..126b016 100644
--- a/data/org.gnome.settings-daemon.plugins.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.gschema.xml.in.in
@@ -24,6 +24,7 @@
     <child name="orientation" schema="org.gnome.settings-daemon.plugins.orientation"/>
     <child name="power" schema="org.gnome.settings-daemon.plugins.power"/>
     <child name="print-notifications" schema="org.gnome.settings-daemon.plugins.print-notifications"/>
+    <child name="remote-display" schema="org.gnome.settings-daemon.plugins.remote-display"/>
     <child name="screensaver-proxy" schema="org.gnome.settings-daemon.plugins.screensaver-proxy"/>
     <child name="smartcard" schema="org.gnome.settings-daemon.plugins.smartcard"/>
     <child name="sound" schema="org.gnome.settings-daemon.plugins.sound"/>
@@ -115,6 +116,18 @@
       <_description>Priority to use for this plugin in gnome-settings-daemon startup queue</_description>
     </key>
   </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.plugins.remote-display" path="/org/gnome/settings-daemon/plugins/remote-display/">
+    <key name="active" type="b">
+      <default>true</default>
+      <_summary>Activation of this plugin</_summary>
+      <_description>Whether this plugin would be activated by gnome-settings-daemon or not</_description>
+    </key>
+    <key name="priority" type="i">
+      <default>8</default>
+      <_summary>Priority to use for this plugin</_summary>
+      <_description>Priority to use for this plugin in gnome-settings-daemon startup queue</_description>
+    </key>
+  </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.plugins.screensaver-proxy" path="/org/gnome/settings-daemon/plugins/screensaver-proxy/">
     <key name="active" type="b">
       <default>true</default>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index baaf252..197ceea 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -13,6 +13,7 @@ enabled_plugins =	\
 	keyboard	\
 	media-keys	\
 	mouse		\
+	remote-display	\
 	screensaver-proxy \
 	sound		\
 	xrandr		\
diff --git a/plugins/remote-display/Makefile.am b/plugins/remote-display/Makefile.am
new file mode 100644
index 0000000..ef98ec1
--- /dev/null
+++ b/plugins/remote-display/Makefile.am
@@ -0,0 +1,61 @@
+plugin_name = remote-display
+
+plugin_LTLIBRARIES = libremote-display.la
+
+libremote_display_la_SOURCES =	\
+	gsd-remote-display-manager.c	\
+	gsd-remote-display-manager.h	\
+	gsd-remote-display-plugin.c	\
+	gsd-remote-display-plugin.h
+
+libremote_display_la_CPPFLAGS =				\
+	-I$(top_srcdir)/gnome-settings-daemon			\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"	\
+	$(AM_CPPFLAGS)
+
+libremote_display_la_CFLAGS =	\
+	$(PLUGIN_CFLAGS)		\
+	$(SETTINGS_PLUGIN_CFLAGS)	\
+	$(AM_CFLAGS)
+
+libremote_display_la_LDFLAGS = $(GSD_PLUGIN_LDFLAGS)
+
+libremote_display_la_LIBADD  = $(SETTINGS_PLUGIN_LIBS)
+
+libexec_PROGRAMS = gsd-test-remote-display
+
+gsd_test_remote_display_SOURCES =		\
+	test-remote-display.c			\
+	gsd-remote-display-manager.c		\
+	gsd-remote-display-manager.h
+
+gsd_test_remote_display_CPPFLAGS =					\
+	-I$(top_srcdir)/data/					\
+	-I$(top_srcdir)/gnome-settings-daemon			\
+	-I$(top_srcdir)/plugins/common				\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"	\
+	-DLIBEXECDIR=\""$(libexecdir)"\"			\
+	$(AM_CPPFLAGS)
+
+gsd_test_remote_display_CFLAGS =			\
+	$(PLUGIN_CFLAGS)		\
+	$(SETTINGS_PLUGIN_CFLAGS)	\
+	$(AM_CFLAGS)
+
+gsd_test_remote_display_LDADD =						\
+	$(top_builddir)/gnome-settings-daemon/libgsd.la		\
+	$(top_builddir)/plugins/common/libcommon.la		\
+	$(SETTINGS_DAEMON_LIBS)			\
+	$(SETTINGS_PLUGIN_LIBS)
+
+plugin_in_files = remote-display.gnome-settings-plugin.in
+
+plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+
+DISTCLEANFILES = $(plugin_DATA)
+
+ GSD_INTLTOOL_PLUGIN_RULE@
diff --git a/plugins/remote-display/gsd-remote-display-manager.c b/plugins/remote-display/gsd-remote-display-manager.c
new file mode 100644
index 0000000..38acd39
--- /dev/null
+++ b/plugins/remote-display/gsd-remote-display-manager.c
@@ -0,0 +1,141 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <locale.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdk.h>
+
+#include "gnome-settings-session.h"
+#include "gnome-settings-profile.h"
+#include "gsd-remote-display-manager.h"
+
+#define GSD_REMOTE_DISPLAY_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_REMOTE_DISPLAY_MANAGER, GsdRemoteDisplayManagerPrivate))
+
+struct GsdRemoteDisplayManagerPrivate
+{
+        GSettings *desktop_settings;
+        GSettings *vnc_settings;
+};
+
+static void     gsd_remote_display_manager_class_init  (GsdRemoteDisplayManagerClass *klass);
+static void     gsd_remote_display_manager_init        (GsdRemoteDisplayManager      *remote_display_manager);
+
+G_DEFINE_TYPE (GsdRemoteDisplayManager, gsd_remote_display_manager, G_TYPE_OBJECT)
+
+static gpointer manager_object = NULL;
+
+static void
+vnc_settings_changed (GSettings *settings,
+		      gchar     *key,
+		      GsdRemoteDisplayManager *manager)
+{
+	gboolean state;
+
+	if (g_strcmp0 (key, "enabled") != 0)
+		return;
+
+	state = g_settings_get_boolean (settings, key);
+	g_settings_set_boolean (manager->priv->desktop_settings, "enable-animations", !state);
+}
+
+static gboolean
+schema_is_installed (const gchar *name)
+{
+	const gchar * const *schemas;
+	const gchar * const *s;
+
+	schemas = g_settings_list_schemas ();
+	for (s = schemas; *s; ++s)
+		if (g_str_equal (*s, name))
+			return TRUE;
+
+	return FALSE;
+}
+
+gboolean
+gsd_remote_display_manager_start (GsdRemoteDisplayManager *manager,
+				  GError               **error)
+{
+        g_debug ("Starting remote-display manager");
+
+        gnome_settings_profile_start (NULL);
+
+        manager->priv->desktop_settings = g_settings_new ("org.gnome.desktop.interface");
+
+	/* Check if vino is installed */
+	if (schema_is_installed ("org.gnome.Vino")) {
+		manager->priv->vnc_settings = g_settings_new ("org.gnome.Vino");
+		g_signal_connect (G_OBJECT (manager->priv->vnc_settings), "changed",
+				  G_CALLBACK (vnc_settings_changed), manager);
+		vnc_settings_changed (manager->priv->vnc_settings, "enabled", manager);
+	}
+
+	/* FIXME:
+	 * Check if session is being used in spice */
+
+        gnome_settings_profile_end (NULL);
+        return TRUE;
+}
+
+void
+gsd_remote_display_manager_stop (GsdRemoteDisplayManager *manager)
+{
+        g_debug ("Stopping remote_display manager");
+        g_clear_object (&manager->priv->vnc_settings);
+        g_clear_object (&manager->priv->desktop_settings);
+}
+
+static void
+gsd_remote_display_manager_class_init (GsdRemoteDisplayManagerClass *klass)
+{
+        g_type_class_add_private (klass, sizeof (GsdRemoteDisplayManagerPrivate));
+}
+
+static void
+gsd_remote_display_manager_init (GsdRemoteDisplayManager *manager)
+{
+        manager->priv = GSD_REMOTE_DISPLAY_MANAGER_GET_PRIVATE (manager);
+}
+
+GsdRemoteDisplayManager *
+gsd_remote_display_manager_new (void)
+{
+        if (manager_object != NULL) {
+                g_object_ref (manager_object);
+        } else {
+                manager_object = g_object_new (GSD_TYPE_REMOTE_DISPLAY_MANAGER, NULL);
+                g_object_add_weak_pointer (manager_object,
+                                           (gpointer *) &manager_object);
+        }
+
+        return GSD_REMOTE_DISPLAY_MANAGER (manager_object);
+}
diff --git a/plugins/remote-display/gsd-remote-display-manager.h b/plugins/remote-display/gsd-remote-display-manager.h
new file mode 100644
index 0000000..77ae8d6
--- /dev/null
+++ b/plugins/remote-display/gsd-remote-display-manager.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_REMOTE_DISPLAY_MANAGER_H
+#define __GSD_REMOTE_DISPLAY_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_REMOTE_DISPLAY_MANAGER         (gsd_remote_display_manager_get_type ())
+#define GSD_REMOTE_DISPLAY_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_REMOTE_DISPLAY_MANAGER, GsdRemoteDisplayManager))
+#define GSD_REMOTE_DISPLAY_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_REMOTE_DISPLAY_MANAGER, GsdRemoteDisplayManagerClass))
+#define GSD_IS_REMOTE_DISPLAY_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_REMOTE_DISPLAY_MANAGER))
+#define GSD_IS_REMOTE_DISPLAY_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_REMOTE_DISPLAY_MANAGER))
+#define GSD_REMOTE_DISPLAY_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_REMOTE_DISPLAY_MANAGER, GsdRemoteDisplayManagerClass))
+
+typedef struct GsdRemoteDisplayManagerPrivate GsdRemoteDisplayManagerPrivate;
+
+typedef struct
+{
+        GObject                     parent;
+        GsdRemoteDisplayManagerPrivate *priv;
+} GsdRemoteDisplayManager;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} GsdRemoteDisplayManagerClass;
+
+GType                       gsd_remote_display_manager_get_type            (void);
+
+GsdRemoteDisplayManager *gsd_remote_display_manager_new                 (void);
+gboolean                    gsd_remote_display_manager_start               (GsdRemoteDisplayManager  *manager,
+                                                                               GError                     **error);
+void                        gsd_remote_display_manager_stop                (GsdRemoteDisplayManager  *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_REMOTE_DISPLAY_MANAGER_H */
diff --git a/plugins/remote-display/gsd-remote-display-plugin.c b/plugins/remote-display/gsd-remote-display-plugin.c
new file mode 100644
index 0000000..6fb450d
--- /dev/null
+++ b/plugins/remote-display/gsd-remote-display-plugin.c
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+#include "gsd-remote-display-manager.h"
+
+struct GsdRemoteDisplayPluginPrivate {
+        GsdRemoteDisplayManager *manager;
+};
+
+GNOME_SETTINGS_PLUGIN_REGISTER (GsdRemoteDisplay, gsd_remote_display)
diff --git a/plugins/remote-display/gsd-remote-display-plugin.h b/plugins/remote-display/gsd-remote-display-plugin.h
new file mode 100644
index 0000000..3ee8869
--- /dev/null
+++ b/plugins/remote-display/gsd-remote-display-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_REMOTE_DISPLAY_PLUGIN_H__
+#define __GSD_REMOTE_DISPLAY_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_REMOTE_DISPLAY_PLUGIN                (gsd_remote_display_plugin_get_type ())
+#define GSD_REMOTE_DISPLAY_PLUGIN(o)                  (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_REMOTE_DISPLAY_PLUGIN, GsdRemoteDisplayPlugin))
+#define GSD_REMOTE_DISPLAY_PLUGIN_CLASS(k)            (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_REMOTE_DISPLAY_PLUGIN, GsdRemoteDisplayPluginClass))
+#define GSD_IS_REMOTE_DISPLAY_PLUGIN(o)               (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_REMOTE_DISPLAY_PLUGIN))
+#define GSD_IS_REMOTE_DISPLAY_PLUGIN_CLASS(k)         (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_REMOTE_DISPLAY_PLUGIN))
+#define GSD_REMOTE_DISPLAY_PLUGIN_GET_CLASS(o)        (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_REMOTE_DISPLAY_PLUGIN, GsdRemoteDisplayPluginClass))
+
+typedef struct GsdRemoteDisplayPluginPrivate GsdRemoteDisplayPluginPrivate;
+
+typedef struct
+{
+        GnomeSettingsPlugin    parent;
+        GsdRemoteDisplayPluginPrivate *priv;
+} GsdRemoteDisplayPlugin;
+
+typedef struct
+{
+        GnomeSettingsPluginClass parent_class;
+} GsdRemoteDisplayPluginClass;
+
+GType   gsd_remote_display_plugin_get_type            (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_REMOTE_DISPLAY_PLUGIN_H__ */
diff --git a/plugins/remote-display/remote-display.gnome-settings-plugin.in b/plugins/remote-display/remote-display.gnome-settings-plugin.in
new file mode 100644
index 0000000..2abd05d
--- /dev/null
+++ b/plugins/remote-display/remote-display.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=remote-display
+IAge=0
+_Name=Screensaver Proxy
+_Description=Proxy FreeDesktop screensaver inhibition to gnome-session
+Authors=Bastien Nocera
+Copyright=Copyright  2012 Bastien Nocera
+Website=
diff --git a/plugins/remote-display/test-remote-display.c b/plugins/remote-display/test-remote-display.c
new file mode 100644
index 0000000..bae71b0
--- /dev/null
+++ b/plugins/remote-display/test-remote-display.c
@@ -0,0 +1,7 @@
+#define NEW gsd_remote_display_manager_new
+#define START gsd_remote_display_manager_start
+#define STOP gsd_remote_display_manager_stop
+#define MANAGER GsdRemoteDisplayManager
+#include "gsd-remote-display-manager.h"
+
+#include "test-plugin.h"



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