2003-06-25 17:37:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
#include <glade/glade.h>
|
|
|
|
|
|
|
|
#include "capplet-util.h"
|
|
|
|
#include "gconf-property-editor.h"
|
|
|
|
#include "activate-settings-daemon.h"
|
|
|
|
|
|
|
|
#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
|
|
|
|
#define ACCESSIBILITY_KEY_DIR "/desktop/gnome/interface"
|
|
|
|
|
2007-09-18 18:58:37 +00:00
|
|
|
static gboolean initial_state;
|
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
static GladeXML *
|
|
|
|
create_dialog (void)
|
|
|
|
{
|
|
|
|
GladeXML *dialog;
|
2007-02-08 19:45:59 +00:00
|
|
|
|
2003-07-18 22:22:38 +00:00
|
|
|
dialog = glade_xml_new (GLADEDIR "/at-enable-dialog.glade", "at_properties_dialog", NULL);
|
2007-02-08 19:45:59 +00:00
|
|
|
|
|
|
|
if (dialog) {
|
2007-05-05 11:14:54 +00:00
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("at_close_logout_button")), image);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("at_pref_button")), image);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("keyboard_button")), image);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (WID ("login_button")), image);
|
2007-02-08 19:45:59 +00:00
|
|
|
|
|
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("at_enable_image")),
|
2007-04-26 11:14:15 +00:00
|
|
|
PIXMAPDIR "/at-startup.png");
|
2007-02-08 19:45:59 +00:00
|
|
|
|
|
|
|
gtk_image_set_from_file (GTK_IMAGE (WID ("at_applications_image")),
|
2007-04-26 11:14:15 +00:00
|
|
|
PIXMAPDIR "/at-support.png");
|
2007-02-08 19:45:59 +00:00
|
|
|
}
|
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2007-04-26 11:14:15 +00:00
|
|
|
static void
|
|
|
|
cb_at_preferences (GtkDialog *dialog, gint response_id)
|
|
|
|
{
|
|
|
|
g_spawn_command_line_async("gnome-default-applications-properties", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cb_keyboard_preferences (GtkDialog *dialog, gint response_id)
|
|
|
|
{
|
2008-01-02 19:03:10 +00:00
|
|
|
g_spawn_command_line_async("gnome-keyboard-properties --a11y", NULL);
|
2007-04-26 11:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cb_login_preferences (GtkDialog *dialog, gint response_id)
|
|
|
|
{
|
|
|
|
g_spawn_command_line_async("gdmsetup", NULL);
|
|
|
|
}
|
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
static void
|
|
|
|
cb_dialog_response (GtkDialog *dialog, gint response_id)
|
|
|
|
{
|
|
|
|
GnomeClient *client;
|
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
capplet_help (GTK_WINDOW (dialog),
|
2004-09-02 21:07:48 +00:00
|
|
|
"user-guide.xml",
|
|
|
|
"goscustaccess-11");
|
2004-02-16 17:32:32 +00:00
|
|
|
else if (response_id == GTK_RESPONSE_CLOSE || response_id == GTK_RESPONSE_DELETE_EVENT)
|
2003-06-25 17:37:32 +00:00
|
|
|
gtk_main_quit ();
|
|
|
|
else {
|
|
|
|
g_message ("CLOSE AND LOGOUT!");
|
|
|
|
if (!(client = gnome_master_client ())) {
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
2007-05-05 11:14:54 +00:00
|
|
|
gnome_client_request_save (client, GNOME_SAVE_GLOBAL, TRUE,
|
2003-06-25 17:37:32 +00:00
|
|
|
GNOME_INTERACT_ANY, FALSE, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
close_logout_update (GladeXML *dialog)
|
|
|
|
{
|
|
|
|
GConfClient *client = gconf_client_get_default ();
|
2007-09-18 18:58:37 +00:00
|
|
|
gboolean curr_state = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
|
2003-06-25 17:37:32 +00:00
|
|
|
|
2007-09-18 18:58:37 +00:00
|
|
|
gtk_widget_set_sensitive (WID ("at_close_logout_button"), initial_state != curr_state);
|
2003-06-25 17:37:32 +00:00
|
|
|
g_object_unref (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-05 11:14:54 +00:00
|
|
|
at_enable_toggled (GtkToggleButton *toggle_button,
|
2003-06-25 17:37:32 +00:00
|
|
|
GladeXML *dialog)
|
|
|
|
{
|
|
|
|
GConfClient *client = gconf_client_get_default ();
|
|
|
|
gboolean is_enabled = gtk_toggle_button_get_active (toggle_button);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
gconf_client_set_bool (client, ACCESSIBILITY_KEY,
|
|
|
|
is_enabled,
|
|
|
|
NULL);
|
|
|
|
g_object_unref (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
at_enable_update (GConfClient *client,
|
|
|
|
GladeXML *dialog)
|
|
|
|
{
|
|
|
|
gboolean is_enabled = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-07-18 22:22:38 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("at_enable_toggle")),
|
2003-06-25 17:37:32 +00:00
|
|
|
is_enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
at_enable_changed (GConfClient *client,
|
|
|
|
guint cnxn_id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
at_enable_update (client, user_data);
|
2007-05-05 11:14:54 +00:00
|
|
|
close_logout_update (user_data);
|
2003-06-25 17:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_dialog (GladeXML *dialog)
|
|
|
|
{
|
|
|
|
GConfClient *client;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GObject *peditor;
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
client = gconf_client_get_default ();
|
2007-05-05 11:14:54 +00:00
|
|
|
|
|
|
|
gconf_client_add_dir (client, ACCESSIBILITY_KEY_DIR,
|
2003-06-25 17:37:32 +00:00
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-07-18 22:22:38 +00:00
|
|
|
widget = WID ("at_enable_toggle");
|
2003-06-25 17:37:32 +00:00
|
|
|
g_signal_connect (widget, "toggled",
|
2007-05-05 11:14:54 +00:00
|
|
|
G_CALLBACK (at_enable_toggled),
|
2003-06-25 17:37:32 +00:00
|
|
|
dialog);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
peditor = gconf_peditor_new_boolean (NULL, ACCESSIBILITY_KEY,
|
|
|
|
widget,
|
|
|
|
NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2007-09-18 18:58:37 +00:00
|
|
|
initial_state = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
|
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
at_enable_update (client, dialog);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
gconf_client_notify_add (client, ACCESSIBILITY_KEY_DIR,
|
|
|
|
at_enable_changed,
|
|
|
|
dialog, NULL, NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2007-04-26 11:14:15 +00:00
|
|
|
g_signal_connect (G_OBJECT (WID("at_pref_button")),
|
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (cb_at_preferences), NULL);
|
2003-06-25 17:37:32 +00:00
|
|
|
|
2007-04-26 11:14:15 +00:00
|
|
|
g_signal_connect (G_OBJECT (WID("keyboard_button")),
|
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (cb_keyboard_preferences), NULL);
|
2003-06-25 17:37:32 +00:00
|
|
|
|
2007-04-26 11:14:15 +00:00
|
|
|
g_signal_connect (G_OBJECT (WID("login_button")),
|
|
|
|
"clicked",
|
|
|
|
G_CALLBACK (cb_login_preferences), NULL);
|
2003-06-25 17:37:32 +00:00
|
|
|
|
2003-07-18 22:22:38 +00:00
|
|
|
widget = WID ("at_properties_dialog");
|
2004-08-20 16:50:57 +00:00
|
|
|
capplet_set_icon (widget, "gnome-settings-accessibility-technologies");
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
g_signal_connect (G_OBJECT (widget),
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (cb_dialog_response), NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
gtk_widget_show (widget);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
g_object_unref (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2007-02-08 19:45:59 +00:00
|
|
|
GnomeProgram *program;
|
2003-06-25 17:37:32 +00:00
|
|
|
GladeXML *dialog;
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2007-02-08 19:45:59 +00:00
|
|
|
program = gnome_program_init ("gnome-at-properties", VERSION,
|
|
|
|
LIBGNOMEUI_MODULE, argc, argv,
|
|
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
|
|
|
NULL);
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
activate_settings_daemon ();
|
2007-05-05 11:14:54 +00:00
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
dialog = create_dialog ();
|
|
|
|
|
2007-02-08 19:45:59 +00:00
|
|
|
if (dialog) {
|
|
|
|
|
|
|
|
setup_dialog (dialog);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
g_object_unref (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (program);
|
|
|
|
|
2003-06-25 17:37:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|