[libwnck] core: Add API to get WM_CLASS group name & instance name of a WnckWindow



commit 065fb8394e5437a741da50bb22558babcf5ce9c1
Author: Marco Trevisan (TreviÃo) <mail 3v1n0 net>
Date:   Sat Jul 30 03:27:17 2011 +0200

    core: Add API to get WM_CLASS group name & instance name of a WnckWindow
    
    The old private getters for getting a window WM_CLASS name or WM_CLASS
    are now public as wnck_window_get_class_group_name() and
    wnck_window_get_class_instance_name().
    
    It's important to be able to get the instance name as they could differ
    for special windows or for sub-applications (i.e. chromium web-apps).
    
    Also make wnckprop print out the window class instance.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=168718

 libwnck/private.h  |    3 ---
 libwnck/screen.c   |    2 +-
 libwnck/tasklist.c |    4 ++--
 libwnck/window.c   |   26 ++++++++++++++++++++++++--
 libwnck/window.h   |    5 ++++-
 libwnck/wnckprop.c |    8 ++++++++
 6 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/libwnck/private.h b/libwnck/private.h
index 97207fd..b4d6572 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -61,9 +61,6 @@ char*       _wnck_window_get_name_for_display (WnckWindow *window,
                                                gboolean    use_state_decorations);
 const char* _wnck_window_get_startup_id (WnckWindow *window);
 
-const char* _wnck_window_get_resource_class (WnckWindow *window);
-const char* _wnck_window_get_resource_name  (WnckWindow *window);
-
 time_t      _wnck_window_get_needs_attention_time (WnckWindow *window);
 time_t      _wnck_window_or_transient_get_needs_attention_time (WnckWindow *window);
 
diff --git a/libwnck/screen.c b/libwnck/screen.c
index 07d66cf..fabbac0 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -1530,7 +1530,7 @@ update_client_list (WnckScreen *screen)
 
 	  /* Class group */
 
-	  res_class = _wnck_window_get_resource_class (window);
+	  res_class = wnck_window_get_class_group_name (window);
 
 	  class_group = wnck_class_group_get (res_class);
 	  if (class_group == NULL)
diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c
index 14214dd..178d670 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/tasklist.c
@@ -4233,8 +4233,8 @@ wnck_tasklist_check_end_sequence (WnckTasklist   *tasklist,
   if (tasklist->priv->startup_sequences == NULL)
     return;
 
-  res_class = _wnck_window_get_resource_class (window);
-  res_name = _wnck_window_get_resource_name (window);
+  res_class = wnck_window_get_class_group_name (window);
+  res_name = wnck_window_get_class_instance_name (window);
 
   if (res_class == NULL && res_name == NULL)
     return;
diff --git a/libwnck/window.c b/libwnck/window.c
index a6fcb81..ced342d 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -1172,16 +1172,38 @@ _wnck_window_get_startup_id (WnckWindow *window)
   return window->priv->startup_id;
 }
 
+/**
+ * wnck_window_get_class_group_name:
+ * @window: a #WnckWindow.
+ *
+ * Gets class group name parameter of the <ulink
+ * url="http://tronche.com/gui/x/icccm/sec-4.html&num;WM_CLASS";>WM_CLASS Property</ulink>
+ * for the window @window.
+ * Note that using this function is actually like doing wnck_window_get_class_group()
+ * and then wnck_class_group_get_res_class()
+ *
+ * Return value: the class name for @window, or %NULL if @window has no class.
+ **/
 const char*
-_wnck_window_get_resource_class (WnckWindow *window)
+wnck_window_get_class_group_name (WnckWindow *window)
 {
   g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
 
   return window->priv->res_class;
 }
 
+/**
+ * wnck_window_get_class_instance_name:
+ * @window: a #WnckWindow.
+ *
+ * Gets class instance name parameter of the <ulink
+ * url="http://tronche.com/gui/x/icccm/sec-4.html&num;WM_CLASS";>WM_CLASS Property</ulink>
+ * for the window @window.
+ *
+ * Return value: the class instance for @window, or %NULL if @window has no class instance.
+ **/
 const char*
-_wnck_window_get_resource_name (WnckWindow *window)
+wnck_window_get_class_instance_name (WnckWindow *window)
 {
   g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
 
diff --git a/libwnck/window.h b/libwnck/window.h
index 673f44a..dbdb529 100644
--- a/libwnck/window.h
+++ b/libwnck/window.h
@@ -299,7 +299,10 @@ WnckWindow*      wnck_window_get_transient    (WnckWindow *window);
 gulong           wnck_window_get_group_leader (WnckWindow *window);
 gulong           wnck_window_get_xid          (WnckWindow *window);
 
-WnckClassGroup *wnck_window_get_class_group (WnckWindow *window);
+WnckClassGroup *wnck_window_get_class_group   (WnckWindow *window);
+
+const char* wnck_window_get_class_group_name    (WnckWindow *window);
+const char* wnck_window_get_class_instance_name (WnckWindow *window);
 
 const char* wnck_window_get_session_id        (WnckWindow *window);
 const char* wnck_window_get_session_id_utf8   (WnckWindow *window);
diff --git a/libwnck/wnckprop.c b/libwnck/wnckprop.c
index 81810fd..b8f363d 100644
--- a/libwnck/wnckprop.c
+++ b/libwnck/wnckprop.c
@@ -1507,6 +1507,14 @@ print_window (WnckWindow *window)
    * same class. */
   g_print (_("Class Group: %s\n"), buf);
 
+  if (wnck_window_get_class_instance_name (window))
+    buf = wnck_window_get_class_instance_name (window);
+  else
+    /* Translators: 'unset' in the sense of "something has not been set". */
+    buf = _("<unset>");
+
+  g_print (_("Class Instance: %s\n"), buf);
+
   g_print (_("XID: %lu\n"), wnck_window_get_xid (window));
 
   if (wnck_window_get_pid (window) != 0)



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