comparison plugins/perl/perl.c @ 12872:59ff3e1c874e

[gaim-migrate @ 15224] Perl plugins can now each have their own plugin pref frame. Plugin actions are still limited to one per plugin I'll deal with that a bit later. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sat, 14 Jan 2006 08:28:05 +0000
parents 2422097a7a5e
children 96d611ab3fcb
comparison
equal deleted inserted replaced
12871:2422097a7a5e 12872:59ff3e1c874e
93 #include "perl-common.h" 93 #include "perl-common.h"
94 #include "perl-handlers.h" 94 #include "perl-handlers.h"
95 95
96 #define PERL_PLUGIN_ID "core-perl" 96 #define PERL_PLUGIN_ID "core-perl"
97 97
98 typedef struct
99 {
100 GaimPlugin *plugin;
101 char *package;
102 char *load_sub;
103 char *unload_sub;
104 } GaimPerlScript;
105
106 PerlInterpreter *my_perl = NULL; 98 PerlInterpreter *my_perl = NULL;
99
100 static GaimPluginUiInfo ui_info =
101 {
102 gaim_perl_get_plugin_frame,
103 0, /* page_num (Reserved) */
104 NULL /* frame (Reserved) */
105 };
106
107 static GaimGtkPluginUiInfo gtk_ui_info =
108 {
109 gaim_perl_gtk_get_plugin_frame,
110 0 /* page_num (Reserved) */
111 };
107 112
108 static void 113 static void
109 #ifdef OLD_PERL 114 #ifdef OLD_PERL
110 xs_init() 115 xs_init()
111 #else 116 #else
342 /* representing the plugin preferences */ 347 /* representing the plugin preferences */
343 /* page. */ 348 /* page. */
344 /********************************************************/ 349 /********************************************************/
345 if ((key = hv_fetch(plugin_info, "prefs_info", 350 if ((key = hv_fetch(plugin_info, "prefs_info",
346 strlen("prefs_info"), 0))) { 351 strlen("prefs_info"), 0))) {
347 char *tmp = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len));
348 /* key now is the name of the Perl sub that 352 /* key now is the name of the Perl sub that
349 * will create a frame for us */ 353 * will create a frame for us */
350 info->prefs_info = gaim_perl_plugin_pref(tmp); 354 gps->prefs_sub = g_strdup_printf("%s::%s",
351 g_free(tmp); 355 gps->package,
356 SvPV(*key, len));
357 info->prefs_info = &ui_info;
352 } 358 }
353 359
354 if ((key = hv_fetch(plugin_info, "gtk_prefs_info", 360 if ((key = hv_fetch(plugin_info, "gtk_prefs_info",
355 strlen("gtk_prefs_info"), 0))) { 361 strlen("gtk_prefs_info"), 0))) {
356 char *tmp = g_strdup_printf("%s::%s", gps->package, SvPV(*key, len));
357 /* key now is the name of the Perl sub that 362 /* key now is the name of the Perl sub that
358 * will create a frame for us */ 363 * will create a frame for us */
359 info->ui_info = gaim_perl_gtk_plugin_pref(tmp); 364 gps->gtk_prefs_sub = g_strdup_printf("%s::%s",
360 g_free(tmp); 365 gps->package,
366 SvPV(*key, len));
367 info->ui_info = &gtk_ui_info;
361 } 368 }
362 369
363 /********************************************************/ 370 /********************************************************/
364 /* */ 371 /* */
365 /* plugin_action - This is given to the plugin info */ 372 /* plugin_action - This is given to the plugin info */
535 gps = (GaimPerlScript *)plugin->info->extra_info; 542 gps = (GaimPerlScript *)plugin->info->extra_info;
536 if (gps != NULL) { 543 if (gps != NULL) {
537 g_free(gps->load_sub); 544 g_free(gps->load_sub);
538 g_free(gps->unload_sub); 545 g_free(gps->unload_sub);
539 g_free(gps->package); 546 g_free(gps->package);
547 g_free(gps->prefs_sub);
548 g_free(gps->gtk_prefs_sub);
540 g_free(gps); 549 g_free(gps);
541 plugin->info->extra_info = NULL; 550 plugin->info->extra_info = NULL;
542 } 551 }
543 } 552 }
544 } 553 }