| 212 gtk_widget_hide(menu->separator); |
212 gtk_widget_hide(menu->separator); |
| 213 } |
213 } |
| 214 } |
214 } |
| 215 |
215 |
| 216 /****************************************************************************** |
216 /****************************************************************************** |
| 217 * Purple Signal Callbacks |
217 * Callbacks |
| 218 *****************************************************************************/ |
218 *****************************************************************************/ |
| 219 static void |
219 static void |
| 220 pidgin_plugins_menu_plugin_load_cb(PurplePlugin *plugin, gpointer data) { |
220 pidgin_plugins_menu_plugin_loaded_cb(GObject *manager, GPluginPlugin *plugin, |
| |
221 gpointer data) |
| |
222 { |
| 221 pidgin_plugins_menu_add_plugin_actions(PIDGIN_PLUGINS_MENU(data), plugin); |
223 pidgin_plugins_menu_add_plugin_actions(PIDGIN_PLUGINS_MENU(data), plugin); |
| 222 } |
224 } |
| 223 |
225 |
| 224 static void |
226 static void |
| 225 pidgin_plugins_menu_plugin_unload_cb(PurplePlugin *plugin, gpointer data) { |
227 pidgin_plugins_menu_plugin_unloaded_cb(GObject *manager, GPluginPlugin *plugin, |
| |
228 gpointer data) |
| |
229 { |
| 226 pidgin_plugins_menu_remove_plugin_actions(PIDGIN_PLUGINS_MENU(data), |
230 pidgin_plugins_menu_remove_plugin_actions(PIDGIN_PLUGINS_MENU(data), |
| 227 plugin); |
231 plugin); |
| 228 } |
232 } |
| 229 |
233 |
| 230 /****************************************************************************** |
234 /****************************************************************************** |
| 232 *****************************************************************************/ |
236 *****************************************************************************/ |
| 233 G_DEFINE_TYPE(PidginPluginsMenu, pidgin_plugins_menu, GTK_TYPE_MENU) |
237 G_DEFINE_TYPE(PidginPluginsMenu, pidgin_plugins_menu, GTK_TYPE_MENU) |
| 234 |
238 |
| 235 static void |
239 static void |
| 236 pidgin_plugins_menu_init(PidginPluginsMenu *menu) { |
240 pidgin_plugins_menu_init(PidginPluginsMenu *menu) { |
| 237 gpointer handle; |
241 GObject *manager = NULL; |
| 238 |
242 |
| 239 /* initialize our template */ |
243 /* initialize our template */ |
| 240 gtk_widget_init_template(GTK_WIDGET(menu)); |
244 gtk_widget_init_template(GTK_WIDGET(menu)); |
| 241 |
245 |
| 242 /* create our internal action group and assign it to ourself */ |
246 /* create our internal action group and assign it to ourself */ |
| 248 /* create our storage for the items */ |
252 /* create our storage for the items */ |
| 249 menu->plugin_items = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
253 menu->plugin_items = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
| 250 g_object_unref, |
254 g_object_unref, |
| 251 (GDestroyNotify)gtk_widget_destroy); |
255 (GDestroyNotify)gtk_widget_destroy); |
| 252 |
256 |
| 253 /* finally connect to the purple signals to stay up to date */ |
257 /* Connect to the plugin manager's signals so we can stay up to date. */ |
| 254 handle = purple_plugins_get_handle(); |
258 manager = gplugin_manager_get_instance(); |
| 255 purple_signal_connect(handle, "plugin-load", menu, |
259 |
| 256 PURPLE_CALLBACK(pidgin_plugins_menu_plugin_load_cb), |
260 g_signal_connect_object(manager, "loaded-plugin", |
| 257 menu); |
261 G_CALLBACK(pidgin_plugins_menu_plugin_loaded_cb), |
| 258 purple_signal_connect(handle, "plugin-unload", menu, |
262 menu, 0); |
| 259 PURPLE_CALLBACK(pidgin_plugins_menu_plugin_unload_cb), |
263 g_signal_connect_object(manager, "unloaded-plugin", |
| 260 menu); |
264 G_CALLBACK(pidgin_plugins_menu_plugin_unloaded_cb), |
| |
265 menu, 0); |
| 261 }; |
266 }; |
| 262 |
267 |
| 263 static void |
268 static void |
| 264 pidgin_plugins_menu_finalize(GObject *obj) { |
|
| 265 purple_signals_disconnect_by_handle(obj); |
|
| 266 |
|
| 267 G_OBJECT_CLASS(pidgin_plugins_menu_parent_class)->finalize(obj); |
|
| 268 } |
|
| 269 |
|
| 270 static void |
|
| 271 pidgin_plugins_menu_class_init(PidginPluginsMenuClass *klass) { |
269 pidgin_plugins_menu_class_init(PidginPluginsMenuClass *klass) { |
| 272 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
| 273 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
270 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
| 274 |
|
| 275 obj_class->finalize = pidgin_plugins_menu_finalize; |
|
| 276 |
271 |
| 277 gtk_widget_class_set_template_from_resource( |
272 gtk_widget_class_set_template_from_resource( |
| 278 widget_class, |
273 widget_class, |
| 279 "/im/pidgin/Pidgin/Plugins/menu.ui" |
274 "/im/pidgin/Pidgin/Plugins/menu.ui" |
| 280 ); |
275 ); |