Added infrastructure for external custom modes, the actual mode code will be committed later
This commit is contained in:
parent
7c511264df
commit
6e472afe6e
13
src/main.c
13
src/main.c
@ -186,6 +186,14 @@ static void load_css(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void sig(int32_t signum) {
|
||||
switch(signum) {
|
||||
case SIGTERM:
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
const struct option opts[] = {
|
||||
@ -643,6 +651,11 @@ int main(int argc, char** argv) {
|
||||
map_put(config, "no_actions", no_actions);
|
||||
}
|
||||
|
||||
struct sigaction sigact;
|
||||
memset(&sigact, 0, sizeof(sigact));
|
||||
sigact.sa_handler = sig;
|
||||
sigaction(SIGTERM, &sigact, NULL);
|
||||
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
|
37
src/wofi.c
37
src/wofi.c
@ -846,10 +846,8 @@ static void* get_plugin_proc(const char* prefix, const char* suffix) {
|
||||
return proc;
|
||||
}
|
||||
|
||||
static void add_mode(char* _mode) {
|
||||
static void* load_mode(char* _mode, struct mode* mode_ptr, struct map* props) {
|
||||
char* dso = strstr(_mode, ".so");
|
||||
struct mode* mode_ptr = calloc(1, sizeof(struct mode));
|
||||
map_put_void(modes, _mode, mode_ptr);
|
||||
|
||||
mode_ptr->name = strdup(_mode);
|
||||
|
||||
@ -889,21 +887,40 @@ static void add_mode(char* _mode) {
|
||||
mode = _mode;
|
||||
}
|
||||
|
||||
struct map* props = map_init();
|
||||
for(size_t count = 0; count < arg_count; ++count) {
|
||||
const char* arg = arg_names[count];
|
||||
char* full_name = utils_concat(3, _mode, "-", arg);
|
||||
map_put(props, arg, config_get(config, full_name, NULL));
|
||||
free(full_name);
|
||||
}
|
||||
return init;
|
||||
}
|
||||
|
||||
if(init != NULL) {
|
||||
init(mode_ptr, props);
|
||||
gdk_threads_add_idle(_insert_widget, mode_ptr);
|
||||
} else {
|
||||
fprintf(stderr, "I would love to show %s but Idk what it is\n", _mode);
|
||||
exit(1);
|
||||
static void add_mode(char* _mode) {
|
||||
struct mode* mode_ptr = calloc(1, sizeof(struct mode));
|
||||
struct map* props = map_init();
|
||||
void (*init)(struct mode* _mode, struct map* props) = load_mode(_mode, mode_ptr, props);
|
||||
|
||||
if(init == NULL) {
|
||||
free(mode_ptr->name);
|
||||
free(mode_ptr);
|
||||
map_free(props);
|
||||
|
||||
mode_ptr = calloc(1, sizeof(struct mode));
|
||||
props = map_init();
|
||||
|
||||
init = load_mode("external", mode_ptr, props);
|
||||
|
||||
map_put(props, "exec", _mode);
|
||||
|
||||
if(init == NULL) {
|
||||
fprintf(stderr, "I would love to show %s but Idk what it is\n", _mode);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
map_put_void(modes, _mode, mode_ptr);
|
||||
init(mode_ptr, props);
|
||||
gdk_threads_add_idle(_insert_widget, mode_ptr);
|
||||
|
||||
map_free(props);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user