devhelp r1076 - in trunk: . src



Author: rhult
Date: Thu Oct  2 14:47:25 2008
New Revision: 1076
URL: http://svn.gnome.org/viewvc/devhelp?rev=1076&view=rev

Log:
2008-10-02  Richard Hult  <richard imendio com>

	* src/dh-base.c (dh_base_get_window): New function that returns an
	existing window on the current workspace or creates a new one.
	(dh_base_get_window_on_current_workspace): Make this work somewhat
	on non-X11, by returning any window (instead of none).


Modified:
   trunk/ChangeLog
   trunk/src/dh-base.c
   trunk/src/dh-base.h

Modified: trunk/src/dh-base.c
==============================================================================
--- trunk/src/dh-base.c	(original)
+++ trunk/src/dh-base.c	Thu Oct  2 14:47:25 2008
@@ -410,15 +410,7 @@
 GtkWidget *
 dh_base_get_window_on_current_workspace (DhBase *base)
 {
-#ifdef HAVE_PLATFORM_X11
 	DhBasePriv    *priv;
-	WnckWorkspace *workspace;
-	WnckScreen    *screen;
-	GtkWidget     *window;
-	GList         *windows, *w;
-	GSList        *l;
-	gulong         xid;
-	pid_t          pid;
 
 	g_return_val_if_fail (DH_IS_BASE (base), NULL);
 
@@ -428,46 +420,57 @@
 		return NULL;
 	}
 
-	screen = wnck_screen_get (0);
-	if (!screen) {
-		return NULL;
-	}
-
-	workspace = wnck_screen_get_active_workspace (screen);
-	if (!workspace) {
-		return NULL;
-	}
-
-	xid = 0;
-	pid = getpid ();
-
-	/* Use _stacked so we can use the one on top. */
-	windows = wnck_screen_get_windows_stacked (screen);
-	windows = g_list_last (windows);
-
-	for (w = windows; w; w = w->prev) {
-		if (wnck_window_is_on_workspace (w->data, workspace) &&
-		    wnck_window_get_pid (w->data) == pid) {
-			xid = wnck_window_get_xid (w->data);
-			break;
-		}
-	}
-
-	if (!xid) {
-		return NULL;
-	}
-
-	/* Return the first matching window we have. */
-	for (l = priv->windows; l; l = l->next) {
-		window = l->data;
-
-		if (GDK_WINDOW_XID (window->window) == xid) {
-			return window;
-		}
-	}
+#ifdef HAVE_PLATFORM_X11
+        {
+                WnckWorkspace *workspace;
+                WnckScreen    *screen;
+                GtkWidget     *window;
+                GList         *windows, *w;
+                GSList        *l;
+                gulong         xid;
+                pid_t          pid;
+
+                screen = wnck_screen_get (0);
+                if (!screen) {
+                        return NULL;
+                }
+
+                workspace = wnck_screen_get_active_workspace (screen);
+                if (!workspace) {
+                        return NULL;
+                }
+
+                xid = 0;
+                pid = getpid ();
+
+                /* Use _stacked so we can use the one on top. */
+                windows = wnck_screen_get_windows_stacked (screen);
+                windows = g_list_last (windows);
+
+                for (w = windows; w; w = w->prev) {
+                        if (wnck_window_is_on_workspace (w->data, workspace) &&
+                            wnck_window_get_pid (w->data) == pid) {
+                                xid = wnck_window_get_xid (w->data);
+                                break;
+                        }
+                }
+
+                if (!xid) {
+                        return NULL;
+                }
+
+                /* Return the first matching window we have. */
+                for (l = priv->windows; l; l = l->next) {
+                        window = l->data;
+
+                        if (GDK_WINDOW_XID (window->window) == xid) {
+                                return window;
+                        }
+                }
+        }
+#else
+        return priv->windows->data;
 #endif
-
-	return NULL;
 }
 
 GConfClient *
@@ -481,3 +484,19 @@
 	
 	return priv->gconf_client;
 }
+
+GtkWidget *
+dh_base_get_window (DhBase *base)
+{
+        GtkWidget *window;
+
+	g_return_val_if_fail (DH_IS_BASE (base), NULL);
+	
+	window = dh_base_get_window_on_current_workspace (base);
+	if (!window) {
+		window = dh_base_new_window (base);
+		gtk_window_present (GTK_WINDOW (window));
+	}
+
+        return window;
+}

Modified: trunk/src/dh-base.h
==============================================================================
--- trunk/src/dh-base.h	(original)
+++ trunk/src/dh-base.h	Thu Oct  2 14:47:25 2008
@@ -23,8 +23,7 @@
 #ifndef __DH_BASE_H__
 #define __DH_BASE_H__
 
-#include <glib-object.h>
-#include <gtk/gtkwidget.h>
+#include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 
 typedef struct _DhBase      DhBase;
@@ -58,5 +57,6 @@
 GList *      dh_base_get_keywords                    (DhBase *base);
 GSList *     dh_base_get_windows                     (DhBase *base);
 GConfClient *dh_base_get_gconf_client                (DhBase *base);
+GtkWidget *  dh_base_get_window                      (DhBase *base);
 
 #endif /* __DH_BASE_H__ */



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