static void ide_workbench_views_foreach_cb (GtkWidget *widget, gpointer user_data) { struct { GtkCallback callback; gpointer user_data; } *closure = user_data; g_assert (IDE_IS_PERSPECTIVE (widget)); g_assert (closure != NULL); g_assert (closure->callback != NULL); ide_perspective_views_foreach (IDE_PERSPECTIVE (widget), closure->callback, closure->user_data); }
static void ide_editor_perspective_focus_location_full (IdeEditorPerspective *self, IdeSourceLocation *location, gboolean open_if_not_found) { struct { IdeFile *file; IdeEditorView *view; } lookup = { 0 }; GtkWidget *stack; guint line; guint line_offset; IDE_ENTRY; g_assert (IDE_IS_EDITOR_PERSPECTIVE (self)); g_assert (location != NULL); lookup.file = ide_source_location_get_file (location); lookup.view = NULL; if (lookup.file == NULL) { g_warning ("IdeSourceLocation does not contain a file"); IDE_EXIT; } #ifdef IDE_ENABLE_TRACE { const gchar *path = ide_file_get_path (lookup.file); IDE_TRACE_MSG ("Locating %s, open_if_not_found=%d", path, open_if_not_found); } #endif ide_perspective_views_foreach (IDE_PERSPECTIVE (self), ide_editor_perspective_find_source_location, &lookup); if (!open_if_not_found && lookup.view == NULL) IDE_EXIT; if (lookup.view == NULL) { FocusLocation *state; IdeBufferManager *bufmgr; IdeWorkbench *workbench; IdeContext *context; workbench = ide_widget_get_workbench (GTK_WIDGET (self)); context = ide_workbench_get_context (workbench); bufmgr = ide_context_get_buffer_manager (context); state = g_slice_new0 (FocusLocation); state->self = g_object_ref (self); state->location = ide_source_location_ref (location); ide_buffer_manager_load_file_async (bufmgr, lookup.file, FALSE, IDE_WORKBENCH_OPEN_FLAGS_NONE, NULL, NULL, ide_editor_perspective_focus_location_cb, state); IDE_EXIT; } line = ide_source_location_get_line (location); line_offset = ide_source_location_get_line_offset (location); stack = gtk_widget_get_ancestor (GTK_WIDGET (lookup.view), IDE_TYPE_LAYOUT_STACK); ide_layout_stack_set_visible_child (IDE_LAYOUT_STACK (stack), IDE_LAYOUT_VIEW (lookup.view)); ide_editor_view_scroll_to_line_offset (lookup.view, line, line_offset); IDE_EXIT; }