#143487 Calls the modmap load dialog. Loads the modmap files. Added newly

2005-01-29  Shakti Sen  <shprasad@novell.com>

	#143487
	* gnome-settings-keyboard-xkb.c
	(gnome_settings_keyboard_xkb_chk_lcl_xmm): Calls the modmap load
	dialog.
	* gnome-settings-daemon.c (gnome_settings_daemon_new):
	Loads the modmap files.
	* gnome-settings-xmodmap.h: Added newly
	* gnome-settings-xmodmap.c: Also added newly which handles the modmap
	settings.
	* modmap-dialog.glade: Added newly.
This commit is contained in:
Shakti Sen 2005-01-31 15:31:44 +00:00 committed by Jody Goldberg
parent 0bfbf3610a
commit 0c21cb9f45
5 changed files with 93 additions and 40 deletions

View file

@ -1,3 +1,17 @@
2005-01-29 Shakti Sen <shprasad@novell.com>
* gnome-settings-keyboard-xkb.c
(gnome_settings_keyboard_xkb_chk_lcl_xmm): Calls the modmap load
dialog.
* gnome-settings-daemon.c (gnome_settings_daemon_new):
Loads the modmap files.
* gnome-settings-xmodmap.h: Added newly
* gnome-settings-xmodmap.c: Also added newly which handles the modmap
settings.
* modmap-dialog.glade: Added newly.
Solved bug #143487
2005-01-12 Sebastien Bacher <seb128@debian.org>
* gnome-settings-accessibility-keyboard.c: (warning_dialog_post):

View file

@ -53,6 +53,8 @@ gnome_settings_daemon_SOURCES = \
gnome-settings-typing-break.h \
reaper.c \
reaper.h \
gnome-settings-xmodmap.c \
gnome-settings-xmodmap.h \
$(CORBA_GENERATED)
# $(AccessX_files)
@ -92,13 +94,16 @@ IDL_FLAGS = -D__GNOME_SettingsDaemon_COMPILATION -I $(idl_dir) -I $(datadir)/idl
$(CORBA_GENERATED): $(idl_dir)/GNOME_SettingsDaemon.idl $(ORBIT_IDL)
$(ORBIT_IDL) $(IDL_FLAGS) $(idl_dir)/GNOME_SettingsDaemon.idl
Gladedir = $(GNOMECC_GLADE_DIR)
Glade_DATA = modmap-dialog.glade
serverfile = GNOME_SettingsDaemon.server.in
serverdir = $(libdir)/bonobo/servers
install-data-hook :
$(mkinstalldirs) $(DESTDIR)$(serverdir)
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $(srcdir)/$(serverfile) > $(DESTDIR)$(serverdir)/$(serverfile:.in=)
EXTRA_DIST = $(serverfile)
EXTRA_DIST = $(serverfile) $(Glade_DATA)
CLEANFILES = $(BUILT_SOURCES)
uninstall-local:

View file

@ -39,6 +39,7 @@
#include "xsettings-manager.h"
#include "gnome-settings-daemon.h"
#include "gnome-settings-xmodmap.h"
/*#include "gnome-settings-disk.h"*/
#include "gnome-settings-font.h"
@ -275,6 +276,7 @@ gnome_settings_daemon_new (void)
gnome_settings_xsettings_init (client);
gnome_settings_mouse_init (client);
/* Essential - xkb initialization should happen before */
gnome_settings_keyboard_xkb_set_post_activation_callback (gnome_settings_load_modmap_files, NULL);
gnome_settings_keyboard_xkb_init (client);
gnome_settings_keyboard_init (client);
gnome_settings_multimedia_keys_init (client);

View file

