Module* module_load (const gchar *path, const gchar *channel_name) { void (*init) (XfsmSplashConfig *config); Module *module; gchar property_base[512]; XfconfChannel *channel; gchar *dp; gchar *sp; /* load module */ module = g_new0 (Module, 1); #if GLIB_CHECK_VERSION(2,4,0) module->handle = g_module_open (path, G_MODULE_BIND_LOCAL); #else module->handle = g_module_open (path, 0); #endif if (G_UNLIKELY (module->handle == NULL)) goto error0; if (!g_module_symbol (module->handle, "config_init", (gpointer)&init)) goto error1; /* determine engine name */ sp = module->engine = g_path_get_basename (path); if (sp[0] == 'l' && sp[1] == 'i' && sp[2] == 'b') sp += 3; for (dp = module->engine; *sp != '\0'; ++dp, ++sp) { if (*sp == '.') break; else *dp = *sp; } *dp = '\0'; g_snprintf (property_base, sizeof (property_base), "/splash/engines/%s", module->engine); channel = xfconf_channel_new_with_property_base (channel_name, property_base); /* initialize module */ module->config.rc = xfsm_splash_rc_new (channel); g_object_unref (channel); init (&module->config); if (G_UNLIKELY (module->config.name == NULL)) { module_free (module); return NULL; } /* succeed */ return module; error1: g_module_close (module->handle); error0: g_free (module); return NULL; }
XfsmSplashScreen* xfsm_splash_screen_new (GdkDisplay *display, const gchar *engine) { XfsmSplashScreen *splash; XfsmSplashRc *splash_rc; GdkScreen *screen; gchar name[128]; int monitor; XfconfChannel *channel; /* locate monitor with pointer */ screen = xfce_gdk_screen_get_active (&monitor); if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display (screen) != display)) { screen = gdk_display_get_screen (display, 0); monitor = 0; } /* initialize the screen struct */ splash = g_new0 (XfsmSplashScreen, 1); splash->engine.display = display; splash->engine.primary_screen = screen; splash->engine.primary_monitor = monitor; /* load and setup the engine */ if (G_LIKELY (engine != NULL && *engine != '\0')) { xfsm_splash_screen_load (splash, engine); if (G_LIKELY (splash->engine.setup != NULL)) { g_snprintf (name, sizeof(name), "/splash/engines/%s", engine); channel = xfconf_channel_new_with_property_base ("xfce4-session", name); splash_rc = xfsm_splash_rc_new (channel); g_object_unref (channel); splash->engine.setup (&splash->engine, splash_rc); xfsm_splash_rc_free (splash_rc); gdk_flush (); } } return splash; }
static void migrate_46_panel_add_plugin (ConfigParser *parser, const gchar *name, const gchar *id, GError **error) { XfconfChannel *channel; gchar base[256]; XfceRc *rc; const gchar *plugin_name = name; g_return_if_fail (XFCONF_IS_CHANNEL (parser->channel)); /* open the old rc file of the plugin */ g_snprintf (base, sizeof (base), "heartlenv" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "%s-%s.rc", name, id); rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, base, TRUE); /* open a panel with the propert base for the plugin */ g_snprintf (base, sizeof (base), "/plugins/plugin-%d", parser->plugin_id_counter); channel = xfconf_channel_new_with_property_base (XFCE_PANEL_CHANNEL_NAME, base); if (strcmp (name, "actions") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_actions (channel, rc); } else if (strcmp (name, "clock") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_clock (channel, rc); } else if (strcmp (name, "iconbox") == 0) { plugin_name = "tasklist"; if (G_LIKELY (rc != NULL)) migrate_46_plugin_iconbox (channel, rc); } else if (strcmp (name, "launcher") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_launcher (channel, rc, parser->plugin_id_counter, error); } else if (strcmp (name, "pager") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_pager (channel, rc); } else if (strcmp (name, "separator") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_separator (channel, rc); } else if (strcmp (name, "showdesktop") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_showdesktop (channel, rc); } else if (strcmp (name, "systray") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_systray (channel, rc); } else if (strcmp (name, "tasklist") == 0) { if (G_LIKELY (rc != NULL)) migrate_46_plugin_tasklist (channel, rc); } else if (strcmp (name, "windowlist") == 0) { plugin_name = "windowmenu"; if (G_LIKELY (rc != NULL)) migrate_46_plugin_windowlist (channel, rc); } else if (strcmp (name, "heartlenv-menu") == 0) { plugin_name = "applicationsmenu"; if (G_LIKELY (rc != NULL)) migrate_46_plugin_heartlenv_menu (channel, rc); } else { /* handle other "external" plugins */ } /* close plugin configs */ g_object_unref (G_OBJECT (channel)); if (G_LIKELY (rc != NULL)) xfce_rc_close (rc); /* store the (new) plugin name */ xfconf_channel_set_string (parser->channel, base, plugin_name); }