Bell properties patch



Attached is a patch that adds a bell properties dialog which was largely
based on the keyboard properties dialog. Works for me, if someone with
CVS access could look it over and check it in. Thanks...

Cheers,
Chris
diff -uNr /usr/src/gnome-core-virgin/desktop-properties/Makefile.am /usr/src/gnome-core/desktop-properties/Makefile.am
--- /usr/src/gnome-core-virgin/desktop-properties/Makefile.am	Sun May 10 23:01:05 1998
+++ /usr/src/gnome-core/desktop-properties/Makefile.am	Sun May 10 21:58:51 1998
@@ -2,7 +2,7 @@
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
 	-I$(includedir) $(X_CFLAGS) $(GNOME_INCLUDEDIR)
 
-bin_PROGRAMS = mouse-properties keyboard-properties background-properties
+bin_PROGRAMS = mouse-properties keyboard-properties background-properties bell-properties
 
 mouse_properties_SOURCES =	\
 	main.c			\
@@ -18,6 +18,13 @@
 	gnome-desktop.h		\
 	app-keyboard.c
 
+bell_properties_SOURCES =	\
+	main.c			\
+	args.c			\
+        property-bell.c		\
+	gnome-desktop.h		\
+	app-bell.c
+
 background_properties_SOURCES =	\
 	main.c			\
 	property-background.c	\
@@ -51,7 +58,13 @@
         @XF86MISC_LIBS@					\
 	$(INTLLIBS)
 
-EXTRA_DIST = background.desktop keyboard.desktop mouse.desktop
+bell_properties_LDADD = \
+	$(GNOME_LIBDIR)					\
+	$(GNOMEUI_LIBS)					\
+        @XF86MISC_LIBS@					\
+	$(INTLLIBS)
+
+EXTRA_DIST = background.desktop keyboard.desktop mouse.desktop bell.desktop
 
 sysdir = $(datadir)/apps/System
