comparison src/dialogs.c @ 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 19ea44f74a88
children 2927c2c26fe6
comparison
equal deleted inserted replaced
2369:117e9f0950b6 2370:25e7c2a68ed2
4037 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry); 4037 GTK_SIGNAL_FUNC(do_rename_buddy), name_entry);
4038 } 4038 }
4039 4039
4040 gtk_widget_show_all(rename_bud_dialog); 4040 gtk_widget_show_all(rename_bud_dialog);
4041 } 4041 }
4042
4043 static GtkWidget *perl_config = NULL;
4044 static char *perl_last_dir = NULL;
4045
4046 static void cfdes(GtkWidget *m, gpointer n) {
4047 if (perl_config) gtk_widget_destroy(perl_config);
4048 perl_config = NULL;
4049 }
4050
4051 static void do_load(GtkWidget *m, gpointer n) {
4052 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(perl_config));
4053 gchar *f = NULL;
4054 if (!file || !strlen(file)) {
4055 return;
4056 }
4057
4058 if (file_is_dir(file, perl_config)) {
4059 return;
4060 }
4061
4062 if (perl_last_dir) {
4063 g_free(perl_last_dir);
4064 }
4065 perl_last_dir = g_dirname(file);
4066
4067 debug_printf("Loading perl script: %s\n", file);
4068
4069 f = g_strdup(file);
4070 perl_load_file(f);
4071 g_free(f);
4072 cfdes(perl_config, NULL);
4073 }
4074
4075 void load_perl_script()
4076 {
4077 char *buf, *temp;
4078
4079 if (perl_config) {
4080 gtk_widget_show(perl_config);
4081 gdk_window_raise(perl_config->window);
4082 return;
4083 }
4084
4085 /* Below is basically stolen from plugins.c */
4086 perl_config = gtk_file_selection_new(_("Gaim - Select Perl Script"));
4087
4088 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config));
4089
4090 if (!perl_last_dir) {
4091 temp = gaim_user_dir();
4092 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
4093 g_free(temp);
4094 } else {
4095 buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL);
4096 }
4097
4098 gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf);
4099 gtk_file_selection_complete(GTK_FILE_SELECTION(perl_config), "*.pl");
4100 gtk_signal_connect(GTK_OBJECT(perl_config), "destroy", GTK_SIGNAL_FUNC(cfdes),
4101 perl_config);
4102
4103 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->ok_button),
4104 "clicked", GTK_SIGNAL_FUNC(do_load), NULL);
4105
4106 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(perl_config)->cancel_button),
4107 "clicked", GTK_SIGNAL_FUNC(cfdes), NULL);
4108
4109 g_free(buf);
4110 gtk_widget_show(perl_config);
4111 gdk_window_raise(perl_config->window);
4112 }