mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-11 17:04:15 +01:00
Add floppy button.
This commit is contained in:
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -199,6 +199,9 @@ typedef struct W_Screen {
|
||||
struct W_Pixmap *trashcanIcon;
|
||||
struct W_Pixmap *altTrashcanIcon;
|
||||
|
||||
struct W_Pixmap *disketteIcon;
|
||||
struct W_Pixmap *altDisketteIcon;
|
||||
|
||||
struct W_Pixmap *magnifyIcon;
|
||||
/* struct W_Pixmap *altMagnifyIcon;*/
|
||||
struct W_Pixmap *wheelIcon;
|
||||
|
||||
@@ -28,6 +28,7 @@ typedef struct W_FilePanel {
|
||||
|
||||
WMButton *homeButton;
|
||||
WMButton *trashcanButton;
|
||||
WMButton *disketteButton;
|
||||
|
||||
WMView *accessoryView;
|
||||
|
||||
@@ -69,6 +70,8 @@ static void deleteFile();
|
||||
|
||||
static void goHome();
|
||||
|
||||
static void goFloppy();
|
||||
|
||||
static void buttonClick();
|
||||
|
||||
static char *getCurrentFileName(WMFilePanel *panel);
|
||||
@@ -254,8 +257,16 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
WMSetButtonImagePosition(fPtr->trashcanButton, WIPImageOnly);
|
||||
WMSetButtonImage(fPtr->trashcanButton, scrPtr->trashcanIcon);
|
||||
WMSetButtonAltImage(fPtr->trashcanButton, scrPtr->altTrashcanIcon);
|
||||
|
||||
WMSetButtonAction(fPtr->trashcanButton, deleteFile, fPtr);
|
||||
|
||||
fPtr->disketteButton = WMCreateCommandButton(fPtr->win);
|
||||
WMMoveWidget(fPtr->disketteButton, 85, 325);
|
||||
WMResizeWidget(fPtr->disketteButton, 28, 28);
|
||||
WMSetButtonImagePosition(fPtr->disketteButton, WIPImageOnly);
|
||||
WMSetButtonImage(fPtr->disketteButton, scrPtr->disketteIcon);
|
||||
WMSetButtonAltImage(fPtr->disketteButton, scrPtr->altDisketteIcon);
|
||||
WMSetButtonAction(fPtr->disketteButton, goFloppy, fPtr);
|
||||
|
||||
/*xxxxxxxxxxxx***/
|
||||
|
||||
WMRealizeWidget(fPtr->win);
|
||||
@@ -586,7 +597,7 @@ browserClick(WMBrowser *bPtr, WMFilePanel *panel)
|
||||
#define ERROR_PANEL(s) err_str = wmalloc(strlen(file)+strlen(s)); \
|
||||
sprintf(err_str, s, file); \
|
||||
WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, \
|
||||
"Error", err_str, "OK", NULL, NULL);
|
||||
"Error", err_str, "OK", NULL, NULL);
|
||||
|
||||
static void
|
||||
deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||
@@ -618,7 +629,7 @@ deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||
ERROR_PANEL("%s does not exist.");
|
||||
break;
|
||||
case EACCES:
|
||||
ERROR_PANEL("Has no right to access %s.");
|
||||
ERROR_PANEL("Permission denied.");
|
||||
break;
|
||||
case ENOMEM:
|
||||
ERROR_PANEL("Insufficient kernel memory was available.");
|
||||
@@ -641,6 +652,26 @@ deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||
free(file);
|
||||
}
|
||||
|
||||
static void
|
||||
goFloppy(WMButton *bPtr, WMFilePanel *panel)
|
||||
{
|
||||
char *file, *err_str;
|
||||
struct stat filestat;
|
||||
|
||||
/* home is statically allocated. Don't free it! */
|
||||
if (stat("/floppy",&filestat)) {
|
||||
ERROR_PANEL("An error occured browsing /floppy.");
|
||||
free(err_str);
|
||||
return;
|
||||
} else if (!S_ISDIR(filestat.st_mode)) {
|
||||
ERROR_PANEL("/floppy is not a directory.");
|
||||
free(err_str);
|
||||
return;
|
||||
}
|
||||
|
||||
WMSetFilePanelDirectory(panel, "/floppy/");
|
||||
}
|
||||
|
||||
static void
|
||||
goHome(WMButton *bPtr, WMFilePanel *panel)
|
||||
{
|
||||
|
||||
@@ -435,6 +435,15 @@ loadPixmaps(WMScreen *scr)
|
||||
RCombineImageWithColor(tmp, &white);
|
||||
scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||
RDestroyImage(tmp);
|
||||
/* diskette */
|
||||
tmp = RGetSubImage(image, 105, 25, 24, 24);
|
||||
RCombineImageWithColor(tmp, &white);
|
||||
scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||
RDestroyImage(tmp);
|
||||
tmp = RGetSubImage(image, 105, 25, 24, 24);
|
||||
RCombineImageWithColor(tmp, &white);
|
||||
scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||
RDestroyImage(tmp);
|
||||
|
||||
|
||||
tmp = RGetSubImage(image, 0, 0, 24, 24);
|
||||
|
||||
Reference in New Issue
Block a user