[gtk/strdup-avoidance: 3/3] Use gtk_event_controller_set_static_name




commit 32796cad108fc4d58dfb532e7079fdad9f0e7bbc
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 27 22:00:42 2022 -0400

    Use gtk_event_controller_set_static_name
    
    This avoids strdups.

 gtk/gtkentrycompletion.c  |  4 ++--
 gtk/gtkimcontextwayland.c |  2 +-
 gtk/gtkshortcutmanager.c  |  4 ++--
 gtk/gtktext.c             | 12 ++++++------
 gtk/gtkwidget.c           |  2 +-
 gtk/gtkwindow.c           |  6 +++---
 6 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 328d3cc0fd..8d1bf57269 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -2050,12 +2050,12 @@ connect_completion_signals (GtkEntryCompletion *completion)
   GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
 
   controller = completion->entry_key_controller = gtk_event_controller_key_new ();
-  gtk_event_controller_set_name (controller, "gtk-entry-completion");
+  gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
   g_signal_connect (controller, "key-pressed",
                     G_CALLBACK (gtk_entry_completion_key_pressed), completion);
   gtk_widget_add_controller (GTK_WIDGET (text), controller);
   controller = completion->entry_focus_controller = gtk_event_controller_focus_new ();
-  gtk_event_controller_set_name (controller, "gtk-entry-completion");
+  gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
   g_signal_connect_swapped (controller, "leave", G_CALLBACK (text_focus_out), completion);
   gtk_widget_add_controller (GTK_WIDGET (text), controller);
 
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index e4469b05aa..b5195e28d7 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -588,7 +588,7 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
       GtkGesture *gesture;
 
       gesture = gtk_gesture_click_new ();
-      gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), "wayland-im-context-click");
+      gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (gesture), "wayland-im-context-click");
       gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
                                                   GTK_PHASE_CAPTURE);
       g_signal_connect (gesture, "pressed",
diff --git a/gtk/gtkshortcutmanager.c b/gtk/gtkshortcutmanager.c
index d5e08279d9..ab96eaef4f 100644
--- a/gtk/gtkshortcutmanager.c
+++ b/gtk/gtkshortcutmanager.c
@@ -51,13 +51,13 @@ gtk_shortcut_manager_create_controllers (GtkWidget *widget)
   model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
   g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
   controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
-  gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
+  gtk_event_controller_set_static_name (controller, "gtk-shortcut-manager-bubble");
   gtk_widget_add_controller (widget, controller);
 
   model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
   g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
   controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
-  gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
+  gtk_event_controller_set_static_name (controller, "gtk-shortcut-manager-capture");
   gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
   gtk_widget_add_controller (widget, controller);
 }
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 5eb216e14d..b95d6d8c51 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1856,7 +1856,7 @@ gtk_text_init (GtkText *self)
   GTK_TEXT_CONTENT (priv->selection_content)->self = self;
 
   target = gtk_drop_target_new (G_TYPE_STRING, GDK_ACTION_COPY | GDK_ACTION_MOVE);
-  gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (target), "gtk-text-drop-target");
+  gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (target), "gtk-text-drop-target");
   g_signal_connect (target, "accept", G_CALLBACK (gtk_text_drag_accept), self);
   g_signal_connect (target, "enter", G_CALLBACK (gtk_text_drag_motion), self);
   g_signal_connect (target, "motion", G_CALLBACK (gtk_text_drag_motion), self);
@@ -1881,7 +1881,7 @@ gtk_text_init (GtkText *self)
                     G_CALLBACK (gtk_text_delete_surrounding_cb), self);
 
   priv->drag_gesture = gtk_gesture_drag_new ();
-  gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (priv->drag_gesture), "gtk-text-drag-gesture");
+  gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (priv->drag_gesture), "gtk-text-drag-gesture");
   g_signal_connect (priv->drag_gesture, "drag-update",
                     G_CALLBACK (gtk_text_drag_gesture_update), self);
   g_signal_connect (priv->drag_gesture, "drag-end",
@@ -1891,7 +1891,7 @@ gtk_text_init (GtkText *self)
   gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (priv->drag_gesture));
 
   gesture = gtk_gesture_click_new ();
