static void ide_file_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { IdeFile *self = (IdeFile *)object; switch (prop_id) { case PROP_FILE: g_value_set_object (value, ide_file_get_file (self)); break; case PROP_IS_TEMPORARY: g_value_set_boolean (value, ide_file_get_is_temporary (self)); break; case PROP_LANGUAGE: g_value_set_object (value, ide_file_get_language (self)); break; case PROP_PATH: g_value_set_string (value, ide_file_get_path (self)); break; case PROP_TEMPORARY_ID: g_value_set_uint (value, ide_file_get_temporary_id (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
/** * ide_clang_service_get_translation_unit_async: * * This function is used to asynchronously retrieve the translation unit for * a particular file. * * If the translation unit is up to date, then no parsing will occur and the * existing translation unit will be used. * * If the translation unit is out of date, then the source file(s) will be * parsed via clang_parseTranslationUnit() asynchronously. */ void ide_clang_service_get_translation_unit_async (IdeClangService *self, IdeFile *file, gint64 min_serial, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeClangTranslationUnit *cached; g_autoptr(GTask) task = NULL; g_return_if_fail (IDE_IS_CLANG_SERVICE (self)); g_return_if_fail (IDE_IS_FILE (file)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); /* * Clang likes to crash on our temporary files. */ if (ide_file_get_is_temporary (file)) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "File does not yet exist, ignoring translation unit request."); return; } if (min_serial == 0) { IdeContext *context; IdeUnsavedFiles *unsaved_files; context = ide_object_get_context (IDE_OBJECT (self)); unsaved_files = ide_context_get_unsaved_files (context); min_serial = ide_unsaved_files_get_sequence (unsaved_files); } /* * If we have a cached unit, and it is new enough, then re-use it. */ if ((cached = egg_task_cache_peek (self->units_cache, file)) && (ide_clang_translation_unit_get_serial (cached) >= min_serial)) { g_task_return_pointer (task, g_object_ref (cached), g_object_unref); return; } egg_task_cache_get_async (self->units_cache, file, TRUE, cancellable, ide_clang_service_get_translation_unit_cb, g_object_ref (task)); }
static void ide_editor_view_actions_save (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeEditorView *self = user_data; IdeContext *context; IdeBufferManager *buffer_manager; IdeFile *file; IdeProgress *progress = NULL; IdeVcs *vcs; GFile *workdir; g_assert (IDE_IS_EDITOR_VIEW (self)); file = ide_buffer_get_file (IDE_BUFFER (self->document)); context = ide_buffer_get_context (IDE_BUFFER (self->document)); buffer_manager = ide_context_get_buffer_manager (context); vcs = ide_context_get_vcs (context); workdir = ide_vcs_get_working_directory (vcs); if (ide_file_get_is_temporary (file)) { GtkDialog *dialog; GtkWidget *toplevel; GtkWidget *suggested; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self)); dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG, "action", GTK_FILE_CHOOSER_ACTION_SAVE, "do-overwrite-confirmation", TRUE, "local-only", FALSE, "modal", TRUE, "select-multiple", FALSE, "show-hidden", FALSE, "transient-for", toplevel, "title", _("Save Document"), NULL); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), workdir, NULL); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Cancel"), GTK_RESPONSE_CANCEL, _("Save"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_style_context_add_class (gtk_widget_get_style_context (suggested), GTK_STYLE_CLASS_SUGGESTED_ACTION); g_signal_connect (dialog, "response", G_CALLBACK (save_temp_response), g_object_ref (self)); gtk_window_present (GTK_WINDOW (dialog)); return; } ide_buffer_manager_save_file_async (buffer_manager, IDE_BUFFER (self->document), file, &progress, NULL, save_file_cb, g_object_ref (self)); g_object_bind_property (progress, "fraction", self->progress_bar, "fraction", G_BINDING_SYNC_CREATE); gtk_widget_show (GTK_WIDGET (self->progress_bar)); g_clear_object (&progress); }