aboutdialog: Put event controllers into ui file

This commit is contained in:
Benjamin Otte 2018-03-09 00:35:18 +01:00 committed by Carlos Garnacho
parent 9c0acf62b4
commit 40a082de10
2 changed files with 33 additions and 27 deletions

View 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);
}

View File

@ -157,6 +157,21 @@
<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>
@ -183,6 +198,21 @@
<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>