summaryrefslogtreecommitdiff
path: root/packages/gtk+/gtk+-2.6.10/help.patch
blob: 268b3dd9e24153c7824c8b7ca5d35b20a9dbe1a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
diff -NaurBb gtk+-2.6.10.old/gtk/Makefile.am gtk+-2.6.10/gtk/Makefile.am
--- gtk+-2.6.10.old/gtk/Makefile.am	2005-08-18 16:10:56.000000000 +0200
+++ gtk+-2.6.10/gtk/Makefile.am	2005-12-29 01:23:52.000000000 +0100
@@ -520,6 +520,7 @@
 	gtkwidget.c		\
 	gtkwindow-decorate.c    \
 	gtkwindow.c		\
+	gpe-what.c		\
 	xembed.h
 
 if OS_UNIX
diff -NaurBb gtk+-2.6.10.old/gtk/gpe-what.c gtk+-2.6.10/gtk/gpe-what.c
--- gtk+-2.6.10.old/gtk/gpe-what.c	1970-01-01 01:00:00.000000000 +0100
+++ gtk+-2.6.10/gtk/gpe-what.c	2005-12-29 00:59:26.000000000 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2002, 2003 Philip Blundell <philb@gnu.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#ifdef GDK_WINDOWING_X11
+#error X11 required
+#endif
+
+#include "gtkwidget.h"
+#include "gtktooltips.h"
+#include "x11/gdkx.h"
+#include "config.h"
+
+#include <libintl.h>
+
+#define _(x) dgettext(GETTEXT_PACKAGE, x)
+
+static GdkAtom help_atom;
+static gboolean gpe_what_initialised;
+
+static GSList *widgets;
+
+static void
+send_text (Display *dpy, Window w, char *text)
+{
+  Atom help_xatom = gdk_x11_atom_to_xatom (help_atom);
+
+  gdk_error_trap_push ();
+
+  XChangeProperty (dpy, w, help_xatom, XA_STRING, 8, PropModeReplace, text, strlen (text));
+
+  XFlush (dpy);
+
+  gdk_error_trap_pop ();
+}
+
+static GdkFilterReturn 
+filter_func (GdkXEvent *xev, GdkEvent *ev, gpointer p)
+{
+  XClientMessageEvent *xc = (XClientMessageEvent *)xev;
+  GSList *list;
+  Window sender = xc->data.l[0];
+
+  for (list = widgets; list; list = list->next)
+    {
+      GtkWidget *widget = GTK_WIDGET (list->data);
+      int x = xc->data.l[1], y = xc->data.l[2];
+      int ax, ay;
+      
+      if (!GTK_WIDGET_DRAWABLE (widget)) continue;
+      
+      if (GTK_WIDGET_NO_WINDOW (widget))
+	{
+	  ax = widget->allocation.x;
+	  ay = widget->allocation.y;
+	}
+      else
+	{
+	  ax = 0;
+	  ay = 0;
+	}
+
+      if (widget->window == ev->any.window
+	  && x >= ax && x < ax + widget->allocation.width
+	  && y >= ay && y < ay + widget->allocation.height)
+	{
+	  GtkTooltipsData *data = gtk_tooltips_data_get (widget);
+	  if (data)
+	    {
+	      send_text (GDK_WINDOW_XDISPLAY (widget->window), sender, 
+			 data->tip_private ? data->tip_private : data->tip_text);
+	      return GDK_FILTER_CONTINUE;
+	    }
+	}
+    }
+
+  send_text (GDK_WINDOW_XDISPLAY (ev->any.window), sender, _("No help available."));
+
+  return GDK_FILTER_CONTINUE;
+}
+
+void
+gpe_what_mark_widget (GtkWidget *widget)
+{
+  if (!gpe_what_initialised)
+    {
+      help_atom = gdk_atom_intern ("_GPE_INTERACTIVE_HELP", FALSE);
+
+      gdk_add_client_message_filter (help_atom, filter_func, NULL);
+
+      gpe_what_initialised = TRUE;
+    }
+  
+  if (widget->window)
+    {
+      widgets = g_slist_prepend (widgets, widget);
+      
+      gdk_property_change (widget->window,
+			   help_atom,
+			   help_atom,
+			   8,
+			   GDK_PROP_MODE_REPLACE,
+			   NULL,
+			   0);
+    }
+  else
+    abort ();
+}
diff -NaurBb gtk+-2.6.10.old/gtk/gtkwidget.c gtk+-2.6.10/gtk/gtkwidget.c
--- gtk+-2.6.10.old/gtk/gtkwidget.c	2005-08-18 16:10:59.000000000 +0200
+++ gtk+-2.6.10/gtk/gtkwidget.c	2005-12-29 00:59:26.000000000 +0100
@@ -2285,6 +2285,9 @@
       
       g_signal_emit (widget, widget_signals[REALIZE], 0);
       
+      extern void gpe_what_mark_widget (GtkWidget *widget);
+      gpe_what_mark_widget (widget);
+      
       if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
 	{
 	  shape_info = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);