diff --git a/xmdev/src/icons/mount.xbm b/xmdev/src/icons/mount.xbm new file mode 100644 index 0000000..24ee2b1 --- /dev/null +++ b/xmdev/src/icons/mount.xbm @@ -0,0 +1,9 @@ +#define mount_width 24 +#define mount_height 24 +static unsigned char mount_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x80, 0xff, 0x01, + 0xe0, 0x81, 0x07, 0x70, 0x00, 0x0e, 0x30, 0x00, 0x0c, 0x18, 0x00, 0x19, + 0x18, 0x80, 0x18, 0x0c, 0x40, 0x30, 0x0c, 0x00, 0x30, 0x0c, 0xd8, 0x37, + 0xec, 0x1b, 0x30, 0x0c, 0x00, 0x30, 0x0c, 0x02, 0x30, 0x18, 0x01, 0x1c, + 0x98, 0x00, 0x14, 0x30, 0x00, 0x14, 0x70, 0x80, 0xf7, 0xe0, 0x81, 0x80, + 0x80, 0xff, 0xf7, 0x00, 0x7e, 0x14, 0x00, 0x00, 0x14, 0x00, 0x00, 0x1c }; diff --git a/xmdev/src/icons/refresh.xbm b/xmdev/src/icons/refresh.xbm new file mode 100644 index 0000000..ee33db9 --- /dev/null +++ b/xmdev/src/icons/refresh.xbm @@ -0,0 +1,9 @@ +#define refresh_width 24 +#define refresh_height 24 +static unsigned char refresh_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xc0, 0xff, 0x00, + 0xf0, 0xff, 0x03, 0xf8, 0xc0, 0x07, 0x38, 0x00, 0x07, 0x1c, 0x00, 0x0e, + 0x1c, 0x00, 0x0e, 0x0e, 0x00, 0x1c, 0x0e, 0x00, 0x1c, 0x0e, 0x00, 0x7f, + 0x0e, 0x00, 0x3e, 0x0e, 0x00, 0x1c, 0x0e, 0x00, 0x08, 0x1c, 0x00, 0x00, + 0x1c, 0x00, 0x06, 0x38, 0x00, 0x07, 0xf8, 0xc0, 0x07, 0xf0, 0xff, 0x03, + 0xc0, 0xff, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmdev/src/icons/unmount.xbm b/xmdev/src/icons/unmount.xbm new file mode 100644 index 0000000..a833cfa --- /dev/null +++ b/xmdev/src/icons/unmount.xbm @@ -0,0 +1,9 @@ +#define unmount_width 24 +#define unmount_height 24 +static unsigned char unmount_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x7e, 0x00, 0x00, 0xff, 0x00, + 0x80, 0xff, 0x01, 0xc0, 0xff, 0x03, 0xe0, 0xff, 0x07, 0xf0, 0xff, 0x0f, + 0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x1f, + 0xf8, 0xff, 0x1f, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/xmdev/src/main.c b/xmdev/src/main.c index 18bbed2..acb261c 100644 --- a/xmdev/src/main.c +++ b/xmdev/src/main.c @@ -1,8 +1,10 @@ #define _XOPEN_SOURCE #include +#include +#include #include -#include #include +#include #include #include @@ -19,6 +21,9 @@ #include #include +#include "icons/refresh.xbm" +#include "icons/mount.xbm" +#include "icons/unmount.xbm" #include "icons/generic.xbm" #include "icons/generic-small.xbm" #include "icons/icon.xbm" @@ -65,6 +70,7 @@ void DeviceSetMountPoint (Device *this, ConstString mountPoint); void DeviceSetLabel (Device *this, ConstString label); int readBlockDevice (FILE *stream, Device **); int readLsblkPair (FILE *stream, String *key, String *value); +void handleRefresh (Widget, XtPointer, XtPointer); int main (int argc, char *argv[]) { devices = XmdStringMapNew(); @@ -74,16 +80,74 @@ int main (int argc, char *argv[]) { NULL, 0, &argc, argv, NULL, - XmNtitle, "Devices", + XmNtitle, "Devices", XmNiconName, "Devices", + XmNwidth, 256, + XmNheight, 256, NULL); - Pixmap iconPixmap = XmdLoadBitmapIcon(window, icon); + + Widget layout = XtVaCreateWidget ( + "layout", xmFormWidgetClass, window, + XmNorientation, XmVERTICAL, + NULL); + Pixmap iconPixmap = XmdLoadBitmapIcon(layout, icon); XtVaSetValues ( window, XmNiconPixmap, iconPixmap, NULL); + + Pixmap refreshPixmap = XmdLoadBitmapIcon(layout, refresh); + XmString string = XmStringCreateLocalized("Refresh"); + Widget refreshButton = XtVaCreateManagedWidget ( + "refreshButton", xmPushButtonWidgetClass, layout, + XmNleftAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNlabelType, XmPIXMAP_AND_STRING, + XmNlabelPixmap, refreshPixmap, + XmNlabelString, string, + NULL); + XmStringFree(string); + XtAddCallback ( + refreshButton, XmNactivateCallback, + handleRefresh, NULL); + + Pixmap mountPixmap = XmdLoadBitmapIcon(layout, mount); + string = XmStringCreateLocalized("Mount"); + Widget mountButton = XtVaCreateManagedWidget ( + "mountButton", xmPushButtonWidgetClass, layout, + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, refreshButton, + XmNbottomAttachment, XmATTACH_FORM, + XmNlabelType, XmPIXMAP_AND_STRING, + XmNlabelPixmap, mountPixmap, + XmNlabelString, string, + NULL); + XmStringFree(string); + + Pixmap unmountPixmap = XmdLoadBitmapIcon(layout, unmount); + string = XmStringCreateLocalized("Unmount"); + /*Widget unmountButton = */XtVaCreateManagedWidget ( + "unmountButton", xmPushButtonWidgetClass, layout, + XmNleftAttachment, XmATTACH_WIDGET, + XmNleftWidget, mountButton, + XmNbottomAttachment, XmATTACH_FORM, + XmNlabelType, XmPIXMAP_AND_STRING, + XmNlabelPixmap, unmountPixmap, + XmNlabelString, string, + NULL); + XmStringFree(string); + + Widget scroller = XtVaCreateWidget ( + "scroll", xmScrolledWindowWidgetClass, layout, + XmNscrollingPolicy, XmAUTOMATIC, + XmNleftAttachment, XmATTACH_FORM, + XmNtopAttachment, XmATTACH_FORM, + XmNrightAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_WIDGET, + XmNbottomWidget, refreshButton, + NULL); container = XtVaCreateManagedWidget ( - "container", xmContainerWidgetClass, window, + "container", xmContainerWidgetClass, scroller, XmNlayoutType, XmSPATIAL, XmNspatialStyle, XmGRID, NULL); @@ -91,6 +155,8 @@ int main (int argc, char *argv[]) { loadIconPixmaps(); refreshDevices(); + XtManageChild(scroller); + XtManageChild(layout); XtRealizeWidget(window); XtAppMainLoop(application); } @@ -106,6 +172,13 @@ void loadIconPixmaps (void) { dev(TTY, tty); } +void handleRefresh (Widget button, XtPointer clientData, XtPointer callData) { + (void)(button); + (void)(clientData); + (void)(callData); + refreshDevices(); +} + Bool markDevice (XmdStringMap *map, ConstString key, void *value, void *data) { (void)(map); (void)(key);