[gnome-flashback] add FlashbackIdleMonitor
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] add FlashbackIdleMonitor
- Date: Sun, 24 Aug 2014 00:22:53 +0000 (UTC)
commit a9343d1dbab7e94b1c37dbe48191c06088385e2b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Aug 24 03:12:02 2014 +0300
add FlashbackIdleMonitor
data/org.gnome.gnome-flashback.gschema.xml.in.in | 5 +
gnome-flashback/Makefile.am | 2 +
gnome-flashback/flashback-application.c | 22 ++++-
gnome-flashback/flashback-gsettings.h | 1 +
gnome-flashback/flashback-idle-monitor.c | 135 ++++++++++++++++++++++
gnome-flashback/flashback-idle-monitor.h | 46 ++++++++
6 files changed, 210 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.gnome-flashback.gschema.xml.in.in
b/data/org.gnome.gnome-flashback.gschema.xml.in.in
index a28adbf..57b4028 100644
--- a/data/org.gnome.gnome-flashback.gschema.xml.in.in
+++ b/data/org.gnome.gnome-flashback.gschema.xml.in.in
@@ -15,6 +15,11 @@
<_summary>End session dialog</_summary>
<_description>If set to true, then GNOME Flashback application will be used to show
end session dialog.</_description>
</key>
+ <key name="idle-monitor" type="b">
+ <default>true</default>
+ <_summary>Idle monitor</_summary>
+ <_description>If set to true, then GNOME Flashback application will be used fo user
activity monitoring.</_description>
+ </key>
<!--
<child name="background" schema="org.gnome.gnome-flashback.background"/>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 93080fa..29f941e 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -23,6 +23,8 @@ gnome_flashback_SOURCES = \
flashback-end-session-dialog.c \
flashback-end-session-dialog.h \
flashback-gsettings.h \
+ flashback-idle-monitor.c \
+ flashback-idle-monitor.h \
flashback-inhibit-dialog.c \
flashback-inhibit-dialog.h \
flashback-main.c \
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 23ce5df..08a5f45 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -23,6 +23,7 @@
#include "flashback-display-config.h"
#include "flashback-end-session-dialog.h"
#include "flashback-gsettings.h"
+#include "flashback-idle-monitor.h"
struct _FlashbackApplicationPrivate {
GSettings *settings;
@@ -30,6 +31,7 @@ struct _FlashbackApplicationPrivate {
FlashbackDesktopBackground *background;
FlashbackDisplayConfig *config;
FlashbackEndSessionDialog *dialog;
+ FlashbackIdleMonitor *monitor;
};
G_DEFINE_TYPE (FlashbackApplication, flashback_application, GTK_TYPE_APPLICATION);
@@ -79,6 +81,19 @@ flashback_application_settings_changed (GSettings *settings,
}
}
}
+
+ if (key == NULL || g_strcmp0 (key, KEY_IDLE_MONITOR) == 0) {
+ if (g_settings_get_boolean (settings, KEY_IDLE_MONITOR)) {
+ if (app->priv->monitor == NULL) {
+ app->priv->monitor = flashback_idle_monitor_new ();
+ }
+ } else {
+ if (app->priv->monitor) {
+ g_object_unref (app->priv->monitor);
+ app->priv->monitor = NULL;
+ }
+ }
+ }
}
static void
@@ -115,7 +130,7 @@ flashback_application_shutdown (GApplication *application)
g_object_unref (app->priv->background);
app->priv->background = NULL;
}
-
+
if (app->priv->config) {
g_object_unref (app->priv->config);
app->priv->config = NULL;
@@ -126,6 +141,11 @@ flashback_application_shutdown (GApplication *application)
app->priv->dialog = NULL;
}
+ if (app->priv->monitor) {
+ g_object_unref (app->priv->monitor);
+ app->priv->monitor = NULL;
+ }
+
if (app->priv->settings) {
g_object_unref (app->priv->settings);
app->priv->settings = NULL;
diff --git a/gnome-flashback/flashback-gsettings.h b/gnome-flashback/flashback-gsettings.h
index 1481bfc..652395b 100644
--- a/gnome-flashback/flashback-gsettings.h
+++ b/gnome-flashback/flashback-gsettings.h
@@ -22,6 +22,7 @@
#define KEY_DESKTOP_BACKGROUND "desktop-background"
#define KEY_DISPLAY_CONFIG "display-config"
#define KEY_END_SESSION_DIALOG "end-session-dialog"
+#define KEY_IDLE_MONITOR "idle-monitor"
/*#define FLASHBACK_BACKGROUND_SCHEMA "org.gnome.gnome-flashback.background"
#define KEY_FADE "fade"*/
diff --git a/gnome-flashback/flashback-idle-monitor.c b/gnome-flashback/flashback-idle-monitor.c
new file mode 100644
index 0000000..5803bce
--- /dev/null
+++ b/gnome-flashback/flashback-idle-monitor.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2014 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+#include "config.h"
+#include "dbus-idle-monitor.h"
+#include "flashback-idle-monitor.h"
+
+struct _FlashbackIdleMonitorPrivate {
+ gint bus_name;
+};
+
+G_DEFINE_TYPE (FlashbackIdleMonitor, flashback_idle_monitor, G_TYPE_OBJECT);
+
+/*static void
+handle_add_idle_watch (DBusIdleMonitor *object,
+ GDBusMethodInvocation *invocation,
+ guint64 interval,
+ gpointer user_data)
+{
+ g_warning ("AddIdleWatch is not implemented!");
+}
+
+static void
+handle_add_user_active_watch (DBusIdleMonitor *object,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ g_warning ("AddUserActiveWatch is not implemented!");
+}
+
+static void
+handle_remove_watch (DBusIdleMonitor *object,
+ GDBusMethodInvocation *invocation,
+ guint id,
+ gpointer user_data)
+{
+ g_warning ("RemoveWatch is not implemented!");
+}
+
+static void
+handle_get_idletime (DBusIdleMonitor *object,
+ GDBusMethodInvocation *invocation,
+ guint id,
+ gpointer user_data)
+{
+ g_warning ("GetIdletime is not implemented!");
+}*/
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ FlashbackIdleMonitor *monitor = FLASHBACK_IDLE_MONITOR (user_data);
+ GDBusObjectManagerServer *manager = g_dbus_object_manager_server_new
("/org/gnome/Mutter/IdleMonitor");
+
+ g_dbus_object_manager_server_set_connection (manager, connection);
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const char *name,
+ gpointer user_data)
+{
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const char *name,
+ gpointer user_data)
+{
+}
+
+static void
+flashback_idle_monitor_finalize (GObject *object)
+{
+ FlashbackIdleMonitor *monitor = FLASHBACK_IDLE_MONITOR (object);
+
+ if (monitor->priv->bus_name) {
+ g_bus_unown_name (monitor->priv->bus_name);
+ monitor->priv->bus_name = 0;
+ }
+
+ G_OBJECT_CLASS (flashback_idle_monitor_parent_class)->finalize (object);
+}
+
+static void
+flashback_idle_monitor_init (FlashbackIdleMonitor *monitor)
+{
+ monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor,
+ FLASHBACK_TYPE_IDLE_MONITOR,
+ FlashbackIdleMonitorPrivate);
+
+ monitor->priv->bus_name = g_bus_own_name (G_BUS_TYPE_SESSION,
+ "org.gnome.Mutter.IdleMonitor",
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ G_BUS_NAME_OWNER_FLAGS_REPLACE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ monitor,
+ NULL);
+}
+
+static void
+flashback_idle_monitor_class_init (FlashbackIdleMonitorClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = flashback_idle_monitor_finalize;
+
+ g_type_class_add_private (class, sizeof (FlashbackIdleMonitorPrivate));
+}
+
+FlashbackIdleMonitor *
+flashback_idle_monitor_new (void)
+{
+ return g_object_new (FLASHBACK_TYPE_IDLE_MONITOR,
+ NULL);
+}
diff --git a/gnome-flashback/flashback-idle-monitor.h b/gnome-flashback/flashback-idle-monitor.h
new file mode 100644
index 0000000..6d78eb9
--- /dev/null
+++ b/gnome-flashback/flashback-idle-monitor.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FLASHBACK_IDLE_MONITOR_H
+#define FLASHBACK_IDLE_MONITOR_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_IDLE_MONITOR (flashback_idle_monitor_get_type ())
+#define FLASHBACK_IDLE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FLASHBACK_TYPE_IDLE_MONITOR,
FlashbackIdleMonitor))
+
+typedef struct _FlashbackIdleMonitor FlashbackIdleMonitor;
+typedef struct _FlashbackIdleMonitorClass FlashbackIdleMonitorClass;
+typedef struct _FlashbackIdleMonitorPrivate FlashbackIdleMonitorPrivate;
+
+struct _FlashbackIdleMonitor {
+ GObject parent;
+ FlashbackIdleMonitorPrivate *priv;
+};
+
+struct _FlashbackIdleMonitorClass {
+ GObjectClass parent_class;
+};
+
+GType flashback_idle_monitor_get_type (void);
+FlashbackIdleMonitor *flashback_idle_monitor_new (void);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]