@ -30,6 +30,7 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gconf/gconf-client.h>
#include "gnome-settings-xmodmap.h"
#include <string.h>
#include <time.h>
@ -56,6 +57,8 @@ static void *paCallbackUserData = NULL;
static const char DISABLE_XMM_WARNING_KEY[] =
"/desktop/gnome/peripherals/keyboard/disable_xmm_and_xkb_warning";
static const char KNOWN_FILES_KEY[] =
"/desktop/gnome/peripherals/keyboard/general/known_file_list";
typedef enum {
RESPONSE_USE_X,
@ -229,55 +232,70 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
GSwitchItKbdConfigTerm (&backupGConfKbdConfig);
}
static void
gnome_settings_keyboard_xkb_chk_lcl_xmm_response (GtkDialog * dlg,
gint response)
static gboolean
gnome_settings_chk_file_list (void)
{
GDir *homeDir;
G_CONST_RETURN gchar *fname;
GSList *file_list = NULL;
GSList *last_login_file_list = NULL;
GSList *tmp = NULL;
GSList *tmp_l = NULL;
gboolean new_file_exist = FALSE;
GConfClient *confClient = gconf_client_get_default ();
switch (response) {
case GTK_RESPONSE_OK:
gconf_client_set_bool (confClient, DISABLE_XMM_WARNING_KEY, TRUE,
NULL);
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
while ((fname = g_dir_read_name (homeDir)) != NULL) {
if (g_strrstr (fname, "modmap")) {
file_list = g_slist_append (file_list, g_strdup (fname));
}
}
last_login_file_list = gconf_client_get_list (confClient, KNOWN_FILES_KEY, GCONF_VALUE_STRING, NULL);
/* Compare between the two file list, currently available modmap files
and the files available in the last log in */
tmp = file_list;
while (tmp != NULL) {
tmp_l = last_login_file_list;
new_file_exist = TRUE;
while (tmp_l != NULL) {
if (strcmp (tmp->data, tmp_l->data) == 0) {
new_file_exist = FALSE;
break;
}
else
tmp_l = tmp_l->next;
}
if (new_file_exist)
break;
else
tmp = tmp->next;
}
if (new_file_exist)
gconf_client_set_list (confClient, KNOWN_FILES_KEY, GCONF_VALUE_STRING, file_list, NULL);
g_slist_foreach (file_list, (GFunc) g_free, NULL);
g_slist_free (file_list);
g_slist_foreach (last_login_file_list, (GFunc) g_free, NULL);
g_slist_free (last_login_file_list);
g_object_unref (G_OBJECT (confClient));
gtk_widget_destroy (GTK_WIDGET (dlg));
return new_file_exist;
}
static void
gnome_settings_keyboard_xkb_chk_lcl_xmm (void)
{
GConfClient *confClient = gconf_client_get_default ();
gboolean disableWarning =
gconf_client_get_bool (confClient, DISABLE_XMM_WARNING_KEY, NULL);
GDir *homeDir;
G_CONST_RETURN gchar *fname;
g_object_unref (G_OBJECT (confClient));
if (disableWarning)
return;
if (gnome_settings_chk_file_list ())
gnome_settings_modmap_dialog_call ();
gnome_settings_load_modmap_files ();
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
if (homeDir == NULL)
return;
while ((fname = g_dir_read_name (homeDir)) != NULL)
if (strlen (fname) >= 8
&& !g_ascii_strncasecmp (fname, ".xmodmap", 8)) {
GtkWidget *msg =
gtk_message_dialog_new_with_markup (NULL, 0,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
_
("You have a keyboard remapping file (%s) in your home directory whose contents will now be ignored."
" You can use the keyboard preferences to restore them."),
fname);
g_signal_connect (msg, "response",
G_CALLBACK
(gnome_settings_keyboard_xkb_chk_lcl_xmm_response),
NULL);
gtk_widget_show (msg);
break;
}
g_dir_close (homeDir);
}
void

View file

@ -65,6 +65,20 @@
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/peripherals/keyboard/general/known_file_list</key>
<applyto>/desktop/gnome/peripherals/keyboard/general/known_file_list</applyto>
<owner>gnome</owner>
<type>list</type>
<list_type>string</list_type>
<default>[]</default>
<locale name="C">
<short>modmap file list</short>
<long>A list of modmap files available in the $HOME directory.</long>
</locale>
</schema>
<schema>
<key>/schemas/desktop/gnome/peripherals/keyboard/general/defaultGroup</key>
<applyto>/desktop/gnome/peripherals/keyboard/general/defaultGroup</applyto>