diff options
author | Bill Haneman <billh@src.gnome.org> | 2003-06-25 17:37:32 +0000 |
---|---|---|
committer | Bill Haneman <billh@src.gnome.org> | 2003-06-25 17:37:32 +0000 |
commit | 4e66e604e9ff53ca0c749d3a275467f35893b01f (patch) | |
tree | 321c777dab0d2f99c226b990f84480f9fe62be81 /capplets | |
parent | 9a9dd67234b521812acf5da218e7e964f44e6281 (diff) | |
download | gnome-control-center-4e66e604e9ff53ca0c749d3a275467f35893b01f.tar.gz |
Include revised AT startup dialog as per discussions with JRB and Jody.
Diffstat (limited to 'capplets')
-rw-r--r-- | capplets/Makefile.am | 2 | ||||
-rw-r--r-- | capplets/accessibility/Makefile.am | 2 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/Makefile.am | 36 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/at-enable-capplet.png | bin | 0 -> 3688 bytes | |||
-rw-r--r-- | capplets/accessibility/at-properties/at-enable-dialog.glade | 383 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/at-properties.desktop.in | 13 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/at-startup-session.c | 139 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/at-startup-session.h | 16 | ||||
-rw-r--r-- | capplets/accessibility/at-properties/at-startup.png | bin | 0 -> 2879 bytes | |||
-rw-r--r-- | capplets/accessibility/at-properties/at-support.png | bin | 0 -> 1562 bytes | |||
-rw-r--r-- | capplets/accessibility/at-properties/main.c | 269 |
11 files changed, 858 insertions, 2 deletions
diff --git a/capplets/Makefile.am b/capplets/Makefile.am index b370bbafd..2495fc813 100644 --- a/capplets/Makefile.am +++ b/capplets/Makefile.am @@ -3,7 +3,7 @@ always_built_SUBDIRS = \ default-applications desktop-links font \ background keyboard mouse sound \ file-types theme-switcher ui-properties \ - keybindings network windows + keybindings network windows if HAVE_RANDR randr_SUBDIRS = display diff --git a/capplets/accessibility/Makefile.am b/capplets/accessibility/Makefile.am index d60926e4d..afaf9ad06 100644 --- a/capplets/accessibility/Makefile.am +++ b/capplets/accessibility/Makefile.am @@ -1 +1 @@ -SUBDIRS = keyboard +SUBDIRS = keyboard at-properties diff --git a/capplets/accessibility/at-properties/Makefile.am b/capplets/accessibility/at-properties/Makefile.am new file mode 100644 index 000000000..13dbbddbe --- /dev/null +++ b/capplets/accessibility/at-properties/Makefile.am @@ -0,0 +1,36 @@ +bin_PROGRAMS = gnome-at-properties + +gnome_at_properties_LDADD = $(AT_CAPPLET_LIBS) $(top_builddir)/capplets/common/libcommon.la +gnome_at_properties_SOURCES = \ + main.c \ + at-startup-session.h \ + at-startup-session.c +gnome_at_properties_LDFLAGS = -export-dynamic + +@INTLTOOL_DESKTOP_RULE@ + +iconsdir = $(GNOMECC_ICONS_DIR) +icons_DATA = at-enable-capplet.png + +desktopdir = $(GNOMECC_DESKTOP_DIR) +Desktop_in_files = at-properties.desktop.in +desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) + +pixmapdir = $(GNOMECC_PIXMAPS_DIR) +pixmap_DATA = \ + at-enable-capplet.png \ + at-startup.png \ + at-support.png + +desktop_iconsdir = $(datadir)/pixmaps +desktop_icons_DATA = at-enable-capplet.png + +gladedir = $(GNOMECC_GLADE_DIR) +glade_DATA = at-enable-dialog.glade + +INCLUDES = $(AT_CAPPLET_CFLAGS) \ + $(GNOMECC_CAPPLETS_CFLAGS) \ + -DGLADEDIR=\""$(gladedir)"\" \ + -DPIXMAPDIR=\""$(pixmapdir)"\" +CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) +EXTRA_DIST = $(icons_DATA) $(glade_DATA) $(pixmap_DATA) $(Desktop_in_files) diff --git a/capplets/accessibility/at-properties/at-enable-capplet.png b/capplets/accessibility/at-properties/at-enable-capplet.png Binary files differnew file mode 100644 index 000000000..75084f8dc --- /dev/null +++ b/capplets/accessibility/at-properties/at-enable-capplet.png diff --git a/capplets/accessibility/at-properties/at-enable-dialog.glade b/capplets/accessibility/at-properties/at-enable-dialog.glade new file mode 100644 index 000000000..4a03367c5 --- /dev/null +++ b/capplets/accessibility/at-properties/at-enable-dialog.glade @@ -0,0 +1,383 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkDialog" id="dlgATPrefs"> + <property name="title" translatable="yes">Assitive Technology Preferences</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="btnHelp"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-11</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="btnCloseLogout"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">0</property> + + <child> + <widget class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Close and _Log Out</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkButton" id="btnClose"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="response_id">-7</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="fraSupport"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkTable" id="table1"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + + <child> + <widget class="GtkLabel" id="lblNote"> + <property name="visible">True</property> + <property name="label" translatable="yes"><small><i><b>Note:</b> Changes to this setting will not take effect until you next log in.</i></small></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="chkEnableAT"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Enable assistive technologies</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0</property> + <property name="xpad">6</property> + <property name="ypad">6</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">2</property> + <property name="x_padding">6</property> + <property name="x_options"></property> + <property name="y_options">fill</property> + </packing> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Support</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="fraApps"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkTable" id="table2"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="n_rows">4</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Start these assistive technologies every time you log in:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">6</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="chkScreenreader"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Screenreader</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="chkMagnifier"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Magnifier</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="chkKeyboard"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_On-screen keyboard</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0</property> + <property name="xpad">6</property> + <property name="ypad">6</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">4</property> + <property name="x_padding">6</property> + <property name="x_options"></property> + <property name="y_options">fill</property> + </packing> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Applications</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/capplets/accessibility/at-properties/at-properties.desktop.in b/capplets/accessibility/at-properties/at-properties.desktop.in new file mode 100644 index 000000000..92f822d39 --- /dev/null +++ b/capplets/accessibility/at-properties/at-properties.desktop.in @@ -0,0 +1,13 @@ +[Desktop Entry] +Encoding=UTF-8 +_Name=Assistive Technology Support +_Comment=Enable support for GNOME assistive technologies at login +Exec=gnome-at-properties +Icon=at-enable-capplet.png +Terminal=false +Type=Application +StartupNotify=true +Categories=GNOME;Settings;Accessibility; +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=control-center +X-GNOME-Bugzilla-Component=Assistive Technology Support diff --git a/capplets/accessibility/at-properties/at-startup-session.c b/capplets/accessibility/at-properties/at-startup-session.c new file mode 100644 index 000000000..eb297f498 --- /dev/null +++ b/capplets/accessibility/at-properties/at-startup-session.c @@ -0,0 +1,139 @@ +#include <config.h> +#include <string.h> +#include <glib-object.h> +#include <gconf/gconf-client.h> + +#include "at-startup-session.h" + +#define AT_STARTUP_KEY "/desktop/gnome/accessibility/startup/exec_ats" + +#define GNOPERNICUS_MAGNIFIER_KEY "/apps/gnopernicus/srcore/mag_active" +#define GNOPERNICUS_SPEECH_KEY "/apps/gnopernicus/srcore/sp_active" +#define GNOPERNICUS_BRAILLE_KEY "/apps/gnopernicus/srcore/br_active" + +static AtStartupState at_startup_state_recent; + +static GSList * +at_startup_get_list (GConfClient *client) +{ + GError *error = NULL; + GSList *at_list = gconf_client_get_list (client, AT_STARTUP_KEY, GCONF_VALUE_STRING, &error); + if (error) { + g_warning ("Error getting value of " AT_STARTUP_KEY ": %s", error->message); + g_error_free (error); + return NULL; + } + return at_list; +} + +gint +at_startup_string_compare (gconstpointer s1, gconstpointer s2) +{ + if (s1 && s2) { + return strcmp (s1, s2); + } + else + return (s2-s1); +} + +static GSList * +at_startup_list_add (GSList *list, const gchar *exec_name) +{ + GSList *l = g_slist_find_custom (list, exec_name, at_startup_string_compare); + if (!l) { + list = g_slist_append (list, g_strdup (exec_name)); + } + return list; +} + +static GSList * +at_startup_list_remove (GSList *list, const gchar *exec_name) +{ + GSList *l = g_slist_find_custom (list, exec_name, at_startup_string_compare); + if (l) { + g_free (l->data); + list = g_slist_delete_link (list, l); + } + return list; +} + +void +at_startup_state_init (AtStartupState *startup_state) +{ + gboolean mag_active, speech_active, braille_active; + GSList *l; + GConfClient *client = gconf_client_get_default (); + GSList *at_list = at_startup_get_list (client); + for (l = at_list; l; l = l->next) { + gchar *exec_name = (char *) l->data; + if (exec_name && !strcmp (exec_name, "gnopernicus")) { + braille_active = gconf_client_get_bool (client, + GNOPERNICUS_BRAILLE_KEY, + NULL); + mag_active = gconf_client_get_bool (client, + GNOPERNICUS_MAGNIFIER_KEY, + NULL); + speech_active = gconf_client_get_bool (client, + GNOPERNICUS_SPEECH_KEY, + NULL); + + startup_state->enabled.screenreader = (braille_active || speech_active); + startup_state->enabled.magnifier = mag_active; + } + else if (exec_name && !strcmp(exec_name, "gok")) { + startup_state->enabled.osk = TRUE; + } + g_free (exec_name); + } + g_slist_free (at_list); + g_object_unref (client); + at_startup_state_recent.flags = startup_state->flags; +} + +void +at_startup_state_update (AtStartupState *startup_state) +{ + GError *error = NULL; + GConfClient *client = gconf_client_get_default (); + GSList *at_list = at_startup_get_list (client); + + if (startup_state->enabled.screenreader != at_startup_state_recent.enabled.screenreader) { + gconf_client_set_bool (client, GNOPERNICUS_SPEECH_KEY, + startup_state->enabled.screenreader, NULL); + gconf_client_set_bool (client, GNOPERNICUS_BRAILLE_KEY, + startup_state->enabled.screenreader, NULL); + } + + if (startup_state->enabled.magnifier != at_startup_state_recent.enabled.magnifier) { + gconf_client_set_bool (client, GNOPERNICUS_MAGNIFIER_KEY, + startup_state->enabled.magnifier, NULL); + } + + if (startup_state->enabled.screenreader || startup_state->enabled.magnifier) { + if (!(at_startup_state_recent.enabled.screenreader || + at_startup_state_recent.enabled.magnifier)) + /* new state includes SR or magnifier, initial one did not */ + at_list = at_startup_list_add (at_list, "gnopernicus"); + } + else { + if (at_startup_state_recent.enabled.screenreader || + at_startup_state_recent.enabled.magnifier) + at_list = at_startup_list_remove (at_list, "gnopernicus"); + } + if (startup_state->enabled.osk) { + if (!at_startup_state_recent.enabled.osk) + at_list = at_startup_list_add (at_list, "gok"); + } + else { + if (at_startup_state_recent.enabled.osk) + at_list = at_startup_list_remove (at_list, "gok"); + } + if (at_startup_state_recent.flags != startup_state->flags) { + at_startup_state_recent.flags = startup_state->flags; + gconf_client_set_list (client, AT_STARTUP_KEY, GCONF_VALUE_STRING, at_list, &error); + } + g_object_unref (client); + g_slist_free (at_list); +} + + diff --git a/capplets/accessibility/at-properties/at-startup-session.h b/capplets/accessibility/at-properties/at-startup-session.h new file mode 100644 index 000000000..3ef33abd1 --- /dev/null +++ b/capplets/accessibility/at-properties/at-startup-session.h @@ -0,0 +1,16 @@ +#include <config.h> +#include <gtk/gtk.h> + +typedef union { + guint flags; + struct { + guint support:1; + guint osk:1; + guint magnifier:1; + guint screenreader:1; + } enabled; +} AtStartupState; + +void at_startup_state_init (AtStartupState *startup_state); + +void at_startup_state_update (AtStartupState *startup_state); diff --git a/capplets/accessibility/at-properties/at-startup.png b/capplets/accessibility/at-properties/at-startup.png Binary files differnew file mode 100644 index 000000000..0b192b4c8 --- /dev/null +++ b/capplets/accessibility/at-properties/at-startup.png diff --git a/capplets/accessibility/at-properties/at-support.png b/capplets/accessibility/at-properties/at-support.png Binary files differnew file mode 100644 index 000000000..c36c2f3fb --- /dev/null +++ b/capplets/accessibility/at-properties/at-support.png diff --git a/capplets/accessibility/at-properties/main.c b/capplets/accessibility/at-properties/main.c new file mode 100644 index 000000000..f6d41d019 --- /dev/null +++ b/capplets/accessibility/at-properties/main.c @@ -0,0 +1,269 @@ +#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" +#include "at-startup-session.h" + +#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility" +#define ACCESSIBILITY_KEY_DIR "/desktop/gnome/interface" +#define AT_STARTUP_DIR "/desktop/gnome/accessibility/startup" +#define AT_STARTUP_KEY "/desktop/gnome/accessibility/startup/exec_ats" +#define SR_PREFS_DIR "/apps/gnopernicus/srcore" + +static AtStartupState at_startup_state, at_startup_state_initial; + +static void +init_startup_state (GladeXML *dialog) +{ + GConfClient *client = gconf_client_get_default (); + + at_startup_state.flags = (gconf_client_get_bool (client, + ACCESSIBILITY_KEY, + NULL)) ? 1 : 0; + + at_startup_state_init (&at_startup_state); + + at_startup_state_initial.flags = at_startup_state.flags; + g_object_unref (client); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkKeyboard")), + at_startup_state.enabled.osk); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkScreenreader")), + at_startup_state.enabled.screenreader); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkMagnifier")), + at_startup_state.enabled.magnifier); +} + +static GladeXML * +create_dialog (void) +{ + GladeXML *dialog; + + dialog = glade_xml_new (GLADEDIR "/at-enable-dialog.glade", "dlgATPrefs", NULL); + + gtk_image_set_from_stock (GTK_IMAGE (WID ("image1")), + GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON); + + gtk_image_set_from_file (GTK_IMAGE (WID ("image2")), + PIXMAPDIR "/at-support.png"); + + gtk_image_set_from_file (GTK_IMAGE (WID ("image3")), + PIXMAPDIR "/at-startup.png"); + + return dialog; +} + +static void +cb_dialog_response (GtkDialog *dialog, gint response_id) +{ + GnomeClient *client; + if (response_id == GTK_RESPONSE_HELP) + capplet_help (GTK_WINDOW (dialog), + "foo.xml", + "bar"); + else if (response_id == GTK_RESPONSE_CLOSE) + gtk_main_quit (); + else { + g_message ("CLOSE AND LOGOUT!"); + if (!(client = gnome_master_client ())) { + + gtk_main_quit (); + } + gnome_client_request_save (client, GNOME_SAVE_GLOBAL, TRUE, + GNOME_INTERACT_ANY, FALSE, TRUE); + } +} + +static void +close_logout_update (GladeXML *dialog) +{ + GConfClient *client = gconf_client_get_default (); + gboolean has_changed = + (at_startup_state.flags != at_startup_state_initial.flags) && + gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL); + + gtk_widget_set_sensitive (WID ("btnCloseLogout"), has_changed); + g_object_unref (client); +} + +static void +at_startup_toggled (GtkToggleButton *toggle_button, + GladeXML *dialog) +{ + if (toggle_button == GTK_TOGGLE_BUTTON (WID ("chkKeyboard"))) { + at_startup_state.enabled.osk = gtk_toggle_button_get_active (toggle_button); + } + else if (toggle_button == GTK_TOGGLE_BUTTON (WID ("chkMagnifier"))) { + at_startup_state.enabled.magnifier = gtk_toggle_button_get_active (toggle_button); + } + else if (toggle_button == GTK_TOGGLE_BUTTON (WID ("chkScreenreader"))) { + at_startup_state.enabled.screenreader = gtk_toggle_button_get_active (toggle_button); + } + + at_startup_state_update (&at_startup_state); + close_logout_update (dialog); +} + +static void +at_enable_toggled (GtkToggleButton *toggle_button, + GladeXML *dialog) +{ + GConfClient *client = gconf_client_get_default (); + gboolean is_enabled = gtk_toggle_button_get_active (toggle_button); + + gconf_client_set_bool (client, ACCESSIBILITY_KEY, + is_enabled, + NULL); + at_startup_state.enabled.support = is_enabled; + g_object_unref (client); +} + +static void +at_startup_update_ui (GConfClient *client, + GladeXML *dialog) +{ + at_startup_state_init (&at_startup_state); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkKeyboard")), + at_startup_state.enabled.osk); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkScreenreader")), + at_startup_state.enabled.screenreader); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkMagnifier")), + at_startup_state.enabled.magnifier); +} + +static void +at_enable_update (GConfClient *client, + GladeXML *dialog) +{ + gboolean is_enabled = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("chkEnableAT")), + is_enabled); + + gtk_widget_set_sensitive (WID ("fraApps"), is_enabled); + gtk_widget_set_sensitive (WID ("chkKeyboard"), is_enabled); + gtk_widget_set_sensitive (WID ("chkMagnifier"), is_enabled); + gtk_widget_set_sensitive (WID ("chkScreenreader"), is_enabled); +} + +static void +at_startup_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data) +{ + at_startup_state_init (&at_startup_state); + at_startup_update_ui (client, user_data); + close_logout_update (user_data); +} + +static void +at_enable_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data) +{ + at_enable_update (client, user_data); + close_logout_update (user_data); +} + +static void +setup_dialog (GladeXML *dialog) +{ + GConfClient *client; + GtkWidget *widget; + GObject *peditor; + + client = gconf_client_get_default (); + + gconf_client_add_dir (client, ACCESSIBILITY_KEY_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + widget = WID ("chkEnableAT"); + g_signal_connect (widget, "toggled", + G_CALLBACK (at_enable_toggled), + dialog); + + peditor = gconf_peditor_new_boolean (NULL, ACCESSIBILITY_KEY, + widget, + NULL); + + at_enable_update (client, dialog); + + gconf_client_notify_add (client, ACCESSIBILITY_KEY_DIR, + at_enable_changed, + dialog, NULL, NULL); + + gconf_client_add_dir (client, AT_STARTUP_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + gconf_client_add_dir (client, SR_PREFS_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + gconf_client_notify_add (client, AT_STARTUP_DIR, + at_startup_changed, + dialog, NULL, NULL); + + gconf_client_notify_add (client, SR_PREFS_DIR, + at_startup_changed, + dialog, NULL, NULL); + + widget = WID ("chkKeyboard"); + + g_signal_connect (widget, "toggled", + G_CALLBACK (at_startup_toggled), + dialog); + + widget = WID ("chkMagnifier"); + g_signal_connect (widget, "toggled", + G_CALLBACK (at_startup_toggled), + dialog); + + widget = WID ("chkScreenreader"); + g_signal_connect (widget, "toggled", + G_CALLBACK (at_startup_toggled), + dialog); + + widget = WID ("dlgATPrefs"); + capplet_set_icon (widget, "at-enable-capplet.png"); + + g_signal_connect (G_OBJECT (widget), + "response", + G_CALLBACK (cb_dialog_response), NULL); + + gtk_widget_show (widget); + + g_object_unref (client); +} + +int +main (int argc, char *argv[]) +{ + GladeXML *dialog; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + gnome_program_init ("gnome-at-properties", VERSION, + LIBGNOMEUI_MODULE, argc, argv, + GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR, + NULL); + + activate_settings_daemon (); + + dialog = create_dialog (); + + init_startup_state (dialog); + + setup_dialog (dialog); + + gtk_main (); + + return 0; +} |