static void ide_editor_view_actions_language (GSimpleAction *action, GVariant *variant, gpointer user_data) { IdeEditorView *self = user_data; GtkSourceLanguageManager *manager; GtkSourceLanguage *language; GtkSourceBuffer *buffer; const gchar *name; g_assert (IDE_IS_EDITOR_VIEW (self)); manager = gtk_source_language_manager_get_default (); name = g_variant_get_string (variant, NULL); buffer = GTK_SOURCE_BUFFER (self->document); if (name != NULL) { language = gtk_source_language_manager_get_language (manager, name); gtk_source_buffer_set_language (buffer, language); ide_editor_view_actions_update (self); } }
static void ide_editor_view_set_document (IdeEditorView *self, IdeBuffer *document) { g_return_if_fail (IDE_IS_EDITOR_VIEW (self)); g_return_if_fail (IDE_IS_BUFFER (document)); if (g_set_object (&self->document, document)) { if (self->frame1) ide_editor_frame_set_document (self->frame1, document); if (self->frame2) ide_editor_frame_set_document (self->frame2, document); g_settings_bind (self->settings, "style-scheme-name", document, "style-scheme-name", G_SETTINGS_BIND_GET); g_settings_bind (self->settings, "highlight-matching-brackets", document, "highlight-matching-brackets", G_SETTINGS_BIND_GET); g_signal_connect_object (document, "cursor-moved", G_CALLBACK (ide_editor_view__buffer_cursor_moved), self, G_CONNECT_SWAPPED); g_object_bind_property_full (document, "language", self->tweak_button, "label", G_BINDING_SYNC_CREATE, language_to_string, NULL, NULL, NULL); g_signal_connect_object (document, "modified-changed", G_CALLBACK (ide_editor_view__buffer_modified_changed), self, G_CONNECT_SWAPPED); g_signal_connect_object (document, "notify::title", G_CALLBACK (ide_editor_view__buffer_notify_title), self, G_CONNECT_SWAPPED); g_signal_connect_object (document, "notify::language", G_CALLBACK (ide_editor_view__buffer_notify_language), self, G_CONNECT_SWAPPED); g_signal_connect_object (document, "notify::changed-on-volume", G_CALLBACK (ide_editor_view__buffer_changed_on_volume), self, G_CONNECT_SWAPPED); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DOCUMENT]); g_object_bind_property (document, "has-diagnostics", self->warning_button, "visible", G_BINDING_SYNC_CREATE); ide_editor_view__buffer_notify_language (self, NULL, document); ide_editor_view__buffer_notify_title (self, NULL, IDE_BUFFER (document)); ide_editor_view_actions_update (self); } }