Added more things to xmdev i think

This commit is contained in:
Sasha Koshka 2024-01-17 21:48:01 -05:00
parent 318e35242d
commit d14b748536
4 changed files with 104 additions and 4 deletions

View File

@ -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 };

View File

@ -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 };

View File

@ -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 };

View File

@ -1,8 +1,10 @@
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#include <Xm/Xm.h> #include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/MainW.h> #include <Xm/MainW.h>
#include <Xm/Container.h>
#include <Xm/IconG.h> #include <Xm/IconG.h>
#include <Xm/Container.h>
#include <Xm/ScrolledW.h> #include <Xm/ScrolledW.h>
#include <Xmd/Icon.h> #include <Xmd/Icon.h>
@ -19,6 +21,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "icons/refresh.xbm"
#include "icons/mount.xbm"
#include "icons/unmount.xbm"
#include "icons/generic.xbm" #include "icons/generic.xbm"
#include "icons/generic-small.xbm" #include "icons/generic-small.xbm"
#include "icons/icon.xbm" #include "icons/icon.xbm"
@ -65,6 +70,7 @@ void DeviceSetMountPoint (Device *this, ConstString mountPoint);
void DeviceSetLabel (Device *this, ConstString label); void DeviceSetLabel (Device *this, ConstString label);
int readBlockDevice (FILE *stream, Device **); int readBlockDevice (FILE *stream, Device **);
int readLsblkPair (FILE *stream, String *key, String *value); int readLsblkPair (FILE *stream, String *key, String *value);
void handleRefresh (Widget, XtPointer, XtPointer);
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
devices = XmdStringMapNew(); devices = XmdStringMapNew();
@ -74,16 +80,74 @@ int main (int argc, char *argv[]) {
NULL, 0, NULL, 0,
&argc, argv, &argc, argv,
NULL, NULL,
XmNtitle, "Devices", XmNtitle, "Devices",
XmNiconName, "Devices", XmNiconName, "Devices",
XmNwidth, 256,
XmNheight, 256,
NULL); NULL);
Pixmap iconPixmap = XmdLoadBitmapIcon(window, icon);
Widget layout = XtVaCreateWidget (
"layout", xmFormWidgetClass, window,
XmNorientation, XmVERTICAL,
NULL);
Pixmap iconPixmap = XmdLoadBitmapIcon(layout, icon);
XtVaSetValues ( XtVaSetValues (
window, window,
XmNiconPixmap, iconPixmap, XmNiconPixmap, iconPixmap,
NULL); 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 = XtVaCreateManagedWidget (
"container", xmContainerWidgetClass, window, "container", xmContainerWidgetClass, scroller,
XmNlayoutType, XmSPATIAL, XmNlayoutType, XmSPATIAL,
XmNspatialStyle, XmGRID, XmNspatialStyle, XmGRID,
NULL); NULL);
@ -91,6 +155,8 @@ int main (int argc, char *argv[]) {
loadIconPixmaps(); loadIconPixmaps();
refreshDevices(); refreshDevices();
XtManageChild(scroller);
XtManageChild(layout);
XtRealizeWidget(window); XtRealizeWidget(window);
XtAppMainLoop(application); XtAppMainLoop(application);
} }
@ -106,6 +172,13 @@ void loadIconPixmaps (void) {
dev(TTY, tty); 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) { Bool markDevice (XmdStringMap *map, ConstString key, void *value, void *data) {
(void)(map); (void)(map);
(void)(key); (void)(key);