void ide_workbench_set_visible_perspective (IdeWorkbench *self, IdePerspective *perspective) { GActionGroup *actions; GtkStack *stack; gchar *id; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_PERSPECTIVE (perspective)); stack = GTK_STACK (gtk_widget_get_ancestor (GTK_WIDGET (perspective), GTK_TYPE_STACK)); id = ide_perspective_get_id (perspective); if (!ide_str_equal0 (gtk_stack_get_visible_child_name (stack), id)) { gtk_stack_set_visible_child_name (stack, id); gtk_stack_set_visible_child_name (self->titlebar_stack, id); } g_free (id); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); if ((stack == self->perspectives_stack) && !ide_str_equal0 (gtk_stack_get_visible_child_name (self->top_stack), "perspectives")) { gtk_stack_set_visible_child_name (self->top_stack, "perspectives"); g_timeout_add (1000 + gtk_stack_get_transition_duration (self->top_stack), remove_early_perspectives, g_object_ref (self)); } }
void ide_workbench_set_context (IdeWorkbench *self, IdeContext *context) { g_autoptr(GSettings) settings = NULL; IdeProject *project; guint duration; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); g_return_if_fail (self->context == NULL); settings = g_settings_new ("org.gnome.builder"); g_set_object (&self->context, context); project = ide_context_get_project (context); g_object_bind_property_full (project, "name", self, "title", G_BINDING_SYNC_CREATE, transform_title, NULL, NULL, NULL); self->addins = peas_extension_set_new (peas_engine_get_default (), IDE_TYPE_WORKBENCH_ADDIN, NULL); g_signal_connect (self->addins, "extension-added", G_CALLBACK (ide_workbench_addin_added), self); g_signal_connect (self->addins, "extension-removed", G_CALLBACK (ide_workbench_addin_removed), self); peas_extension_set_foreach (self->addins, ide_workbench_addin_added, self); /* * Creating all the addins above is a bit intenstive, so give ourselves * just a bit of time to stablize allocations and sizing before * transitioning to the editor. */ g_timeout_add (STABLIZE_DELAY_MSEC, stablize_cb, g_object_ref (self)); /* * When restoring, previous buffers may get loaded. This causes new * widgets to be created and added to the workspace. Doing so during * the stack transition results in non-smooth transitions. So instead, * we will delay until the transition has completed. */ if (g_settings_get_boolean (settings, "restore-previous-files")) { duration = gtk_stack_get_transition_duration (self->top_stack); g_timeout_add (STABLIZE_DELAY_MSEC + duration, restore_in_timeout, g_object_ref (context)); } }
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); }
void ide_workbench_set_context (IdeWorkbench *self, IdeContext *context) { g_autoptr(GSettings) settings = NULL; IdeBuildManager *build_manager; IdeRunManager *run_manager; IdeProject *project; guint delay_msec; IDE_ENTRY; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); g_return_if_fail (self->context == NULL); settings = g_settings_new ("org.gnome.builder"); g_set_object (&self->context, context); project = ide_context_get_project (context); g_object_bind_property_full (project, "name", self, "title", G_BINDING_SYNC_CREATE, transform_title, NULL, NULL, NULL); build_manager = ide_context_get_build_manager (context); gtk_widget_insert_action_group (GTK_WIDGET (self), "build-manager", G_ACTION_GROUP (build_manager)); run_manager = ide_context_get_run_manager (context); gtk_widget_insert_action_group (GTK_WIDGET (self), "run-manager", G_ACTION_GROUP (run_manager)); self->addins = peas_extension_set_new (peas_engine_get_default (), IDE_TYPE_WORKBENCH_ADDIN, NULL); g_signal_connect (self->addins, "extension-added", G_CALLBACK (ide_workbench_addin_added), self); g_signal_connect (self->addins, "extension-removed", G_CALLBACK (ide_workbench_addin_removed), self); peas_extension_set_foreach (self->addins, ide_workbench_addin_added, self); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONTEXT]); /* * Creating all the addins above is a bit intensive, so give ourselves * just a bit of time to stablize allocations and sizing before * transitioning to the editor. */ delay_msec = self->disable_greeter ? 0 : STABLIZE_DELAY_MSEC; g_timeout_add (delay_msec, stablize_cb, g_object_ref (self)); /* * When restoring, previous buffers may get loaded. This causes new * widgets to be created and added to the workspace. Doing so during * the stack transition results in non-smooth transitions. So instead, * we will delay until the transition has completed. */ if (g_settings_get_boolean (settings, "restore-previous-files")) { guint duration = 0; if (!self->disable_greeter) duration = gtk_stack_get_transition_duration (self->perspectives_stack); g_timeout_add (delay_msec + duration, restore_in_timeout, g_object_ref (context)); } IDE_EXIT; }