From e7d4425e3cc26504ee04cebf7612ff56c72615d7 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 27 Sep 2012 18:29:52 +0000 Subject: [PATCH] panel-test now uses the Plugin class as well --- tools/notify.c | 7 +++++++ tools/test.c | 36 ++++++++++++++---------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tools/notify.c b/tools/notify.c index 801a235..83e349d 100644 --- a/tools/notify.c +++ b/tools/notify.c @@ -34,6 +34,13 @@ #define PACKAGE "panel-notify" #include "helper.c" +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif +#ifndef LIBDIR +# define LIBDIR PREFIX "/lib" +#endif + /* private */ /* prototypes */ diff --git a/tools/test.c b/tools/test.c index 87673f8..ea79d46 100644 --- a/tools/test.c +++ b/tools/test.c @@ -21,18 +21,25 @@ #include #include #include -#include #include #include #include #include "../src/panel.h" #include "../config.h" + #ifdef PACKAGE # undef PACKAGE #endif #define PACKAGE "panel-test" #include "helper.c" +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif +#ifndef LIBDIR +# define LIBDIR PREFIX "/lib" +#endif + /* private */ /* prototypes */ @@ -46,19 +53,10 @@ static int _test(GtkIconSize iconsize, char * applets[]) { Panel panel; char * filename; - char const path[] = PREFIX "/lib/Panel/applets/"; -#ifdef __APPLE__ - char const ext[] = ".dylib"; -#else - char const ext[] = ".so"; -#endif GtkWidget * box; GtkWidget * widget; size_t i; - size_t len; - char * p = NULL; - char * q; - void * dl; + Plugin * plugin; PanelAppletHelper helper; PanelAppletDefinition * pad; PanelApplet * pa; @@ -77,20 +75,15 @@ static int _test(GtkIconSize iconsize, char * applets[]) _helper_init(&helper, &panel, PANEL_APPLET_TYPE_NORMAL, iconsize); for(i = 0; applets[i] != NULL; i++) { - len = sizeof(path) + strlen(applets[i]) + sizeof(ext); - if((q = realloc(p, len)) == NULL) - break; - p = q; - snprintf(p, len, "%s%s%s", path, applets[i], ext); - if((dl = dlopen(p, RTLD_LAZY)) == NULL) + if((plugin = plugin_new(LIBDIR, "Panel", "applets", applets[i])) + == NULL) { - fprintf(stderr, "%s: %s: %s\n", "panel-test", - applets[i], dlerror()); + error_print(PACKAGE); continue; } - if((pad = dlsym(dl, "applet")) == NULL) + if((pad = plugin_lookup(plugin, "applet")) == NULL) { - dlclose(dl); + plugin_delete(plugin); continue; } widget = NULL; @@ -99,7 +92,6 @@ static int _test(GtkIconSize iconsize, char * applets[]) gtk_box_pack_start(GTK_BOX(box), widget, pad->expand, pad->fill, 0); } - free(p); gtk_container_add(GTK_CONTAINER(panel.window), box); gtk_widget_show_all(panel.window); panel.timeout = 0;