[gnome-builder/gnome-builder-42] lsp: Use percentage value to show a precise progress bar (#1651)



commit b7efdc88b3924cd0c2975e6188c0b12bbf3f4e2a
Author: JCWasmx86 <JCWasmx86 t-online de>
Date:   Sun Apr 3 18:53:01 2022 +0200

    lsp: Use percentage value to show a precise progress bar (#1651)

 src/libide/lsp/ide-lsp-client.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/lsp/ide-lsp-client.c b/src/libide/lsp/ide-lsp-client.c
index 43a63ff0b..6c218f1fe 100644
--- a/src/libide/lsp/ide-lsp-client.c
+++ b/src/libide/lsp/ide-lsp-client.c
@@ -856,6 +856,7 @@ ide_lsp_client_real_notification (IdeLspClient *self,
           const gchar *message = NULL;
           const gchar *title = NULL;
           const gchar *kind = NULL;
+          gint64 percentage = -1;
           IdeContext *context;
           IdeNotifications *notifications;
           IdeNotification *notification = NULL;
@@ -870,6 +871,9 @@ ide_lsp_client_real_notification (IdeLspClient *self,
           JSONRPC_MESSAGE_PARSE (params, "value", "{",
                                            "message", JSONRPC_MESSAGE_GET_STRING (&message),
                                          "}");
+          JSONRPC_MESSAGE_PARSE (params, "value", "{",
+                                           "percentage", JSONRPC_MESSAGE_GET_INT64 (&percentage),
+                                         "}");
           context = ide_object_get_context (IDE_OBJECT (self));
           notifications = ide_object_get_child_typed (IDE_OBJECT (context), IDE_TYPE_NOTIFICATIONS);
           notification = ide_notifications_find_by_id (notifications, token);
@@ -885,19 +889,22 @@ ide_lsp_client_real_notification (IdeLspClient *self,
                   notification = ide_notification_new ();
                   ide_notification_set_id (notification, token);
                   ide_notification_set_has_progress (notification, TRUE);
-                  ide_notification_set_progress_is_imprecise (notification, TRUE);
+                  ide_notification_set_progress_is_imprecise (notification, percentage == -1);
                 }
 
               ide_notification_set_title (notification, title);
               ide_notification_set_body (notification, message != NULL ? message : title);
-
+              if (percentage != -1)
+                ide_notification_set_progress (notification, percentage / 100.0);
               if (!notification_exists)
                 ide_notification_attach (notification, IDE_OBJECT (context));
             }
-          else
+          else if (notification != NULL)
             {
-              if (message != NULL && notification != NULL)
+              if (message != NULL)
                 ide_notification_set_body (notification, message);
+              if (percentage != -1)
+                ide_notification_set_progress (notification, percentage / 100.0);
             }
 
           if (ide_str_equal0 (kind, "end") && notification != NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]