author | yippi |
Mon, 27 Sep 2010 21:07:51 +0000 | |
changeset 20108 | 51df67ca9307 |
parent 17793 | 208207fdc93f |
child 20201 | 33ac0296e01d |
child 21593 | 2d1a4d25db41 |
permissions | -rw-r--r-- |
13074 | 1 |
diff -urN libwnck.orig/config.h.in libwnck.new/config.h.in |
2 |
--- libwnck.orig/config.h.in 2008-08-06 23:43:14.009985000 +0100 |
|
3 |
+++ libwnck.new/config.h.in 2008-08-06 23:43:40.045900000 +0100 |
|
7480 | 4 |
@@ -32,6 +32,7 @@ |
5 |
||
11180 | 6 |
/* Define if you have libstartup-notification */ |
7480 | 7 |
#undef HAVE_STARTUP_NOTIFICATION |
8 |
+#undef HAVE_XTSOL |
|
9 |
||
10 |
/* Define to 1 if you have the <stdint.h> header file. */ |
|
11 |
#undef HAVE_STDINT_H |
|
13074 | 12 |
diff -urN libwnck.orig/configure.in libwnck.new/configure.in |
13 |
--- libwnck.orig/configure.in 2008-08-06 23:43:14.618321000 +0100 |
|
14 |
+++ libwnck.new/configure.in 2008-08-06 23:43:40.049192000 +0100 |
|
15 |
@@ -139,6 +139,15 @@ |
|
11190 | 16 |
dnl Honor ACLOCAL_FLAGS for --enable-maintainer-mode |
17 |
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" |
|
7480 | 18 |
|
19 |
+case "$host" in |
|
20 |
+ *-*-solaris*) |
|
11180 | 21 |
+ AC_CHECK_HEADERS(X11/extensions/Xtsol.h sys/tsol/label_macro.h libgnometsol/userattr.h, |
22 |
+ AC_DEFINE(HAVE_XTSOL, , [Building with XTSOL support])) |
|
7480 | 23 |
+ ;; |
24 |
+ *) |
|
25 |
+ ;; |
|
26 |
+esac |
|
27 |
+ |
|
11190 | 28 |
################################################## |
29 |
# Checks for gtk-doc and docbook-tools |
|
30 |
################################################## |
|
13074 | 31 |
diff -urN libwnck.orig/libwnck/pager.c libwnck.new/libwnck/pager.c |
32 |
--- libwnck.orig/libwnck/pager.c 2008-08-06 23:43:13.356087000 +0100 |
|
33 |
+++ libwnck.new/libwnck/pager.c 2008-08-06 23:43:40.066590000 +0100 |
|
11201 | 34 |
@@ -29,6 +29,7 @@ |
10174 | 35 |
#include <math.h> |
36 |
#include <glib/gi18n-lib.h> |
|
7480 | 37 |
|
38 |
+#include <config.h> |
|
39 |
#include "pager.h" |
|
40 |
#include "workspace.h" |
|
41 |
#include "window.h" |
|
11201 | 42 |
@@ -59,6 +60,11 @@ |
10129 | 43 |
* layout. |
44 |
*/ |
|
8535 | 45 |
|
7480 | 46 |
+#ifdef HAVE_XTSOL |
8535 | 47 |
+#include "trusted-tooltips.h" |
7480 | 48 |
+#include "wnck-tsol.h" |
49 |
+#endif |
|
50 |
+ |
|
51 |
#define N_SCREEN_CONNECTIONS 11 |
|
52 |
||
8535 | 53 |
struct _WnckPagerPrivate |
12160 | 54 |
@@ -82,6 +88,9 @@ |
8535 | 55 |
WnckWindow *drag_window; |
7480 | 56 |
|
57 |
GdkPixbuf *bg_cache; |
|
58 |
+#ifdef HAVE_XTSOL |
|
59 |
+ TrustedTooltips *tooltips; |
|
60 |
+#endif /* HAVE_XTSOL */ |
|
61 |
||
62 |
int layout_manager_token; |
|
63 |
||
12160 | 64 |
@@ -345,8 +354,8 @@ |
7480 | 65 |
attributes.colormap = gtk_widget_get_colormap (widget); |
8535 | 66 |
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | |
67 |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
|
68 |
- GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | |
|
69 |
- GDK_POINTER_MOTION_HINT_MASK; |
|
70 |
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | |
|
71 |
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; |
|
7480 | 72 |
|
73 |
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
|
74 |
||
12160 | 75 |
@@ -1237,6 +1257,53 @@ |
8535 | 76 |
cairo_stroke (cr); |
77 |
cairo_destroy (cr); |
|
7480 | 78 |
} |
8535 | 79 |
+#ifdef HAVE_XTSOL |
7480 | 80 |
+ { |
81 |
+ #define DEFAULT_COLOR "white" |
|
12160 | 82 |
+ const char *label = NULL; |
7480 | 83 |
+ char *colorname; |
84 |
+ int error; |
|
85 |
+ GdkColor label_color; |
|
86 |
+ m_label_t *mlabel = NULL; |
|
87 |
+ |
|
88 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
89 |
+ { |
|
12160 | 90 |
+ label = wnck_workspace_get_label (wnck_screen_get_workspace(pager->priv->screen, workspace)); |
7480 | 91 |
+ if (label != NULL && (libtsol_str_to_label (label, &mlabel, MAC_LABEL, L_NO_CORRECTION, &error) == 0)) |
8535 | 92 |
+ { |
93 |
+ cairo_t *cr; |
|
94 |
+ cr = gdk_cairo_create (widget->window); |
|
95 |
+ |
|
96 |
+ libtsol_label_to_str (mlabel, &colorname, M_COLOR, DEF_NAMES); |
|
97 |
+ |
|
98 |
+ if (colorname == NULL) |
|
99 |
+ colorname = g_strdup(DEFAULT_COLOR); |
|
100 |
+ |
|
101 |
+ gdk_color_parse ((const char*)colorname, &label_color); |
|
102 |
+ |
|
103 |
+ g_free (colorname); |
|
104 |
+ |
|
105 |
+ cairo_set_source_rgba (cr, |
|
106 |
+ (double) label_color.red / 65535, |
|
107 |
+ (double) label_color.green / 65535, |
|
108 |
+ (double) label_color.blue / 65535, |
|
109 |
+ 0.5); |
|
110 |
+ cairo_set_line_width (cr, 1.0); |
|
111 |
+ cairo_rectangle (cr, |
|
112 |
+ rect->x + 0.5, rect->y + 0.5, |
|
113 |
+ rect->width - 1, rect->height - 1); |
|
114 |
+ cairo_fill (cr); |
|
115 |
+ cairo_destroy (cr); |
|
116 |
+ } |
|
7480 | 117 |
+ else |
118 |
+ { |
|
119 |
+ g_warning("Could not validate sensitivity label \"%s\"", label ? label : "no label defined"); |
|
120 |
+ } |
|
121 |
+ } |
|
122 |
+ |
|
123 |
+ } |
|
124 |
+#endif /*HAVE_XTSOL*/ |
|
125 |
+ |
|
126 |
} |
|
127 |
||
128 |
static gboolean |
|
12160 | 129 |
@@ -1940,6 +2015,14 @@ |
10129 | 130 |
WnckPager *pager; |
131 |
||
7480 | 132 |
pager = g_object_new (WNCK_TYPE_PAGER, NULL); |
133 |
+#ifdef HAVE_XTSOL |
|
12160 | 134 |
+ if (_wnck_use_trusted_extensions () == TRUE) { |
135 |
+ pager->priv->tooltips = trusted_tooltips_new (); |
|
136 |
+ trusted_tooltips_set_pager (pager->priv->tooltips, pager); |
|
137 |
+ gtk_object_ref (GTK_OBJECT (pager->priv->tooltips)); |
|
138 |
+ gtk_object_sink (GTK_OBJECT (pager->priv->tooltips)); |
|
139 |
+ } |
|
7480 | 140 |
+#endif /* HAVE_XTSOL */ |
141 |
||
142 |
return GTK_WIDGET (pager); |
|
143 |
} |
|
13074 | 144 |
diff -urN libwnck.orig/libwnck/private.h libwnck.new/libwnck/private.h |
145 |
--- libwnck.orig/libwnck/private.h 2008-08-06 23:43:13.349065000 +0100 |
|
146 |
+++ libwnck.new/libwnck/private.h 2008-08-06 23:43:40.073263000 +0100 |
|
11201 | 147 |
@@ -35,6 +35,9 @@ |
7480 | 148 |
#ifdef HAVE_STARTUP_NOTIFICATION |
149 |
#include <libsn/sn.h> |
|
150 |
#endif |
|
151 |
+#ifdef HAVE_XTSOL |
|
152 |
+#include <tsol/label.h> |
|
153 |
+#endif |
|
154 |
||
155 |
G_BEGIN_DECLS |
|
156 |
||
13074 | 157 |
@@ -102,9 +105,23 @@ |
7480 | 158 |
|
159 |
void _wnck_workspace_update_name (WnckWorkspace *workspace, |
|
160 |
const char *name); |
|
161 |
+#ifdef HAVE_XTSOL |
|
162 |
+void _wnck_workspace_update_label (WnckWorkspace *workspace, |
|
163 |
+ const char *label); |
|
164 |
+void _wnck_workspace_update_role (WnckWorkspace *workspace, |
|
165 |
+ const char *role); |
|
166 |
+blrange_t * _wnck_workspace_get_range (WnckWorkspace *space); |
|
167 |
+#endif |
|
168 |
void _wnck_screen_change_workspace_name (WnckScreen *screen, |
|
169 |
int number, |
|
170 |
const char *name); |
|
171 |
+#ifdef HAVE_XTSOL |
|
172 |
+void _wnck_screen_change_workspace_label (WnckScreen *screen, |
|
173 |
+ int number, |
|
174 |
+ const char *label); |
|
175 |
+gboolean _wnck_check_xtsol_extension (); |
|
176 |
+gboolean _wnck_use_trusted_extensions (); |
|
177 |
+#endif |
|
178 |
||
179 |
gboolean _wnck_workspace_set_geometry (WnckWorkspace *space, int w, int h); |
|
180 |
gboolean _wnck_workspace_set_viewport (WnckWorkspace *space, int x, int y); |
|
13074 | 181 |
diff -urN libwnck.orig/libwnck/screen.c libwnck.new/libwnck/screen.c |
182 |
--- libwnck.orig/libwnck/screen.c 2008-08-06 23:43:13.472108000 +0100 |
|
183 |
+++ libwnck.new/libwnck/screen.c 2008-08-06 23:43:40.084085000 +0100 |
|
11201 | 184 |
@@ -33,11 +33,17 @@ |
7480 | 185 |
#include "class-group.h" |
186 |
#include "xutils.h" |
|
187 |
#include "private.h" |
|
188 |
+#include "wnck-tsol.h" |
|
189 |
#include <gdk/gdk.h> |
|
190 |
#include <gdk/gdkx.h> |
|
191 |
#include <string.h> |
|
192 |
#include <stdlib.h> |
|
193 |
||
194 |
+#ifdef HAVE_XTSOL |
|
195 |
+#include <tsol/label.h> |
|
8535 | 196 |
+#include <sys/tsol/label_macro.h> |
7480 | 197 |
+#endif |
198 |
+ |
|
10129 | 199 |
/** |
200 |
* SECTION:screen |
|
201 |
* @short_description: an object representing a screen. |
|
13074 | 202 |
@@ -122,6 +128,10 @@ |
7480 | 203 |
guint need_update_active_window : 1; |
204 |
guint need_update_workspace_layout : 1; |
|
205 |
guint need_update_workspace_names : 1; |
|
206 |
+#ifdef HAVE_XTSOL |
|
207 |
+ guint need_update_workspace_labels : 1; |
|
208 |
+ guint need_update_workspace_roles : 1; |
|
209 |
+#endif |
|
210 |
guint need_update_bg_pixmap : 1; |
|
211 |
guint need_update_showing_desktop : 1; |
|
10129 | 212 |
guint need_update_wm : 1; |
13074 | 213 |
@@ -160,6 +170,10 @@ |
7480 | 214 |
static void update_active_window (WnckScreen *screen); |
215 |
static void update_workspace_layout (WnckScreen *screen); |
|
216 |
static void update_workspace_names (WnckScreen *screen); |
|
217 |
+#ifdef HAVE_XTSOL |
|
218 |
+static void update_workspace_labels (WnckScreen *screen); |
|
219 |
+static void update_workspace_roles (WnckScreen *screen); |
|
220 |
+#endif |
|
221 |
static void update_showing_desktop (WnckScreen *screen); |
|
222 |
||
223 |
static void queue_update (WnckScreen *screen); |
|
13074 | 224 |
@@ -602,6 +616,10 @@ |
7480 | 225 |
screen->priv->need_update_active_window = TRUE; |
226 |
screen->priv->need_update_workspace_layout = TRUE; |
|
227 |
screen->priv->need_update_workspace_names = TRUE; |
|
228 |
+#ifdef HAVE_XTSOL |
|
229 |
+ screen->priv->need_update_workspace_labels = TRUE; |
|
230 |
+ screen->priv->need_update_workspace_roles = TRUE; |
|
231 |
+#endif |
|
232 |
screen->priv->need_update_bg_pixmap = TRUE; |
|
233 |
screen->priv->need_update_showing_desktop = TRUE; |
|
10129 | 234 |
screen->priv->need_update_wm = TRUE; |
13074 | 235 |
@@ -1124,6 +1142,20 @@ |
7480 | 236 |
screen->priv->need_update_workspace_names = TRUE; |
237 |
queue_update (screen); |
|
238 |
} |
|
239 |
+#ifdef HAVE_XTSOL |
|
240 |
+ else if (xevent->xproperty.atom == |
|
241 |
+ _wnck_atom_get ("_NET_DESKTOP_LABELS")) |
|
242 |
+ { |
|
243 |
+ screen->priv->need_update_workspace_labels = TRUE; |
|
244 |
+ queue_update (screen); |
|
245 |
+ } |
|
246 |
+ else if (xevent->xproperty.atom == |
|
247 |
+ _wnck_atom_get ("_NET_DESKTOP_ROLES")) |
|
248 |
+ { |
|
249 |
+ screen->priv->need_update_workspace_roles = TRUE; |
|
250 |
+ queue_update (screen); |
|
251 |
+ } |
|
252 |
+#endif |
|
253 |
else if (xevent->xproperty.atom == |
|
254 |
_wnck_atom_get ("_XROOTPMAP_ID")) |
|
255 |
{ |
|
13074 | 256 |
@@ -2220,6 +2252,85 @@ |
7480 | 257 |
g_list_free (copy); |
258 |
} |
|
259 |
||
260 |
+#ifdef HAVE_XTSOL |
|
261 |
+static void |
|
262 |
+update_workspace_labels (WnckScreen *screen) |
|
263 |
+{ |
|
264 |
+ char **labels; |
|
265 |
+ int i; |
|
266 |
+ GList *tmp; |
|
267 |
+ GList *copy; |
|
268 |
+ |
|
269 |
+ if (!screen->priv->need_update_workspace_labels) |
|
270 |
+ return; |
|
271 |
+ |
|
272 |
+ screen->priv->need_update_workspace_labels = FALSE; |
|
273 |
+ |
|
274 |
+ labels = _wnck_get_utf8_list (screen->priv->xroot, |
|
275 |
+ _wnck_atom_get ("_NET_DESKTOP_LABELS")); |
|
276 |
+ |
|
277 |
+ copy = g_list_copy (screen->priv->workspaces); |
|
278 |
+ |
|
279 |
+ i = 0; |
|
280 |
+ tmp = copy; |
|
281 |
+ while (tmp != NULL) |
|
282 |
+ { |
|
283 |
+ if (labels && labels[i]) |
|
284 |
+ { |
|
285 |
+ _wnck_workspace_update_label (tmp->data, labels[i]); |
|
286 |
+ ++i; |
|
287 |
+ } |
|
288 |
+ else |
|
289 |
+ _wnck_workspace_update_label (tmp->data, NULL); |
|
290 |
+ |
|
291 |
+ tmp = tmp->next; |
|
292 |
+ } |
|
293 |
+ |
|
294 |
+ g_strfreev (labels); |
|
295 |
+ |
|
296 |
+ g_list_free (copy); |
|
297 |
+} |
|
298 |
+ |
|
299 |
+static void |
|
300 |
+update_workspace_roles (WnckScreen *screen) |
|
301 |
+{ |
|
302 |
+ char **roles; |
|
303 |
+ int i; |
|
304 |
+ GList *tmp; |
|
305 |
+ GList *copy; |
|
306 |
+ |
|
307 |
+ if (!screen->priv->need_update_workspace_roles) |
|
308 |
+ return; |
|
309 |
+ |
|
310 |
+ screen->priv->need_update_workspace_roles = FALSE; |
|
311 |
+ |
|
312 |
+ roles = _wnck_get_utf8_list (screen->priv->xroot, |
|
313 |
+ _wnck_atom_get ("_NET_DESKTOP_ROLES")); |
|
314 |
+ |
|
315 |
+ copy = g_list_copy (screen->priv->workspaces); |
|
316 |
+ |
|
317 |
+ i = 0; |
|
318 |
+ tmp = copy; |
|
319 |
+ while (tmp != NULL) |
|
320 |
+ { |
|
321 |
+ if (roles && roles[i]) |
|
322 |
+ { |
|
323 |
+ _wnck_workspace_update_role (tmp->data, roles[i]); |
|
324 |
+ ++i; |
|
325 |
+ } |
|
326 |
+ else |
|
327 |
+ _wnck_workspace_update_role (tmp->data, NULL); |
|
328 |
+ |
|
329 |
+ tmp = tmp->next; |
|
330 |
+ } |
|
331 |
+ |
|
332 |
+ g_strfreev (roles); |
|
333 |
+ |
|
334 |
+ g_list_free (copy); |
|
335 |
+} |
|
336 |
+#endif /* HAVE_XTSOL */ |
|
337 |
+ |
|
338 |
+ |
|
339 |
static void |
|
340 |
update_bg_pixmap (WnckScreen *screen) |
|
341 |
{ |
|
13074 | 342 |
@@ -2305,6 +2416,10 @@ |
7480 | 343 |
{ |
344 |
screen->priv->need_update_viewport_settings = TRUE; |
|
345 |
screen->priv->need_update_workspace_names = TRUE; |
|
346 |
+#ifdef HAVE_XTSOL |
|
347 |
+ screen->priv->need_update_workspace_labels = TRUE; |
|
348 |
+ screen->priv->need_update_workspace_roles = TRUE; |
|
349 |
+#endif |
|
350 |
} |
|
351 |
||
352 |
/* First get our big-picture state in order */ |
|
13074 | 353 |
@@ -2317,6 +2432,15 @@ |
7480 | 354 |
update_active_window (screen); |
355 |
update_workspace_layout (screen); |
|
356 |
update_workspace_names (screen); |
|
357 |
+#ifdef HAVE_XTSOL |
|
358 |
+ /* IMPORTANT |
|
359 |
+ * Workspace roles MUST be set before labels |
|
360 |
+ * as the valid label range for role workspaces |
|
361 |
+ * is different from the user's min and max label |
|
362 |
+ */ |
|
363 |
+ update_workspace_roles (screen); |
|
364 |
+ update_workspace_labels (screen); |
|
365 |
+#endif |
|
366 |
update_showing_desktop (screen); |
|
10129 | 367 |
update_wm (screen); |
7480 | 368 |
|
13074 | 369 |
@@ -2815,3 +2939,86 @@ |
7480 | 370 |
|
371 |
g_free (names); |
|
372 |
} |
|
373 |
+ |
|
374 |
+#ifdef HAVE_XTSOL |
|
375 |
+void |
|
376 |
+_wnck_screen_change_workspace_label (WnckScreen *screen, |
|
377 |
+ int number, |
|
378 |
+ const char *label) |
|
379 |
+{ |
|
380 |
+ int n_spaces; |
|
381 |
+ char **labels; |
|
382 |
+ int i; |
|
383 |
+ int error=-2; |
|
384 |
+ m_label_t *mlabel = NULL; |
|
385 |
+ |
|
386 |
+ static char *lower_sl_str = NULL; |
|
387 |
+ static char *upper_clear_str = NULL; |
|
388 |
+ static blrange_t *workspace_range = NULL; |
|
389 |
+ |
|
390 |
+ WnckWorkspace *tmp_space = NULL; |
|
391 |
+ |
|
392 |
+ /* First check that we are running in a trusted windowing environment */ |
|
393 |
+ if (! _wnck_check_xtsol_extension ()) { |
|
394 |
+ g_warning("Workspace labelling can not work with out the SUN_TSOL X extension"); |
|
395 |
+ return; |
|
396 |
+ } |
|
397 |
+ |
|
398 |
+ if (!_wnck_use_trusted_extensions()) |
|
399 |
+ return; |
|
400 |
+ |
|
401 |
+ /* |
|
402 |
+ * Label must be validated. |
|
403 |
+ * Convert the label string to a binary MAC_LABEL type. |
|
404 |
+ * Then check that it is in the workspace's range which |
|
405 |
+ * depends on what role (if any) the workspace has. |
|
406 |
+ */ |
|
407 |
+ |
|
408 |
+ if (libtsol_str_to_label (label, &mlabel, MAC_LABEL, L_NO_CORRECTION, &error) < 0) { |
|
409 |
+ g_warning("Could not validate sensitivity label \"%s\"", label); |
|
410 |
+ return; |
|
411 |
+ } |
|
412 |
+ |
|
413 |
+ tmp_space = wnck_screen_get_workspace (screen, number); |
|
11201 | 414 |
+ /* need to refresh the role cache if an app is calling change label |
415 |
+ * after setting directly the _NET_DESKTOP_ROLES as this wouldn't have been |
|
416 |
+ * updated in libwnck yet */ |
|
417 |
+ screen->priv->need_update_workspace_roles = TRUE; |
|
418 |
+ update_workspace_roles (screen); |
|
419 |
+ workspace_range = _wnck_workspace_get_range (tmp_space); |
|
7480 | 420 |
+ |
421 |
+ if (!libtsol_blinrange (mlabel, workspace_range)) { |
|
422 |
+ g_warning("Could not change the sensitivity label of workspace %d because \"%s\" " |
|
423 |
+ "appears to be outside of the workspace's label range", number, label); |
|
424 |
+ libtsol_m_label_free (mlabel); |
|
425 |
+ return; |
|
426 |
+ } |
|
427 |
+ |
|
428 |
+ n_spaces = wnck_screen_get_workspace_count (screen); |
|
429 |
+ |
|
430 |
+ labels = g_new0 (char*, n_spaces + 1); |
|
431 |
+ |
|
432 |
+ i = 0; |
|
433 |
+ while (i < n_spaces) { |
|
434 |
+ if (i == number) |
|
435 |
+ labels[i] = (char*) label; |
|
436 |
+ else { |
|
437 |
+ WnckWorkspace *workspace; |
|
438 |
+ workspace = wnck_screen_get_workspace (screen, i); |
|
439 |
+ if (workspace) { |
|
440 |
+ labels[i] = (char*) wnck_workspace_get_label (workspace); |
|
441 |
+ if (labels[i] == NULL) |
|
442 |
+ labels[i] = (char*) ""; /* Maybe a g_warning too ? */ |
|
443 |
+ } else |
|
444 |
+ labels[i] = (char*) ""; /* maybe this should be a g_warning too */ |
|
445 |
+ } |
|
446 |
+ i++; |
|
447 |
+ } |
|
448 |
+ |
|
449 |
+ _wnck_set_utf8_list (screen->priv->xroot, |
|
450 |
+ _wnck_atom_get ("_NET_DESKTOP_LABELS"), |
|
451 |
+ labels); |
|
452 |
+ libtsol_m_label_free (mlabel); |
|
453 |
+ g_free (labels); |
|
454 |
+} |
|
455 |
+#endif /* HAVE_XTSOL */ |
|
13074 | 456 |
diff -urN libwnck.orig/libwnck/tasklist.c libwnck.new/libwnck/tasklist.c |
457 |
--- libwnck.orig/libwnck/tasklist.c 2008-08-06 23:43:13.368589000 +0100 |
|
458 |
+++ libwnck.new/libwnck/tasklist.c 2008-08-06 23:43:40.101354000 +0100 |
|
11201 | 459 |
@@ -36,6 +36,10 @@ |
7480 | 460 |
#include "workspace.h" |
461 |
#include "xutils.h" |
|
462 |
#include "private.h" |
|
463 |
+#ifdef HAVE_XTSOL |
|
464 |
+#include "wnck-tsol.h" |
|
465 |
+#include "trusted-tooltips.h" |
|
466 |
+#endif /* HAVE_XTSOL */ |
|
467 |
||
10129 | 468 |
/** |
469 |
* SECTION:tasklist |
|
12160 | 470 |
@@ -200,6 +204,10 @@ |
7480 | 471 |
GHashTable *class_group_hash; |
472 |
GHashTable *win_hash; |
|
473 |
||
474 |
+#ifdef HAVE_XTSOL |
|
475 |
+ TrustedTooltips *tooltips; |
|
10129 | 476 |
+#endif /*HAVE_XTSOL*/ |
477 |
+ |
|
7480 | 478 |
gint max_button_width; |
479 |
gint max_button_height; |
|
10129 | 480 |
|
12160 | 481 |
@@ -2123,6 +2131,10 @@ |
10129 | 482 |
WnckTasklist *tasklist; |
7480 | 483 |
|
484 |
tasklist = g_object_new (WNCK_TYPE_TASKLIST, NULL); |
|
9890
d929dccb218b
Commit libwnck-01 TX patch mentioned in ChangeLog.
dcarbery
parents:
9275
diff
changeset
|
485 |
+#ifdef HAVE_XTSOL |
12160 | 486 |
+ if (_wnck_use_trusted_extensions () == TRUE) |
487 |
+ tasklist->priv->tooltips = trusted_tooltips_new (); |
|
10129 | 488 |
+#endif /*HAVE_XTSOL*/ |
7480 | 489 |
|
10129 | 490 |
return GTK_WIDGET (tasklist); |
491 |
} |
|
12160 | 492 |
@@ -2960,6 +2972,10 @@ |
7480 | 493 |
{ |
494 |
image = gtk_image_new_from_pixbuf (pixbuf); |
|
495 |
gtk_widget_show (image); |
|
496 |
+#ifdef HAVE_XTSOL |
|
497 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
498 |
+ image = window_menu_create_label_indicator (win_task->window, image); |
|
499 |
+#endif /*HAVE_XTSOL*/ |
|
500 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), |
|
501 |
image); |
|
502 |
g_object_unref (pixbuf); |
|
12160 | 503 |
@@ -3352,6 +3368,15 @@ |
10174 | 504 |
text = wnck_task_get_text (task, TRUE, TRUE); |
505 |
if (text != NULL) |
|
506 |
{ |
|
507 |
+#ifdef HAVE_XTSOL |
|
12160 | 508 |
+ if (_wnck_use_trusted_extensions () == TRUE) |
509 |
+ trusted_tooltips_set_tip (task->tasklist->priv->tooltips, |
|
510 |
+ task->button, |
|
511 |
+ text, |
|
512 |
+ task->window ? wnck_window_get_label_human_readable (task->window) : "", |
|
513 |
+ task->window ? wnck_window_get_label_color (task->window) : NULL, |
|
514 |
+ NULL); |
|
515 |
+#endif /* HAVE_XTSOL */ |
|
10174 | 516 |
gtk_label_set_text (GTK_LABEL (task->label), text); |
517 |
if (wnck_task_get_needs_attention (task)) |
|
518 |
{ |
|
12160 | 519 |
@@ -3812,7 +3837,24 @@ |
7480 | 520 |
g_free (text); |
521 |
||
10174 | 522 |
text = wnck_task_get_text (task, FALSE, FALSE); |
7480 | 523 |
+#ifdef HAVE_XTSOL |
12160 | 524 |
+ if (_wnck_use_trusted_extensions () == TRUE) |
7480 | 525 |
+ { |
12160 | 526 |
+ if (task->window) |
527 |
+ { |
|
528 |
+ trusted_tooltips_set_tip (task->tasklist->priv->tooltips, |
|
529 |
+ task->button, |
|
530 |
+ text, |
|
531 |
+ wnck_window_get_label_human_readable (task->window), |
|
532 |
+ wnck_window_get_label_color (task->window), |
|
533 |
+ NULL); |
|
534 |
+ } |
|
535 |
+ else |
|
536 |
+ trusted_tooltips_set_tip (task->tasklist->priv->tooltips, task->button, text, "Hum No Label", NULL, NULL); |
|
537 |
+ } |
|
7480 | 538 |
+#else |
10174 | 539 |
gtk_widget_set_tooltip_text (task->button, text); |
7480 | 540 |
+#endif /*HAVE_XTSOL*/ |
541 |
g_free (text); |
|
542 |
||
543 |
/* Set up signals */ |
|
12160 | 544 |
@@ -4182,6 +4224,48 @@ |
10174 | 545 |
#endif |
7480 | 546 |
} |
547 |
||
548 |
+#ifdef HAVE_XTSOL |
|
10174 | 549 |
+static void |
7480 | 550 |
+draw_trusted_label (GtkWidget* widget, WnckTask *task) |
551 |
+{ |
|
552 |
+ GtkStyle *style; |
|
553 |
+ int x_offset; |
|
554 |
+ ConstraintImage *cimage; |
|
555 |
+ GdkRectangle area; |
|
556 |
+ |
|
557 |
+ style = task->button->style; |
|
558 |
+ /* get the width of the icon and the padding */ |
|
559 |
+ x_offset = task->image->allocation.width + (style->xthickness *2); |
|
10174 | 560 |
+ |
7480 | 561 |
+ area.x = widget->allocation.x + x_offset; |
562 |
+ area.y = widget->allocation.y + 2; |
|
563 |
+ area.width = widget->allocation.width - x_offset; |
|
564 |
+ area.height = task->label->allocation.y -task->button->allocation.y; |
|
10174 | 565 |
+ |
566 |
+ cimage = get_highlight_stripe ((char*)wnck_window_get_label (task->window), |
|
567 |
+ wnck_window_get_label_color (task->window)); |
|
7480 | 568 |
+ |
569 |
+ if (cimage) |
|
570 |
+ libgnome_tsol_constraint_image_render (cimage, widget->window, |
|
10174 | 571 |
+ NULL, &area, |
572 |
+ FALSE, |
|
573 |
+ area.x, |
|
574 |
+ area.y, |
|
575 |
+ area.width, |
|
576 |
+ area.height); |
|
7480 | 577 |
+} |
578 |
+ |
|
579 |
+ |
|
580 |
+gboolean |
|
581 |
+wnck_task_class_expose (GtkWidget *widget, |
|
10174 | 582 |
+ GdkEventExpose *event, |
583 |
+ gpointer data) |
|
7480 | 584 |
+{ |
585 |
+ draw_trusted_label (widget, (WnckTask*) data); |
|
586 |
+ return FALSE; |
|
587 |
+} |
|
588 |
+#endif /* HAVE_XTSOL */ |
|
589 |
+ |
|
10174 | 590 |
static WnckTask * |
591 |
wnck_task_new_from_window (WnckTasklist *tasklist, |
|
592 |
WnckWindow *window) |
|
12160 | 593 |
@@ -4197,6 +4281,14 @@ |
7480 | 594 |
|
595 |
wnck_task_create_widgets (task, tasklist->priv->relief); |
|
596 |
||
597 |
+#ifdef HAVE_XTSOL |
|
598 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
599 |
+ g_signal_connect_object (task->button, "expose_event", |
|
10174 | 600 |
+ G_CALLBACK (wnck_task_class_expose), |
601 |
+ G_OBJECT (task), |
|
602 |
+ G_CONNECT_AFTER); |
|
603 |
+#endif /* HAVE_XTSOL */ |
|
7480 | 604 |
+ |
605 |
remove_startup_sequences_for_window (tasklist, window); |
|
606 |
||
607 |
return task; |
|
13074 | 608 |
diff -urN libwnck.orig/libwnck/trusted-tooltips.c libwnck.new/libwnck/trusted-tooltips.c |
609 |
--- libwnck.orig/libwnck/trusted-tooltips.c 1970-01-01 01:00:00.000000000 +0100 |
|
610 |
+++ libwnck.new/libwnck/trusted-tooltips.c 2008-08-06 23:43:40.105541000 +0100 |
|
7480 | 611 |
@@ -0,0 +1,916 @@ |
612 |
+/* GTK - The GIMP Toolkit |
|
613 |
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
|
614 |
+ * |
|
615 |
+ * This library is free software; you can redistribute it and/or |
|
616 |
+ * modify it under the terms of the GNU Lesser General Public |
|
617 |
+ * License as published by the Free Software Foundation; either |
|
618 |
+ * version 2 of the License, or (at your option) any later version. |
|
619 |
+ * |
|
620 |
+ * This library is distributed in the hope that it will be useful, |
|
621 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
622 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
623 |
+ * Lesser General Public License for more details. |
|
624 |
+ * |
|
625 |
+ * You should have received a copy of the GNU Lesser General Public |
|
626 |
+ * License along with this library; if not, write to the |
|
627 |
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
628 |
+ * Boston, MA 02111-1307, USA. |
|
629 |
+ */ |
|
630 |
+ |
|
631 |
+/* |
|
632 |
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
|
633 |
+ * file for a list of people on the GTK+ Team. See the ChangeLog |
|
634 |
+ * files for a list of changes. These files are distributed with |
|
635 |
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
|
636 |
+ * |
|
637 |
+ * Modified for trusted JDS by Erwann Chenede - <[email protected]> 2005 |
|
638 |
+ * Copyright (C) Sun Microsystems 2005 |
|
639 |
+ */ |
|
640 |
+ |
|
641 |
+#include <config.h> |
|
642 |
+#include <stdlib.h> |
|
643 |
+#include <string.h> |
|
644 |
+#include <stdio.h> |
|
645 |
+ |
|
646 |
+#ifdef HAVE_XTSOL |
|
647 |
+#include "trusted-tooltips.h" |
|
648 |
+#include "workspace.h" |
|
649 |
+#include <wnck-tsol.h> |
|
650 |
+#include <gtk/gtk.h> |
|
651 |
+ |
|
652 |
+ |
|
653 |
+#define DEFAULT_DELAY 500 /* Default delay in ms */ |
|
654 |
+#define STICKY_DELAY 0 /* Delay before popping up next tip |
|
655 |
+ * if we're sticky |
|
656 |
+ */ |
|
657 |
+#define STICKY_REVERT_DELAY 1000 /* Delay before sticky tooltips revert |
|
658 |
+ * to normal |
|
659 |
+ */ |
|
660 |
+ |
|
661 |
+static void trusted_tooltips_class_init (TrustedTooltipsClass *klass); |
|
662 |
+static void trusted_tooltips_init (TrustedTooltips *tooltips); |
|
663 |
+static void trusted_tooltips_destroy (GtkObject *object); |
|
664 |
+ |
|
665 |
+static void trusted_tooltips_event_handler (GtkWidget *widget, |
|
666 |
+ GdkEvent *event); |
|
667 |
+static void trusted_tooltips_widget_unmap (GtkWidget *widget, |
|
668 |
+ gpointer data); |
|
669 |
+static void trusted_tooltips_widget_remove (GtkWidget *widget, |
|
670 |
+ gpointer data); |
|
671 |
+static void trusted_tooltips_set_active_widget (TrustedTooltips *tooltips, |
|
672 |
+ GtkWidget *widget); |
|
673 |
+static gint trusted_tooltips_timeout (gpointer data); |
|
674 |
+ |
|
675 |
+static gint trusted_tooltips_paint_window (TrustedTooltips *tooltips); |
|
676 |
+static void trusted_tooltips_draw_tips (TrustedTooltips *tooltips); |
|
677 |
+static void trusted_tooltips_unset_tip_window (TrustedTooltips *tooltips); |
|
678 |
+ |
|
679 |
+static gboolean get_keyboard_mode (GtkWidget *widget); |
|
680 |
+ |
|
681 |
+static GtkObjectClass *parent_class; |
|
682 |
+static const gchar tooltips_data_key[] = "_TrustedTooltipsData"; |
|
683 |
+static const gchar tooltips_info_key[] = "_TrustedTooltipsInfo"; |
|
684 |
+ |
|
685 |
+GType |
|
686 |
+trusted_tooltips_get_type (void) |
|
687 |
+{ |
|
688 |
+ static GType tooltips_type = 0; |
|
689 |
+ |
|
690 |
+ if (!tooltips_type) |
|
691 |
+ { |
|
692 |
+ static const GTypeInfo tooltips_info = |
|
693 |
+ { |
|
694 |
+ sizeof (TrustedTooltipsClass), |
|
695 |
+ NULL, /* base_init */ |
|
696 |
+ NULL, /* base_finalize */ |
|
697 |
+ (GClassInitFunc) trusted_tooltips_class_init, |
|
698 |
+ NULL, /* class_finalize */ |
|
699 |
+ NULL, /* class_data */ |
|
700 |
+ sizeof (TrustedTooltips), |
|
701 |
+ 0, /* n_preallocs */ |
|
702 |
+ (GInstanceInitFunc) trusted_tooltips_init, |
|
703 |
+ }; |
|
704 |
+ |
|
705 |
+ tooltips_type = g_type_register_static (GTK_TYPE_OBJECT, "TrustedTooltips", |
|
706 |
+ &tooltips_info, 0); |
|
707 |
+ } |
|
708 |
+ |
|
709 |
+ return tooltips_type; |
|
710 |
+} |
|
711 |
+ |
|
712 |
+static void |
|
713 |
+trusted_tooltips_class_init (TrustedTooltipsClass *class) |
|
714 |
+{ |
|
715 |
+ GtkObjectClass *object_class; |
|
716 |
+ |
|
717 |
+ object_class = (GtkObjectClass*) class; |
|
718 |
+ |
|
719 |
+ parent_class = g_type_class_peek_parent (class); |
|
720 |
+ |
|
721 |
+ object_class->destroy = trusted_tooltips_destroy; |
|
722 |
+} |
|
723 |
+ |
|
724 |
+static void |
|
725 |
+trusted_tooltips_init (TrustedTooltips *tooltips) |
|
726 |
+{ |
|
727 |
+ tooltips->tip_window = NULL; |
|
728 |
+ tooltips->active_tips_data = NULL; |
|
729 |
+ tooltips->tips_data_list = NULL; |
|
730 |
+ |
|
731 |
+ tooltips->delay = DEFAULT_DELAY; |
|
732 |
+ tooltips->enabled = TRUE; |
|
733 |
+ tooltips->timer_tag = 0; |
|
734 |
+ tooltips->use_sticky_delay = FALSE; |
|
735 |
+ tooltips->last_popdown.tv_sec = -1; |
|
736 |
+ tooltips->last_popdown.tv_usec = -1; |
|
737 |
+ tooltips->pager = NULL; |
|
738 |
+} |
|
739 |
+ |
|
740 |
+TrustedTooltips * |
|
741 |
+trusted_tooltips_new (void) |
|
742 |
+{ |
|
743 |
+ return g_object_new (TRUSTED_TOOLTIPS_TYPE, NULL); |
|
744 |
+} |
|
745 |
+ |
|
746 |
+static void |
|
747 |
+trusted_tooltips_destroy_data (TrustedTooltipsData *tooltipsdata) |
|
748 |
+{ |
|
749 |
+ g_free (tooltipsdata->tip_text); |
|
750 |
+ g_free (tooltipsdata->trusted_label); |
|
751 |
+ g_free (tooltipsdata->tip_private); |
|
752 |
+ |
|
753 |
+ g_signal_handlers_disconnect_by_func (tooltipsdata->widget, |
|
754 |
+ (gpointer)trusted_tooltips_event_handler, |
|
755 |
+ tooltipsdata); |
|
756 |
+ g_signal_handlers_disconnect_by_func (tooltipsdata->widget, |
|
757 |
+ (gpointer)trusted_tooltips_widget_unmap, |
|
758 |
+ tooltipsdata); |
|
759 |
+ g_signal_handlers_disconnect_by_func (tooltipsdata->widget, |
|
760 |
+ (gpointer)trusted_tooltips_widget_remove, |
|
761 |
+ tooltipsdata); |
|
762 |
+ |
|
763 |
+ g_object_set_data (G_OBJECT (tooltipsdata->widget), tooltips_data_key, NULL); |
|
764 |
+ g_object_unref (tooltipsdata->widget); |
|
765 |
+ g_free (tooltipsdata); |
|
766 |
+} |
|
767 |
+ |
|
768 |
+static void |
|
769 |
+tip_window_display_closed (GdkDisplay *display, |
|
770 |
+ gboolean was_error, |
|
771 |
+ TrustedTooltips *tooltips) |
|
772 |
+{ |
|
773 |
+ trusted_tooltips_unset_tip_window (tooltips); |
|
774 |
+} |
|
775 |
+ |
|
776 |
+static void |
|
777 |
+disconnect_tip_window_display_closed (TrustedTooltips *tooltips) |
|
778 |
+{ |
|
779 |
+ g_signal_handlers_disconnect_by_func (gtk_widget_get_display (tooltips->tip_window), |
|
780 |
+ (gpointer) tip_window_display_closed, |
|
781 |
+ tooltips); |
|
782 |
+} |
|
783 |
+ |
|
784 |
+static void |
|
785 |
+trusted_tooltips_unset_tip_window (TrustedTooltips *tooltips) |
|
786 |
+{ |
|
787 |
+ if (tooltips->tip_window) |
|
788 |
+ { |
|
789 |
+ disconnect_tip_window_display_closed (tooltips); |
|
790 |
+ |
|
791 |
+ gtk_widget_destroy (tooltips->tip_window); |
|
792 |
+ tooltips->tip_window = NULL; |
|
793 |
+ } |
|
794 |
+} |
|
795 |
+ |
|
796 |
+static void |
|
797 |
+trusted_tooltips_destroy (GtkObject *object) |
|
798 |
+{ |
|
799 |
+ TrustedTooltips *tooltips = TRUSTED_TOOLTIPS (object); |
|
800 |
+ GList *current; |
|
801 |
+ TrustedTooltipsData *tooltipsdata; |
|
802 |
+ |
|
803 |
+ g_return_if_fail (tooltips != NULL); |
|
804 |
+ |
|
805 |
+ if (tooltips->timer_tag) |
|
806 |
+ { |
|
807 |
+ g_source_remove (tooltips->timer_tag); |
|
808 |
+ tooltips->timer_tag = 0; |
|
809 |
+ } |
|
810 |
+ |
|
811 |
+ if (tooltips->tips_data_list != NULL) |
|
812 |
+ { |
|
813 |
+ current = g_list_first (tooltips->tips_data_list); |
|
814 |
+ while (current != NULL) |
|
815 |
+ { |
|
816 |
+ tooltipsdata = (TrustedTooltipsData*) current->data; |
|
817 |
+ current = current->next; |
|
818 |
+ trusted_tooltips_widget_remove (tooltipsdata->widget, tooltipsdata); |
|
819 |
+ } |
|
820 |
+ } |
|
821 |
+ |
|
822 |
+ trusted_tooltips_unset_tip_window (tooltips); |
|
823 |
+ |
|
824 |
+ GTK_OBJECT_CLASS (parent_class)->destroy (object); |
|
825 |
+} |
|
826 |
+ |
|
827 |
+static void |
|
828 |
+trusted_tooltips_update_screen (TrustedTooltips *tooltips, |
|
829 |
+ gboolean new_window) |
|
830 |
+{ |
|
831 |
+ gboolean screen_changed = FALSE; |
|
832 |
+ |
|
833 |
+ if (tooltips->active_tips_data && |
|
834 |
+ tooltips->active_tips_data->widget) |
|
835 |
+ { |
|
836 |
+ GdkScreen *screen = gtk_widget_get_screen (tooltips->active_tips_data->widget); |
|
837 |
+ |
|
838 |
+ screen_changed = (screen != gtk_widget_get_screen (tooltips->tip_window)); |
|
839 |
+ |
|
840 |
+ if (screen_changed) |
|
841 |
+ { |
|
842 |
+ if (!new_window) |
|
843 |
+ disconnect_tip_window_display_closed (tooltips); |
|
844 |
+ |
|
845 |
+ gtk_window_set_screen (GTK_WINDOW (tooltips->tip_window), screen); |
|
846 |
+ } |
|
847 |
+ } |
|
848 |
+ |
|
849 |
+ if (screen_changed || new_window) |
|
850 |
+ g_signal_connect (gtk_widget_get_display (tooltips->tip_window), "closed", |
|
851 |
+ G_CALLBACK (tip_window_display_closed), tooltips); |
|
852 |
+ |
|
853 |
+} |
|
854 |
+ |
|
855 |
+void |
|
856 |
+trusted_tooltips_force_window (TrustedTooltips *tooltips) |
|
857 |
+{ |
|
858 |
+ g_return_if_fail (IS_TRUSTED_TOOLTIPS (tooltips)); |
|
859 |
+ |
|
860 |
+ if (!tooltips->tip_window) |
|
861 |
+ { |
|
862 |
+ GtkWidget * vbox; |
|
863 |
+ |
|
864 |
+ tooltips->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
865 |
+ trusted_tooltips_update_screen (tooltips, TRUE); |
|
866 |
+ gtk_widget_set_app_paintable (tooltips->tip_window, TRUE); |
|
867 |
+ gtk_window_set_resizable (GTK_WINDOW (tooltips->tip_window), FALSE); |
|
868 |
+ gtk_widget_set_name (tooltips->tip_window, "gtk-tooltips"); |
|
869 |
+ gtk_container_set_border_width (GTK_CONTAINER (tooltips->tip_window), 2); |
|
870 |
+ |
|
871 |
+ g_signal_connect_swapped (tooltips->tip_window, |
|
872 |
+ "expose_event", |
|
873 |
+ G_CALLBACK (trusted_tooltips_paint_window), |
|
874 |
+ tooltips); |
|
875 |
+ |
|
876 |
+ tooltips->tip_label = gtk_label_new (NULL); |
|
877 |
+ gtk_label_set_line_wrap (GTK_LABEL (tooltips->tip_label), FALSE); |
|
878 |
+ gtk_misc_set_alignment (GTK_MISC (tooltips->tip_label), 0.5, 0.5); |
|
879 |
+ gtk_widget_show (tooltips->tip_label); |
|
880 |
+ |
|
881 |
+ tooltips->tip_trusted_label = gtk_label_new (NULL); |
|
882 |
+ gtk_label_set_line_wrap (GTK_LABEL (tooltips->tip_trusted_label), FALSE); |
|
883 |
+ gtk_misc_set_alignment (GTK_MISC (tooltips->tip_trusted_label), 0.5, 0.5); |
|
884 |
+ gtk_widget_show (tooltips->tip_trusted_label); |
|
885 |
+ |
|
886 |
+ vbox = gtk_vbox_new (FALSE, 1); |
|
887 |
+ tooltips->event = gtk_event_box_new (); |
|
888 |
+ |
|
889 |
+ gtk_container_add (GTK_CONTAINER (tooltips->event), tooltips->tip_trusted_label); |
|
890 |
+ |
|
891 |
+ gtk_container_add (GTK_CONTAINER (vbox), tooltips->event); |
|
892 |
+ |
|
893 |
+ gtk_container_add (GTK_CONTAINER (vbox), tooltips->tip_label); |
|
894 |
+ gtk_container_add (GTK_CONTAINER (tooltips->tip_window), vbox); |
|
895 |
+ |
|
896 |
+ gtk_widget_show (vbox); |
|
897 |
+ gtk_widget_show (tooltips->event); |
|
898 |
+ |
|
899 |
+ g_signal_connect (tooltips->tip_window, |
|
900 |
+ "destroy", |
|
901 |
+ G_CALLBACK (gtk_widget_destroyed), |
|
902 |
+ &tooltips->tip_window); |
|
903 |
+ } |
|
904 |
+} |
|
905 |
+ |
|
906 |
+void |
|
907 |
+trusted_tooltips_enable (TrustedTooltips *tooltips) |
|
908 |
+{ |
|
909 |
+ g_return_if_fail (tooltips != NULL); |
|
910 |
+ |
|
911 |
+ tooltips->enabled = TRUE; |
|
912 |
+} |
|
913 |
+ |
|
914 |
+void |
|
915 |
+trusted_tooltips_disable (TrustedTooltips *tooltips) |
|
916 |
+{ |
|
917 |
+ g_return_if_fail (tooltips != NULL); |
|
918 |
+ |
|
919 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
920 |
+ |
|
921 |
+ tooltips->enabled = FALSE; |
|
922 |
+} |
|
923 |
+ |
|
924 |
+void |
|
925 |
+trusted_tooltips_set_delay (TrustedTooltips *tooltips, |
|
926 |
+ guint delay) |
|
927 |
+{ |
|
928 |
+ g_return_if_fail (tooltips != NULL); |
|
929 |
+ |
|
930 |
+ tooltips->delay = delay; |
|
931 |
+} |
|
932 |
+ |
|
933 |
+TrustedTooltipsData* |
|
934 |
+trusted_tooltips_data_get (GtkWidget *widget) |
|
935 |
+{ |
|
936 |
+ g_return_val_if_fail (widget != NULL, NULL); |
|
937 |
+ |
|
938 |
+ return g_object_get_data (G_OBJECT (widget), tooltips_data_key); |
|
939 |
+} |
|
940 |
+ |
|
941 |
+void |
|
942 |
+trusted_tooltips_set_tip (TrustedTooltips *tooltips, |
|
943 |
+ GtkWidget *widget, |
|
944 |
+ const gchar *tip_text, |
|
945 |
+ const gchar *trusted_label, |
|
946 |
+ GdkColor *trusted_color, |
|
947 |
+ const gchar *tip_private) |
|
948 |
+{ |
|
949 |
+ TrustedTooltipsData *tooltipsdata; |
|
950 |
+ |
|
951 |
+ g_return_if_fail (IS_TRUSTED_TOOLTIPS (tooltips)); |
|
952 |
+ g_return_if_fail (widget != NULL); |
|
953 |
+ |
|
954 |
+ tooltipsdata = trusted_tooltips_data_get (widget); |
|
955 |
+ |
|
956 |
+ if (!tip_text) |
|
957 |
+ { |
|
958 |
+ if (tooltipsdata) |
|
959 |
+ trusted_tooltips_widget_remove (tooltipsdata->widget, tooltipsdata); |
|
960 |
+ return; |
|
961 |
+ } |
|
962 |
+ |
|
963 |
+ if (tooltips->active_tips_data |
|
964 |
+ && tooltips->active_tips_data->widget == widget |
|
965 |
+ && GTK_WIDGET_DRAWABLE (tooltips->active_tips_data->widget)) |
|
966 |
+ { |
|
967 |
+ g_free (tooltipsdata->tip_text); |
|
968 |
+ g_free (tooltipsdata->tip_private); |
|
969 |
+ |
|
970 |
+ tooltipsdata->tip_text = g_strdup (tip_text); |
|
971 |
+ tooltipsdata->tip_private = g_strdup (tip_private); |
|
972 |
+ |
|
973 |
+ trusted_tooltips_draw_tips (tooltips); |
|
974 |
+ } |
|
975 |
+ else |
|
976 |
+ { |
|
977 |
+ g_object_ref (widget); |
|
978 |
+ |
|
979 |
+ if (tooltipsdata) |
|
980 |
+ trusted_tooltips_widget_remove (tooltipsdata->widget, tooltipsdata); |
|
981 |
+ |
|
982 |
+ tooltipsdata = g_new0 (TrustedTooltipsData, 1); |
|
983 |
+ |
|
984 |
+ tooltipsdata->tooltips = tooltips; |
|
985 |
+ tooltipsdata->widget = widget; |
|
986 |
+ |
|
987 |
+ tooltipsdata->tip_text = g_strdup (tip_text); |
|
988 |
+ tooltipsdata->trusted_label = g_strdup (trusted_label); |
|
989 |
+ tooltipsdata->tip_private = g_strdup (tip_private); |
|
990 |
+ if (trusted_color) |
|
991 |
+ tooltipsdata->trusted_color = trusted_color; |
|
992 |
+ |
|
993 |
+ tooltips->tips_data_list = g_list_append (tooltips->tips_data_list, |
|
994 |
+ tooltipsdata); |
|
995 |
+ g_signal_connect_after (widget, "event-after", |
|
996 |
+ G_CALLBACK (trusted_tooltips_event_handler), |
|
997 |
+ tooltipsdata); |
|
998 |
+ |
|
999 |
+ g_object_set_data (G_OBJECT (widget), tooltips_data_key, |
|
1000 |
+ tooltipsdata); |
|
1001 |
+ |
|
1002 |
+ g_signal_connect (widget, "unmap", |
|
1003 |
+ G_CALLBACK (trusted_tooltips_widget_unmap), |
|
1004 |
+ tooltipsdata); |
|
1005 |
+ |
|
1006 |
+ g_signal_connect (widget, "unrealize", |
|
1007 |
+ G_CALLBACK (trusted_tooltips_widget_unmap), |
|
1008 |
+ tooltipsdata); |
|
1009 |
+ |
|
1010 |
+ g_signal_connect (widget, "destroy", |
|
1011 |
+ G_CALLBACK (trusted_tooltips_widget_remove), |
|
1012 |
+ tooltipsdata); |
|
1013 |
+ } |
|
1014 |
+} |
|
1015 |
+ |
|
1016 |
+static gint |
|
1017 |
+trusted_tooltips_paint_window (TrustedTooltips *tooltips) |
|
1018 |
+{ |
|
1019 |
+ GtkRequisition req; |
|
1020 |
+ |
|
1021 |
+ gtk_widget_size_request (tooltips->tip_window, &req); |
|
1022 |
+ gtk_paint_flat_box (tooltips->tip_window->style, tooltips->tip_window->window, |
|
1023 |
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT, |
|
1024 |
+ NULL, GTK_WIDGET(tooltips->tip_window), "tooltip", |
|
1025 |
+ 0, 0, req.width, req.height); |
|
1026 |
+ |
|
1027 |
+ return FALSE; |
|
1028 |
+} |
|
1029 |
+ |
|
1030 |
+static void |
|
1031 |
+trusted_tooltips_draw_tips (TrustedTooltips *tooltips) |
|
1032 |
+{ |
|
1033 |
+ GtkRequisition requisition; |
|
1034 |
+ GtkWidget *widget; |
|
1035 |
+ GtkStyle *style; |
|
1036 |
+ gint x, y, w, h; |
|
1037 |
+ TrustedTooltipsData *data; |
|
1038 |
+ gboolean keyboard_mode; |
|
1039 |
+ GdkScreen *screen; |
|
1040 |
+ GdkScreen *pointer_screen; |
|
1041 |
+ gint monitor_num, px, py; |
|
1042 |
+ GdkRectangle monitor; |
|
1043 |
+ |
|
1044 |
+ if (!tooltips->tip_window) |
|
1045 |
+ trusted_tooltips_force_window (tooltips); |
|
1046 |
+ else if (GTK_WIDGET_VISIBLE (tooltips->tip_window)) |
|
1047 |
+ g_get_current_time (&tooltips->last_popdown); |
|
1048 |
+ |
|
1049 |
+ gtk_widget_ensure_style (tooltips->tip_window); |
|
1050 |
+ style = tooltips->tip_window->style; |
|
1051 |
+ |
|
1052 |
+ widget = tooltips->active_tips_data->widget; |
|
1053 |
+ g_object_set_data (G_OBJECT (tooltips->tip_window), tooltips_info_key, |
|
1054 |
+ tooltips); |
|
1055 |
+ |
|
1056 |
+ keyboard_mode = get_keyboard_mode (widget); |
|
1057 |
+ |
|
1058 |
+ trusted_tooltips_update_screen (tooltips, FALSE); |
|
1059 |
+ |
|
1060 |
+ screen = gtk_widget_get_screen (widget); |
|
1061 |
+ |
|
1062 |
+ data = tooltips->active_tips_data; |
|
1063 |
+ |
|
1064 |
+ if (tooltips->pager) /* pager special case */ |
|
1065 |
+ { |
|
1066 |
+ char *colorname; |
|
1067 |
+ int error; |
|
1068 |
+ GdkColor label_color; |
|
1069 |
+ m_label_t *mlabel = NULL; |
|
1070 |
+ WnckWorkspace *tip_ws = g_object_get_data (G_OBJECT (tooltips->pager), |
|
1071 |
+ "tip_ws"); |
|
1072 |
+ |
|
1073 |
+ const char *label = wnck_workspace_get_label (tip_ws); |
|
1074 |
+ |
|
1075 |
+ gtk_label_set_text (GTK_LABEL (tooltips->tip_label), |
|
1076 |
+ wnck_workspace_get_name (tip_ws)); |
|
1077 |
+ |
|
1078 |
+ if (_wnck_use_trusted_extensions ()) |
|
1079 |
+ { |
|
1080 |
+ if (label != NULL && |
|
1081 |
+ (error = libtsol_str_to_label (label, &mlabel, MAC_LABEL, |
|
1082 |
+ L_NO_CORRECTION, &error)) == 0) |
|
1083 |
+ { |
|
1084 |
+ GdkPixbuf *pb; |
|
1085 |
+ guint32 rgba; |
|
1086 |
+ char *readable_label; |
|
1087 |
+ |
|
1088 |
+ error = libtsol_label_to_str (mlabel, &colorname, M_COLOR, DEF_NAMES); |
|
1089 |
+ |
|
1090 |
+#define DEFAULT_COLOR "white" |
|
1091 |
+ if (colorname == NULL) |
|
1092 |
+ colorname = g_strdup(DEFAULT_COLOR); |
|
1093 |
+ |
|
1094 |
+ gdk_color_parse ((const char*)colorname, &label_color); |
|
1095 |
+ |
|
1096 |
+ g_free (colorname); |
|
1097 |
+ |
|
1098 |
+ |
|
1099 |
+ readable_label = wnck_workspace_get_human_readable_label (tip_ws); |
|
1100 |
+ |
|
1101 |
+ gtk_label_set_text (GTK_LABEL (tooltips->tip_trusted_label), readable_label); |
|
1102 |
+ |
|
1103 |
+ g_free (readable_label); |
|
1104 |
+ |
|
1105 |
+ gtk_widget_modify_bg (tooltips->event, GTK_STATE_NORMAL, &label_color); |
|
1106 |
+ |
|
1107 |
+ gtk_widget_show (tooltips->event); |
|
1108 |
+ } |
|
1109 |
+ else /* failed call to libtsol_label_to_str */ |
|
1110 |
+ gtk_widget_hide (tooltips->event); |
|
1111 |
+ } |
|
1112 |
+ else /* not using trusted_extensions */ |
|
1113 |
+ gtk_widget_hide (tooltips->event); |
|
1114 |
+ } |
|
1115 |
+ else |
|
1116 |
+ { |
|
1117 |
+ gtk_label_set_text (GTK_LABEL (tooltips->tip_label), data->tip_text); |
|
1118 |
+ gtk_label_set_text (GTK_LABEL (tooltips->tip_trusted_label), data->trusted_label); |
|
1119 |
+ gtk_widget_modify_bg (tooltips->event, GTK_STATE_NORMAL, data->trusted_color); |
|
1120 |
+ if (data->trusted_color == NULL) |
|
1121 |
+ gtk_widget_hide (tooltips->event); |
|
1122 |
+ else |
|
1123 |
+ gtk_widget_show (tooltips->event); |
|
1124 |
+ } |
|
1125 |
+ |
|
1126 |
+ |
|
1127 |
+ gtk_widget_size_request (tooltips->tip_window, &requisition); |
|
1128 |
+ w = requisition.width; |
|
1129 |
+ h = requisition.height; |
|
1130 |
+ |
|
1131 |
+ gdk_window_get_origin (widget->window, &x, &y); |
|
1132 |
+ if (GTK_WIDGET_NO_WINDOW (widget)) |
|
1133 |
+ { |
|
1134 |
+ x += widget->allocation.x; |
|
1135 |
+ y += widget->allocation.y; |
|
1136 |
+ } |
|
1137 |
+ |
|
1138 |
+ x += widget->allocation.width / 2; |
|
1139 |
+ |
|
1140 |
+ if (!keyboard_mode) |
|
1141 |
+ gdk_window_get_pointer (gdk_screen_get_root_window (screen), |
|
1142 |
+ &x, NULL, NULL); |
|
1143 |
+ |
|
1144 |
+ x -= (w / 2 + 4); |
|
1145 |
+ |
|
1146 |
+ gdk_display_get_pointer (gdk_screen_get_display (screen), |
|
1147 |
+ &pointer_screen, &px, &py, NULL); |
|
1148 |
+ if (pointer_screen != screen) |
|
1149 |
+ { |
|
1150 |
+ px = x; |
|
1151 |
+ py = y; |
|
1152 |
+ } |
|
1153 |
+ monitor_num = gdk_screen_get_monitor_at_point (screen, px, py); |
|
1154 |
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); |
|
1155 |
+ |
|
1156 |
+ if ((x + w) > monitor.x + monitor.width) |
|
1157 |
+ x -= (x + w) - (monitor.x + monitor.width); |
|
1158 |
+ else if (x < monitor.x) |
|
1159 |
+ x = monitor.x; |
|
1160 |
+ |
|
1161 |
+ if ((y + h + widget->allocation.height + 4) > monitor.y + monitor.height) |
|
1162 |
+ y = y - h - 4; |
|
1163 |
+ else |
|
1164 |
+ y = y + widget->allocation.height + 4; |
|
1165 |
+ |
|
1166 |
+ gtk_window_move (GTK_WINDOW (tooltips->tip_window), x, y); |
|
1167 |
+ gtk_widget_show (tooltips->tip_window); |
|
1168 |
+} |
|
1169 |
+ |
|
1170 |
+static gint |
|
1171 |
+trusted_tooltips_timeout (gpointer data) |
|
1172 |
+{ |
|
1173 |
+ TrustedTooltips *tooltips = (TrustedTooltips *) data; |
|
1174 |
+ |
|
1175 |
+ GDK_THREADS_ENTER (); |
|
1176 |
+ |
|
1177 |
+ if (tooltips->active_tips_data != NULL && |
|
1178 |
+ GTK_WIDGET_DRAWABLE (tooltips->active_tips_data->widget)) |
|
1179 |
+ trusted_tooltips_draw_tips (tooltips); |
|
1180 |
+ |
|
1181 |
+ GDK_THREADS_LEAVE (); |
|
1182 |
+ |
|
1183 |
+ return FALSE; |
|
1184 |
+} |
|
1185 |
+ |
|
1186 |
+static void |
|
1187 |
+trusted_tooltips_set_active_widget (TrustedTooltips *tooltips, |
|
1188 |
+ GtkWidget *widget) |
|
1189 |
+{ |
|
1190 |
+ if (tooltips->tip_window) |
|
1191 |
+ { |
|
1192 |
+ if (GTK_WIDGET_VISIBLE (tooltips->tip_window)) |
|
1193 |
+ g_get_current_time (&tooltips->last_popdown); |
|
1194 |
+ gtk_widget_hide (tooltips->tip_window); |
|
1195 |
+ } |
|
1196 |
+ if (tooltips->timer_tag) |
|
1197 |
+ { |
|
1198 |
+ g_source_remove (tooltips->timer_tag); |
|
1199 |
+ tooltips->timer_tag = 0; |
|
1200 |
+ } |
|
1201 |
+ |
|
1202 |
+ tooltips->active_tips_data = NULL; |
|
1203 |
+ |
|
1204 |
+ if (widget) |
|
1205 |
+ { |
|
1206 |
+ GList *list; |
|
1207 |
+ |
|
1208 |
+ for (list = tooltips->tips_data_list; list; list = list->next) |
|
1209 |
+ { |
|
1210 |
+ TrustedTooltipsData *tooltipsdata; |
|
1211 |
+ |
|
1212 |
+ tooltipsdata = list->data; |
|
1213 |
+ |
|
1214 |
+ if (tooltipsdata->widget == widget && |
|
1215 |
+ GTK_WIDGET_DRAWABLE (widget)) |
|
1216 |
+ { |
|
1217 |
+ tooltips->active_tips_data = tooltipsdata; |
|
1218 |
+ break; |
|
1219 |
+ } |
|
1220 |
+ } |
|
1221 |
+ } |
|
1222 |
+ else |
|
1223 |
+ { |
|
1224 |
+ tooltips->use_sticky_delay = FALSE; |
|
1225 |
+ } |
|
1226 |
+} |
|
1227 |
+ |
|
1228 |
+static void |
|
1229 |
+trusted_tooltips_show_tip (GtkWidget *widget) |
|
1230 |
+{ |
|
1231 |
+ TrustedTooltipsData *tooltipsdata; |
|
1232 |
+ |
|
1233 |
+ tooltipsdata = trusted_tooltips_data_get (widget); |
|
1234 |
+ |
|
1235 |
+ if (tooltipsdata && |
|
1236 |
+ (!tooltipsdata->tooltips->active_tips_data || |
|
1237 |
+ tooltipsdata->tooltips->active_tips_data->widget != widget)) |
|
1238 |
+ { |
|
1239 |
+ trusted_tooltips_set_active_widget (tooltipsdata->tooltips, widget); |
|
1240 |
+ trusted_tooltips_draw_tips (tooltipsdata->tooltips); |
|
1241 |
+ } |
|
1242 |
+} |
|
1243 |
+ |
|
1244 |
+static void |
|
1245 |
+trusted_tooltips_hide_tip (GtkWidget *widget) |
|
1246 |
+{ |
|
1247 |
+ TrustedTooltipsData *tooltipsdata; |
|
1248 |
+ |
|
1249 |
+ tooltipsdata = trusted_tooltips_data_get (widget); |
|
1250 |
+ |
|
1251 |
+ if (tooltipsdata && |
|
1252 |
+ (tooltipsdata->tooltips->active_tips_data && |
|
1253 |
+ tooltipsdata->tooltips->active_tips_data->widget == widget)) |
|
1254 |
+ trusted_tooltips_set_active_widget (tooltipsdata->tooltips, NULL); |
|
1255 |
+} |
|
1256 |
+ |
|
1257 |
+static gboolean |
|
1258 |
+trusted_tooltips_recently_shown (TrustedTooltips *tooltips) |
|
1259 |
+{ |
|
1260 |
+ GTimeVal now; |
|
1261 |
+ glong msec; |
|
1262 |
+ |
|
1263 |
+ g_get_current_time (&now); |
|
1264 |
+ msec = (now.tv_sec - tooltips->last_popdown.tv_sec) * 1000 + |
|
1265 |
+ (now.tv_usec - tooltips->last_popdown.tv_usec) / 1000; |
|
1266 |
+ return (msec < STICKY_REVERT_DELAY); |
|
1267 |
+} |
|
1268 |
+ |
|
1269 |
+static gboolean |
|
1270 |
+get_keyboard_mode (GtkWidget *widget) |
|
1271 |
+{ |
|
1272 |
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget); |
|
1273 |
+ if (GTK_IS_WINDOW (toplevel)) |
|
1274 |
+ return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode")); |
|
1275 |
+ else |
|
1276 |
+ return FALSE; |
|
1277 |
+} |
|
1278 |
+ |
|
1279 |
+static void |
|
1280 |
+start_keyboard_mode (GtkWidget *widget) |
|
1281 |
+{ |
|
1282 |
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget); |
|
1283 |
+ if (GTK_IS_WINDOW (toplevel)) |
|
1284 |
+ { |
|
1285 |
+ GtkWidget *focus = GTK_WINDOW (toplevel)->focus_widget; |
|
1286 |
+ |
|
1287 |
+ g_object_set_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode", GUINT_TO_POINTER (TRUE)); |
|
1288 |
+ |
|
1289 |
+ if (focus) |
|
1290 |
+ trusted_tooltips_show_tip (focus); |
|
1291 |
+ } |
|
1292 |
+} |
|
1293 |
+ |
|
1294 |
+static void |
|
1295 |
+stop_keyboard_mode (GtkWidget *widget) |
|
1296 |
+{ |
|
1297 |
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget); |
|
1298 |
+ if (GTK_IS_WINDOW (toplevel)) |
|
1299 |
+ { |
|
1300 |
+ GtkWidget *focus = GTK_WINDOW (toplevel)->focus_widget; |
|
1301 |
+ if (focus) |
|
1302 |
+ trusted_tooltips_hide_tip (focus); |
|
1303 |
+ |
|
1304 |
+ g_object_set_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode", GUINT_TO_POINTER (FALSE)); |
|
1305 |
+ } |
|
1306 |
+} |
|
1307 |
+ |
|
1308 |
+static void |
|
1309 |
+trusted_tooltips_start_delay (TrustedTooltips *tooltips, |
|
1310 |
+ GtkWidget *widget) |
|
1311 |
+{ |
|
1312 |
+ TrustedTooltipsData *old_tips_data; |
|
1313 |
+ |
|
1314 |
+ old_tips_data = tooltips->active_tips_data; |
|
1315 |
+ if (tooltips->enabled && |
|
1316 |
+ (!old_tips_data || old_tips_data->widget != widget)) |
|
1317 |
+ { |
|
1318 |
+ guint delay; |
|
1319 |
+ |
|
1320 |
+ trusted_tooltips_set_active_widget (tooltips, widget); |
|
1321 |
+ |
|
1322 |
+ if (tooltips->use_sticky_delay && |
|
1323 |
+ trusted_tooltips_recently_shown (tooltips)) |
|
1324 |
+ delay = STICKY_DELAY; |
|
1325 |
+ else |
|
1326 |
+ delay = tooltips->delay; |
|
1327 |
+ tooltips->timer_tag = g_timeout_add (delay, |
|
1328 |
+ trusted_tooltips_timeout, |
|
1329 |
+ (gpointer) tooltips); |
|
1330 |
+ } |
|
1331 |
+} |
|
1332 |
+ |
|
1333 |
+static void |
|
1334 |
+trusted_tooltips_event_handler (GtkWidget *widget, |
|
1335 |
+ GdkEvent *event) |
|
1336 |
+{ |
|
1337 |
+ TrustedTooltips *tooltips; |
|
1338 |
+ TrustedTooltipsData *old_tips_data; |
|
1339 |
+ GtkWidget *event_widget; |
|
1340 |
+ gboolean keyboard_mode = get_keyboard_mode (widget); |
|
1341 |
+ |
|
1342 |
+ |
|
1343 |
+ if ((event->type == GDK_LEAVE_NOTIFY || event->type == GDK_ENTER_NOTIFY) && |
|
1344 |
+ event->crossing.detail == GDK_NOTIFY_INFERIOR) |
|
1345 |
+ return; |
|
1346 |
+ |
|
1347 |
+ old_tips_data = trusted_tooltips_data_get (widget); |
|
1348 |
+ tooltips = old_tips_data->tooltips; |
|
1349 |
+ |
|
1350 |
+ if (keyboard_mode) |
|
1351 |
+ { |
|
1352 |
+ switch (event->type) |
|
1353 |
+ { |
|
1354 |
+ case GDK_FOCUS_CHANGE: |
|
1355 |
+ if (event->focus_change.in) |
|
1356 |
+ trusted_tooltips_show_tip (widget); |
|
1357 |
+ else |
|
1358 |
+ trusted_tooltips_hide_tip (widget); |
|
1359 |
+ break; |
|
1360 |
+ default: |
|
1361 |
+ break; |
|
1362 |
+ } |
|
1363 |
+ } |
|
1364 |
+ else |
|
1365 |
+ { |
|
1366 |
+ if (event->type != GDK_KEY_PRESS && event->type != GDK_KEY_RELEASE) |
|
1367 |
+ { |
|
1368 |
+ event_widget = gtk_get_event_widget (event); |
|
1369 |
+ if (event_widget != widget) |
|
1370 |
+ return; |
|
1371 |
+ } |
|
1372 |
+ |
|
1373 |
+ if (tooltips->pager != NULL) /* handler pager tooltips special case */ |
|
1374 |
+ { |
|
1375 |
+ static WnckWorkspace *current = NULL; |
|
1376 |
+ if (event->type == GDK_MOTION_NOTIFY || event->type == GDK_ENTER_NOTIFY) |
|
1377 |
+ { |
|
1378 |
+ WnckWorkspace *tip_ws = g_object_get_data (G_OBJECT (tooltips->pager), |
|
1379 |
+ "tip_ws"); |
|
1380 |
+ |
|
1381 |
+ if (current != tip_ws) |
|
1382 |
+ { |
|
1383 |
+ /* do something only if the workspace changed */ |
|
1384 |
+ current = tip_ws; |
|
1385 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1386 |
+ trusted_tooltips_start_delay (tooltips, widget); |
|
1387 |
+ } |
|
1388 |
+ } |
|
1389 |
+ if (event->type == GDK_LEAVE_NOTIFY) |
|
1390 |
+ { |
|
1391 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1392 |
+ current = NULL; |
|
1393 |
+ } |
|
1394 |
+ } |
|
1395 |
+ else |
|
1396 |
+ { |
|
1397 |
+ switch (event->type) |
|
1398 |
+ { |
|
1399 |
+ case GDK_EXPOSE: |
|
1400 |
+ /* do nothing */ |
|
1401 |
+ break; |
|
1402 |
+ case GDK_ENTER_NOTIFY: |
|
1403 |
+ if (!(GTK_IS_MENU_ITEM (widget) && GTK_MENU_ITEM (widget)->submenu)) |
|
1404 |
+ trusted_tooltips_start_delay (tooltips, widget); |
|
1405 |
+ break; |
|
1406 |
+ |
|
1407 |
+ case GDK_LEAVE_NOTIFY: |
|
1408 |
+ { |
|
1409 |
+ gboolean use_sticky_delay; |
|
1410 |
+ |
|
1411 |
+ use_sticky_delay = tooltips->tip_window && |
|
1412 |
+ GTK_WIDGET_VISIBLE (tooltips->tip_window); |
|
1413 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1414 |
+ tooltips->use_sticky_delay = use_sticky_delay; |
|
1415 |
+ } |
|
1416 |
+ break; |
|
1417 |
+ |
|
1418 |
+ case GDK_MOTION_NOTIFY: |
|
1419 |
+ /* Handle menu items specially ... pend popup for each motion |
|
1420 |
+ * on other widgets, we ignore motion. |
|
1421 |
+ */ |
|
1422 |
+ if (GTK_IS_MENU_ITEM (widget) && !GTK_MENU_ITEM (widget)->submenu) |
|
1423 |
+ { |
|
1424 |
+ /* Completely evil hack to make sure we get the LEAVE_NOTIFY |
|
1425 |
+ */ |
|
1426 |
+ /* GTK_PRIVATE_SET_FLAG (widget, GTK_LEAVE_PENDING); */ |
|
1427 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1428 |
+ trusted_tooltips_start_delay (tooltips, widget); |
|
1429 |
+ break; |
|
1430 |
+ } |
|
1431 |
+ break; /* ignore */ |
|
1432 |
+ case GDK_BUTTON_PRESS: |
|
1433 |
+ case GDK_BUTTON_RELEASE: |
|
1434 |
+ case GDK_KEY_PRESS: |
|
1435 |
+ case GDK_KEY_RELEASE: |
|
1436 |
+ case GDK_PROXIMITY_IN: |
|
1437 |
+ case GDK_SCROLL: |
|
1438 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1439 |
+ break; |
|
1440 |
+ default: |
|
1441 |
+ break; |
|
1442 |
+ } |
|
1443 |
+ } |
|
1444 |
+ } |
|
1445 |
+} |
|
1446 |
+ |
|
1447 |
+static void |
|
1448 |
+trusted_tooltips_widget_unmap (GtkWidget *widget, |
|
1449 |
+ gpointer data) |
|
1450 |
+{ |
|
1451 |
+ TrustedTooltipsData *tooltipsdata = (TrustedTooltipsData *)data; |
|
1452 |
+ TrustedTooltips *tooltips = tooltipsdata->tooltips; |
|
1453 |
+ |
|
1454 |
+ if (tooltips->active_tips_data && |
|
1455 |
+ (tooltips->active_tips_data->widget == widget)) |
|
1456 |
+ trusted_tooltips_set_active_widget (tooltips, NULL); |
|
1457 |
+} |
|
1458 |
+ |
|
1459 |
+static void |
|
1460 |
+trusted_tooltips_widget_remove (GtkWidget *widget, |
|
1461 |
+ gpointer data) |
|
1462 |
+{ |
|
1463 |
+ TrustedTooltipsData *tooltipsdata = (TrustedTooltipsData*) data; |
|
1464 |
+ TrustedTooltips *tooltips = tooltipsdata->tooltips; |
|
1465 |
+ |
|
1466 |
+ trusted_tooltips_widget_unmap (widget, data); |
|
1467 |
+ tooltips->tips_data_list = g_list_remove (tooltips->tips_data_list, |
|
1468 |
+ tooltipsdata); |
|
1469 |
+ trusted_tooltips_destroy_data (tooltipsdata); |
|
1470 |
+} |
|
1471 |
+ |
|
1472 |
+void |
|
1473 |
+_trusted_tooltips_toggle_keyboard_mode (GtkWidget *widget) |
|
1474 |
+{ |
|
1475 |
+ if (get_keyboard_mode (widget)) |
|
1476 |
+ stop_keyboard_mode (widget); |
|
1477 |
+ else |
|
1478 |
+ start_keyboard_mode (widget); |
|
1479 |
+} |
|
1480 |
+ |
|
1481 |
+/** |
|
1482 |
+ * trusted_tooltips_get_info_from_tip_window: |
|
1483 |
+ * @tip_window: a #GtkWindow |
|
1484 |
+ * @tooltips: the return location for the tooltips which are displayed |
|
1485 |
+ * in @tip_window, or %NULL |
|
1486 |
+ * @current_widget: the return location for the widget whose tooltips |
|
1487 |
+ * are displayed, or %NULL |
|
1488 |
+ * |
|
1489 |
+ * Determines the tooltips and the widget they belong to from the window in |
|
1490 |
+ * which they are displayed. |
|
1491 |
+ * |
|
1492 |
+ * This function is mostly intended for use by accessibility technologies; |
|
1493 |
+ * applications should have little use for it. |
|
1494 |
+ * |
|
1495 |
+ * Return value: %TRUE if @tip_window is displaying tooltips, otherwise %FALSE. |
|
1496 |
+ * |
|
1497 |
+ * Since: 2.4 |
|
1498 |
+ **/ |
|
1499 |
+gboolean |
|
1500 |
+trusted_tooltips_get_info_from_tip_window (GtkWindow *tip_window, |
|
1501 |
+ TrustedTooltips **tooltips, |
|
1502 |
+ GtkWidget **current_widget) |
|
1503 |
+{ |
|
1504 |
+ TrustedTooltips *current_tooltips; |
|
1505 |
+ gboolean has_tips; |
|
1506 |
+ |
|
1507 |
+ g_return_val_if_fail (GTK_IS_WINDOW (tip_window), FALSE); |
|
1508 |
+ |
|
1509 |
+ current_tooltips = g_object_get_data (G_OBJECT (tip_window), tooltips_info_key); |
|
1510 |
+ |
|
1511 |
+ has_tips = current_tooltips != NULL; |
|
1512 |
+ |
|
1513 |
+ if (tooltips) |
|
1514 |
+ *tooltips = current_tooltips; |
|
1515 |
+ if (current_widget) |
|
1516 |
+ *current_widget = has_tips ? current_tooltips->active_tips_data->widget : NULL; |
|
1517 |
+ |
|
1518 |
+ return has_tips; |
|
1519 |
+} |
|
1520 |
+void |
|
1521 |
+trusted_tooltips_set_pager (TrustedTooltips *tooltips, |
|
1522 |
+ WnckPager *pager) |
|
1523 |
+{ |
|
1524 |
+ tooltips->pager = pager; |
|
1525 |
+} |
|
1526 |
+#endif /* HAVE_XTSOL */ |
|
1527 |
+#define __TRUSTED_TOOLTIPS_C__ |
|
13074 | 1528 |
diff -urN libwnck.orig/libwnck/trusted-tooltips.h libwnck.new/libwnck/trusted-tooltips.h |
1529 |
--- libwnck.orig/libwnck/trusted-tooltips.h 1970-01-01 01:00:00.000000000 +0100 |
|
1530 |
+++ libwnck.new/libwnck/trusted-tooltips.h 2008-08-06 23:43:40.108722000 +0100 |
|
7480 | 1531 |
@@ -0,0 +1,120 @@ |
1532 |
+/* GTK - The GIMP Toolkit |
|
1533 |
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
|
1534 |
+ * |
|
1535 |
+ * This library is free software; you can redistribute it and/or |
|
1536 |
+ * modify it under the terms of the GNU Lesser General Public |
|
1537 |
+ * License as published by the Free Software Foundation; either |
|
1538 |
+ * version 2 of the License, or (at your option) any later version. |
|
1539 |
+ * |
|
1540 |
+ * This library is distributed in the hope that it will be useful, |
|
1541 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1542 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
1543 |
+ * Lesser General Public License for more details. |
|
1544 |
+ * |
|
1545 |
+ * You should have received a copy of the GNU Lesser General Public |
|
1546 |
+ * License along with this library; if not, write to the |
|
1547 |
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
1548 |
+ * Boston, MA 02111-1307, USA. |
|
1549 |
+ */ |
|
1550 |
+ |
|
1551 |
+/* |
|
1552 |
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
|
1553 |
+ * file for a list of people on the GTK+ Team. See the ChangeLog |
|
1554 |
+ * files for a list of changes. These files are distributed with |
|
1555 |
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
|
1556 |
+ */ |
|
1557 |
+ |
|
1558 |
+#ifndef __TRUSTED_TOOLTIPS_H__ |
|
1559 |
+#define __TRUSTED_TOOLTIPS_H__ |
|
1560 |
+ |
|
1561 |
+#include <gtk/gtkwidget.h> |
|
1562 |
+#include <gtk/gtkwindow.h> |
|
1563 |
+#include "pager.h" |
|
1564 |
+ |
|
1565 |
+G_BEGIN_DECLS |
|
1566 |
+ |
|
1567 |
+#define TRUSTED_TOOLTIPS_TYPE (trusted_tooltips_get_type ()) |
|
1568 |
+#define TRUSTED_TOOLTIPS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRUSTED_TOOLTIPS_TYPE, TrustedTooltips)) |
|
1569 |
+#define TRUSTED_TOOLTIPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRUSTED_TOOLTIPS_TYPE, TrustedTooltipsClass)) |
|
1570 |
+#define IS_TRUSTED_TOOLTIPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRUSTED_TOOLTIPS_TYPE)) |
|
1571 |
+#define IS_TRUSTED_TOOLTIPS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRUSTED_TOOLTIPS_TYPE)) |
|
1572 |
+#define TRUSTED_TOOLTIPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRUSTED_TOOLTIPS_TYPE, TrustedTooltipsClass)) |
|
1573 |
+ |
|
1574 |
+ |
|
1575 |
+typedef struct _TrustedTooltips TrustedTooltips; |
|
1576 |
+typedef struct _TrustedTooltipsClass TrustedTooltipsClass; |
|
1577 |
+typedef struct _TrustedTooltipsData TrustedTooltipsData; |
|
1578 |
+ |
|
1579 |
+struct _TrustedTooltipsData |
|
1580 |
+{ |
|
1581 |
+ TrustedTooltips *tooltips; |
|
1582 |
+ GtkWidget *widget; |
|
1583 |
+ gchar *tip_text; |
|
1584 |
+ gchar *trusted_label; |
|
1585 |
+ GdkColor *trusted_color; |
|
1586 |
+ gchar *tip_private; |
|
1587 |
+}; |
|
1588 |
+ |
|
1589 |
+struct _TrustedTooltips |
|
1590 |
+{ |
|
1591 |
+ GtkObject parent_instance; |
|
1592 |
+ |
|
1593 |
+ GtkWidget *tip_window; |
|
1594 |
+ GtkWidget *tip_label; |
|
1595 |
+ GtkWidget *tip_trusted_label; |
|
1596 |
+ GtkWidget *event; |
|
1597 |
+ TrustedTooltipsData *active_tips_data; |
|
1598 |
+ GList *tips_data_list; |
|
1599 |
+ |
|
1600 |
+ guint delay : 30; |
|
1601 |
+ guint enabled : 1; |
|
1602 |
+ guint have_grab : 1; |
|
1603 |
+ guint use_sticky_delay : 1; |
|
1604 |
+ gint timer_tag; |
|
1605 |
+ GTimeVal last_popdown; |
|
1606 |
+ WnckPager *pager; |
|
1607 |
+}; |
|
1608 |
+ |
|
1609 |
+struct _TrustedTooltipsClass |
|
1610 |
+{ |
|
1611 |
+ GtkObjectClass parent_class; |
|
1612 |
+ |
|
1613 |
+ /* Padding for future expansion */ |
|
1614 |
+ void (*_gtk_reserved1) (void); |
|
1615 |
+ void (*_gtk_reserved2) (void); |
|
1616 |
+ void (*_gtk_reserved3) (void); |
|
1617 |
+ void (*_gtk_reserved4) (void); |
|
1618 |
+}; |
|
1619 |
+ |
|
1620 |
+GType trusted_tooltips_get_type (void) G_GNUC_CONST; |
|
1621 |
+TrustedTooltips* trusted_tooltips_new (void); |
|
1622 |
+ |
|
1623 |
+void trusted_tooltips_enable (TrustedTooltips *tooltips); |
|
1624 |
+void trusted_tooltips_disable (TrustedTooltips *tooltips); |
|
1625 |
+#ifndef GTK_DISABLE_DEPRECATED |
|
1626 |
+void trusted_tooltips_set_delay (TrustedTooltips *tooltips, |
|
1627 |
+ guint delay); |
|
1628 |
+#endif /* GTK_DISABLE_DEPRECATED */ |
|
1629 |
+void trusted_tooltips_set_tip (TrustedTooltips *tooltips, |
|
1630 |
+ GtkWidget *widget, |
|
1631 |
+ const gchar *tip_text, |
|
1632 |
+ const gchar *trusted_label, |
|
1633 |
+ GdkColor *trusted_color, |
|
1634 |
+ const gchar *tip_private); |
|
1635 |
+TrustedTooltipsData* trusted_tooltips_data_get (GtkWidget *widget); |
|
1636 |
+void trusted_tooltips_force_window (TrustedTooltips *tooltips); |
|
1637 |
+ |
|
1638 |
+ |
|
1639 |
+void _trusted_tooltips_toggle_keyboard_mode (GtkWidget *widget); |
|
1640 |
+ |
|
1641 |
+gboolean trusted_tooltips_get_info_from_tip_window (GtkWindow *tip_window, |
|
1642 |
+ TrustedTooltips **tooltips, |
|
1643 |
+ GtkWidget **current_widget); |
|
1644 |
+ |
|
1645 |
+void trusted_tooltips_set_pager (TrustedTooltips *tooltips, |
|
1646 |
+ WnckPager *pager); |
|
1647 |
+ |
|
1648 |
+ |
|
1649 |
+G_END_DECLS |
|
1650 |
+ |
|
1651 |
+#endif /* __TRUSTED_TOOLTIPS_H__ */ |
|
13074 | 1652 |
diff -urN libwnck.orig/libwnck/tsol-pics.h libwnck.new/libwnck/tsol-pics.h |
1653 |
--- libwnck.orig/libwnck/tsol-pics.h 1970-01-01 01:00:00.000000000 +0100 |
|
1654 |
+++ libwnck.new/libwnck/tsol-pics.h 2008-08-06 23:43:40.110678000 +0100 |
|
7480 | 1655 |
@@ -0,0 +1,43 @@ |
1656 |
+/* GdkPixbuf RGBA C-Source image dump */ |
|
1657 |
+ |
|
1658 |
+#ifdef __SUNPRO_C |
|
1659 |
+#pragma align 4 (highlight_stripe_pb) |
|
1660 |
+#endif |
|
1661 |
+#ifdef __GNUC__ |
|
1662 |
+static const guint8 highlight_stripe_pb[] __attribute__ ((__aligned__ (4))) = |
|
1663 |
+#else |
|
1664 |
+static const guint8 highlight_stripe_pb[] = |
|
1665 |
+#endif |
|
1666 |
+{ "" |
|
1667 |
+ /* Pixbuf magic (0x47646b50) */ |
|
1668 |
+ "GdkP" |
|
1669 |
+ /* length: header (24) + pixel_data (704) */ |
|
1670 |
+ "\0\0\2\330" |
|
1671 |
+ /* pixdata_type (0x1010002) */ |
|
1672 |
+ "\1\1\0\2" |
|
1673 |
+ /* rowstride (176) */ |
|
1674 |
+ "\0\0\0\260" |
|
1675 |
+ /* width (44) */ |
|
1676 |
+ "\0\0\0," |
|
1677 |
+ /* height (4) */ |
|
1678 |
+ "\0\0\0\4" |
|
1679 |
+ /* pixel_data: */ |
|
1680 |
+ "\0\0\0\0^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1681 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1682 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1683 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\365^^^\336^^^\303^^^\246^^^\207^^^[^" |
|
1684 |
+ "^^3^^^\26^^^\5^^^\2^^^\360^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1685 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1686 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1687 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\365^^^\336^^^\303" |
|
1688 |
+ "^^^\246^^^\207^^^[^^^3^^^\26^^^\5^^^\2^^^\360^^^\377^^^\377^^^\377^^" |
|
1689 |
+ "^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1690 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1691 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1692 |
+ "^^^\365^^^\336^^^\303^^^\246^^^\207^^^[^^^3^^^\26^^^\5^^^\2\0\0\0\0^" |
|
1693 |
+ "^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1694 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1695 |
+ "^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377^^^\377" |
|
1696 |
+ "^^^\377^^^\377^^^\377^^^\365^^^\336^^^\303^^^\246^^^\207^^^[^^^3^^^\26" |
|
1697 |
+ "^^^\5^^^\2"}; |
|
1698 |
+ |
|
13074 | 1699 |
diff -urN libwnck.orig/libwnck/window.c libwnck.new/libwnck/window.c |
1700 |
--- libwnck.orig/libwnck/window.c 2008-08-06 23:43:13.689319000 +0100 |
|
1701 |
+++ libwnck.new/libwnck/window.c 2008-08-06 23:43:40.130350000 +0100 |
|
11201 | 1702 |
@@ -47,6 +47,13 @@ |
10129 | 1703 |
* referenced or unreferenced. |
1704 |
*/ |
|
7480 | 1705 |
|
1706 |
+#ifdef HAVE_XTSOL |
|
1707 |
+#include <strings.h> |
|
1708 |
+#include <sys/types.h> |
|
1709 |
+#include <unistd.h> |
|
1710 |
+#include <wnck-tsol.h> |
|
1711 |
+#endif |
|
1712 |
+ |
|
9988 | 1713 |
#define FALLBACK_NAME _("Untitled window") |
7480 | 1714 |
#define ALL_WORKSPACES (0xFFFFFFFF) |
1715 |
||
13074 | 1716 |
@@ -83,6 +90,12 @@ |
7480 | 1717 |
char *icon_name; |
1718 |
char *session_id; |
|
1719 |
char *session_id_utf8; |
|
1720 |
+#ifdef HAVE_XTSOL |
|
1721 |
+ char *label; |
|
1722 |
+ GdkColor *label_color; |
|
1723 |
+ char *label_color_str; |
|
1724 |
+ char *role; |
|
1725 |
+#endif |
|
1726 |
int pid; |
|
1727 |
int workspace; |
|
1728 |
gint sort_order; |
|
13074 | 1729 |
@@ -100,6 +113,9 @@ |
7480 | 1730 |
int y; |
1731 |
int width; |
|
1732 |
int height; |
|
1733 |
+#ifdef HAVE_XTSOL |
|
1734 |
+ int is_trusted; |
|
1735 |
+#endif |
|
1736 |
||
10129 | 1737 |
int left_frame; |
1738 |
int right_frame; |
|
13074 | 1739 |
@@ -161,6 +177,9 @@ |
8535 | 1740 |
|
1741 |
guint need_emit_name_changed : 1; |
|
1742 |
guint need_emit_icon_changed : 1; |
|
7480 | 1743 |
+#ifdef HAVE_XTSOL |
1744 |
+ guint need_update_label : 1; |
|
1745 |
+#endif |
|
1746 |
}; |
|
1747 |
||
10129 | 1748 |
G_DEFINE_TYPE (WnckWindow, wnck_window, G_TYPE_OBJECT); |
13074 | 1749 |
@@ -223,6 +242,9 @@ |
10174 | 1750 |
window->priv->group_leader = None; |
1751 |
window->priv->transient_for = None; |
|
8535 | 1752 |
window->priv->icon_geometry.width = -1; /* invalid cached value */ |
8584 | 1753 |
+#ifdef HAVE_XTSOL |
7480 | 1754 |
+ window->priv->is_trusted = -1; |
8584 | 1755 |
+#endif |
10174 | 1756 |
window->priv->name = NULL; |
1757 |
window->priv->icon_name = NULL; |
|
1758 |
window->priv->session_id = NULL; |
|
13074 | 1759 |
@@ -446,6 +468,12 @@ |
7480 | 1760 |
_wnck_icon_cache_free (window->priv->icon_cache); |
10174 | 1761 |
window->priv->icon_cache = NULL; |
7480 | 1762 |
|
1763 |
+#ifdef HAVE_XTSOL |
|
1764 |
+ g_free (window->priv->label); |
|
1765 |
+ g_free (window->priv->label_color); |
|
1766 |
+ g_free (window->priv->role); |
|
1767 |
+#endif |
|
10174 | 1768 |
+ |
1769 |
g_free (window->priv->startup_id); |
|
1770 |
window->priv->startup_id = NULL; |
|
1771 |
g_free (window->priv->res_class); |
|
13074 | 1772 |
@@ -559,11 +587,40 @@ |
10129 | 1773 |
window->priv->need_update_frame_extents = TRUE; |
8535 | 1774 |
window->priv->need_emit_name_changed = FALSE; |
1775 |
window->priv->need_emit_icon_changed = FALSE; |
|
7480 | 1776 |
+#ifdef HAVE_XTSOL |
1777 |
+ window->priv->need_update_label = TRUE; |
|
1778 |
+#endif |
|
1779 |
force_update_now (window); |
|
1780 |
||
1781 |
return window; |
|
10129 | 1782 |
} |
1783 |
||
1784 |
+#ifdef HAVE_XTSOL |
|
1785 |
+/** |
|
1786 |
+ * wnck_window_is_trusted: |
|
1787 |
+ * @window: a #WnckWindow |
|
1788 |
+ * |
|
1789 |
+ * Trusted here means that the application running in the window is |
|
1790 |
+ * in the trusted path. |
|
1791 |
+ * |
|
1792 |
+ * Return value: %TRUE if the window is trusted. |
|
1793 |
+ **/ |
|
1794 |
+gboolean |
|
1795 |
+wnck_window_is_trusted (WnckWindow *window) |
|
1796 |
+{ |
|
1797 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); |
|
1798 |
+ if (!_wnck_check_xtsol_extension()) { |
|
1799 |
+ g_warning ("wnck_window_is_trusted() was called but the X server does not support the SUN_TSOL extension"); |
|
1800 |
+ return 0; |
|
1801 |
+ } |
|
1802 |
+ if (!_wnck_use_trusted_extensions()) { |
|
1803 |
+ g_warning ("wnck_window_is_trusted(): Can not initialise the trusted extensions libraries. Check your installation"); |
|
1804 |
+ return 0; |
|
1805 |
+ } |
|
1806 |
+ return window->priv->is_trusted; |
|
1807 |
+} |
|
1808 |
+#endif |
|
1809 |
+ |
|
1810 |
void |
|
1811 |
_wnck_window_destroy (WnckWindow *window) |
|
1812 |
{ |
|
13074 | 1813 |
@@ -711,6 +768,92 @@ |
10174 | 1814 |
return g_strdup (name); |
7480 | 1815 |
} |
10174 | 1816 |
|
7480 | 1817 |
+#ifdef HAVE_XTSOL |
1818 |
+/** |
|
1819 |
+ * wnck_window_get_label: |
|
1820 |
+ * @window: a #WnckWindow |
|
1821 |
+ * |
|
1822 |
+ * Gets the sensitivity label of the window in it's long string |
|
10174 | 1823 |
+ * representation. |
7480 | 1824 |
+ * |
1825 |
+ * Return value: sensitivity label of the window. |
|
1826 |
+ * If the window has no sensitivity label set, %NULL is returned. |
|
1827 |
+ **/ |
|
1828 |
+const char* |
|
1829 |
+wnck_window_get_label (WnckWindow *window) |
|
1830 |
+{ |
|
1831 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); |
|
1832 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
1833 |
+ return window->priv->label; |
|
1834 |
+ return NULL; |
|
1835 |
+} |
|
1836 |
+/** |
|
1837 |
+ * wnck_window_get_label_human_readable: |
|
1838 |
+ * @window: a #WnckWindow |
|
1839 |
+ * |
|
1840 |
+ * Gets the sensitivity label of the window and returns it in a |
|
1841 |
+ * form suitable for presentation in a user visible interface. |
|
1842 |
+ * |
|
1843 |
+ * Return value: sensitivity label of the window appropriate for |
|
1844 |
+ * human presentation. |
|
1845 |
+ * If the window has no sensitivity label set, %NULL is returned. |
|
1846 |
+ **/ |
|
1847 |
+char* |
|
1848 |
+wnck_window_get_label_human_readable (WnckWindow *window) |
|
1849 |
+{ |
|
1850 |
+ char *human_readable_label; |
|
1851 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); |
|
1852 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
1853 |
+ { |
|
1854 |
+ int error; |
|
1855 |
+ m_label_t *mlabel = NULL; |
|
1856 |
+ |
|
1857 |
+ if (wnck_window_is_trusted (window)) |
|
10174 | 1858 |
+ /* SUN_BRANDING TJDS */ |
1859 |
+ return g_strdup (_("Trusted Path")); |
|
1860 |
+ |
|
1861 |
+ if (window->priv->label != NULL && |
|
1862 |
+ (error = libtsol_str_to_label (window->priv->label, |
|
1863 |
+ &mlabel, MAC_LABEL, |
|
1864 |
+ L_NO_CORRECTION, &error)) == 0) |
|
1865 |
+ { |
|
1866 |
+ error = libtsol_label_to_str (mlabel, |
|
1867 |
+ &human_readable_label, |
|
1868 |
+ M_LABEL, DEF_NAMES); |
|
1869 |
+ return human_readable_label; |
|
1870 |
+ } |
|
7480 | 1871 |
+ } |
1872 |
+ return NULL; |
|
1873 |
+} |
|
1874 |
+ |
|
1875 |
+GdkColor * |
|
1876 |
+wnck_window_get_label_color (WnckWindow *window) |
|
1877 |
+{ |
|
1878 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); |
|
1879 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
1880 |
+ return window->priv->label_color; |
|
1881 |
+ else |
|
1882 |
+ return NULL; |
|
1883 |
+} |
|
1884 |
+ |
|
8535 | 1885 |
+const char * |
7480 | 1886 |
+wnck_window_get_label_color_str (WnckWindow *window) |
1887 |
+{ |
|
1888 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); |
|
1889 |
+ if (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) |
|
1890 |
+ return window->priv->label_color_str; |
|
1891 |
+ else |
|
1892 |
+ return NULL; |
|
1893 |
+} |
|
1894 |
+ |
|
1895 |
+const char * |
|
1896 |
+wnck_window_get_role (WnckWindow *window) |
|
1897 |
+{ |
|
1898 |
+ g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL); |
|
1899 |
+ |
|
1900 |
+ return window->priv->role; |
|
1901 |
+} |
|
1902 |
+#endif |
|
1903 |
||
10129 | 1904 |
/** |
1905 |
* wnck_window_get_application: |
|
13074 | 1906 |
@@ -1777,9 +1920,44 @@ |
7480 | 1907 |
wnck_window_move_to_workspace (WnckWindow *window, |
1908 |
WnckWorkspace *space) |
|
1909 |
{ |
|
1910 |
+#ifdef HAVE_XTSOL |
|
1911 |
+ static char *workstationowner = NULL; |
|
1912 |
+#endif |
|
1913 |
+ |
|
1914 |
g_return_if_fail (WNCK_IS_WINDOW (window)); |
|
1915 |
g_return_if_fail (WNCK_IS_WORKSPACE (space)); |
|
1916 |
||
1917 |
+#ifdef HAVE_XTSOL |
|
1918 |
+ if ((_wnck_check_xtsol_extension) && (_wnck_use_trusted_extensions ())) { |
|
1919 |
+ char *windowrole = NULL; |
|
1920 |
+ char *workspacerole = wnck_workspace_get_role (space); |
|
1921 |
+ windowrole = wnck_window_get_role (window); |
|
1922 |
+ /* |
|
1923 |
+ * Only windows that are in the Trusted Path |
|
1924 |
+ * are allowed to be move onto a role workspace |
|
1925 |
+ * This could be implemented in _wnck_window_change_workspace() but |
|
1926 |
+ * it's less complicated to do so here. |
|
1927 |
+ */ |
|
1928 |
+ if (workstationowner == NULL) { |
|
1929 |
+ uid_t wsuid; |
|
1930 |
+ struct passwd *pwd; |
|
1931 |
+ if ((libxtsol_XTSOLgetWorkstationOwner (gdk_x11_get_default_xdisplay (), &wsuid)) < 0) { |
|
1932 |
+ g_warning ("XTSOLgetWorkstationOwner() failed. Using getuid() instead"); |
|
1933 |
+ pwd = getpwuid (getuid ()); |
|
1934 |
+ } else |
|
1935 |
+ pwd = getpwuid (wsuid); |
|
1936 |
+ workstationowner = g_strdup (pwd->pw_name); |
|
1937 |
+ } |
|
1938 |
+ |
|
1939 |
+ /* Don't allow non-trusted path windows into role workspaces unless the window role |
|
1940 |
+ * matches the workspace role |
|
1941 |
+ */ |
|
1942 |
+ if ((workspacerole != NULL) && (strcmp (workstationowner, workspacerole)) && |
|
1943 |
+ (!wnck_window_is_trusted (window)) && (strcmp (workspacerole, windowrole))) |
|
1944 |
+ return; |
|
1945 |
+ } |
|
1946 |
+#endif |
|
1947 |
+ |
|
1948 |
_wnck_change_workspace (WNCK_SCREEN_XSCREEN (window->priv->screen), |
|
1949 |
window->priv->xwindow, |
|
1950 |
wnck_workspace_get_number (space)); |
|
13074 | 1951 |
@@ -2387,9 +2565,38 @@ |
7480 | 1952 |
wnck_window_is_on_workspace (WnckWindow *window, |
1953 |
WnckWorkspace *workspace) |
|
1954 |
{ |
|
1955 |
+#ifdef HAVE_XTSOL |
|
1956 |
+ static char *workstationowner = NULL; |
|
1957 |
+#endif |
|
1958 |
+ |
|
1959 |
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); |
|
1960 |
g_return_val_if_fail (WNCK_IS_WORKSPACE (workspace), FALSE); |
|
1961 |
||
1962 |
+#ifdef HAVE_XTSOL |
|
1963 |
+ /* |
|
1964 |
+ * Non trusted path windows will not be visible on role workspaces |
|
1965 |
+ * unless the window role matches the workspace role. |
|
1966 |
+ */ |
|
1967 |
+ if (_wnck_use_trusted_extensions () && _wnck_check_xtsol_extension ()) { |
|
1968 |
+ char *windowrole = g_strdup (wnck_window_get_role (window)); |
|
1969 |
+ char *workspacerole = wnck_workspace_get_role (workspace); |
|
1970 |
+ |
|
1971 |
+ if (workstationowner == NULL) { |
|
1972 |
+ uid_t wsuid; |
|
1973 |
+ struct passwd *pwd; |
|
1974 |
+ if ((libxtsol_XTSOLgetWorkstationOwner (gdk_x11_get_default_xdisplay (), &wsuid)) < 0) { |
|
1975 |
+ g_warning ("XTSOLgetWorkstationOwner() failed. Using getuid() instead"); |
|
1976 |
+ pwd = getpwuid (getuid ()); |
|
1977 |
+ } else |
|
1978 |
+ pwd = getpwuid (wsuid); |
|
1979 |
+ workstationowner = g_strdup (pwd->pw_name); |
|
1980 |
+ } |
|
1981 |
+ if ((workspacerole != NULL) && (strcmp (workstationowner, workspacerole)) && |
|
1982 |
+ (!wnck_window_is_trusted (window)) && (strcmp (workspacerole, windowrole))) { |
|
1983 |
+ return FALSE; |
|
1984 |
+ } |
|
1985 |
+ } |
|
1986 |
+#endif |
|
1987 |
return wnck_window_is_pinned (window) || |
|
1988 |
wnck_window_get_workspace (window) == workspace; |
|
1989 |
} |
|
13074 | 1990 |
@@ -2416,8 +2623,12 @@ |
7480 | 1991 |
g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE); |
1992 |
g_return_val_if_fail (WNCK_IS_WORKSPACE (workspace), FALSE); |
|
1993 |
||
1994 |
+ /* Being pinned is no guarantee in a trusted desktop */ |
|
1995 |
+ /* TESTME */ |
|
1996 |
+#ifndef HAVE_XTSOL |
|
1997 |
if (wnck_window_is_pinned (window) ) |
|
1998 |
return TRUE; |
|
1999 |
+#endif |
|
2000 |
||
2001 |
if (wnck_window_get_workspace (window) != workspace) |
|
2002 |
return FALSE; |
|
13074 | 2003 |
@@ -2792,6 +3003,91 @@ |
8535 | 2004 |
window->priv->icon_name = new_name; |
7480 | 2005 |
} |
2006 |
||
2007 |
+#ifdef HAVE_XTSOL |
|
2008 |
+ |
|
2009 |
+static void |
|
2010 |
+update_label_color (WnckWindow *window, m_label_t* label) |
|
2011 |
+{ |
|
2012 |
+ #define DEFAULT_COLOR "white" |
|
2013 |
+ int error; |
|
2014 |
+ |
|
2015 |
+ if (window->priv->label_color) |
|
2016 |
+ g_free (window->priv->label_color); |
|
2017 |
+ |
|
2018 |
+ if (window->priv->label_color_str) |
|
2019 |
+ g_free (window->priv->label_color_str); |
|
2020 |
+ |
|
2021 |
+ window->priv->label_color = g_new0 (GdkColor, 1); |
|
2022 |
+ |
|
2023 |
+ error = libtsol_label_to_str (label, &window->priv->label_color_str, M_COLOR, DEF_NAMES); |
|
2024 |
+ if (window->priv->label_color_str == NULL) |
|
2025 |
+ window->priv->label_color_str = g_strdup(DEFAULT_COLOR); |
|
2026 |
+ |
|
2027 |
+ gdk_color_parse ((const char*)window->priv->label_color_str, window->priv->label_color); |
|
2028 |
+} |
|
2029 |
+ |
|
2030 |
+static void |
|
2031 |
+update_window_role (WnckWindow *window) |
|
2032 |
+{ |
|
2033 |
+ int error; |
|
2034 |
+ gulong xid; |
|
2035 |
+ uid_t uid = -1; |
|
2036 |
+ struct passwd *pwd; |
|
2037 |
+ |
|
2038 |
+ if (window->priv->role) |
|
2039 |
+ g_free (window->priv->role); |
|
2040 |
+ xid = wnck_window_get_xid (window); |
|
2041 |
+ error = libxtsol_XTSOLgetResUID (gdk_x11_get_default_xdisplay (), |
|
2042 |
+ xid, IsWindow, &uid); |
|
2043 |
+ if ((error < 0) || (uid < 0)) { |
|
8535 | 2044 |
+ pwd = getpwuid (getuid); |
7480 | 2045 |
+ g_warning ("XTSOLgetResUID() failed. Assuming window %d belongs to %s\n", xid, pwd->pw_name); |
2046 |
+ } else |
|
2047 |
+ pwd = getpwuid (uid); |
|
2048 |
+ window->priv->role = g_strdup (pwd->pw_name); |
|
2049 |
+} |
|
2050 |
+ |
|
2051 |
+/* |
|
2052 |
+ * Since window sensitivity labels are static, this is a one time |
|
2053 |
+ * only function for each window. |
|
2054 |
+ */ |
|
2055 |
+void |
|
2056 |
+wnck_window_update_label (WnckWindow *window) |
|
2057 |
+{ |
|
2058 |
+ g_return_if_fail (window->priv->label == NULL); |
|
2059 |
+ |
|
2060 |
+ if (!window->priv->need_update_label) |
|
2061 |
+ return; |
|
2062 |
+ window->priv->need_update_label = FALSE; |
|
2063 |
+ |
|
2064 |
+ if (!_wnck_use_trusted_extensions()) |
|
2065 |
+ return; |
|
2066 |
+ |
|
2067 |
+ /* Check for a trusted windowing environment first */ |
|
2068 |
+ if (_wnck_check_xtsol_extension () && _wnck_use_trusted_extensions()) { |
|
2069 |
+ if (window->priv->label == NULL) { |
|
2070 |
+ m_label_t label; |
|
2071 |
+ int error; |
|
15579 | 2072 |
+ if (libxtsol_XTSOLgetResLabel(gdk_display, window->priv->xwindow, |
2073 |
+ IsWindow, &label)) { |
|
7480 | 2074 |
+ error = libtsol_label_to_str (&label, &window->priv->label, M_INTERNAL, |
2075 |
+ LONG_NAMES); |
|
2076 |
+ /* add label color */ |
|
2077 |
+ update_label_color (window, &label); |
|
2078 |
+ update_window_role (window); |
|
2079 |
+ |
|
2080 |
+ } else { |
|
2081 |
+ window->priv->label = NULL; |
|
2082 |
+ } |
|
2083 |
+ } |
|
2084 |
+ } else { |
|
2085 |
+ g_warning("Window labelling needs the SUN_TSOL X server extension"); |
|
2086 |
+ return; |
|
2087 |
+ } |
|
2088 |
+ |
|
2089 |
+} |
|
2090 |
+#endif |
|
2091 |
+ |
|
2092 |
static void |
|
2093 |
update_workspace (WnckWindow *window) |
|
2094 |
{ |
|
13074 | 2095 |
@@ -3149,6 +3445,14 @@ |
8535 | 2096 |
if (window->priv->need_emit_name_changed) |
7480 | 2097 |
emit_name_changed (window); |
2098 |
||
2099 |
+#ifdef HAVE_XTSOL |
|
2100 |
+ if (_wnck_check_xtsol_extension () && _wnck_use_trusted_extensions()) { |
|
2101 |
+ if (window->priv->is_trusted < 0) |
|
2102 |
+ window->priv->is_trusted = libxtsol_XTSOLIsWindowTrusted (gdk_display, window->priv->xwindow); |
|
2103 |
+ if (window->priv->label == NULL) |
|
2104 |
+ wnck_window_update_label (window); |
|
2105 |
+ } |
|
2106 |
+#endif |
|
2107 |
old_state = COMPRESS_STATE (window); |
|
2108 |
old_actions = window->priv->actions; |
|
2109 |
||
13074 | 2110 |
diff -urN libwnck.orig/libwnck/window.h libwnck.new/libwnck/window.h |
2111 |
--- libwnck.orig/libwnck/window.h 2008-08-06 23:43:13.423557000 +0100 |
|
2112 |
+++ libwnck.new/libwnck/window.h 2008-08-06 23:43:40.134710000 +0100 |
|
11201 | 2113 |
@@ -31,6 +31,7 @@ |
7480 | 2114 |
#include <glib-object.h> |
2115 |
#include <libwnck/screen.h> |
|
2116 |
#include <gdk-pixbuf/gdk-pixbuf.h> |
|
2117 |
+#include <gdk/gdkcolor.h> |
|
2118 |
||
2119 |
G_BEGIN_DECLS |
|
2120 |
||
13074 | 2121 |
@@ -289,6 +290,14 @@ |
7480 | 2122 |
const char* wnck_window_get_name (WnckWindow *window); |
8535 | 2123 |
gboolean wnck_window_has_icon_name (WnckWindow *window); |
7480 | 2124 |
const char* wnck_window_get_icon_name (WnckWindow *window); |
2125 |
+#ifdef HAVE_XTSOL |
|
2126 |
+const char* wnck_window_get_label (WnckWindow *window); |
|
2127 |
+char* wnck_window_get_label_human_readable (WnckWindow *window); |
|
2128 |
+GdkColor* wnck_window_get_label_color (WnckWindow *window); |
|
8535 | 2129 |
+const char* wnck_window_get_label_color_str (WnckWindow *window); |
7480 | 2130 |
+void wnck_window_update_label (WnckWindow *window); |
2131 |
+const char* wnck_window_get_role (WnckWindow *window); |
|
2132 |
+#endif |
|
2133 |
||
2134 |
WnckApplication* wnck_window_get_application (WnckWindow *window); |
|
2135 |
WnckWindow* wnck_window_get_transient (WnckWindow *window); |
|
13074 | 2136 |
@@ -321,6 +330,9 @@ |
7480 | 2137 |
gboolean wnck_window_is_sticky (WnckWindow *window); |
2138 |
gboolean wnck_window_needs_attention (WnckWindow *window); |
|
2139 |
gboolean wnck_window_or_transient_needs_attention (WnckWindow *window); |
|
2140 |
+#ifdef HAVE_XTSOL |
|
2141 |
+gboolean wnck_window_is_trusted (WnckWindow *window); |
|
2142 |
+#endif |
|
2143 |
||
2144 |
void wnck_window_set_skip_pager (WnckWindow *window, |
|
2145 |
gboolean skip); |
|
13074 | 2146 |
diff -urN libwnck.orig/libwnck/wnck-tsol.c libwnck.new/libwnck/wnck-tsol.c |
2147 |
--- libwnck.orig/libwnck/wnck-tsol.c 1970-01-01 01:00:00.000000000 +0100 |
|
2148 |
+++ libwnck.new/libwnck/wnck-tsol.c 2008-08-06 23:43:40.140377000 +0100 |
|
10174 | 2149 |
@@ -0,0 +1,289 @@ |
7480 | 2150 |
+#include <config.h> |
2151 |
+#ifdef HAVE_XTSOL |
|
2152 |
+ |
|
2153 |
+#include <stdlib.h> |
|
10174 | 2154 |
+#include <strings.h> |
7480 | 2155 |
+#include <dlfcn.h> |
2156 |
+#include <link.h> |
|
2157 |
+#include <glib.h> |
|
2158 |
+#include "wnck-tsol.h" |
|
2159 |
+#include "tsol-pics.h" |
|
2160 |
+ |
|
2161 |
+static |
|
2162 |
+void * dlopen_bsm (void) |
|
2163 |
+{ |
|
2164 |
+ return dlopen ("/usr/lib/libbsm.so", RTLD_LAZY); |
|
2165 |
+} |
|
2166 |
+ |
|
2167 |
+static |
|
2168 |
+void * dlopen_tsol (void) |
|
2169 |
+{ |
|
2170 |
+ void *handle = NULL; |
|
2171 |
+ |
|
2172 |
+ /* |
|
2173 |
+ * No 64-bit version of libwnck so we can get away with hardcoding |
|
2174 |
+ * to a single path on this occasion |
|
2175 |
+ */ |
|
2176 |
+ if ((handle = dlopen ("/usr/lib/libtsol.so.2", RTLD_LAZY)) != NULL) |
|
2177 |
+ return handle; |
|
2178 |
+ |
|
2179 |
+ return handle; |
|
2180 |
+} |
|
2181 |
+ |
|
2182 |
+static |
|
2183 |
+void * dlopen_gnometsol (void) |
|
2184 |
+{ |
|
2185 |
+ void *handle = NULL; |
|
2186 |
+ |
|
2187 |
+ if ((handle = dlopen ("/usr/lib/libgnometsol.so", RTLD_LAZY)) != NULL) |
|
2188 |
+ return handle; |
|
2189 |
+ |
|
2190 |
+ return handle; |
|
2191 |
+} |
|
2192 |
+ |
|
2193 |
+static |
|
2194 |
+void * dlopen_xtsol (void) |
|
2195 |
+{ |
|
2196 |
+ void *handle = NULL; |
|
2197 |
+ |
|
2198 |
+ if ((handle = dlopen ("/usr/lib/libXtsol.so.1", RTLD_LAZY)) != NULL) |
|
2199 |
+ return handle; |
|
2200 |
+ if ((handle = dlopen ("/usr/openwin/lib/libXtsol.so.1", RTLD_LAZY)) != NULL) |
|
2201 |
+ return handle; |
|
2202 |
+ |
|
2203 |
+ return handle; |
|
2204 |
+} |
|
2205 |
+ |
|
2206 |
+gboolean |
|
2207 |
+_wnck_use_trusted_extensions (void) |
|
2208 |
+{ |
|
2209 |
+ |
|
2210 |
+ static int trusted = -1; |
|
2211 |
+ |
|
2212 |
+ /* |
|
2213 |
+ * Sun Trusted Extensions (tm) for Solaris (tm) support. |
|
2214 |
+ * |
|
2215 |
+ * It is necessary to use dlopen because the label aware extensions to libwnck work |
|
2216 |
+ * only on systems with the trusted extensions installed and with the SUN_TSOL |
|
2217 |
+ * xserver extension present |
|
2218 |
+ */ |
|
2219 |
+ |
|
2220 |
+ if (trusted < 0) { |
|
2221 |
+ static gpointer bsm_handle = NULL; |
|
2222 |
+ static gpointer tsol_handle = NULL; |
|
2223 |
+ static gpointer xtsol_handle = NULL; |
|
2224 |
+ static gpointer gnometsol_handle = NULL; |
|
2225 |
+ |
|
2226 |
+ if (getenv ("TRUSTED_SESSION") == NULL) { |
|
2227 |
+ trusted = 0; |
|
2228 |
+ return 0; |
|
2229 |
+ } |
|
2230 |
+ |
|
2231 |
+ bsm_handle = dlopen_bsm (); |
|
2232 |
+ tsol_handle = dlopen_tsol (); |
|
2233 |
+ xtsol_handle = dlopen_xtsol (); |
|
2234 |
+ |
|
2235 |
+ if (bsm_handle && tsol_handle && xtsol_handle) { |
|
2236 |
+ /* libbsm function (only interested in the one) */ |
|
2237 |
+ libbsm_getdevicerange = (bsm_getdevicerange) dlsym (bsm_handle, "getdevicerange"); |
|
2238 |
+ |
|
2239 |
+ /* libtsol functions */ |
|
2240 |
+ libtsol_label_to_str = (tsol_label_to_str) dlsym (tsol_handle, "label_to_str"); |
|
2241 |
+ libtsol_str_to_label = (tsol_str_to_label) dlsym (tsol_handle, "str_to_label"); |
|
2242 |
+ libtsol_m_label_free = (tsol_m_label_free) dlsym (tsol_handle, "m_label_free"); |
|
2243 |
+ |
|
2244 |
+ /* Other misc. libtsol functions */ |
|
2245 |
+ libtsol_blminimum = (tsol_blminimum) dlsym (tsol_handle, "blminimum"); |
|
2246 |
+ libtsol_blmaximum = (tsol_blmaximum) dlsym (tsol_handle, "blmaximum"); |
|
2247 |
+ libtsol_blinrange = (tsol_blinrange) dlsym (tsol_handle, "blinrange"); |
|
2248 |
+ libtsol_getuserrange = (tsol_getuserrange) dlsym (tsol_handle, "getuserrange"); |
|
2249 |
+ libtsol_blabel_alloc = (tsol_blabel_alloc) dlsym (tsol_handle, "blabel_alloc"); |
|
2250 |
+ libtsol_blabel_free = (tsol_blabel_free) dlsym (tsol_handle, "blabel_free"); |
|
2251 |
+ libtsol_bsllow = (tsol_bsllow) dlsym (tsol_handle, "bsllow"); |
|
2252 |
+ libtsol_bslhigh = (tsol_bslhigh) dlsym (tsol_handle, "bslhigh"); |
|
2253 |
+ |
|
2254 |
+ |
|
2255 |
+ |
|
2256 |
+ /* libXtsol functions */ |
|
15579 | 2257 |
+ libxtsol_XTSOLgetResLabel = (xtsol_XTSOLgetResLabel) dlsym (xtsol_handle, |
2258 |
+ "XTSOLgetResLabel"); |
|
7480 | 2259 |
+ libxtsol_XTSOLgetResUID = (xtsol_XTSOLgetResUID) dlsym (xtsol_handle, |
2260 |
+ "XTSOLgetResUID"); |
|
2261 |
+ libxtsol_XTSOLgetWorkstationOwner = (xtsol_XTSOLgetWorkstationOwner) dlsym (xtsol_handle, |
|
2262 |
+ "XTSOLgetWorkstationOwner"); |
|
2263 |
+ libxtsol_XTSOLIsWindowTrusted = (xtsol_XTSOLIsWindowTrusted) dlsym (xtsol_handle, |
|
2264 |
+ "XTSOLIsWindowTrusted"); |
|
2265 |
+ |
|
2266 |
+ if (libbsm_getdevicerange == NULL || |
|
2267 |
+ libtsol_label_to_str == NULL || |
|
2268 |
+ libtsol_str_to_label == NULL || |
|
2269 |
+ libtsol_m_label_free == NULL || |
|
2270 |
+ libtsol_blminimum == NULL || |
|
2271 |
+ libtsol_blmaximum == NULL || |
|
2272 |
+ libtsol_blinrange == NULL || |
|
2273 |
+ libtsol_getuserrange == NULL || |
|
2274 |
+ libtsol_blabel_alloc == NULL || |
|
2275 |
+ libtsol_blabel_free == NULL || |
|
2276 |
+ libtsol_bsllow == NULL || |
|
2277 |
+ libtsol_bslhigh == NULL || |
|
15579 | 2278 |
+ libxtsol_XTSOLgetResLabel == NULL || |
7480 | 2279 |
+ libxtsol_XTSOLgetResUID == NULL || |
2280 |
+ libxtsol_XTSOLgetWorkstationOwner == NULL || |
|
2281 |
+ libxtsol_XTSOLIsWindowTrusted == NULL) { |
|
2282 |
+ dlclose (bsm_handle); |
|
2283 |
+ dlclose (tsol_handle); |
|
2284 |
+ dlclose (xtsol_handle); |
|
2285 |
+ bsm_handle = NULL; |
|
2286 |
+ tsol_handle = NULL; |
|
2287 |
+ xtsol_handle = NULL; |
|
2288 |
+ } |
|
2289 |
+ } |
|
2290 |
+ gnometsol_handle = dlopen_gnometsol (); |
|
2291 |
+ if (gnometsol_handle != NULL) |
|
2292 |
+ { |
|
2293 |
+ libgnome_tsol_constraint_image_render = (gnome_tsol_constraint_image_render) dlsym (gnometsol_handle, "gnome_tsol_constraint_image_render"); |
|
2294 |
+ libgnome_tsol_constraint_image_set_border = (gnome_tsol_constraint_image_set_border) dlsym (gnometsol_handle, "gnome_tsol_constraint_image_set_border"); |
|
2295 |
+ libgnome_tsol_constraint_image_set_stretch = (gnome_tsol_constraint_image_set_stretch) dlsym (gnometsol_handle, "gnome_tsol_constraint_image_set_stretch"); |
|
2296 |
+ libgnome_tsol_constraint_image_colorize = (gnome_tsol_constraint_image_colorize) dlsym (gnometsol_handle, "gnome_tsol_constraint_image_colorize"); |
|
2297 |
+ |
|
2298 |
+ if (libgnome_tsol_constraint_image_render == NULL || |
|
2299 |
+ libgnome_tsol_constraint_image_set_border == NULL || |
|
2300 |
+ libgnome_tsol_constraint_image_set_stretch == NULL || |
|
2301 |
+ libgnome_tsol_constraint_image_colorize == NULL) |
|
2302 |
+ gnometsol_handle = NULL; |
|
2303 |
+ |
|
2304 |
+ } |
|
2305 |
+ trusted = ((bsm_handle != NULL) && (tsol_handle != NULL) && (xtsol_handle != NULL) && (gnometsol_handle != NULL)) ? 1 : 0; |
|
2306 |
+ } |
|
2307 |
+ return trusted ? TRUE : FALSE; |
|
2308 |
+} |
|
2309 |
+ |
|
2310 |
+const char * |
|
2311 |
+_wnck_get_min_label () |
|
2312 |
+{ |
|
2313 |
+ static char *min_label = NULL; |
|
2314 |
+ |
|
2315 |
+ if (!min_label) { |
|
2316 |
+ min_label = (char *) getenv ("USER_MIN_SL"); |
|
2317 |
+ } |
|
2318 |
+ return min_label; |
|
2319 |
+} |
|
2320 |
+ |
|
2321 |
+const char* |
|
2322 |
+_wnck_get_max_label() |
|
2323 |
+{ |
|
2324 |
+ static char *max_label = NULL; |
|
2325 |
+ |
|
2326 |
+ if (!max_label) { |
|
2327 |
+ max_label = (char *) getenv ("USER_MAX_SL"); |
|
2328 |
+ } |
|
2329 |
+ return max_label; |
|
2330 |
+} |
|
2331 |
+ |
|
2332 |
+ |
|
2333 |
+/* GFX part */ |
|
2334 |
+ |
|
2335 |
+ |
|
2336 |
+typedef struct _HighlightStripe HighlightStripe; |
|
2337 |
+ |
|
2338 |
+struct _HighlightStripe |
|
2339 |
+{ |
|
2340 |
+ ConstraintImage *image; |
|
2341 |
+ char *name; |
|
2342 |
+}; |
|
2343 |
+ |
|
2344 |
+static gint |
|
2345 |
+label_string_compare (HighlightStripe *tmp, char *searched_label) |
|
2346 |
+{ |
|
2347 |
+ return strcmp (searched_label, tmp->name); |
|
2348 |
+} |
|
2349 |
+ |
|
2350 |
+ConstraintImage * |
|
2351 |
+get_highlight_stripe (char *name, |
|
2352 |
+ GdkColor *label_color) |
|
2353 |
+{ |
|
2354 |
+ static GSList *hl_stripe_list = NULL; |
|
2355 |
+ GSList *stored_hl_stripe = NULL; |
|
2356 |
+ HighlightStripe *hl_stripe; |
|
2357 |
+ |
|
2358 |
+ if ((name == NULL) || (label_color == NULL)) |
|
2359 |
+ return NULL; |
|
2360 |
+ |
|
2361 |
+ |
|
2362 |
+ stored_hl_stripe = g_slist_find_custom (hl_stripe_list, |
|
2363 |
+ name, |
|
2364 |
+ (GCompareFunc)label_string_compare); |
|
2365 |
+ if (stored_hl_stripe) |
|
2366 |
+ return ((HighlightStripe* )stored_hl_stripe->data)->image; |
|
2367 |
+ |
|
2368 |
+ hl_stripe = g_new0 (HighlightStripe, 1); |
|
2369 |
+ |
|
2370 |
+ hl_stripe->name = g_strdup (name); |
|
2371 |
+ |
|
2372 |
+ hl_stripe->image = g_new0 (ConstraintImage, 1); |
|
2373 |
+ |
|
2374 |
+ hl_stripe->image->pixbuf = gdk_pixbuf_new_from_inline (-1, |
|
2375 |
+ highlight_stripe_pb, |
|
2376 |
+ TRUE, NULL); |
|
2377 |
+ |
|
2378 |
+ libgnome_tsol_constraint_image_set_border (hl_stripe->image, 3, 0, 1, 1); |
|
2379 |
+ libgnome_tsol_constraint_image_set_stretch (hl_stripe->image, TRUE); |
|
2380 |
+ libgnome_tsol_constraint_image_colorize (hl_stripe->image, label_color, 255, TRUE); |
|
2381 |
+ |
|
2382 |
+ hl_stripe_list = g_slist_append (hl_stripe_list, hl_stripe); |
|
2383 |
+ return hl_stripe->image; |
|
2384 |
+} |
|
2385 |
+ |
|
2386 |
+static gboolean label_expose_event (GtkWidget *widget, |
|
2387 |
+ GdkEventExpose *event, |
|
2388 |
+ gpointer data) |
|
2389 |
+{ |
|
2390 |
+ WnckWindow *window = (WnckWindow *) data; |
|
2391 |
+ |
|
2392 |
+ GdkGC *tmp_gc = gdk_gc_new (widget->window); |
|
2393 |
+ gdk_gc_set_rgb_fg_color (tmp_gc, wnck_window_get_label_color (window)); |
|
2394 |
+ |
|
2395 |
+ gdk_draw_rectangle (widget->window, |
|
2396 |
+ widget->style->black_gc, |
|
2397 |
+ FALSE, |
|
2398 |
+ event->area.x, event->area.y, |
|
2399 |
+ event->area.width - 1, event->area.height - 1); |
|
2400 |
+ |
|
2401 |
+ gdk_draw_rectangle (widget->window, |
|
2402 |
+ tmp_gc, |
|
2403 |
+ TRUE, |
|
2404 |
+ event->area.x + 1, event->area.y + 1, |
|
2405 |
+ event->area.width - 2, event->area.height - 2); |
|
2406 |
+ |
|
2407 |
+ g_object_unref (tmp_gc); |
|
2408 |
+ |
|
2409 |
+ return FALSE; |
|
2410 |
+} |
|
2411 |
+ |
|
2412 |
+GtkWidget * |
|
2413 |
+window_menu_create_label_indicator (WnckWindow *window, |
|
2414 |
+ GtkWidget *image) |
|
2415 |
+{ |
|
2416 |
+ GtkWidget *da, *hbox; |
|
2417 |
+ da = gtk_drawing_area_new (); |
|
2418 |
+ |
|
2419 |
+ g_signal_connect (G_OBJECT (da), "expose_event", |
|
2420 |
+ G_CALLBACK (label_expose_event), |
|
2421 |
+ window); |
|
2422 |
+ |
|
2423 |
+ gtk_widget_set_size_request (da, 5, -1); |
|
2424 |
+ |
|
2425 |
+ hbox = gtk_hbox_new (FALSE, 4); |
|
2426 |
+ |
|
2427 |
+ gtk_container_add (GTK_CONTAINER (hbox), da); |
|
2428 |
+ gtk_container_add (GTK_CONTAINER (hbox), image); |
|
2429 |
+ |
|
2430 |
+ gtk_widget_show (da); |
|
2431 |
+ gtk_widget_show (hbox); |
|
2432 |
+ gtk_widget_show (image); |
|
2433 |
+ |
|
2434 |
+ return hbox; |
|
2435 |
+} |
|
2436 |
+ |
|
2437 |
+ |
|
2438 |
+#endif /* HAVE_XTSOL */ |
|
13074 | 2439 |
diff -urN libwnck.orig/libwnck/wnck-tsol.h libwnck.new/libwnck/wnck-tsol.h |
2440 |
--- libwnck.orig/libwnck/wnck-tsol.h 1970-01-01 01:00:00.000000000 +0100 |
|
2441 |
+++ libwnck.new/libwnck/wnck-tsol.h 2008-08-06 23:43:40.142752000 +0100 |
|
7480 | 2442 |
@@ -0,0 +1,133 @@ |
2443 |
+#ifndef __WNCK_TSOL_H__ |
|
2444 |
+#define __WNCK_TSOL_H__ |
|
2445 |
+ |
|
2446 |
+#include <config.h> |
|
2447 |
+ |
|
2448 |
+#ifdef HAVE_XTSOL |
|
2449 |
+#include <pwd.h> |
|
2450 |
+#include <glib-2.0/glib.h> |
|
2451 |
+#include <tsol/label.h> |
|
2452 |
+#include <sys/tsol/label_macro.h> |
|
2453 |
+#include <X11/Xlib.h> |
|
2454 |
+#include <X11/extensions/Xtsol.h> |
|
2455 |
+#include <gtk/gtk.h> |
|
2456 |
+#include "libwnck.h" |
|
2457 |
+ |
|
2458 |
+typedef struct _ConstraintImage ConstraintImage; |
|
2459 |
+struct _ConstraintImage |
|
2460 |
+{ |
|
2461 |
+ gchar *filename; |
|
2462 |
+ GdkPixbuf *pixbuf; |
|
2463 |
+ GdkPixbuf *scaled; |
|
2464 |
+ gboolean stretch; |
|
2465 |
+ gint border_left; |
|
2466 |
+ gint border_right; |
|
2467 |
+ gint border_bottom; |
|
2468 |
+ gint border_top; |
|
2469 |
+ guint hints[3][3]; |
|
2470 |
+ gboolean recolorable; |
|
2471 |
+ GdkColor colorize_color; |
|
2472 |
+ gboolean use_as_bkg_mask; |
|
2473 |
+}; |
|
2474 |
+ |
|
2475 |
+/* libbsm provides getdevicerange(3TSOL) - don't believe the man page */ |
|
2476 |
+typedef blrange_t* (*bsm_getdevicerange) (const char *device); |
|
2477 |
+ |
|
2478 |
+/* Libtsol functions */ |
|
2479 |
+typedef int (*tsol_label_to_str) (const m_label_t *label, char **string, |
|
2480 |
+ const m_label_str_t conversion_type, |
|
2481 |
+ uint_t flags); |
|
2482 |
+typedef int (*tsol_str_to_label) (const char *string, m_label_t **label, |
|
2483 |
+ const m_label_type_t label_type, |
|
2484 |
+ uint_t flags, |
|
2485 |
+ int *error); |
|
2486 |
+ |
|
2487 |
+typedef void (*tsol_m_label_free) (m_label_t *label); |
|
2488 |
+ |
|
2489 |
+/* Other misc. libtsol functions */ |
|
2490 |
+typedef blrange_t* (*tsol_getuserrange) (const char *username); |
|
2491 |
+typedef int (*tsol_blinrange) (const m_label_t *label, |
|
2492 |
+ const blrange_t *range); |
|
2493 |
+typedef void (*tsol_blminimum) (m_label_t *minimum_label, |
|
2494 |
+ const m_label_t *bounding_label); |
|
2495 |
+typedef void (*tsol_blmaximum) (m_label_t *maximum_label, |
|
2496 |
+ const m_label_t *bounding_label); |
|
2497 |
+typedef m_label_t* (*tsol_blabel_alloc) (void); |
|
2498 |
+typedef void (*tsol_blabel_free) (m_label_t *label_p); |
|
2499 |
+typedef void (*tsol_bsllow) (m_label_t *label); |
|
2500 |
+typedef void (*tsol_bslhigh) (m_label_t *label); |
|
2501 |
+ |
|
2502 |
+/* libXtsol functions */ |
|
15579 | 2503 |
+typedef Status (*xtsol_XTSOLgetResLabel) (Display *dpy, XID xid, |
2504 |
+ ResourceType resourceFlag, bslabel_t *sl); |
|
7480 | 2505 |
+typedef Status (*xtsol_XTSOLgetResUID) (Display *dpy, XID object, |
2506 |
+ ResourceType resourceFlag, |
|
2507 |
+ uid_t *uidp); |
|
2508 |
+typedef Status (*xtsol_XTSOLgetWorkstationOwner) (Display *dpy, uid_t *uidp); |
|
2509 |
+typedef Bool (*xtsol_XTSOLIsWindowTrusted) (Display *dpy, Window win); |
|
2510 |
+ |
|
2511 |
+/* libgnometsol functions */ |
|
2512 |
+typedef void (*gnome_tsol_constraint_image_render) (ConstraintImage *cimage, |
|
2513 |
+ GdkWindow *window, |
|
2514 |
+ GdkBitmap *mask, |
|
2515 |
+ GdkRectangle *clip_rect, |
|
2516 |
+ gboolean center, |
|
2517 |
+ gint x, |
|
2518 |
+ gint y, |
|
2519 |
+ gint width, |
|
2520 |
+ gint height); |
|
2521 |
+ |
|
2522 |
+typedef void (*gnome_tsol_constraint_image_set_border) (ConstraintImage *pb, |
|
2523 |
+ gint left, |
|
2524 |
+ gint right, |
|
2525 |
+ gint top, |
|
2526 |
+ gint bottom); |
|
2527 |
+ |
|
2528 |
+typedef void (*gnome_tsol_constraint_image_set_stretch) (ConstraintImage *pb, |
|
2529 |
+ gboolean stretch); |
|
2530 |
+ |
|
2531 |
+typedef void (*gnome_tsol_constraint_image_colorize) (ConstraintImage *image, |
|
2532 |
+ GdkColor *color, |
|
2533 |
+ int alpha, |
|
2534 |
+ gboolean use_alpha); |
|
2535 |
+ |
|
2536 |
+/* libbsm functions */ |
|
2537 |
+bsm_getdevicerange libbsm_getdevicerange; |
|
2538 |
+/* libtsol functions*/ |
|
2539 |
+tsol_label_to_str libtsol_label_to_str; |
|
2540 |
+tsol_str_to_label libtsol_str_to_label; |
|
2541 |
+tsol_m_label_free libtsol_m_label_free; |
|
2542 |
+/* Other misc. libtsol functions */ |
|
2543 |
+tsol_blminimum libtsol_blminimum; |
|
2544 |
+tsol_blmaximum libtsol_blmaximum; |
|
2545 |
+tsol_blinrange libtsol_blinrange; |
|
2546 |
+tsol_getuserrange libtsol_getuserrange; |
|
2547 |
+tsol_blabel_alloc libtsol_blabel_alloc; |
|
2548 |
+tsol_blabel_free libtsol_blabel_free; |
|
2549 |
+tsol_bsllow libtsol_bsllow; |
|
2550 |
+tsol_bslhigh libtsol_bslhigh; |
|
2551 |
+ |
|
15579 | 2552 |
+xtsol_XTSOLgetResLabel libxtsol_XTSOLgetResLabel; |
7480 | 2553 |
+xtsol_XTSOLgetResUID libxtsol_XTSOLgetResUID; |
2554 |
+xtsol_XTSOLgetWorkstationOwner libxtsol_XTSOLgetWorkstationOwner; |
|
2555 |
+xtsol_XTSOLIsWindowTrusted libxtsol_XTSOLIsWindowTrusted; |
|
2556 |
+ |
|
2557 |
+gnome_tsol_constraint_image_render libgnome_tsol_constraint_image_render; |
|
2558 |
+gnome_tsol_constraint_image_set_border libgnome_tsol_constraint_image_set_border; |
|
2559 |
+gnome_tsol_constraint_image_set_stretch libgnome_tsol_constraint_image_set_stretch; |
|
2560 |
+gnome_tsol_constraint_image_colorize libgnome_tsol_constraint_image_colorize; |
|
2561 |
+ |
|
2562 |
+const char* _wnck_get_min_label (); |
|
2563 |
+const char* _wnck_get_max_label (); |
|
2564 |
+ |
|
2565 |
+ |
|
2566 |
+/* GFX part */ |
|
2567 |
+ |
|
2568 |
+ConstraintImage* get_highlight_stripe (char* name, |
|
2569 |
+ GdkColor* label_color); |
|
2570 |
+ |
|
2571 |
+GtkWidget* window_menu_create_label_indicator (WnckWindow *window, |
|
2572 |
+ GtkWidget *image); |
|
2573 |
+ |
|
2574 |
+#endif /* HAVE_XTSOL */ |
|
2575 |
+#endif |
|
13074 | 2576 |
diff -urN libwnck.orig/libwnck/workspace.c libwnck.new/libwnck/workspace.c |
2577 |
--- libwnck.orig/libwnck/workspace.c 2008-08-06 23:43:13.502854000 +0100 |
|
2578 |
+++ libwnck.new/libwnck/workspace.c 2008-08-06 23:51:01.138260000 +0100 |
|
10691 | 2579 |
@@ -26,6 +26,16 @@ |
7480 | 2580 |
#include <config.h> |
2581 |
||
2582 |
#include <glib/gi18n-lib.h> |
|
2583 |
+#ifdef HAVE_XTSOL |
|
2584 |
+#include <stdlib.h> |
|
2585 |
+#include <sys/types.h> |
|
2586 |
+#include <unistd.h> |
|
2587 |
+#include <user_attr.h> |
|
2588 |
+#include <X11/Xlib.h> |
|
2589 |
+#include <X11/extensions/Xtsol.h> |
|
2590 |
+#include <libgnometsol/userattr.h> |
|
2591 |
+#include <wnck-tsol.h> |
|
2592 |
+#endif |
|
2593 |
#include "workspace.h" |
|
2594 |
#include "xutils.h" |
|
2595 |
#include "private.h" |
|
13074 | 2596 |
@@ -69,6 +79,13 @@ |
7480 | 2597 |
WnckScreen *screen; |
2598 |
int number; |
|
2599 |
char *name; |
|
2600 |
+#ifdef HAVE_XTSOL /* TSOL */ |
|
2601 |
+ char *label; /* Workspace sensitivity label */ |
|
2602 |
+ char *role; /* Workspace role : login name. Set only once */ |
|
2603 |
+ /* The workspace range can differ for Workstation Owner and role workspaces */ |
|
2604 |
+ const blrange_t *ws_range; |
|
2605 |
+#endif |
|
2606 |
+ |
|
2607 |
int width, height; /* Workspace size */ |
|
2608 |
int viewport_x, viewport_y; /* Viewport origin */ |
|
2609 |
gboolean is_virtual; |
|
13074 | 2610 |
@@ -79,6 +96,10 @@ |
7480 | 2611 |
|
2612 |
enum { |
|
2613 |
NAME_CHANGED, |
|
2614 |
+#ifdef HAVE_XTSOL |
|
2615 |
+ LABEL_CHANGED, |
|
2616 |
+ ROLE_CHANGED, |
|
2617 |
+#endif |
|
2618 |
LAST_SIGNAL |
|
2619 |
}; |
|
2620 |
||
13074 | 2621 |
@@ -91,6 +112,12 @@ |
7480 | 2622 |
|
10129 | 2623 |
static guint signals[LAST_SIGNAL] = { 0 }; |
7480 | 2624 |
|
2625 |
+#ifdef HAVE_XTSOL |
|
2626 |
+static void emit_label_changed (WnckWorkspace *space); |
|
2627 |
+static void emit_role_changed (WnckWorkspace *space); |
|
2628 |
+static blrange_t * get_display_range (void); |
|
2629 |
+#endif |
|
2630 |
+ |
|
10129 | 2631 |
static void |
2632 |
wnck_workspace_init (WnckWorkspace *workspace) |
|
2633 |
{ |
|
13074 | 2634 |
@@ -104,6 +131,9 @@ |
10174 | 2635 |
workspace->priv->viewport_x = 0; |
2636 |
workspace->priv->viewport_y = 0; |
|
2637 |
workspace->priv->is_virtual = FALSE; |
|
7480 | 2638 |
+#ifdef HAVE_XTSOL |
2639 |
+ workspace->priv->ws_range = NULL; |
|
2640 |
+#endif |
|
2641 |
} |
|
2642 |
||
2643 |
static void |
|
13074 | 2644 |
@@ -129,6 +159,24 @@ |
7480 | 2645 |
NULL, NULL, |
2646 |
g_cclosure_marshal_VOID__VOID, |
|
2647 |
G_TYPE_NONE, 0); |
|
2648 |
+#ifdef HAVE_XTSOL |
|
2649 |
+ signals[LABEL_CHANGED] = |
|
2650 |
+ g_signal_new ("label_changed", |
|
2651 |
+ G_OBJECT_CLASS_TYPE (object_class), |
|
2652 |
+ G_SIGNAL_RUN_LAST, |
|
2653 |
+ G_STRUCT_OFFSET (WnckWorkspaceClass, label_changed), |
|
2654 |
+ NULL, NULL, |
|
2655 |
+ g_cclosure_marshal_VOID__VOID, |
|
2656 |
+ G_TYPE_NONE, 0); |
|
2657 |
+ signals[ROLE_CHANGED] = |
|
2658 |
+ g_signal_new ("role_changed", |
|
2659 |
+ G_OBJECT_CLASS_TYPE (object_class), |
|
2660 |
+ G_SIGNAL_RUN_LAST, |
|
2661 |
+ G_STRUCT_OFFSET (WnckWorkspaceClass, role_changed), |
|
2662 |
+ NULL, NULL, |
|
2663 |
+ g_cclosure_marshal_VOID__VOID, |
|
2664 |
+ G_TYPE_NONE, 0); |
|
2665 |
+#endif |
|
2666 |
} |
|
2667 |
||
2668 |
static void |
|
13074 | 2669 |
@@ -140,6 +188,11 @@ |
7480 | 2670 |
|
2671 |
g_free (workspace->priv->name); |
|
10174 | 2672 |
workspace->priv->name = NULL; |
2673 |
+ |
|
7480 | 2674 |
+#ifdef HAVE_XTSOL |
2675 |
+ g_free (workspace->priv->role); |
|
2676 |
+ g_free (workspace->priv->label); |
|
2677 |
+#endif |
|
2678 |
||
10129 | 2679 |
G_OBJECT_CLASS (wnck_workspace_parent_class)->finalize (object); |
10174 | 2680 |
} |
13074 | 2681 |
@@ -179,6 +232,134 @@ |
7480 | 2682 |
return space->priv->name; |
2683 |
} |
|
2684 |
||
2685 |
+#ifdef HAVE_XTSOL |
|
2686 |
+/** |
|
2687 |
+ * wnck_workspace_get_label_range: |
|
2688 |
+ * @space: a #WnckWorkspace |
|
2689 |
+ * @min_label: a string pointer to pointer to the minimum valid label value for @space |
|
2690 |
+ * @max_label: a string pointer to pointer to the maximum valid label value for @space |
|
2691 |
+ * |
|
2692 |
+ * Gets the sensitivity label range for the specified workspace when |
|
2693 |
+ * running in a label aware desktop session. @min_label represents the minimum |
|
2694 |
+ * sensitivity label that the #WnckWorkspace, @space, may be assigned. |
|
2695 |
+ * @max_label represents the maximum sensitivity label thatthe #WnckWorkspace, |
|
2696 |
+ * @space may be assigned. Both min_label and max_label are allocated memory |
|
2697 |
+ * on behalf of the caller. It is the caller's responsibility to free the memory |
|
2698 |
+ * pointed to by @min_label and @max_label. |
|
2699 |
+ * |
|
2700 |
+ * Return value: 0 on success, non zero on failure. |
|
2701 |
+ **/ |
|
2702 |
+int |
|
2703 |
+wnck_workspace_get_label_range (WnckWorkspace *space, char **min_label, char **max_label) |
|
2704 |
+{ |
|
2705 |
+ int error = 0; |
|
2706 |
+ blrange_t *brange; |
|
2707 |
+ g_return_val_if_fail (WNCK_IS_WORKSPACE (space), -1); |
|
2708 |
+ |
|
2709 |
+ if (! _wnck_check_xtsol_extension ()) |
|
2710 |
+ return -1; |
|
2711 |
+ |
|
2712 |
+ if (!_wnck_use_trusted_extensions()) |
|
2713 |
+ return -1; |
|
2714 |
+ |
|
2715 |
+ brange = _wnck_workspace_get_range (space); |
|
10691 | 2716 |
+ if (!brange) |
2717 |
+ return -1; |
|
7480 | 2718 |
+ |
2719 |
+ if (libtsol_label_to_str (brange->lower_bound, min_label, M_INTERNAL, |
|
2720 |
+ LONG_NAMES) != 0) { |
|
2721 |
+ g_warning ("wnck_workspace_get_label_range: Workspace has an invalid minimum label bound"); |
|
2722 |
+ return -1; |
|
2723 |
+ } |
|
2724 |
+ |
|
2725 |
+ if (libtsol_label_to_str (brange->upper_bound, max_label, M_INTERNAL, |
|
2726 |
+ LONG_NAMES) != 0) { |
|
2727 |
+ g_warning ("wnck_workspace_get_label_range: Workspace has an invalid maximum label bound"); |
|
2728 |
+ return -1; |
|
2729 |
+ } |
|
2730 |
+ return 0; |
|
2731 |
+} |
|
2732 |
+ |
|
2733 |
+/** |
|
2734 |
+ * wnck_workspace_get_label: |
|
2735 |
+ * @space: a #WnckWorkspace |
|
2736 |
+ * |
|
2737 |
+ * Gets the sensitivity label as an hex number for the specified |
|
2738 |
+ * workspace when running in a label aware desktop session. |
|
2739 |
+ * |
|
2740 |
+ * Return value: workspace sensitivity label, %NULL on failure. |
|
2741 |
+ **/ |
|
2742 |
+const char* |
|
2743 |
+wnck_workspace_get_label (WnckWorkspace *space) |
|
2744 |
+{ |
|
2745 |
+ g_return_val_if_fail (WNCK_IS_WORKSPACE (space), NULL); |
|
2746 |
+ /* A bit anal perhaps but I'd rather make sure nothing useful is returned */ |
|
2747 |
+ if (! (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) ) |
|
2748 |
+ return NULL; |
|
2749 |
+ return space->priv->label; |
|
2750 |
+} |
|
2751 |
+ |
|
2752 |
+/** |
|
2753 |
+ * wnck_workspace_get_human_readable_label: |
|
2754 |
+ * @space: a #WnckWorkspace |
|
2755 |
+ * |
|
2756 |
+ * Gets the sensitivity label as a string for the specified workspace when |
|
2757 |
+ * running in a label aware desktop session. |
|
2758 |
+ * |
|
2759 |
+ * |
|
2760 |
+ * Return value: workspace sensitivity label, %NULL on failure. |
|
2761 |
+ **/ |
|
2762 |
+char* |
|
2763 |
+wnck_workspace_get_human_readable_label (WnckWorkspace *space) |
|
2764 |
+{ |
|
2765 |
+ const char *hex_label; |
|
2766 |
+ char *human_readable_label; |
|
2767 |
+ int error; |
|
2768 |
+ m_label_t *mlabel = NULL; |
|
2769 |
+ |
|
2770 |
+ g_return_val_if_fail (WNCK_IS_WORKSPACE (space), NULL); |
|
2771 |
+ if (! (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) ) |
|
2772 |
+ return NULL; |
|
2773 |
+ |
|
2774 |
+ hex_label = space->priv->label; |
|
2775 |
+ |
|
2776 |
+ if (hex_label && (error = libtsol_str_to_label (hex_label, &mlabel, MAC_LABEL, |
|
2777 |
+ L_NO_CORRECTION, &error) == 0)) |
|
2778 |
+ { |
|
2779 |
+ error = libtsol_label_to_str (mlabel, |
|
2780 |
+ &human_readable_label, |
|
2781 |
+ M_LABEL, DEF_NAMES); |
|
2782 |
+ if (strcmp (human_readable_label, "ADMIN_HIGH") == 0 || |
|
2783 |
+ strcmp (human_readable_label, "ADMIN_LOW") == 0) |
|
9275 | 2784 |
+ /* SUN_BRANDING TJDS */ |
7480 | 2785 |
+ return g_strdup (_("Trusted Path")); |
2786 |
+ return human_readable_label; |
|
2787 |
+ } |
|
2788 |
+ return NULL; |
|
2789 |
+} |
|
2790 |
+ |
|
2791 |
+ |
|
2792 |
+/** |
|
2793 |
+ * wnck_workspace_get_role: |
|
2794 |
+ * @space: a #WnckWorkspace |
|
2795 |
+ * |
|
2796 |
+ * Gets the role (login name) for the specified workspace when |
|
2797 |
+ * running in a trusted desktop session. |
|
2798 |
+ * |
|
2799 |
+ * Return value: workspace user role, %NULL on failure. |
|
2800 |
+ **/ |
|
2801 |
+const char* |
|
2802 |
+wnck_workspace_get_role (WnckWorkspace *space) |
|
2803 |
+{ |
|
2804 |
+ g_return_val_if_fail (WNCK_IS_WORKSPACE (space), NULL); |
|
2805 |
+ /* Make sure to return NULL for non-tsol */ |
|
2806 |
+ if (! (_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions()) ) |
|
2807 |
+ return NULL; |
|
2808 |
+ return space->priv->role; |
|
2809 |
+} |
|
2810 |
+#endif /* HAVE_XTSOL */ |
|
2811 |
+ |
|
2812 |
+ |
|
2813 |
/** |
|
2814 |
* wnck_workspace_change_name: |
|
10129 | 2815 |
* @space: a #WnckWorkspace. |
13074 | 2816 |
@@ -217,6 +398,29 @@ |
10174 | 2817 |
return space->priv->screen; |
7480 | 2818 |
} |
2819 |
||
2820 |
+#ifdef HAVE_XTSOL |
|
2821 |
+/** |
|
2822 |
+ * wnck_workspace_change_label: |
|
2823 |
+ * @space: a #WnckWorkspace |
|
2824 |
+ * @label: new workspace sensitivity label |
|
2825 |
+ * |
|
2826 |
+ * Try changing the sensitivity label of the workspace. |
|
2827 |
+ * |
|
2828 |
+ **/ |
|
2829 |
+ |
|
2830 |
+void |
|
2831 |
+wnck_workspace_change_label (WnckWorkspace *space, |
|
2832 |
+ const char *label) |
|
2833 |
+{ |
|
2834 |
+ g_return_if_fail (WNCK_IS_WORKSPACE (space)); |
|
2835 |
+ g_return_if_fail (label != NULL); |
|
2836 |
+ |
|
2837 |
+ _wnck_screen_change_workspace_label (space->priv->screen, |
|
2838 |
+ space->priv->number, |
|
2839 |
+ label); |
|
2840 |
+} |
|
2841 |
+#endif |
|
2842 |
+ |
|
2843 |
/** |
|
2844 |
* wnck_workspace_activate: |
|
10129 | 2845 |
* @space: a #WnckWorkspace. |
13074 | 2846 |
@@ -254,6 +458,7 @@ |
7480 | 2847 |
space->priv->screen = screen; |
2848 |
||
2849 |
_wnck_workspace_update_name (space, NULL); |
|
2850 |
+/* FIXME - do label and role need to be updated here? */ |
|
2851 |
||
2852 |
/* Just set reasonable defaults */ |
|
2853 |
space->priv->width = wnck_screen_get_width (screen); |
|
13074 | 2854 |
@@ -289,6 +494,251 @@ |
7480 | 2855 |
g_free (old); |
2856 |
} |
|
2857 |
||
2858 |
+#ifdef HAVE_XTSOL |
|
13074 | 2859 |
+ |
2860 |
+static char* |
|
2861 |
+get_workstationowner (void) |
|
2862 |
+{ |
|
2863 |
+ static char *workstationowner = NULL; |
|
2864 |
+ uid_t wsuid; |
|
2865 |
+ struct passwd *pwd; |
|
2866 |
+ |
|
2867 |
+ if (workstationowner == NULL) { |
|
2868 |
+ if ((libxtsol_XTSOLgetWorkstationOwner (gdk_x11_get_default_xdisplay (), |
|
2869 |
+ &wsuid)) < 0) { |
|
2870 |
+ g_warning ("XTSOLgetWorkstationOwner() failed. Using getuid() instead"); |
|
2871 |
+ pwd = getpwuid (getuid ()); |
|
2872 |
+ } else { |
|
2873 |
+ pwd = getpwuid (wsuid); |
|
2874 |
+ } |
|
2875 |
+ |
|
2876 |
+ workstationowner = g_strdup (pwd->pw_name); |
|
2877 |
+ } |
|
2878 |
+ |
|
2879 |
+ return workstationowner; |
|
2880 |
+} |
|
2881 |
+ |
|
7480 | 2882 |
+void |
2883 |
+_wnck_workspace_update_label (WnckWorkspace *space, |
|
2884 |
+ const char *label) |
|
2885 |
+{ |
|
2886 |
+ char *old; |
|
2887 |
+ |
|
2888 |
+ g_return_if_fail (WNCK_IS_WORKSPACE (space)); |
|
2889 |
+ /* Don't do anything unless this is a trusted system */ |
|
2890 |
+ if (!(_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions())) |
|
2891 |
+ return; |
|
2892 |
+ |
|
2893 |
+ /* Should a warning be called here? */ |
|
2894 |
+ if (label == NULL) |
|
2895 |
+ g_warning("Workspace %d label is null\n", |
|
2896 |
+ wnck_workspace_get_number (space)); |
|
2897 |
+ |
|
2898 |
+ old = space->priv->label; |
|
2899 |
+ space->priv->label = g_strdup (label); |
|
2900 |
+ |
|
2901 |
+ /* |
|
2902 |
+ *Initialise the label range for this workspace |
|
2903 |
+ */ |
|
2904 |
+ |
|
2905 |
+ if (!space->priv->ws_range) { |
|
13074 | 2906 |
+ if ((!space->priv->role) || (strlen (space->priv->role) == 0) || |
2907 |
+ (strcmp (space->priv->role, get_workstationowner ()) == 0)) { |
|
7480 | 2908 |
+ blrange_t *range; |
2909 |
+ int error; |
|
2910 |
+ char *min_label = NULL; |
|
2911 |
+ char *max_label = NULL; |
|
2912 |
+ range = g_malloc (sizeof (blrange_t)); |
|
2913 |
+ range->lower_bound = range->upper_bound = NULL; |
|
2914 |
+ |
|
2915 |
+ min_label = g_strdup (_wnck_get_min_label ()); |
|
2916 |
+ max_label = g_strdup (_wnck_get_max_label ()); |
|
2917 |
+ |
|
2918 |
+ if (libtsol_str_to_label (min_label, &(range->lower_bound), |
|
2919 |
+ MAC_LABEL, L_NO_CORRECTION, &error) < 0) { |
|
2920 |
+ g_warning ("Couldn't determine minimum workspace label"); |
|
2921 |
+ g_free (min_label); |
|
2922 |
+ g_free (max_label); |
|
2923 |
+ return; |
|
2924 |
+ } |
|
2925 |
+ if (libtsol_str_to_label (max_label, &(range->upper_bound), |
|
2926 |
+ USER_CLEAR, L_NO_CORRECTION, &error) < 0) { |
|
2927 |
+ g_warning ("Couldn't determine workspace clearance"); |
|
2928 |
+ g_free (min_label); |
|
2929 |
+ g_free (max_label); |
|
2930 |
+ return; |
|
2931 |
+ } |
|
2932 |
+ space->priv->ws_range = range; |
|
2933 |
+ g_free (min_label); |
|
2934 |
+ g_free (max_label); |
|
2935 |
+ |
|
2936 |
+ } else { |
|
2937 |
+ int error; |
|
2938 |
+ blrange_t *role_range; |
|
2939 |
+ blrange_t *disp_range; |
|
2940 |
+ userattr_t *u_ent; |
|
2941 |
+ /* |
|
2942 |
+ * This is a role workspace so we need to construct the correct label range |
|
2943 |
+ * instead of relying on USER_MIN_SL and USER_MAX_SL |
|
2944 |
+ */ |
|
2945 |
+ if ((role_range = libtsol_getuserrange (space->priv->role)) == NULL) { |
|
2946 |
+ g_warning ("Couldn't get label range for %s\n", space->priv->role); |
|
2947 |
+ return; |
|
2948 |
+ } |
|
2949 |
+ |
|
2950 |
+ /* Get display device's range */ |
|
2951 |
+ if ((disp_range = get_display_range ()) == NULL) { |
|
2952 |
+ g_warning ("Couldn't get the display's device range"); |
|
2953 |
+ return; |
|
2954 |
+ } |
|
2955 |
+ |
|
2956 |
+ /* |
|
2957 |
+ * Determine the low & high bound of the label range |
|
2958 |
+ * where the role user can operate. This is the |
|
2959 |
+ * intersection of display label range & role label |
|
2960 |
+ * range. |
|
2961 |
+ */ |
|
2962 |
+ libtsol_blmaximum (role_range->lower_bound, disp_range->lower_bound); |
|
2963 |
+ libtsol_blminimum (role_range->upper_bound, disp_range->upper_bound); |
|
2964 |
+ space->priv->ws_range = role_range; |
|
2965 |
+ libtsol_blabel_free (disp_range->lower_bound); |
|
2966 |
+ libtsol_blabel_free (disp_range->upper_bound); |
|
2967 |
+ free (disp_range); |
|
2968 |
+ } |
|
2969 |
+ } |
|
2970 |
+ /* Should we put a g_warning here? */ |
|
2971 |
+ /* if (space->priv->label == NULL) */ |
|
2972 |
+ |
|
2973 |
+ if ((!old && label) || |
|
2974 |
+ (old && label && strcmp (old, label) != 0)) |
|
2975 |
+ emit_label_changed (space); |
|
2976 |
+ |
|
2977 |
+ g_free (old); |
|
2978 |
+} |
|
2979 |
+ |
|
2980 |
+void |
|
2981 |
+_wnck_workspace_update_role (WnckWorkspace *space, |
|
2982 |
+ const char *role) |
|
2983 |
+{ |
|
13074 | 2984 |
+ char *workstationowner = NULL; |
7480 | 2985 |
+ char *old; |
2986 |
+ |
|
2987 |
+ g_return_if_fail (WNCK_IS_WORKSPACE (space)); |
|
2988 |
+ /* Check for a multi label trusted environment first */ |
|
2989 |
+ if (!(_wnck_check_xtsol_extension() && _wnck_use_trusted_extensions())) |
|
2990 |
+ return; |
|
13074 | 2991 |
+ workstationowner = get_workstationowner (); |
7480 | 2992 |
+ |
2993 |
+ if (role == NULL) |
|
2994 |
+ return; |
|
2995 |
+ old = space->priv->role; |
|
2996 |
+ |
|
2997 |
+ /* Check the the workspace role really is changing */ |
|
2998 |
+ if ((!old && role) || |
|
2999 |
+ (old && role && strcmp (old, role) != 0)) { |
|
3000 |
+ g_free (space->priv->role); |
|
3001 |
+ if (strlen (role) ==0) |
|
8535 | 3002 |
+ { space->priv->role = g_strdup (workstationowner); return;} |
7480 | 3003 |
+ else |
3004 |
+ space->priv->role = g_strdup (role); |
|
3005 |
+ |
|
3006 |
+ /* |
|
3007 |
+ * A role change requires that the label range of the |
|
3008 |
+ * workspace be reset. The label also needs to be |
|
3009 |
+ * silently set to the lowest in the range. |
|
3010 |
+ */ |
|
3011 |
+ |
|
3012 |
+ if (space->priv->ws_range) { |
|
3013 |
+ libtsol_blabel_free (space->priv->ws_range->lower_bound); |
|
3014 |
+ libtsol_blabel_free (space->priv->ws_range->upper_bound); |
|
3015 |
+ /* FIXME - man pages tell me to use free but generates a compiler warning */ |
|
3016 |
+ free ((void *)space->priv->ws_range); |
|
3017 |
+ } |
|
3018 |
+ |
|
3019 |
+ if (strcmp (space->priv->role, workstationowner) == 0) { |
|
3020 |
+ /* Workstation owner, so it's not a real role */ |
|
3021 |
+ blrange_t *range; |
|
3022 |
+ int error; |
|
3023 |
+ char *min_label = NULL; |
|
3024 |
+ char *max_label = NULL; |
|
3025 |
+ range = g_malloc (sizeof (blrange_t)); |
|
3026 |
+ range->lower_bound = range->upper_bound = NULL; |
|
3027 |
+ |
|
3028 |
+ min_label = g_strdup (_wnck_get_min_label ()); |
|
3029 |
+ max_label = g_strdup (_wnck_get_max_label ()); |
|
3030 |
+ |
|
3031 |
+ /* Workspace label must be reset by default to the min_label value */ |
|
3032 |
+ if (space->priv->label) |
|
3033 |
+ g_free (space->priv->label); |
|
3034 |
+ space->priv->label = g_strdup (min_label); |
|
3035 |
+ |
|
3036 |
+ if (libtsol_str_to_label (min_label, &(range->lower_bound), |
|
3037 |
+ MAC_LABEL, L_NO_CORRECTION, &error) < 0) { |
|
3038 |
+ g_warning ("Couldn't determine minimum workspace label"); |
|
3039 |
+ g_free (min_label); |
|
3040 |
+ g_free (max_label); |
|
3041 |
+ return; |
|
3042 |
+ } |
|
3043 |
+ |
|
3044 |
+ if (libtsol_str_to_label (max_label, &(range->upper_bound), |
|
3045 |
+ USER_CLEAR, L_NO_CORRECTION, &error) < 0) { |
|
3046 |
+ g_warning ("Couldn't determine workspace clearance"); |
|
3047 |
+ g_free (min_label); |
|
3048 |
+ g_free (max_label); |
|
3049 |
+ return; |
|
3050 |
+ } |
|
3051 |
+ |
|
3052 |
+ space->priv->ws_range = range; |
|
3053 |
+ g_free (min_label); |
|
3054 |
+ g_free (max_label); |
|
3055 |
+ |
|
3056 |
+ } else { |
|
3057 |
+ int error; |
|
3058 |
+ blrange_t *role_range; |
|
3059 |
+ blrange_t *disp_range; |
|
3060 |
+ userattr_t *u_ent; |
|
3061 |
+ |
|
3062 |
+ /* |
|
3063 |
+ * This is a role workspace so we need to construct the correct label range |
|
3064 |
+ * instead of relying on USER_MIN_SL and USER_MAX_SL |
|
3065 |
+ */ |
|
3066 |
+ if ((role_range = libtsol_getuserrange (space->priv->role)) == NULL) { |
|
3067 |
+ g_warning ("Couldn't get label range for %s\n", space->priv->role); |
|
3068 |
+ return; |
|
3069 |
+ } |
|
3070 |
+ |
|
3071 |
+ /* Get display device's range */ |
|
3072 |
+ if ((disp_range = get_display_range ()) == NULL) { |
|
3073 |
+ g_warning ("Couldn't get the display's device range"); |
|
3074 |
+ return; |
|
3075 |
+ } |
|
3076 |
+ |
|
3077 |
+ /* |
|
3078 |
+ * Determine the low & high bound of the label range |
|
3079 |
+ * where the role user can operate. This is the |
|
3080 |
+ * intersection of display label range & role label |
|
3081 |
+ * range. |
|
3082 |
+ */ |
|
3083 |
+ libtsol_blmaximum (role_range->lower_bound, disp_range->lower_bound); |
|
3084 |
+ libtsol_blminimum (role_range->upper_bound, disp_range->upper_bound); |
|
3085 |
+ space->priv->ws_range = role_range; |
|
3086 |
+ |
|
3087 |
+ /* Workspace label must be reset by default to the lower_bound value */ |
|
3088 |
+ if (libtsol_label_to_str (role_range->lower_bound, &space->priv->label, M_INTERNAL, |
|
3089 |
+ LONG_NAMES) != 0) { |
|
3090 |
+ /* Weird - default to admin_low */ |
|
3091 |
+ space->priv->label = g_strup ("ADMIN_LOW"); |
|
3092 |
+ } |
|
3093 |
+ |
|
3094 |
+ libtsol_blabel_free (disp_range->lower_bound); |
|
3095 |
+ libtsol_blabel_free (disp_range->upper_bound); |
|
3096 |
+ free (disp_range); |
|
3097 |
+ } |
|
3098 |
+ emit_role_changed (space); |
|
3099 |
+ } |
|
3100 |
+} |
|
3101 |
+#endif /* HAVE_XTSOL */ |
|
3102 |
+ |
|
3103 |
static void |
|
3104 |
emit_name_changed (WnckWorkspace *space) |
|
3105 |
{ |
|
13074 | 3106 |
@@ -297,6 +747,24 @@ |
7480 | 3107 |
0); |
3108 |
} |
|
3109 |
||
3110 |
+#ifdef HAVE_XTSOL |
|
3111 |
+static void |
|
3112 |
+emit_label_changed (WnckWorkspace *space) |
|
3113 |
+{ |
|
3114 |
+ g_signal_emit (G_OBJECT (space), |
|
3115 |
+ signals[LABEL_CHANGED], |
|
3116 |
+ 0); |
|
3117 |
+} |
|
3118 |
+ |
|
3119 |
+static void |
|
3120 |
+emit_role_changed (WnckWorkspace *space) |
|
3121 |
+{ |
|
3122 |
+ g_signal_emit (G_OBJECT (space), |
|
3123 |
+ signals[ROLE_CHANGED], |
|
3124 |
+ 0); |
|
3125 |
+} |
|
3126 |
+#endif /* HAVE_XTSOL */ |
|
3127 |
+ |
|
3128 |
gboolean |
|
3129 |
_wnck_workspace_set_geometry (WnckWorkspace *space, |
|
3130 |
int w, |
|
13074 | 3131 |
@@ -612,3 +1080,33 @@ |
10129 | 3132 |
|
10174 | 3133 |
return wnck_screen_get_workspace (space->priv->screen, index); |
7480 | 3134 |
} |
3135 |
+ |
|
3136 |
+#ifdef HAVE_XTSOL |
|
3137 |
+/* |
|
3138 |
+ * These private (hint hint) functions assume that they have been called |
|
3139 |
+ * from within a trusted desktop session. The caller must ensure that |
|
3140 |
+ * this is the case otherwise it will trigger a load of the potentially |
|
3141 |
+ * non existant tsol and xtsol libs. That would be bad! |
|
3142 |
+ */ |
|
3143 |
+static blrange_t * |
|
3144 |
+get_display_range (void) |
|
3145 |
+{ |
|
3146 |
+ blrange_t *range = NULL; |
|
3147 |
+ |
|
3148 |
+ range = libbsm_getdevicerange ("framebuffer"); |
|
3149 |
+ if (range == NULL) { |
|
3150 |
+ range = g_malloc (sizeof (blrange_t)); |
|
3151 |
+ range->lower_bound = libtsol_blabel_alloc (); |
|
3152 |
+ range->upper_bound = libtsol_blabel_alloc (); |
|
3153 |
+ libtsol_bsllow (range->lower_bound); |
|
3154 |
+ libtsol_bslhigh (range->upper_bound); |
|
3155 |
+ } |
|
3156 |
+ return (range); |
|
3157 |
+} |
|
3158 |
+ |
|
3159 |
+blrange_t * |
|
3160 |
+_wnck_workspace_get_range (WnckWorkspace *space) |
|
3161 |
+{ |
|
3162 |
+ return space->priv->ws_range; |
|
3163 |
+} |
|
3164 |
+#endif |
|
13074 | 3165 |
diff -urN libwnck.orig/libwnck/workspace.h libwnck.new/libwnck/workspace.h |
3166 |
--- libwnck.orig/libwnck/workspace.h 2008-08-06 23:43:13.464638000 +0100 |
|
3167 |
+++ libwnck.new/libwnck/workspace.h 2008-08-06 23:43:40.159050000 +0100 |
|
3168 |
@@ -57,6 +57,11 @@ |
|
7480 | 3169 |
GObjectClass parent_class; |
3170 |
||
3171 |
void (* name_changed) (WnckWorkspace *space); |
|
10012 | 3172 |
+ |
7480 | 3173 |
+#ifdef HAVE_XTSOL |
3174 |
+ void (* label_changed) (WnckWorkspace *space); |
|
8535 | 3175 |
+ void (* role_changed) (WnckWorkspace *space); |
7480 | 3176 |
+#endif |
10012 | 3177 |
|
3178 |
/* Padding for future expansion */ |
|
3179 |
void (* pad1) (void); |
|
13074 | 3180 |
@@ -69,9 +74,22 @@ |
7480 | 3181 |
|
3182 |
int wnck_workspace_get_number (WnckWorkspace *space); |
|
3183 |
const char* wnck_workspace_get_name (WnckWorkspace *space); |
|
3184 |
+#ifdef HAVE_XTSOL |
|
10012 | 3185 |
+int wnck_workspace_get_label_range(WnckWorkspace *space, |
3186 |
+ char **min_label, |
|
3187 |
+ char **max_label); |
|
3188 |
+const char* wnck_workspace_get_label (WnckWorkspace *space); |
|
3189 |
+char* wnck_workspace_get_human_readable_label (WnckWorkspace *space); |
|
3190 |
+const char* wnck_workspace_get_role (WnckWorkspace *space); |
|
7480 | 3191 |
+#endif |
10012 | 3192 |
+ |
7480 | 3193 |
void wnck_workspace_change_name (WnckWorkspace *space, |
3194 |
const char *name); |
|
10174 | 3195 |
WnckScreen* wnck_workspace_get_screen (WnckWorkspace *space); |
7480 | 3196 |
+#ifdef HAVE_XTSOL |
3197 |
+void wnck_workspace_change_label (WnckWorkspace *space, |
|
3198 |
+ const char *label); |
|
3199 |
+#endif |
|
3200 |
void wnck_workspace_activate (WnckWorkspace *space, |
|
3201 |
guint32 timestamp); |
|
3202 |
int wnck_workspace_get_width (WnckWorkspace *space); |
|
13074 | 3203 |
diff -urN libwnck.orig/libwnck/xutils.c libwnck.new/libwnck/xutils.c |
3204 |
--- libwnck.orig/libwnck/xutils.c 2008-08-06 23:43:13.631420000 +0100 |
|
3205 |
+++ libwnck.new/libwnck/xutils.c 2008-08-06 23:43:40.166864000 +0100 |
|
11201 | 3206 |
@@ -27,6 +27,7 @@ |
7480 | 3207 |
#include <stdio.h> |
3208 |
#include "screen.h" |
|
3209 |
#include "window.h" |
|
3210 |
+#include "wnck-tsol.h" |
|
3211 |
#include "private.h" |
|
3212 |
#include "inlinepixbufs.h" |
|
3213 |
||
13074 | 3214 |
@@ -231,6 +232,21 @@ |
7480 | 3215 |
return TRUE; |
3216 |
} |
|
3217 |
||
3218 |
+#ifdef HAVE_XTSOL |
|
3219 |
+gboolean |
|
3220 |
+_wnck_check_xtsol_extension () |
|
3221 |
+{ |
|
3222 |
+ static int foundxtsol = -1; |
|
3223 |
+ int major_code, first_event, first_error; |
|
3224 |
+ |
|
3225 |
+ if (foundxtsol < 0) { |
|
3226 |
+ foundxtsol = XQueryExtension (gdk_display, "SUN_TSOL", &major_code, |
|
3227 |
+ &first_event, &first_error); |
|
3228 |
+ } |
|
3229 |
+ return foundxtsol; |
|
3230 |
+} |
|
3231 |
+#endif |
|
3232 |
+ |
|
3233 |
static char* |
|
3234 |
text_property_to_utf8 (const XTextProperty *prop) |
|
3235 |
{ |
|
17793 | 3236 |
diff -ruN libwnck-2.30.0.orig/libwnck/Makefile.am libwnck-2.30.0/libwnck/Makefile.am |
3237 |
--- libwnck-2.30.0.orig/libwnck/Makefile.am 2010-04-03 21:06:32.639895227 +0100 |
|
3238 |
+++ libwnck-2.30.0/libwnck/Makefile.am 2010-04-03 21:08:33.899401342 +0100 |
|
3239 |
@@ -27,6 +27,11 @@ |
|
3240 |
wnck_built_headers = $(wnck_built_installed_headers) wnck-marshal.h |
|
3241 |
wnck_built_cfiles = wnck-enum-types.c wnck-marshal.c |
|
3242 |
||
3243 |
+wncktsol_sources = \ |
|
3244 |
+ wnck-tsol.c |
|
3245 |
+wncktsol_h_sources = \ |
|
3246 |
+ wnck-tsol.h |
|
3247 |
+ |
|
3248 |
# Sources that are relevant for introspection |
|
3249 |
wnck_sources = \ |
|
3250 |
application.c \ |
|
3251 |
@@ -58,6 +63,11 @@ |
|
3252 |
private.h \ |
|
3253 |
xutils.c \ |
|
3254 |
xutils.h \ |
|
3255 |
+ tsol-pics.h \ |
|
3256 |
+ trusted-tooltips.c \ |
|
3257 |
+ trusted-tooltips.h \ |
|
3258 |
+ $(wncktsol_sources) \ |
|
3259 |
+ $(wncktsol_h_sources) \ |
|
3260 |
$(wnck_accessibility_files) |
|
3261 |
||
3262 |
$(libwnck_1_la_OBJECTS): $(wnck_built_headers) inlinepixbufs.h |