[gnome-flashback] key-grabber: replace with shell
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] key-grabber: replace with shell
- Date: Fri, 27 Mar 2015 04:41:25 +0000 (UTC)
commit 0e953555bd72aa7830e058acadb464dded9e14f0
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Mar 27 06:36:14 2015 +0200
key-grabber: replace with shell
Makefile.am | 1 +
configure.ac | 8 +-
data/org.gnome.gnome-flashback.gschema.xml.in.in | 6 +-
gnome-flashback/Makefile.am | 4 +-
gnome-flashback/flashback-application.c | 18 +-
gnome-flashback/libkey-grabber/Makefile.am | 38 --
.../libkey-grabber/flashback-key-grabber.c | 337 ----------------
.../libkey-grabber/flashback-key-grabber.h | 51 ---
.../libkey-grabber/org.gnome.KeyGrabber.xml | 23 -
gnome-flashback/libshell/Makefile.am | 37 ++
.../flashback-key-bindings.c | 74 +++--
.../flashback-key-bindings.h | 5 +-
gnome-flashback/libshell/flashback-shell.c | 423 ++++++++++++++++++++
gnome-flashback/libshell/flashback-shell.h | 32 ++
gnome-flashback/libshell/org.gnome.Shell.xml | 42 ++
15 files changed, 605 insertions(+), 494 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 70b4140..2740d7a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,7 @@ MAINTAINERCLEANFILES = \
$(srcdir)/compile \
$(srcdir)/config.guess \
$(srcdir)/config.h.in \
+ $(srcdir)/config.h.in~ \
$(srcdir)/config.sub \
$(srcdir)/depcomp \
$(srcdir)/install-sh \
diff --git a/configure.ac b/configure.ac
index 41052ba..c5e6b03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,9 +53,9 @@ PKG_CHECK_MODULES(DISPLAY_CONFIG, gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_RE
AC_SUBST(DISPLAY_CONFIG_CFLAGS)
AC_SUBST(DISPLAY_CONFIG_LIBS)
-PKG_CHECK_MODULES(KEY_GRABBER, gtk+-3.0 >= $GTK_REQUIRED x11)
-AC_SUBST(KEY_GRABBER_CFLAGS)
-AC_SUBST(KEY_GRABBER_LIBS)
+PKG_CHECK_MODULES(SHELL, gtk+-3.0 >= $GTK_REQUIRED x11)
+AC_SUBST(SHELL_CFLAGS)
+AC_SUBST(SHELL_LIBS)
PKG_CHECK_MODULES(GVC, gobject-2.0 libpulse libpulse-mainloop-glib)
AM_CONDITIONAL(HAVE_INTROSPECTION, false)
@@ -72,7 +72,7 @@ gnome-flashback/libautomount-manager/Makefile
gnome-flashback/libdesktop-background/Makefile
gnome-flashback/libdisplay-config/Makefile
gnome-flashback/libend-session-dialog/Makefile
-gnome-flashback/libkey-grabber/Makefile
+gnome-flashback/libshell/Makefile
gnome-flashback/libsound-applet/Makefile
gnome-flashback/libsound-applet/gvc/Makefile
po/Makefile.in
diff --git a/data/org.gnome.gnome-flashback.gschema.xml.in.in
b/data/org.gnome.gnome-flashback.gschema.xml.in.in
index d8b9318..217ee35 100644
--- a/data/org.gnome.gnome-flashback.gschema.xml.in.in
+++ b/data/org.gnome.gnome-flashback.gschema.xml.in.in
@@ -20,10 +20,10 @@
<_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="key-grabber" type="b">
+ <key name="shell" type="b">
<default>true</default>
- <_summary>Key grabber</_summary>
- <_description>If set to true, then GNOME Flashback application will be used for key
grabbing.</_description>
+ <_summary>Shell</_summary>
+ <_description>If set to true, then GNOME Flashback application will be used as
shell.</_description>
</key>
<key name="sound-applet" type="b">
<default>true</default>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 7fcfde8..47f2aa6 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -3,7 +3,7 @@ SUBDIRS = \
libdesktop-background \
libdisplay-config \
libend-session-dialog \
- libkey-grabber \
+ libshell \
libsound-applet
bin_PROGRAMS = \
@@ -27,7 +27,7 @@ gnome_flashback_LDADD = \
$(top_builddir)/gnome-flashback/libdesktop-background/libdesktop-background.la \
$(top_builddir)/gnome-flashback/libdisplay-config/libdisplay-config.la \
$(top_builddir)/gnome-flashback/libend-session-dialog/libend-session-dialog.la \
- $(top_builddir)/gnome-flashback/libkey-grabber/libkey-grabber.la \
+ $(top_builddir)/gnome-flashback/libshell/libshell.la \
$(top_builddir)/gnome-flashback/libsound-applet/libsound-applet.la
-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 445b9ce..59ae945 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -23,7 +23,7 @@
#include "libdesktop-background/desktop-background.h"
#include "libdisplay-config/flashback-display-config.h"
#include "libend-session-dialog/flashback-end-session-dialog.h"
-#include "libkey-grabber/flashback-key-grabber.h"
+#include "libshell/flashback-shell.h"
#include "libsound-applet/gvc-applet.h"
#define FLASHBACK_SCHEMA "org.gnome.gnome-flashback"
@@ -31,7 +31,7 @@
#define KEY_DESKTOP_BACKGROUND "desktop-background"
#define KEY_DISPLAY_CONFIG "display-config"
#define KEY_END_SESSION_DIALOG "end-session-dialog"
-#define KEY_KEY_GRABBER "key-grabber"
+#define KEY_SHELL "shell"
#define KEY_SOUND_APPLET "sound-applet"
struct _FlashbackApplicationPrivate {
@@ -40,7 +40,7 @@ struct _FlashbackApplicationPrivate {
DesktopBackground *background;
FlashbackDisplayConfig *config;
FlashbackEndSessionDialog *dialog;
- FlashbackKeyGrabber *grabber;
+ FlashbackShell *shell;
GvcApplet *applet;
gint bus_name;
@@ -95,13 +95,13 @@ flashback_application_settings_changed (GSettings *settings,
}
}
- if (key == NULL || g_strcmp0 (key, KEY_KEY_GRABBER) == 0) {
- if (g_settings_get_boolean (settings, KEY_KEY_GRABBER)) {
- if (app->priv->grabber == NULL) {
- app->priv->grabber = flashback_key_grabber_new ();
+ if (key == NULL || g_strcmp0 (key, KEY_SHELL) == 0) {
+ if (g_settings_get_boolean (settings, KEY_SHELL)) {
+ if (app->priv->shell == NULL) {
+ app->priv->shell = flashback_shell_new ();
}
} else {
- g_clear_object (&app->priv->grabber);
+ g_clear_object (&app->priv->shell);
}
}
@@ -130,7 +130,7 @@ flashback_application_finalize (GObject *object)
g_clear_object (&app->priv->background);
g_clear_object (&app->priv->config);
g_clear_object (&app->priv->dialog);
- g_clear_object (&app->priv->grabber);
+ g_clear_object (&app->priv->shell);
g_clear_object (&app->priv->applet);
g_clear_object (&app->priv->settings);
diff --git a/gnome-flashback/libshell/Makefile.am b/gnome-flashback/libshell/Makefile.am
new file mode 100644
index 0000000..90d2408
--- /dev/null
+++ b/gnome-flashback/libshell/Makefile.am
@@ -0,0 +1,37 @@
+noinst_LTLIBRARIES = \
+ libshell.la
+
+AM_CPPFLAGS = \
+ $(SHELL_CFLAGS) \
+ -I$(top_builddir)/gnome-flashback/libshell
+
+libshell_la_SOURCES = \
+ flashback-dbus-shell.c \
+ flashback-dbus-shell.h \
+ flashback-key-bindings.c \
+ flashback-key-bindings.h \
+ flashback-shell.c \
+ flashback-shell.h
+
+libshell_la_LIBADD = \
+ $(SHELL_LIBS)
+
+flashback-dbus-shell.h:
+flashback-dbus-shell.c: org.gnome.Shell.xml
+ $(AM_V_GEN) gdbus-codegen \
+ --interface-prefix org.gnome.Shell. \
+ --c-namespace Flashback \
+ --generate-c-code flashback-dbus-shell \
+ $(srcdir)/org.gnome.Shell.xml
+
+BUILT_SOURCES = \
+ flashback-dbus-shell.c \
+ flashback-dbus-shell.h
+
+EXTRA_DIST = \
+ org.gnome.Shell.xml
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libkey-grabber/flashback-key-bindings.c
b/gnome-flashback/libshell/flashback-key-bindings.c
similarity index 81%
rename from gnome-flashback/libkey-grabber/flashback-key-bindings.c
rename to gnome-flashback/libshell/flashback-key-bindings.c
index 41f59d7..30db02b 100644
--- a/gnome-flashback/libkey-grabber/flashback-key-bindings.c
+++ b/gnome-flashback/libshell/flashback-key-bindings.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 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
@@ -84,39 +84,66 @@ get_real_modifiers (GdkModifierType modifiers)
return mods;
}
+static GVariant *
+build_parameters (guint device_id,
+ guint timestamp,
+ guint action_mode)
+{
+ GVariantBuilder *builder;
+ GVariant *parameters;
+
+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (builder, "{sv}", "device-id", g_variant_new_uint32 (device_id));
+ g_variant_builder_add (builder, "{sv}", "timestamp", g_variant_new_uint32 (timestamp));
+ g_variant_builder_add (builder, "{sv}", "action-mode", g_variant_new_uint32 (action_mode));
+
+ parameters = g_variant_new ("a{sv}", builder);
+ g_variant_builder_unref (builder);
+
+ return parameters;
+}
+
static GdkFilterReturn
filter_func (GdkXEvent *xevent,
GdkEvent *event,
gpointer user_data)
{
- FlashbackKeyBindings *bindings;
- XEvent *ev;
+ FlashbackKeyBindings *bindings;
+ XEvent *ev;
- bindings = FLASHBACK_KEY_BINDINGS (user_data);
- ev = xevent;
+ bindings = FLASHBACK_KEY_BINDINGS (user_data);
+ ev = xevent;
- XAllowEvents (bindings->priv->xdisplay, AsyncKeyboard, ev->xkey.time);
+ XAllowEvents (bindings->priv->xdisplay, AsyncKeyboard, ev->xkey.time);
- if (ev->type == KeyPress) {
- GList *values, *l;
+ if (ev->type == KeyPress)
+ {
+ GList *values, *l;
- values = g_hash_table_get_values (bindings->priv->table);
+ values = g_hash_table_get_values (bindings->priv->table);
- for (l = values; l; l = l->next) {
- KeyBinding *binding = l->data;
+ for (l = values; l; l = l->next)
+ {
+ KeyBinding *binding = l->data;
- if (binding->keycode == ev->xkey.keycode &&
- binding->modifiers == (ev->xkey.state & 0xff &
~(bindings->priv->ignored_modifier_mask))) {
- g_signal_emit (bindings, signals[BINDING_ACTIVATED], 0,
- binding->action, 0, 0);
- break;
- }
- }
+ if (binding->keycode == ev->xkey.keycode &&
+ binding->modifiers == (ev->xkey.state & 0xff & ~(bindings->priv->ignored_modifier_mask)))
+ {
+ GVariant *parameters;
- g_list_free (values);
- }
+ parameters = build_parameters (0, 0, 0);
+
+ g_signal_emit (bindings, signals[BINDING_ACTIVATED], 0,
+ binding->action, parameters);
- return GDK_FILTER_CONTINUE;
+ break;
+ }
+ }
+
+ g_list_free (values);
+ }
+
+ return GDK_FILTER_CONTINUE;
}
static void
@@ -217,10 +244,9 @@ flashback_key_bindings_class_init (FlashbackKeyBindingsClass *class)
G_STRUCT_OFFSET (FlashbackKeyBindingsClass, binding_activated),
NULL, NULL, NULL,
G_TYPE_NONE,
- 3,
- G_TYPE_UINT,
+ 2,
G_TYPE_UINT,
- G_TYPE_UINT);
+ G_TYPE_VARIANT);
}
FlashbackKeyBindings *
diff --git a/gnome-flashback/libkey-grabber/flashback-key-bindings.h
b/gnome-flashback/libshell/flashback-key-bindings.h
similarity index 93%
rename from gnome-flashback/libkey-grabber/flashback-key-bindings.h
rename to gnome-flashback/libshell/flashback-key-bindings.h
index e53fabc..959245d 100644
--- a/gnome-flashback/libkey-grabber/flashback-key-bindings.h
+++ b/gnome-flashback/libshell/flashback-key-bindings.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 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
@@ -43,8 +43,7 @@ struct _FlashbackKeyBindingsClass {
void (*binding_activated) (FlashbackKeyBindings *bindings,
guint action,
- guint device,
- guint timestamp);
+ GVariant *parameters);
};
GType flashback_key_bindings_get_type (void);
diff --git a/gnome-flashback/libshell/flashback-shell.c b/gnome-flashback/libshell/flashback-shell.c
new file mode 100644
index 0000000..f419aa5
--- /dev/null
+++ b/gnome-flashback/libshell/flashback-shell.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2015 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 <config.h>
+#include <gtk/gtk.h>
+#include "flashback-dbus-shell.h"
+#include "flashback-key-bindings.h"
+#include "flashback-shell.h"
+
+#define SHELL_DBUS_NAME "org.gnome.Shell"
+#define SHELL_DBUS_PATH "/org/gnome/Shell"
+
+typedef struct
+{
+ const gchar *sender;
+ FlashbackShell *shell;
+} GrabberData;
+
+struct _FlashbackShell
+{
+ GObject parent;
+
+ gint bus_name;
+ GDBusInterfaceSkeleton *iface;
+
+ FlashbackKeyBindings *bindings;
+ GHashTable *grabbed_accelerators;
+ GHashTable *grabbers;
+};
+
+G_DEFINE_TYPE (FlashbackShell, flashback_shell, G_TYPE_OBJECT)
+
+static void
+binding_activated (FlashbackKeyBindings *bindings,
+ guint action,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ FlashbackDBusShell *dbus_shell;
+
+ shell = FLASHBACK_SHELL (user_data);
+ dbus_shell = FLASHBACK_DBUS_SHELL (shell->iface);
+
+ flashback_dbus_shell_emit_accelerator_activated (dbus_shell, action, parameters);
+}
+
+static gint
+real_grab (FlashbackShell *shell,
+ const gchar *accelerator)
+{
+ return flashback_key_bindings_grab (shell->bindings, accelerator);
+}
+
+static gboolean
+real_ungrab (FlashbackShell *shell,
+ gint action)
+{
+ return flashback_key_bindings_ungrab (shell->bindings, action);
+}
+
+static void
+ungrab_accelerator (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ guint action;
+ gchar *sender;
+ GrabberData *data;
+
+ action = GPOINTER_TO_UINT (key);
+ sender = (gchar *) value;
+ data = (GrabberData *) user_data;
+
+ if (g_str_equal (sender, data->sender))
+ {
+ if (real_ungrab (data->shell, action))
+ g_hash_table_remove (data->shell->grabbed_accelerators, key);
+ }
+}
+
+static void
+name_vanished_handler (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ guint id;
+ GrabberData *data;
+
+ shell = FLASHBACK_SHELL (user_data);
+ id = GPOINTER_TO_UINT (g_hash_table_lookup (shell->grabbers, name));
+ data = g_new0 (GrabberData, 1);
+
+ data->sender = name;
+ data->shell = shell;
+
+ g_hash_table_foreach (shell->grabbed_accelerators, (GHFunc) ungrab_accelerator, data);
+ g_free (data);
+
+ g_bus_unwatch_name (id);
+ g_hash_table_remove (shell->grabbers, name);
+}
+
+static guint
+grab_accelerator (FlashbackShell *shell,
+ const gchar *accelerator,
+ guint flags,
+ const gchar *sender)
+{
+ guint action;
+
+ action = real_grab (shell, accelerator);
+ g_hash_table_insert (shell->grabbed_accelerators,
+ GUINT_TO_POINTER (action), g_strdup (sender));
+
+ if (g_hash_table_lookup (shell->grabbers, sender) == NULL)
+ {
+ guint id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ sender,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL,
+ (GBusNameVanishedCallback) name_vanished_handler,
+ shell,
+ NULL);
+ g_hash_table_insert (shell->grabbers, g_strdup (sender), GUINT_TO_POINTER (id));
+ }
+
+ return action;
+}
+
+static gboolean
+handle_eval (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ const gchar action,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_eval (dbus_shell, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_focus_search (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_focus_search (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_show_osd (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ GVariant *params,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_show_osd (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_show_monitor_labels (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ GVariant *params,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_show_monitor_labels (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_hide_minitor_labels (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_hide_monitor_labels (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_focus_app (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ const gchar id,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_focus_app (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_show_applications (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ flashback_dbus_shell_complete_show_applications (dbus_shell, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_grab_accelerator (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ const gchar *accelerator,
+ guint flags,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ const gchar *sender;
+ guint action;
+
+ shell = FLASHBACK_SHELL (user_data);
+ sender = g_dbus_method_invocation_get_sender (invocation);
+ action = grab_accelerator (shell, accelerator, flags, sender);
+
+ flashback_dbus_shell_complete_grab_accelerator (dbus_shell, invocation, action);
+
+ return TRUE;
+}
+
+static gboolean
+handle_grab_accelerators (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ GVariant *accelerators,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ GVariantBuilder builder;
+ GVariantIter iter;
+ GVariant *child;
+ const gchar *sender;
+
+ shell = FLASHBACK_SHELL (user_data);
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE("au"));
+ g_variant_iter_init (&iter, accelerators);
+
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ while ((child = g_variant_iter_next_value (&iter)))
+ {
+ gchar *accelerator;
+ guint flags;
+ guint action;
+
+ g_variant_get (child, "(su)", &accelerator, &flags);
+
+ action = grab_accelerator (shell, accelerator, flags, sender);
+ g_variant_builder_add (&builder, "u", action);
+
+ g_free (accelerator);
+ g_variant_unref (child);
+ }
+
+ flashback_dbus_shell_complete_grab_accelerators (dbus_shell, invocation,
+ g_variant_builder_end (&builder));
+
+ return TRUE;
+}
+
+static gboolean
+handle_ungrab_accelerator (FlashbackDBusShell *dbus_shell,
+ GDBusMethodInvocation *invocation,
+ guint action,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ gchar *sender;
+ gboolean success;
+
+ shell = FLASHBACK_SHELL (user_data);
+ success = FALSE;
+ sender = (gchar *) g_hash_table_lookup (shell->grabbed_accelerators,
+ GUINT_TO_POINTER (action));
+
+ if (g_str_equal (sender, g_dbus_method_invocation_get_sender (invocation)))
+ {
+ success = real_ungrab (shell, action);
+
+ if (success)
+ g_hash_table_remove (shell->grabbed_accelerators, GUINT_TO_POINTER (action));
+ }
+
+ flashback_dbus_shell_complete_ungrab_accelerator (dbus_shell, invocation, success);
+
+ return TRUE;
+}
+
+static void
+name_appeared_handler (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ FlashbackShell *shell;
+ FlashbackDBusShell *skeleton;
+ GError *error;
+
+ shell = FLASHBACK_SHELL (user_data);
+ skeleton = flashback_dbus_shell_skeleton_new ();
+
+ g_signal_connect (skeleton, "handle-eval",
+ G_CALLBACK (handle_eval), shell);
+ g_signal_connect (skeleton, "handle-focus-search",
+ G_CALLBACK (handle_focus_search), shell);
+ g_signal_connect (skeleton, "handle-show-osd",
+ G_CALLBACK (handle_show_osd), shell);
+ g_signal_connect (skeleton, "handle-show-monitor-labels",
+ G_CALLBACK (handle_show_monitor_labels), shell);
+ g_signal_connect (skeleton, "handle-hide-monitor-labels",
+ G_CALLBACK (handle_hide_minitor_labels), shell);
+ g_signal_connect (skeleton, "handle-focus-app",
+ G_CALLBACK (handle_focus_app), shell);
+ g_signal_connect (skeleton, "handle-show-applications",
+ G_CALLBACK (handle_show_applications), shell);
+ g_signal_connect (skeleton, "handle-grab-accelerator",
+ G_CALLBACK (handle_grab_accelerator), shell);
+ g_signal_connect (skeleton, "handle-grab-accelerators",
+ G_CALLBACK (handle_grab_accelerators), shell);
+ g_signal_connect (skeleton, "handle-ungrab-accelerator",
+ G_CALLBACK (handle_ungrab_accelerator), shell);
+
+ flashback_dbus_shell_set_mode (skeleton, "");
+ flashback_dbus_shell_set_overview_active (skeleton, FALSE);
+ flashback_dbus_shell_set_shell_version (skeleton, "");
+
+ error = NULL;
+ shell->iface = G_DBUS_INTERFACE_SKELETON (skeleton);
+
+ if (!g_dbus_interface_skeleton_export (shell->iface, connection,
+ SHELL_DBUS_PATH,
+ &error))
+ {
+ g_warning ("Failed to export interface: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
+flashback_shell_finalize (GObject *object)
+{
+ FlashbackShell *shell;
+
+ shell = FLASHBACK_SHELL (object);
+
+ if (shell->bus_name)
+ {
+ g_bus_unwatch_name (shell->bus_name);
+ shell->bus_name = 0;
+ }
+
+ if (shell->grabbed_accelerators)
+ {
+ g_hash_table_destroy (shell->grabbed_accelerators);
+ shell->grabbed_accelerators = NULL;
+ }
+
+ if (shell->grabbers)
+ {
+ g_hash_table_destroy (shell->grabbers);
+ shell->grabbers = NULL;
+ }
+
+ g_clear_object (&shell->bindings);
+
+ G_OBJECT_CLASS (flashback_shell_parent_class)->finalize (object);
+}
+
+static void
+flashback_shell_class_init (FlashbackShellClass *shell_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (shell_class);
+
+ object_class->finalize = flashback_shell_finalize;
+}
+
+static void
+flashback_shell_init (FlashbackShell *shell)
+{
+ shell->grabbed_accelerators = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ shell->grabbers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ shell->bindings = flashback_key_bindings_new ();
+ g_signal_connect (shell->bindings, "binding-activated",
+ G_CALLBACK (binding_activated), shell);
+
+ shell->bus_name = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ SHELL_DBUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ name_appeared_handler,
+ NULL,
+ shell,
+ NULL);
+}
+
+FlashbackShell *
+flashback_shell_new (void)
+{
+ return g_object_new (FLASHBACK_TYPE_SHELL, NULL);
+}
diff --git a/gnome-flashback/libshell/flashback-shell.h b/gnome-flashback/libshell/flashback-shell.h
new file mode 100644
index 0000000..948cea0
--- /dev/null
+++ b/gnome-flashback/libshell/flashback-shell.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 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_SHELL_H
+#define FLASHBACK_SHELL_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_SHELL flashback_shell_get_type ()
+G_DECLARE_FINAL_TYPE (FlashbackShell, flashback_shell, FLASHBACK, SHELL, GObject)
+
+FlashbackShell *flashback_shell_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libshell/org.gnome.Shell.xml b/gnome-flashback/libshell/org.gnome.Shell.xml
new file mode 100644
index 0000000..e4af146
--- /dev/null
+++ b/gnome-flashback/libshell/org.gnome.Shell.xml
@@ -0,0 +1,42 @@
+<node>
+ <interface name="org.gnome.Shell">
+ <annotation name="org.gtk.GDBus.C.Name" value="DBusShell" />
+ <method name="Eval">
+ <arg type="s" direction="in" name="script" />
+ <arg type="b" direction="out" name="success" />
+ <arg type="s" direction="out" name="result" />
+ </method>
+ <method name="FocusSearch"/>
+ <method name="ShowOSD">
+ <arg type="a{sv}" direction="in" name="params" />
+ </method>
+ <method name="ShowMonitorLabels">
+ <arg type="a{uv}" direction="in" name="params" />
+ </method>
+ <method name="HideMonitorLabels" />
+ <method name="FocusApp">
+ <arg type="s" direction="in" name="id" />
+ </method>
+ <method name="ShowApplications" />
+ <method name="GrabAccelerator">
+ <arg type="s" direction="in" name="accelerator" />
+ <arg type="u" direction="in" name="flags" />
+ <arg type="u" direction="out" name="action" />
+ </method>
+ <method name="GrabAccelerators">
+ <arg type="a(su)" direction="in" name="accelerators" />
+ <arg type="au" direction="out" name="actions" />
+ </method>
+ <method name="UngrabAccelerator">
+ <arg type="u" direction="in" name="action" />
+ <arg type="b" direction="out" name="success" />
+ </method>
+ <signal name="AcceleratorActivated">
+ <arg name="action" type="u" />
+ <arg name="parameters" type="a{sv}" />
+ </signal>
+ <property name="Mode" type="s" access="read" />
+ <property name="OverviewActive" type="b" access="readwrite" />
+ <property name="ShellVersion" type="s" access="read" />
+ </interface>
+</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]