[gnome-terminal] client: legacy: Don't mix environment and command line options



commit 4c919d19d58ca96d5c60857ffa623a0895b85fa6
Author: Christian Persch <chpe src gnome org>
Date:   Sat Nov 11 22:28:12 2017 +0100

    client: legacy: Don't mix environment and command line options
    
    Be consistent when deciding which gnome-terminal-server to use.
    Only take the parent screen from the environment when also
    using the service name from the environment.

 src/terminal-options.c |   19 +++++++++++++++++++
 src/terminal-options.h |    4 +++-
 src/terminal.c         |    7 ++++---
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/terminal-options.c b/src/terminal-options.c
index c212b6a..e2bf0a1 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -1240,6 +1240,25 @@ terminal_options_get_service_name (TerminalOptions *options)
 }
 
 /**
+ * terminal_options_get_service_name:
+ * @options:
+ *
+ * Returns the DBus object path of the parent screen, if using the server
+ * specified by the GNOME_TERMINAL_SERVICE environment variable; else %NULL.
+ *
+ * Returns: (transfer none): the DBus object path of the parent screen, or %NULL
+ */
+const char *
+terminal_options_get_parent_screen_object_path (TerminalOptions *options)
+{
+  if (options->server_app_id == NULL &&
+      options->server_unique_name != NULL)
+    return options->parent_screen_object_path;
+
+  return NULL;
+}
+
+/**
  * terminal_options_free:
  * @options:
  *
diff --git a/src/terminal-options.h b/src/terminal-options.h
index 5f7c01e..6a02290 100644
--- a/src/terminal-options.h
+++ b/src/terminal-options.h
@@ -154,7 +154,9 @@ void terminal_options_ensure_window (TerminalOptions *options);
 
 const char *terminal_options_get_service_name (TerminalOptions *options);
 
-  void terminal_options_free (TerminalOptions *options);
+const char *terminal_options_get_parent_screen_object_path (TerminalOptions *options);
+
+void terminal_options_free (TerminalOptions *options);
 
 typedef enum {
   TERMINAL_VERBOSITY_QUIET  = 0,
diff --git a/src/terminal.c b/src/terminal.c
index d6faaa8..a53ba6f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -281,7 +281,7 @@ handle_options (TerminalOptions *options,
 
       gs_free char *previous_screen_object_path = NULL;
       if (iw->implicit_first_window)
-        previous_screen_object_path = g_strdup (options->parent_screen_object_path);
+        previous_screen_object_path = g_strdup (terminal_options_get_parent_screen_object_path (options));
 
       /* Now add the tabs */
       for (GList *lt = iw->tabs; lt != NULL; lt = lt->next)
@@ -305,9 +305,10 @@ handle_options (TerminalOptions *options,
                                                           iw->start_fullscreen);
 
           /* This will be used to apply missing defaults */
-          if (options->parent_screen_object_path)
+          const char *parent_screen_object_path = terminal_options_get_parent_screen_object_path (options);
+          if (parent_screen_object_path != NULL)
             g_variant_builder_add (&builder, "{sv}",
-                                   "parent-screen", g_variant_new_object_path 
(options->parent_screen_object_path));
+                                   "parent-screen", g_variant_new_object_path (parent_screen_object_path));
 
           /* This will be used to get the parent window */
           if (previous_screen_object_path)


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