Commit 29cc79e7 authored by Günther Wagner's avatar Günther Wagner
Browse files

Add i18n for user visible strings

shortcircuit if unparenting service

fixed runtime error

proper error handling in case of missing internet
parent 19d8de20
Pipeline #179021 canceled with stage
in 11 minutes and 50 seconds
......@@ -27,6 +27,7 @@
#include <glib-unix.h>
#include <libide-core.h>
#include <jsonrpc-glib.h>
#include <glib/gi18n.h>
struct _RustAnalyzerService
{
......@@ -131,6 +132,9 @@ rust_analyzer_service_set_parent (IdeObject *object,
g_return_if_fail (RUST_IS_ANALYZER_SERVICE (object));
if (parent == NULL)
return;
context = ide_object_get_context (object);
workdir = ide_context_ref_workdir (context);
cargo_toml = g_file_get_child (workdir, "Cargo.toml");
......@@ -360,10 +364,10 @@ rust_analyzer_service_ensure_started (RustAnalyzerService *self)
notification = ide_notification_new ();
ide_notification_set_id (notification, "org.gnome-builder.rust-analyzer");
ide_notification_set_title (notification, "Your computer is missing the Rust Analyzer Language Server");
ide_notification_set_body (notification, "The Language Server is necessary to provide IDE features like completion or diagnostic");
ide_notification_set_title (notification, _("Your computer is missing the Rust Analyzer Language Server"));
ide_notification_set_body (notification, _("The Language Server is necessary to provide IDE features like completion or diagnostic"));
ide_notification_set_icon_name (notification, "dialog-warning-symbolic");
ide_notification_add_button (notification, "Install Language Server", NULL, "win.install-rust-analyzer");
ide_notification_add_button (notification, _("Install Language Server"), NULL, "win.install-rust-analyzer");
ide_notification_set_urgent (notification, TRUE);
context = ide_object_get_context (IDE_OBJECT (self));
ide_notification_attach (notification, IDE_OBJECT (context));
......
......@@ -25,6 +25,7 @@
#include <glib/gstdio.h>
#include <stdio.h>
#include <sys/stat.h>
#include <glib/gi18n.h>
struct _RustAnalyzerTransfer
{
......@@ -106,17 +107,26 @@ _download_lsp (GObject *source_object,
g_autoptr(GError) error = NULL;
GInputStream *stream = NULL;
DownloadData *data;
IdeTransfer *transfer = IDE_TRANSFER (ide_task_get_task_data (task));
IDE_ENTRY;
g_return_if_fail (SOUP_IS_REQUEST (request));
g_return_if_fail (IDE_IS_TASK (task));
stream = soup_request_send_finish (request, result, NULL);
stream = soup_request_send_finish (request, result, &error);
if (error != NULL)
{
ide_task_return_error (task, g_steal_pointer (&error));
ide_transfer_cancel (transfer);
return;
}
data = g_slice_new0 (DownloadData);
data->filepath = g_build_filename (g_get_home_dir (), ".cargo", "bin", "rust-analyzer", NULL);
file = g_file_new_for_path (data->filepath);
data->transfer = IDE_TRANSFER (ide_task_get_task_data (task));
data->filestream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, ide_task_get_cancellable (data->task), &error));
data->transfer = transfer;
data->filestream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, ide_task_get_cancellable (task), &error));
if (data->filestream == NULL)
{
ide_task_return_error (task, g_steal_pointer (&error));
......@@ -126,6 +136,8 @@ _download_lsp (GObject *source_object,
data->task = g_steal_pointer (&task);
g_input_stream_read_async (stream, &data->buffer, sizeof (data->buffer), G_PRIORITY_DEFAULT, ide_task_get_cancellable (data->task), _downloaded_chunk, data);
IDE_EXIT;
}
static void
......@@ -180,5 +192,5 @@ rust_analyzer_transfer_class_init (RustAnalyzerTransferClass *klass)
static void
rust_analyzer_transfer_init (RustAnalyzerTransfer *self)
{
ide_transfer_set_title (IDE_TRANSFER (self), "Installing Rust Analyzer...");
ide_transfer_set_title (IDE_TRANSFER (self), _("Installing Rust Analyzer..."));
}
......@@ -21,6 +21,7 @@
#include "rust-analyzer-workbench-addin.h"
#include <libide-gui.h>
#include <libide-core.h>
#include <glib/gi18n.h>
#include "rust-analyzer-transfer.h"
#include "rust-analyzer-service.h"
......@@ -62,10 +63,18 @@ rust_analyzer_service_downloaded_lsp (GObject *object,
gpointer user_data)
{
IdeContext *context = IDE_CONTEXT (user_data);
IdeTransferManager *transfer_manager = IDE_TRANSFER_MANAGER (object);
g_autoptr(GError) error = NULL;
RustAnalyzerService *service = NULL;
g_return_if_fail (IDE_IS_CONTEXT (context));
ide_transfer_manager_execute_finish (transfer_manager, res, &error);
if (error != NULL) {
g_warning (_("Cannot download Rust Analyzer: %s"), error->message);
return;
}
service = ide_object_ensure_child_typed (IDE_OBJECT (context), RUST_TYPE_ANALYZER_SERVICE);
rust_analyzer_service_set_state (service, RUST_ANALYZER_SERVICE_READY);
rust_analyzer_service_ensure_started (service);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment