1999-12-20 07:44:21 -08:00
|
|
|
/* E-Mountbox.h
|
|
|
|
*
|
2000-01-05 08:24:01 -08:00
|
|
|
* Copyright (C) 1999-2000 Christian Kreibich
|
1999-12-20 07:44:21 -08: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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
1999-11-09 04:34:40 -08:00
|
|
|
#include "epplet.h"
|
|
|
|
#include <math.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#define FSTAB "/etc/fstab"
|
|
|
|
#define PROCMOUNTS "/proc/mounts"
|
|
|
|
#define ETCMTAB "/etc/mtab"
|
|
|
|
#define MOUNT_CMD "/bin/mount"
|
|
|
|
#define UMOUNT_CMD "/bin/umount"
|
|
|
|
|
1999-12-13 09:38:52 -08:00
|
|
|
#define __BG_IMAGE EROOT"/epplet_data/E-Mountbox/E-Mountbox-bg.png"
|
|
|
|
#define __DEFAULT EROOT"/epplet_data/E-Mountbox/E-Mountbox-blockdev.png"
|
|
|
|
|
1999-11-09 04:34:40 -08:00
|
|
|
ConfigItem defaults[] = {
|
1999-11-24 15:36:51 -08:00
|
|
|
{"BG_IMAGE", EROOT"/epplet_data/E-Mountbox/E-Mountbox-bg.png"},
|
1999-12-13 09:38:52 -08:00
|
|
|
{"DEFAULT", EROOT"/epplet_data/E-Mountbox/E-Mountbox-blockdev.png"}
|
|
|
|
};
|
|
|
|
|
|
|
|
char *default_types[] = {
|
|
|
|
"cd "EROOT"/epplet_data/E-Mountbox/E-Mountbox-cd.png",
|
|
|
|
"fd "EROOT"/epplet_data/E-Mountbox/E-Mountbox-floppy.png",
|
|
|
|
"zip "EROOT"/epplet_data/E-Mountbox/E-Mountbox-zip.png",
|
|
|
|
"jazz "EROOT"/epplet_data/E-Mountbox/E-Mountbox-jazz.png"
|
1999-11-09 04:34:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _tile Tile;
|
1999-12-13 09:38:52 -08:00
|
|
|
typedef struct _mountpointtype MountPointType;
|
|
|
|
|
|
|
|
struct _mountpointtype
|
|
|
|
{
|
|
|
|
char *key;
|
|
|
|
char *imagefile;
|
|
|
|
ImlibImage *image;
|
|
|
|
MountPointType *next;
|
|
|
|
MountPointType *prev;
|
|
|
|
};
|
1999-11-09 04:34:40 -08:00
|
|
|
|
|
|
|
typedef struct _mountpoint
|
|
|
|
{
|
|
|
|
char *device;
|
|
|
|
char *path;
|
|
|
|
char mounted;
|
|
|
|
}
|
|
|
|
MountPoint;
|
|
|
|
|
|
|
|
struct _tile
|
|
|
|
{
|
|
|
|
ImlibImage *image;
|
|
|
|
MountPoint *mountpoint;
|
|
|
|
Tile *prev;
|
|
|
|
Tile *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
Tile *tiles = NULL;
|
|
|
|
Tile *current_tile = NULL;
|
|
|
|
int current_tile_index = 0;
|
|
|
|
int num_tiles = 0;
|
1999-12-13 09:38:52 -08:00
|
|
|
MountPointType *types = NULL;
|
|
|
|
int num_types = 0;
|
1999-11-09 04:34:40 -08:00
|
|
|
ImlibData *id = NULL;
|
1999-12-13 09:38:52 -08:00
|
|
|
ImlibImage *bg_image = NULL;
|
|
|
|
ImlibImage *default_image = NULL;
|
|
|
|
Epplet_gadget action_area, button_close, button_config, button_help;
|
|
|
|
|
|
|
|
/* stuff for the config win */
|
|
|
|
Epplet_gadget tbox_key, tbox_file, tbox_default, tbox_bg;
|
1999-12-27 11:57:37 -08:00
|
|
|
Epplet_gadget arrow_left, arrow_right, button_add, button_del, button_add_long;
|
|
|
|
Epplet_gadget label_key, label_file;
|
1999-12-13 09:38:52 -08:00
|
|
|
Window config_win = 0;
|
|
|
|
MountPointType *current_type = NULL;
|
|
|
|
|
1999-12-20 07:44:21 -08:00
|
|
|
RGB_buf window_buf = NULL;
|
|
|
|
RGB_buf widescreen_buf = NULL;
|
|
|
|
RGB_buf widescreen_canvas_buf = NULL;
|
1999-11-09 04:34:40 -08:00
|
|
|
char anim_mount = 0;
|
1999-11-16 16:18:31 -08:00
|
|
|
int is_shown = 0;
|
1999-11-09 04:34:40 -08:00
|
|
|
|
|
|
|
/* graphx handling */
|
|
|
|
int IsTransparent(ImlibImage * im, int x, int y);
|
|
|
|
void UpdateView(int dir, int fast);
|
|
|
|
void FreeImages(void);
|
1999-12-20 07:44:21 -08:00
|
|
|
void UpdateGraphics(void);
|
1999-12-27 11:57:37 -08:00
|
|
|
void ConfigShowMore(void);
|
|
|
|
void ConfigShowLess(void);
|
1999-11-09 04:34:40 -08:00
|
|
|
|
|
|
|
/* mount handling */
|
|
|
|
void SetupMounts(void);
|
|
|
|
void FreeMounts(void);
|
|
|
|
void AddMountPoint(char *device, char *path);
|
1999-12-13 09:38:52 -08:00
|
|
|
void FreeMountPointTypes(void);
|
1999-12-20 07:44:21 -08:00
|
|
|
void AddMountPointType(char *key, char *image);
|
|
|
|
void ModifyMountPointType(MountPointType *mpt, char *key, char *imagefile);
|
|
|
|
void DeleteMountPointType(MountPointType *mpt);
|
1999-11-09 04:34:40 -08:00
|
|
|
void Mount(MountPoint * mp);
|
|
|
|
void Umount(MountPoint * mp);
|
|
|
|
|
|
|
|
/* miscellaneous nitty gritty */
|
|
|
|
int ParseFstab(void);
|
|
|
|
int ParseProcMounts(void);
|
|
|
|
int ParseEtcMtab(void);
|
|
|
|
void VisitMountPoints(void);
|
|
|
|
MountPoint *FindMountPointByClick(int x, int y);
|
1999-12-20 07:44:21 -08:00
|
|
|
void SyncConfigs(void);
|
1999-11-09 04:34:40 -08:00
|
|
|
|
|
|
|
/* callbacks/ handlers */
|
1999-11-16 16:18:31 -08:00
|
|
|
/*
|
|
|
|
static void CallbackEnter(void *data, Window w);
|
|
|
|
static void CallbackLeave(void *data, Window w);
|
|
|
|
*/
|
1999-11-09 04:34:40 -08:00
|
|
|
static void CallbackExpose(void *data, Window win, int x, int y, int w, int h);
|
|
|
|
static void CallbackButtonUp(void *data, Window win, int x, int y, int b);
|
|
|
|
static void CallbackExit(void *data);
|
|
|
|
static void CallbackSlideLeft(void *data);
|
|
|
|
static void CallbackSlideRight(void *data);
|
|
|
|
static void CallbackAnimate(void *data);
|
|
|
|
static void CallbackHelp(void *data);
|
1999-11-16 16:18:31 -08:00
|
|
|
static void CallbackShowMore(void *data);
|
1999-12-13 09:38:52 -08:00
|
|
|
static void Callback_ConfigOK(void *data);
|
|
|
|
static void Callback_ConfigApply(void *data);
|
|
|
|
static void Callback_ConfigCancel(void *data);
|
|
|
|
static void Callback_DefaultChange(void *data);
|
|
|
|
static void Callback_BGChange(void *data);
|
1999-12-20 07:44:21 -08:00
|
|
|
static void Callback_TypeChange(void *data);
|
1999-12-13 09:38:52 -08:00
|
|
|
static void Callback_ConfigLeft(void *data);
|
|
|
|
static void Callback_ConfigRight(void *data);
|
1999-12-20 07:44:21 -08:00
|
|
|
static void Callback_ConfigAdd(void *data);
|
|
|
|
static void Callback_ConfigDel(void *data);
|
1999-11-09 04:34:40 -08:00
|
|
|
|
|
|
|
/* config stuff */
|
|
|
|
void SetupDefaults(void);
|
|
|
|
void SetupGraphx(void);
|