Start of making SardemFF7 happy

Allow mode's to be loaded as dynamic plugins.
This commit is contained in:
Dave Davenport 2017-02-14 08:52:17 +01:00
parent 97be4e9c72
commit fb05409365
5 changed files with 27 additions and 2 deletions

View file

@ -102,7 +102,7 @@ PKG_PROG_PKG_CONFIG
dnl ---------------------------------------------------------------------
dnl PKG_CONFIG based dependencies
dnl ---------------------------------------------------------------------
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0])
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0])
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama])
PKG_CHECK_MODULES([pango], [pango pangocairo])
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])

View file

@ -5,7 +5,6 @@
#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include "timings.h"
#include "keyb.h"
#include "mode.h"
#include "view.h"

View file

@ -49,6 +49,8 @@
#include "dialogs/run.h"
#include "mode-private.h"
#include "timings.h"
/**
* Name of the history file where previously choosen commands are stored.
*/

View file

@ -34,6 +34,7 @@
#include <errno.h>
#include <time.h>
#include <locale.h>
#include <gmodule.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_ewmh.h>
@ -66,6 +67,8 @@
#include "theme.h"
#include "timings.h"
// Pidfile.
char *pidfile = NULL;
const char *cache_dir = NULL;
@ -441,6 +444,26 @@ static int add_mode ( const char * token )
modi[num_modi] = &combi_mode;
num_modi++;
}
else if ( g_str_has_suffix ( token, G_MODULE_SUFFIX ) )
{
TICK_N("Loading module");
// Load module.
GModule *mod = g_module_open ( token, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL );
if ( mod ) {
gpointer m = NULL;
if ( g_module_symbol ( mod, "mode", &m) ){
modi[num_modi] = m;
num_modi++;
} else {
fprintf(stderr, "Symbol 'mode' not found in module: %s\n", token);
g_module_close ( mod );
}
} else {
fprintf ( stderr, "Failed to open module: %s\n", token);
}
TICK_N("Loading module done");
}
else {
// If not build in, use custom modi.
Mode *sw = script_switcher_parse_setup ( token );

View file

@ -45,6 +45,7 @@
#define SN_API_NOT_YET_FROZEN
#include <libsn/sn.h>
#include "timings.h"
#include "settings.h"
#include "rofi.h"