keyboard: Separate code for tabs in notebooks

This commit is contained in:
Rodrigo Moya 2010-12-07 16:29:22 +01:00
parent fa9c9818df
commit 974acd358e
7 changed files with 184 additions and 38 deletions

View file

@ -10,8 +10,10 @@ libkeyboard_la_SOURCES = \
cc-keyboard-panel.h \ cc-keyboard-panel.h \
wm-common.c \ wm-common.c \
wm-common.h \ wm-common.h \
gnome-keyboard-panel.c \ keyboard-general.c \
gnome-keyboard-panel.h \ keyboard-general.h \
keyboard-shortcuts.c \
keyboard-shortcuts.h \
eggcellrendererkeys.c \ eggcellrendererkeys.c \
eggcellrendererkeys.h \ eggcellrendererkeys.h \
eggaccelerators.c \ eggaccelerators.c \

View file

@ -20,7 +20,8 @@
*/ */
#include "cc-keyboard-panel.h" #include "cc-keyboard-panel.h"
#include "gnome-keyboard-panel.h" #include "keyboard-general.h"
#include "keyboard-shortcuts.h"
G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL) G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL)
@ -62,7 +63,8 @@ cc_keyboard_panel_set_property (GObject *object,
static void static void
cc_keyboard_panel_dispose (GObject *object) cc_keyboard_panel_dispose (GObject *object)
{ {
gnome_keybinding_properties_dispose (CC_PANEL (object)); keyboard_general_dispose (CC_PANEL (object));
keyboard_shortcuts_dispose (CC_PANEL (object));
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->dispose (object); G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->dispose (object);
} }
@ -102,7 +104,8 @@ cc_keyboard_panel_constructor (GType gtype,
return obj; return obj;
} }
gnome_keybinding_properties_init (CC_PANEL (self), priv->builder); keyboard_general_init (CC_PANEL (self), priv->builder);
keyboard_shortcuts_init (CC_PANEL (self), priv->builder);
widget = (GtkWidget *) gtk_builder_get_object (priv->builder, widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
"keyboard_notebook"); "keyboard_notebook");

View file

@ -82,9 +82,7 @@ static gboolean block_accels = FALSE;
static GtkWidget *custom_shortcut_dialog = NULL; static GtkWidget *custom_shortcut_dialog = NULL;
static GtkWidget *custom_shortcut_name_entry = NULL; static GtkWidget *custom_shortcut_name_entry = NULL;
static GtkWidget *custom_shortcut_command_entry = NULL; static GtkWidget *custom_shortcut_command_entry = NULL;
static GHashTable *keyb_sections = NULL;
static GSettings *keyboard_settings = NULL;
static GSettings *interface_settings = NULL;
#define WID(builder, name) (GTK_WIDGET (gtk_builder_get_object (builder, name))) #define WID(builder, name) (GTK_WIDGET (gtk_builder_get_object (builder, name)))
@ -1576,7 +1574,7 @@ add_custom_shortcut (GtkTreeView *tree_view,
key_entry->gconf_cnxn_desc = gconf_client_notify_add (client, key_entry->gconf_cnxn_desc = gconf_client_notify_add (client,
key_entry->desc_gconf_key, key_entry->desc_gconf_key,
(GConfClientNotifyFunc) &keybinding_description_changed, (GConfClientNotifyFunc) &keybinding_description_changed,
key_entry, NULL, NULL); key_entry, NULL, NULL);
key_entry->gconf_cnxn_cmd = gconf_client_notify_add (client, key_entry->gconf_cnxn_cmd = gconf_client_notify_add (client,
key_entry->cmd_gconf_key, key_entry->cmd_gconf_key,
(GConfClientNotifyFunc) &keybinding_command_changed, (GConfClientNotifyFunc) &keybinding_command_changed,
@ -1821,33 +1819,6 @@ remove_button_clicked (GtkWidget *button,
} }
} }
static void
setup_general_page (GtkBuilder *builder)
{
if (keyboard_settings == NULL)
keyboard_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.keyboard");
if (interface_settings == NULL)
interface_settings = g_settings_new ("org.gnome.desktop.interface");
g_settings_bind (keyboard_settings, "repeat",
gtk_builder_get_object (builder, "repeat_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (keyboard_settings, "delay",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_delay_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (keyboard_settings, "rate",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_speed_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (interface_settings, "cursor-blink",
gtk_builder_get_object (builder, "cursor_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (interface_settings, "cursor-blink-time",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "cursor_blink_time_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
}
static void static void
setup_dialog (CcPanel *panel, GtkBuilder *builder) setup_dialog (CcPanel *panel, GtkBuilder *builder)
{ {
@ -1860,8 +1831,6 @@ setup_dialog (CcPanel *panel, GtkBuilder *builder)
GSList *allowed_keys; GSList *allowed_keys;
CcShell *shell; CcShell *shell;
setup_general_page (builder);
treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,
"shortcut_treeview")); "shortcut_treeview"));
@ -1972,6 +1941,9 @@ gnome_keybinding_properties_init (CcPanel *panel, GtkBuilder *builder)
{ {
wm_common_register_window_manager_change ((GFunc) on_window_manager_change, wm_common_register_window_manager_change ((GFunc) on_window_manager_change,
builder); builder);
keyb_sections = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, free_key_list);
setup_dialog (panel, builder); setup_dialog (panel, builder);
} }
@ -1988,6 +1960,9 @@ gnome_keybinding_properties_dispose (CcPanel *panel)
g_signal_handler_disconnect (toplevel, maybe_block_accels_id); g_signal_handler_disconnect (toplevel, maybe_block_accels_id);
maybe_block_accels_id = 0; maybe_block_accels_id = 0;
if (keyb_sections != NULL)
g_hash_table_destroy (keyb_sections);
} }
} }

