+ if (!p->started) {
+ p->startup();
+ p->started = TRUE;
+ }
+}
+
+void plugin_startall()
+{
+ g_datalist_foreach(&plugins, (GDataForeachFunc)foreach_start, NULL);
+}
+
+void plugin_start(gchar *name)
+{
+ Plugin *p;
+
+ if (!(p = g_datalist_get_data(&plugins, name))) {
+ g_warning("Tried to start plugin '%s' but it is not loaded", name);
+ return;
+ }
+ if (!p->started) {
+ p->startup();
+ p->started = TRUE;
+ }
+}
+
+void plugin_loadall(ObParseInst *i)
+{
+ GIOChannel *io;
+ GError *err;
+ gchar *path, *name;
+
+ path = g_build_filename(g_get_home_dir(), ".openbox", "pluginrc", NULL);
+ err = NULL;
+ io = g_io_channel_new_file(path, "r", &err);
+ g_free(path);
+
+ if (io == NULL) {
+ path = g_build_filename(RCDIR, "pluginrc", NULL);
+ err = NULL;
+ io = g_io_channel_new_file(path, "r", &err);
+ g_free(path);
+ }
+
+ if (io == NULL) {
+ /* load the default plugins */
+ plugin_open("placement", i);
+ } else {
+ /* load the plugins in the rc file */
+ while (g_io_channel_read_line(io, &name, NULL, NULL, &err) ==
+ G_IO_STATUS_NORMAL) {
+ g_strstrip(name);
+ if (name[0] != '\0' && name[0] != '#')
+ plugin_open(name, i);
+ g_free(name);
+ }
+ g_io_channel_unref(io);
+ }