changeset 2370:25e7c2a68ed2

[gaim-migrate @ 2383] moving gtk out of perl and sound. i don't know why i'm moving it out of sound though. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 27 Sep 2001 09:20:47 +0000
parents 117e9f0950b6
children db02399a9ad7
files src/dialogs.c src/gaim.h src/perl.c src/sound.c src/util.c
diffstat 5 files changed, 85 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Thu Sep 27 09:02:07 2001 +0000
+++ b/src/dialogs.c	Thu Sep 27 09:20:47 2001 +0000
@@ -4039,3 +4039,74 @@
 
 	gtk_widget_show_all(rename_bud_dialog);
 }
+
+static GtkWidget *perl_config = NULL; 
+static char *perl_last_dir = NULL;
+
+static void cfdes(GtkWidget *m, gpointer n) {
+	if (perl_config) gtk_widget_destroy(perl_config);
+	perl_config = NULL;
+}
+
+static void do_load(GtkWidget *m, gpointer n) {
+	const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(perl_config));
+	gchar *f = NULL;
+	if (!file || !strlen(file)) {
+		return;
+	}
+	
+	if (file_is_dir(file, perl_config)) {
+		return;
+	}
+	
+	if (perl_last_dir) {
+		g_free(perl_last_dir);
+	}
+	perl_last_dir = g_dirname(file);
+
+	debug_printf("Loading perl script: %s\n", file);
+	
+	f = g_strdup(file);
+	perl_load_file(f);
+	g_free(f);
+	cfdes(perl_config, NULL);
+}
+
+void load_perl_script()
+{
+	char *buf, *temp;
+
+	if (perl_config) {
+		gtk_widget_show(perl_config);
+		gdk_window_raise(perl_config->window);
+		return;
+	}
+
+	/* Below is basically stolen from plugins.c */
+	perl_config = gtk_file_selection_new(_("Gaim - Select Perl Script"));
+
+	gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config));
+
+	if (!perl_last_dir) {
+		temp = gaim_user_dir();
+		buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
+		g_free(temp);
+	} else {
+		buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL);
+	}
+
+	gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf);
+	gtk_file_selection_complete(GTK_FILE_SELECTION(perl_config), "*.pl"); 
+	gtk_signal_connect(GTK_OBJECT(perl_config), "destroy",  GTK_SIGNAL_FUNC(cfdes),
+			perl_config);
+
+	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->ok_button),
+			"clicked", GTK_SIGNAL_FUNC(do_load), NULL);
+    
+	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->cancel_button),
+			"clicked", GTK_SIGNAL_FUNC(cfdes), NULL);
+
+	g_free(buf);
+	gtk_widget_show(perl_config);
+	gdk_window_raise(perl_config->window);
+}
--- a/src/gaim.h	Thu Sep 27 09:02:07 2001 +0000
+++ b/src/gaim.h	Thu Sep 27 09:20:47 2001 +0000
@@ -621,7 +621,7 @@
 extern int escape_message(char *msg);
 extern char *tobase64(const char *);
 extern void frombase64(const char *, char **, int *);
-extern gint clean_pid(void *);
+extern gint clean_pid(gpointer);
 extern char *date();
 extern gint linkify_text(char *);
 extern void aol_icon(GdkWindow *);
@@ -796,12 +796,11 @@
 /* Functions in perl.c */
 #ifdef USE_PERL
 extern void perl_autoload();
-extern int perl_load_file(char *);
 extern void perl_end();
 extern int perl_event(char *, char *);
-extern void load_perl_script(GtkWidget *, gpointer);
-extern void unload_perl_scripts(GtkWidget *, gpointer);
-extern void list_perl_scripts(GtkWidget *, gpointer);
+extern int perl_load_file(char *);
+extern void unload_perl_scripts();
+extern void list_perl_scripts();
 #endif
 
 /* Functions in plugins.c */
@@ -886,6 +885,7 @@
 extern void set_color_selection(GtkWidget *selection, GdkColor color);
 extern void show_rename_group(GtkWidget *, struct group *);
 extern void show_rename_buddy(GtkWidget *, struct buddy *);
+extern void load_perl_script();
 
 /* Functions in browser.c */
 extern void open_url(GtkWidget *, char *);
--- a/src/perl.c	Thu Sep 27 09:02:07 2001 +0000
+++ b/src/perl.c	Thu Sep 27 09:20:47 2001 +0000
@@ -48,7 +48,6 @@
 #include <stdio.h>
 #include <dirent.h>
 #include <string.h>
-#include <gtk/gtk.h>
 
 
 /* perl module support */
@@ -82,7 +81,6 @@
 static GList *perl_timeout_handlers = NULL;
 static GList *perl_event_handlers = NULL;
 static PerlInterpreter *my_perl = NULL;
