Re: Denoting Remote Machines (Re: Custom Icons for GNOME Terminal Profiles)



On Mon, 2005-11-21 at 20:13 +1100, Jeff Waugh wrote:

> Given that this is a 'just works' feature for people who use forwarding, and
> won't even be on the radar for standard local application users... let's DO
> IT!

The quick'n'dirty patch is attached. It works on my desktop at home
using ssh X-forwarding and on my desktop at work using more traditional
X-forwarding. It could probably be a whole lot neater, but it gives
people the gist of how things work.

--d

-- 
Davyd Madeley

http://www.davyd.id.au/
08B0 341A 0B9B 08BB 2118  C060 2EDD BB4F 5191 6CDA
diff -rpu metacity.clean/src/window-props.c metacity/src/window-props.c
--- metacity.clean/src/window-props.c	2005-10-09 03:38:53.000000000 +0800
+++ metacity/src/window-props.c	2005-11-21 12:17:30.000000000 +0800
@@ -26,6 +26,8 @@
 #include "frame.h"
 #include "group.h"
 #include <X11/Xatom.h>
+#include <unistd.h>
+#include <string.h>
 
 typedef void (* InitValueFunc)   (MetaDisplay   *display,
                                   Atom           property,
@@ -204,7 +206,27 @@ set_window_title (MetaWindow *window,
   if (title == NULL)
     window->title = g_strdup ("");
   else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) <= MAX_TITLE_LENGTH)
-    window->title = g_strdup (title);
+    if (window->wm_client_machine)
+    {
+      char hostname[HOST_NAME_MAX + 1];
+
+      /* if WM_CLIENT_MACHINE indicates this machine is on a remote host
+       * lets place that hostname in the title */
+      if (!gethostname (hostname, HOST_NAME_MAX + 1) &&
+          strcmp (hostname, window->wm_client_machine))
+      {
+        window->title = g_strdup_printf ("%s (on %s)",
+					title, window->wm_client_machine);
+        meta_prop_set_utf8_string_hint (window->display,
+                                      window->xwindow,
+                                      window->display->atom_net_wm_visible_name,
+                                      window->title);
+      }
+      else
+	window->title = g_strdup (title);
+    }
+    else
+      window->title = g_strdup (title);
   else
     {
       window->title = meta_g_utf8_strndup (title, MAX_TITLE_LENGTH);
@@ -297,7 +319,27 @@ set_icon_title (MetaWindow *window,
   if (title == NULL)
     window->icon_name = g_strdup ("");
   else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) <= MAX_TITLE_LENGTH)
-    window->icon_name = g_strdup (title);
+    if (window->wm_client_machine)
+    {
+      char hostname[HOST_NAME_MAX + 1];
+
+      /* if WM_CLIENT_MACHINE indicates this machine is on a remote host
+       * lets place that hostname in the title */
+      if (!gethostname (hostname, HOST_NAME_MAX + 1) &&
+          strcmp (hostname, window->wm_client_machine))
+      {
+        window->icon_name = g_strdup_printf ("%s (on %s)",
+					title, window->wm_client_machine);
+        meta_prop_set_utf8_string_hint (window->display,
+                                        window->xwindow,
+                                        window->display->atom_net_wm_visible_icon_name,
+                                        window->icon_name);
+      }
+      else
+	window->icon_name = g_strdup (title);
+    }
+    else
+      window->icon_name = g_strdup (title);
   else
     {
       window->icon_name = meta_g_utf8_strndup (title, MAX_TITLE_LENGTH);


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