2002-06-15 Jody Goldberg <jody@gnome.org> http://bugzilla.gnome.org/show_bug.cgi?id=85397 http://bugzilla.gnome.org/show_bug.cgi?id=84545 * mime-types-model.c (mime_types_model_get_value) : gtk_tree_view_search_equal_func does not like NULL. (IS_CATEGORY) : check for NULL. * file-types-capplet.c (create_dialog) : search the description not the mime type. 2002-06-08 Jody Goldberg <jody@gnome.org> * mime-types-model.c (IS_CATEGORY) : test for null in case we are stupid. 2002-06-07 Jody Goldberg <jody@gnome.org> * file-types-capplet.c (dialog_done_cb) : no need to save things again. The only caller had already done that. * mime-type-info.c (mime_type_info_save) : Don't mess with the application here, it should already be setup. However, be really really anal about verifying it because I do not trust the surrounding code or know it well enough to trust it. Make sure that the assigned app is on the short list of associated apps. * mime-category-edit-dialog.c (store_data) : Use mime_edit_dialog_get_app. * mime-edit-dialog.c (store_data) : Use it here too. (mime_edit_dialog_get_app) : new. split some duplicated code out of the type and category dialogs and move it here. Then make it readable and less stupid about creating copies of existing applications. While we're at it have it handle the creation of new applications, merging commands with existing applications and other useful stuff. 2002-06-07 Jody Goldberg <jody@gnome.org> * mime-category-edit-dialog.c (store_data) : clarify and remove the custom flag. * mime-type-info.c (mime_category_info_using_custom_app) : delete. (mime_type_info_using_custom_app) : delete. * mime-edit-dialog.c (validate_data) : correct the warning about invalid type, we would _not_ create one for the user :-( Allow a user to optionally overwrite an existing mime type. This is useful when editing. * mime-edit-dialog.c (store_data) : clarify and remove the custom flag. 2002-06-10 Jody Goldberg <jody@gnome.org> * accessibility-keyboard.c : tweak the layout as requested and adjust the max slowkey delay to 500 to avoid losing the keyboard due to some sort of an X problem. 2002-06-13 Jody Goldberg <jody@gnome.org> * gnome-keyboard-properties.c (accessibility_button_clicked) : produce a better warning for failure to launch the keyboard accessibility capplet.
396 lines
12 KiB
C
396 lines
12 KiB
C
/* -*- mode: c; style: linux -*- */
|
|
|
|
/* keyboard-properties.c
|
|
* Copyright (C) 2000-2001 Ximian, Inc.
|
|
* Copyright (C) 2001 Jonathan Blandford
|
|
*
|
|
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
|
* Rachel Hestilow <hestilow@ximian.com>
|
|
* Jonathan Blandford <jrb@redhat.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.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
#include <gnome.h>
|
|
#include <gconf/gconf-client.h>
|
|
#include <glade/glade.h>
|
|
|
|
#include "capplet-util.h"
|
|
#include "gconf-property-editor.h"
|
|
#include "activate-settings-daemon.h"
|
|
#include <../accessibility/keyboard/accessibility-keyboard.h>
|
|
|
|
enum
|
|
{
|
|
RESPONSE_APPLY = 1,
|
|
RESPONSE_CLOSE
|
|
};
|
|
|
|
static GladeXML *
|
|
create_dialog (void)
|
|
{
|
|
GladeXML *dialog;
|
|
|
|
dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-keyboard-properties.glade", "keyboard_dialog", NULL);
|
|
|
|
return dialog;
|
|
}
|
|
|
|
static GConfValue *
|
|
rate_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
int rate;
|
|
|
|
rate = gconf_value_get_int (value);
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
|
|
if (rate >= (255 + 192) / 2)
|
|
gconf_value_set_int (new_value, 0);
|
|
else if (rate >= (192 + 64) / 2)
|
|
gconf_value_set_int (new_value, 1);
|
|
else if (rate >= (64 + 1) / 2)
|
|
gconf_value_set_int (new_value, 2);
|
|
else
|
|
gconf_value_set_int (new_value, 3);
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
rate_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
static int rates[] = {
|
|
255, 192, 64, 1
|
|
};
|
|
|
|
GConfValue *new_value;
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
gconf_value_set_int (new_value, rates[gconf_value_get_int (value)]);
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
delay_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
int delay;
|
|
|
|
delay = gconf_value_get_int (value);
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
|
|
if (delay >= (1000 + 700) / 2)
|
|
gconf_value_set_int (new_value, 3);
|
|
else if (delay >= (700 + 300) / 2)
|
|
gconf_value_set_int (new_value, 2);
|
|
else if (delay >= (300 + 150) / 2)
|
|
gconf_value_set_int (new_value, 1);
|
|
else
|
|
gconf_value_set_int (new_value, 0);
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
delay_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
|
|
{
|
|
static int delays[] = {
|
|
150, 300, 700, 1000
|
|
};
|
|
|
|
GConfValue *new_value;
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
gconf_value_set_int (new_value, delays[gconf_value_get_int (value)]);
|
|
return new_value;
|
|
}
|
|
|
|
static GConfEnumStringPair bell_enums[] = {
|
|
{ 0, "off" },
|
|
{ 1, "on" },
|
|
{ 2, "custom" }
|
|
};
|
|
|
|
static GConfValue *
|
|
bell_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_STRING);
|
|
gconf_value_set_string (new_value,
|
|
gconf_enum_to_string (bell_enums, gconf_value_get_int (value)));
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
bell_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
const gchar *str;
|
|
gint val = 2;
|
|
|
|
str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL;
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
if (value->type == GCONF_VALUE_STRING) {
|
|
gconf_string_to_enum (bell_enums,
|
|
str,
|
|
&val);
|
|
}
|
|
gconf_value_set_int (new_value, val);
|
|
|
|
return new_value;
|
|
}
|
|
|
|
|
|
static GConfValue *
|
|
blink_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
gconf_value_set_int (new_value, 2600 - (int) gconf_value_get_float (value));
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
blink_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
GConfValue *new_value;
|
|
gint current_rate;
|
|
|
|
current_rate = gconf_value_get_int (value);
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
|
gconf_value_set_float (new_value, CLAMP (2600 - current_rate, 100, 2500));
|
|
|
|
return new_value;
|
|
}
|
|
|
|
static GConfValue *
|
|
volume_to_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
return gconf_value_int_to_float (value);
|
|
}
|
|
static GConfValue *
|
|
volume_from_widget (GConfPropertyEditor *peditor, const GConfValue *value)
|
|
{
|
|
return gconf_value_float_to_int (value);
|
|
}
|
|
|
|
static void
|
|
bell_guard (GtkWidget *toggle,
|
|
GladeXML *dialog)
|
|
{
|
|
gtk_widget_set_sensitive (WID ("bell_custom_fileentry"), GTK_TOGGLE_BUTTON (toggle)->active);
|
|
}
|
|
|
|
static gboolean
|
|
mnemonic_activate (GtkWidget *toggle,
|
|
gboolean group_cycling,
|
|
GtkWidget *entry)
|
|
{
|
|
if (! group_cycling)
|
|
gtk_widget_grab_focus (entry);
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
static void
|
|
dialog_response (GtkWidget *widget,
|
|
gint response_id,
|
|
GConfChangeSet *changeset)
|
|
{
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
capplet_help (GTK_WINDOW (widget),
|
|
"wgoscustdesk.xml",
|
|
"goscustperiph-2");
|
|
else
|
|
gtk_main_quit ();
|
|
}
|
|
|
|
static void
|
|
accessibility_button_clicked (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
GError *err = NULL;
|
|
if (!g_spawn_command_line_async ("gnome-accessibility-keyboard-properties", NULL))
|
|
capplet_error_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
|
|
_("There was an error launching the keyboard capplet : %s"),
|
|
err);
|
|
}
|
|
|
|
static void
|
|
setup_dialog (GladeXML *dialog,
|
|
GConfChangeSet *changeset)
|
|
{
|
|
GObject *peditor;
|
|
GnomeProgram *program;
|
|
gchar *filename;
|
|
|
|
/* load all the images */
|
|
program = gnome_program_get ();
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-repeat.png", TRUE, NULL);
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("repeat_image")), filename);
|
|
g_free (filename);
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-cursor.png", TRUE, NULL);
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("cursor_image")), filename);
|
|
g_free (filename);
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-volume.png", TRUE, NULL);
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("volume_image")), filename);
|
|
g_free (filename);
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "keyboard-bell.png", TRUE, NULL);
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("bell_image")), filename);
|
|
g_free (filename);
|
|
|
|
peditor = gconf_peditor_new_boolean
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/repeat", WID ("repeat_toggle"), NULL);
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("repeat_table"));
|
|
|
|
gconf_peditor_new_select_menu
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/delay", WID ("repeat_delay_omenu"),
|
|
"conv-to-widget-cb", delay_to_widget,
|
|
"conv-from-widget-cb", delay_from_widget,
|
|
NULL);
|
|
|
|
gconf_peditor_new_select_menu
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/rate", WID ("repeat_speed_omenu"),
|
|
"conv-to-widget-cb", rate_to_widget,
|
|
"conv-from-widget-cb", rate_from_widget,
|
|
NULL);
|
|
|
|
peditor = gconf_peditor_new_boolean
|
|
(changeset, "/desktop/gnome/interface/cursor_blink", WID ("cursor_toggle"), NULL);
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("cursor_hbox"));
|
|
gconf_peditor_new_numeric_range
|
|
(changeset, "/desktop/gnome/interface/cursor_blink_time", WID ("cursor_blink_time_scale"),
|
|
"conv-to-widget-cb", blink_to_widget,
|
|
"conv-from-widget-cb", blink_from_widget,
|
|
NULL);
|
|
|
|
|
|
peditor = gconf_peditor_new_boolean
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/click", WID ("volume_toggle"), NULL);
|
|
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("volume_hbox"));
|
|
gconf_peditor_new_numeric_range
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/click_volume", WID ("volume_scale"),
|
|
"conv-to-widget-cb", volume_to_widget,
|
|
"conv-from-widget-cb", volume_from_widget,
|
|
NULL);
|
|
|
|
g_signal_connect (G_OBJECT (WID ("bell_custom_radio")), "toggled", (GCallback) bell_guard, dialog);
|
|
peditor = gconf_peditor_new_select_radio
|
|
(changeset, "/desktop/gnome/peripherals/keyboard/bell_mode",
|
|
gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("bell_disabled_radio"))),
|
|
"conv-to-widget-cb", bell_to_widget,
|
|
"conv-from-widget-cb", bell_from_widget,
|
|
NULL);
|
|
g_signal_connect (G_OBJECT (WID ("bell_custom_radio")), "mnemonic_activate", (GCallback) mnemonic_activate, WID ("bell_custom_entry"));
|
|
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")), "response", (GCallback) dialog_response, changeset);
|
|
|
|
g_signal_connect (G_OBJECT (WID ("accessibility_button")), "clicked", (GCallback) accessibility_button_clicked, NULL);
|
|
}
|
|
|
|
static void
|
|
get_legacy_settings (void)
|
|
{
|
|
GConfClient *client;
|
|
gboolean val_bool, def;
|
|
gulong val_int;
|
|
|
|
client = gconf_client_get_default ();
|
|
|
|
COPY_FROM_LEGACY (bool, "/gnome/desktop/peripherals/keyboard/repeat", "/Desktop/Keyboard/repeat=true");
|
|
COPY_FROM_LEGACY (bool, "/gnome/desktop/peripherals/keyboard/click", "/Desktop/Keyboard/click=true");
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/rate", "/Desktop/Keyboard/rate=30");
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/delay", "/Desktop/Keyboard/delay=500");
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/volume", "/Desktop/Keyboard/clickvolume=0");
|
|
#if 0
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/bell_volume", "/Desktop/Bell/percent=50");
|
|
#endif
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/bell_pitch", "/Desktop/Bell/pitch=50");
|
|
COPY_FROM_LEGACY (int, "/gnome/desktop/peripherals/keyboard/bell_duration", "/Desktop/Bell/duration=100");
|
|
}
|
|
|
|
#if 0
|
|
static void
|
|
setup_accessibility (GladeXML *dialog, GConfChangeSet *changeset)
|
|
{
|
|
GtkWidget *notebook = WID ("notebook1");
|
|
GtkWidget *label = gtk_label_new_with_mnemonic (_("_Accessibility"));
|
|
GtkWidget *page = setup_accessX_dialog (changeset, FALSE);
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
|
|
}
|
|
#endif
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
GConfClient *client;
|
|
GConfChangeSet *changeset;
|
|
GladeXML *dialog;
|
|
|
|
static gboolean apply_only;
|
|
static gboolean get_legacy;
|
|
static struct poptOption cap_options[] = {
|
|
{ "apply", '\0', POPT_ARG_NONE, &apply_only, 0,
|
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
|
{ "init-session-settings", '\0', POPT_ARG_NONE, &apply_only, 0,
|
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
|
{ "get-legacy", '\0', POPT_ARG_NONE, &get_legacy, 0,
|
|
N_("Retrieve and store legacy settings"), NULL },
|
|
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
|
};
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
textdomain (GETTEXT_PACKAGE);
|
|
|
|
gnome_program_init ("gnome-keyboard-properties", VERSION, LIBGNOMEUI_MODULE, argc, argv,
|
|
GNOME_PARAM_POPT_TABLE, cap_options,
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
|
NULL);
|
|
|
|
activate_settings_daemon ();
|
|
|
|
client = gconf_client_get_default ();
|
|
gconf_client_add_dir (client, "/desktop/gnome/peripherals/keyboard", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
gconf_client_add_dir (client, "/desktop/gnome/interface", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
|
|
if (get_legacy) {
|
|
get_legacy_settings ();
|
|
} else {
|
|
changeset = NULL;
|
|
dialog = create_dialog ();
|
|
setup_dialog (dialog, changeset);
|
|
#if 0
|
|
setup_accessibility (dialog, changeset);
|
|
#endif
|
|
gtk_widget_show (WID ("keyboard_dialog"));
|
|
gtk_main ();
|
|
}
|
|
|
|
return 0;
|
|
}
|