universal-access: use switches instead of radio groups

This commit is contained in:
William Jon McCann 2011-02-17 19:21:00 -05:00
parent ab5adcb98e
commit 7ed56b00fd
4 changed files with 109 additions and 289 deletions

View file

@ -412,6 +412,24 @@ peditor_boolean_value_changed (GConfClient *client,
}
}
static void
peditor_switch_value_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
GConfPropertyEditor *peditor)
{
GConfValue *value, *value_wid;
if (peditor->p->changeset != NULL)
gconf_change_set_remove (peditor->p->changeset, peditor->p->key);
if (entry && (value = gconf_entry_get_value (entry))) {
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
gtk_switch_set_active (GTK_SWITCH (peditor->p->ui_control), gconf_value_get_bool (value_wid));
gconf_value_free (value_wid);
}
}
static void
peditor_boolean_widget_changed (GConfPropertyEditor *peditor,
GtkToggleButton *tb)
@ -428,6 +446,22 @@ peditor_boolean_widget_changed (GConfPropertyEditor *peditor,
gconf_value_free (value);
}
static void
peditor_switch_widget_changed (GConfPropertyEditor *peditor,
GtkSwitch *sw)
{
GConfValue *value, *value_wid;
if (!peditor->p->inited) return;
value_wid = gconf_value_new (GCONF_VALUE_BOOL);
gconf_value_set_bool (value_wid, gtk_switch_get_active (sw));
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
peditor_set_gconf_value (peditor, peditor->p->key, value);
g_signal_emit (peditor, peditor_signals[VALUE_CHANGED], 0, peditor->p->key, value);
gconf_value_free (value_wid);
gconf_value_free (value);
}
GObject *
gconf_peditor_new_boolean (GConfChangeSet *changeset,
const gchar *key,
@ -461,6 +495,39 @@ gconf_peditor_new_boolean (GConfChangeSet *changeset,
return peditor;
}
GObject *
gconf_peditor_new_switch (GConfChangeSet *changeset,
const gchar *key,
GtkWidget *sw,
const gchar *first_property_name,
...)
{
GObject *peditor;
va_list var_args;
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (sw != NULL, NULL);
g_return_val_if_fail (GTK_IS_SWITCH (sw), NULL);
va_start (var_args, first_property_name);
peditor = gconf_peditor_new
(key,
(GConfClientNotifyFunc) peditor_switch_value_changed,
changeset,
G_OBJECT (sw),
first_property_name,
var_args,
NULL);
va_end (var_args);
g_signal_connect_swapped (sw, "notify::active",
(GCallback) peditor_switch_widget_changed, peditor);
return peditor;
}
static void
peditor_integer_value_changed (GConfClient *client,
guint cnxn_id,

View file

@ -67,6 +67,12 @@ GObject *gconf_peditor_new_boolean (GConfChangeSet *changeset,
const gchar *first_property_name,
...);
GObject *gconf_peditor_new_switch (GConfChangeSet *changeset,
const gchar *key,
GtkWidget *sw,
const gchar *first_property_name,
...);
GObject *gconf_peditor_new_enum_toggle (GConfChangeSet *changeset,
const gchar *key,
GtkWidget *checkbox,

View file

@ -203,16 +203,17 @@ static gchar *visual_alerts_section[] = {
};
static void
cc_ua_panel_section_toggled (GtkToggleButton *button,
GtkBuilder *builder)
cc_ua_panel_section_switched (GObject *object,
GParamSpec *pspec,
GtkBuilder *builder)
{
GtkWidget *w;
gboolean enabled;
gchar **widgets, **s;
widgets = g_object_get_data (G_OBJECT (button), "section-widgets");
widgets = g_object_get_data (object, "section-widgets");
enabled = gtk_toggle_button_get_active (button);
enabled = gtk_switch_get_active (GTK_SWITCH (object));
for (s = widgets; *s; s++)
{
@ -232,8 +233,8 @@ settings_on_off_editor_new (CcUaPanelPrivate *priv,
if (section)
{
g_object_set_data (G_OBJECT (widget), "section-widgets", section);
g_signal_connect (widget, "toggled",
G_CALLBACK (cc_ua_panel_section_toggled),
g_signal_connect (widget, "notify::active",
G_CALLBACK (cc_ua_panel_section_switched),
priv->builder);
}
@ -241,35 +242,17 @@ settings_on_off_editor_new (CcUaPanelPrivate *priv,
g_settings_bind (settings, key, widget, "active", G_SETTINGS_BIND_DEFAULT);
}
static GConfValue*
cc_ua_panel_toggle_radios (GConfPropertyEditor *peditor,
static GConfValue *
cc_ua_panel_toggle_switch (GConfPropertyEditor *peditor,
const GConfValue *value)
{
GtkWidget *radio;
GtkWidget *sw;
gboolean enabled;
enabled = gconf_value_get_bool (value);
radio = (GtkWidget*) gconf_property_editor_get_ui_control (peditor);
sw = (GtkWidget*) gconf_property_editor_get_ui_control (peditor);
if (!enabled)
{
GSList *list, *l;
list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));
if (list)
{
/* activate the "off" button */
for (l = list; l; l = l->next)
{
if (l->data == radio)
continue;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data),
TRUE);
}
}
}
gtk_switch_set_active (GTK_SWITCH (sw), enabled);
return gconf_value_copy (value);
}
@ -286,14 +269,14 @@ gconf_on_off_peditor_new (CcUaPanelPrivate *priv,
if (section)
{
g_object_set_data (G_OBJECT (widget), "section-widgets", section);
g_signal_connect (widget, "toggled",
G_CALLBACK (cc_ua_panel_section_toggled),
g_signal_connect (widget, "notify::active",
G_CALLBACK (cc_ua_panel_section_switched),
priv->builder);
}
/* set up the boolean editor */
peditor = gconf_peditor_new_boolean (NULL, key, widget, NULL);
g_object_set (peditor, "conv-to-widget-cb", cc_ua_panel_toggle_radios, NULL);
peditor = gconf_peditor_new_switch (NULL, key, widget, NULL);
g_object_set (peditor, "conv-to-widget-cb", cc_ua_panel_toggle_switch, NULL);
/* emit the notify on the key, so that the conv-to-widget-cb callback is run */
gconf_client_notify (priv->client, key);
@ -551,7 +534,7 @@ cc_ua_panel_init_seeing (CcUaPanel *self)
settings_on_off_editor_new (priv, priv->application_settings,
"screen-magnifier-enabled",
WID (priv->builder, "seeing_zoom_on_radiobutton"),
WID (priv->builder, "seeing_zoom_switch"),
NULL);
}
@ -610,7 +593,7 @@ cc_ua_panel_init_hearing (CcUaPanel *self)
gconf_client_add_dir (priv->client, "/apps/metacity/general",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
w = WID (priv->builder, "hearing_visual_alerts_on_radiobutton");
w = WID (priv->builder, "hearing_visual_alerts_switch");
gconf_on_off_peditor_new (priv, "/apps/metacity/general/visual_bell",
w, visual_alerts_section);
@ -662,7 +645,7 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
g_settings_bind (priv->kb_settings, "enable", w, "active", G_SETTINGS_BIND_DEFAULT);
/* sticky keys */
w = WID (priv->builder, "typing_sticky_keys_on_radiobutton");
w = WID (priv->builder, "typing_sticky_keys_switch");
settings_on_off_editor_new (priv, priv->kb_settings, "stickykeys-enable", w, sticky_keys_section);
w = WID (priv->builder, "typing_sticky_keys_disable_two_keys_checkbutton");
@ -672,7 +655,7 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
g_settings_bind (priv->kb_settings, "stickykeys-modifier-beep", w, "active", G_SETTINGS_BIND_DEFAULT);
/* slow keys */
w = WID (priv->builder, "typing_slow_keys_on_radiobutton");
w = WID (priv->builder, "typing_slow_keys_switch");
settings_on_off_editor_new (priv, priv->kb_settings, "slowkeys-enable", w, slow_keys_section);
w = WID (priv->builder, "typing_slowkeys_delay_scale");
@ -690,7 +673,7 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
g_settings_bind (priv->kb_settings, "slowkeys-beep-reject", w, "active", G_SETTINGS_BIND_DEFAULT);
/* bounce keys */
w = WID (priv->builder, "typing_bounce_keys_on_radiobutton");
w = WID (priv->builder, "typing_bounce_keys_switch");
settings_on_off_editor_new (priv, priv->kb_settings, "bouncekeys-enable", w, bounce_keys_section);
w = WID (priv->builder, "typing_bouncekeys_delay_scale");
@ -724,11 +707,11 @@ cc_ua_panel_init_mouse (CcUaPanel *self)
GtkWidget *w;
/* mouse keys */
w = WID (priv->builder, "pointing_mouse_keys_on_radiobutton");
w = WID (priv->builder, "pointing_mouse_keys_switch");
settings_on_off_editor_new (priv, priv->kb_settings, "mousekeys-enable", w, NULL);
/* simulated secondary click */
w = WID (priv->builder, "pointing_second_click_on_radiobutton");
w = WID (priv->builder, "pointing_second_click_switch");
settings_on_off_editor_new (priv, priv->mouse_settings, "secondary-click-enabled", w, secondary_click_section);
w = WID (priv->builder, "pointing_secondary_click_delay_scale");
@ -737,7 +720,7 @@ cc_ua_panel_init_mouse (CcUaPanel *self)
G_SETTINGS_BIND_DEFAULT);
/* dwell click */
w = WID (priv->builder, "pointing_hover_click_on_radiobutton");
w = WID (priv->builder, "pointing_hover_click_switch");
settings_on_off_editor_new (priv, priv->mouse_settings, "dwell-click-enabled", w, dwell_click_section);
w = WID (priv->builder, "pointing_dwell_delay_scale");

View file

@ -441,49 +441,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="seeing_zoom_on_radiobutton">
<object class="GtkSwitch" id="seeing_zoom_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">seeing_zoom_off_radiobutton</property>
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">On</property>
<attributes>
<attribute name="scale" value="1.250000"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="seeing_zoom_off_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<child>
<object class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="label" translatable="yes">Off</property>
<attributes>
<attribute name="scale" value="1.250000"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -733,49 +700,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="seeing_reader_on_radiobutton">
<object class="GtkSwitch" id="seeing_reader_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">seeing_reader_off_radiobutton</property>
<child>
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="label" translatable="yes">On</property>
<attributes>
<attribute name="scale" value="1.250000"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="seeing_reader_off_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<child>
<object class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="label" translatable="yes">Off</property>
<attributes>
<attribute name="scale" value="1.250000"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -941,33 +875,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="hearing_visual_alerts_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="hearing_visual_alerts_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">hearing_visual_alerts_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="hearing_visual_alerts_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1138,33 +1055,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="hearing_captions_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="hearing_captions_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">hearing_captions_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="hearing_captions_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1288,33 +1188,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="typing_assistant_on_radiobutton1">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="typing_assistant_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">typing_assistant_off_radiobutton1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="typing_assistant_off_radiobutton1">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1403,33 +1286,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="typing_sticky_keys_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="typing_sticky_keys_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">typing_sticky_keys_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="typing_sticky_keys_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1555,33 +1421,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="typing_slow_keys_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="typing_slow_keys_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">typing_slow_keys_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="typing_slow_keys_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -1860,33 +1709,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="typing_bounce_keys_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="typing_bounce_keys_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">typing_bounce_keys_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="typing_bounce_keys_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -2175,33 +2007,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="pointing_mouse_keys_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="pointing_mouse_keys_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">pointing_mouse_keys_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="pointing_mouse_keys_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -2287,33 +2102,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="pointing_video_mouse_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="pointing_video_mouse_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">pointing_video_mouse_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="pointing_video_mouse_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -2401,33 +2199,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="pointing_second_click_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="pointing_second_click_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">pointing_second_click_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="pointing_second_click_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@ -2621,33 +2402,16 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="pointing_hover_click_on_radiobutton">
<property name="label" translatable="yes">On</property>
<object class="GtkSwitch" id="pointing_hover_click_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">pointing_hover_click_off_radiobutton</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="pointing_hover_click_off_radiobutton">
<property name="label" translatable="yes">Off</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>