aboutdialog: Put event controllers into ui file
authorBenjamin Otte <otte@redhat.com>
Thu, 8 Mar 2018 23:35:18 +0000 (00:35 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 26 Apr 2018 15:59:41 +0000 (17:59 +0200)
gtk/gtkaboutdialog.c
gtk/ui/gtkaboutdialog.ui

index a6aec53265855f9dd37a1dd304a575c3021698a4..49d890dddf1c4757fbf3e7ae5f8e2e331f1e6617 100644 (file)
@@ -185,13 +185,6 @@ struct _GtkAboutDialogPrivate
 
   GSList *visited_links;
 
-  GtkGesture *license_press;
-  GtkGesture *system_press;
-  GtkEventController *license_motion;
-  GtkEventController *system_motion;
-  GtkEventController *license_key;
-  GtkEventController *system_key;
-
   GtkLicense license_type;
 
   guint hovering_over_link : 1;
@@ -614,6 +607,9 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtkAboutDialog, system_view);
 
   gtk_widget_class_bind_template_callback (widget_class, emit_activate_link);
+  gtk_widget_class_bind_template_callback (widget_class, text_view_released);
+  gtk_widget_class_bind_template_callback (widget_class, text_view_motion);
+  gtk_widget_class_bind_template_callback (widget_class, text_view_key_pressed);
   gtk_widget_class_bind_template_callback (widget_class, stack_visible_child_notify);
 }
 
@@ -777,19 +773,6 @@ gtk_about_dialog_init (GtkAboutDialog *about)
   switch_page (about, "main");
   update_stack_switcher_visibility (about);
 
-  priv->license_press = gtk_gesture_multi_press_new (priv->license_view);
-  g_signal_connect (priv->license_press, "released", G_CALLBACK (text_view_released), about);
-  priv->system_press = gtk_gesture_multi_press_new (priv->system_view);
-  g_signal_connect (priv->system_press, "released", G_CALLBACK (text_view_released), about);
-  priv->license_motion = gtk_event_controller_motion_new (priv->license_view);
-  g_signal_connect (priv->license_motion, "motion", G_CALLBACK (text_view_motion), about);
-  priv->system_motion = gtk_event_controller_motion_new (priv->system_view);
-  g_signal_connect (priv->system_motion, "motion", G_CALLBACK (text_view_motion), about);
-  priv->license_key = gtk_event_controller_key_new (priv->license_view);
-  g_signal_connect (priv->license_key, "key-pressed", G_CALLBACK (text_view_key_pressed), about);
-  priv->system_key = gtk_event_controller_key_new (priv->system_view);
-  g_signal_connect (priv->system_key, "key-pressed", G_CALLBACK (text_view_key_pressed), about);
-
   /* force defaults */
   gtk_about_dialog_set_program_name (about, NULL);
   gtk_about_dialog_set_logo (about, NULL);
@@ -826,13 +809,6 @@ gtk_about_dialog_finalize (GObject *object)
   g_slist_free_full (priv->credit_sections, destroy_credit_section);
   g_slist_free_full (priv->visited_links, g_free);
 
-  g_object_unref (priv->license_press);
-  g_object_unref (priv->system_press);
-  g_object_unref (priv->license_motion);
-  g_object_unref (priv->system_motion);
-  g_object_unref (priv->license_key);
-  g_object_unref (priv->system_key);
-
   G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
 }
 
index f48ed4c9b9697d18f2df546136a2f94f77be2fd6..180151f66e3cf736a460b20235620604d756c989 100644 (file)
                             <property name="left-margin">8</property>
                             <property name="right-margin">8</property>
                             <property name="cursor-visible">0</property>
+                            <child>
+                              <object class="GtkGestureMultiPress">
+                                <signal name="released" handler="text_view_released" swapped="no"/>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkEventControllerMotion">
+                                <signal name="motion" handler="text_view_motion" swapped="no"/>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkEventControllerKey">
+                                <signal name="key-pressed" handler="text_view_key_pressed" swapped="no"/>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
                             <property name="left-margin">8</property>
                             <property name="right-margin">8</property>
                             <property name="cursor-visible">0</property>
+                            <child>
+                              <object class="GtkGestureMultiPress">
+                                <signal name="released" handler="text_view_released" swapped="no"/>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkEventControllerMotion">
+                                <signal name="motion" handler="text_view_motion" swapped="no"/>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkEventControllerKey">
+                                <signal name="key-pressed" handler="text_view_key_pressed" swapped="no"/>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>