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) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
const struct option opts[] = {
|
const struct option opts[] = {
|
||||||
@ -643,6 +651,11 @@ int main(int argc, char** argv) {
|
|||||||
map_put(config, "no_actions", no_actions);
|
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);
|
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;
|
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");
|
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);
|
mode_ptr->name = strdup(_mode);
|
||||||
|
|
||||||
@ -889,21 +887,40 @@ static void add_mode(char* _mode) {
|
|||||||
mode = _mode;
|
mode = _mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct map* props = map_init();
|
|
||||||
for(size_t count = 0; count < arg_count; ++count) {
|
for(size_t count = 0; count < arg_count; ++count) {
|
||||||
const char* arg = arg_names[count];
|
const char* arg = arg_names[count];
|
||||||
char* full_name = utils_concat(3, _mode, "-", arg);
|
char* full_name = utils_concat(3, _mode, "-", arg);
|
||||||
map_put(props, arg, config_get(config, full_name, NULL));
|
map_put(props, arg, config_get(config, full_name, NULL));
|
||||||
free(full_name);
|
free(full_name);
|
||||||
}
|
}
|
||||||
|
return init;
|
||||||
|
}
|
||||||
|
|
||||||
if(init != NULL) {
|
static void add_mode(char* _mode) {
|
||||||
init(mode_ptr, props);
|
struct mode* mode_ptr = calloc(1, sizeof(struct mode));
|
||||||
gdk_threads_add_idle(_insert_widget, mode_ptr);
|
struct map* props = map_init();
|
||||||
} else {
|
void (*init)(struct mode* _mode, struct map* props) = load_mode(_mode, mode_ptr, props);
|
||||||
fprintf(stderr, "I would love to show %s but Idk what it is\n", _mode);
|
|
||||||
exit(1);
|
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);
|
map_free(props);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user