summaryrefslogtreecommitdiffstats
path: root/gtk2/kgtk2.c
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-10 01:41:14 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-10 01:41:14 +0000
commitf3cecf25bba7ac38a7aef8dc4dda75f97a199b9f (patch)
treea96781e61297c48f92e1a45f4eefce4bdcbeefcd /gtk2/kgtk2.c
parentb07b4efa606017a8fb9ff922e8463abd0ed08ec6 (diff)
downloadkgtk-qt3-f3cecf25bba7ac38a7aef8dc4dda75f97a199b9f.tar.gz
kgtk-qt3-f3cecf25bba7ac38a7aef8dc4dda75f97a199b9f.zip
Fix kgtk dialogs with GTK applications that add buttons via gtk_dialog_add_buttons after the dialog is created
This includes geany and possibly later Firefox versions git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kgtk-qt3@1258109 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'gtk2/kgtk2.c')
-rw-r--r--gtk2/kgtk2.c95
1 files changed, 85 insertions, 10 deletions
diff --git a/gtk2/kgtk2.c b/gtk2/kgtk2.c
index e76aba6..933d4db 100644
--- a/gtk2/kgtk2.c
+++ b/gtk2/kgtk2.c
@@ -71,7 +71,7 @@ TODO
#define KGTK_DLSYM_VERSION "GLIBC_2.0"
#endif
-#define BLACKLIST_UNKNOWN_GTK_APPS 1
+#define BLACKLIST_UNKNOWN_GTK_APPS 0
/*
#define KGTK_DEBUG_DLSYM
@@ -672,6 +672,22 @@ kgtk_file_chooser_dialog_new_valist (const gchar *title,
return result;
}
+
+void
+kgtk_dialog_add_buttons_valist ( GtkDialog *dialog,
+ const gchar *first_button_text,
+ va_list varargs)
+{
+ const char *button_text = first_button_text;
+ gint response_id;
+
+ while (button_text)
+ {
+ response_id = va_arg (varargs, gint);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
+ button_text = va_arg (varargs, const gchar *);
+ }
+}
/* ......................... */
gboolean gtk_init_check(int *argc, char ***argv)
@@ -1437,6 +1453,7 @@ gint gtk_dialog_run(GtkDialog *dialog)
#ifdef KGTK_DEBUG
printf("KGTK::RETURN RESP:%d\n", resp);
+ printf("OK would be %d; Cancel would be %d\n\r", data->ok, data->cancel);
#endif
g_signal_emit_by_name(dialog, "response", resp);
running=FALSE;
@@ -1626,8 +1643,6 @@ void gtk_file_chooser_set_current_name(GtkFileChooser *chooser, const char *file
}
}
-// [FIXME]
-// This function cannot pick up filenames chosen by a program such as geany
GSList * gtk_file_chooser_get_filenames(GtkFileChooser *chooser)
{
KGtkFileData *data=lookupHash(chooser, FALSE);
@@ -1889,11 +1904,52 @@ void g_signal_stop_emission_by_name(gpointer instance, const gchar *detailed_sig
#endif
}
-// [FIXME]
-// This needs to use the real gtk_file_chooser_dialog_new function when an app is blacklisted,
-// but I don't know how to handle the variable arguments!
-// On the other hand this program seems to work just fine with this function this way...hmmm...
-// ...does anything need to be changed in reality?
+void gtk_dialog_add_buttons(GtkDialog *dialog, const gchar *first_button_text, ...)
+{
+ KGtkFileData *data=NULL;
+ const char *text=first_button_text;
+ gint id;
+ va_list varargs;
+
+ va_start(varargs, first_button_text);
+ kgtk_dialog_add_buttons_valist(dialog, first_button_text, varargs);
+ va_end(varargs);
+
+ determineAppName();
+ if ((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) {
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_dialog_add_buttons Bypassing internal function\n\r"); fflush(stdout);
+#endif
+ return;
+ }
+
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_dialog_add_buttons\n");
+#endif
+ data=lookupHash(dialog, TRUE);
+ va_start(varargs, first_button_text);
+ while(text)
+ {
+ id = va_arg(varargs, gint);
+
+ if(text && (0==strcmp(text, GTK_STOCK_CANCEL) || 0==strcmp(text, GTK_STOCK_CLOSE) ||
+ 0==strcmp(text, GTK_STOCK_QUIT) || 0==strcmp(text, GTK_STOCK_NO))) {
+ data->cancel=id;
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_dialog_add_buttons Overriding data->cancel: %d\n\r", data->cancel);
+#endif
+ }
+ else if(text && (0==strcmp(text, GTK_STOCK_OK) || 0==strcmp(text, GTK_STOCK_OPEN) ||
+ 0==strcmp(text, GTK_STOCK_SAVE) || 0==strcmp(text, GTK_STOCK_YES))) {
+ data->ok=id;
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_dialog_add_buttons Overriding data->ok: %d\n\r", data->ok);
+#endif
+ }
+ text=va_arg(varargs, const gchar *);
+ }
+}
+
GtkWidget * gtk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent,
GtkFileChooserAction action, const gchar *first_button_text,
...)
@@ -1908,6 +1964,14 @@ GtkWidget * gtk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent,
dlg=kgtk_file_chooser_dialog_new_valist(title, parent, action, NULL, first_button_text, varargs);
va_end(varargs);
+ determineAppName();
+ if ((kgtkApp == APP_UNKNOWN) && BLACKLIST_UNKNOWN_GTK_APPS) {
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_file_chooser_dialog_new Bypassing internal function\n\r"); fflush(stdout);
+#endif
+ return dlg;
+ }
+
#ifdef KGTK_DEBUG
printf("KGTK::gtk_file_chooser_dialog_new\n");
#endif
@@ -1918,11 +1982,19 @@ GtkWidget * gtk_file_chooser_dialog_new(const gchar *title, GtkWindow *parent,
id = va_arg(varargs, gint);
if(text && (0==strcmp(text, GTK_STOCK_CANCEL) || 0==strcmp(text, GTK_STOCK_CLOSE) ||
- 0==strcmp(text, GTK_STOCK_QUIT) || 0==strcmp(text, GTK_STOCK_NO)))
+ 0==strcmp(text, GTK_STOCK_QUIT) || 0==strcmp(text, GTK_STOCK_NO))) {
data->cancel=id;
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_file_chooser_dialog_new Overriding data->cancel: %d\n\r", data->cancel);
+#endif
+ }
else if(text && (0==strcmp(text, GTK_STOCK_OK) || 0==strcmp(text, GTK_STOCK_OPEN) ||
- 0==strcmp(text, GTK_STOCK_SAVE) || 0==strcmp(text, GTK_STOCK_YES)))
+ 0==strcmp(text, GTK_STOCK_SAVE) || 0==strcmp(text, GTK_STOCK_YES))) {
data->ok=id;
+#ifdef KGTK_DEBUG
+ printf("KGTK::gtk_file_chooser_dialog_new Overriding data->ok: %d\n\r", data->ok);
+#endif
+ }
text=va_arg(varargs, const gchar *);
}
va_end(varargs);
@@ -2062,6 +2134,9 @@ static void * kgtk_get_fnptr(const char *raw_name)
else if(0==strcmp(raw_name, "gtk_file_chooser_dialog_new"))
return &gtk_file_chooser_dialog_new;
+ else if(0==strcmp(raw_name, "gtk_dialog_add_buttons"))
+ return &gtk_dialog_add_buttons;
+
else if(0==strcmp(raw_name, "gtk_file_chooser_button_new"))
return &gtk_file_chooser_button_new;