First replicant yay
This commit is contained in:
80
replicants/Launcher/src/main.c
Normal file
80
replicants/Launcher/src/main.c
Normal file
@@ -0,0 +1,80 @@
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xmd/Icon.h>
|
||||
#include <Xmd/Replicant.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "icons/appCalculator.xbm"
|
||||
#include "icons/appEditor.xbm"
|
||||
#include "icons/appFiles.xbm"
|
||||
#include "icons/appMail.xbm"
|
||||
#include "icons/appMusic.xbm"
|
||||
#include "icons/appTerminal.xbm"
|
||||
#include "icons/appWebBrowser.xbm"
|
||||
#include "icons/unknown.xbm"
|
||||
|
||||
void activateLauncher (Widget button, XtPointer clientData, XtPointer callData) {
|
||||
(void)(button);
|
||||
(void)(callData);
|
||||
XmdReplicantState *state = (XmdReplicantState *)(clientData);
|
||||
|
||||
String command = XmdReplicantStateQuery(state, "Exec");
|
||||
String fullCommand = NULL;
|
||||
XtAsprintf(&fullCommand, "%s &", command);
|
||||
XtFree(command);
|
||||
system(fullCommand);
|
||||
XtFree(fullCommand);
|
||||
}
|
||||
|
||||
int Launcher_XmdReplicantVersion () {
|
||||
return XmdREPLICANT_VERSION;
|
||||
}
|
||||
|
||||
void Launcher_XmdReplicantConstruct () {
|
||||
|
||||
}
|
||||
|
||||
void Launcher_XmdReplicantDestruct () {
|
||||
|
||||
}
|
||||
|
||||
void handleDestroyFreePixmap (
|
||||
Widget replicant,
|
||||
XtPointer clientData,
|
||||
XtPointer callData
|
||||
) {
|
||||
(void)(callData);
|
||||
XFreePixmap(XtDisplay(replicant), (Pixmap)(clientData));
|
||||
}
|
||||
|
||||
Widget Launcher_XmdReplicantCreate (Widget parent, XmdReplicantState *state) {
|
||||
String iconName = XmdReplicantStateQuery(state, "Icon");
|
||||
Pixmap icon;
|
||||
#define iconCase(name) if (strcmp(#name, iconName) == 0) {\
|
||||
icon = XmdLoadBitmapIcon(parent, app##name);\
|
||||
} else
|
||||
iconCase(Calculator)
|
||||
iconCase(Editor)
|
||||
iconCase(Files)
|
||||
iconCase(Mail)
|
||||
iconCase(Terminal)
|
||||
iconCase(WebBrowser)
|
||||
iconCase(Music)
|
||||
icon = XmdLoadBitmapIcon(parent, unknown);
|
||||
|
||||
XtFree(iconName);
|
||||
|
||||
Widget button = XtVaCreateManagedWidget (
|
||||
"launcher", xmPushButtonWidgetClass, parent,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNlabelType, XmPIXMAP,
|
||||
XmNlabelPixmap, icon,
|
||||
NULL);
|
||||
XtAddCallback (
|
||||
button, XmNactivateCallback,
|
||||
activateLauncher, (XtPointer)(state));
|
||||
XtAddCallback (
|
||||
button, XmNdestroyCallback,
|
||||
handleDestroyFreePixmap, (XtPointer)(icon));
|
||||
return button;
|
||||
}
|
||||
Reference in New Issue
Block a user