static void ide_omni_bar_update (IdeOmniBar *self) { g_autofree gchar *branch_name = NULL; const gchar *project_name = NULL; IdeContext *context; g_assert (IDE_IS_OMNI_BAR (self)); context = ide_widget_get_context (GTK_WIDGET (self)); if (IDE_IS_CONTEXT (context)) { IdeProject *project; IdeVcs *vcs; project = ide_context_get_project (context); project_name = ide_project_get_name (project); vcs = ide_context_get_vcs (context); branch_name = ide_vcs_get_branch_name (vcs); } gtk_label_set_label (self->project_label, project_name); gtk_label_set_label (self->branch_label, branch_name); gtk_label_set_label (self->popover_branch_label, branch_name); }
static IdeProjectFile * create_file (IdeContext *context, GFile *file, GFileType file_type) { g_autofree gchar *path = NULL; g_autofree gchar *name = NULL; g_autoptr(GFileInfo) file_info = NULL; IdeVcs *vcs; GFile *workdir; g_assert (IDE_IS_CONTEXT (context)); g_assert (G_IS_FILE (file)); g_assert ((file_type == G_FILE_TYPE_DIRECTORY) || (file_type == G_FILE_TYPE_REGULAR)); vcs = ide_context_get_vcs (context); workdir = ide_vcs_get_working_directory (vcs); path = g_file_get_relative_path (workdir, file); name = g_file_get_basename (file); file_info = g_file_info_new (); g_file_info_set_file_type (file_info, file_type); g_file_info_set_name (file_info, name); g_file_info_set_display_name (file_info, name); return g_object_new (IDE_TYPE_PROJECT_FILE, "context", context, "file", file, "file-info", file_info, "path", path, "parent", NULL, NULL); }
void gb_project_tree_set_context (GbProjectTree *self, IdeContext *context) { GtkTreeModel *model; GtkTreeIter iter; IdeTreeNode *root; g_return_if_fail (GB_IS_PROJECT_TREE (self)); g_return_if_fail (!context || IDE_IS_CONTEXT (context)); model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); root = ide_tree_node_new (); ide_tree_node_set_item (root, G_OBJECT (context)); ide_tree_set_root (IDE_TREE (self), root); /* * If we only have one toplevel item (underneath root), expand it. */ if ((gtk_tree_model_iter_n_children (model, NULL) == 1) && gtk_tree_model_get_iter_first (model, &iter)) { g_autoptr(IdeTreeNode) node = NULL; gtk_tree_model_get (model, &iter, 0, &node, -1); if (node != NULL) ide_tree_node_expand (node, FALSE); } }
/** * ide_context_addin_project_loaded: * @self: an #IdeContextAddin * @context: an #IdeContext * * Emits the #IdeContextAddin::project-loaded signal. * * This is called when the context has completed loading a project. * * Since: 3.32 */ void ide_context_addin_project_loaded (IdeContextAddin *self, IdeContext *context) { g_return_if_fail (IDE_IS_CONTEXT_ADDIN (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); g_signal_emit (self, signals [PROJECT_LOADED], 0, context); }
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)); } }
static void do_run_async (IdeRunManager *self, GTask *task) { IdeBuildTarget *build_target; IdeContext *context; IdeConfigurationManager *config_manager; IdeConfiguration *config; IdeRuntime *runtime; g_autoptr(IdeRunner) runner = NULL; GCancellable *cancellable; g_assert (IDE_IS_RUN_MANAGER (self)); g_assert (G_IS_TASK (task)); build_target = g_task_get_task_data (task); context = ide_object_get_context (IDE_OBJECT (self)); g_assert (IDE_IS_BUILD_TARGET (build_target)); g_assert (IDE_IS_CONTEXT (context)); config_manager = ide_context_get_configuration_manager (context); config = ide_configuration_manager_get_current (config_manager); runtime = ide_configuration_get_runtime (config); if (runtime == NULL) { g_task_return_new_error (task, IDE_RUNTIME_ERROR, IDE_RUNTIME_ERROR_NO_SUCH_RUNTIME, "%s “%s”", _("Failed to locate runtime"), ide_configuration_get_runtime_id (config)); IDE_EXIT; } runner = ide_runtime_create_runner (runtime, build_target); cancellable = g_task_get_cancellable (task); g_assert (IDE_IS_RUNNER (runner)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); /* * If the current handler has a callback specified (our default "run" handler * does not), then we need to allow that handler to prepare the runner. */ if (self->handler != NULL && self->handler->handler != NULL) self->handler->handler (self, runner, self->handler->handler_data); g_signal_emit (self, signals [RUN], 0, runner); ide_runner_run_async (runner, cancellable, ide_run_manager_run_cb, g_object_ref (task)); }
/** * ide_context_addin_unload: * @self: an #IdeContextAddin * @context: an #IdeContext * * Requests that the #IdeContextAddin unloads any previously loaded * resources. * * Since: 3.32 */ void ide_context_addin_unload (IdeContextAddin *self, IdeContext *context) { g_return_if_fail (IDE_IS_CONTEXT_ADDIN (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); if (IDE_CONTEXT_ADDIN_GET_IFACE (self)->unload) IDE_CONTEXT_ADDIN_GET_IFACE (self)->unload (self, context); }
void gb_project_tree_set_context (GbProjectTree *self, IdeContext *context) { GtkTreeModel *model; GtkTreeIter iter; IdeTreeNode *root; IdeProject *project; IdeVcs *vcs; g_return_if_fail (GB_IS_PROJECT_TREE (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); vcs = ide_context_get_vcs (context); g_signal_connect_object (vcs, "changed", G_CALLBACK (gb_project_tree_vcs_changed), self, G_CONNECT_SWAPPED); project = ide_context_get_project (context); g_signal_connect_object (project, "file-renamed", G_CALLBACK (gb_project_tree_project_file_renamed), self, G_CONNECT_SWAPPED); g_signal_connect_object (project, "file-trashed", G_CALLBACK (gb_project_tree_project_file_trashed), self, G_CONNECT_SWAPPED); model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); root = ide_tree_node_new (); ide_tree_node_set_item (root, G_OBJECT (context)); ide_tree_set_root (IDE_TREE (self), root); /* * If we only have one toplevel item (underneath root), expand it. */ if ((gtk_tree_model_iter_n_children (model, NULL) == 1) && gtk_tree_model_get_iter_first (model, &iter)) { g_autoptr(IdeTreeNode) node = NULL; gtk_tree_model_get (model, &iter, 0, &node, -1); if (node != NULL) ide_tree_node_expand (node, FALSE); } }
static gboolean restore_in_timeout (gpointer data) { g_autoptr(IdeContext) context = data; g_assert (IDE_IS_CONTEXT (context)); ide_context_restore_async (context, NULL, NULL, NULL); return G_SOURCE_REMOVE; }
static void ide_mingw_device_provider_discover_worker (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { IdeMingwDeviceProvider *self = source_object; GPtrArray *devices; IdeContext *context; g_assert (G_IS_TASK (task)); g_assert (IDE_IS_MINGW_DEVICE_PROVIDER (self)); devices = g_ptr_array_new_with_free_func (g_object_unref); context = ide_object_get_context (IDE_OBJECT (self)); g_assert (IDE_IS_CONTEXT (context)); /* * FIXME: * * I'm almost certain this is not the proper way to check for mingw support. * Someone that knows how this works, please fix this up! */ if (g_file_test ("/usr/bin/x86_64-w64-mingw32-gcc", G_FILE_TEST_EXISTS)) { IdeDevice *device; /* add 64-bit mingw device */ device = ide_mingw_device_new (context, _("MinGW 64-bit"), "local-x86_64-w64-mingw32", "x86_64-w64-mingw32"); g_ptr_array_add (devices, device); } if (g_file_test ("/usr/bin/i686-w64-mingw32-gcc", G_FILE_TEST_EXISTS)) { IdeDevice *device; /* add 32-bit mingw device */ device = ide_mingw_device_new (context, _("MinGW 32-bit"), "local-i686-w64-mingw32", "i686-w64-mingw32"); g_ptr_array_add (devices, device); } g_task_return_pointer (task, devices, (GDestroyNotify)g_ptr_array_unref); ide_object_release (IDE_OBJECT (self)); }
static void ide_terminal_page_context_set (GtkWidget *widget, IdeContext *context) { IdeTerminalPage *self = (IdeTerminalPage *)widget; g_assert (IDE_IS_TERMINAL_PAGE (self)); g_assert (!context || IDE_IS_CONTEXT (context)); if (self->launcher == NULL && context != NULL) self->launcher = ide_terminal_launcher_new (context); }
/** * ide_file_new: * @context: (allow-none): An #IdeContext or %NULL. * @file: a #GFile. * * Creates a new file. * * Returns: (transfer full): An #IdeFile. */ IdeFile * ide_file_new (IdeContext *context, GFile *file) { g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL); g_return_val_if_fail (G_IS_FILE (file), NULL); return g_object_new (IDE_TYPE_FILE, "context", context, "file", file, NULL); }
/** * ide_context_addin_load_project_async: * @self: an #IdeContextAddin * @context: an #IdeContext * @cancellable: (nullable): a #GCancellable or %NULL * @callback: a callback to execute upon completion * @user_data: closure data for @callback * * Requests to load a project with the #IdeContextAddin. * * This function is called when the #IdeContext requests loading a project. * * Since: 3.32 */ void ide_context_addin_load_project_async (IdeContextAddin *self, IdeContext *context, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_return_if_fail (IDE_IS_CONTEXT_ADDIN (self)); g_return_if_fail (IDE_IS_CONTEXT (context)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); IDE_CONTEXT_ADDIN_GET_IFACE (self)->load_project_async (self, context, cancellable, callback, user_data); }
IdeSourceLocation * ide_source_location_new_for_path (IdeContext *context, const gchar *path, guint line, guint line_offset) { g_autoptr(IdeFile) ifile = NULL; g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL); ifile = ide_file_new_for_path (context, path); return ide_source_location_new (ifile, line, line_offset, 0); }
IdeContext * gb_project_tree_get_context (GbProjectTree *self) { IdeTreeNode *root; GObject *item; g_return_val_if_fail (GB_IS_PROJECT_TREE (self), NULL); if ((root = ide_tree_get_root (IDE_TREE (self))) && (item = ide_tree_node_get_item (root)) && IDE_IS_CONTEXT (item)) return IDE_CONTEXT (item); return NULL; }
IdeContext * gb_widget_get_context (GtkWidget *widget) { GbWorkbench *workbench; IdeContext *context = NULL; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); if ((workbench = gb_widget_get_workbench (widget))) context = gb_workbench_get_context (workbench); g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL); return context; }
static void gb_project_tree_builder_build_node (IdeTreeBuilder *builder, IdeTreeNode *node) { GbProjectTreeBuilder *self = (GbProjectTreeBuilder *)builder; GObject *item; g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self)); item = ide_tree_node_get_item (node); if (IDE_IS_CONTEXT (item)) build_context (self, node); else if (GB_IS_PROJECT_FILE (item)) build_file (self, node); }
static void gb_view_stack_on_workbench_unload (GbWorkbench *workbench, IdeContext *context, GbViewStack *self) { IdeBackForwardList *back_forward_list; g_assert (GB_IS_WORKBENCH (workbench)); g_assert (IDE_IS_CONTEXT (context)); g_assert (GB_IS_VIEW_STACK (self)); if (self->back_forward_list) { back_forward_list = ide_context_get_back_forward_list (context); ide_back_forward_list_merge (back_forward_list, self->back_forward_list); } }
void gb_project_tree_reveal (GbProjectTree *self, GFile *file) { g_autofree gchar *relpath = NULL; g_auto(GStrv) parts = NULL; IdeContext *context; IdeTreeNode *node; IdeVcs *vcs; GFile *workdir; guint i; g_return_if_fail (GB_IS_PROJECT_TREE (self)); g_return_if_fail (G_IS_FILE (file)); context = gb_project_tree_get_context (self); g_assert (IDE_IS_CONTEXT (context)); if (context == NULL) return; vcs = ide_context_get_vcs (context); workdir = ide_vcs_get_working_directory (vcs); relpath = g_file_get_relative_path (workdir, file); if (relpath == NULL) return; node = ide_tree_find_child_node (IDE_TREE (self), NULL, find_files_node, NULL); if (node == NULL) return; parts = g_strsplit (relpath, G_DIR_SEPARATOR_S, 0); for (i = 0; parts [i]; i++) { node = ide_tree_find_child_node (IDE_TREE (self), node, find_child_node, parts [i]); if (node == NULL) return; } ide_tree_expand_to_node (IDE_TREE (self), node); ide_tree_scroll_to_node (IDE_TREE (self), node); ide_tree_node_select (node); }
IdeFile * ide_file_new_for_path (IdeContext *context, const gchar *path) { g_autoptr(GFile) file = NULL; IdeFile *ret; g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL); g_return_val_if_fail (path != NULL, NULL); file = g_file_new_for_path (path); ret = g_object_new (IDE_TYPE_FILE, "context", context, "file", file, NULL); return ret; }
IdeConfiguration * ide_configuration_new (IdeContext *context, const gchar *id, const gchar *device_id, const gchar *runtime_id) { g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL); g_return_val_if_fail (id != NULL, NULL); g_return_val_if_fail (device_id != NULL, NULL); g_return_val_if_fail (runtime_id != NULL, NULL); return g_object_new (IDE_TYPE_CONFIGURATION, "context", context, "device-id", device_id, "id", id, "runtime-id", runtime_id, NULL); }
static void gb_view_stack_context_handler (GtkWidget *widget, IdeContext *context) { IdeBackForwardList *back_forward; GbViewStack *self = (GbViewStack *)widget; g_assert (GTK_IS_WIDGET (widget)); g_assert (!context || IDE_IS_CONTEXT (context)); if (context) { GList *children; GList *iter; ide_set_weak_pointer (&self->context, context); back_forward = ide_context_get_back_forward_list (context); g_clear_object (&self->back_forward_list); self->back_forward_list = ide_back_forward_list_branch (back_forward); g_signal_connect_object (self->back_forward_list, "navigate-to", G_CALLBACK (navigate_to_cb), self, G_CONNECT_SWAPPED); g_object_bind_property (self->back_forward_list, "can-go-backward", self->go_backward, "sensitive", G_BINDING_SYNC_CREATE); g_object_bind_property (self->back_forward_list, "can-go-forward", self->go_forward, "sensitive", G_BINDING_SYNC_CREATE); children = gtk_container_get_children (GTK_CONTAINER (self->stack)); for (iter = children; iter; iter = iter->next) gb_view_set_back_forward_list (iter->data, self->back_forward_list); g_list_free (children); } }
/** * ide_build_system_new_async: * @context: #IdeBuildSystem * @project_file: A #GFile containing the directory or project file. * @cancellable: (allow-none): A #GCancellable * @callback: A callback to execute upon completion * @user_data: User data for @callback. * * Asynchronously creates a new #IdeBuildSystem instance using the registered * #GIOExtensionPoint system. Each extension point will be tried asynchronously * by priority until one has been found that supports @project_file. * * If no build system could be found, then ide_build_system_new_finish() will * return %NULL. */ void ide_build_system_new_async (IdeContext *context, GFile *project_file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_return_if_fail (IDE_IS_CONTEXT (context)); g_return_if_fail (G_IS_FILE (project_file)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); ide_object_new_for_extension_async (IDE_TYPE_BUILD_SYSTEM, sort_priority, NULL, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "context", context, "project-file", project_file, NULL); }
static void ide_omni_bar_context_set (GtkWidget *widget, IdeContext *context) { IdeOmniBar *self = (IdeOmniBar *)widget; IdeConfigurationManager *config_manager = NULL; IdeBuildManager *build_manager = NULL; GListModel *pausables = NULL; IdeProject *project = NULL; IdeVcs *vcs = NULL; IDE_ENTRY; g_assert (IDE_IS_OMNI_BAR (self)); g_assert (!context || IDE_IS_CONTEXT (context)); ide_omni_bar_update (self); if (context != NULL) { vcs = ide_context_get_vcs (context); build_manager = ide_context_get_build_manager (context); config_manager = ide_context_get_configuration_manager (context); project = ide_context_get_project (context); pausables = _ide_context_get_pausables (context); } dzl_binding_group_set_source (self->build_manager_bindings, build_manager); dzl_signal_group_set_target (self->build_manager_signals, build_manager); dzl_binding_group_set_source (self->config_manager_bindings, config_manager); dzl_signal_group_set_target (self->config_manager_signals, config_manager); dzl_binding_group_set_source (self->project_bindings, project); dzl_binding_group_set_source (self->vcs_bindings, vcs); dzl_list_box_set_model (self->pausables, pausables); if (config_manager != NULL) ide_omni_bar__config_manager__notify_current (self, NULL, config_manager); IDE_EXIT; }
IdeSettings * _ide_settings_new (IdeContext *context, const gchar *schema_id, const gchar *relative_path, gboolean ignore_project_settings) { IdeSettings *ret; IDE_ENTRY; g_assert (IDE_IS_CONTEXT (context)); g_assert (schema_id != NULL); g_assert (relative_path != NULL); ret = g_object_new (IDE_TYPE_SETTINGS, "context", context, "ignore-project-settings", ignore_project_settings, "relative-path", relative_path, "schema-id", schema_id, NULL); IDE_RETURN (ret); }
void gb_project_tree_set_context (GbProjectTree *self, IdeContext *context) { GbTreeNode *root; IdeProject *project = NULL; GtkTreeModel *model; g_return_if_fail (GB_IS_PROJECT_TREE (self)); g_return_if_fail (!context || IDE_IS_CONTEXT (context)); if (context != NULL) project = ide_context_get_project (context); root = gb_tree_get_root (GB_TREE (self)); gb_tree_node_set_item (root, G_OBJECT (project)); gb_tree_rebuild (GB_TREE (self)); /* * If we only have one item at the root of the tree, expand it. */ if ((model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)))) { GtkTreeIter iter; if ((gtk_tree_model_iter_n_children (model, NULL) == 1) && gtk_tree_model_get_iter_first (model, &iter)) { g_autoptr(GbTreeNode) node = NULL; gtk_tree_model_get (model, &iter, 0, &node, -1); if (node != NULL) gb_tree_node_expand (node, FALSE); } } }
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; }
static void ide_back_forward_list_load_cb (GObject *object, GAsyncResult *result, gpointer user_data) { g_autoptr(GTask) task = user_data; g_autofree gchar *contents = NULL; g_auto(GStrv) lines = NULL; IdeBackForwardList *self; IdeContext *context; GError *error = NULL; GFile *file = (GFile *)object; gsize length = 0; gsize n_lines; gint i; g_assert (G_IS_FILE (file)); g_assert (G_IS_TASK (task)); self = g_task_get_source_object (task); g_assert (IDE_IS_BACK_FORWARD_LIST (self)); context = ide_object_get_context (IDE_OBJECT (self)); g_assert (IDE_IS_CONTEXT (context)); if (!g_file_load_contents_finish (file, result, &contents, &length, NULL, &error)) { g_task_return_error (task, error); return; } if (length > (10 * 1024 * 1024)) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "Implausible file size discovered"); return; } if (!g_utf8_validate (contents, length, NULL)) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "The content was not UTF-8 formatted"); return; } lines = g_strsplit (contents, "\n", 0); n_lines = g_strv_length (lines); for (i = n_lines; i > 0; i--) { const gchar *line = lines [i - 1]; g_autoptr(IdeUri) uri = NULL; g_autoptr(IdeBackForwardItem) item = NULL; g_autofree gchar *new_style_uri = NULL; char *old_style_uri = NULL; guint lineno = 0; guint line_offset = 0; if (ide_str_empty0 (line)) continue; /* Convert from old style "LINE OFFSET URI" to new-style "URI". */ if (3 == sscanf (line, "%u %u %ms", &lineno, &line_offset, &old_style_uri)) { line = new_style_uri = g_strdup_printf ("%s#L%u_%u", old_style_uri, lineno, line_offset); free (old_style_uri); } uri = ide_uri_new (line, 0, &error); if (uri == NULL) { g_task_return_error (task, error); return; } item = ide_back_forward_item_new (context, uri); ide_back_forward_list_push (self, item); } g_task_return_boolean (task, TRUE); }
static void gbp_flatpak_dependency_updater_update_async (IdeDependencyUpdater *updater, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GbpFlatpakDependencyUpdater *self = (GbpFlatpakDependencyUpdater *)updater; GbpFlatpakDownloadStage *stage = NULL; g_autoptr(GTask) task = NULL; IdeBuildPipeline *pipeline; IdeBuildManager *manager; IdeContext *context; g_assert (GBP_IS_FLATPAK_DEPENDENCY_UPDATER (self)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, gbp_flatpak_dependency_updater_update_async); g_task_set_priority (task, G_PRIORITY_LOW); context = ide_object_get_context (IDE_OBJECT (self)); g_assert (IDE_IS_CONTEXT (context)); manager = ide_context_get_build_manager (context); g_assert (IDE_IS_BUILD_MANAGER (manager)); pipeline = ide_build_manager_get_pipeline (manager); g_assert (!pipeline || IDE_IS_BUILD_PIPELINE (pipeline)); if (pipeline == NULL) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "Cannot update flatpak dependencies until build pipeline is initialized"); return; } /* Find the downloads stage and tell it to download updates one time */ ide_build_pipeline_foreach_stage (pipeline, find_download_stage_cb, &stage); if (stage == NULL) { /* Synthesize success if they weren't using flatpak. */ g_task_return_boolean (task, TRUE); return; } gbp_flatpak_download_stage_force_update (stage); /* Ensure downloads and everything past it is invalidated */ ide_build_pipeline_invalidate_phase (pipeline, IDE_BUILD_PHASE_DOWNLOADS); /* Start building all the way up to the project configure so that * the user knows if the updates broke their configuration or anything. */ ide_build_manager_rebuild_async (manager, IDE_BUILD_PHASE_CONFIGURE, NULL, gbp_flatpak_dependency_updater_update_cb, g_steal_pointer (&task)); }