keybindings: convert capplet to a settings panel
Add a module and CcPanel implementation for keyboard shortcuts settings.
This commit is contained in:
parent
f112fc3a8e
commit
19b7502f5e
21 changed files with 560 additions and 92 deletions
|
@ -3,14 +3,12 @@ SUBDIRS = \
|
||||||
accessibility \
|
accessibility \
|
||||||
appearance \
|
appearance \
|
||||||
display \
|
display \
|
||||||
keybindings \
|
|
||||||
windows
|
windows
|
||||||
|
|
||||||
DIST_SUBDIRS = \
|
DIST_SUBDIRS = \
|
||||||
common \
|
common \
|
||||||
accessibility \
|
accessibility \
|
||||||
appearance \
|
appearance \
|
||||||
keybindings \
|
|
||||||
windows \
|
windows \
|
||||||
display \
|
display \
|
||||||
about-me
|
about-me
|
||||||
|
|
|
@ -387,9 +387,9 @@ panels/default-applications/gnome-at-session.desktop.in
|
||||||
panels/default-applications/gnome-default-applications.pc
|
panels/default-applications/gnome-default-applications.pc
|
||||||
capplets/display/Makefile
|
capplets/display/Makefile
|
||||||
capplets/display/display-properties.desktop.in
|
capplets/display/display-properties.desktop.in
|
||||||
capplets/keybindings/Makefile
|
panels/keybindings/Makefile
|
||||||
capplets/keybindings/gnome-keybindings.pc
|
panels/keybindings/gnome-keybindings.pc
|
||||||
capplets/keybindings/keybinding.desktop.in
|
panels/keybindings/keybinding.desktop.in
|
||||||
capplets/windows/Makefile
|
capplets/windows/Makefile
|
||||||
capplets/windows/window-properties.desktop.in
|
capplets/windows/window-properties.desktop.in
|
||||||
docs/Makefile
|
docs/Makefile
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
SUBDIRS=mouse keyboard network default-applications
|
SUBDIRS=mouse keyboard network default-applications keybindings
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
# This is used in GNOMECC_CAPPLETS_CFLAGS
|
# This is used in GNOMECC_CAPPLETS_CFLAGS
|
||||||
cappletname = keybinding
|
cappletname = keybinding
|
||||||
|
|
||||||
bin_PROGRAMS = gnome-keybinding-properties
|
ccpanelsdir = $(PANELS_DIR)
|
||||||
|
ccpanels_LTLIBRARIES = libkeybinding-properties.la
|
||||||
|
|
||||||
gnome_keybinding_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
libkeybinding_properties_la_SOURCES = \
|
||||||
gnome_keybinding_properties_SOURCES = \
|
keybindings-module.c \
|
||||||
|
cc-keybindings-panel.c \
|
||||||
|
cc-keybindings-panel.h \
|
||||||
|
wm-common.c \
|
||||||
|
wm-common.h \
|
||||||
gnome-keybinding-properties.c \
|
gnome-keybinding-properties.c \
|
||||||
eggcellrendererkeys.c \
|
eggcellrendererkeys.c \
|
||||||
eggcellrendererkeys.h \
|
eggcellrendererkeys.h \
|
130
panels/keybindings/cc-keybindings-panel.c
Normal file
130
panels/keybindings/cc-keybindings-panel.c
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
74
panels/keybindings/cc-keybindings-panel.h
Normal file
74
panels/keybindings/cc-keybindings-panel.h
Normal file
|
@ -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 */
|
|
@ -14,7 +14,6 @@
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
#include "wm-common.h"
|
#include "wm-common.h"
|
||||||
#include "capplet-util.h"
|
|
||||||
#include "eggcellrendererkeys.h"
|
#include "eggcellrendererkeys.h"
|
||||||
#include "activate-settings-daemon.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));
|
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*
|
static char*
|
||||||
binding_name (guint keyval,
|
binding_name (guint keyval,
|
||||||
guint keycode,
|
guint keycode,
|
||||||
|
@ -1745,6 +1727,7 @@ maybe_block_accels (GtkWidget *widget,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static void
|
static void
|
||||||
cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
|
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 ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selection_changed (GtkTreeSelection *selection, gpointer data)
|
selection_changed (GtkTreeSelection *selection, gpointer data)
|
||||||
|
@ -1802,6 +1786,40 @@ selection_changed (GtkTreeSelection *selection, gpointer data)
|
||||||
gtk_widget_set_sensitive (button, can_remove);
|
gtk_widget_set_sensitive (button, can_remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
setup_dialog (GtkBuilder *builder)
|
setup_dialog (GtkBuilder *builder)
|
||||||
{
|
{
|
||||||
|
@ -1869,11 +1887,8 @@ setup_dialog (GtkBuilder *builder)
|
||||||
reload_key_entries (builder);
|
reload_key_entries (builder);
|
||||||
|
|
||||||
widget = _gtk_builder_get_widget (builder, "gnome-keybinding-dialog");
|
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, "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));
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
|
||||||
g_signal_connect (selection, "changed",
|
g_signal_connect (selection, "changed",
|
||||||
|
@ -1901,10 +1916,18 @@ setup_dialog (GtkBuilder *builder)
|
||||||
"custom-shortcut-name-entry");
|
"custom-shortcut-name-entry");
|
||||||
custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
|
custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
|
||||||
"custom-shortcut-command-entry");
|
"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_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog),
|
||||||
GTK_RESPONSE_OK);
|
GTK_RESPONSE_OK);
|
||||||
|
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog),
|
gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog),
|
||||||
GTK_WINDOW (widget));
|
GTK_WINDOW (widget));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1913,34 +1936,12 @@ on_window_manager_change (const char *wm_name, GtkBuilder *builder)
|
||||||
reload_key_entries (builder);
|
reload_key_entries (builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
main (int argc, char *argv[])
|
gnome_keybinding_properties_init (GtkBuilder *builder)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
wm_common_register_window_manager_change ((GFunc) on_window_manager_change,
|
||||||
|
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);
|
|
||||||
setup_dialog (builder);
|
setup_dialog (builder);
|
||||||
|
|
||||||
gtk_main ();
|
|
||||||
|
|
||||||
g_object_unref (builder);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -10,15 +10,18 @@
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
<object class="GtkVBox" id="shortcut_dialog">
|
<object class="GtkVBox" id="shortcut_dialog">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">2</property>
|
<property name="spacing">2</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkVBox" id="vbox3">
|
<object class="GtkVBox" id="vbox3">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkVBox" id="shortcuts_vbox">
|
<object class="GtkVBox" id="shortcuts_vbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="actions_swindow">
|
<object class="GtkScrolledWindow" id="actions_swindow">
|
||||||
|
@ -80,6 +83,48 @@
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
|
@ -105,35 +150,10 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="add-button">
|
<placeholder/>
|
||||||
<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>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="remove-button">
|
<placeholder/>
|
||||||
<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>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="button1">
|
<object class="GtkButton" id="button1">
|
||||||
|
@ -161,8 +181,6 @@
|
||||||
</child>
|
</child>
|
||||||
<action-widgets>
|
<action-widgets>
|
||||||
<action-widget response="-11">helpbutton1</action-widget>
|
<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-widget response="-7">button1</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</object>
|
41
panels/keybindings/keybindings-module.c
Normal file
41
panels/keybindings/keybindings-module.c
Normal file
|
@ -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)
|
||||||
|
{
|
||||||
|
}
|
184
panels/keybindings/wm-common.c
Normal file
184
panels/keybindings/wm-common.c
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
17
panels/keybindings/wm-common.h
Normal file
17
panels/keybindings/wm-common.h
Normal file
|
@ -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 */
|
||||||
|
|
|
@ -46,12 +46,12 @@ capplets/display/display-properties.desktop.in.in
|
||||||
capplets/display/gnome-display-properties-install-systemwide.c
|
capplets/display/gnome-display-properties-install-systemwide.c
|
||||||
capplets/display/org.gnome.randr.policy.in
|
capplets/display/org.gnome.randr.policy.in
|
||||||
capplets/display/xrandr-capplet.c
|
capplets/display/xrandr-capplet.c
|
||||||
capplets/keybindings/00-multimedia-key.xml.in
|
panels/keybindings/00-multimedia-key.xml.in
|
||||||
capplets/keybindings/01-desktop-key.xml.in
|
panels/keybindings/01-desktop-key.xml.in
|
||||||
capplets/keybindings/eggcellrendererkeys.c
|
panels/keybindings/eggcellrendererkeys.c
|
||||||
capplets/keybindings/gnome-keybinding-properties.c
|
panels/keybindings/gnome-keybinding-properties.c
|
||||||
[type: gettext/glade]capplets/keybindings/gnome-keybinding-properties.ui
|
[type: gettext/glade]panels/keybindings/gnome-keybinding-properties.ui
|
||||||
capplets/keybindings/keybinding.desktop.in.in
|
panels/keybindings/keybinding.desktop.in.in
|
||||||
panels/keyboard/gnome-keyboard-properties.c
|
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-a11y-notifications.ui
|
||||||
[type: gettext/glade]panels/keyboard/gnome-keyboard-properties-dialog.ui
|
[type: gettext/glade]panels/keyboard/gnome-keyboard-properties-dialog.ui
|
||||||
|
|
|
@ -7,7 +7,7 @@ capplets/appearance/data/gnome-theme-package.xml
|
||||||
panels/default-applications/default-applications.desktop.in
|
panels/default-applications/default-applications.desktop.in
|
||||||
panels/default-applications/gnome-at-session.desktop.in
|
panels/default-applications/gnome-at-session.desktop.in
|
||||||
capplets/display/display-properties.desktop.in
|
capplets/display/display-properties.desktop.in
|
||||||
capplets/keybindings/keybinding.desktop.in
|
panels/keybindings/keybinding.desktop.in
|
||||||
panels/keyboard/keyboard.desktop.in
|
panels/keyboard/keyboard.desktop.in
|
||||||
capplets/localization/localization.desktop.in
|
capplets/localization/localization.desktop.in
|
||||||
capplets/mouse/gnome-settings-mouse.desktop.in
|
capplets/mouse/gnome-settings-mouse.desktop.in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue