87 lines
2.0 KiB
C
87 lines
2.0 KiB
C
#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"
|
|
|
|
static 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 (
|
|
XtAppContext application,
|
|
Widget parent,
|
|
XmdReplicantState *state
|
|
) {
|
|
(void)(application);
|
|
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);
|
|
#undef iconCase
|
|
|
|
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;
|
|
}
|