[gnome-builder: 3/17] Add i18n for user visible strings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 3/17] Add i18n for user visible strings
- Date: Mon, 22 Jun 2020 19:22:50 +0000 (UTC)
commit 29cc79e743f64ab06b5b53e90c77754a253ce9d4
Author: Günther Wagner <info gunibert de>
Date: Wed May 13 19:30:23 2020 +0200
Add i18n for user visible strings
shortcircuit if unparenting service
fixed runtime error
proper error handling in case of missing internet
src/plugins/rust-analyzer/rust-analyzer-service.c | 10 +++++++---
src/plugins/rust-analyzer/rust-analyzer-transfer.c | 20 ++++++++++++++++----
.../rust-analyzer/rust-analyzer-workbench-addin.c | 9 +++++++++
3 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/rust-analyzer/rust-analyzer-service.c
b/src/plugins/rust-analyzer/rust-analyzer-service.c
index ec6532eff..541b091c3 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-service.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-service.c
@@ -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));
diff --git a/src/plugins/rust-analyzer/rust-analyzer-transfer.c
b/src/plugins/rust-analyzer/rust-analyzer-transfer.c
index dbf638883..4507f6075 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-transfer.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-transfer.c
@@ -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..."));
}
diff --git a/src/plugins/rust-analyzer/rust-analyzer-workbench-addin.c
b/src/plugins/rust-analyzer/rust-analyzer-workbench-addin.c
index 30878efe9..b0a85969e 100644
--- a/src/plugins/rust-analyzer/rust-analyzer-workbench-addin.c
+++ b/src/plugins/rust-analyzer/rust-analyzer-workbench-addin.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]