View file

@ -0,0 +1,68 @@
/*
* 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.
*
* Authors: Thomas Wood <thomas.wood@intel.com>
* Rodrigo Moya <rodrigo@gnome.org>
*/
#include "keyboard-general.h"
static GSettings *keyboard_settings = NULL;
static GSettings *interface_settings = NULL;
void
keyboard_general_init (CcPanel *panel, GtkBuilder *builder)
{
if (keyboard_settings == NULL)
keyboard_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.keyboard");
if (interface_settings == NULL)
interface_settings = g_settings_new ("org.gnome.desktop.interface");
g_settings_bind (keyboard_settings, "repeat",
gtk_builder_get_object (builder, "repeat_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (keyboard_settings, "delay",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_delay_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (keyboard_settings, "rate",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_speed_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (interface_settings, "cursor-blink",
gtk_builder_get_object (builder, "cursor_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (interface_settings, "cursor-blink-time",
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "cursor_blink_time_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
}
void
keyboard_general_dispose (CcPanel *panel)
{
if (keyboard_settings != NULL)
{
g_object_unref (keyboard_settings);
keyboard_settings = NULL;
}
if (interface_settings != NULL)
{
g_object_unref (interface_settings);
interface_settings = NULL;
}
}

View file

@ -0,0 +1,26 @@
/*
* 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.
*
* Authors: Thomas Wood <thomas.wood@intel.com>
* Rodrigo Moya <rodrigo@gnome.org>
*/
#include <gtk/gtk.h>
#include <libgnome-control-center/cc-panel.h>
void keyboard_general_init (CcPanel *panel, GtkBuilder *builder);
void keyboard_general_dispose (CcPanel *panel);

View file

@ -0,0 +1,46 @@
/*
* 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.
*
* Authors: Thomas Wood <thomas.wood@intel.com>
* Rodrigo Moya <rodrigo@gnome.org>
*/
#include "keyboard-shortcuts.h"
GHashTable *kb_sections = NULL;
static void
free_key_list (gpointer list)
{
}
static void
setup_dialog (CcPanel *panel, GtkBuilder *builder)
{
}
void
keyboard_shortcuts_init (CcPanel *panel, GtkBuilder *builder)
{
kb_sections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_key_list);
setup_dialog (panel, builder);
}
void
keyboard_shortcuts_dispose (CcPanel *panel)
{
}

View file

@ -0,0 +1,26 @@
/*
* 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.
*
* Authors: Thomas Wood <thomas.wood@intel.com>
* Rodrigo Moya <rodrigo@gnome.org>
*/
#include <gtk/gtk.h>
#include <libgnome-control-center/cc-panel.h>
void keyboard_shortcuts_init (CcPanel *panel, GtkBuilder *builder);
void keyboard_shortcuts_dispose (CcPanel *panel);