give icons to launcher

This commit is contained in:
Nishi 2025-12-28 00:36:44 +09:00
commit 9796eb2c3c
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 64 additions and 18 deletions

View file

@ -1,3 +1,4 @@
#include <MDE/Foundation.h>
#include <Mw/Milsko.h>
#include <xemil.h>
@ -31,9 +32,33 @@ void module(MwWidget box, xl_node_t* node) {
int y = (gap + 18) * (c % 2);
if(n->type == XL_NODE_NODE && strcmp(n->name, "Execute") == 0 && n->text != NULL) {
MwWidget btn = MwVaCreateWidget(MwButtonClass, "button", f, x, y, 18, 18,
MwNflat, 1,
NULL);
MwLLPixmap px = NULL;
MwWidget btn;
const char* icon = NULL;
xl_attribute_t* a = n->first_attribute;
while(a != NULL) {
if(strcmp(a->key, "Icon") == 0) {
icon = a->value;
}
a = a->next;
}
if(icon != NULL && icon[0] == '/') {
px = MwLoadImage(box, icon);
} else if(icon != NULL) {
char* p = MDEIconLookUp("apps", icon, 16);
if(p != NULL) {
px = MwLoadImage(box, p);
free(p);
}
}
btn = MwVaCreateWidget(MwButtonClass, "button", f, x, y, 18, 18,
MwNflat, 1,
MwNpixmap, px,
NULL);
c++;
}

View file

@ -10,27 +10,25 @@
<Application Name="Applications" />
<Separator />
<Execute Name="Terminal">uxterm</Execute>
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Execute Name="" />
<Separator />
<EndSession Name="End Session" />
<ShutDown Name="Shut Down" />
<Reboot Name="Reboot" />
</Menu>
</StartButton>
<Separator />
<Launcher>
<Execute>uxterm</Execute>
<Execute>uxterm</Execute>
<Execute>uxterm</Execute>
<Execute>uxterm</Execute>
<Execute>uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
<Execute Icon="terminal">uxterm</Execute>
</Launcher>
<Separator />

View file

@ -339,6 +339,29 @@ static void menu_scan(opaque_t* opaque, xl_node_t* node) {
m->wsub = NULL;
m->sub = NULL;
m->opaque = MwStringDuplicate(n->text == NULL ? "" : n->text);
} else if(n->type == XL_NODE_NODE && strcmp(n->name, "EndSession") == 0 && name != NULL) {
m = malloc(sizeof(*m));
m->name = MwStringDuplicate(name);
m->keep = 0;
m->wsub = NULL;
m->sub = NULL;
m->opaque = malloc(512);
sprintf(m->opaque, "kill %ld", (long)getppid());
} else if(n->type == XL_NODE_NODE && strcmp(n->name, "ShutDown") == 0 && name != NULL) {
m = malloc(sizeof(*m));
m->name = MwStringDuplicate(name);
m->keep = 0;
m->wsub = NULL;
m->sub = NULL;
m->opaque = MwStringDuplicate(""); /* TODO */
} else if(n->type == XL_NODE_NODE && strcmp(n->name, "Reboot") == 0 && name != NULL) {
m = malloc(sizeof(*m));
m->name = MwStringDuplicate(name);
m->keep = 0;
m->wsub = NULL;
m->sub = NULL;
m->opaque = MwStringDuplicate(""); /* TODO */
}
if(m != NULL) {