Getting colder with our second freeze... it's 3.31.91 release day and string freeze, upload a tarball and lock those strings 🏂

Commit 4239cb8a authored by Bastien Nocera's avatar Bastien Nocera

keyboard: Remove horrible xmodmap fallback code

https://bugzilla.gnome.org/show_bug.cgi?id=150542
parent bf86725e
......@@ -13,9 +13,6 @@ icons_DATA = \
kbd-capslock-off.png kbd-numlock-off.png kbd-scrolllock-off.png \
kbd-capslock-on.png kbd-numlock-on.png kbd-scrolllock-on.png
uidir = $(pkgdatadir)
ui_DATA = modmap-dialog.ui
libkeyboard_la_SOURCES = \
gsd-keyboard-plugin.h \
gsd-keyboard-plugin.c \
......@@ -23,8 +20,6 @@ libkeyboard_la_SOURCES = \
gsd-keyboard-manager.c \
gsd-keyboard-xkb.h \
gsd-keyboard-xkb.c \
gsd-xmodmap.h \
gsd-xmodmap.c \
delayed-dialog.h \
delayed-dialog.c \
$(NULL)
......
......@@ -50,7 +50,6 @@
#include "gsd-enums.h"
#include "gsd-keyboard-xkb.h"
#include "gsd-xmodmap.h"
#define GSD_KEYBOARD_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBOARD_MANAGER, GsdKeyboardManagerPrivate))
......@@ -371,7 +370,6 @@ start_keyboard_idle_cb (GsdKeyboardManager *manager)
manager->priv->settings = g_settings_new (GSD_KEYBOARD_DIR);
/* Essential - xkb initialization should happen before */
gsd_keyboard_xkb_set_post_activation_callback ((PostActivationCallback) gsd_load_modmap_files, NULL);
gsd_keyboard_xkb_init (manager);
#ifdef HAVE_X11_EXTENSIONS_XKB_H
......
......@@ -36,7 +36,6 @@
#include <libgnomekbd/gkbd-keyboard-config.h>
#include <libgnomekbd/gkbd-util.h>
#include "gsd-xmodmap.h"
#include "gsd-keyboard-xkb.h"
#include "delayed-dialog.h"
#include "gnome-settings-profile.h"
......@@ -614,83 +613,6 @@ gsd_keyboard_xkb_analyze_sysconfig (void)
NULL);
}
static gboolean
gsd_chk_file_list (void)
{
GDir *home_dir;
const char *fname;
GSList *file_list = NULL;
GSList *last_login_file_list = NULL;
GSList *tmp = NULL;
GSList *tmp_l = NULL;
gboolean new_file_exist = FALSE;
GConfClient *conf_client;
home_dir = g_dir_open (g_get_home_dir (), 0, NULL);
while ((fname = g_dir_read_name (home_dir)) != NULL) {
if (g_strrstr (fname, "modmap")) {
file_list =
g_slist_append (file_list, g_strdup (fname));
}
}
g_dir_close (home_dir);
conf_client = gconf_client_get_default ();
last_login_file_list = gconf_client_get_list (conf_client,
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 (conf_client,
KNOWN_FILES_KEY,
GCONF_VALUE_STRING,
file_list, NULL);
}
g_object_unref (conf_client);
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);
return new_file_exist;
}
static void
gsd_keyboard_xkb_chk_lcl_xmm (void)
{
if (gsd_chk_file_list ()) {
gsd_modmap_dialog_call ();
}
gsd_load_modmap_files ();
}
void
gsd_keyboard_xkb_set_post_activation_callback (PostActivationCallback fun,
void *user_data)
......@@ -803,11 +725,6 @@ gsd_keyboard_xkb_init (GsdKeyboardManager * kbd_manager)
xkl_engine);
xkl_engine_backup_names_prop (xkl_engine);
gsd_keyboard_xkb_analyze_sysconfig ();
gnome_settings_profile_start
("gsd_keyboard_xkb_chk_lcl_xmm");
gsd_keyboard_xkb_chk_lcl_xmm ();
gnome_settings_profile_end
("gsd_keyboard_xkb_chk_lcl_xmm");
settings_desktop = g_settings_new (GKBD_DESKTOP_SCHEMA);
settings_keyboard = g_settings_new (GKBD_KEYBOARD_SCHEMA);
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright © 2005 Novell Inc.
*
* Written by Shakti Sen <shprasad@novell.com>
*
* 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)
* 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.
*/
#include "config.h"
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
#include "gsd-xmodmap.h"
static const char DISABLE_XMM_WARNING_KEY[] =
"/desktop/gnome/peripherals/keyboard/disable_xmm_and_xkb_warning";
static const char LOADED_FILES_KEY[] =
"/desktop/gnome/peripherals/keyboard/general/update_handlers";
static void
check_button_callback (GtkWidget *chk_button,
gpointer data)
{
GConfClient *client;
client = gconf_client_get_default ();
gconf_client_set_bool (client,
DISABLE_XMM_WARNING_KEY,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_button)),
NULL);
g_object_unref (client);
}
void
gsd_load_modmap_files (void)
{
GConfClient *client;
GSList *tmp;
GSList *loaded_file_list;
client = gconf_client_get_default ();
loaded_file_list = gconf_client_get_list (client, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
for (tmp = loaded_file_list; tmp != NULL; tmp = tmp->next) {
gchar *file;
gchar *command;
file = g_build_filename (g_get_home_dir (), (gchar *) tmp->data, NULL);
command = g_strconcat ("xmodmap ", file, NULL);
g_free (file);
g_spawn_command_line_async (command, NULL);
g_free (command);
g_free (tmp->data);
}
g_slist_free (loaded_file_list);
g_object_unref (client);
}
static void
response_callback (GtkWidget *dialog,
int id,
void *data)
{
if (id == GTK_RESPONSE_OK) {
GtkWidget *chk_button = g_object_get_data (G_OBJECT (dialog), "check_button");
check_button_callback (chk_button, NULL);
gsd_load_modmap_files ();
}
gtk_widget_destroy (dialog);
}
static void
get_selected_files_func (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data)
{
GSList **list = data;
gchar *filename;
filename = NULL;
gtk_tree_model_get (model,
iter,
0,
&filename,
-1);
*list = g_slist_prepend (*list, filename);
}
static GSList*
remove_string_from_list (GSList *list,
const char *str)
{
GSList *tmp;
for (tmp = list; tmp != NULL; tmp = tmp->next) {
if (strcmp (tmp->data, str) == 0) {
g_free (tmp->data);
list = g_slist_delete_link (list, tmp);
break;
}
}
return list;
}
static void
remove_button_clicked_callback (GtkWidget *button,
void *data)
{
GtkWidget *dialog;
GtkListStore *tree = NULL;
GtkTreeSelection *selection;
GtkWidget *treeview;
GConfClient *client;
GSList *filenames = NULL;
GSList *tmp = NULL;
GSList *loaded_files = NULL;
dialog = data;
treeview = g_object_get_data (G_OBJECT (dialog), "treeview1");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_selected_foreach (selection,
get_selected_files_func,
&filenames);
if (!filenames)
return;
/* Remove the selected file */
client = gconf_client_get_default ();
loaded_files = gconf_client_get_list (client,
LOADED_FILES_KEY,
GCONF_VALUE_STRING,
NULL);
loaded_files = remove_string_from_list (loaded_files, (char *)filenames->data);
gconf_client_set_list (client,
LOADED_FILES_KEY,
GCONF_VALUE_STRING,
loaded_files,
NULL);
g_object_unref (client);
tree = g_object_get_data (G_OBJECT (dialog), "tree");
gtk_list_store_clear (tree);
for (tmp = loaded_files; tmp != NULL; tmp = tmp->next) {
GtkTreeIter iter;
gtk_list_store_append (tree, &iter);
gtk_list_store_set (tree, &iter,
0,
tmp->data,
-1);
}
g_slist_foreach (loaded_files, (GFunc) g_free, NULL);
g_slist_free (loaded_files);
}
static void
load_button_clicked_callback (GtkWidget *button,
void *data)
{
GtkWidget *dialog;
GtkListStore *tree = NULL;
GtkTreeSelection *selection;
GtkWidget *treeview;
GSList *filenames = NULL;
GSList *tmp = NULL;
GSList *loaded_files = NULL;
GConfClient *client;
dialog = data;
treeview = g_object_get_data (G_OBJECT (dialog),
"loaded-treeview");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_selected_foreach (selection,
get_selected_files_func,
&filenames);
if (!filenames)
return;
/* Add the files to left-tree-view */
client = gconf_client_get_default ();
loaded_files = gconf_client_get_list (client,
LOADED_FILES_KEY,
GCONF_VALUE_STRING,
NULL);
if (g_slist_find_custom (loaded_files, filenames->data, (GCompareFunc) strcmp)) {
g_free (filenames->data);
g_slist_free (filenames);
goto out;
}
loaded_files = g_slist_append (loaded_files, filenames->data);
gconf_client_set_list (client,
LOADED_FILES_KEY,
GCONF_VALUE_STRING,
loaded_files,
NULL);
tree = g_object_get_data (G_OBJECT (dialog), "tree");
gtk_list_store_clear (tree);
for (tmp = loaded_files; tmp != NULL; tmp = tmp->next) {
GtkTreeIter iter;
gtk_list_store_append (tree, &iter);
gtk_list_store_set (tree, &iter,
0,
tmp->data,
-1);
}
out:
g_object_unref (client);
g_slist_foreach (loaded_files, (GFunc) g_free, NULL);
g_slist_free (loaded_files);
}
void
gsd_modmap_dialog_call (void)
{
GtkBuilder *builder;
guint res;
GError *error;
GtkWidget *load_dialog;
GtkListStore *tree;
GtkCellRenderer *cell_renderer;
GtkTreeIter parent_iter;
GtkTreeIter iter;
GtkTreeModel *sort_model;
GtkTreeSelection *selection;
GtkWidget *treeview;
GtkWidget *treeview1;
GtkTreeViewColumn *column;
GtkWidget *add_button;
GtkWidget *remove_button;
GtkWidget *chk_button;
GSList *tmp;
GDir *homeDir;
GSList *loaded_files;
const char *fname;
GConfClient *client;
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
if (homeDir == NULL)
return;
error = NULL;
builder = gtk_builder_new ();
res = gtk_builder_add_from_file (builder,
DATADIR "/modmap-dialog.ui",
&error);
if (res == 0) {
g_warning ("Could not load UI file: %s", error->message);
g_error_free (error);
g_object_unref (builder);
g_dir_close (homeDir);
return;
}
load_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog1"));
gtk_window_set_modal (GTK_WINDOW (load_dialog), TRUE);
g_signal_connect (load_dialog,
"response",
G_CALLBACK (response_callback),
builder);
add_button = GTK_WIDGET (gtk_builder_get_object (builder, "button7"));
g_signal_connect (add_button,
"clicked",
G_CALLBACK (load_button_clicked_callback),
load_dialog);
remove_button = GTK_WIDGET (gtk_builder_get_object (builder,
"button6"));
g_signal_connect (remove_button,
"clicked",
G_CALLBACK (remove_button_clicked_callback),
load_dialog);
chk_button = GTK_WIDGET (gtk_builder_get_object (builder,
"checkbutton1"));
g_signal_connect (chk_button,
"toggled",
G_CALLBACK (check_button_callback),
NULL);
g_object_set_data (G_OBJECT (load_dialog), "check_button", chk_button);
treeview = GTK_WIDGET (gtk_builder_get_object (builder, "treeview1"));
g_object_set_data (G_OBJECT (load_dialog), "treeview1", treeview);
treeview = GTK_WIDGET (gtk_builder_get_object (builder, "treeview2"));
g_object_set_data (G_OBJECT (load_dialog), "loaded-treeview", treeview);
tree = gtk_list_store_new (1, G_TYPE_STRING);
cell_renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("modmap",
cell_renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
gtk_tree_view_column_set_sort_column_id (column, 0);
/* Add the data */
while ((fname = g_dir_read_name (homeDir)) != NULL) {
if (g_strrstr (fname, "modmap")) {
gtk_list_store_append (tree, &parent_iter);
gtk_list_store_set (tree, &parent_iter,
0,
fname,
-1);
}
}
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
0,
GTK_SORT_ASCENDING);
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), sort_model);
g_object_unref (G_OBJECT (tree));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
GTK_SELECTION_MULTIPLE);
gtk_widget_show (load_dialog);
g_dir_close (homeDir);
/* Left treeview */
treeview1 = GTK_WIDGET (gtk_builder_get_object (builder, "treeview1"));
tree = gtk_list_store_new (1, G_TYPE_STRING);
cell_renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("modmap",
cell_renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview1), column);
gtk_tree_view_column_set_sort_column_id (column, 0);
client = gconf_client_get_default ();
loaded_files = gconf_client_get_list (client, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
g_object_unref (client);
/* Add the data */
for (tmp = loaded_files; tmp != NULL; tmp = tmp->next) {
gtk_list_store_append (tree, &iter);
gtk_list_store_set (tree, &iter,
0,
tmp->data,
-1);
}
g_slist_foreach (loaded_files, (GFunc) g_free, NULL);
g_slist_free (loaded_files);
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
0,
GTK_SORT_ASCENDING);
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview1), sort_model);
g_object_unref (G_OBJECT (tree));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview1));
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
GTK_SELECTION_MULTIPLE);
g_object_set_data (G_OBJECT (load_dialog), "tree", tree);
g_object_unref (builder);
}
/* gnome-settings-xmodmap.h
*
* Copyright © 2005 Novell Inc.
*
* Written by Shakti Sen <shprasad@novell.com>
*
* 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)
* 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.
*/
#ifndef XMODMAP_H
#define XMODMAP_H
void gsd_load_modmap_files (void);
void gsd_modmap_dialog_call (void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment