summaryrefslogtreecommitdiff
path: root/patches/a11y/a11y-gtk-frame.diff
blob: 001066543fd4873a2e65c0042b1b78211384f957 (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
Index: vcl/unx/inc/plugins/gtk/gtkframe.hxx
===================================================================
RCS file: /cvs/gsl/vcl/unx/inc/plugins/gtk/gtkframe.hxx,v
retrieving revision 1.13
diff -u -r1.13 gtkframe.hxx
--- vcl/unx/inc/plugins/gtk/gtkframe.hxx	30 Mar 2005 09:09:03 -0000	1.13
+++ vcl/unx/inc/plugins/gtk/gtkframe.hxx	12 Apr 2005 15:53:55 -0000
@@ -69,6 +69,9 @@
 #include <gdk/gdkkeysyms.h>
 #include <postx.h>
 
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/accessibility/XAccessible.hdl>
+
 #ifndef _SV_SALFRAME_HXX
 #include <salframe.hxx>
 #endif
@@ -355,6 +358,9 @@
     virtual bool                SetPluginParent( SystemParentData* pNewParent );
 
     virtual void                SetBackgroundBitmap( SalBitmap* );
+
+	static GtkSalFrame         *getFromWindow( GtkWindow *pWindow );
+	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessible( bool bCreate = true );
 };
 
 
Index: vcl/unx/gtk/window/gtkframe.cxx
===================================================================
RCS file: /cvs/gsl/vcl/unx/gtk/window/gtkframe.cxx,v
retrieving revision 1.26
diff -u -r1.26 gtkframe.cxx
--- vcl/unx/gtk/window/gtkframe.cxx	30 Mar 2005 09:11:10 -0000	1.26
+++ vcl/unx/gtk/window/gtkframe.cxx	12 Apr 2005 15:53:58 -0000
@@ -63,6 +63,7 @@
 #include <plugins/gtk/gtkdata.hxx>
 #include <plugins/gtk/gtkinst.hxx>
 #include <plugins/gtk/gtkgdi.hxx>
+#include <plugins/gtk/atkfactory.hxx>
 #include <keycodes.hxx>
 #include <wmadaptor.hxx>
 #include <sm.hxx>
@@ -71,6 +72,7 @@
 #include <floatwin.hxx>
 #include <salprn.h>
 #include <svapp.hxx>
+#include <window.hxx>
 
 #include <prex.h>
 #include <X11/Xatom.h>
@@ -271,7 +273,10 @@
     if( m_pFixedContainer )
         gtk_widget_destroy( GTK_WIDGET(m_pFixedContainer) );
     if( m_pWindow )
+	{
+		g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", NULL );
         gtk_widget_destroy( GTK_WIDGET(m_pWindow) );
+	}
     if( m_pForeignParent )
         g_object_unref( G_OBJECT(m_pForeignParent) );
     if( m_pForeignTopLevel )
@@ -485,6 +490,64 @@
     }
 }
 
+// Always use a sub-class of GtkWindow we can tag for a11yx
+static GType
+ooo_window_get_type()
+{
+	static GType t = 0;
+
+	if (!t) {
+		static const GTypeInfo tinfo =
+		{
+			sizeof( GtkWindowClass ),
+			NULL, NULL, NULL, NULL, NULL,
+			sizeof( GtkWindow ), 0, NULL, NULL
+		};
+
+		t = g_type_register_static(
+				GTK_TYPE_WINDOW, "OOoWindow", &tinfo, (GTypeFlags) 0);
+		RegisterAtkFactory( t );
+	}
+
+	return t;									
+}
+
+static GtkWindow *
+createWindow( GtkSalFrame *pThis, ULONG nStyle )
+{
+	GtkWindow *pWindow;
+	GtkWindowType eType = (  (nStyle & SAL_FRAME_STYLE_FLOAT) &&
+						   ! (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) ? 
+			GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL;
+
+	// FIXME - we should really sub-class instead of doing
+	// tens of expensive signal connections ... and this:
+
+	static int nCount = 0;
+	if( eType == GTK_WINDOW_TOPLEVEL )
+			fprintf( stderr, "Create toplevel %d\n", ++nCount );
+
+	pWindow = GTK_WINDOW( g_object_new( ooo_window_get_type(),
+										"type", eType, "visible", FALSE, NULL ) );
+	g_object_set_data( G_OBJECT( pWindow ), "SalFrame", pThis );
+
+	return pWindow;
+}
+
+GtkSalFrame *GtkSalFrame::getFromWindow( GtkWindow *pWindow )
+{
+	return (GtkSalFrame *) g_object_get_data( G_OBJECT( pWindow ), "SalFrame" );
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+GtkSalFrame::getAccessible( bool bCreate )
+{
+	// Yes - this is a hack - but: this abstraction seems totally useless to me
+	Window *pWindow = static_cast<Window *>(GetInstance());
+	if( pWindow )
+		return pWindow->GetAccessible( bCreate );
+}
+
 void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle )
 {
     if( nStyle & SAL_FRAME_STYLE_DEFAULT ) // ensure default style
@@ -493,7 +556,8 @@
         nStyle &= ~SAL_FRAME_STYLE_FLOAT;
     }
 
-    m_pWindow = GTK_WINDOW( gtk_widget_new( GTK_TYPE_WINDOW, "type", ((nStyle & SAL_FRAME_STYLE_FLOAT) && ! (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION)) ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL, "visible", FALSE, NULL ) );
+    m_pWindow = createWindow( this, nStyle );
+
     m_pParent = static_cast<GtkSalFrame*>(pParent);
     m_pForeignParent = NULL;
     m_aForeignParentWindow = None;