summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacob berkman <jacob@ximian.com>2002-05-16 23:09:02 +0000
committerJacob Berkman <jberkman@src.gnome.org>2002-05-16 23:09:02 +0000
commit58aa3658454a079a087e21702fbbe2e159669cf0 (patch)
treee43ddd7c778b2769656ed2e29da75dae06086f0d
parent98b7a5871587be425d219fdd272f3e40f72fb493 (diff)
downloadgnome-control-center-58aa3658454a079a087e21702fbbe2e159669cf0.tar.gz
keep text/plain and text* using the same mime type (#78037)
2002-05-16 jacob berkman <jacob@ximian.com> * Makefile.am: * gnome-settings-default-editor.[ch]: keep text/plain and text* using the same mime type (#78037) * gnome-settings-daemon.c (gnome_settings_daemon_new): load editor and keyboard settings (bugs #78037 and #78016)
-rw-r--r--gnome-settings-daemon/ChangeLog9
-rw-r--r--gnome-settings-daemon/Makefile.am2
-rw-r--r--gnome-settings-daemon/gnome-settings-daemon.c6
-rw-r--r--gnome-settings-daemon/gnome-settings-default-editor.c125
-rw-r--r--gnome-settings-daemon/gnome-settings-default-editor.h18
-rw-r--r--gnome-settings-daemon/gnome-settings-keyboard.c11
6 files changed, 169 insertions, 2 deletions
diff --git a/gnome-settings-daemon/ChangeLog b/gnome-settings-daemon/ChangeLog
index 6baed74c0..59afff2d3 100644
--- a/gnome-settings-daemon/ChangeLog
+++ b/gnome-settings-daemon/ChangeLog
@@ -1,3 +1,12 @@
+2002-05-16 jacob berkman <jacob@ximian.com>
+
+ * Makefile.am:
+ * gnome-settings-default-editor.[ch]: keep text/plain and text*
+ using the same mime type (#78037)
+
+ * gnome-settings-daemon.c (gnome_settings_daemon_new): load editor
+ and keyboard settings (bugs #78037 and #78016)
+
Tue May 14 14:50:34 2002 Jonathan Blandford <jrb@redhat.com>
* gnome-settings-*.c: Remove all debug print statements, #76085
diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am
index 1c4bdf60f..670911eeb 100644
--- a/gnome-settings-daemon/Makefile.am
+++ b/gnome-settings-daemon/Makefile.am
@@ -26,6 +26,8 @@ gnome_settings_daemon_SOURCES = \
gnome-settings-accessibility-keyboard.c \
gnome-settings-screensaver.h \
gnome-settings-screensaver.c \
+ gnome-settings-default-editor.c \
+ gnome-settings-default-editor.h \
xsettings-common.c \
xsettings-manager.c \
xsettings-common.h \
diff --git a/gnome-settings-daemon/gnome-settings-daemon.c b/gnome-settings-daemon/gnome-settings-daemon.c
index 0ff882da0..80e992462 100644
--- a/gnome-settings-daemon/gnome-settings-daemon.c
+++ b/gnome-settings-daemon/gnome-settings-daemon.c
@@ -44,6 +44,7 @@
#include "gnome-settings-wm.h"
#include "gnome-settings-accessibility-keyboard.h"
#include "gnome-settings-screensaver.h"
+#include "gnome-settings-default-editor.h"
#include "GNOME_SettingsDaemon.h"
@@ -237,6 +238,7 @@ gnome_settings_daemon_new (void)
gnome_settings_wm_init (client);
gnome_settings_accessibility_keyboard_init (client);
gnome_settings_screensaver_init (client);
+ gnome_settings_default_editor_init (client);
for (list = directories; list; list = list->next)
{
@@ -269,11 +271,13 @@ gnome_settings_daemon_new (void)
gnome_settings_font_load (client);
gnome_settings_xsettings_load (client);
gnome_settings_mouse_load (client);
+ gnome_settings_keyboard_load (client);
gnome_settings_sound_load (client);
gnome_settings_background_load (client);
gnome_settings_wm_load (client);
gnome_settings_accessibility_keyboard_load (client);
gnome_settings_screensaver_load (client);
-
+ gnome_settings_default_editor_load (client);
+
return G_OBJECT (daemon);
}
diff --git a/gnome-settings-daemon/gnome-settings-default-editor.c b/gnome-settings-daemon/gnome-settings-default-editor.c
new file mode 100644
index 000000000..d1a3e791f
--- /dev/null
+++ b/gnome-settings-daemon/gnome-settings-default-editor.c
@@ -0,0 +1,125 @@
+/*
+ * gnome-settings-default-editor.h: sync default editor changes to mime database
+ *
+ * Copyright 2002 Sun Microsystems, Inc.
+ *
+ * Author: jacob berkman <jacob@ximian.com>
+ *
+ */
+
+/*
+ * WARNING: This is a hack.
+ *
+ * All it does is keep the "text/*" and "text/plain" mime type
+ * handlers in sync with each other. The reason we do this is because
+ * there is no UI for editing the text/* handler, and this is probably
+ * what the user actually wants to do.
+ */
+
+#include <config.h>
+
+#include "gnome-settings-daemon.h"
+#include "gnome-settings-default-editor.h"
+
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomevfs/gnome-vfs-mime-monitor.h>
+
+#include <string.h>
+
+/* #define DE_DEBUG */
+
+#define SYNC_CHANGES_KEY "/apps/gnome_settings_daemon/default_editor/sync_text_types"
+
+static gboolean sync_changes;
+
+#if DE_DEBUG
+static void
+print_mime_app (const char *mime_type)
+{
+ GnomeVFSMimeApplication *mime_app;
+
+ mime_app = gnome_vfs_mime_get_default_application (mime_type);
+
+ g_message ("Default info for %s (%p):\n"
+ "\t id: %s\n"
+ "\t name: %s\n"
+ "\t command: %s\n"
+ "\tneeds term: %s\n",
+ mime_type, mime_app,
+ mime_app->id,
+ mime_app->name,
+ mime_app->command,
+ mime_app->requires_terminal ? "Yes" : "No");
+}
+
+static void
+print_state (void)
+{
+ if (sync_changes)
+ g_message ("Synching changes.");
+ else
+ g_message ("Not synching changes.");
+
+ print_mime_app ("text/*");
+ print_mime_app ("text/plain");
+}
+#define PRINT_STATE print_state()
+#else
+#define PRINT_STATE
+#endif
+
+static void
+sync_changes_cb (GConfEntry *entry)
+{
+ GConfValue *value = gconf_entry_get_value (entry);
+ sync_changes = gconf_value_get_bool (value);
+
+ PRINT_STATE;
+}
+
+static void
+vfs_change_cb (GnomeVFSMIMEMonitor *monitor, GConfClient *client)
+{
+ GnomeVFSMimeApplication *star_app, *plain_app;
+ GnomeVFSMimeActionType action;
+
+ PRINT_STATE;
+
+ if (!sync_changes_cb)
+ return;
+
+
+ star_app = gnome_vfs_mime_get_default_application ("text/*");
+ plain_app = gnome_vfs_mime_get_default_application ("text/plain");
+
+ if (!strcmp (star_app->id, plain_app->id))
+ return;
+
+#if DE_DEBUG
+ g_message ("Synching text/plain to text/*...");
+#endif
+
+ action = gnome_vfs_mime_get_default_action_type ("text/plain");
+
+ gnome_vfs_mime_set_default_application ("text/*", plain_app->id);
+ gnome_vfs_mime_set_default_action_type ("text/*", action);
+
+ PRINT_STATE;
+}
+
+void
+gnome_settings_default_editor_init (GConfClient *client)
+{
+ sync_changes = gconf_client_get_bool (client, SYNC_CHANGES_KEY, NULL);
+
+ gnome_settings_daemon_register_callback (SYNC_CHANGES_KEY, sync_changes_cb);
+
+ g_signal_connect (gnome_vfs_mime_monitor_get (), "data_changed",
+ G_CALLBACK (vfs_change_cb), client);
+}
+
+void
+gnome_settings_default_editor_load (GConfClient *client)
+{
+ vfs_change_cb (NULL, client);
+}
diff --git a/gnome-settings-daemon/gnome-settings-default-editor.h b/gnome-settings-daemon/gnome-settings-default-editor.h
new file mode 100644
index 000000000..fd510fa94
--- /dev/null
+++ b/gnome-settings-daemon/gnome-settings-default-editor.h
@@ -0,0 +1,18 @@
+/*
+ * gnome-settings-default-editor.h: sync default editor changes to mime database
+ *
+ * Copyright 2002 Sun Microsystems, Inc.
+ *
+ * Author: jacob berkman <jacob@ximian.com>
+ *
+ */
+
+#ifndef GNOME_SETTINGS_DEFAULT_EDITOR_H
+#define GNOME_SETTINGS_DEFAULT_EDITOR_H
+
+#include <gconf/gconf-client.h>
+
+void gnome_settings_default_editor_init (GConfClient *client);
+void gnome_settings_default_editor_load (GConfClient *client);
+
+#endif /* GNOME_SETTINGS_DEFAULT_EDITOR_H */
diff --git a/gnome-settings-daemon/gnome-settings-keyboard.c b/gnome-settings-daemon/gnome-settings-keyboard.c
index eda7fd675..3333ac57e 100644
--- a/gnome-settings-daemon/gnome-settings-keyboard.c
+++ b/gnome-settings-daemon/gnome-settings-keyboard.c
@@ -40,6 +40,8 @@
#include <X11/XKBlib.h>
#endif
+#include <string.h>
+
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
static gboolean
xfree86_set_keyboard_autorepeat_rate (int delay, int rate)
@@ -82,6 +84,7 @@ apply_settings (void)
gboolean repeat, click;
int rate, delay;
int click_volume, bell_volume, bell_pitch, bell_duration;
+ const char *volume_string;
XKeyboardControl kbdcontrol;
@@ -92,10 +95,15 @@ apply_settings (void)
rate = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/rate", NULL);
delay = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/delay", NULL);
click_volume = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/click_volume", NULL);
+#if 0
bell_volume = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_volume", NULL);
+#endif
bell_pitch = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_pitch", NULL);
bell_duration = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_duration", NULL);
+ volume_string = gconf_client_get_string (client, "/desktop/gnome/peripherals/keyboard/bell_mode", NULL);
+ bell_volume = (volume_string && !strcmp (volume_string, "on")) ? 50 : 0;
+
gdk_error_trap_push ();
if (repeat) {
gboolean rate_set = FALSE;
@@ -126,7 +134,8 @@ apply_settings (void)
kbdcontrol.bell_percent = bell_volume;
kbdcontrol.bell_pitch = bell_pitch;
kbdcontrol.bell_duration = bell_duration;
- XChangeKeyboardControl (GDK_DISPLAY (), KBKeyClickPercent,
+ XChangeKeyboardControl (GDK_DISPLAY (),
+ KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration,
&kbdcontrol);
XSync (GDK_DISPLAY (), FALSE);