changeset 153:8ed64c704fb0

[gaim-migrate @ 163] This should be interesting. We'll see how well this works. I can't explain why, but I have a bad feeling about this one. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 24 Apr 2000 01:47:24 +0000
parents cb0d3ec5a4c8
children 1c4e47c0c5dd
files src/plugins.c
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins.c	Mon Apr 24 01:43:16 2000 +0000
+++ b/src/plugins.c	Mon Apr 24 01:47:24 2000 +0000
@@ -86,6 +86,7 @@
 static void load_file(GtkWidget *w, gpointer data)
 {
 	char *buf = g_malloc(BUF_LEN);
+	FILE *fd;
  
 	if (plugin_dialog) {
 		g_free(buf);
@@ -99,13 +100,15 @@
 	gtk_file_selection_hide_fileop_buttons(
 					GTK_FILE_SELECTION(plugin_dialog));
 
-	if(getenv("PLUGIN_DIR") == NULL) {
-		g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR);
-	} else {
-		g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("PLUGIN_DIR"));
-	}
+	g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR);
+	fd = fopen(buf, "r");
+	if (!fd)
+		mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
+	else
+		fclose(fd);
 
 	gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf);
+	gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so");
 	gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy",
 			GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog);
 
@@ -135,8 +138,15 @@
 	char *(*cfunc)();
 	char *error;
 
+	if (filename == NULL) return;
 	plug = g_malloc(sizeof *plug);
-	plug->filename = g_strdup(filename);
+	if (filename[0] != '/') {
+		char *buf = g_malloc(BUF_LEN);
+		g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), PLUGIN_DIR);
+		plug->filename = g_malloc(strlen(buf) + strlen(filename) + 1);
+		sprintf(plug->filename, "%s%s", buf, filename);
+	} else
+		plug->filename = g_strdup(filename);
 	/* do NOT OR with RTLD_GLOBAL, otherwise plugins may conflict
 	 * (it's really just a way to work around other people's bad
 	 * programming, by not using RTLD_GLOBAL :P ) */
@@ -172,6 +182,7 @@
 		plug->description = NULL;
 
 	update_show_plugins();
+	save_prefs();
 }
 
 void show_plugins(GtkWidget *w, gpointer data) {