-sys_DATA = background.desktop mouse.desktop keyboard.desktop
+sys_DATA = background.desktop mouse.desktop keyboard.desktop bell.desktop
diff -uNr /usr/src/gnome-core-virgin/desktop-properties/app-bell.c /usr/src/gnome-core/desktop-properties/app-bell.c
--- /usr/src/gnome-core-virgin/desktop-properties/app-bell.c	Wed Dec 31 19:00:00 1969
+++ /usr/src/gnome-core/desktop-properties/app-bell.c	Sun May 10 21:42:15 1998
@@ -0,0 +1,35 @@
+/* app-bell.c - Bell configuration application.  */
+
+#include <config.h>
+#include "gnome-desktop.h"
+
+extern void bell_register(GnomePropertyConfigurator *c);
+
+char *
+application_title (void)
+{
+  return _("Bell Properties");
+}
+
+char *
+application_property (void)
+{
+  return "GNOME_BELL_PROPERTY";
+}
+
+void
+application_help (void)
+{
+}
+
+void
+application_register (GnomePropertyConfigurator *pconf)
+{
+  bell_register (pconf);
+}
+
+int
+main (int argc, char *argv[])
+{
+  return (property_main ("bell_properties", argc, argv));
+}
diff -uNr /usr/src/gnome-core-virgin/desktop-properties/bell.desktop /usr/src/gnome-core/desktop-properties/bell.desktop
--- /usr/src/gnome-core-virgin/desktop-properties/bell.desktop	Wed Dec 31 19:00:00 1969
+++ /usr/src/gnome-core/desktop-properties/bell.desktop	Sun May 10 22:42:33 1998
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Name=Bell Properties
+Name[es]=Bell Properties
+Name[de]=Bell Properties
+Name[ko]=Bell Properties
+Name[fr]=Bell Properties
+Name[it]=Bell Properties
+Name[no]=Bell Properties
+Comment=Bell Properties
+Comment[es]=Bell Properties
+Comment[de]=Bell Properties
+Comment[ko]=Bell Properties
+Comment[fr]=Bell Properties
+Comment[it]=Bell Properties
+Comment[no]=Bell Properties
+Exec=bell-properties
+Icon=
+Terminal=0
+Type=Application
diff -uNr /usr/src/gnome-core-virgin/desktop-properties/property-bell.c /usr/src/gnome-core/desktop-properties/property-bell.c
--- /usr/src/gnome-core-virgin/desktop-properties/property-bell.c	Wed Dec 31 19:00:00 1969
+++ /usr/src/gnome-core/desktop-properties/property-bell.c	Sun May 10 22:33:20 1998
@@ -0,0 +1,258 @@
+#include <config.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <X11/X.h>
+#include <config.h>
+
+#include "gnome.h"
+#include "gnome-desktop.h"
+
+static GnomePropertyConfigurator *config;
+
+static gint bell_percent;
+static gint bell_pitch;
+static gint bell_duration;
+static XKeyboardState kbdstate;
+static XKeyboardControl kbdcontrol;
+
+static GtkWidget *vscale, *pscale, *dscale;
+
+
+static void bell_read(void)
+{
+	bell_percent = gnome_config_get_int("/Desktop/Bell/percent=-1");
+	bell_pitch = gnome_config_get_int("/Desktop/Bell/pitch=-1");
+	bell_duration = gnome_config_get_int("/Desktop/Bell/duration=-1");
+
+	XGetKeyboardControl(GDK_DISPLAY(), &kbdstate);
+
+	if (bell_percent == -1) {
+		bell_percent = kbdstate.bell_percent;
+	}
+	if (bell_pitch == -1) {
+	        bell_pitch = kbdstate.bell_pitch;
+        }
+	if (bell_duration == -1) {
+	        bell_duration = kbdstate.bell_duration;
+	}
+}
+
+static void bell_write(void)
+{
+	gnome_config_set_int("/Desktop/Bell/percent", bell_percent);
+	gnome_config_set_int("/Desktop/Bell/pitch", bell_pitch);
+	gnome_config_set_int("/Desktop/Bell/duration", bell_duration);
+	gnome_config_sync ();
+}
+
+static void bell_apply(void)
+{
+	kbdcontrol.bell_percent = bell_percent;
+	kbdcontrol.bell_pitch = bell_pitch;
+	kbdcontrol.bell_duration = bell_duration;
+	XChangeKeyboardControl(GDK_DISPLAY(), KBBellPercent | KBBellPitch | KBBellDuration, &kbdcontrol);
+
+	property_applied ();
+}
+
+static void
+percent_changed(GtkAdjustment *adj, gpointer data)
+{
+	bell_percent = adj->value;
+	property_changed ();
+}
+
+static void
+pitch_changed(GtkAdjustment *adj, gpointer *data)
+{
+	bell_pitch = adj->value;
+	property_changed ();
+}
+
+static void
+duration_changed(GtkAdjustment *adj, gpointer *data)
+{
+	bell_duration = adj->value;
+	property_changed ();
+}
+
+static void
+test_bell(GtkWidget *widget, void *data)
+{
+        gint save_percent;
+	gint save_pitch;
+	gint save_duration;
+
+	XGetKeyboardControl(GDK_DISPLAY(), &kbdstate);
+
+	save_percent = kbdstate.bell_percent;
+	save_pitch = kbdstate.bell_pitch;
+	save_duration = kbdstate.bell_duration;
+	
+	kbdcontrol.bell_percent = bell_percent;
+	kbdcontrol.bell_pitch = bell_pitch;
+	kbdcontrol.bell_duration = bell_duration;
+	XChangeKeyboardControl(GDK_DISPLAY(), KBBellPercent | KBBellPitch | KBBellDuration, &kbdcontrol);
+
+        XBell(gdk_display,0);
+
+	kbdcontrol.bell_percent = save_percent;
+	kbdcontrol.bell_pitch = save_pitch;
+	kbdcontrol.bell_duration = save_duration;
+	XChangeKeyboardControl(GDK_DISPLAY(), KBBellPercent | KBBellPitch | KBBellDuration, &kbdcontrol);
+
+	return;
+}
+
+static void
+bell_setup(void)
+{
+	GtkWidget *vbox;
+	GtkWidget *frame;
+	GtkWidget *hbox, *tbox;
+	GtkWidget *table;
+	GtkWidget *tbutton;
+	GtkWidget *label;
+	GtkObject *vadj, *padj, *dadj;
+
+	vbox = gtk_vbox_new(FALSE, GNOME_PAD_SMALL);
+	gtk_container_border_width(GTK_CONTAINER(vbox), GNOME_PAD);
+
+	frame = gtk_frame_new(_("Sound"));
+	gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
+	gtk_widget_show (frame);
+
+	table = gtk_table_new (4, 2, FALSE);
+	gtk_container_border_width (GTK_CONTAINER (table), GNOME_PAD);
+	gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
+	gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
+	gtk_container_add (GTK_CONTAINER (frame), table);
+	gtk_widget_show (table);
+	
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_table_attach (GTK_TABLE (table), hbox,
+			  0, 2, 0, 1,
+			  GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show (hbox);
+
+	label = gtk_label_new(_("Volume"));
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
+	gtk_table_attach (GTK_TABLE (table), label,
+			  0, 1, 1, 2,
+			  GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show(label);
+
+	vadj = gtk_adjustment_new(bell_percent, 0, 100, 1, 1, 0);
+	vscale = gtk_hscale_new(GTK_ADJUSTMENT(vadj));
+	gtk_scale_set_digits (GTK_SCALE (vscale), 0);
+	gtk_signal_connect(GTK_OBJECT(vadj), "value_changed",
+			   GTK_SIGNAL_FUNC(percent_changed), NULL);
+	gtk_table_attach (GTK_TABLE (table), vscale,
+			  1, 2, 1, 2,
+			  GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show(vscale);
+
+	label = gtk_label_new(_("Pitch"));
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
+	gtk_table_attach (GTK_TABLE (table), label,
+			  0, 1, 2, 3,
+			  GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show(label);
+
+	padj = gtk_adjustment_new(bell_pitch, 0, 2000, 1, 1, 0);
+	pscale = gtk_hscale_new(GTK_ADJUSTMENT(padj));
+	gtk_scale_set_digits (GTK_SCALE (pscale), 0);
+	gtk_signal_connect(GTK_OBJECT(padj), "value_changed",
+			   GTK_SIGNAL_FUNC(pitch_changed), NULL);
+	gtk_table_attach (GTK_TABLE (table), pscale,
+			  1, 2, 2, 3,
+			  GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show(pscale);
+
+	label = gtk_label_new(_("Duration"));
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
+	gtk_table_attach (GTK_TABLE (table), label,
+			  0, 1, 3, 4,
+			  GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show(label);
+
+	dadj = gtk_adjustment_new(bell_duration, 0, 500, 1, 1, 0);
+	dscale = gtk_hscale_new(GTK_ADJUSTMENT(dadj));
+	gtk_scale_set_digits (GTK_SCALE (dscale), 0);
+	gtk_signal_connect(GTK_OBJECT(dadj), "value_changed",
+			   GTK_SIGNAL_FUNC(duration_changed), NULL);
+	gtk_table_attach (GTK_TABLE (table), dscale,
+			  1, 2, 3, 4,
+			  GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+			  GTK_FILL | GTK_SHRINK,
+			  0, 0);
+	gtk_widget_show (dscale);
+
+	/* Set sensitivity of scale */
+
+	gtk_widget_set_sensitive(vscale, bell_percent);
+	gtk_widget_set_sensitive(pscale, bell_pitch);
+	gtk_widget_set_sensitive(dscale, bell_duration);
+
+	/* Throw up a test button */
+
+      	tbox = gtk_hbox_new(TRUE, 0);
+	tbutton = gtk_button_new_with_label("Test");
+	gtk_widget_set_usize(tbutton, 100, 30);
+	gtk_signal_connect(GTK_OBJECT (tbutton), "clicked",
+			   GTK_SIGNAL_FUNC (test_bell), NULL);
+	gtk_box_pack_start (GTK_BOX (tbox), tbutton, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (vbox), tbox, FALSE, FALSE, 5);
+	gtk_widget_show (tbutton);
+	gtk_widget_show (tbox);
+
+	/* Finished */
+
+	gtk_widget_show(vbox);
+	gnome_property_box_append_page(GNOME_PROPERTY_BOX(config->property_box),
+				       vbox,
+				       gtk_label_new(_("Bell")));
+}
+
+static gint bell_action(GnomePropertyRequest req)
+{
+	switch (req) {
+	case GNOME_PROPERTY_READ:
+		bell_read();
+		break;
+	case GNOME_PROPERTY_WRITE:
+		bell_write();
+		break;
+	case GNOME_PROPERTY_APPLY:
+		bell_apply();
+		break;
+	case GNOME_PROPERTY_SETUP:
+		bell_setup();
+		break;
+	default:
+		return 0;
+	}
+
+	return 1;
+}
+
+void bell_register(GnomePropertyConfigurator *c)
+{
+	config = c;
+	gnome_property_configurator_register(config, bell_action);
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]