static void ide_layout_stack_actions_previous_view (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeLayoutStack *self = user_data; GtkWidget *active_view; GtkWidget *new_view; IDE_ENTRY; g_assert (IDE_IS_LAYOUT_STACK (self)); active_view = ide_layout_stack_get_active_view (self); if (active_view == NULL || !IDE_IS_LAYOUT_VIEW (active_view)) return; if (g_list_length (self->focus_history) <= 1) return; g_assert (active_view); g_assert (self->focus_history); g_assert (self->focus_history->next); g_assert (active_view == self->focus_history->data); new_view = self->focus_history->next->data; g_assert (IDE_IS_LAYOUT_VIEW (new_view)); self->focus_history = g_list_remove_link (self->focus_history, self->focus_history); self->focus_history = g_list_append (self->focus_history, active_view); ide_layout_stack_set_active_view (self, new_view); IDE_EXIT; }
static void ide_editor_perspective_find_source_location (GtkWidget *widget, gpointer user_data) { struct { IdeFile *file; IdeEditorView *view; } *lookup = user_data; IdeBuffer *buffer; IdeFile *file; g_return_if_fail (IDE_IS_LAYOUT_VIEW (widget)); if (lookup->view != NULL) return; if (!IDE_IS_EDITOR_VIEW (widget)) return; buffer = ide_editor_view_get_buffer (IDE_EDITOR_VIEW (widget)); file = ide_buffer_get_file (buffer); if (ide_file_equal (file, lookup->file)) lookup->view = IDE_EDITOR_VIEW (widget); }
static void ide_layout_stack_actions_close (GSimpleAction *action, GVariant *param, gpointer user_data) { g_autoptr(GTask) task = NULL; IdeLayoutStack *self = user_data; GtkWidget *active_view; struct { IdeLayoutStack *self; GtkWidget *active_view; } *pair; g_assert (IDE_IS_LAYOUT_STACK (self)); active_view = ide_layout_stack_get_active_view (self); if (active_view == NULL || !IDE_IS_LAYOUT_VIEW (active_view)) return; /* * Queue until we are out of this potential signalaction. (Which mucks things * up since it expects the be able to continue working with the widget). */ pair = g_slice_alloc (sizeof *pair); pair->self = g_object_ref (self); pair->active_view = g_object_ref (active_view); g_timeout_add (0, ide_layout_stack_actions_close_cb, pair); }
static gboolean ide_layout_stack_actions_close_cb (gpointer data) { struct { IdeLayoutStack *self; GtkWidget *active_view; } *pair = data; g_assert (pair != NULL); g_assert (IDE_IS_LAYOUT_STACK (pair->self)); g_assert (IDE_IS_LAYOUT_VIEW (pair->active_view)); ide_layout_stack_remove (pair->self, GTK_WIDGET (pair->active_view)); /* * Force the view to destroy. This helps situation where plugins are holding * onto a reference that can't easily be broken automatically. */ gtk_widget_destroy (GTK_WIDGET (pair->active_view)); g_object_unref (pair->self); g_object_unref (pair->active_view); g_slice_free1 (sizeof *pair, pair); return G_SOURCE_REMOVE; }
/** * ide_layout_view_set_split_view: * @self: A #IdeLayoutView. * @split_view: if the split should be enabled. * * Set a split view using GtkPaned style split with %GTK_ORIENTATION_VERTICAL. */ void ide_layout_view_set_split_view (IdeLayoutView *self, gboolean split_view) { g_return_if_fail (IDE_IS_LAYOUT_VIEW (self)); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->set_split_view) IDE_LAYOUT_VIEW_GET_CLASS (self)->set_split_view (self, split_view); }
static gboolean gb_vim_command_vsplit (GtkWidget *active_widget, const gchar *command, const gchar *options, GError **error) { IdeWorkbench *workbench; IdeContext *context; IdeVcs *vcs; GFile *workdir; GFile *file = NULL; gchar *file_path; SplitCallbackData *split_callback_data; GVariant *variant; g_assert (GTK_IS_WIDGET (active_widget)); if (!IDE_IS_LAYOUT_VIEW (active_widget)) return gb_vim_set_no_view_error (error); if (ide_str_empty0 (options)) { variant = g_variant_new_string (""); ide_widget_action (GTK_WIDGET (active_widget), "view-stack", "split-left", variant); } else { if (!(workbench = ide_widget_get_workbench (active_widget)) || !(context = ide_workbench_get_context (workbench)) || !(vcs = ide_context_get_vcs (context)) || !(workdir = ide_vcs_get_working_directory (vcs))) { g_set_error (error, GB_VIM_ERROR, GB_VIM_ERROR_NOT_SOURCE_VIEW, _("Failed to locate working directory")); return FALSE; } file_path = g_strdup (options); if (!g_path_is_absolute (file_path)) file_path = g_build_filename (g_file_get_path (workdir), file_path, NULL); file = g_file_new_for_path (file_path); split_callback_data = g_slice_new (SplitCallbackData); split_callback_data->active_widget = g_object_ref (active_widget); split_callback_data->file_path = file_path; ide_workbench_open_files_async (workbench, &file, 1, "editor", IDE_WORKBENCH_OPEN_FLAGS_BACKGROUND, NULL, gb_vim_command_vsplit_cb, split_callback_data); g_clear_object (&file); } return TRUE; }
gchar * ide_layout_view_get_title (IdeLayoutView *self) { g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), NULL); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->get_title) return IDE_LAYOUT_VIEW_GET_CLASS (self)->get_title (self); return g_strdup (_("untitled document")); }
void ide_layout_view_set_back_forward_list (IdeLayoutView *self, IdeBackForwardList *back_forward_list) { g_return_if_fail (IDE_IS_LAYOUT_VIEW (self)); g_return_if_fail (IDE_IS_BACK_FORWARD_LIST (back_forward_list)); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->set_back_forward_list) IDE_LAYOUT_VIEW_GET_CLASS (self)->set_back_forward_list (self, back_forward_list); }
void ide_layout_view_navigate_to (IdeLayoutView *self, IdeSourceLocation *location) { g_return_if_fail (IDE_IS_LAYOUT_VIEW (self)); g_return_if_fail (location != NULL); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->navigate_to) IDE_LAYOUT_VIEW_GET_CLASS (self)->navigate_to (self, location); }
gboolean ide_layout_view_agree_to_close (IdeLayoutView *self) { g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), FALSE); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->agree_to_close) return IDE_LAYOUT_VIEW_GET_CLASS (self)->agree_to_close (self); return TRUE; }
/** * ide_layout_view_get_can_split: * @self: A #IdeLayoutView. * * Checks if @self can create a split view. If so, %TRUE is returned. Otherwise, %FALSE. * * Returns: %TRUE if @self can create a split. */ gboolean ide_layout_view_get_can_split (IdeLayoutView *self) { g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), FALSE); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->get_can_split) return IDE_LAYOUT_VIEW_GET_CLASS (self)->get_can_split (self); return FALSE; }
/** * ide_editor_addin_view_set: * @self: an #IdeEditorAddin * @view: (nullable): an #IdeLayoutView or %NULL * * This function is called when the current view has changed in the * editor perspective. This could happen when the user focus another * view, either with the keyboard, mouse, touch, or by opening a new * buffer. * * Note that @view may not be an #IdeEditorView, so consumers of this * interface should take appropriate action based on the type. * * When the last view is removed, @view will be %NULL to indicate to the * addin that there is no active view. * * Since: 3.26 */ void ide_editor_addin_view_set (IdeEditorAddin *self, IdeLayoutView *view) { g_return_if_fail (IDE_IS_EDITOR_ADDIN (self)); g_return_if_fail (!view || IDE_IS_LAYOUT_VIEW (view)); if (IDE_EDITOR_ADDIN_GET_IFACE (self)->view_set) IDE_EDITOR_ADDIN_GET_IFACE (self)->view_set (self, view); }
static void do_split_down_cb (GObject *object, GAsyncResult *result, gpointer user_data) { IdeLayoutView *view = (IdeLayoutView *)object; g_assert (IDE_IS_LAYOUT_VIEW (view)); ide_layout_view_set_split_view (view, !ide_layout_view_get_split_view (view)); }
/** * ide_layout_view_create_split: * @self: A #IdeLayoutView. * @file: A #GFile already loaded by the #IdeBufferManager, or %NULL to use the * existing buffer. * * Creates a new view that can be displayed in a split, potentially with a different * buffer. If the view does not support splits, %NULL will be returned. * * Returns: (transfer full): A #IdeLayoutView. */ IdeLayoutView * ide_layout_view_create_split (IdeLayoutView *self, GFile *file) { g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), NULL); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->create_split) return IDE_LAYOUT_VIEW_GET_CLASS (self)->create_split (self, file); return NULL; }
static void ide_editor_view_set_back_forward_list (IdeLayoutView *view, IdeBackForwardList *back_forward_list) { IdeEditorView *self = (IdeEditorView *)view; g_assert (IDE_IS_LAYOUT_VIEW (view)); g_assert (IDE_IS_BACK_FORWARD_LIST (back_forward_list)); g_object_set (self->frame1, "back-forward-list", back_forward_list, NULL); if (self->frame2) g_object_set (self->frame2, "back-forward-list", back_forward_list, NULL); }
static void ide_editor_perspective_add (GtkContainer *container, GtkWidget *widget) { IdeEditorPerspective *self = (IdeEditorPerspective *)container; g_assert (IDE_IS_EDITOR_PERSPECTIVE (self)); g_assert (GTK_IS_WIDGET (widget)); if (IDE_IS_LAYOUT_VIEW (widget)) gtk_container_add (GTK_CONTAINER (self->grid), widget); else GTK_CONTAINER_CLASS (ide_editor_perspective_parent_class)->add (container, widget); }
static gboolean gb_vim_command_split (GtkWidget *active_widget, const gchar *command, const gchar *options, GError **error) { g_assert (GTK_IS_WIDGET (active_widget)); if (IDE_IS_LAYOUT_VIEW (active_widget)) ide_widget_action (GTK_WIDGET (active_widget), "view-stack", "split-down", NULL); else return gb_vim_set_no_view_error (error); return TRUE; }
/* * TODO: * * This function is a hack in place for 3.18 until we get the path bar * which will provide a better view of file paths. It should be removed * after 3.18 when path bar lands. Also remove the "special-title" * property. */ gchar * ide_layout_view_get_special_title (IdeLayoutView *self) { gchar *ret = NULL; g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), NULL); if (IDE_LAYOUT_VIEW_GET_CLASS (self)->get_special_title) ret = IDE_LAYOUT_VIEW_GET_CLASS (self)->get_special_title (self); if (ret == NULL) ret = ide_layout_view_get_title (self); return ret; }
static void ide_layout_stack_actions_move_left (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeLayoutStack *self = user_data; GtkWidget *active_view; g_assert (IDE_IS_LAYOUT_STACK (self)); active_view = ide_layout_stack_get_active_view (self); if (active_view == NULL || !IDE_IS_LAYOUT_VIEW (active_view)) return; g_signal_emit_by_name (self, "split", active_view, IDE_LAYOUT_GRID_SPLIT_MOVE_LEFT, NULL); }
static void ide_editor_perspective_addins_view_set (PeasExtensionSet *set, PeasPluginInfo *plugin_info, PeasExtension *exten, gpointer user_data) { IdeEditorAddin *addin = (IdeEditorAddin *)exten; IdeLayoutView *view = user_data; g_assert (PEAS_IS_EXTENSION_SET (set)); g_assert (plugin_info != NULL); g_assert (IDE_IS_EDITOR_ADDIN (addin)); g_assert (!view || IDE_IS_LAYOUT_VIEW (view)); ide_editor_addin_view_set (addin, view); }
static void ide_layout_stack_actions_split_down (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeLayoutStack *self = user_data; GtkWidget *active_view; g_autoptr(GTask) task = NULL; g_assert (IDE_IS_LAYOUT_STACK (self)); active_view = ide_layout_stack_get_active_view (self); if (!IDE_IS_LAYOUT_VIEW (active_view)) return; task = g_task_new (active_view, NULL, do_split_down_cb, NULL); g_task_return_boolean (task, TRUE); }
static gboolean gb_vim_command_vsplit (GtkWidget *active_widget, const gchar *command, const gchar *options, GError **error) { GVariant *variant; g_assert (GTK_IS_WIDGET (active_widget)); if (!IDE_IS_LAYOUT_VIEW (active_widget)) return gb_vim_set_no_view_error (error); if (dzl_str_empty0 (options)) { variant = g_variant_new_string (""); dzl_gtk_widget_action (GTK_WIDGET (active_widget), "layoutstack", "open-in-new-frame", variant); return TRUE; } else return load_split_async (active_widget, options, gb_vim_command_vsplit_cb, error); }
static void ide_layout_stack_actions_split_left (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeLayoutStack *self = user_data; GtkWidget *active_view; const gchar *file_path; g_autoptr(GFile) file = NULL; g_assert (IDE_IS_LAYOUT_STACK (self)); active_view = ide_layout_stack_get_active_view (self); if (active_view == NULL || !IDE_IS_LAYOUT_VIEW (active_view)) return; file_path = g_variant_get_string (param, NULL); if (ide_str_empty0 (file_path)) file = NULL; else file = g_file_new_for_path (file_path); g_signal_emit_by_name (self, "split", active_view, IDE_LAYOUT_GRID_SPLIT_LEFT, file); }