fix
This commit is contained in:
parent
9aaf59b94f
commit
cd93891efa
3 changed files with 33 additions and 48 deletions
|
|
@ -2,6 +2,12 @@
|
|||
#include <Mw/Milsko.h>
|
||||
#include <xemil.h>
|
||||
|
||||
#include <stb_ds.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int calc_gap(MwWidget box) {
|
||||
return MwGetInteger(box, MwNheight) - 18 * 2;
|
||||
}
|
||||
|
|
@ -23,6 +29,21 @@ static int calc_size(MwWidget box, xl_node_t* node) {
|
|||
return (gap + 18) * ((c + (c % 2)) / 2) - gap;
|
||||
}
|
||||
|
||||
static void exec_button(MwWidget handle, void* user, void* client){
|
||||
char** args = MDEStringToExec(MwGetText(handle, "Sexec"), NULL);
|
||||
int i;
|
||||
|
||||
if(fork() == 0){
|
||||
execvp(args[0], args);
|
||||
_exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < arrlen(args); i++) {
|
||||
if(args[i] != NULL) free(args[i]);
|
||||
}
|
||||
arrfree(args);
|
||||
}
|
||||
|
||||
void module_reload(MwWidget box, MwWidget user, xl_node_t* node) {
|
||||
int w = calc_size(box, node);
|
||||
int gap = calc_gap(box);
|
||||
|
|
@ -82,6 +103,12 @@ void module_reload(MwWidget box, MwWidget user, xl_node_t* node) {
|
|||
MwNpixmap, px,
|
||||
NULL);
|
||||
|
||||
MwVaApply(btn,
|
||||
"Sexec", n->text,
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(btn, MwNactivateHandler, exec_button, NULL);
|
||||
|
||||
c++;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
mpanel/launcher/stb_ds.c
Normal file
2
mpanel/launcher/stb_ds.c
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define STB_DS_IMPLEMENTATION
|
||||
#include <stb_ds.h>
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stb_image.h>
|
||||
#include <stb_ds.h>
|
||||
|
||||
#define _MILSKO
|
||||
#include <MDE/Foundation.h>
|
||||
#include <Mw/Milsko.h>
|
||||
#include <xemil.h>
|
||||
|
||||
#include <ini.h>
|
||||
#include <stb_image.h>
|
||||
#include <stb_ds.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -172,57 +172,13 @@ static void call(const char* name, int dir, int symlink, void* user) {
|
|||
}
|
||||
}
|
||||
|
||||
static char** desktop_exec(const char* exec, const char* file) {
|
||||
char** a = NULL;
|
||||
int i;
|
||||
char* buf = malloc(1);
|
||||
|
||||
buf[0] = 0;
|
||||
|
||||
for(i = 0;; i++) {
|
||||
if(exec[i] == ' ' || exec[i] == 0) {
|
||||
if(strlen(buf) > 0) arrput(a, buf);
|
||||
|
||||
buf = malloc(1);
|
||||
buf[0] = 0;
|
||||
|
||||
if(exec[i] == 0) break;
|
||||
} else if(exec[i] == '%') {
|
||||
char c = exec[++i];
|
||||
|
||||
if(c == 'f' && file != NULL) {
|
||||
char* old = buf;
|
||||
|
||||
buf = malloc(strlen(old) + strlen(file) + 1);
|
||||
strcpy(buf, old);
|
||||
strcpy(buf + strlen(old), file);
|
||||
|
||||
free(old);
|
||||
}
|
||||
} else {
|
||||
char* old = buf;
|
||||
|
||||
buf = malloc(strlen(old) + 2);
|
||||
strcpy(buf, old);
|
||||
buf[strlen(old)] = exec[i];
|
||||
buf[strlen(old) + 1] = 0;
|
||||
|
||||
free(old);
|
||||
}
|
||||
}
|
||||
|
||||
arrput(a, NULL);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
static void menu(MwWidget handle, void* user, void* client) {
|
||||
opaque_t* opaque = handle->opaque;
|
||||
char* s = NULL;
|
||||
MwMenu m = client;
|
||||
|
||||
if(m->opaque != NULL) {
|
||||
char** args = desktop_exec(m->opaque, NULL);
|
||||
char** args = MDEStringToExec(m->opaque, NULL);
|
||||
int i;
|
||||
|
||||
if(fork() == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue