universal-access: Add Cursor Size selection dialogue
The dialogue offers the 5 separate cursor sizes that adwaita's cursor theme supports, aligned in a row. The cursor sizes are described in a way that doesn't judge their respective sizes, but simply describes them. https://bugzilla.gnome.org/show_bug.cgi?id=608231
This commit is contained in:
parent
75241454f0
commit
922c6588d3
8 changed files with 234 additions and 0 deletions
|
@ -50,6 +50,7 @@
|
|||
#define KEY_ICON_THEME "icon-theme"
|
||||
#define KEY_CURSOR_BLINKING "cursor-blink"
|
||||
#define KEY_CURSOR_BLINKING_TIME "cursor-blink-time"
|
||||
#define KEY_MOUSE_CURSOR_SIZE "cursor-size"
|
||||
|
||||
/* application settings */
|
||||
#define APPLICATION_SETTINGS "org.gnome.desktop.a11y.applications"
|
||||
|
@ -178,6 +179,67 @@ zoom_options_launch (CcUaPanel *self)
|
|||
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));
|
||||
}
|
||||
|
||||
/* cursor size dialog */
|
||||
static void
|
||||
cursor_size_toggled (GtkWidget *button,
|
||||
CcUaPanel *self)
|
||||
{
|
||||
CcUaPanelPrivate *priv = self->priv;
|
||||
guint cursor_size;
|
||||
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
return;
|
||||
|
||||
cursor_size = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "cursor-size"));
|
||||
g_settings_set_int (priv->interface_settings, KEY_MOUSE_CURSOR_SIZE, cursor_size);
|
||||
g_debug ("Setting cursor size to %d", cursor_size);
|
||||
}
|
||||
|
||||
static void
|
||||
cursor_size_setup (CcUaPanel *self)
|
||||
{
|
||||
guint cursor_sizes[] = { 24, 32, 48, 64, 96 };
|
||||
guint current_cursor_size, i;
|
||||
CcUaPanelPrivate *priv = self->priv;
|
||||
GtkWidget *grid;
|
||||
GtkSizeGroup *size_group;
|
||||
GtkWidget *last_radio_button = NULL;
|
||||
|
||||
grid = WID ("cursor_size_grid");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (grid), "linked");
|
||||
|
||||
current_cursor_size = g_settings_get_int (priv->interface_settings,
|
||||
KEY_MOUSE_CURSOR_SIZE);
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(cursor_sizes); i++)
|
||||
{
|
||||
GtkWidget *image, *button;
|
||||
char *cursor_image_name;
|
||||
|
||||
cursor_image_name = g_strdup_printf ("/org/gnome/control-center/universal-access/left_ptr_%dpx.png", cursor_sizes[i]);
|
||||
image = gtk_image_new_from_resource (cursor_image_name);
|
||||
g_free (cursor_image_name);
|
||||
|
||||
button = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (last_radio_button));
|
||||
last_radio_button = button;
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
g_object_set_data (G_OBJECT (button), "cursor-size", GUINT_TO_POINTER (cursor_sizes[i]));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, i, 0, 1, 1);
|
||||
gtk_size_group_add_widget (size_group, button);
|
||||
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (cursor_size_toggled), self);
|
||||
|
||||
if (current_cursor_size == cursor_sizes[i])
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
}
|
||||
|
||||
gtk_widget_show_all (grid);
|
||||
}
|
||||
|
||||
/* seeing section */
|
||||
|
||||
static gboolean
|
||||
|
@ -271,6 +333,45 @@ on_off_label_mapping_get (GValue *value,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
cursor_size_label_mapping_get (GValue *value,
|
||||
GVariant *variant,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *label;
|
||||
int cursor_size;
|
||||
|
||||
cursor_size = g_variant_get_int32 (variant);
|
||||
|
||||
switch (cursor_size)
|
||||
{
|
||||
case 24:
|
||||
/* translators: the labels will read:
|
||||
* Cursor Size: Default */
|
||||
label = g_strdup (C_("cursor size", "Default"));
|
||||
break;
|
||||
case 32:
|
||||
label = g_strdup (C_("cursor size", "Medium"));
|
||||
break;
|
||||
case 48:
|
||||
label = g_strdup (C_("cursor size", "Large"));
|
||||
break;
|
||||
case 64:
|
||||
label = g_strdup (C_("cursor size", "Larger"));
|
||||
break;
|
||||
case 96:
|
||||
label = g_strdup (C_("cursor size", "Largest"));
|
||||
break;
|
||||
default:
|
||||
label = g_strdup_printf (_("%d pixels"), g_variant_get_int32 (variant));
|
||||
break;
|
||||
}
|
||||
|
||||
g_value_take_string (value, label);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
add_separators (GtkListBox *list)
|
||||
{
|
||||
|
@ -434,6 +535,23 @@ cc_ua_panel_init_seeing (CcUaPanel *self)
|
|||
priv->interface_settings,
|
||||
NULL);
|
||||
|
||||
/* cursor size */
|
||||
|
||||
cursor_size_setup (self);
|
||||
|
||||
g_settings_bind_with_mapping (priv->interface_settings, KEY_MOUSE_CURSOR_SIZE,
|
||||
WID ("value_cursor_size"),
|
||||
"label", G_SETTINGS_BIND_GET,
|
||||
cursor_size_label_mapping_get,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
dialog = WID ("cursor_size_dialog");
|
||||
priv->toplevels = g_slist_prepend (priv->toplevels, dialog);
|
||||
|
||||
g_object_set_data (G_OBJECT (WID ("row_cursor_size")), "dialog", dialog);
|
||||
g_signal_connect (dialog, "delete-event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
|
||||
/* zoom */
|
||||
|
||||
g_settings_bind_with_mapping (priv->application_settings, "screen-magnifier-enabled",
|
||||
|
|
BIN
panels/universal-access/left_ptr_24px.png
Normal file
BIN
panels/universal-access/left_ptr_24px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 762 B |
BIN
panels/universal-access/left_ptr_32px.png
Normal file
BIN
panels/universal-access/left_ptr_32px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
panels/universal-access/left_ptr_48px.png
Normal file
BIN
panels/universal-access/left_ptr_48px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
panels/universal-access/left_ptr_64px.png
Normal file
BIN
panels/universal-access/left_ptr_64px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
panels/universal-access/left_ptr_96px.png
Normal file
BIN
panels/universal-access/left_ptr_96px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -223,6 +223,53 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="row_cursor_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_cursor_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_cursor_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_start">20</property>
|
||||
<property name="margin_end">20</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="label" translatable="yes">C_ursor Size</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="value_cursor_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_start">20</property>
|
||||
<property name="margin_end">20</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="label">24 pixels</property>
|
||||
<property name="xalign">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="row_zoom">
|
||||
<property name="visible">True</property>
|
||||
|
@ -952,6 +999,7 @@
|
|||
<widgets>
|
||||
<widget name="row_highcontrast"/>
|
||||
<widget name="row_large_text"/>
|
||||
<widget name="row_cursor_size"/>
|
||||
<widget name="row_zoom"/>
|
||||
<widget name="row_screen_reader"/>
|
||||
<widget name="row_sound_keys"/>
|
||||
|
@ -962,6 +1010,69 @@
|
|||
<widget name="row_click_assist"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkDialog" id="cursor_size_dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Cursor Size</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox7">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="cursor_size_blurb">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_start">12</property>
|
||||
<property name="margin_end">6</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="label" translatable="yes">Cursor size can be combined with zoom to make it easier to see the cursor.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="max_width_chars">45</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="cursor_size_grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="headerbar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkDialog" id="screen_reader_dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
|
|
|
@ -3,5 +3,10 @@
|
|||
<gresource prefix="/org/gnome/control-center/universal-access">
|
||||
<file preprocess="xml-stripblanks">uap.ui</file>
|
||||
<file preprocess="xml-stripblanks">zoom-options.ui</file>
|
||||
<file>left_ptr_24px.png</file>
|
||||
<file>left_ptr_32px.png</file>
|
||||
<file>left_ptr_48px.png</file>
|
||||
<file>left_ptr_64px.png</file>
|
||||
<file>left_ptr_96px.png</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
Loading…
Add table
Reference in a new issue