[gnome-builder] gui: add API to specify command-line is handled



commit 64cbba8dd6f27941194240dc68230289e5ae602a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 30 11:46:55 2019 -0800

    gui: add API to specify command-line is handled

 src/libide/gui/ide-application-command-line.c |  8 +++
 src/libide/gui/ide-application.c              | 21 ++++++++
 src/libide/gui/ide-application.h              | 71 +++++++++++++++------------
 3 files changed, 68 insertions(+), 32 deletions(-)
---
diff --git a/src/libide/gui/ide-application-command-line.c b/src/libide/gui/ide-application-command-line.c
index ebdfc88f0..aadebf9a3 100644
--- a/src/libide/gui/ide-application-command-line.c
+++ b/src/libide/gui/ide-application-command-line.c
@@ -87,6 +87,10 @@ command_line_foreach_cb (PeasExtensionSet *set,
   g_assert (IDE_IS_APPLICATION_ADDIN (addin));
   g_assert (G_IS_APPLICATION_COMMAND_LINE (cmdline));
 
+  /* Stop if we've already handled things */
+  if (ide_application_get_command_line_handled (IDE_APPLICATION_DEFAULT, cmdline))
+    return;
+
   ide_application_addin_handle_command_line (addin, IDE_APPLICATION_DEFAULT, cmdline);
 }
 
@@ -166,6 +170,10 @@ _ide_application_command_line (IdeApplication          *self,
    */
   peas_extension_set_foreach (self->addins, command_line_foreach_cb, cmdline);
 
+  /* Short-circuit if there is nothing more to do */
+  if (ide_application_get_command_line_handled (self, cmdline))
+    return;
+
   /*
    * Open the project if --project/-p was spefified by the invoking
    * processes command-line.
diff --git a/src/libide/gui/ide-application.c b/src/libide/gui/ide-application.c
index fe0481457..51a3dfc08 100644
--- a/src/libide/gui/ide-application.c
+++ b/src/libide/gui/ide-application.c
@@ -748,3 +748,24 @@ ide_application_find_workbench_for_file (IdeApplication *self,
 
   return match;
 }
+
+void
+ide_application_set_command_line_handled (IdeApplication          *self,
+                                          GApplicationCommandLine *cmdline,
+                                          gboolean                 handled)
+{
+  g_return_if_fail (IDE_IS_APPLICATION (self));
+  g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline));
+
+  return g_object_set_data (G_OBJECT (cmdline), "COMMAND_LINE_HANDLED", GINT_TO_POINTER (!!handled));
+}
+
+gboolean
+ide_application_get_command_line_handled (IdeApplication          *self,
+                                          GApplicationCommandLine *cmdline)
+{
+  g_return_val_if_fail (IDE_IS_APPLICATION (self), FALSE);
+  g_return_val_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline), FALSE);
+
+  return !!g_object_get_data (G_OBJECT (cmdline), "COMMAND_LINE_HANDLED");
+}
diff --git a/src/libide/gui/ide-application.h b/src/libide/gui/ide-application.h
index dcb88db8b..dd8cc3dbf 100644
--- a/src/libide/gui/ide-application.h
+++ b/src/libide/gui/ide-application.h
@@ -39,48 +39,55 @@ IDE_AVAILABLE_IN_3_32
 G_DECLARE_FINAL_TYPE (IdeApplication, ide_application, IDE, APPLICATION, DzlApplication)
 
 IDE_AVAILABLE_IN_3_32
-gboolean       ide_application_has_network         (IdeApplication           *self);
+gboolean       ide_application_has_network              (IdeApplication           *self);
 IDE_AVAILABLE_IN_3_32
-gchar        **ide_application_get_argv            (IdeApplication           *self,
-                                                    GApplicationCommandLine  *cmdline);
+gchar        **ide_application_get_argv                 (IdeApplication           *self,
+                                                         GApplicationCommandLine  *cmdline);
 IDE_AVAILABLE_IN_3_32
-GDateTime     *ide_application_get_started_at      (IdeApplication           *self);
+GDateTime     *ide_application_get_started_at           (IdeApplication           *self);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_open_project_async  (IdeApplication           *self,
-                                                    IdeProjectInfo           *project_info,
-                                                    GType                     workspace_type,
-                                                    GCancellable             *cancellable,
-                                                    GAsyncReadyCallback       callback,
-                                                    gpointer                  user_data);
+gboolean       ide_application_get_command_line_handled (IdeApplication           *self,
+                                                         GApplicationCommandLine  *cmdline);
 IDE_AVAILABLE_IN_3_32
-IdeWorkbench  *ide_application_open_project_finish (IdeApplication           *self,
-                                                    GAsyncResult             *result,
-                                                    GError                  **error);
+void           ide_application_set_command_line_handled (IdeApplication           *self,
+                                                         GApplicationCommandLine  *cmdline,
+                                                         gboolean                  handled);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_set_workspace_type  (IdeApplication           *self,
-                                                    GType                     workspace_type);
+void           ide_application_open_project_async       (IdeApplication           *self,
+                                                         IdeProjectInfo           *project_info,
+                                                         GType                     workspace_type,
+                                                         GCancellable             *cancellable,
+                                                         GAsyncReadyCallback       callback,
+                                                         gpointer                  user_data);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_add_workbench       (IdeApplication           *self,
-                                                    IdeWorkbench             *workbench);
+IdeWorkbench  *ide_application_open_project_finish      (IdeApplication           *self,
+                                                         GAsyncResult             *result,
+                                                         GError                  **error);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_remove_workbench    (IdeApplication           *self,
-                                                    IdeWorkbench             *workbench);
+void           ide_application_set_workspace_type       (IdeApplication           *self,
+                                                         GType                     workspace_type);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_foreach_workbench   (IdeApplication           *self,
-                                                    GFunc                     callback,
-                                                    gpointer                  user_data);
+void           ide_application_add_workbench            (IdeApplication           *self,
+                                                         IdeWorkbench             *workbench);
 IDE_AVAILABLE_IN_3_32
-void           ide_application_get_worker_async    (IdeApplication           *self,
-                                                    const gchar              *plugin_name,
-                                                    GCancellable             *cancellable,
-                                                    GAsyncReadyCallback       callback,
-                                                    gpointer                  user_data);
+void           ide_application_remove_workbench         (IdeApplication           *self,
+                                                         IdeWorkbench             *workbench);
 IDE_AVAILABLE_IN_3_32
-GDBusProxy    *ide_application_get_worker_finish   (IdeApplication           *self,
-                                                    GAsyncResult             *result,
-                                                    GError                  **error);
+void           ide_application_foreach_workbench        (IdeApplication           *self,
+                                                         GFunc                     callback,
+                                                         gpointer                  user_data);
 IDE_AVAILABLE_IN_3_32
-IdeWorkbench *ide_application_find_workbench_for_file (IdeApplication *self,
-                                                       GFile          *file);
+void           ide_application_get_worker_async         (IdeApplication           *self,
+                                                         const gchar              *plugin_name,
+                                                         GCancellable             *cancellable,
+                                                         GAsyncReadyCallback       callback,
+                                                         gpointer                  user_data);
+IDE_AVAILABLE_IN_3_32
+GDBusProxy    *ide_application_get_worker_finish        (IdeApplication           *self,
+                                                         GAsyncResult             *result,
+                                                         GError                  **error);
+IDE_AVAILABLE_IN_3_32
+IdeWorkbench  *ide_application_find_workbench_for_file  (IdeApplication           *self,
+                                                         GFile                    *file);
 
 G_END_DECLS


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