-  gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), "gtk-text-click-gesture");
+  gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (gesture), "gtk-text-click-gesture");
   g_signal_connect (gesture, "pressed",
                     G_CALLBACK (gtk_text_click_gesture_pressed), self);
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
@@ -1899,14 +1899,14 @@ gtk_text_init (GtkText *self)
   gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
 
   controller = gtk_event_controller_motion_new ();
-  gtk_event_controller_set_name (controller, "gtk-text-motion-controller");
+  gtk_event_controller_set_static_name (controller, "gtk-text-motion-controller");
   g_signal_connect (controller, "motion",
                     G_CALLBACK (gtk_text_motion_controller_motion), self);
   gtk_widget_add_controller (GTK_WIDGET (self), controller);
 
   priv->key_controller = gtk_event_controller_key_new ();
   gtk_event_controller_set_propagation_phase (priv->key_controller, GTK_PHASE_TARGET);
-  gtk_event_controller_set_name (priv->key_controller, "gtk-text-key-controller");
+  gtk_event_controller_set_static_name (priv->key_controller, "gtk-text-key-controller");
   g_signal_connect (priv->key_controller, "key-pressed",
                     G_CALLBACK (gtk_text_key_controller_key_pressed), self);
   g_signal_connect_swapped (priv->key_controller, "im-update",
@@ -1916,7 +1916,7 @@ gtk_text_init (GtkText *self)
   gtk_widget_add_controller (GTK_WIDGET (self), priv->key_controller);
 
   priv->focus_controller = gtk_event_controller_focus_new ();
-  gtk_event_controller_set_name (priv->focus_controller, "gtk-text-focus-controller");
+  gtk_event_controller_set_static_name (priv->focus_controller, "gtk-text-focus-controller");
   g_signal_connect (priv->focus_controller, "notify::is-focus",
                     G_CALLBACK (gtk_text_focus_changed), self);
   gtk_widget_add_controller (GTK_WIDGET (self), priv->focus_controller);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 003b61f0bd..dda5a1f042 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2362,7 +2362,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
   if (g_list_model_get_n_items (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts)) > 0)
     {
       controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (GTK_WIDGET_CLASS 
(g_class)->priv->shortcuts));
-      gtk_event_controller_set_name (controller, "gtk-widget-class-shortcuts");
+      gtk_event_controller_set_static_name (controller, "gtk-widget-class-shortcuts");
       gtk_widget_add_controller (widget, controller);
     }
 
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 6fcdcf23cf..efd1cff6f0 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1683,7 +1683,7 @@ gtk_window_init (GtkWindow *window)
   gtk_widget_add_controller (widget, controller);
 
   controller = gtk_event_controller_legacy_new ();
-  gtk_event_controller_set_name (controller, "gtk-window-toplevel-focus");
+  gtk_event_controller_set_static_name (controller, "gtk-window-toplevel-focus");
   g_signal_connect_swapped (controller, "event",
                             G_CALLBACK (gtk_window_handle_focus), window);
   gtk_widget_add_controller (widget, controller);
@@ -1694,7 +1694,7 @@ gtk_window_init (GtkWindow *window)
   shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (MENU_BAR_ACCEL, 0),
                                gtk_callback_action_new (gtk_window_activate_menubar, NULL, NULL));
   gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
-  gtk_event_controller_set_name (controller, "gtk-window-menubar-accel");
+  gtk_event_controller_set_static_name (controller, "gtk-window-menubar-accel");
   gtk_widget_add_controller (widget, controller);
 
   priv->menubar_controller = controller;
@@ -2797,7 +2797,7 @@ gtk_window_set_application (GtkWindow      *window,
 
           app_accels = gtk_application_get_application_accels (priv->application);
           priv->application_shortcut_controller = gtk_shortcut_controller_new_for_model 
(gtk_application_accels_get_shortcuts (app_accels));
-          gtk_event_controller_set_name (priv->application_shortcut_controller, "gtk-application-shortcuts");
+          gtk_event_controller_set_static_name (priv->application_shortcut_controller, 
"gtk-application-shortcuts");
           gtk_event_controller_set_propagation_phase (priv->application_shortcut_controller, 
GTK_PHASE_CAPTURE);
           gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER 
(priv->application_shortcut_controller), GTK_SHORTCUT_SCOPE_GLOBAL);
           gtk_widget_add_controller (GTK_WIDGET (window), priv->application_shortcut_controller);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]