diff --git a/capplets/keyboard/Bonobo_Control_Capplet_keyboard_properties.oaf b/capplets/keyboard/Bonobo_Control_Capplet_keyboard_properties.oaf
new file mode 100644
index 000000000..45eb027ec
--- /dev/null
+++ b/capplets/keyboard/Bonobo_Control_Capplet_keyboard_properties.oaf
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/capplets/keyboard/ChangeLog b/capplets/keyboard/ChangeLog
index 9e27b0d8c..aa9e866b8 100644
--- a/capplets/keyboard/ChangeLog
+++ b/capplets/keyboard/ChangeLog
@@ -1,3 +1,7 @@
+2001-07-18 Richard Hestilow
+
+ * Rewritten to use bonobo-conf.
+
2001-07-18 Jakub Steiner
* keyboard-capplet.png: use the 3d version.
diff --git a/capplets/keyboard/Makefile.am b/capplets/keyboard/Makefile.am
index c1ababe04..af898bb44 100644
--- a/capplets/keyboard/Makefile.am
+++ b/capplets/keyboard/Makefile.am
@@ -1,13 +1,22 @@
SUBDIRS =
+defaultsdir= $(datadir)/control-center/defaults
+defaults_DATA = keyboard-properties.xml
+
+oafdir = $(datadir)/oaf
+oaf_DATA = Bonobo_Control_Capplet_keyboard_properties.oaf
+
+EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(oaf_DATA) $(defaults_DATA)
+
cappletname = keyboard
bin_PROGRAMS = keyboard-properties
-keyboard_properties_LDADD = @CAPPLET_LIBS@ $(XF86MISC_LIBS)
+keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(XF86MISC_LIBS)
+
keyboard_properties_SOURCES = \
main.c \
- prefs-widget.c prefs-widget.h \
- preferences.c preferences.h
+ bonobo-property-editor-range.c \
+ bonobo-property-editor-range.h
##
## You should not need to modify anything below this line
@@ -24,4 +33,4 @@ pixmapdir = $(GNOMECC_PIXMAPS_DIR)
Glade_DATA = $(cappletname)-properties.glade
icons_DATA = $(cappletname)-capplet.png
desktop = $(cappletname).desktop
-all-local: $(desktop)
\ No newline at end of file
+all-local: $(desktop)
diff --git a/capplets/keyboard/bonobo-property-editor-range.c b/capplets/keyboard/bonobo-property-editor-range.c
new file mode 100644
index 000000000..f4069b63e
--- /dev/null
+++ b/capplets/keyboard/bonobo-property-editor-range.c
@@ -0,0 +1,70 @@
+#include
+#include
+#include
+#include
+
+static void
+changed_cb (GtkAdjustment *adj, BonoboPEditor *editor)
+{
+ CORBA_Environment ev;
+ DynamicAny_DynAny dyn;
+ BonoboArg *arg;
+ gulong val;
+
+ CORBA_exception_init (&ev);
+
+ val = adj->value;
+
+ dyn = CORBA_ORB_create_basic_dyn_any (bonobo_orb (), TC_ulong, &ev);
+ DynamicAny_DynAny_insert_ulong (dyn, val, &ev);
+
+ if (BONOBO_EX (&ev) || dyn == NULL)
+ return;
+
+ arg = DynamicAny_DynAny_to_any (dyn, &ev);
+ bonobo_peditor_set_value (editor, arg, &ev);
+
+ bonobo_arg_release (arg);
+ CORBA_Object_release ((CORBA_Object) dyn, &ev);
+ CORBA_exception_free (&ev);
+}
+
+static void
+adj_set_value_cb (BonoboPEditor *editor,
+ BonoboArg *value,
+ CORBA_Environment *ev)
+{
+ GtkAdjustment *adj;
+ gulong v;
+
+ adj = gtk_range_get_adjustment (GTK_RANGE (bonobo_peditor_get_widget (editor)));
+
+ if (!bonobo_arg_type_is_equal (value->_type, TC_ulong, NULL))
+ return;
+
+ v = BONOBO_ARG_GET_GENERAL (value, TC_ulong, CORBA_unsigned_long, NULL);
+
+ gtk_signal_handler_block_by_func (GTK_OBJECT (adj), changed_cb,
+ editor);
+
+ gtk_adjustment_set_value (adj, v);
+
+ gtk_signal_handler_unblock_by_func (GTK_OBJECT (adj), changed_cb,
+ editor);
+}
+
+GtkObject* bonobo_peditor_range_construct (GtkWidget *widget)
+{
+ BonoboPEditor *editor;
+ GtkAdjustment *adj;
+
+ g_return_val_if_fail (widget != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_RANGE (widget), NULL);
+
+ editor = bonobo_peditor_construct (widget, adj_set_value_cb, TC_ulong);
+ adj = gtk_range_get_adjustment (GTK_RANGE (widget));
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (changed_cb), editor);
+
+ return GTK_OBJECT (editor);
+}
diff --git a/capplets/keyboard/bonobo-property-editor-range.h b/capplets/keyboard/bonobo-property-editor-range.h
new file mode 100644
index 000000000..a0167d48d
--- /dev/null
+++ b/capplets/keyboard/bonobo-property-editor-range.h
@@ -0,0 +1,8 @@
+#ifndef __BONOBO_PROPERTY_RANGE_SCALE_H__
+#define __BONOBO_PROPERTY_RANGE_SCALE_H__
+
+#include
+
+GtkObject* bonobo_peditor_range_construct (GtkWidget *widget);
+
+#endif /* __BONOBO_PROPERTY_RANGE_SCALE_H__ */
diff --git a/capplets/keyboard/keyboard-properties.glade b/capplets/keyboard/keyboard-properties.glade
index dc9269229..fecd63b2b 100644
--- a/capplets/keyboard/keyboard-properties.glade
+++ b/capplets/keyboard/keyboard-properties.glade
@@ -10,6 +10,8 @@
C
True
True
+ True
+ keyboard-properties.glade.h
@@ -24,289 +26,195 @@
False
- GtkVBox
+ GtkNotebook
prefs_widget
- False
- 4
+ True
+ True
+ True
+ GTK_POS_TOP
+ False
+ 2
+ 2
+ False
- GtkCheckButton
- repeat_toggle
- True
-
- toggled
- repeat_toggled_cb
- Thu, 30 Nov 2000 23:56:30 GMT
-
-
- False
- True
-
- 0
- False
- False
-
-
-
-
- GtkFrame
- delay_frame
-
- 0
- GTK_SHADOW_ETCHED_IN
-
- 0
- False
- False
-
+ GtkVBox
+ keyboard_vbox
+ 4
+ False
+ 4
- GtkHBox
- hbox2
- 4
- True
- 4
-
-
- GtkLabel
- label5
-
- GTK_JUSTIFY_CENTER
- False
- 0.5
- 0.5
- 0
- 0
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- delay0
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- delay1
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- delay2
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- delay3
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkLabel
- label6
-
- GTK_JUSTIFY_CENTER
- False
- 0.5
- 0.5
- 0
- 0
-
- 0
- True
- True
-
-
+ GtkCheckButton
+ repeat_toggle
+ True
+
+ toggled
+ repeat_toggled_cb
+ Thu, 30 Nov 2000 23:56:30 GMT
+
+
+ False
+ True
+
+ 0
+ False
+ False
+
-
-
-
- GtkFrame
- repeat_frame
-
- 0
- GTK_SHADOW_ETCHED_IN
-
- 0
- False
- False
-
- GtkHBox
- hbox3
- 4
- True
- 4
+ Placeholder
+
-
- GtkLabel
- label7
-
- GTK_JUSTIFY_CENTER
- False
- 0.5
- 0.5
- 0
- 0
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- repeat0
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- repeat1
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- repeat2
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
-
-
- GtkToggleButton
- repeat3
- True
-
- GTK_RELIEF_NORMAL
- False
-
- 0
- True
- True
-
-
+
+ GtkTable
+ repeat_table
+ 2
+ 2
+ False
+ 4
+ 4
+
+ 4
+ False
+ False
+
GtkLabel
label8
-
+
GTK_JUSTIFY_CENTER
False
- 0.5
+ 0
0.5
0
0
- 0
- True
- True
+ 0
+ 1
+ 0
+ 1
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkLabel
+ label9
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0
+ 0.5
+ 0
+ 0
+
+ 0
+ 1
+ 1
+ 2
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkOptionMenu
+ delay_menu
+ True
+ Very long
+Long
+Medium
+Short
+
+ 2
+
+ 1
+ 2
+ 0
+ 1
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkOptionMenu
+ repeat_menu
+ True
+ Very fast
+Fast
+Medium
+Slow
+
+ 2
+
+ 1
+ 2
+ 1
+ 2
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
-
-
- GtkCheckButton
- click_toggle
- True
-
- toggled
- click_toggled_cb
- Mon, 11 Sep 2000 02:02:18 GMT
-
-
- False
- True
-
- 0
- False
- False
-
-
-
-
- GtkFrame
- click_frame
-
- 0
- GTK_SHADOW_ETCHED_IN
-
- 0
- False
- False
-
+
+ GtkCheckButton
+ click_toggle
+ True
+
+ toggled
+ click_toggled_cb
+ Mon, 11 Sep 2000 02:02:18 GMT
+
+
+ False
+ True
+
+ 0
+ False
+ False
+
+
GtkHBox
- hbox4
- 4
+ click_hbox
False
4
+
+ 0
+ False
+ False
+
GtkLabel
@@ -346,21 +254,278 @@
+
+
+ Placeholder
+
- GtkEntry
- test_entry
- True
- True
- True
- 0
- Type here to test setting
-
- 0
- False
- False
-
+ GtkLabel
+ Notebook:tab
+ label8
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+
+ GtkTable
+ table1
+ 4
+ 4
+ 2
+ False
+ 4
+ 4
+
+
+ GtkLabel
+ label11
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0
+ 0.5
+ 0
+ 0
+
+ 0
+ 1
+ 0
+ 1
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkLabel
+ label12
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0
+ 0.5
+ 0
+ 0
+
+ 0
+ 1
+ 1
+ 2
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkLabel
+ label13
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0
+ 0.5
+ 0
+ 0
+
+ 0
+ 1
+ 2
+ 3
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ False
+
+
+
+
+ GtkHScale
+ bell_volume_range
+ True
+ True
+ GTK_POS_TOP
+ 0
+ GTK_UPDATE_CONTINUOUS
+ 0
+ 0
+ 100
+ 0
+ 0
+ 0
+
+ 1
+ 2
+ 0
+ 1
+ 0
+ 0
+ True
+ False
+ False
+ False
+ True
+ True
+
+
+
+
+ GtkHScale
+ bell_pitch_range
+ True
+ True
+ GTK_POS_TOP
+ 0
+ GTK_UPDATE_CONTINUOUS
+ 0
+ 0
+ 2000
+ 0
+ 0
+ 0
+
+ 1
+ 2
+ 1
+ 2
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ True
+
+
+
+
+ GtkHScale
+ bell_duration_range
+ True
+ True
+ GTK_POS_TOP
+ 0
+ GTK_UPDATE_CONTINUOUS
+ 0
+ 0
+ 500
+ 0
+ 0
+ 0
+
+ 1
+ 2
+ 2
+ 3
+ 0
+ 0
+ False
+ False
+ False
+ False
+ True
+ True
+
+
+
+
+ GtkButton
+ bell_test_button
+ 4
+ True
+ GTK_RELIEF_NORMAL
+
+ 0
+ 1
+ 3
+ 4
+ 0
+ 0
+ False
+ False
+ False
+ False
+ False
+ False
+
+
+
+ GtkHBox
+ hbox1
+ 4
+ False
+ 0
+
+
+ GtkHBox
+ bell_test_holder
+ False
+ 0
+
+ 0
+ False
+ False
+
+
+
+ Placeholder
+
+
+
+
+ GtkLabel
+ label14
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+ 0
+ False
+ False
+
+
+
+
+
+
+
+ GtkLabel
+ Notebook:tab
+ label9
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0.5
+ 0.5
+ 0
+ 0
diff --git a/capplets/keyboard/keyboard-properties.glade.h b/capplets/keyboard/keyboard-properties.glade.h
new file mode 100644
index 000000000..7b8d44390
--- /dev/null
+++ b/capplets/keyboard/keyboard-properties.glade.h
@@ -0,0 +1,26 @@
+/*
+ * Translatable strings file generated by Glade.
+ * Add this file to your project's POTFILES.in.
+ * DO NOT compile it as part of your application.
+ */
+
+gchar *s = N_("window1");
+gchar *s = N_("Enable Keyboard Repeat");
+gchar *s = N_("Delay until repeat:");
+gchar *s = N_("Key repeat rate:");
+gchar *s = N_("Very long");
+gchar *s = N_("Long");
+gchar *s = N_("Medium");
+gchar *s = N_("Short");
+gchar *s = N_("Very fast");
+gchar *s = N_("Fast");
+gchar *s = N_("Medium");
+gchar *s = N_("Slow");
+gchar *s = N_("Enable Keyboard Click");
+gchar *s = N_("Click volume");
+gchar *s = N_("Keyboard");
+gchar *s = N_("Volume");
+gchar *s = N_("Pitch (Hz)");
+gchar *s = N_("Duration (ms)");
+gchar *s = N_("Test");
+gchar *s = N_("Bell");
diff --git a/capplets/keyboard/keyboard-properties.xml b/capplets/keyboard/keyboard-properties.xml
new file mode 100644
index 000000000..babd1db7b
--- /dev/null
+++ b/capplets/keyboard/keyboard-properties.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/capplets/keyboard/main.c b/capplets/keyboard/main.c
index d0ec43d57..7c826ddff 100644
--- a/capplets/keyboard/main.c
+++ b/capplets/keyboard/main.c
@@ -1,10 +1,10 @@
/* -*- mode: c; style: linux -*- */
/* main.c
- * Copyright (C) 2000 Helix Code, Inc.
- *
- * Written by Bradford Hovinen (hovinen@helixcode.com)
+ * Copyright (C) 2000-2001 Ximian, Inc.
*
+ * Written by: Bradford Hovinen
+ * Richard Hestilow
* 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, or (at your option)
@@ -25,276 +25,190 @@
# include
#endif
-#include
-#include
-#include
-#include
-#include
-#include
+#include "capplet-util.h"
+#include "bonobo-property-editor-range.h"
#include
+#include
-#include
+#include
+#include
-#ifdef HAVE_XIMIAN_ARCHIVER
-# include
-# include
-#endif /* HAVE_XIMIAN_ARCHIVER */
-
-#include "preferences.h"
-#include "prefs-widget.h"
-
-static Preferences *prefs;
-static Preferences *old_prefs;
-static PrefsWidget *prefs_widget;
-
-#ifdef HAVE_XIMIAN_ARCHIVER
-
-static Archive *archive;
-static gboolean outside_location;
+#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
+#include
+#endif
static void
-store_archive_data (void)
+apply_settings (Bonobo_ConfigDatabase db)
{
- Location *location;
- xmlDocPtr xml_doc;
+ gboolean repeat, click;
+ int rate, delay, volume;
+ int bell_volume, bell_pitch, bell_duration;
- if (capplet_get_location () == NULL)
- location = archive_get_current_location (archive);
- else
- location = archive_get_location (archive,
- capplet_get_location ());
+#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
+ XF86MiscKbdSettings kbdsettings;
+#endif
+ XKeyboardControl kbdcontrol;
+ int event_base_return, error_base_return;
- xml_doc = preferences_write_xml (prefs);
- location_store_xml (location, "keyboard-properties-capplet",
- xml_doc, STORE_MASK_PREVIOUS);
- xmlFreeDoc (xml_doc);
- archive_close (archive);
-}
+ repeat = bonobo_config_get_boolean (db, "/main/repeat", NULL);
+ click = bonobo_config_get_boolean (db, "/main/click", NULL);
+ rate = bonobo_config_get_ulong (db, "/main/rate", NULL);
+ delay = bonobo_config_get_ulong (db, "/main/delay", NULL);
+ volume = bonobo_config_get_ulong (db, "/main/volume", NULL);
+ bell_volume = bonobo_config_get_ulong (db, "/main/bell_volume", NULL);
+ bell_pitch = bonobo_config_get_ulong (db, "/main/bell_pitch", NULL);
+ bell_duration = bonobo_config_get_ulong (db, "/main/bell_duration", NULL);
-#endif /* HAVE_XIMIAN_ARCHIVER */
-
-static void
-ok_cb (GtkWidget *widget)
-{
-#ifdef HAVE_XIMIAN_ARCHIVER
- if (!outside_location) {
- preferences_save (prefs);
- preferences_apply_now (prefs);
- }
-#else /* !HAVE_XIMIAN_ARCHIVER */
- preferences_save (old_prefs);
- preferences_apply_now (old_prefs);
-#endif /* !HAVE_XIMIAN_ARCHIVER */
-
-#ifdef HAVE_XIMIAN_ARCHIVER
- store_archive_data ();
-#endif /* HAVE_XIMIAN_ARCHIVER */
-}
-
-static void
-cancel_cb (GtkWidget *widget)
-{
-#ifdef HAVE_XIMIAN_ARCHIVER
- if (!outside_location) {
- preferences_save (old_prefs);
- preferences_apply_now (old_prefs);
- }
-#else /* !HAVE_XIMIAN_ARCHIVER */
- preferences_save (old_prefs);
- preferences_apply_now (old_prefs);
-#endif /* !HAVE_XIMIAN_ARCHIVER */
-}
-
-static void
-setup_capplet_widget (void)
-{
- preferences_freeze (prefs);
-
- prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs));
-
- gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok",
- GTK_SIGNAL_FUNC (ok_cb), NULL);
- gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel",
- GTK_SIGNAL_FUNC (cancel_cb), NULL);
-
- gtk_widget_show_all (GTK_WIDGET (prefs_widget));
-
- preferences_thaw (prefs);
-}
-
-#ifdef HAVE_XIMIAN_ARCHIVER
-
-static void
-do_get_xml (void)
-{
- Preferences *prefs;
- xmlDocPtr doc;
-
- prefs = PREFERENCES (preferences_new ());
- preferences_load (prefs);
- doc = preferences_write_xml (prefs);
- xmlDocDump (stdout, doc);
- gtk_object_destroy (GTK_OBJECT (prefs));
-}
-
-
-static void
-do_set_xml (gboolean apply_settings)
-{
- xmlDocPtr doc;
- char buffer[16384];
- GString *doc_str;
- int t = 0;
-
- fflush (stdin);
-
- fcntl (fileno (stdin), F_SETFL, 0);
-
- doc_str = g_string_new ("");
-
- while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) {
- buffer[t] = '\0';
- g_string_append (doc_str, buffer);
- }
-
- if (doc_str->len > 0) {
- doc = xmlParseDoc (doc_str->str);
- g_string_free (doc_str, TRUE);
-
- if (doc != NULL) {
- prefs = preferences_read_xml (doc);
-
- if (prefs != NULL) {
- if (apply_settings) {
- preferences_save (prefs);
- preferences_apply_now (prefs);
- }
-
- return;
- }
- else if (prefs != NULL) {
- return;
- }
-
- xmlFreeDoc (doc);
- }
+ if (repeat) {
+ XAutoRepeatOn (GDK_DISPLAY ());
+#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
+ if (XF86MiscQueryExtension (GDK_DISPLAY (),
+ &event_base_return,
+ &error_base_return) == True)
+ {
+ kbdsettings.rate = rate;
+ kbdsettings.delay = delay;
+ XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings);
+ } else {
+ XAutoRepeatOff (GDK_DISPLAY ());
+ }
+#endif
} else {
- g_critical ("No data to apply");
+ XAutoRepeatOff (GDK_DISPLAY ());
}
- return;
+ kbdcontrol.key_click_percent =
+ click ? volume : 0;
+ kbdcontrol.bell_percent = bell_volume;
+ kbdcontrol.bell_pitch = bell_pitch;
+ kbdcontrol.bell_duration = bell_duration;
+ XChangeKeyboardControl (GDK_DISPLAY (), KBKeyClickPercent,
+ &kbdcontrol);
}
-#endif /* HAVE_XIMIAN_ARCHIVER */
+static gulong
+get_value_ulong (Bonobo_PropertyBag bag, const gchar *prop)
+{
+ BonoboArg *arg;
+ gulong val;
+
+ arg = bonobo_property_bag_client_get_value_any (bag, prop, NULL);
+ val = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_unsigned_long, NULL);
+ bonobo_arg_release (arg);
+ return val;
+}
static void
-do_restore_from_defaults (void)
+bell_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
{
- prefs = PREFERENCES (preferences_new ());
- preferences_save (prefs);
- preferences_apply_now (prefs);
+ XKeyboardState backup;
+ XKeyboardControl kbdcontrol;
+
+ XGetKeyboardControl (GDK_DISPLAY (), &backup);
+
+ kbdcontrol.bell_percent = get_value_ulong (bag, "bell_volume");
+ kbdcontrol.bell_pitch = get_value_ulong (bag, "bell_pitch");
+ kbdcontrol.bell_duration = get_value_ulong (bag, "bell_duration");
+ XChangeKeyboardControl (GDK_DISPLAY (),
+ KBBellPercent | KBBellPitch | KBBellDuration,
+ &kbdcontrol);
+ XBell (GDK_DISPLAY (), 0);
+
+ kbdcontrol.bell_percent = backup.bell_percent;
+ kbdcontrol.bell_pitch = backup.bell_pitch;
+ kbdcontrol.bell_duration = backup.bell_duration;
+
+ XChangeKeyboardControl (GDK_DISPLAY (),
+ KBBellPercent | KBBellPitch | KBBellDuration,
+ &kbdcontrol);
+}
+
+static GtkWidget*
+create_dialog (Bonobo_PropertyBag bag)
+{
+ GladeXML *dialog;
+ GtkWidget *widget, *pixmap;
+
+ dialog = glade_xml_new (GLADE_DATADIR "/keyboard-properties.glade", "prefs_widget");
+ widget = glade_xml_get_widget (dialog, "prefs_widget");
+ gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
+
+ /* Minor GUI addition */
+ pixmap = gnome_stock_pixmap_widget (WID ("bell_test_button"),
+ GNOME_STOCK_PIXMAP_VOLUME);
+ gtk_box_pack_start (GTK_BOX (WID ("bell_test_holder")), pixmap,
+ TRUE, TRUE, 0);
+ gtk_widget_show_all (WID ("bell_test_button"));
+
+ gtk_signal_connect (GTK_OBJECT (WID ("bell_test_button")),
+ "clicked", bell_cb, bag);
+
+ gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
+ GTK_SIGNAL_FUNC (gtk_object_destroy),
+ GTK_OBJECT (dialog));
+
+ return widget;
+}
+
+static void
+setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
+{
+ GladeXML *dialog;
+ BonoboPEditor *ed;
+
+ dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
+
+ CREATE_PEDITOR (boolean, "repeat", "repeat_toggle");
+
+ ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("delay_menu")));
+ bonobo_peditor_set_property (ed, bag, "delay", TC_ulong, NULL);
+
+ ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("repeat_menu")));
+ bonobo_peditor_set_property (ed, bag, "rate", TC_ulong, NULL);
+ bonobo_peditor_set_guard (WID ("repeat_table"), bag, "repeat");
+
+ CREATE_PEDITOR (boolean, "click", "click_toggle");
+
+ ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("click_volume_entry")));
+ bonobo_peditor_set_property (ed, bag, "volume", TC_ulong, NULL);
+ bonobo_peditor_set_guard (WID ("click_hbox"), bag, "click");
+
+ /* Bell properties */
+ ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_volume_range")));
+ bonobo_peditor_set_property (ed, bag, "bell_volume", TC_ulong, NULL);
+
+ ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_pitch_range")));
+ bonobo_peditor_set_property (ed, bag, "bell_pitch", TC_ulong, NULL);
+
+ ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_duration_range")));
+ bonobo_peditor_set_property (ed, bag, "bell_duration", TC_ulong, NULL);
+}
+
+static void
+get_legacy_settings (Bonobo_ConfigDatabase db)
+{
+ gboolean val_boolean, def;
+ gulong val_ulong;
+
+ COPY_FROM_LEGACY (boolean, "/main/repeat", bool, "/Desktop/Keyboard/repeat=true");
+ COPY_FROM_LEGACY (boolean, "/main/click", bool, "/Desktop/Keyboard/click=true");
+ COPY_FROM_LEGACY (ulong, "/main/rate", int, "/Desktop/Keyboard/rate=30");
+ COPY_FROM_LEGACY (ulong, "/main/delay", int, "/Desktop/Keyboard/delay=500");
+ COPY_FROM_LEGACY (ulong, "/main/volume", int, "/Desktop/Keyboard/clickvolume=0");
+ COPY_FROM_LEGACY (ulong, "/main/bell_volume", int, "/Desktop/Bell/percent=50");
+ COPY_FROM_LEGACY (ulong, "/main/bell_pitch", int, "/Desktop/Bell/pitch=50");
+ COPY_FROM_LEGACY (ulong, "/main/bell_duration", int, "/Desktop/Bell/duration=100");
}
int
-main (int argc, char **argv)
+main (int argc, char **argv)
{
- GnomeClient *client;
- GnomeClientFlags flags;
- gint token, res;
- gchar *restart_args[3];
-
- bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);
-
glade_gnome_init ();
- res = gnome_capplet_init ("keyboard-properties-capplet",
- VERSION, argc, argv, NULL,
- 0, NULL);
-
- if (res < 0) {
- g_error ("Could not initialize the capplet.");
- }
- else if (res == 3) {
-#ifdef HAVE_XIMIAN_ARCHIVER
- do_get_xml ();
-#endif /* HAVE_XIMIAN_ARCHIVER */
- return 0;
- }
- else if (res == 4) {
-#ifdef HAVE_XIMIAN_ARCHIVER
- do_set_xml (TRUE);
-#endif /* HAVE_XIMIAN_ARCHIVER */
- return 0;
- }
- else if (res == 5) {
- do_restore_from_defaults ();
- return 0;
- }
-
- client = gnome_master_client ();
- flags = gnome_client_get_flags (client);
-
- if (flags & GNOME_CLIENT_IS_CONNECTED) {
- token = gnome_startup_acquire_token
- ("GNOME_KEYBOARD_PROPERTIES",
- gnome_client_get_id (client));
-
- if (token) {
- gnome_client_set_priority (client, 20);
- gnome_client_set_restart_style (client,
- GNOME_RESTART_ANYWAY);
- restart_args[0] = argv[0];
- restart_args[1] = "--init-session-settings";
- restart_args[2] = NULL;
- gnome_client_set_restart_command (client, 2,
- restart_args);
- } else {
- gnome_client_set_restart_style (client,
- GNOME_RESTART_NEVER);
- }
- } else {
- token = 1;
- }
+ capplet_init (argc, argv, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
gnome_window_icon_set_default_from_file
(GNOMECC_ICONS_DIR"keyboard-capplet.png.png");
-
-#ifdef HAVE_XIMIAN_ARCHIVER
- archive = ARCHIVE (archive_load (FALSE));
-
- if (capplet_get_location () != NULL &&
- strcmp (capplet_get_location (),
- archive_get_current_location_id (archive)))
- {
- outside_location = TRUE;
- do_set_xml (FALSE);
- if (prefs == NULL) return -1;
- preferences_freeze (prefs);
- } else {
- outside_location = FALSE;
- prefs = PREFERENCES (preferences_new ());
- preferences_load (prefs);
- }
-
- if (!outside_location && token) {
- preferences_apply_now (prefs);
- }
-
-#else /* !HAVE_XIMIAN_ARCHIVER */
-
- prefs = PREFERENCES (preferences_new ());
- preferences_load (prefs);
- if (token) preferences_apply_now (prefs);
-
-#endif /* HAVE_XIMIAN_ARCHIVER */
-
- if (!res) {
- old_prefs = PREFERENCES (preferences_clone (prefs));
- setup_capplet_widget ();
-
- capplet_gtk_main ();
- }
-
+
return 0;
}