[gnome-control-center/signal-connect-object: 3/16] universal-access: Connect signals with g_signal_connect_object in swapped form
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/signal-connect-object: 3/16] universal-access: Connect signals with g_signal_connect_object in swapped form
- Date: Fri, 22 Nov 2019 02:55:06 +0000 (UTC)
commit d81c7153e12c34eb3a53b55790d4f96310b1b4a2
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Nov 22 10:35:12 2019 +1300
universal-access: Connect signals with g_signal_connect_object in swapped form
panels/universal-access/cc-ua-panel.c | 95 ++++++++++++++++------------------
panels/universal-access/zoom-options.c | 92 ++++++++++++++++----------------
2 files changed, 90 insertions(+), 97 deletions(-)
---
diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c
index aebdd572b..29df11c48 100644
--- a/panels/universal-access/cc-ua-panel.c
+++ b/panels/universal-access/cc-ua-panel.c
@@ -333,8 +333,8 @@ zoom_options_launch (CcUaPanel *self)
/* cursor size dialog */
static void
-cursor_size_toggled (GtkWidget *button,
- CcUaPanel *self)
+cursor_size_toggled (CcUaPanel *self,
+ GtkWidget *button)
{
guint cursor_size;
@@ -379,8 +379,8 @@ cursor_size_setup (CcUaPanel *self)
gtk_grid_attach (GTK_GRID (self->cursor_size_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);
+ g_signal_connect_object (button, "toggled",
+ G_CALLBACK (cursor_size_toggled), self, G_CONNECT_SWAPPED);
if (current_cursor_size == cursor_sizes[i])
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
@@ -529,7 +529,7 @@ add_separators (GtkListBox *list)
}
static gboolean
-keynav_failed (GtkWidget *list, GtkDirectionType direction, CcUaPanel *self)
+keynav_failed (CcUaPanel *self, GtkDirectionType direction, GtkWidget *list)
{
GList *item, *sections;
gdouble value, lower, upper, page;
@@ -570,7 +570,7 @@ keynav_failed (GtkWidget *list, GtkDirectionType direction, CcUaPanel *self)
static void
add_section (GtkWidget *list, CcUaPanel *self)
{
- g_signal_connect (list, "keynav-failed", G_CALLBACK (keynav_failed), self);
+ g_signal_connect_object (list, "keynav-failed", G_CALLBACK (keynav_failed), self, G_CONNECT_SWAPPED);
self->sections = g_list_append (self->sections, list);
self->sections_reverse = g_list_prepend (self->sections_reverse, list);
@@ -655,8 +655,8 @@ cc_ua_panel_init_seeing (CcUaPanel *self)
add_separators (GTK_LIST_BOX (self->list_seeing));
- g_signal_connect_swapped (self->list_seeing, "row-activated",
- G_CALLBACK (activate_row), self);
+ g_signal_connect_object (self->list_seeing, "row-activated",
+ G_CALLBACK (activate_row), self, G_CONNECT_SWAPPED);
g_settings_bind_with_mapping (self->interface_settings, KEY_GTK_THEME,
self->value_highcontrast,
@@ -741,9 +741,7 @@ cc_ua_panel_init_seeing (CcUaPanel *self)
/* hearing/sound section */
static void
-visual_bell_type_notify_cb (GSettings *settings,
- const gchar *key,
- CcUaPanel *self)
+visual_bell_type_notify_cb (CcUaPanel *self)
{
GtkWidget *widget;
GDesktopVisualBellType type;
@@ -759,19 +757,18 @@ visual_bell_type_notify_cb (GSettings *settings,
}
static void
-visual_bell_type_toggle_cb (GtkWidget *button,
- CcUaPanel *panel)
+visual_bell_type_toggle_cb (CcUaPanel *self)
{
gboolean frame_flash;
GDesktopVisualBellType type;
- frame_flash = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+ frame_flash = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->visual_alerts_window_radio));
if (frame_flash)
type = G_DESKTOP_VISUAL_BELL_FRAME_FLASH;
else
type = G_DESKTOP_VISUAL_BELL_FULLSCREEN_FLASH;
- g_settings_set_enum (panel->wm_settings, KEY_VISUAL_BELL_TYPE, type);
+ g_settings_set_enum (self->wm_settings, KEY_VISUAL_BELL_TYPE, type);
}
static void
@@ -789,11 +786,11 @@ cc_ua_panel_init_hearing (CcUaPanel *self)
add_separators (GTK_LIST_BOX (self->list_hearing));
- g_signal_connect_swapped (self->list_hearing, "row-activated",
- G_CALLBACK (activate_row), self);
+ g_signal_connect_object (self->list_hearing, "row-activated",
+ G_CALLBACK (activate_row), self, G_CONNECT_SWAPPED);
/* set the initial visual bell values */
- visual_bell_type_notify_cb (NULL, NULL, self);
+ visual_bell_type_notify_cb (self);
/* and listen */
g_settings_bind (self->wm_settings, KEY_VISUAL_BELL_ENABLED,
@@ -813,10 +810,10 @@ cc_ua_panel_init_hearing (CcUaPanel *self)
self->visual_alerts_screen_radio, "sensitive",
G_BINDING_SYNC_CREATE);
- g_signal_connect (self->wm_settings, "changed::" KEY_VISUAL_BELL_TYPE,
- G_CALLBACK (visual_bell_type_notify_cb), self);
- g_signal_connect (self->visual_alerts_window_radio,
- "toggled", G_CALLBACK (visual_bell_type_toggle_cb), self);
+ g_signal_connect_object (self->wm_settings, "changed::" KEY_VISUAL_BELL_TYPE,
+ G_CALLBACK (visual_bell_type_notify_cb), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->visual_alerts_window_radio,
+ "toggled", G_CALLBACK (visual_bell_type_toggle_cb), self, G_CONNECT_SWAPPED);
self->toplevels = g_slist_prepend (self->toplevels, self->visual_alerts_dialog);
@@ -831,11 +828,11 @@ cc_ua_panel_init_hearing (CcUaPanel *self)
/* typing/keyboard section */
static void
-on_repeat_keys_toggled (GSettings *settings, const gchar *key, CcUaPanel *self)
+on_repeat_keys_toggled (CcUaPanel *self)
{
gboolean on;
- on = g_settings_get_boolean (settings, KEY_REPEAT_KEYS);
+ on = g_settings_get_boolean (self->kb_desktop_settings, KEY_REPEAT_KEYS);
gtk_label_set_text (GTK_LABEL (self->value_repeat_keys), on ? _("On") : _("Off"));
@@ -844,23 +841,23 @@ on_repeat_keys_toggled (GSettings *settings, const gchar *key, CcUaPanel *self)
}
static void
-on_cursor_blinking_toggled (GSettings *settings, const gchar *key, CcUaPanel *self)
+on_cursor_blinking_toggled (CcUaPanel *self)
{
gboolean on;
- on = g_settings_get_boolean (settings, KEY_CURSOR_BLINKING);
+ on = g_settings_get_boolean (self->interface_settings, KEY_CURSOR_BLINKING);
gtk_label_set_text (GTK_LABEL (self->value_row_cursor_blinking), on ? _("On") : _("Off"));
}
static void
-update_accessx_label (GSettings *settings, const gchar *key, CcUaPanel *self)
+update_accessx_label (CcUaPanel *self)
{
gboolean on;
- on = g_settings_get_boolean (settings, KEY_STICKYKEYS_ENABLED) ||
- g_settings_get_boolean (settings, KEY_SLOWKEYS_ENABLED) ||
- g_settings_get_boolean (settings, KEY_BOUNCEKEYS_ENABLED);
+ on = g_settings_get_boolean (self->kb_settings, KEY_STICKYKEYS_ENABLED) ||
+ g_settings_get_boolean (self->kb_settings, KEY_SLOWKEYS_ENABLED) ||
+ g_settings_get_boolean (self->kb_settings, KEY_BOUNCEKEYS_ENABLED);
gtk_label_set_text (GTK_LABEL (self->value_accessx), on ? _("On") : _("Off"));
}
@@ -877,8 +874,8 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
add_separators (GTK_LIST_BOX (list));
- g_signal_connect_swapped (list, "row-activated",
- G_CALLBACK (activate_row), self);
+ g_signal_connect_object (list, "row-activated",
+ G_CALLBACK (activate_row), self, G_CONNECT_SWAPPED);
/* on-screen keyboard */
g_settings_bind (self->application_settings, KEY_SCREEN_KEYBOARD_ENABLED,
@@ -886,8 +883,8 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
G_SETTINGS_BIND_DEFAULT);
/* Repeat keys */
- g_signal_connect (self->kb_desktop_settings, "changed",
- G_CALLBACK (on_repeat_keys_toggled), self);
+ g_signal_connect_object (self->kb_desktop_settings, "changed",
+ G_CALLBACK (on_repeat_keys_toggled), self, G_CONNECT_SWAPPED);
self->toplevels = g_slist_prepend (self->toplevels, self->repeat_keys_dialog);
@@ -900,7 +897,7 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
g_settings_bind (self->kb_desktop_settings, KEY_REPEAT_KEYS,
sw, "active",
G_SETTINGS_BIND_DEFAULT);
- on_repeat_keys_toggled (self->kb_desktop_settings, NULL, self);
+ on_repeat_keys_toggled (self);
g_settings_bind (self->kb_desktop_settings, "delay",
gtk_range_get_adjustment (GTK_RANGE (self->repeat_keys_delay_scale)), "value",
@@ -910,8 +907,8 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
G_SETTINGS_BIND_DEFAULT);
/* Cursor Blinking */
- g_signal_connect (self->interface_settings, "changed",
- G_CALLBACK (on_cursor_blinking_toggled), self);
+ g_signal_connect_object (self->interface_settings, "changed",
+ G_CALLBACK (on_cursor_blinking_toggled), self, G_CONNECT_SWAPPED);
self->toplevels = g_slist_prepend (self->toplevels, self->cursor_blinking_dialog);
@@ -924,7 +921,7 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
g_settings_bind (self->interface_settings, KEY_CURSOR_BLINKING,
sw, "active",
G_SETTINGS_BIND_DEFAULT);
- on_cursor_blinking_toggled (self->interface_settings, NULL, self);
+ on_cursor_blinking_toggled (self);
g_settings_bind (self->interface_settings, KEY_CURSOR_BLINKING_TIME,
gtk_range_get_adjustment (GTK_RANGE (self->cursor_blinking_scale)), "value",
@@ -932,9 +929,9 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
/* accessx */
- g_signal_connect (self->kb_settings, "changed",
- G_CALLBACK (update_accessx_label), self);
- update_accessx_label (self->kb_settings, NULL, self);
+ g_signal_connect_object (self->kb_settings, "changed",
+ G_CALLBACK (update_accessx_label), self, G_CONNECT_SWAPPED);
+ update_accessx_label (self);
/* enable shortcuts */
sw = self->typing_keyboard_toggle_switch;
@@ -1020,12 +1017,12 @@ cc_ua_panel_init_keyboard (CcUaPanel *self)
/* mouse/pointing & clicking section */
static void
-update_click_assist_label (GSettings *settings, const gchar *key, CcUaPanel *self)
+update_click_assist_label (CcUaPanel *self)
{
gboolean on;
- on = g_settings_get_boolean (settings, KEY_SECONDARY_CLICK_ENABLED) ||
- g_settings_get_boolean (settings, KEY_DWELL_CLICK_ENABLED);
+ on = g_settings_get_boolean (self->mouse_settings, KEY_SECONDARY_CLICK_ENABLED) ||
+ g_settings_get_boolean (self->mouse_settings, KEY_DWELL_CLICK_ENABLED);
gtk_label_set_text (GTK_LABEL (self->value_click_assist), on ? _("On") : _("Off"));
}
@@ -1043,16 +1040,16 @@ cc_ua_panel_init_mouse (CcUaPanel *self)
add_separators (GTK_LIST_BOX (list));
- g_signal_connect_swapped (list, "row-activated",
- G_CALLBACK (activate_row), self);
+ g_signal_connect_object (list, "row-activated",
+ G_CALLBACK (activate_row), self, G_CONNECT_SWAPPED);
g_settings_bind (self->kb_settings, KEY_MOUSEKEYS_ENABLED,
self->mouse_keys_switch, "active",
G_SETTINGS_BIND_DEFAULT);
- g_signal_connect (self->mouse_settings, "changed",
- G_CALLBACK (update_click_assist_label), self);
- update_click_assist_label (self->mouse_settings, NULL, self);
+ g_signal_connect_object (self->mouse_settings, "changed",
+ G_CALLBACK (update_click_assist_label), self, G_CONNECT_SWAPPED);
+ update_click_assist_label (self);
/* simulated secondary click */
sw = self->pointing_secondary_click_switch;
diff --git a/panels/universal-access/zoom-options.c b/panels/universal-access/zoom-options.c
index dcfaa44e4..c7aee198c 100644
--- a/panels/universal-access/zoom-options.c
+++ b/panels/universal-access/zoom-options.c
@@ -69,14 +69,13 @@ static gchar *contrast_keys[] = {
NULL
};
-static void set_enable_screen_part_ui (GtkWidget *widget, ZoomOptions *self);
+static void set_enable_screen_part_ui (ZoomOptions *self);
static void scale_label (GtkBin *toggle, PangoAttrList *attrs);
-static void xhairs_color_opacity_changed (GtkColorButton *button, ZoomOptions *self);
static void xhairs_length_add_marks (ZoomOptions *self, GtkScale *scale);
static void effects_slider_set_value (GtkRange *slider, GSettings *settings);
-static void brightness_slider_notify_cb (GSettings *settings, const gchar *key, ZoomOptions *self);
-static void contrast_slider_notify_cb (GSettings *settings, const gchar *key, ZoomOptions *self);
-static void effects_slider_changed (GtkRange *slider, ZoomOptions *self);
+static void brightness_slider_notify_cb (ZoomOptions *self, const gchar *key);
+static void contrast_slider_notify_cb (ZoomOptions *self, const gchar *key);
+static void effects_slider_changed (ZoomOptions *self, GtkRange *slider);
static void
mouse_tracking_radio_toggled_cb (ZoomOptions *self, GtkWidget *widget)
@@ -123,7 +122,7 @@ init_screen_part_section (ZoomOptions *self, PangoAttrList *pango_attrs)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->follow_mouse_radio), lens_mode);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->screen_part_radio), !lens_mode);
- set_enable_screen_part_ui (self->screen_part_radio, self);
+ set_enable_screen_part_ui (self);
g_settings_bind (self->settings, "lens-mode",
self->follow_mouse_radio, "active",
@@ -133,8 +132,8 @@ init_screen_part_section (ZoomOptions *self, PangoAttrList *pango_attrs)
self->extend_beyond_checkbox, "active",
G_SETTINGS_BIND_DEFAULT);
- g_signal_connect (G_OBJECT (self->screen_part_radio), "toggled",
- G_CALLBACK (set_enable_screen_part_ui), self);
+ g_signal_connect_object (G_OBJECT (self->screen_part_radio), "toggled",
+ G_CALLBACK (set_enable_screen_part_ui), self, G_CONNECT_SWAPPED);
mouse_tracking_notify_cb (self);
g_signal_connect_object (G_OBJECT (self->settings), "changed::mouse-tracking",
@@ -142,7 +141,7 @@ init_screen_part_section (ZoomOptions *self, PangoAttrList *pango_attrs)
}
static void
-set_enable_screen_part_ui (GtkWidget *widget, ZoomOptions *self)
+set_enable_screen_part_ui (ZoomOptions *self)
{
gboolean screen_part;
@@ -172,14 +171,14 @@ scale_label (GtkBin *toggle, PangoAttrList *attrs)
}
static void
-screen_position_combo_changed_cb (GtkWidget *combobox, ZoomOptions *self)
+screen_position_combo_changed_cb (ZoomOptions *self)
{
g_autofree gchar *combo_value = NULL;
GtkTreeIter iter;
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &iter);
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->screen_position_combobox), &iter);
- gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (combobox)), &iter,
+ gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (self->screen_position_combobox)), &iter,
POSITION_MODEL_VALUE_COLUMN, &combo_value,
-1);
@@ -190,9 +189,8 @@ screen_position_combo_changed_cb (GtkWidget *combobox, ZoomOptions *self)
}
static void
-screen_position_notify_cb (GSettings *settings,
- const gchar *key,
- ZoomOptions *self)
+screen_position_notify_cb (ZoomOptions *self,
+ const gchar *key)
{
g_autofree gchar *position = NULL;
GtkTreeIter iter;
@@ -241,31 +239,31 @@ init_xhairs_color_opacity (GtkColorButton *color_button, GSettings *settings)
}
static void
-xhairs_color_notify_cb (GSettings *settings, gchar *key, GtkColorButton *button)
+xhairs_color_notify_cb (ZoomOptions *self)
{
- init_xhairs_color_opacity (button, settings);
+ init_xhairs_color_opacity (GTK_COLOR_BUTTON (self->crosshair_picker_color_button), self->settings);
}
static void
-xhairs_opacity_notify_cb (GSettings *settings, gchar *key, GtkColorButton *button)
+xhairs_opacity_notify_cb (ZoomOptions *self, gchar *key)
{
GdkRGBA rgba;
gdouble opacity;
- opacity = g_settings_get_double (settings, key);
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
+ opacity = g_settings_get_double (self->settings, key);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba);
rgba.alpha = opacity * 65535;
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &rgba);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba);
}
#define TO_HEX(x) (int) ((gdouble) x * 255.0)
static void
-xhairs_color_opacity_changed (GtkColorButton *button, ZoomOptions *self)
+xhairs_color_opacity_changed (ZoomOptions *self)
{
GdkRGBA rgba;
g_autofree gchar *color_string = NULL;
- gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->crosshair_picker_color_button), &rgba);
color_string = g_strdup_printf ("#%02x%02x%02x",
TO_HEX(rgba.red),
TO_HEX(rgba.green),
@@ -323,11 +321,11 @@ init_effects_slider (GtkRange *slider,
for (key = keys; *key; key++)
{
g_autofree gchar *signal = g_strdup_printf ("changed::%s", *key);
- g_signal_connect (G_OBJECT (self->settings), signal, notify_cb, self);
+ g_signal_connect_object (G_OBJECT (self->settings), signal, notify_cb, self, G_CONNECT_SWAPPED);
}
- g_signal_connect (G_OBJECT (slider), "value-changed",
- G_CALLBACK (effects_slider_changed),
- self);
+ g_signal_connect_object (G_OBJECT (slider), "value-changed",
+ G_CALLBACK (effects_slider_changed),
+ self, G_CONNECT_SWAPPED);
gtk_scale_add_mark (GTK_SCALE (slider), 0, GTK_POS_BOTTOM, NULL);
}
@@ -354,31 +352,29 @@ effects_slider_set_value (GtkRange *slider, GSettings *settings)
}
static void
-brightness_slider_notify_cb (GSettings *settings,
- const gchar *key,
- ZoomOptions *self)
+brightness_slider_notify_cb (ZoomOptions *self,
+ const gchar *key)
{
GtkRange *slider = GTK_RANGE (self->brightness_slider);
g_signal_handlers_block_by_func (slider, effects_slider_changed, self);
- effects_slider_set_value (slider, settings);
+ effects_slider_set_value (slider, self->settings);
g_signal_handlers_unblock_by_func (slider, effects_slider_changed, self);
}
static void
-contrast_slider_notify_cb (GSettings *settings,
- const gchar *key,
- ZoomOptions *self)
+contrast_slider_notify_cb (ZoomOptions *self,
+ const gchar *key)
{
GtkRange *slider = GTK_RANGE (self->contrast_slider);
g_signal_handlers_block_by_func (slider, effects_slider_changed, self);
- effects_slider_set_value (slider, settings);
+ effects_slider_set_value (slider, self->settings);
g_signal_handlers_unblock_by_func (slider, effects_slider_changed, self);
}
static void
-effects_slider_changed (GtkRange *slider, ZoomOptions *self)
+effects_slider_changed (ZoomOptions *self, GtkRange *slider)
{
gchar **keys, **key;
gdouble value;
@@ -418,11 +414,11 @@ zoom_options_constructed (GObject *object)
"value", G_SETTINGS_BIND_DEFAULT);
/* Screen position combo */
- screen_position_notify_cb (self->settings, "screen-position", self);
- g_signal_connect (self->settings, "changed::screen-position",
- G_CALLBACK (screen_position_notify_cb), self);
- g_signal_connect (self->screen_position_combobox, "changed",
- G_CALLBACK (screen_position_combo_changed_cb), self);
+ screen_position_notify_cb (self, "screen-position");
+ g_signal_connect_object (self->settings, "changed::screen-position",
+ G_CALLBACK (screen_position_notify_cb), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->screen_position_combobox, "changed",
+ G_CALLBACK (screen_position_combo_changed_cb), self, G_CONNECT_SWAPPED);
/* Screen part section */
init_screen_part_section (self, pango_attrs);
@@ -434,13 +430,13 @@ zoom_options_constructed (GObject *object)
/* ... Cross hairs: color and opacity */
init_xhairs_color_opacity (GTK_COLOR_BUTTON (self->crosshair_picker_color_button), self->settings);
- g_signal_connect (self->settings, "changed::cross-hairs-color",
- G_CALLBACK (xhairs_color_notify_cb), self->crosshair_picker_color_button);
- g_signal_connect (self->settings, "changed::cross-hairs-opacity",
- G_CALLBACK (xhairs_opacity_notify_cb), self->crosshair_picker_color_button);
- g_signal_connect (self->crosshair_picker_color_button, "color-set",
- G_CALLBACK (xhairs_color_opacity_changed),
- self);
+ g_signal_connect_object (self->settings, "changed::cross-hairs-color",
+ G_CALLBACK (xhairs_color_notify_cb), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->settings, "changed::cross-hairs-opacity",
+ G_CALLBACK (xhairs_opacity_notify_cb), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->crosshair_picker_color_button, "color-set",
+ G_CALLBACK (xhairs_color_opacity_changed),
+ self, G_CONNECT_SWAPPED);
/* ... Cross hairs: thickness ... */
g_settings_bind (self->settings, "cross-hairs-thickness",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]