comparison plugins/perl/perl-handlers.c @ 12874:e65a7a7eabaf

[gaim-migrate @ 15226] Remove some stuff that's not being used anymore, and finish making gtk pref frames work like plugin pref frames. Note: the gtk pref stuff hasn't been tested by me because all it does is crash and I haven't quite figured out why yet, but I think my changes should be fine. It was crashing before I made them as well. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sat, 14 Jan 2006 09:06:40 +0000
parents 59ff3e1c874e
children e1603fd610fa
comparison
equal deleted inserted replaced
12873:96d611ab3fcb 12874:e65a7a7eabaf
4 #include "debug.h" 4 #include "debug.h"
5 #include "signals.h" 5 #include "signals.h"
6 6
7 static GList *timeout_handlers = NULL; 7 static GList *timeout_handlers = NULL;
8 static GList *signal_handlers = NULL; 8 static GList *signal_handlers = NULL;
9 static char *perl_plugin_pref_cb;
10 static char *perl_gtk_plugin_pref_cb;
11 extern PerlInterpreter *my_perl; 9 extern PerlInterpreter *my_perl;
12 10
13 /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */ 11 /* perl < 5.8.0 doesn't define PERL_MAGIC_ext */
14 #ifndef PERL_MAGIC_ext 12 #ifndef PERL_MAGIC_ext
15 #define PERL_MAGIC_ext '~' 13 #define PERL_MAGIC_ext '~'
61 gl = g_list_append(gl, act); 59 gl = g_list_append(gl, act);
62 60
63 return gl; 61 return gl;
64 } 62 }
65 63
66
67 GaimGtkPluginUiInfo *
68 gaim_perl_gtk_plugin_pref(const char * frame_cb)
69 {
70 GaimGtkPluginUiInfo *ui_info;
71
72 ui_info = g_new0(GaimGtkPluginUiInfo, 1);
73 perl_gtk_plugin_pref_cb = g_strdup(frame_cb);
74 ui_info->get_config_frame = gaim_perl_gtk_get_plugin_frame;
75
76 return ui_info;
77 }
78
79 GtkWidget * 64 GtkWidget *
80 gaim_perl_gtk_get_plugin_frame(GaimPlugin *plugin) 65 gaim_perl_gtk_get_plugin_frame(GaimPlugin *plugin)
81 { 66 {
82 SV * sv; 67 SV * sv;
68 int count;
69 MAGIC *mg;
83 GtkWidget *ret; 70 GtkWidget *ret;
84 MAGIC *mg; 71 GaimPerlScript *gps;
85 dSP; 72 dSP;
86 int count; 73
74 gps = (GaimPerlScript *)plugin->info->extra_info;
87 75
88 ENTER; 76 ENTER;
89 SAVETMPS; 77 SAVETMPS;
90 78
91 count = call_pv(perl_gtk_plugin_pref_cb, G_SCALAR | G_NOARGS); 79 count = call_pv(gps->gtk_prefs_sub, G_SCALAR | G_NOARGS);
92 if (count != 1) 80 if (count != 1)
93 croak("call_pv: Did not return the correct number of values.\n"); 81 croak("call_pv: Did not return the correct number of values.\n");
94 82
95 /* the frame was created in a perl sub and is returned */ 83 /* the frame was created in a perl sub and is returned */
96 SPAGAIN; 84 SPAGAIN;
97 85
98 /* We have a Gtk2::Frame on top of the stack */ 86 /* We have a Gtk2::Frame on top of the stack */
99 sv = POPs; 87 sv = POPs;
100 88
101 /* The magic field hides the pointer to the actuale GtkWidget */ 89 /* The magic field hides the pointer to the actual GtkWidget */
102 mg = mg_find(SvRV(sv), PERL_MAGIC_ext); 90 mg = mg_find(SvRV(sv), PERL_MAGIC_ext);
103 ret = (GtkWidget *)mg->mg_ptr; 91 ret = (GtkWidget *)mg->mg_ptr;
104 92
105 PUTBACK; 93 PUTBACK;
106 FREETMPS; 94 FREETMPS;
107 LEAVE; 95 LEAVE;
108 96
109 return ret; 97 return ret;
110 }
111
112 /* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo */
113 /* It will then in turn create ui_info with the C function pointer */
114 /* that will eventually do a call_pv to call a perl functions so users */
115 /* can create their own frames in the prefs */
116 GaimPluginUiInfo *
117 gaim_perl_plugin_pref(const char * frame_cb)
118 {
119 GaimPluginUiInfo *ui_info;
120
121 ui_info = g_new0(GaimPluginUiInfo, 1);
122 perl_plugin_pref_cb = g_strdup(frame_cb);
123 ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame;
124
125 return ui_info;
126 } 98 }
127 99
128 GaimPluginPrefFrame * 100 GaimPluginPrefFrame *
129 gaim_perl_get_plugin_frame(GaimPlugin *plugin) 101 gaim_perl_get_plugin_frame(GaimPlugin *plugin)
130 { 102 {