[gnome-control-center] keybindings: convert capplet to a settings panel
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keybindings: convert capplet to a settings panel
- Date: Mon, 24 May 2010 22:21:46 +0000 (UTC)
commit 19b7502f5efb35a133119df43520496ccfb9c8b3
Author: Thomas Wood <thomas wood intel com>
Date: Mon May 24 17:42:52 2010 +0100
keybindings: convert capplet to a settings panel
Add a module and CcPanel implementation for keyboard shortcuts settings.
capplets/Makefile.am | 2 -
configure.ac | 6 +-
panels/Makefile.am | 2 +-
.../keybindings/00-multimedia-key.xml.in | 0
.../keybindings/01-desktop-key.xml.in | 0
{capplets => panels}/keybindings/Makefile.am | 11 +-
panels/keybindings/cc-keybindings-panel.c | 130 ++++++++++++++
panels/keybindings/cc-keybindings-panel.h | 74 ++++++++
{capplets => panels}/keybindings/eggaccelerators.c | 0
{capplets => panels}/keybindings/eggaccelerators.h | 0
.../keybindings/eggcellrendererkeys.c | 0
.../keybindings/eggcellrendererkeys.h | 0
.../keybindings/gnome-keybinding-properties.c | 95 +++++-----
.../keybindings/gnome-keybinding-properties.ui | 76 +++++---
.../keybindings/gnome-keybindings.pc.in | 0
.../keybindings/keybinding.desktop.in.in | 0
panels/keybindings/keybindings-module.c | 41 +++++
panels/keybindings/wm-common.c | 184 ++++++++++++++++++++
panels/keybindings/wm-common.h | 17 ++
po/POTFILES.in | 12 +-
po/POTFILES.skip | 2 +-
21 files changed, 560 insertions(+), 92 deletions(-)
---
diff --git a/capplets/Makefile.am b/capplets/Makefile.am
index c8262fa..460600e 100644
--- a/capplets/Makefile.am
+++ b/capplets/Makefile.am
@@ -3,14 +3,12 @@ SUBDIRS = \
accessibility \
appearance \
display \
- keybindings \
windows
DIST_SUBDIRS = \
common \
accessibility \
appearance \
- keybindings \
windows \
display \
about-me
diff --git a/configure.ac b/configure.ac
index d39ae05..e49fb24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -387,9 +387,9 @@ panels/default-applications/gnome-at-session.desktop.in
panels/default-applications/gnome-default-applications.pc
capplets/display/Makefile
capplets/display/display-properties.desktop.in
-capplets/keybindings/Makefile
-capplets/keybindings/gnome-keybindings.pc
-capplets/keybindings/keybinding.desktop.in
+panels/keybindings/Makefile
+panels/keybindings/gnome-keybindings.pc
+panels/keybindings/keybinding.desktop.in
capplets/windows/Makefile
capplets/windows/window-properties.desktop.in
docs/Makefile
diff --git a/panels/Makefile.am b/panels/Makefile.am
index 1a7acd7..3d62fef 100644
--- a/panels/Makefile.am
+++ b/panels/Makefile.am
@@ -1 +1 @@
-SUBDIRS=mouse keyboard network default-applications
+SUBDIRS=mouse keyboard network default-applications keybindings
diff --git a/capplets/keybindings/00-multimedia-key.xml.in b/panels/keybindings/00-multimedia-key.xml.in
similarity index 100%
rename from capplets/keybindings/00-multimedia-key.xml.in
rename to panels/keybindings/00-multimedia-key.xml.in
diff --git a/capplets/keybindings/01-desktop-key.xml.in b/panels/keybindings/01-desktop-key.xml.in
similarity index 100%
rename from capplets/keybindings/01-desktop-key.xml.in
rename to panels/keybindings/01-desktop-key.xml.in
diff --git a/capplets/keybindings/Makefile.am b/panels/keybindings/Makefile.am
similarity index 82%
rename from capplets/keybindings/Makefile.am
rename to panels/keybindings/Makefile.am
index 62847fa..85d4def 100644
--- a/capplets/keybindings/Makefile.am
+++ b/panels/keybindings/Makefile.am
@@ -1,10 +1,15 @@
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = keybinding
-bin_PROGRAMS = gnome-keybinding-properties
-
-gnome_keybinding_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
-gnome_keybinding_properties_SOURCES = \
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libkeybinding-properties.la
+
+libkeybinding_properties_la_SOURCES = \
+ keybindings-module.c \
+ cc-keybindings-panel.c \
+ cc-keybindings-panel.h \
+ wm-common.c \
+ wm-common.h \
gnome-keybinding-properties.c \
eggcellrendererkeys.c \
eggcellrendererkeys.h \
diff --git a/panels/keybindings/cc-keybindings-panel.c b/panels/keybindings/cc-keybindings-panel.c
new file mode 100644
index 0000000..a4479f9
--- /dev/null
+++ b/panels/keybindings/cc-keybindings-panel.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include "cc-keybindings-panel.h"
+
+G_DEFINE_DYNAMIC_TYPE (CcKeybindingsPanel, cc_keybindings_panel, CC_TYPE_PANEL)
+
+#define KEYBINDINGS_PANEL_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBINDINGS_PANEL, CcKeybindingsPanelPrivate))
+
+struct _CcKeybindingsPanelPrivate
+{
+ GtkBuilder *builder;
+};
+
+
+static void
+cc_keybindings_panel_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_keybindings_panel_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_keybindings_panel_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (cc_keybindings_panel_parent_class)->dispose (object);
+}
+
+static void
+cc_keybindings_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (cc_keybindings_panel_parent_class)->finalize (object);
+}
+
+static void
+cc_keybindings_panel_class_init (CcKeybindingsPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CcKeybindingsPanelPrivate));
+
+ object_class->get_property = cc_keybindings_panel_get_property;
+ object_class->set_property = cc_keybindings_panel_set_property;
+ object_class->dispose = cc_keybindings_panel_dispose;
+ object_class->finalize = cc_keybindings_panel_finalize;
+}
+
+static void
+cc_keybindings_panel_class_finalize (CcKeybindingsPanelClass *klass)
+{
+}
+
+static void
+cc_keybindings_panel_init (CcKeybindingsPanel *self)
+{
+ CcKeybindingsPanelPrivate *priv;
+ GError *error = NULL;
+ const gchar *uifile = GNOMECC_UI_DIR "/gnome-keybinding-properties.ui";
+
+ priv = self->priv = KEYBINDINGS_PANEL_PRIVATE (self);
+
+
+ priv->builder = gtk_builder_new ();
+
+ if (gtk_builder_add_from_file (priv->builder, uifile, &error) == 0)
+ {
+ g_warning ("Could not load UI: %s", error->message);
+ g_clear_error (&error);
+ g_object_unref (priv->builder);
+ priv->builder = NULL;
+ return;
+ }
+
+ gnome_keybinding_properties_init (priv->builder);
+
+ GtkWidget *widget;
+
+ widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
+ "vbox3");
+
+ gtk_widget_reparent (widget, (GtkWidget *) self);
+}
+
+void
+cc_keybindings_panel_register (GIOModule *module)
+{
+ cc_keybindings_panel_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+ CC_TYPE_KEYBINDINGS_PANEL,
+ "keybinding.desktop", 0);
+}
+
diff --git a/panels/keybindings/cc-keybindings-panel.h b/panels/keybindings/cc-keybindings-panel.h
new file mode 100644
index 0000000..cfd7be2
--- /dev/null
+++ b/panels/keybindings/cc-keybindings-panel.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+
+#ifndef _CC_KEYBINDINGS_PANEL_H
+#define _CC_KEYBINDINGS_PANEL_H
+
+#include <libgnome-control-center/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_KEYBINDINGS_PANEL cc_keybindings_panel_get_type()
+
+#define CC_KEYBINDINGS_PANEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_KEYBINDINGS_PANEL, CcKeybindingsPanel))
+
+#define CC_KEYBINDINGS_PANEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_KEYBINDINGS_PANEL, CcKeybindingsPanelClass))
+
+#define CC_IS_KEYBINDINGS_PANEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_KEYBINDINGS_PANEL))
+
+#define CC_IS_KEYBINDINGS_PANEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_KEYBINDINGS_PANEL))
+
+#define CC_KEYBINDINGS_PANEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_KEYBINDINGS_PANEL, CcKeybindingsPanelClass))
+
+typedef struct _CcKeybindingsPanel CcKeybindingsPanel;
+typedef struct _CcKeybindingsPanelClass CcKeybindingsPanelClass;
+typedef struct _CcKeybindingsPanelPrivate CcKeybindingsPanelPrivate;
+
+struct _CcKeybindingsPanel
+{
+ CcPanel parent;
+
+ CcKeybindingsPanelPrivate *priv;
+};
+
+struct _CcKeybindingsPanelClass
+{
+ CcPanelClass parent_class;
+};
+
+GType cc_keybindings_panel_get_type (void) G_GNUC_CONST;
+
+void cc_keybindings_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_KEYBINDINGS_PANEL_H */
diff --git a/capplets/keybindings/eggaccelerators.c b/panels/keybindings/eggaccelerators.c
similarity index 100%
rename from capplets/keybindings/eggaccelerators.c
rename to panels/keybindings/eggaccelerators.c
diff --git a/capplets/keybindings/eggaccelerators.h b/panels/keybindings/eggaccelerators.h
similarity index 100%
rename from capplets/keybindings/eggaccelerators.h
rename to panels/keybindings/eggaccelerators.h
diff --git a/capplets/keybindings/eggcellrendererkeys.c b/panels/keybindings/eggcellrendererkeys.c
similarity index 100%
rename from capplets/keybindings/eggcellrendererkeys.c
rename to panels/keybindings/eggcellrendererkeys.c
diff --git a/capplets/keybindings/eggcellrendererkeys.h b/panels/keybindings/eggcellrendererkeys.h
similarity index 100%
rename from capplets/keybindings/eggcellrendererkeys.h
rename to panels/keybindings/eggcellrendererkeys.h
diff --git a/capplets/keybindings/gnome-keybinding-properties.c b/panels/keybindings/gnome-keybinding-properties.c
similarity index 97%
rename from capplets/keybindings/gnome-keybinding-properties.c
rename to panels/keybindings/gnome-keybinding-properties.c
index d383def..afaec74 100644
--- a/capplets/keybindings/gnome-keybinding-properties.c
+++ b/panels/keybindings/gnome-keybinding-properties.c
@@ -14,7 +14,6 @@
#include <gdk/gdkkeysyms.h>
#include "wm-common.h"
-#include "capplet-util.h"
#include "eggcellrendererkeys.h"
#include "activate-settings-daemon.h"
@@ -88,23 +87,6 @@ _gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
return GTK_WIDGET (gtk_builder_get_object (builder, name));
}
-static GtkBuilder *
-create_builder (void)
-{
- GtkBuilder *builder = gtk_builder_new();
- GError *error = NULL;
- static const gchar *uifile = GNOMECC_UI_DIR "/gnome-keybinding-properties.ui";
-
- if (gtk_builder_add_from_file (builder, uifile, &error) == 0) {
- g_warning ("Could not load UI: %s", error->message);
- g_error_free (error);
- g_object_unref (builder);
- builder = NULL;
- }
-
- return builder;
-}
-
static char*
binding_name (guint keyval,
guint keycode,
@@ -1745,6 +1727,7 @@ maybe_block_accels (GtkWidget *widget,
return FALSE;
}
+#if 0
static void
cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
{
@@ -1781,6 +1764,7 @@ cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
gtk_main_quit ();
}
}
+#endif
static void
selection_changed (GtkTreeSelection *selection, gpointer data)
@@ -1803,6 +1787,40 @@ selection_changed (GtkTreeSelection *selection, gpointer data)
}
static void
+add_button_clicked (GtkWidget *button,
+ GtkBuilder *builder)
+{
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,
+ "shortcut_treeview"));
+ model = gtk_tree_view_get_model (treeview);
+
+ add_custom_shortcut (treeview, model);
+}
+
+static void
+remove_button_clicked (GtkWidget *button,
+ GtkBuilder *builder)
+{
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+
+ treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,
+ "shortcut_treeview"));
+ model = gtk_tree_view_get_model (treeview);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ {
+ remove_custom_shortcut (model, &iter);
+ }
+}
+
+static void
setup_dialog (GtkBuilder *builder)
{
GConfClient *client;
@@ -1869,11 +1887,8 @@ setup_dialog (GtkBuilder *builder)
reload_key_entries (builder);
widget = _gtk_builder_get_widget (builder, "gnome-keybinding-dialog");
- capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts");
- gtk_widget_show (widget);
g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL);
- g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
g_signal_connect (selection, "changed",
@@ -1901,10 +1916,18 @@ setup_dialog (GtkBuilder *builder)
"custom-shortcut-name-entry");
custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
"custom-shortcut-command-entry");
+ g_signal_connect (_gtk_builder_get_widget (builder, "add-button"),
+ "clicked", G_CALLBACK (add_button_clicked), builder);
+ g_signal_connect (_gtk_builder_get_widget (builder, "remove-button"),
+ "clicked", G_CALLBACK (remove_button_clicked), builder);
+
+#if 0
gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog),
GTK_RESPONSE_OK);
+
gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog),
GTK_WINDOW (widget));
+#endif
}
static void
@@ -1913,34 +1936,12 @@ on_window_manager_change (const char *wm_name, GtkBuilder *builder)
reload_key_entries (builder);
}
-int
-main (int argc, char *argv[])
+void
+gnome_keybinding_properties_init (GtkBuilder *builder)
{
- GtkBuilder *builder;
-
- g_thread_init (NULL);
- gtk_init (&argc, &argv);
-
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-
- gtk_init (&argc, &argv);
-
- activate_settings_daemon ();
-
- builder = create_builder ();
-
- if (!builder) /* Warning was already printed to console */
- exit (EXIT_FAILURE);
-
- wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder);
+ wm_common_register_window_manager_change ((GFunc) on_window_manager_change,
+ builder);
setup_dialog (builder);
-
- gtk_main ();
-
- g_object_unref (builder);
- return 0;
}
/*
diff --git a/capplets/keybindings/gnome-keybinding-properties.ui b/panels/keybindings/gnome-keybinding-properties.ui
similarity index 86%
rename from capplets/keybindings/gnome-keybinding-properties.ui
rename to panels/keybindings/gnome-keybinding-properties.ui
index 75795b4..8575448 100644
--- a/capplets/keybindings/gnome-keybinding-properties.ui
+++ b/panels/keybindings/gnome-keybinding-properties.ui
@@ -10,15 +10,18 @@
<child internal-child="vbox">
<object class="GtkVBox" id="shortcut_dialog">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="border_width">5</property>
+ <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="shortcuts_vbox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkScrolledWindow" id="actions_swindow">
@@ -80,6 +83,48 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="add-button">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="remove-button">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
@@ -105,35 +150,10 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="add-button">
- <property name="label">gtk-add</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
<child>
- <object class="GtkButton" id="remove-button">
- <property name="label">gtk-remove</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
+ <placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
@@ -161,8 +181,6 @@
</child>
<action-widgets>
<action-widget response="-11">helpbutton1</action-widget>
- <action-widget response="0">add-button</action-widget>
- <action-widget response="1">remove-button</action-widget>
<action-widget response="-7">button1</action-widget>
</action-widgets>
</object>
diff --git a/capplets/keybindings/gnome-keybindings.pc.in b/panels/keybindings/gnome-keybindings.pc.in
similarity index 100%
rename from capplets/keybindings/gnome-keybindings.pc.in
rename to panels/keybindings/gnome-keybindings.pc.in
diff --git a/capplets/keybindings/keybinding.desktop.in.in b/panels/keybindings/keybinding.desktop.in.in
similarity index 100%
rename from capplets/keybindings/keybinding.desktop.in.in
rename to panels/keybindings/keybinding.desktop.in.in
diff --git a/panels/keybindings/keybindings-module.c b/panels/keybindings/keybindings-module.c
new file mode 100644
index 0000000..09ed934
--- /dev/null
+++ b/panels/keybindings/keybindings-module.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include <config.h>
+
+#include "cc-keybindings-panel.h"
+
+#include <glib/gi18n.h>
+
+void
+g_io_module_load (GIOModule *module)
+{
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ /* register the panel */
+ cc_keybindings_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
diff --git a/panels/keybindings/wm-common.c b/panels/keybindings/wm-common.c
new file mode 100644
index 0000000..6ffc6be
--- /dev/null
+++ b/panels/keybindings/wm-common.c
@@ -0,0 +1,184 @@
+#include <X11/Xatom.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdk.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include "wm-common.h"
+
+typedef struct _WMCallbackData
+{
+ GFunc func;
+ gpointer data;
+} WMCallbackData;
+
+/* Our WM Window */
+static Window wm_window = None;
+
+static char *
+wm_common_get_window_manager_property (Atom atom)
+{
+ Atom utf8_string, type;
+ int result;
+ char *retval;
+ int format;
+ gulong nitems;
+ gulong bytes_after;
+ gchar *val;
+
+ if (wm_window == None)
+ return NULL;
+
+ utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False);
+
+ gdk_error_trap_push ();
+
+ val = NULL;
+ result = XGetWindowProperty (GDK_DISPLAY (),
+ wm_window,
+ atom,
+ 0, G_MAXLONG,
+ False, utf8_string,
+ &type, &format, &nitems,
+ &bytes_after, (guchar **) &val);
+
+ if (gdk_error_trap_pop () || result != Success ||
+ type != utf8_string || format != 8 || nitems == 0 ||
+ !g_utf8_validate (val, nitems, NULL))
+ {
+ retval = NULL;
+ }
+ else
+ {
+ retval = g_strndup (val, nitems);
+ }
+
+ if (val)
+ XFree (val);
+
+ return retval;
+}
+
+char*
+wm_common_get_current_window_manager (void)
+{
+ Atom atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);
+ char *result;
+
+ result = wm_common_get_window_manager_property (atom);
+ if (result)
+ return result;
+ else
+ return g_strdup (WM_COMMON_UNKNOWN);
+}
+
+char**
+wm_common_get_current_keybindings (void)
+{
+ Atom keybindings_atom = XInternAtom (GDK_DISPLAY (), "_GNOME_WM_KEYBINDINGS", False);
+ char *keybindings = wm_common_get_window_manager_property (keybindings_atom);
+ char **results;
+
+ if (keybindings)
+ {
+ char **p;
+ results = g_strsplit(keybindings, ",", -1);
+ for (p = results; *p; p++)
+ g_strstrip (*p);
+ g_free (keybindings);
+ }
+ else
+ {
+ Atom wm_atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);
+ char *wm_name = wm_common_get_window_manager_property (wm_atom);
+ char *to_copy[] = { NULL, NULL };
+
+ to_copy[0] = wm_name ? wm_name : WM_COMMON_UNKNOWN;
+
+ results = g_strdupv (to_copy);
+ g_free (wm_name);
+ }
+
+ return results;
+}
+
+static void
+update_wm_window (void)
+{
+ Window *xwindow;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+
+ XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
+ XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False),
+ 0, G_MAXLONG, False, XA_WINDOW, &type, &format,
+ &nitems, &bytes_after, (guchar **) &xwindow);
+
+ if (type != XA_WINDOW)
+ {
+ wm_window = None;
+ return;
+ }
+
+ gdk_error_trap_push ();
+ XSelectInput (GDK_DISPLAY (), *xwindow, StructureNotifyMask | PropertyChangeMask);
+ XSync (GDK_DISPLAY (), False);
+
+ if (gdk_error_trap_pop ())
+ {
+ XFree (xwindow);
+ wm_window = None;
+ return;
+ }
+
+ wm_window = *xwindow;
+ XFree (xwindow);
+}
+
+static GdkFilterReturn
+wm_window_event_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data)
+{
+ WMCallbackData *ncb_data = (WMCallbackData*) data;
+ XEvent *xevent = (XEvent *)xev;
+
+ if ((xevent->type == DestroyNotify &&
+ wm_window != None && xevent->xany.window == wm_window) ||
+ (xevent->type == PropertyNotify &&
+ xevent->xany.window == GDK_ROOT_WINDOW () &&
+ xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False))) ||
+ (xevent->type == PropertyNotify &&
+ wm_window != None && xevent->xany.window == wm_window &&
+ xevent->xproperty.atom == (XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False))))
+ {
+ update_wm_window ();
+ (* ncb_data->func) ((gpointer)wm_common_get_current_window_manager(),
+ ncb_data->data);
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
+void
+wm_common_register_window_manager_change (GFunc func,
+ gpointer data)
+{
+ WMCallbackData *ncb_data;
+
+ ncb_data = g_new0 (WMCallbackData, 1);
+
+ ncb_data->func = func;
+ ncb_data->data = data;
+
+ gdk_window_add_filter (NULL, wm_window_event_filter, ncb_data);
+
+ update_wm_window ();
+
+ XSelectInput (GDK_DISPLAY (), GDK_ROOT_WINDOW (), PropertyChangeMask);
+ XSync (GDK_DISPLAY (), False);
+}
+
+
diff --git a/panels/keybindings/wm-common.h b/panels/keybindings/wm-common.h
new file mode 100644
index 0000000..4da0d28
--- /dev/null
+++ b/panels/keybindings/wm-common.h
@@ -0,0 +1,17 @@
+#ifndef WM_COMMON_H
+#define WM_COMMON_H
+
+#define WM_COMMON_METACITY "Metacity"
+#define WM_COMMON_SAWFISH "Sawfish"
+#define WM_COMMON_UNKNOWN "Unknown"
+
+gchar *wm_common_get_current_window_manager (void);
+/* Returns a strv of keybinding names for the window manager;
+ * using _GNOME_WM_KEYBINDINGS if available, _NET_WM_NAME otherwise. */
+char **wm_common_get_current_keybindings (void);
+
+void wm_common_register_window_manager_change (GFunc func,
+ gpointer data);
+
+#endif /* WM_COMMON_H */
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0e29468..f621861 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -46,12 +46,12 @@ capplets/display/display-properties.desktop.in.in
capplets/display/gnome-display-properties-install-systemwide.c
capplets/display/org.gnome.randr.policy.in
capplets/display/xrandr-capplet.c
-capplets/keybindings/00-multimedia-key.xml.in
-capplets/keybindings/01-desktop-key.xml.in
-capplets/keybindings/eggcellrendererkeys.c
-capplets/keybindings/gnome-keybinding-properties.c
-[type: gettext/glade]capplets/keybindings/gnome-keybinding-properties.ui
-capplets/keybindings/keybinding.desktop.in.in
+panels/keybindings/00-multimedia-key.xml.in
+panels/keybindings/01-desktop-key.xml.in
+panels/keybindings/eggcellrendererkeys.c
+panels/keybindings/gnome-keybinding-properties.c
+[type: gettext/glade]panels/keybindings/gnome-keybinding-properties.ui
+panels/keybindings/keybinding.desktop.in.in
panels/keyboard/gnome-keyboard-properties.c
[type: gettext/glade]panels/keyboard/gnome-keyboard-properties-a11y-notifications.ui
[type: gettext/glade]panels/keyboard/gnome-keyboard-properties-dialog.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 13bbcdd..0986458 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -7,7 +7,7 @@ capplets/appearance/data/gnome-theme-package.xml
panels/default-applications/default-applications.desktop.in
panels/default-applications/gnome-at-session.desktop.in
capplets/display/display-properties.desktop.in
-capplets/keybindings/keybinding.desktop.in
+panels/keybindings/keybinding.desktop.in
panels/keyboard/keyboard.desktop.in
capplets/localization/localization.desktop.in
capplets/mouse/gnome-settings-mouse.desktop.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]