void ide_application_actions_init (IdeApplication *self) { static const gchar *left[] = { "F9", NULL }; static const gchar *right[] = { "<shift>F9", NULL }; static const gchar *bottom[] = { "<control>F9", NULL }; static const gchar *global_search[] = { "<control>period", NULL }; static const gchar *new_file[] = { "<control>n", NULL }; static const gchar *shortcuts[] = { "<control>F1", "<control><shift>question", NULL }; static const gchar *help[] = { "F1", NULL }; static const gchar *command_bar[] = { "<ctrl>Return", "<ctrl>KP_Enter", NULL }; static const gchar *build[] = { "<ctrl>F7", NULL }; g_action_map_add_action_entries (G_ACTION_MAP (self), IdeApplicationActions, G_N_ELEMENTS (IdeApplicationActions), self); /* * FIXME: Once we get a new shortcuts engine, port these to that. */ gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.help", help); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.shortcuts", shortcuts); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.bottom-visible", bottom); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.left-visible", left); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "dockbin.right-visible", right); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "perspective.new-file", new_file); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.global-search", global_search); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "win.show-command-bar", command_bar); gtk_application_set_accels_for_action (GTK_APPLICATION (self), "build-manager.build", build); ide_application_actions_update (self); }
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); }