aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2012-11-06 11:11:50 (EST)
committerSilenio Quarti2012-11-06 11:11:50 (EST)
commit1e214f1a2d19d10444072387f37ac81226a5c613 (patch)
tree053c3a429a0c59d74d9a183f3cb6c055ee61e15f
parent7d9580eb4c4448d1ac54e4ecb3ce952b76840489 (diff)
downloadrt.equinox.framework-1e214f1a2d19d10444072387f37ac81226a5c613.zip
rt.equinox.framework-1e214f1a2d19d10444072387f37ac81226a5c613.tar.gz
rt.equinox.framework-1e214f1a2d19d10444072387f37ac81226a5c613.tar.bz2
Bug 393681 - Port to GTK+ 3
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c55
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.h32
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkCommon.c2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkInit.c133
-rw-r--r--bundles/org.eclipse.equinox.executable/library/gtk/make_linux.mak2
5 files changed, 94 insertions, 130 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
index af75837..6ec48e7 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.c
@@ -50,8 +50,6 @@ static char* argVM_JAVA[] = { NULL };
/* Define local variables . */
static long splashHandle = 0;
static GtkWidget* shellHandle = 0;
-static GdkPixbuf* pixbuf = 0;
-static GtkWidget* image = 0;
static sem_t* mutex;
static Atom appWindowAtom, launcherWindowAtom;
@@ -115,10 +113,6 @@ int executeWithLock(char *name, LockFunc func) {
return result;
}
-static void log_handler(const gchar* domain, GLogLevelFlags flags, const gchar* msg, gpointer data) {
- /* nothing */
-}
-
/* Create a "SWT_Window_" + APP_NAME string with optional suffix.
* Caller should free the memory when finished */
static char * createSWTWindowString(char * suffix, int semaphore) {
@@ -235,10 +229,8 @@ int reuseWorkbench(_TCHAR** filePath, int timeout) {
/* Create and Display the Splash Window */
int showSplash( const char* featureImage )
{
- GtkAdjustment* vadj, *hadj;
- int width, height;
- guint handlerId;
- GtkWidget* vboxHandle, * scrolledHandle, * handle;
+ GtkWidget *image;
+ GdkPixbuf *pixbuf;
if (splashHandle != 0)
return 0; /* already showing splash */
@@ -253,44 +245,19 @@ int showSplash( const char* featureImage )
shellHandle = gtk.gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk.gtk_window_set_decorated((GtkWindow*)(shellHandle), FALSE);
- gtk.gtk_signal_connect((GtkObject*)shellHandle, "destroy", (GtkSignalFunc)(gtk.gtk_widget_destroyed), &shellHandle);
- vboxHandle = gtk.gtk_vbox_new(FALSE, 0);
- if(vboxHandle == 0)
- return -1;
+ gtk.g_signal_connect_data((gpointer)shellHandle, "destroy", (GtkSignalFunc)(gtk.gtk_widget_destroyed), &shellHandle, NULL, 0);
- vadj = (GtkAdjustment*)gtk.gtk_adjustment_new(0, 0, 100, 1, 10, 10);
- hadj = (GtkAdjustment*)gtk.gtk_adjustment_new(0, 0, 100, 1, 10, 10);
- if (vadj == 0 || hadj == 0)
- return -1;
-
- scrolledHandle = gtk.gtk_scrolled_window_new(hadj, vadj);
-
- gtk.gtk_container_add((GtkContainer*)(vboxHandle), scrolledHandle);
- gtk.gtk_box_set_child_packing((GtkBox*)(vboxHandle), scrolledHandle, TRUE, TRUE, 0, GTK_PACK_END);
- gtk.gtk_scrolled_window_set_policy((GtkScrolledWindow*)(scrolledHandle), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
-
- handle = gtk.gtk_fixed_new();
- gtk.gtk_fixed_set_has_window((GtkFixed*)(handle), TRUE);
- ((GtkObject*)handle)->flags |= GTK_CAN_FOCUS; /*GTK_WIDGET_SET_FLAGS(handle, GTK_CAN_FOCUS);*/
-
- /* avoid gtk_scrolled_window_add warning */
- handlerId = gtk.g_log_set_handler("Gtk", G_LOG_LEVEL_WARNING, &log_handler, NULL);
- gtk.gtk_container_add((GtkContainer*)(scrolledHandle), handle);
- gtk.g_log_remove_handler("Gtk", handlerId);
-
- gtk.gtk_container_add((GtkContainer*)(shellHandle), vboxHandle);
-
pixbuf = gtk.gdk_pixbuf_new_from_file(featureImage, NULL);
image = gtk.gtk_image_new_from_pixbuf(pixbuf);
- gtk.gtk_signal_connect((GtkObject*)(image), "destroy", (GtkSignalFunc)(gtk.gtk_widget_destroyed), &image);
- gtk.gtk_container_add((GtkContainer*)(handle), image);
+ if (pixbuf) {
+ gtk.g_object_unref(pixbuf);
+ }
+ gtk.gtk_container_add((GtkContainer*)(shellHandle), image);
- width = gtk.gdk_pixbuf_get_width(pixbuf);
- height = gtk.gdk_pixbuf_get_height(pixbuf);
- gtk.gtk_window_set_position((GtkWindow*)(shellHandle), GTK_WIN_POS_CENTER);
if (getOfficialName() != NULL)
gtk.gtk_window_set_title((GtkWindow*)(shellHandle), getOfficialName());
- gtk.gtk_window_resize((GtkWindow*)(shellHandle), width, height);
+ gtk.gtk_window_set_position((GtkWindow*)(shellHandle), GTK_WIN_POS_CENTER);
+ gtk.gtk_window_resize((GtkWindow*)(shellHandle), gtk.gdk_pixbuf_get_width(pixbuf), gtk.gdk_pixbuf_get_height(pixbuf));
gtk.gtk_widget_show_all((GtkWidget*)(shellHandle));
splashHandle = (long)shellHandle;
dispatchMessages();
@@ -309,10 +276,6 @@ jlong getSplashHandle() {
void takeDownSplash() {
if(shellHandle != 0) {
gtk.gtk_widget_destroy(shellHandle);
- if (image != NULL) {
- gtk.gtk_widget_destroy(image);
- gtk.g_object_unref(pixbuf);
- }
dispatchMessages();
splashHandle = 0;
shellHandle = NULL;
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.h b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.h
index 05af207..503c9a5 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.h
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtk.h
@@ -16,22 +16,14 @@
#include <gdk/gdkx.h>
struct GTK_PTRS {
- short not_initialized;
- GtkObject* (*gtk_adjustment_new) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble);
- void (*gtk_box_set_child_packing)(GtkBox*, GtkWidget*, gboolean, gboolean, guint, GtkPackType);
+ short not_initialized;
void (*gtk_container_add) (GtkContainer*, GtkWidget*);
gint (*gtk_dialog_run) (GtkDialog *);
- GtkWidget* (*gtk_fixed_new) ();
- void (*gtk_fixed_set_has_window) (GtkFixed *, gboolean);
GtkWidget* (*gtk_image_new_from_pixbuf)(GdkPixbuf*);
gboolean (*gtk_init_check) (int*, char***);
gboolean (*gtk_init_with_args) (int*, char***, const char *, void *, const char *, GError **);
GtkWidget* (*gtk_message_dialog_new) (GtkWindow*, GtkDialogFlags, GtkMessageType, GtkButtonsType, const gchar*, ...);
- void (*gtk_scrolled_window_set_policy)(GtkScrolledWindow*, GtkPolicyType, GtkPolicyType);
- GtkWidget* (*gtk_scrolled_window_new) (GtkAdjustment*, GtkAdjustment*);
gchar* (*gtk_set_locale) ();
- gulong (*gtk_signal_connect_full) (GtkObject*, const gchar*, GtkSignalFunc, GtkCallbackMarshal, gpointer, GtkDestroyNotify, gint, gint);
- GtkWidget* (*gtk_vbox_new) (gboolean, gint);
void (*gtk_widget_destroy) (GtkWidget*);
void (*gtk_widget_destroyed) (GtkWidget*, GtkWidget**);
void (*gtk_widget_show_all) (GtkWidget*);
@@ -40,8 +32,8 @@ struct GTK_PTRS {
void (*gtk_window_set_title) (GtkWindow*, const gchar*);
void (*gtk_window_set_decorated) (GtkWindow*, gboolean);
void (*gtk_window_set_position) (GtkWindow*, GtkWindowPosition);
- guint (*g_log_set_handler) (const gchar*, GLogLevelFlags, GLogFunc, gpointer);
- void (*g_log_remove_handler) (const gchar*, guint);
+
+ gulong (*g_signal_connect_data) (gpointer, const gchar*, GCallback, gpointer, GClosureNotify, GConnectFlags);
gboolean (*g_main_context_iteration) (GMainContext*, gboolean);
void (*g_object_unref) (gpointer);
GObject* (*g_object_new) (GType, const gchar*, ...);
@@ -52,10 +44,12 @@ struct GTK_PTRS {
GString* (*g_string_insert_c) (GString *, gssize, gchar);
#endif
- GdkPixbuf* (*gdk_pixbuf_new_from_file) (const char*, GError **);
- int (*gdk_pixbuf_get_width) (const GdkPixbuf*);
- int (*gdk_pixbuf_get_height) (const GdkPixbuf*);
- void (*gdk_set_program_class) (const char*);
+ GdkDisplay* (*gdk_display_get_default) ();
+ Display* (*gdk_x11_display_get_xdisplay) (GdkDisplay*);
+ GdkPixbuf* (*gdk_pixbuf_new_from_file) (const char*, GError **);
+ int (*gdk_pixbuf_get_width) (const GdkPixbuf*);
+ int (*gdk_pixbuf_get_height) (const GdkPixbuf*);
+ void (*gdk_set_program_class) (const char*);
Window (*XGetSelectionOwner) (Display*, Atom);
void (*XSetSelectionOwner) (Display*, Atom, Window, Time);
@@ -64,17 +58,17 @@ struct GTK_PTRS {
void (*XSync) (Display*, Bool);
int (*XDefaultScreen) (Display*);
Window (*XRootWindow) (Display*, int);
- Atom (*XInternAtom) (Display*, _Xconst char*, Bool );
- Display **gdk_display;
+ Atom (*XInternAtom) (Display*, _Xconst char*, Bool );
};
-#define gtk_GDK_DISPLAY *(gtk.gdk_display)
+#define gtk_GDK_DISPLAY gtk.gdk_x11_display_get_xdisplay(gtk.gdk_display_get_default())
extern struct GTK_PTRS gtk;
-#define FN_TABLE_ENTRY(fn) { (void**)& gtk.fn, #fn }
+#define FN_TABLE_ENTRY(fn, required) { (void**)& gtk.fn, #fn, required }
typedef struct {
void ** fnPtr;
char * fnName;
+ int required;
} FN_TABLE;
/* load the gtk libraries and initialize the function pointers */
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkCommon.c b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkCommon.c
index ebae2b8..b30327e 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkCommon.c
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkCommon.c
@@ -90,7 +90,7 @@ int initWindowSystem(int* pArgc, char* argv[], int showSplash)
}
/* Initialize GTK. */
- gtk.gtk_set_locale();
+ if (gtk.gtk_set_locale) gtk.gtk_set_locale();
if (gtk.gtk_init_with_args) {
GError *error = NULL;
if (!gtk.gtk_init_with_args(pArgc, &argv, NULL, NULL, NULL, &error)) {
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkInit.c b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkInit.c
index 8d0843f..eb0124b 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkInit.c
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/eclipseGtkInit.c
@@ -13,71 +13,69 @@
#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 */
-static FN_TABLE gtkFunctions[] = { FN_TABLE_ENTRY(gtk_adjustment_new),
- FN_TABLE_ENTRY(gtk_box_set_child_packing),
- FN_TABLE_ENTRY(gtk_container_add),
- FN_TABLE_ENTRY(gtk_dialog_run),
- FN_TABLE_ENTRY(gtk_fixed_new),
- FN_TABLE_ENTRY(gtk_fixed_set_has_window),
- FN_TABLE_ENTRY(gtk_image_new_from_pixbuf),
- FN_TABLE_ENTRY(gtk_init_check),
- FN_TABLE_ENTRY(gtk_init_with_args),
- FN_TABLE_ENTRY(gtk_message_dialog_new),
- FN_TABLE_ENTRY(gtk_scrolled_window_set_policy),
- FN_TABLE_ENTRY(gtk_scrolled_window_new),
- FN_TABLE_ENTRY(gtk_set_locale),
- FN_TABLE_ENTRY(gtk_signal_connect_full),
- FN_TABLE_ENTRY(gtk_vbox_new),
- FN_TABLE_ENTRY(gtk_widget_destroy),
- FN_TABLE_ENTRY(gtk_widget_destroyed),
- FN_TABLE_ENTRY(gtk_widget_show_all),
- FN_TABLE_ENTRY(gtk_window_new),
- FN_TABLE_ENTRY(gtk_window_resize),
- FN_TABLE_ENTRY(gtk_window_set_title),
- FN_TABLE_ENTRY(gtk_window_set_decorated),
- FN_TABLE_ENTRY(gtk_window_set_position),
- { NULL, NULL }
- };
-/* functions from libgdk-x11-2.0 */
-static FN_TABLE gdkFunctions[] = { FN_TABLE_ENTRY(gdk_set_program_class),
- FN_TABLE_ENTRY(gdk_display), /* not a function */
- { NULL, NULL }
- };
+/* 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),
- FN_TABLE_ENTRY(gdk_pixbuf_get_width),
- FN_TABLE_ENTRY(gdk_pixbuf_get_height),
- { NULL, NULL }
- };
+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_log_set_handler),
- FN_TABLE_ENTRY(g_log_remove_handler),
- FN_TABLE_ENTRY(g_main_context_iteration),
- FN_TABLE_ENTRY(g_object_unref),
- FN_TABLE_ENTRY(g_timeout_add),
- FN_TABLE_ENTRY(g_error_free),
+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),
+ FN_TABLE_ENTRY(g_string_insert_c, 1),
#endif
- { NULL, NULL }
- };
+ { NULL, NULL }
+};
/* functions from libX11 */
-static FN_TABLE x11Functions[] = { FN_TABLE_ENTRY(XGetSelectionOwner),
- FN_TABLE_ENTRY(XSetSelectionOwner),
- FN_TABLE_ENTRY(XCreateWindow),
- FN_TABLE_ENTRY(XChangeProperty),
- FN_TABLE_ENTRY(XSync),
- FN_TABLE_ENTRY(XRootWindow),
- FN_TABLE_ENTRY(XDefaultScreen),
- FN_TABLE_ENTRY(XInternAtom),
- { NULL, NULL }
- };
+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) {
@@ -85,10 +83,11 @@ static int loadGtkSymbols( void * library, FN_TABLE * table) {
void * fn;
for (i = 0; table[i].fnName != NULL; i++) {
fn = findSymbol(library, table[i].fnName);
- if (fn != 0)
+ if (fn != 0) {
*(table[i].fnPtr) = fn;
- else
- return -1;
+ } else {
+ if (table[i].required) return -1;
+ }
}
return 0;
}
@@ -100,11 +99,19 @@ int loadGtk() {
#define DLFLAGS RTLD_LAZY
#endif
- void * objLib = dlopen(GOBJ_LIB, DLFLAGS);
- void * gdkLib = dlopen(GDK_LIB, DLFLAGS);
- void * pixLib = dlopen(PIXBUF_LIB, DLFLAGS);
- void * gtkLib = dlopen(GTK_LIB, DLFLAGS);
- void * x11Lib = dlopen(X11_LIB, DLFLAGS);
+ void *gdkLib = NULL, *gtkLib = NULL, *objLib = NULL, *pixLib = NULL, *x11Lib = NULL;
+
+ if (getenv("org.eclipse.swt.gtk3")) {
+ gdkLib = dlopen(GDK3_LIB, DLFLAGS);
+ gtkLib = dlopen(GTK3_LIB, DLFLAGS);
+ }
+ if (!gdkLib || !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));
diff --git a/bundles/org.eclipse.equinox.executable/library/gtk/make_linux.mak b/bundles/org.eclipse.equinox.executable/library/gtk/make_linux.mak
index 9c64a31..dda745b 100644
--- a/bundles/org.eclipse.equinox.executable/library/gtk/make_linux.mak
+++ b/bundles/org.eclipse.equinox.executable/library/gtk/make_linux.mak
@@ -43,7 +43,7 @@ EXEC = $(PROGRAM_OUTPUT)
DLL = $(PROGRAM_LIBRARY)
#LIBS = `pkg-config --libs-only-L gtk+-2.0` -lgtk-x11-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lgdk-x11-2.0 -lpthread -ldl -lX11
LIBS = -lpthread -ldl
-GTK_LIBS = -DGTK_LIB="\"libgtk-x11-2.0.so.0\"" -DGDK_LIB="\"libgdk-x11-2.0.so.0\"" -DPIXBUF_LIB="\"libgdk_pixbuf-2.0.so.0\"" -DGOBJ_LIB="\"libgobject-2.0.so.0\"" -DX11_LIB="\"libX11.so.6\""
+GTK_LIBS = -DGTK_LIB="\"libgtk-x11-2.0.so.0\"" -DGDK_LIB="\"libgdk-x11-2.0.so.0\"" -DGTK3_LIB="\"libgtk-3.so.0\"" -DGDK3_LIB="\"libgdk-3.so.0\"" -DPIXBUF_LIB="\"libgdk_pixbuf-2.0.so.0\"" -DGOBJ_LIB="\"libgobject-2.0.so.0\"" -DX11_LIB="\"libX11.so.6\""
LFLAGS = ${M_ARCH} -shared -fpic -Wl,--export-dynamic
CFLAGS = ${M_ARCH} -g -s -Wall\
-fpic \