1 /*******************************************************************************
2  * Copyright (c) 2007, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 #ifndef ECLIPSE_GTK_H
15 #define ECLIPSE_GTK_H
16 
17 #include <gtk/gtk.h>
18 #include <gdk-pixbuf/gdk-pixbuf.h>
19 #include <gdk/gdkx.h>
20 
21 struct GTK_PTRS {
22 	short 		not_initialized;
23 	void		(*gtk_container_add)		(GtkContainer*, GtkWidget*);
24 	gint		(*gtk_dialog_run)			(GtkDialog *);
25 	GtkWidget*	(*gtk_image_new_from_pixbuf)(GdkPixbuf*);
26 	gboolean	(*gtk_init_with_args)		(int*, char***, const char *, void *, const char *, GError **);
27 	GtkWidget*	(*gtk_message_dialog_new)	(GtkWindow*, GtkDialogFlags, GtkMessageType, GtkButtonsType, const gchar*, ...);
28 	void		(*gtk_widget_destroy)		(GtkWidget*);
29 	void		(*gtk_widget_destroyed)		(GtkWidget*, GtkWidget**);
30 	void		(*gtk_widget_show_all)		(GtkWidget*);
31 	GtkWidget*	(*gtk_window_new)			(GtkWindowType);
32 	void		(*gtk_window_resize)		(GtkWindow*, gint, gint);
33 	void		(*gtk_window_set_title)		(GtkWindow*, const gchar*);
34 	void		(*gtk_window_set_decorated)	(GtkWindow*, gboolean);
35 	void		(*gtk_window_set_type_hint)	(GtkWindow*, int);
36 	void		(*gtk_window_set_position)	(GtkWindow*, GtkWindowPosition);
37 
38 	gulong 		(*g_signal_connect_data)	(gpointer, const gchar*, GCallback, gpointer, GClosureNotify, GConnectFlags);
39 	gboolean	(*g_main_context_iteration)	(GMainContext*, gboolean);
40 	void		(*g_object_unref)			(gpointer);
41 	guint       (*g_timeout_add)			(guint, GSourceFunc, gpointer);
42 	void		(*g_error_free)				(GError *);
43 	void		(*g_type_init)            	();
44 	GDBusProxy*	(*g_dbus_proxy_new_for_bus_sync) (GBusType, GDBusProxyFlags, GDBusInterfaceInfo *, const gchar *,const gchar *, const gchar *, GCancellable *, GError **);
45 	GVariant *  (*g_dbus_proxy_call_sync) (GDBusProxy *, const gchar *, GVariant *, GDBusCallFlags, gint, GCancellable *, GError **);
46 	GVariantBuilder * (*g_variant_builder_new) (const GVariantType *);
47 	void 		(*g_variant_builder_add) 	(GVariantBuilder *, const gchar *, const gchar *);
48 	GVariant * 	(*g_variant_new) 			(const gchar *, GVariantBuilder *);
49 	void 		(*g_variant_builder_unref) 	(GVariantBuilder *);
50 	void		(*g_variant_unref) 			(GVariant *);
51 #ifdef SOLARIS
52 	GString* 	(*g_string_insert_c) 		(GString *, gssize, gchar);
53 #endif
54 
55 	GdkDisplay* (*gdk_display_get_default)  		();
56 	GdkPixbuf*	(*gdk_pixbuf_new_from_file)			(const char*, GError **);
57 	GdkPixbuf*	(*gdk_pixbuf_scale_simple)			(const GdkPixbuf*, int, int, GdkInterpType);
58 	int			(*gdk_pixbuf_get_width)				(const GdkPixbuf*);
59 	int			(*gdk_pixbuf_get_height)			(const GdkPixbuf*);
60 	GdkScreen *	(*gdk_screen_get_default)			();
61 	double		(*gdk_screen_get_resolution)		(GdkScreen *);
62 
63 };
64 
65 extern struct GTK_PTRS gtk;
66 
67 #define FN_TABLE_ENTRY(fn, required) { (void**)& gtk.fn, #fn, required }
68 typedef struct {
69 	void ** fnPtr;
70 	char * fnName;
71 	int required;
72 } FN_TABLE;
73 
74 /* load the gtk libraries and initialize the function pointers */
75 extern int loadGtk();
76 
77 #endif
78