Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2013-02-14 12:36:43 -0500
committerThomas Watson2013-02-15 10:50:06 -0500
commitb22f25b711d260fe88c83d320dde89a9f56db7d6 (patch)
treea890c0b561c899cd47e5e78c433aed5e3d4c8be7 /features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c
parentcb70c695f5c85be396bcb024db894795f8ec3262 (diff)
downloadrt.equinox.framework-b22f25b711d260fe88c83d320dde89a9f56db7d6.tar.gz
rt.equinox.framework-b22f25b711d260fe88c83d320dde89a9f56db7d6.tar.xz
rt.equinox.framework-b22f25b711d260fe88c83d320dde89a9f56db7d6.zip
Bug 394216 - o.e.equinox.executables IUs must be in build repo
Generate the correct feature and a secondary IU that doesn't include all executables.
Diffstat (limited to 'features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c')
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c b/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c
new file mode 100644
index 000000000..51ed70a9f
--- /dev/null
+++ b/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtkInit.c
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "eclipseGtk.h"
+#include "eclipseCommon.h"
+#include <dlfcn.h>
+#include <string.h>
+#include <stdlib.h>
+
+struct GTK_PTRS gtk = { 1 }; /* initialize the first field "not_initialized" so we can tell when we've loaded the pointers */
+
+/* tables to help initialize the function pointers */
+/* functions from libgtk-x11-2.0 or libgtk-3.so.0*/
+static FN_TABLE gtkFunctions[] = {
+ FN_TABLE_ENTRY(gtk_container_add, 1),
+ FN_TABLE_ENTRY(gtk_dialog_run, 1),
+ FN_TABLE_ENTRY(gtk_image_new_from_pixbuf, 1),
+ FN_TABLE_ENTRY(gtk_init_check, 1),
+ FN_TABLE_ENTRY(gtk_init_with_args, 0),
+ FN_TABLE_ENTRY(gtk_message_dialog_new, 1),
+ FN_TABLE_ENTRY(gtk_set_locale, 0),
+ FN_TABLE_ENTRY(gtk_widget_destroy, 1),
+ FN_TABLE_ENTRY(gtk_widget_destroyed, 1),
+ FN_TABLE_ENTRY(gtk_widget_show_all, 1),
+ FN_TABLE_ENTRY(gtk_window_new, 1),
+ FN_TABLE_ENTRY(gtk_window_resize, 1),
+ FN_TABLE_ENTRY(gtk_window_set_title, 1),
+ FN_TABLE_ENTRY(gtk_window_set_decorated, 1),
+ FN_TABLE_ENTRY(gtk_window_set_position, 1),
+ { NULL, NULL }
+};
+/* functions from libgdk-x11-2.0 or libgdk-3.so.0*/
+static FN_TABLE gdkFunctions[] = {
+ FN_TABLE_ENTRY(gdk_set_program_class, 1),
+ FN_TABLE_ENTRY(gdk_display_get_default, 1),
+ FN_TABLE_ENTRY(gdk_x11_display_get_xdisplay, 1),
+ { NULL, NULL }
+};
+/* functions from libgdk_pixbuf-2.0 */
+static FN_TABLE pixFunctions[] = {
+ FN_TABLE_ENTRY(gdk_pixbuf_new_from_file, 1),
+ FN_TABLE_ENTRY(gdk_pixbuf_get_width, 1),
+ FN_TABLE_ENTRY(gdk_pixbuf_get_height, 1),
+ { NULL, NULL }
+};
+/* functions from libgobject-2.0 */
+static FN_TABLE gobjFunctions[] = {
+ FN_TABLE_ENTRY(g_signal_connect_data, 1),
+ FN_TABLE_ENTRY(g_main_context_iteration, 1),
+ FN_TABLE_ENTRY(g_object_unref, 1),
+ FN_TABLE_ENTRY(g_timeout_add, 1),
+ FN_TABLE_ENTRY(g_error_free, 1),
+#ifdef SOLARIS
+ FN_TABLE_ENTRY(g_string_insert_c, 1),
+#endif
+ { NULL, NULL }
+};
+
+/* functions from libX11 */
+static FN_TABLE x11Functions[] = {
+ FN_TABLE_ENTRY(XGetSelectionOwner, 1),
+ FN_TABLE_ENTRY(XSetSelectionOwner, 1),
+ FN_TABLE_ENTRY(XCreateWindow, 1),
+ FN_TABLE_ENTRY(XChangeProperty, 1),
+ FN_TABLE_ENTRY(XSync, 1),
+ FN_TABLE_ENTRY(XRootWindow, 1),
+ FN_TABLE_ENTRY(XDefaultScreen, 1),
+ FN_TABLE_ENTRY(XInternAtom, 1),
+ { NULL, NULL }
+};
+
+
+static int loadGtkSymbols( void * library, FN_TABLE * table) {
+ int i = 0;
+ void * fn;
+ for (i = 0; table[i].fnName != NULL; i++) {
+ fn = findSymbol(library, table[i].fnName);
+ if (fn != 0) {
+ *(table[i].fnPtr) = fn;
+ } else {
+ if (table[i].required) return -1;
+ }
+ }
+ return 0;
+}
+
+int loadGtk() {
+#ifdef AIX
+#define DLFLAGS RTLD_LAZY | RTLD_MEMBER
+#else
+#define DLFLAGS RTLD_LAZY
+#endif
+
+ void *gdkLib = NULL, *gtkLib = NULL, *objLib = NULL, *pixLib = NULL, *x11Lib = NULL;
+
+ if (getenv("SWT_GTK3")) {
+ gdkLib = dlopen(GDK3_LIB, DLFLAGS);
+ gtkLib = dlopen(GTK3_LIB, DLFLAGS);
+ }
+ if (!gtkLib || !gdkLib) {
+ gdkLib = dlopen(GDK_LIB, DLFLAGS);
+ gtkLib = dlopen(GTK_LIB, DLFLAGS);
+ }
+ objLib = dlopen(GOBJ_LIB, DLFLAGS);
+ pixLib = dlopen(PIXBUF_LIB, DLFLAGS);
+ x11Lib = dlopen(X11_LIB, DLFLAGS);
+
+ /* initialize ptr struct to 0's */
+ memset(&gtk, 0, sizeof(struct GTK_PTRS));
+
+ if ( gtkLib == NULL || loadGtkSymbols(gtkLib, gtkFunctions) != 0) return -1;
+ if ( gdkLib == NULL || loadGtkSymbols(gdkLib, gdkFunctions) != 0) return -1;
+ if ( pixLib == NULL || loadGtkSymbols(pixLib, pixFunctions) != 0) return -1;
+ if ( objLib == NULL || loadGtkSymbols(objLib, gobjFunctions) != 0) return -1;
+ if ( x11Lib == NULL || loadGtkSymbols(x11Lib, x11Functions) != 0) return -1;
+
+ return 0;
+}

Back to the top