[gtk/wip/baedert/for-master: 8/9] shortcutscontroller: Make add_shortcut transfer-full
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 8/9] shortcutscontroller: Make add_shortcut transfer-full
- Date: Fri, 27 Mar 2020 08:16:07 +0000 (UTC)
commit ecb8dda30970b01f64a5d070507ac1c09972b925
Author: Timm Bäder <mail baedert org>
Date: Thu Mar 26 17:31:38 2020 +0100
shortcutscontroller: Make add_shortcut transfer-full
Like all the other shortcut api
gtk/gtklabel.c | 1 -
gtk/gtkmodelbutton.c | 8 +++-----
gtk/gtkshortcutcontroller.c | 8 ++++++--
3 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 1d591877bd..0b7b884685 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1838,7 +1838,6 @@ gtk_label_setup_mnemonic (GtkLabel *label)
g_object_ref (gtk_mnemonic_action_get ()));
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (priv->mnemonic_controller), shortcut);
gtk_widget_add_controller (GTK_WIDGET (label), priv->mnemonic_controller);
- g_object_unref (shortcut);
}
else
{
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 1bbdd46c50..4cc292c980 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -748,7 +748,6 @@ update_accel (GtkModelButton *self,
if (GTK_IS_POPOVER (gtk_widget_get_native (GTK_WIDGET (self))))
{
- GtkShortcut *shortcut;
GtkShortcutTrigger *trigger;
GtkShortcutAction *action;
@@ -756,7 +755,7 @@ update_accel (GtkModelButton *self,
{
while (g_list_model_get_n_items (G_LIST_MODEL (self->controller)) > 0)
{
- shortcut = g_list_model_get_item (G_LIST_MODEL (self->controller), 0);
+ GtkShortcut *shortcut = g_list_model_get_item (G_LIST_MODEL (self->controller), 0);
gtk_shortcut_controller_remove_shortcut (GTK_SHORTCUT_CONTROLLER (self->controller),
shortcut);
g_object_unref (shortcut);
@@ -771,9 +770,8 @@ update_accel (GtkModelButton *self,
trigger = gtk_keyval_trigger_new (key, mods);
action = gtk_signal_action_new ("clicked");
- shortcut = gtk_shortcut_new (trigger, action);
- gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (self->controller), shortcut);
- g_object_unref (shortcut);
+ gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (self->controller),
+ gtk_shortcut_new (trigger, action));
}
}
else
diff --git a/gtk/gtkshortcutcontroller.c b/gtk/gtkshortcutcontroller.c
index c141f7887c..8123d796e6 100644
--- a/gtk/gtkshortcutcontroller.c
+++ b/gtk/gtkshortcutcontroller.c
@@ -659,7 +659,7 @@ gtk_shortcut_controller_new_for_model (GListModel *model)
/**
* gtk_shortcut_controller_add_shortcut:
* @self: the controller
- * @shortcut: a #GtkShortcut
+ * @shortcut: (transfer-full): a #GtkShortcut
*
* Adds @shortcut to the list of shortcuts handled by @self.
*
@@ -676,13 +676,17 @@ gtk_shortcut_controller_add_shortcut (GtkShortcutController *self,
g_return_if_fail (GTK_IS_SHORTCUT (shortcut));
if (!self->custom_shortcuts)
- return;
+ {
+ g_object_unref (shortcut);
+ return;
+ }
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
if (widget)
update_accel (shortcut, widget, TRUE);
g_list_store_append (G_LIST_STORE (self->shortcuts), shortcut);
+ g_object_unref (shortcut);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]