Files
wmaker/WPrefs.app/imagebrowser.c
T

144 lines
3.4 KiB
C
Raw Normal View History

2000-05-23 21:18:49 +00:00
/* imagebrowser.c- image browser widget
2004-10-12 21:28:27 +00:00
*
2000-05-23 21:18:49 +00:00
* WPrefs - Window Maker Preferences Program
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (c) 2000-2003 Alfredo K. Kojima
2004-10-12 21:28:27 +00:00
*
2000-05-23 21:18:49 +00:00
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2004-10-12 21:28:27 +00:00
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2000-05-23 21:18:49 +00:00
* USA.
*/
#define FOR_WPREFS
#ifdef FOR_WPREFS
2009-08-20 00:59:40 +02:00
# include "WPrefs.h" /* only for _() */
2000-05-23 21:18:49 +00:00
#else
# define _(a) a
#endif
#include <WINGs/WINGs.h>
#include <WINGs/WINGsP.h>
2000-05-23 21:18:49 +00:00
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include "imagebrowser.h"
struct _ImageBrowser {
2009-08-20 00:59:40 +02:00
WMWindow *win;
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
WMPopUpButton *pathP;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMScrollView *sview;
WMFrame *frame;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMWidget *auxWidget;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMButton *viewBtn;
WMButton *okBtn;
WMButton *cancelBtn;
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
WMSize maxPreviewSize;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
ImageBrowserDelegate *delegate;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMArray *previews;
2000-05-23 21:18:49 +00:00
};
#define DEFAULT_WIDTH 300
#define DEFAULT_HEIGHT 200
2009-08-20 00:59:40 +02:00
ImageBrowser *CreateImageBrowser(WMScreen * scr, char *title, char **paths, int pathN,
WMSize * maxSize, WMWidget * auxWidget)
2000-05-23 21:18:49 +00:00
{
2009-08-20 00:59:40 +02:00
ImageBrowser *br;
int i;
int h;
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
br = wmalloc(sizeof(ImageBrowser));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
br->win = WMCreateWindow(scr, "imageBrowser");
WMResizeWidget(br->win, DEFAULT_WIDTH, DEFAULT_HEIGHT);
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
br->pathP = WMCreatePopUpButton(br->win);
WMMoveWidget(br->pathP, (DEFAULT_WIDTH - 80) / 2, 10);
WMResizeWidget(br->pathP, DEFAULT_WIDTH - 80, 20);
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
for (i = 0; i < pathN; i++) {
WMAddPopUpButtonItem(br->pathP, paths[i]);
}
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
br->viewBtn = WMCreateCommandButton(br->win);
WMSetButtonText(br->viewBtn, _("View"));
WMResizeWidget(br->viewBtn, 80, 24);
WMMoveWidget(br->viewBtn, 10, DEFAULT_HEIGHT - 29);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
br->cancelBtn = WMCreateCommandButton(br->win);
WMSetButtonText(br->cancelBtn, _("Cancel"));
WMResizeWidget(br->cancelBtn, 80, 24);
WMMoveWidget(br->cancelBtn, DEFAULT_WIDTH - 10 - 80, DEFAULT_HEIGHT - 29);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
br->okBtn = WMCreateCommandButton(br->win);
WMSetButtonText(br->okBtn, _("OK"));
WMResizeWidget(br->okBtn, 80, 24);
WMMoveWidget(br->okBtn, DEFAULT_WIDTH - 10 - 160 - 5, DEFAULT_HEIGHT - 29);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
br->auxWidget = auxWidget;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
h = DEFAULT_HEIGHT - 20 /* top and bottom spacing */
- 25 /* popup menu and spacing */
- 29; /* button row and spacing */
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (auxWidget != NULL) {
h -= WMWidgetHeight(auxWidget) + 5;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
W_ReparentView(WMWidgetView(auxWidget), WMWidgetView(br->win), 10, 10 + 25 + h + 5);
}
2000-05-23 21:18:49 +00:00
2009-08-20 00:59:40 +02:00
br->sview = WMCreateScrollView(br->win);
WMResizeWidget(br->sview, DEFAULT_WIDTH - 20, h);
WMMoveWidget(br->sview, 10, 5 + 20 + 5);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMMapSubwidgets(br->win);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
return br;
2000-05-23 21:18:49 +00:00
}
2009-08-20 00:59:40 +02:00
void ShowImageBrowser(ImageBrowser * browser)
2000-05-23 21:18:49 +00:00
{
2009-08-20 00:59:40 +02:00
WMMapWidget(browser->win);
2000-05-23 21:18:49 +00:00
}
2009-08-20 00:59:40 +02:00
void CloseImageBrowser(ImageBrowser * browser)
2000-05-23 21:18:49 +00:00
{
2009-08-20 00:59:40 +02:00
WMUnmapWidget(browser->win);
2000-05-23 21:18:49 +00:00
}
2009-08-20 00:59:40 +02:00
void SetImageBrowserPathList(ImageBrowser * browser, char **paths, int pathN)
2000-05-23 21:18:49 +00:00
{
}
2009-08-20 00:59:40 +02:00
void SetImageBrowserDelegate(ImageBrowser * browser, ImageBrowserDelegate * delegate)
2000-05-23 21:18:49 +00:00
{
2004-10-12 21:28:27 +00:00
2000-05-23 21:18:49 +00:00
}
2009-08-20 00:59:40 +02:00
void DestroyImageBrowser(ImageBrowser * browser)
2000-05-23 21:18:49 +00:00
{
2009-08-20 00:59:40 +02:00
WMDestroyWidget(browser->win);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
/**/ wfree(browser);
2000-05-23 21:18:49 +00:00
}