mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
Delete button in file panel.
This commit is contained in:
@@ -196,6 +196,9 @@ typedef struct W_Screen {
|
|||||||
struct W_Pixmap *homeIcon;
|
struct W_Pixmap *homeIcon;
|
||||||
struct W_Pixmap *altHomeIcon;
|
struct W_Pixmap *altHomeIcon;
|
||||||
|
|
||||||
|
struct W_Pixmap *trashcanIcon;
|
||||||
|
struct W_Pixmap *altTrashcanIcon;
|
||||||
|
|
||||||
struct W_Pixmap *magnifyIcon;
|
struct W_Pixmap *magnifyIcon;
|
||||||
/* struct W_Pixmap *altMagnifyIcon;*/
|
/* struct W_Pixmap *altMagnifyIcon;*/
|
||||||
struct W_Pixmap *wheelIcon;
|
struct W_Pixmap *wheelIcon;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ typedef struct W_FilePanel {
|
|||||||
WMButton *cancelButton;
|
WMButton *cancelButton;
|
||||||
|
|
||||||
WMButton *homeButton;
|
WMButton *homeButton;
|
||||||
|
WMButton *trashcanButton;
|
||||||
|
|
||||||
WMView *accessoryView;
|
WMView *accessoryView;
|
||||||
|
|
||||||
@@ -63,6 +64,8 @@ static void browserDClick();
|
|||||||
static void fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column,
|
static void fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column,
|
||||||
WMList *list);
|
WMList *list);
|
||||||
|
|
||||||
|
static void deleteFile();
|
||||||
|
|
||||||
static void goHome();
|
static void goHome();
|
||||||
|
|
||||||
static void buttonClick();
|
static void buttonClick();
|
||||||
@@ -244,6 +247,16 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
|||||||
WMSetButtonAltImage(fPtr->homeButton, scrPtr->altHomeIcon);
|
WMSetButtonAltImage(fPtr->homeButton, scrPtr->altHomeIcon);
|
||||||
WMSetButtonAction(fPtr->homeButton, goHome, fPtr);
|
WMSetButtonAction(fPtr->homeButton, goHome, fPtr);
|
||||||
|
|
||||||
|
fPtr->trashcanButton = WMCreateCommandButton(fPtr->win);
|
||||||
|
WMMoveWidget(fPtr->trashcanButton, 25, 325);
|
||||||
|
WMResizeWidget(fPtr->trashcanButton, 28, 28);
|
||||||
|
WMSetButtonImagePosition(fPtr->trashcanButton, WIPImageOnly);
|
||||||
|
WMSetButtonImage(fPtr->trashcanButton, scrPtr->trashcanIcon);
|
||||||
|
WMSetButtonAltImage(fPtr->trashcanButton, scrPtr->altTrashcanIcon);
|
||||||
|
|
||||||
|
WMSetButtonAction(fPtr->trashcanButton, deleteFile, fPtr);
|
||||||
|
/*xxxxxxxxxxxx***/
|
||||||
|
|
||||||
WMRealizeWidget(fPtr->win);
|
WMRealizeWidget(fPtr->win);
|
||||||
WMMapSubwidgets(fPtr->win);
|
WMMapSubwidgets(fPtr->win);
|
||||||
|
|
||||||
@@ -569,6 +582,63 @@ 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);
|
||||||
|
|
||||||
|
static void
|
||||||
|
deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||||
|
{
|
||||||
|
char *file;
|
||||||
|
char *buffer;
|
||||||
|
char *err_str;
|
||||||
|
|
||||||
|
WMFilePanel *deletePanel;
|
||||||
|
|
||||||
|
file = getCurrentFileName(panel);
|
||||||
|
if (file[strlen(file)-1] == '/') {
|
||||||
|
ERROR_PANEL("%s is a directory.");
|
||||||
|
free(err_str);
|
||||||
|
free(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buffer = wmalloc(strlen(file)+15);
|
||||||
|
sprintf(buffer,"Delete file %s ?\x0",file);
|
||||||
|
if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
||||||
|
"Warning", buffer, "OK", "Cancel", NULL)) {
|
||||||
|
int rem_stat;
|
||||||
|
if (rem_stat = remove(file)) {
|
||||||
|
switch (errno) {
|
||||||
|
case EISDIR:
|
||||||
|
ERROR_PANEL("%s is a directory.");
|
||||||
|
break;
|
||||||
|
case ENOENT:
|
||||||
|
ERROR_PANEL("%s does not exist.");
|
||||||
|
break;
|
||||||
|
case EACCES:
|
||||||
|
ERROR_PANEL("Has no right to access %s.");
|
||||||
|
break;
|
||||||
|
case ENOMEM:
|
||||||
|
ERROR_PANEL("Insufficient kernel memory was available.");
|
||||||
|
break;
|
||||||
|
case EROFS:
|
||||||
|
ERROR_PANEL("%s refers to a file on a read-only filesystem.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERROR_PANEL("Can not delete %s.");
|
||||||
|
}
|
||||||
|
free(err_str);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char *s = strrchr(file,'/');
|
||||||
|
if (s) s[1] = 0;
|
||||||
|
WMSetFilePanelDirectory(panel, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(buffer);
|
||||||
|
free(file);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
goHome(WMButton *bPtr, WMFilePanel *panel)
|
goHome(WMButton *bPtr, WMFilePanel *panel)
|
||||||
@@ -609,6 +679,7 @@ handleEvents(XEvent *event, void *data)
|
|||||||
WMMoveWidget(pPtr->cancelButton, newWidth-(PWIDTH-140),
|
WMMoveWidget(pPtr->cancelButton, newWidth-(PWIDTH-140),
|
||||||
newHeight-(PHEIGHT-325));
|
newHeight-(PHEIGHT-325));
|
||||||
WMMoveWidget(pPtr->homeButton, 55, newHeight-(PHEIGHT-325));
|
WMMoveWidget(pPtr->homeButton, 55, newHeight-(PHEIGHT-325));
|
||||||
|
WMMoveWidget(pPtr->trashcanButton, 25, newHeight-(PHEIGHT-325));
|
||||||
|
|
||||||
newColumnCount = (newWidth - 14) / 140;
|
newColumnCount = (newWidth - 14) / 140;
|
||||||
WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount);
|
WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount);
|
||||||
|
|||||||
@@ -426,6 +426,22 @@ loadPixmaps(WMScreen *scr)
|
|||||||
scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||||
RDestroyImage(tmp);
|
RDestroyImage(tmp);
|
||||||
|
|
||||||
|
/* trash can */
|
||||||
|
tmp = RGetSubImage(image, 105, 0, 24, 24);
|
||||||
|
RCombineImageWithColor(tmp, &white);
|
||||||
|
scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||||
|
RDestroyImage(tmp);
|
||||||
|
tmp = RGetSubImage(image, 105, 0, 24, 24);
|
||||||
|
RCombineImageWithColor(tmp, &white);
|
||||||
|
scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||||
|
RDestroyImage(tmp);
|
||||||
|
|
||||||
|
|
||||||
|
tmp = RGetSubImage(image, 0, 0, 24, 24);
|
||||||
|
RCombineImageWithColor(tmp, &white);
|
||||||
|
scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
|
||||||
|
RDestroyImage(tmp);
|
||||||
|
|
||||||
/* Magnifying Glass Icon for ColorPanel */
|
/* Magnifying Glass Icon for ColorPanel */
|
||||||
tmp = RGetSubImage(image, 24, 0, 40, 32);
|
tmp = RGetSubImage(image, 24, 0, 40, 32);
|
||||||
RCombineImageWithColor(tmp, &gray);
|
RCombineImageWithColor(tmp, &gray);
|
||||||
|
|||||||
Reference in New Issue
Block a user