display: Connect signals with g_signal_connect_object in swapped form

This commit is contained in:
Robert Ancell 2019-11-22 12:17:13 +13:00
parent b4922526c1
commit c0cfbeccff
2 changed files with 25 additions and 42 deletions

View file

@ -389,12 +389,12 @@ reset_titlebar (CcDisplayPanel *self)
}
static void
active_panel_changed (CcShell *shell,
GParamSpec *pspec,
CcPanel *self)
active_panel_changed (CcPanel *self)
{
CcShell *shell;
g_autoptr(CcPanel) panel = NULL;
shell = cc_panel_get_shell (CC_PANEL (self));
g_object_get (shell, "active-panel", &panel, NULL);
if (panel != self)
reset_titlebar (CC_DISPLAY_PANEL (self));
@ -404,8 +404,6 @@ static void
cc_display_panel_dispose (GObject *object)
{
CcDisplayPanel *self = CC_DISPLAY_PANEL (object);
CcShell *shell;
GtkWidget *toplevel;
reset_titlebar (CC_DISPLAY_PANEL (object));
@ -419,11 +417,6 @@ cc_display_panel_dispose (GObject *object)
if (self->focus_id)
{
shell = cc_panel_get_shell (CC_PANEL (object));
toplevel = cc_shell_get_toplevel (shell);
if (toplevel != NULL)
g_signal_handler_disconnect (G_OBJECT (toplevel),
self->focus_id);
self->focus_id = 0;
monitor_labeler_hide (CC_DISPLAY_PANEL (object));
}
@ -611,7 +604,7 @@ static void
cc_display_panel_constructed (GObject *object)
{
g_signal_connect_object (cc_panel_get_shell (CC_PANEL (object)), "notify::active-panel",
G_CALLBACK (active_panel_changed), object, 0);
G_CALLBACK (active_panel_changed), object, G_CONNECT_SWAPPED);
G_OBJECT_CLASS (cc_display_panel_parent_class)->constructed (object);
}
@ -1037,18 +1030,16 @@ mapped_cb (CcDisplayPanel *panel)
shell = cc_panel_get_shell (CC_PANEL (panel));
toplevel = cc_shell_get_toplevel (shell);
if (toplevel && !panel->focus_id)
panel->focus_id = g_signal_connect_swapped (toplevel, "notify::has-toplevel-focus",
G_CALLBACK (dialog_toplevel_focus_changed), panel);
panel->focus_id = g_signal_connect_object (toplevel, "notify::has-toplevel-focus",
G_CALLBACK (dialog_toplevel_focus_changed), panel, G_CONNECT_SWAPPED);
}
static void
cc_display_panel_up_client_changed (UpClient *client,
GParamSpec *pspec,
CcDisplayPanel *self)
cc_display_panel_up_client_changed (CcDisplayPanel *self)
{
gboolean lid_is_closed;
lid_is_closed = up_client_get_lid_is_closed (client);
lid_is_closed = up_client_get_lid_is_closed (self->up_client);
if (lid_is_closed != self->lid_is_closed)
{
@ -1108,10 +1099,9 @@ update_has_accel (CcDisplayPanel *self)
}
static void
sensor_proxy_properties_changed_cb (GDBusProxy *proxy,
sensor_proxy_properties_changed_cb (CcDisplayPanel *self,
GVariant *changed_properties,
GStrv invalidated_properties,
CcDisplayPanel *self)
GStrv invalidated_properties)
{
GVariantDict dict;
@ -1141,8 +1131,8 @@ sensor_proxy_appeared_cb (GDBusConnection *connection,
NULL);
g_return_if_fail (self->iio_sensor_proxy);
g_signal_connect (self->iio_sensor_proxy, "g-properties-changed",
G_CALLBACK (sensor_proxy_properties_changed_cb), self);
g_signal_connect_object (self->iio_sensor_proxy, "g-properties-changed",
G_CALLBACK (sensor_proxy_properties_changed_cb), self, G_CONNECT_SWAPPED);
update_has_accel (self);
}
@ -1236,9 +1226,9 @@ cc_display_panel_init (CcDisplayPanel *self)
self->up_client = up_client_new ();
if (up_client_get_lid_is_present (self->up_client))
{
g_signal_connect (self->up_client, "notify::lid-is-closed",
G_CALLBACK (cc_display_panel_up_client_changed), self);
cc_display_panel_up_client_changed (self->up_client, NULL, self);
g_signal_connect_object (self->up_client, "notify::lid-is-closed",
G_CALLBACK (cc_display_panel_up_client_changed), self, G_CONNECT_SWAPPED);
cc_display_panel_up_client_changed (self);
}
else
g_clear_object (&self->up_client);

View file

@ -380,10 +380,7 @@ dialog_color_temperature_value_changed_cb (GtkAdjustment *adjustment,
}
static void
dialog_color_properties_changed_cb (GDBusProxy *proxy,
GVariant *changed_properties,
GStrv invalidated_properties,
CcNightLightPage *self)
dialog_color_properties_changed_cb (CcNightLightPage *self)
{
dialog_update_state (self);
}
@ -408,7 +405,7 @@ dialog_got_proxy_cb (GObject *source_object,
self->proxy_color = proxy;
g_signal_connect_object (self->proxy_color, "g-properties-changed",
G_CALLBACK (dialog_color_properties_changed_cb), self, 0);
G_CALLBACK (dialog_color_properties_changed_cb), self, G_CONNECT_SWAPPED);
dialog_update_state (self);
self->timer_id = g_timeout_add_seconds (10, dialog_tick_cb, self);
}
@ -495,19 +492,15 @@ dialog_update_adjustments (CcNightLightPage *self)
}
static void
dialog_settings_changed_cb (GSettings *settings_display,
gchar *key,
CcNightLightPage *self)
dialog_settings_changed_cb (CcNightLightPage *self)
{
dialog_update_state (self);
}
static void
dialog_clock_settings_changed_cb (GSettings *settings_display,
gchar *key,
CcNightLightPage *self)
dialog_clock_settings_changed_cb (CcNightLightPage *self)
{
self->clock_format = g_settings_get_enum (settings_display, CLOCK_FORMAT_KEY);
self->clock_format = g_settings_get_enum (self->settings_clock, CLOCK_FORMAT_KEY);
/* uncontionally widen this to avoid truncation */
gtk_adjustment_set_lower (self->adjustment_from_hours, 0);
@ -648,7 +641,7 @@ cc_night_light_page_init (CcNightLightPage *self)
self->cancellable = g_cancellable_new ();
self->settings_display = g_settings_new (DISPLAY_SCHEMA);
g_signal_connect (self->settings_display, "changed", G_CALLBACK (dialog_settings_changed_cb), self);
g_signal_connect_object (self->settings_display, "changed", G_CALLBACK (dialog_settings_changed_cb), self, G_CONNECT_SWAPPED);
build_schedule_combo_row (self);
@ -702,10 +695,10 @@ cc_night_light_page_init (CcNightLightPage *self)
self->settings_clock = g_settings_new (CLOCK_SCHEMA);
self->clock_format = g_settings_get_enum (self->settings_clock, CLOCK_FORMAT_KEY);
dialog_update_adjustments (self);
g_signal_connect (self->settings_clock,
g_signal_connect_object (self->settings_clock,
"changed::" CLOCK_FORMAT_KEY,
G_CALLBACK (dialog_clock_settings_changed_cb),
self);
self, G_CONNECT_SWAPPED);
dialog_update_state (self);
}