summaryrefslogtreecommitdiffstats
path: root/gtk2
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2')
-rw-r--r--gtk2/CMakeLists.txt46
-rw-r--r--gtk2/kgtk2.c258
2 files changed, 158 insertions, 146 deletions
diff --git a/gtk2/CMakeLists.txt b/gtk2/CMakeLists.txt
index 36b3e3f..f043953 100644
--- a/gtk2/CMakeLists.txt
+++ b/gtk2/CMakeLists.txt
@@ -1,22 +1,36 @@
-include(FindPkgConfig)
-pkg_check_modules(GTK gtk+-2.0>=2.6)
+include_directories(
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/common
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${GTK_INCLUDE_DIRS}
+)
-if (GTK_FOUND)
- message("** INFORMATION: Gtk2 LD_PRELOAD library will be built.")
+link_directories(
+ ${GTK_LIBRARY_DIRS}
+)
- # set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
- set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)
+##### kgtk2 (shared)
- include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/common ${CMAKE_BINARY_DIR} ${GTK_INCLUDE_DIRS})
- set(kgtk2_SRCS kgtk2.c)
- add_library(kgtk2 SHARED ${kgtk2_SRCS})
- target_link_libraries(kgtk2 ${GTK_LDFLAGS} -lgthread-2.0 -lglib-2.0 -lc -ldl)
+tde_add_library( kgtk2 SHARED NO_LIBTOOL_FILE
+ SOURCES
+ kgtk2.c
- install(TARGETS kgtk2 LIBRARY DESTINATION ${LIB_INSTALL_DIR}/kgtk )
+ LINK
+ ${GTK_LIBRARIES}
+ ${GTHREAD_LIBRARIES}
+ ${CMAKE_DL_LIBS}
- configure_file (kgtk2-wrapper.cmake ${CMAKE_CURRENT_BINARY_DIR}/kgtk2-wrapper @ONLY)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/kgtk2-wrapper DESTINATION bin)
-else (GTK_FOUND)
- message("** ERROR : Could not locate Gtk2 headers, Gtk2 LD_PRELOAD library will not be built.")
-endif (GTK_FOUND)
+ DESTINATION ${LIB_INSTALL_DIR}/kgtk
+)
+
+
+##### other data
+
+configure_file( kgtk2-wrapper.cmake kgtk2-wrapper @ONLY )
+
+install(
+ PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/kgtk2-wrapper
+ DESTINATION ${BIN_INSTALL_DIR}
+)
diff --git a/gtk2/kgtk2.c b/gtk2/kgtk2.c
index 77d690b..182ed6c 100644
--- a/gtk2/kgtk2.c
+++ b/gtk2/kgtk2.c
@@ -66,10 +66,8 @@ TODO
#include <stdarg.h>
#include "connect.h"
#include "config.h"
-
-#ifndef KGTK_DLSYM_VERSION
-#define KGTK_DLSYM_VERSION "GLIBC_2.0"
-#endif
+#include "ctype.h"
+#include "stdbool.h"
#define BLACKLIST_UNKNOWN_GTK_APPS 0
@@ -78,15 +76,12 @@ TODO
*/
/*
- * For SWT apps (e.g. eclipse) we need to override dlsym, but we can only do this if
- * dlvsym is present in libdl. dlvsym is needed so that we can access the real dlsym
- * as well as our fake dlsym
+ * For SWT apps (e.g. eclipse) we need to override dlsym.
*/
-#ifdef HAVE_DLVSYM
-static void * real_dlsym (void *handle, const char *name);
-#else
-#define real_dlsym(A, B) dlsym(A, B)
+#ifdef HAVE_DL_SYM
+extern void *_dl_sym(void *, const char *, void *);
#endif
+static void * real_dlsym (void *handle, const char *name);
typedef enum
{
@@ -194,7 +189,7 @@ typedef struct
static gpointer kdialogdMain(gpointer data)
{
- KGtkData *d=(struct KGtkData *)data;
+ KGtkData *d=(KGtkData*)data;
char buffer[MAX_DATA_LEN+1]={'\0'};
int num=0;
@@ -254,7 +249,7 @@ static gboolean sendMessage(GtkWidget *widget, Operation op, GSList **res, gchar
#ifdef KGTK_DEBUG
printf("KGTK::Dialog has a parent!\n");
#endif
- xid=GDK_WINDOW_XID(gtk_widget_get_toplevel(widget->parent));
+ xid=GDK_WINDOW_XID(gtk_widget_get_toplevel(widget->parent)->window);
}
/*
@@ -290,6 +285,7 @@ static gboolean sendMessage(GtkWidget *widget, Operation op, GSList **res, gchar
GtkWidget *w=node->data;
if(w && GTK_IS_WIDGET(w) && w->window)
+ {
if(gtk_window_has_toplevel_focus(GTK_WINDOW(w)) &&
gtk_window_is_active(GTK_WINDOW(w)))
{
@@ -303,7 +299,10 @@ static gboolean sendMessage(GtkWidget *widget, Operation op, GSList **res, gchar
break;
}
else
- prevX=GDK_WINDOW_XID(w->window);
+ {
+ prevX=GDK_WINDOW_XID(w->window);
+ }
+ }
}
g_list_free(topWindows);
}
@@ -311,9 +310,9 @@ static gboolean sendMessage(GtkWidget *widget, Operation op, GSList **res, gchar
if(writeBlock(kdialogdSocket, &o, 1) &&
writeBlock(kdialogdSocket, (char *)&xid, 4) &&
writeString(title) &&
- (p1 ? writeString(p1) : TRUE) &&
- (p2 ? writeString(p2) : TRUE) &&
- (OP_FILE_SAVE==op ? writeBool(overWrite) : TRUE))
+ (p1 ? writeString(p1) : true) &&
+ (p2 ? writeString(p2) : true) &&
+ (OP_FILE_SAVE==op ? writeBool(overWrite) : true))
{
GtkWidget *dlg=gtk_dialog_new();
KGtkData d;
@@ -338,7 +337,7 @@ static gboolean sendMessage(GtkWidget *widget, Operation op, GSList **res, gchar
gtk_window_set_skip_pager_hint(GTK_WINDOW(dlg), TRUE);
kdialogdLoop = g_main_loop_new (NULL, FALSE);
kdialogdError=FALSE;
- g_thread_create(&kdialogdMain, &d, FALSE, NULL);
+ g_thread_new(NULL, &kdialogdMain, &d);
GDK_THREADS_LEAVE();
g_main_loop_run(kdialogdLoop);
@@ -463,7 +462,7 @@ static gboolean isMozApp(const char *app, const char *check)
/* OK check for xulrunner-1.9 */
{
double dummy;
- if(app_len>(check_len+1) && 1==sscanf(&app[check_len+1], "%f", &dummy))
+ if(app_len>(check_len+1) && 1==sscanf(&app[check_len+1], "%lf", &dummy))
return TRUE;
}
}
@@ -544,8 +543,6 @@ static gboolean kgtkInit(const char *appName)
{
determineAppName();
if (((kgtkApp != APP_UNKNOWN) || (!BLACKLIST_UNKNOWN_GTK_APPS)) && (kgtkApp != APP_BLACKLISTED)) {
- if(!g_threads_got_initialized)
- g_thread_init(NULL);
atexit(&kgtkExit);
}
}
@@ -702,12 +699,12 @@ kgtk_dialog_add_buttons_valist ( GtkDialog *dialog,
gboolean gtk_init_check(int *argc, char ***argv)
{
- static void * (*realFunction)() = NULL;
+ static gboolean (*realFunction)(int*, char***) = NULL;
gboolean rv=FALSE;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_init_check");
+ realFunction = (gboolean (*)(int*, char***)) real_dlsym(RTLD_NEXT, "gtk_init_check");
rv=realFunction(argc, argv);
#ifdef KGTK_DEBUG
@@ -720,10 +717,10 @@ gboolean gtk_init_check(int *argc, char ***argv)
void gtk_init(int *argc, char ***argv)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(int*, char***) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_init");
+ realFunction = (void *(*)(int*, char***)) real_dlsym(RTLD_NEXT, "gtk_init");
realFunction(argc, argv);
#ifdef KGTK_DEBUG
@@ -1124,10 +1121,10 @@ static GSList * addProtocols(GSList *files)
void gtk_window_present(GtkWindow *window)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkWindow*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_window_present");
+ realFunction = (void *(*)(GtkWindow*)) real_dlsym(RTLD_NEXT, "gtk_window_present");
#ifdef KGTK_DEBUG
printf("KGTK::gtk_window_present %s %d\n", gtk_type_name(GTK_WIDGET_TYPE(window)),
@@ -1142,10 +1139,10 @@ void gtk_window_present(GtkWindow *window)
void gtk_widget_show(GtkWidget *widget)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkWidget*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_widget_show");
+ realFunction = (void *(*)(GtkWidget*)) real_dlsym(RTLD_NEXT, "gtk_widget_show");
if(widget && !GTK_IS_FILE_CHOOSER_BUTTON(widget) && GTK_IS_FILE_CHOOSER(widget))
{
@@ -1162,13 +1159,13 @@ void gtk_widget_show(GtkWidget *widget)
void gtk_widget_hide(GtkWidget *widget)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkWidget*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_widget_hide");
+ realFunction = (void *(*)(GtkWidget*)) real_dlsym(RTLD_NEXT, "gtk_widget_hide");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_widget_hide Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1191,12 +1188,12 @@ void gtk_widget_hide(GtkWidget *widget)
gboolean gtk_file_chooser_get_do_overwrite_confirmation(GtkFileChooser *widget)
{
- static void * (*realFunction)() = NULL;
+ static gboolean (*realFunction)(GtkFileChooser*) = NULL;
gboolean rv=FALSE;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_do_overwrite_confirmation");
+ realFunction = (gboolean (*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_do_overwrite_confirmation");
if(realFunction)
{
@@ -1207,12 +1204,12 @@ gboolean gtk_file_chooser_get_do_overwrite_confirmation(GtkFileChooser *widget)
if(!data->setOverWrite)
{
data->setOverWrite=TRUE;
- data->doOverwrite=(gboolean) realFunction(widget);
+ data->doOverwrite=realFunction(widget);
}
rv=data->doOverwrite;
}
else
- rv=(gboolean) realFunction(widget);
+ rv=realFunction(widget);
}
return rv;
@@ -1221,10 +1218,10 @@ gboolean gtk_file_chooser_get_do_overwrite_confirmation(GtkFileChooser *widget)
/* ext => called from app, not kgtk */
void kgtkFileChooserSetDoOverwriteConfirmation(GtkFileChooser *widget, gboolean v, gboolean ext)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*, gboolean) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_do_overwrite_confirmation");
+ realFunction = (void *(*)(GtkFileChooser*, gboolean)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_do_overwrite_confirmation");
if(realFunction)
{
@@ -1255,16 +1252,16 @@ int gtk_combo_box_get_active(GtkComboBox *combo)
{
int rv=0;
- if(APP_KINO==kgtkApp && isOnFileChooser(combo))
+ if(APP_KINO==kgtkApp && isOnFileChooser((GtkWidget*)combo))
return 1;
else
{
- static void * (*realFunction)() = NULL;
+ static gint (*realFunction)(GtkComboBox*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_combo_box_get_active");
+ realFunction = (gint (*)(GtkComboBox*)) real_dlsym(RTLD_NEXT, "gtk_combo_box_get_active");
- rv=(int)realFunction(combo);
+ rv=realFunction(combo);
}
return rv;
@@ -1272,13 +1269,13 @@ int gtk_combo_box_get_active(GtkComboBox *combo)
gint gtk_dialog_run(GtkDialog *dialog)
{
- static void * (*realFunction)() = NULL;
+ static gint (*realFunction)(GtkDialog*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_dialog_run");
+ realFunction = (gint (*)(GtkDialog*)) real_dlsym(RTLD_NEXT, "gtk_dialog_run");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_dialog_run Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1436,7 +1433,7 @@ gint gtk_dialog_run(GtkDialog *dialog)
#endif
openKdeDialog(GTK_WIDGET(dialog), title ? title : "",
data->folder ? data->folder : "", NULL,
- OP_FOLDER, &res, NULL, FALSE);
+ OP_FOLDER, &res, NULL, false);
folder=firstEntry(res);
if(folder)
@@ -1475,15 +1472,15 @@ gint gtk_dialog_run(GtkDialog *dialog)
g_signal_emit_by_name(dialog, "response", data->cancel);
return data->cancel;
}
- return realFunction(dialog);
+ return (gint)realFunction(dialog);
}
void gtk_widget_destroy(GtkWidget *widget)
{
- static void * (*realFunction)() = NULL;
+ static void (*realFunction)(GtkWidget*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_widget_destroy");
+ realFunction = (void (*)(GtkWidget*)) real_dlsym(RTLD_NEXT, "gtk_widget_destroy");
if(fileDialogHash && GTK_IS_FILE_CHOOSER(widget))
freeHash(widget);
@@ -1495,13 +1492,13 @@ gchar * gtk_file_chooser_get_filename(GtkFileChooser *chooser)
{
KGtkFileData *data=lookupHash(chooser, FALSE);
- static void * (*realFunction)() = NULL;
+ static gchar * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_filename");
+ realFunction = (gchar *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_filename");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_filename Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1518,13 +1515,13 @@ gchar * gtk_file_chooser_get_filename(GtkFileChooser *chooser)
gboolean gtk_file_chooser_select_filename(GtkFileChooser *chooser, const char *filename)
{
KGtkFileData *data=lookupHash(chooser, TRUE);
- static void * (*realFunction)() = NULL;
+ static gboolean (*realFunction)(GtkFileChooser*, const char*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_select_filename");
+ realFunction = (gboolean (*)(GtkFileChooser*, const char*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_select_filename");
realFunction(chooser, filename);
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
- return;
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
+ return FALSE;
}
#ifdef KGTK_DEBUG
@@ -1545,7 +1542,7 @@ gboolean gtk_file_chooser_select_filename(GtkFileChooser *chooser, const char *f
data->files=g_slist_prepend(data->files, g_strdup(filename));
- if(folder && !data->folder || strcmp(folder, data->folder))
+ if(folder && (!data->folder || strcmp(folder, data->folder)))
{
gtk_file_chooser_set_current_folder(chooser, folder);
g_free(folder);
@@ -1559,12 +1556,12 @@ gboolean gtk_file_chooser_select_filename(GtkFileChooser *chooser, const char *f
void gtk_file_chooser_unselect_all(GtkFileChooser *chooser)
{
KGtkFileData *data=lookupHash(chooser, TRUE);
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_unselect_all");
+ realFunction = (void *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_unselect_all");
realFunction(chooser);
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
return;
}
@@ -1582,13 +1579,13 @@ void gtk_file_chooser_unselect_all(GtkFileChooser *chooser)
gboolean gtk_file_chooser_set_filename(GtkFileChooser *chooser, const char *filename)
{
KGtkFileData *data=lookupHash(chooser, TRUE);
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*, const char*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_filename");
+ realFunction = (void *(*)(GtkFileChooser*, const char*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_filename");
realFunction(chooser, filename);
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
- return;
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
+ return FALSE;
}
#ifdef KGTK_DEBUG
@@ -1628,15 +1625,14 @@ void gtk_file_chooser_set_current_name(GtkFileChooser *chooser, const char *file
GtkFileChooserAction act=gtk_file_chooser_get_action(chooser);
if ((GTK_FILE_CHOOSER_ACTION_SAVE==act || GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER==act) ||
- (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED))
- )
+ ((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED))
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*, const char*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_name");
+ realFunction = (void *(*)(GtkFileChooser*, const char*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_name");
realFunction(chooser, filename);
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
return;
}
}
@@ -1658,13 +1654,13 @@ GSList * gtk_file_chooser_get_filenames(GtkFileChooser *chooser)
KGtkFileData *data=lookupHash(chooser, FALSE);
GSList *rv=NULL;
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_filenames");
+ realFunction = (void *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_filenames");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_filenames Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1696,13 +1692,13 @@ GSList * gtk_file_chooser_get_filenames(GtkFileChooser *chooser)
gboolean gtk_file_chooser_set_current_folder(GtkFileChooser *chooser, const gchar *folder)
{
KGtkFileData *data=lookupHash(chooser, TRUE);
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*, const gchar*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_folder");
+ realFunction = (void *(*)(GtkFileChooser*, const gchar*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_folder");
realFunction(chooser, folder);
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
- return;
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
+ return FALSE;
}
#ifdef KGTK_DEBUG
@@ -1724,13 +1720,13 @@ gchar * gtk_file_chooser_get_current_folder(GtkFileChooser *chooser)
{
KGtkFileData *data=lookupHash(chooser, FALSE);
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_current_folder");
+ realFunction = (void *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_current_folder");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_current_folder Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1752,13 +1748,13 @@ gchar * gtk_file_chooser_get_current_folder(GtkFileChooser *chooser)
gchar * gtk_file_chooser_get_uri(GtkFileChooser *chooser)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_uri");
+ realFunction = (void *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_uri");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_uri Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1783,13 +1779,13 @@ gchar * gtk_file_chooser_get_uri(GtkFileChooser *chooser)
gboolean gtk_file_chooser_set_uri(GtkFileChooser *chooser, const char *uri)
{
- static void * (*realFunction)() = NULL;
+ static gboolean (*realFunction)(GtkFileChooser*, const char *) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_uri");
+ realFunction = (gboolean (*)(GtkFileChooser*, const char *)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_uri");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_set_uri Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1814,13 +1810,13 @@ gboolean gtk_file_chooser_set_uri(GtkFileChooser *chooser, const char *uri)
GSList * gtk_file_chooser_get_uris(GtkFileChooser *chooser)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_uris");
+ realFunction = (void *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_uris");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_uris Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1835,13 +1831,13 @@ GSList * gtk_file_chooser_get_uris(GtkFileChooser *chooser)
gboolean gtk_file_chooser_set_current_folder_uri(GtkFileChooser *chooser, const gchar *uri)
{
- static void * (*realFunction)() = NULL;
+ static gboolean (*realFunction)(GtkFileChooser*, const gchar*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_folder_uri");
+ realFunction = (gboolean (*)(GtkFileChooser*, const gchar*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_set_current_folder_uri");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_set_current_folder_uri Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1865,13 +1861,13 @@ gboolean gtk_file_chooser_set_current_folder_uri(GtkFileChooser *chooser, const
gchar * gtk_file_chooser_get_current_folder_uri(GtkFileChooser *chooser)
{
- static void * (*realFunction)() = NULL;
+ static gchar * (*realFunction)(GtkFileChooser*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_current_folder_uri");
+ realFunction = (gchar *(*)(GtkFileChooser*)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_get_current_folder_uri");
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_get_current_folder_uri Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1897,10 +1893,10 @@ gchar * gtk_file_chooser_get_current_folder_uri(GtkFileChooser *chooser)
void g_signal_stop_emission_by_name(gpointer instance, const gchar *detailed_signal)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(gpointer, const gchar*) = NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "g_signal_stop_emission_by_name");
+ realFunction = (void *(*)(gpointer, const gchar*)) real_dlsym(RTLD_NEXT, "g_signal_stop_emission_by_name");
#ifdef KGTK_DEBUG
printf("KGTK::g_signal_stop_emission_by_name %s %s (check)\n", gtk_type_name(GTK_WIDGET_TYPE(instance)), detailed_signal);
@@ -1916,17 +1912,17 @@ void g_signal_stop_emission_by_name(gpointer instance, const gchar *detailed_sig
GtkWidget * gtk_dialog_add_button(GtkDialog *dialog, const gchar *button_text, gint response_id)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(GtkDialog*, const gchar*, gint) = NULL;
GtkWidget *dlg=NULL;
KGtkFileData *data=NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_dialog_add_button");
+ realFunction = (void *(*)(GtkDialog*, const gchar*, gint)) real_dlsym(RTLD_NEXT, "gtk_dialog_add_button");
dlg = realFunction(dialog, button_text, response_id);
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED) && realFunction) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED) && realFunction) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_dialog_add_button Bypassing internal function\n"); fflush(stdout);
#endif
@@ -1952,6 +1948,8 @@ GtkWidget * gtk_dialog_add_button(GtkDialog *dialog, const gchar *button_text, g
printf("KGTK::gtk_dialog_add_button Overriding data->ok: %d\n", data->ok);
#endif
}
+
+ return NULL;
}
void gtk_dialog_add_buttons(GtkDialog *dialog, const gchar *first_button_text, ...)
@@ -1966,7 +1964,7 @@ void gtk_dialog_add_buttons(GtkDialog *dialog, const gchar *first_button_text, .
va_end(varargs);
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED)) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED)) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_dialog_add_buttons Bypassing internal function\n"); fflush(stdout);
#endif
@@ -2015,7 +2013,7 @@ GtkWidget * gtk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent,
va_end(varargs);
determineAppName();
- if (((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) || (kgtkApp == APP_BLACKLISTED)) {
+ if (((kgtkApp == APP_UNKNOWN && BLACKLIST_UNKNOWN_GTK_APPS) || kgtkApp == APP_BLACKLISTED)) {
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_dialog_new Bypassing internal function\n"); fflush(stdout);
#endif
@@ -2057,7 +2055,7 @@ static void handleGtkFileChooserButtonClicked(GtkButton *button, gpointer user_d
#ifdef KGTK_DEBUG
printf("KGTK::handleGtkFileChooserButtonClicked\n");
#endif
- gtk_dialog_run(GTK_FILE_CHOOSER_BUTTON(user_data)->priv->dialog);
+ gtk_dialog_run((GtkDialog*)GTK_FILE_CHOOSER_BUTTON(user_data)->priv->dialog);
}
static void handleGtkFileChooserComboChanged(GtkComboBox *combo_box, gpointer user_data)
@@ -2079,7 +2077,7 @@ static void handleGtkFileChooserComboChanged(GtkComboBox *combo_box, gpointer us
gtk_tree_model_get(priv->filter_model, &iter, TYPE_COLUMN, &type, -1);
if(ROW_TYPE_OTHER==type)
- gtk_dialog_run(GTK_FILE_CHOOSER_BUTTON(user_data)->priv->dialog);
+ gtk_dialog_run((GtkDialog*)GTK_FILE_CHOOSER_BUTTON(user_data)->priv->dialog);
else
{
g_signal_handler_unblock(priv->combo_box, priv->combo_box_changed_id);
@@ -2093,12 +2091,12 @@ static void handleGtkFileChooserComboChanged(GtkComboBox *combo_box, gpointer us
GtkWidget * gtk_file_chooser_button_new(const gchar *title, GtkFileChooserAction action)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(const gchar*, GtkFileChooserAction) = NULL;
GtkWidget *button=NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "gtk_file_chooser_button_new");
+ realFunction = (void *(*)(const gchar*, GtkFileChooserAction)) real_dlsym(RTLD_NEXT, "gtk_file_chooser_button_new");
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_button_new\n");
@@ -2108,7 +2106,7 @@ GtkWidget * gtk_file_chooser_button_new(const gchar *title, GtkFileChooserAction
{
GtkFileChooserButtonPrivate *priv=NULL;
- button=realFunction(title, action);
+ button=(GtkWidget*)realFunction(title, action);
priv=GTK_FILE_CHOOSER_BUTTON(button)->priv;
if(priv->button)
@@ -2210,12 +2208,12 @@ const gchar * kgtk_g_module_check_init(GModule *module)
/* Mozilla specific */
void * PR_FindFunctionSymbol(struct PR_LoadLibrary *lib, const char *raw_name)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(struct PR_LoadLibrary*, const char*) = NULL;
void *rv=NULL;
if(!realFunction)
- realFunction = (void *(*)()) real_dlsym(RTLD_NEXT, "PR_FindFunctionSymbol");
+ realFunction = (void *(*)(struct PR_LoadLibrary*, const char*)) real_dlsym(RTLD_NEXT, "PR_FindFunctionSymbol");
#ifdef KGTK_DEBUG_DLSYM
printf("KGTK::PR_FindFunctionSymbol : %s\n", raw_name);
@@ -2241,41 +2239,42 @@ void * PR_FindFunctionSymbol(struct PR_LoadLibrary *lib, const char *raw_name)
return NULL;
}
-#ifdef HAVE_DLVSYM
/* Overriding dlsym is required for SWT - which dlsym's the gtk_file_chooser functions! */
static void * real_dlsym(void *handle, const char *name)
{
- static void * (*realFunction)() = NULL;
+ static void * (*realFunction)(void*, const char*) = NULL;
#ifdef KGTK_DEBUG_DLSYM
- printf("KGTK::real_dlsym : %s\n", name);
+ printf("KGTK::real_dlsym : %s\n", name);
#endif
- if (!realFunction)
- {
- void *ldHandle=dlopen("libdl.so", RTLD_NOW);
-
-#ifdef KGTK_DEBUG_DLSYM
- printf("KGTK::real_dlsym : %s\n", name);
+ if (!realFunction)
+ {
+ // Get the real dlsym function
+#ifdef HAVE_DL_SYM
+ realFunction = _dl_sym(RTLD_NEXT, "dlsym", dlsym);
+#else
+ realFunction = dlvsym(RTLD_NEXT, "dlsym", "GLIBC_2.2.5");
#endif
+ }
- if(ldHandle)
- {
- static const char * versions[]={KGTK_DLSYM_VERSION, "GLIBC_2.3", "GLIBC_2.2.5",
- "GLIBC_2.2", "GLIBC_2.1", "GLIBC_2.0", NULL};
-
- int i;
-
- for(i=0; versions[i] && !realFunction; ++i)
- realFunction=dlvsym(ldHandle, "dlsym", versions[i]);
- }
- }
-
+ if (realFunction)
return realFunction(handle, name);
+ else
+ {
+ printf("kgtk-qt3 gtk2 real_dlsymc() realFunction not found!!\n");
+ return NULL;
+ }
}
void * dlsym(void *handle, const char *name)
{
+ // Need this so _dl_sym will be able to find the next dlsym, i.e. the real dlsym!
+ if (!strcmp(name, "dlsym"))
+ {
+ return (void*)dlsym;
+ }
+
void *rv=NULL;
#ifdef KGTK_DEBUG_DLSYM
@@ -2294,4 +2293,3 @@ void * dlsym(void *handle, const char *name)
#endif
return rv;
}
-#endif