/** * ide_workbench_get_perspective_by_name: * * Gets the perspective by it's registered name as defined in * ide_perspective_get_id(). * * Returns: (nullable) (transfer none): An #IdePerspective or %NULL. */ IdePerspective * ide_workbench_get_perspective_by_name (IdeWorkbench *self, const gchar *name) { GtkWidget *ret; g_return_val_if_fail (IDE_IS_WORKBENCH (self), NULL); g_return_val_if_fail (name != NULL, NULL); ret = gtk_stack_get_child_by_name (self->perspectives_stack, name); if (ret == NULL) ret = gtk_stack_get_child_by_name (self->top_stack, name); return IDE_PERSPECTIVE (ret); }
static gboolean remove_early_perspectives (gpointer data) { g_autoptr(IdeWorkbench) self = data; GtkWidget *widget; g_assert (IDE_IS_WORKBENCH (self)); widget = gtk_stack_get_child_by_name (self->top_stack, "greeter"); gtk_widget_destroy (widget); widget = gtk_stack_get_child_by_name (self->top_stack, "genesis"); gtk_widget_destroy (widget); return G_SOURCE_REMOVE; }
static gboolean demand_attention (gpointer stack) { GtkWidget *page; page = gtk_stack_get_child_by_name (GTK_STACK (stack), "page3"); set_needs_attention (page, TRUE); return G_SOURCE_REMOVE; }
static void gtk_shortcuts_window_forall (GtkContainer *container, gboolean include_internal, GtkCallback callback, gpointer callback_data) { GtkShortcutsWindow *self = (GtkShortcutsWindow *)container; GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); if (include_internal) { if (priv->header_bar) callback (GTK_WIDGET (priv->header_bar), callback_data); if (priv->main_box) callback (GTK_WIDGET (priv->main_box), callback_data); if (priv->popover) callback (GTK_WIDGET (priv->popover), callback_data); } if (priv->stack) { GList *children, *l; GtkWidget *search; GtkWidget *empty; search = gtk_stack_get_child_by_name (GTK_STACK (priv->stack), "internal-search"); empty = gtk_stack_get_child_by_name (GTK_STACK (priv->stack), "no-search-results"); children = gtk_container_get_children (GTK_CONTAINER (priv->stack)); for (l = children; l; l = l->next) { GtkWidget *child = l->data; if (include_internal || (child != search && child != empty)) callback (child, callback_data); } g_list_free (children); } }
static void gtk_shortcuts_window_set_section_name (GtkShortcutsWindow *self, const gchar *section_name) { GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); GtkWidget *section = NULL; g_free (priv->initial_section); priv->initial_section = g_strdup (section_name); if (!section_name) section = gtk_stack_get_child_by_name (priv->stack, section_name); if (section) gtk_stack_set_visible_child (priv->stack, section); }
void ide_workbench_remove_perspective (IdeWorkbench *self, IdePerspective *perspective) { const gchar *id; GtkWidget *titlebar; g_assert (IDE_IS_WORKBENCH (self)); g_assert (IDE_IS_PERSPECTIVE (perspective)); g_assert (gtk_widget_get_parent (GTK_WIDGET (perspective)) == GTK_WIDGET (self->perspectives_stack)); id = ide_perspective_get_id (perspective); titlebar = gtk_stack_get_child_by_name (self->titlebar_stack, id); gtk_container_remove (GTK_CONTAINER (self->titlebar_stack), titlebar); gtk_container_remove (GTK_CONTAINER (self->perspectives_stack), GTK_WIDGET (perspective)); }
void ide_workbench_set_visible_perspective (IdeWorkbench *self, IdePerspective *perspective) { g_autofree gchar *id = NULL; GActionGroup *actions = NULL; const gchar *current_id; GtkWidget *titlebar; guint restore_duration = 0; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_PERSPECTIVE (perspective)); /* * If we can detect that this is the first transition to the editor, * and that our window is not yet displayed, we can avoid the transition * duration altogether. This is handy when first opening a window with * a project loaded, as used by self->disable_greeter. */ if (self->disable_greeter && IDE_IS_EDITOR_PERSPECTIVE (perspective) && !self->did_initial_editor_transition) { self->did_initial_editor_transition = TRUE; restore_duration = gtk_stack_get_transition_duration (self->perspectives_stack); gtk_stack_set_transition_duration (self->perspectives_stack, 0); } current_id = gtk_stack_get_visible_child_name (self->perspectives_stack); id = ide_perspective_get_id (perspective); if (!ide_str_equal0 (current_id, id)) gtk_stack_set_visible_child_name (self->perspectives_stack, id); titlebar = gtk_stack_get_child_by_name (self->header_stack, id); if (titlebar != NULL) gtk_stack_set_visible_child (self->header_stack, titlebar); else gtk_stack_set_visible_child (self->header_stack, GTK_WIDGET (self->header_bar)); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); /* * If we are transitioning to the editor the first time, we can * remove the early perspectives (greeter, etc). */ if (IDE_IS_EDITOR_PERSPECTIVE (perspective)) remove_early_perspectives (self); gtk_widget_set_visible (GTK_WIDGET (self->perspective_menu_button), !ide_perspective_is_early (perspective)); if (self->addins != NULL) peas_extension_set_foreach (self->addins, ide_workbench_notify_perspective_set, perspective); g_clear_object (&actions); if (restore_duration != 0) gtk_stack_set_transition_duration (self->perspectives_stack, restore_duration); /* Notify the application to possibly update actions such * as the preferences state. */ ide_application_actions_update (IDE_APPLICATION_DEFAULT); }