-static char* last_dir = NULL;
 static void perl_init();
 
 /* dealing with gaim */
@@ -257,7 +255,7 @@
 	while (perl_timeout_handlers) {
 		thn = perl_timeout_handlers->data;
 		perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
-		gtk_timeout_remove(thn->iotag);
+		g_source_remove(thn->iotag);
 		g_free(thn->handler_name);
 		g_free(thn);
 	}
@@ -681,8 +679,9 @@
 	XSRETURN_EMPTY;
 }
 
-static int perl_timeout(struct _perl_timeout_handlers *handler)
+static int perl_timeout(gpointer data)
 {
+	struct _perl_timeout_handlers *handler = data;
 	execute_perl(handler->handler_name, "");
 	perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler);
 	g_free(handler->handler_name);
@@ -704,89 +703,17 @@
 	debug_printf("Adding timeout for %d seconds.\n", timeout/1000);
 	handler->handler_name = g_strdup(SvPV(ST(1), junk));
 	perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler);
-	handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler);
+	handler->iotag = g_timeout_add(timeout, perl_timeout, handler);
 	XSRETURN_EMPTY;
 }
 
-static GtkWidget *config = NULL; 
-
-static void cfdes(GtkWidget *m, gpointer n) {
-	if (config) gtk_widget_destroy(config);
-	config = NULL;
-}
-
-static void do_load(GtkWidget *m, gpointer n) {
-	const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(config));
-	gchar *f = NULL;
-	if (!file || !strlen(file)) {
-		perl_end();
-		perl_init();
-		return;
-	}
-	
-	if (file_is_dir(file, config)) {
-		return;
-	}
-	
-	if (last_dir) {
-		g_free(last_dir);
-	}
-	last_dir = g_dirname(file);
-
-	debug_printf("Loading perl script: %s\n", file);
-	
-	f = g_strdup(file);
-	perl_load_file(f);
-	g_free(f);
-	cfdes(config, NULL);
-}
-
-void load_perl_script(GtkWidget *w, gpointer d)
-{
-	char *buf, *temp;
-
-	if (config) {
-		gtk_widget_show(config);
-		gdk_window_raise(config->window);
-		return;
-	}
-
-	/* Below is basically stolen from plugins.c */
-	config = gtk_file_selection_new(_("Gaim - Select Perl Script"));
-
-	gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(config));
-
-	if (!last_dir) {
-		temp = gaim_user_dir();
-		buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
-		g_free(temp);
-	} else {
-		buf = g_strconcat(last_dir, G_DIR_SEPARATOR_S, NULL);
-	}
-
-	gtk_file_selection_set_filename(GTK_FILE_SELECTION(config), buf);
-	gtk_file_selection_complete(GTK_FILE_SELECTION(config), "*.pl"); 
-	gtk_signal_connect(GTK_OBJECT(config), "destroy",  GTK_SIGNAL_FUNC(cfdes),
-			config);
-
-	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->ok_button),
-			"clicked", GTK_SIGNAL_FUNC(do_load), NULL);
-    
-	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(config)->cancel_button),
-			"clicked", GTK_SIGNAL_FUNC(cfdes), NULL);
-
-	g_free(buf);
-	gtk_widget_show(config);
-	gdk_window_raise(config->window);
-}
-
-extern void unload_perl_scripts(GtkWidget *w, gpointer d)
+extern void unload_perl_scripts()
 {
 	perl_end();
 	perl_init();
 }
 
-extern void list_perl_scripts(GtkWidget *w, gpointer d)
+extern void list_perl_scripts()
 {
 	GList *s = perl_list;
 	struct perlscript *p;
--- a/src/sound.c	Thu Sep 27 09:02:07 2001 +0000
+++ b/src/sound.c	Thu Sep 27 09:20:47 2001 +0000
@@ -27,7 +27,6 @@
 #include <string.h>
 #include <sys/time.h>
 #include <unistd.h>
-#include <gtk/gtk.h>
 #include <fcntl.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -427,7 +426,7 @@
 
 		_exit(0);
 	} else {
-		gtk_timeout_add(100, (GtkFunction)clean_pid, NULL);
+		g_timeout_add(100, clean_pid, NULL);
 	}
 }
 
@@ -481,7 +480,7 @@
 
 		_exit(0);
 	} else {
-		gtk_timeout_add(100, (GtkFunction)clean_pid, NULL);
+		g_timeout_add(100, clean_pid, NULL);
 	}
 }
 
--- a/src/util.c	Thu Sep 27 09:02:07 2001 +0000
+++ b/src/util.c	Thu Sep 27 09:20:47 2001 +0000
@@ -742,7 +742,7 @@
 }
 
 
-gint clean_pid(void *dummy)
+gboolean clean_pid(gpointer dummy)
 {
 	int status;
 	pid_t pid;