Converted keyboard capplet to panel

This commit is contained in:
Sergey V. Udaltsov 2010-05-21 23:22:29 +01:00
parent a4c7d59ec4
commit 7840afd7a1
26 changed files with 355 additions and 134 deletions

View file

@ -5,7 +5,6 @@ SUBDIRS = \
default-applications \ default-applications \
display \ display \
keybindings \ keybindings \
keyboard \
network \ network \
windows windows
@ -15,7 +14,6 @@ DIST_SUBDIRS = \
appearance \ appearance \
default-applications \ default-applications \
keybindings \ keybindings \
keyboard \
network \ network \
windows \ windows \
display \ display \

View file

@ -1,42 +0,0 @@
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = keyboard
bin_PROGRAMS = gnome-keyboard-properties
gnome_keyboard_properties_SOURCES = \
gnome-keyboard-properties.c \
gnome-keyboard-properties-a11y.c \
gnome-keyboard-properties-a11y.h \
gnome-keyboard-properties-xkb.c \
gnome-keyboard-properties-xkbmc.c \
gnome-keyboard-properties-xkblt.c \
gnome-keyboard-properties-xkbltadd.c \
gnome-keyboard-properties-xkbot.c \
gnome-keyboard-properties-xkbpv.c \
gnome-keyboard-properties-xkb.h
gnome_keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(LIBGNOMEKBDUI_LIBS)
@INTLTOOL_DESKTOP_RULE@
uidir = $(pkgdatadir)/ui
dist_ui_DATA = gnome-keyboard-properties-a11y-notifications.ui \
gnome-keyboard-properties-dialog.ui \
gnome-keyboard-properties-layout-chooser.ui \
gnome-keyboard-properties-model-chooser.ui \
gnome-keyboard-properties-options-dialog.ui
desktopdir = $(datadir)/applications
Desktop_in_files = keyboard.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(LIBGNOMEKBDUI_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(ui_DATA)
-include $(top_srcdir)/git.mk

View file

@ -390,8 +390,6 @@ capplets/display/display-properties.desktop.in
capplets/keybindings/Makefile capplets/keybindings/Makefile
capplets/keybindings/gnome-keybindings.pc capplets/keybindings/gnome-keybindings.pc
capplets/keybindings/keybinding.desktop.in capplets/keybindings/keybinding.desktop.in
capplets/keyboard/Makefile
capplets/keyboard/keyboard.desktop.in
capplets/network/Makefile capplets/network/Makefile
capplets/network/gnome-network-properties.desktop.in capplets/network/gnome-network-properties.desktop.in
capplets/windows/Makefile capplets/windows/Makefile
@ -412,6 +410,8 @@ libwindow-settings/gnome-window-settings-2.0.pc
panels/Makefile panels/Makefile
panels/mouse/Makefile panels/mouse/Makefile
panels/mouse/gnome-settings-mouse.desktop.in panels/mouse/gnome-settings-mouse.desktop.in
panels/keyboard/Makefile
panels/keyboard/keyboard.desktop.in
po/Makefile.in po/Makefile.in
shell/Makefile shell/Makefile
shell/gnome-control-center.desktop.in shell/gnome-control-center.desktop.in

View file

@ -1 +1 @@
SUBDIRS=mouse SUBDIRS=mouse keyboard

View file

@ -0,0 +1,58 @@
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = keyboard
INCLUDES = \
$(PANEL_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
$(NULL)
ccpanelsdir = $(PANELS_DIR)
ccpanels_LTLIBRARIES = libkeyboard-properties.la
libkeyboard_properties_la_SOURCES = \
keyboard-module.c \
cc-keyboard-panel.c \
gnome-keyboard-properties.c \
gnome-keyboard-properties-a11y.c \
gnome-keyboard-properties-a11y.h \
gnome-keyboard-properties-xkb.c \
gnome-keyboard-properties-xkbmc.c \
gnome-keyboard-properties-xkblt.c \
gnome-keyboard-properties-xkbltadd.c \
gnome-keyboard-properties-xkbot.c \
gnome-keyboard-properties-xkbpv.c \
gnome-keyboard-properties-xkb.h
libkeyboard_properties_la_LIBADD = $(PANEL_LIBS) $(LIBGNOMEKBDUI_LIBS) \
$(top_builddir)/capplets/common/libcommon.la
libkeyboard_properties_la_LDFLAGS = $(PANEL_LDFLAGS)
@INTLTOOL_DESKTOP_RULE@
uidir = $(pkgdatadir)/ui
ui_DATA = gnome-keyboard-properties-a11y-notifications.ui \
gnome-keyboard-properties-dialog.ui \
gnome-keyboard-properties-layout-chooser.ui \
gnome-keyboard-properties-model-chooser.ui \
gnome-keyboard-properties-options-dialog.ui
desktopdir = $(datadir)/applications
Desktop_in_files = keyboard.desktop.in
desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
INCLUDES = \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(LIBGNOMEKBDUI_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\""
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(ui_DATA)
-include $(top_srcdir)/git.mk

View file

@ -0,0 +1,139 @@
/*
* 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-keyboard-panel.h"
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL)
#define KEYBOARD_PANEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelPrivate))
struct _CcKeyboardPanelPrivate {
GtkBuilder *builder;
GConfClient *client;
};
static void
cc_keyboard_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_keyboard_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_keyboard_panel_dispose (GObject * object)
{
CcKeyboardPanelPrivate *priv = CC_KEYBOARD_PANEL (object)->priv;
if (priv->client) {
g_object_unref (priv->client);
priv->client = NULL;
}
if (priv->builder) {
g_object_unref (priv->builder);
priv->builder = NULL;
}
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->dispose (object);
}
static void
cc_keyboard_panel_finalize (GObject * object)
{
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->finalize (object);
}
static void
cc_keyboard_panel_class_init (CcKeyboardPanelClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcKeyboardPanelPrivate));
object_class->get_property = cc_keyboard_panel_get_property;
object_class->set_property = cc_keyboard_panel_set_property;
object_class->dispose = cc_keyboard_panel_dispose;
object_class->finalize = cc_keyboard_panel_finalize;
}
static void
cc_keyboard_panel_class_finalize (CcKeyboardPanelClass * klass)
{
}
GtkWidget *gnome_keyboard_properties_init (GConfClient * client,
GtkBuilder * dialog);
static void
cc_keyboard_panel_init (CcKeyboardPanel * self)
{
CcKeyboardPanelPrivate *priv;
GtkWidget *prefs_widget;
GError *error = NULL;
priv = self->priv = KEYBOARD_PANEL_PRIVATE (self);
priv->client = gconf_client_get_default ();
priv->builder = gtk_builder_new ();
gtk_builder_add_from_file (priv->builder,
GNOMECC_UI_DIR
"/gnome-keyboard-properties-dialog.ui",
&error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
return;
}
gnome_keyboard_properties_init (priv->client, priv->builder);
prefs_widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
"keyboard_notebook");
gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
}
void
cc_keyboard_panel_register (GIOModule * module)
{
cc_keyboard_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_KEYBOARD_PANEL,
"keyboard.desktop", 0);
}

View 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_KEYBOARD_PANEL_H
#define _CC_KEYBOARD_PANEL_H
#include <libgnome-control-center/cc-panel.h>
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_PANEL cc_keyboard_panel_get_type()
#define CC_KEYBOARD_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanel))
#define CC_KEYBOARD_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
#define CC_IS_KEYBOARD_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_KEYBOARD_PANEL))
#define CC_IS_KEYBOARD_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_KEYBOARD_PANEL))
#define CC_KEYBOARD_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
typedef struct _CcKeyboardPanel CcKeyboardPanel;
typedef struct _CcKeyboardPanelClass CcKeyboardPanelClass;
typedef struct _CcKeyboardPanelPrivate CcKeyboardPanelPrivate;
struct _CcKeyboardPanel
{
CcPanel parent;
CcKeyboardPanelPrivate *priv;
};
struct _CcKeyboardPanelClass
{
CcPanelClass parent_class;
};
GType cc_keyboard_panel_get_type (void) G_GNUC_CONST;
void cc_keyboard_panel_register (GIOModule *module);
G_END_DECLS
#endif /* _CC_KEYBOARD_PANEL_H */

View file

@ -43,18 +43,12 @@ enum {
RESPONSE_CLOSE RESPONSE_CLOSE
}; };
static GtkBuilder * static void
create_dialog (void) create_dialog (GtkBuilder * dialog)
{ {
GtkBuilder *dialog;
GtkSizeGroup *size_group; GtkSizeGroup *size_group;
GtkWidget *image; GtkWidget *image;
dialog = gtk_builder_new ();
gtk_builder_add_from_file (dialog, GNOMECC_UI_DIR
"/gnome-keyboard-properties-dialog.ui",
NULL);
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("repeat_slow_label")); gtk_size_group_add_widget (size_group, WID ("repeat_slow_label"));
gtk_size_group_add_widget (size_group, WID ("delay_short_label")); gtk_size_group_add_widget (size_group, WID ("delay_short_label"));
@ -70,16 +64,19 @@ create_dialog (void)
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, WID ("repeat_delay_scale")); gtk_size_group_add_widget (size_group, WID ("repeat_delay_scale"));
gtk_size_group_add_widget (size_group, WID ("repeat_speed_scale")); gtk_size_group_add_widget (size_group, WID ("repeat_speed_scale"));
gtk_size_group_add_widget (size_group, WID ("cursor_blink_time_scale")); gtk_size_group_add_widget (size_group,
WID ("cursor_blink_time_scale"));
g_object_unref (G_OBJECT (size_group)); g_object_unref (G_OBJECT (size_group));
image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON); image =
gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (WID ("xkb_layouts_add")), image); gtk_button_set_image (GTK_BUTTON (WID ("xkb_layouts_add")), image);
image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON); image =
gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")), image); gtk_image_new_from_stock (GTK_STOCK_REFRESH,
GTK_ICON_SIZE_BUTTON);
return dialog; gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")),
image);
} }
static GConfValue * static GConfValue *
@ -157,26 +154,34 @@ setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
g_free (monitor); g_free (monitor);
peditor = gconf_peditor_new_boolean peditor = gconf_peditor_new_boolean
(changeset, "/desktop/gnome/typing_break/enabled", (changeset, "/desktop/gnome/typing_break/enabled",
WID ("break_enabled_toggle"), NULL); WID ("break_enabled_toggle"), NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR
WID ("break_details_table")); (peditor),
WID
("break_details_table"));
gconf_peditor_new_numeric_range (changeset, gconf_peditor_new_numeric_range (changeset,
"/desktop/gnome/typing_break/type_time", "/desktop/gnome/typing_break/type_time",
WID ("break_enabled_spin"), NULL); WID
("break_enabled_spin"),
NULL);
gconf_peditor_new_numeric_range (changeset, gconf_peditor_new_numeric_range (changeset,
"/desktop/gnome/typing_break/break_time", "/desktop/gnome/typing_break/break_time",
WID ("break_interval_spin"), WID
("break_interval_spin"),
NULL); NULL);
gconf_peditor_new_boolean (changeset, gconf_peditor_new_boolean (changeset,
"/desktop/gnome/typing_break/allow_postpone", "/desktop/gnome/typing_break/allow_postpone",
WID ("break_postponement_toggle"), WID
("break_postponement_toggle"),
NULL); NULL);
} else { } else {
/* don't show the typing break tab if the daemon is not available */ /* don't show the typing break tab if the daemon is not available */
GtkNotebook *nb = GTK_NOTEBOOK (WID ("keyboard_notebook")); GtkNotebook *nb = GTK_NOTEBOOK (WID ("keyboard_notebook"));
gint tb_page = gtk_notebook_page_num (nb, WID ("break_enabled_toggle")); gint tb_page =
gtk_notebook_page_num (nb,
WID ("break_enabled_toggle"));
gtk_notebook_remove_page (nb, tb_page); gtk_notebook_remove_page (nb, tb_page);
} }
@ -187,79 +192,27 @@ setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
setup_a11y_tabs (dialog, changeset); setup_a11y_tabs (dialog, changeset);
} }
int
main (int argc, char **argv) GtkWidget *
gnome_keyboard_properties_init (GConfClient * client, GtkBuilder * dialog)
{ {
GConfClient *client; GtkWidget *dialog_win = NULL;
GConfChangeSet *changeset;
GtkBuilder *dialog;
GOptionContext *context;
static gboolean apply_only = FALSE;
static gboolean switch_to_typing_break_page = FALSE;
static gboolean switch_to_a11y_page = FALSE;
static GOptionEntry cap_options[] = {
{"apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
N_
("Just apply settings and quit (compatibility only; now handled by daemon)"),
NULL},
{"init-session-settings", 0, 0, G_OPTION_ARG_NONE,
&apply_only,
N_
("Just apply settings and quit (compatibility only; now handled by daemon)"),
NULL},
{"typing-break", 0, 0, G_OPTION_ARG_NONE,
&switch_to_typing_break_page,
N_
("Start the page with the typing break settings showing"),
NULL},
{"a11y", 0, 0, G_OPTION_ARG_NONE,
&switch_to_a11y_page,
N_
("Start the page with the accessibility settings showing"),
NULL},
{NULL}
};
context = g_option_context_new (_("- GNOME Keyboard Preferences"));
g_option_context_add_main_entries (context, cap_options,
GETTEXT_PACKAGE);
capplet_init (context, &argc, &argv);
activate_settings_daemon (); activate_settings_daemon ();
client = gconf_client_get_default ();
gconf_client_add_dir (client, gconf_client_add_dir (client,
"/desktop/gnome/peripherals/keyboard", "/desktop/gnome/peripherals/keyboard",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/desktop/gnome/interface", gconf_client_add_dir (client, "/desktop/gnome/interface",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
g_object_unref (client); create_dialog (dialog);
if (dialog) {
changeset = NULL; setup_dialog (dialog, NULL);
dialog = create_dialog (); dialog_win = WID ("keyboard_dialog");
setup_dialog (dialog, changeset); /* g_signal_connect (dialog_win, "response",
if (switch_to_typing_break_page) { G_CALLBACK (dialog_response_cb), NULL); */
gtk_notebook_set_current_page (GTK_NOTEBOOK capplet_set_icon (dialog_win,
(WID "preferences-desktop-keyboard");
("keyboard_notebook")),
4);
}
else if (switch_to_a11y_page) {
gtk_notebook_set_current_page (GTK_NOTEBOOK
(WID
("keyboard_notebook")),
2);
} }
capplet_set_icon (WID ("keyboard_dialog"), return dialog_win;
"preferences-desktop-keyboard");
gtk_widget_show (WID ("keyboard_dialog"));
gtk_main ();
return 0;
} }

View 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: Sergey Udaltsov <svu@gnome.org>
*
*/
#include <config.h>
#include "cc-keyboard-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_keyboard_panel_register (module);
}
void
g_io_module_unload (GIOModule * module)
{
}