Simplify dialog data handling.

This commit is contained in:
Kim Woelders 2014-04-25 23:07:58 +02:00
parent 5fc86cc6ad
commit 23872b2cac
18 changed files with 77 additions and 149 deletions

View File

@ -58,8 +58,8 @@ _DlgFillAbout(Dialog * d, DItem * table, void *data __UNUSED__)
static const DialogDef DlgAbout = {
"ABOUT_ENLIGHTENMENT",
NULL,
NULL,
NULL, NULL,
0,
SOUND_NONE,
NULL,
NULL,

View File

@ -1946,17 +1946,13 @@ CB_InitView(DItem * di, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillBackground(Dialog * d, DItem * table, void *data)
{
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
Background *bg = (Background *) data;
DItem *di, *table2, *table3, *label;
int i, num;
char s[1024];
int mini_w = Mode.backgrounds.mini_w;
int mini_h = Mode.backgrounds.mini_h;
BgDlgData *dd;
dd = DLG_DATA_SET(d, BgDlgData);
if (!dd)
return;
if (!Conf.backgrounds.no_scan)
ScanBackgroundMenu();
@ -2222,8 +2218,8 @@ _DlgFillBackground(Dialog * d, DItem * table, void *data)
const DialogDef DlgBackground = {
"CONFIGURE_BG",
N_("Background"),
N_("Desktop Background Settings"),
N_("Background"), N_("Desktop Background Settings"),
sizeof(BgDlgData),
SOUND_SETTINGS_BG,
"pix/bg.png",
N_("Enlightenment Desktop\n" "Background Settings Dialog"),

View File

@ -1505,15 +1505,11 @@ CB_IconSizeSlider(Dialog * d, int val __UNUSED__, void *data)
static void
_DlgFillContainer(Dialog * d, DItem * table, void *data)
{
ContainerDlgData *dd;
ContainerDlgData *dd = DLG_DATA_GET(d, ContainerDlgData);
Container *ct = (Container *) data;
DItem *di, *table2, *radio, *label;
char s[256];
dd = DLG_DATA_SET(d, ContainerDlgData);
if (!dd)
return;
if (!ct)
return;
@ -1729,8 +1725,8 @@ _DlgFillContainer(Dialog * d, DItem * table, void *data)
static const DialogDef DlgContainer = {
"CONFIGURE_ICONBOX",
NULL,
NULL,
NULL, NULL,
sizeof(ContainerDlgData),
SOUND_SETTINGS_ICONBOX,
"pix/iconbox.png",
N_("Enlightenment Iconbox\n" "Settings Dialog"),

View File

@ -2462,12 +2462,8 @@ CB_DesktopDisplayAreaRedraw(DItem * di, int val __UNUSED__,
static void
_DlgFillDesks(Dialog * d, DItem * table, void *data __UNUSED__)
{
DeskDlgData *dd = DLG_DATA_GET(d, DeskDlgData);
DItem *di, *slider, *radio;
DeskDlgData *dd;
dd = DLG_DATA_SET(d, DeskDlgData);
if (!dd)
return;
dd->desktops = Conf.desks.num;
dd->prev_desktops = -1;
@ -2574,8 +2570,8 @@ _DlgFillDesks(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgDesks = {
"CONFIGURE_DESKTOPS",
N_("Desks"),
N_("Multiple Desktop Settings"),
N_("Desks"), N_("Multiple Desktop Settings"),
sizeof(DeskDlgData),
SOUND_SETTINGS_DESKTOPS,
"pix/desktops.png",
N_("Enlightenment Multiple Desktop\n" "Settings Dialog"),
@ -2659,12 +2655,8 @@ CB_AreaDisplayAreaRedraw(DItem * di, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillAreas(Dialog * d, DItem * table, void *data __UNUSED__)
{
AreaDlgData *dd = DLG_DATA_GET(d, AreaDlgData);
DItem *di, *slider, *slider2, *table2, *radio;
AreaDlgData *dd;
dd = DLG_DATA_SET(d, AreaDlgData);
if (!dd)
return;
dd->area_wraparound = Conf.desks.areas_wraparound;
@ -2750,8 +2742,8 @@ _DlgFillAreas(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgAreas = {
"CONFIGURE_AREA",
N_("Areas"),
N_("Virtual Desktop Settings"),
N_("Areas"), N_("Virtual Desktop Settings"),
sizeof(AreaDlgData),
SOUND_SETTINGS_AREA,
"pix/areas.png",
N_("Enlightenment Virtual Desktop\n" "Settings Dialog"),

View File

@ -150,6 +150,8 @@ typedef struct {
void *data;
} DKeyBind;
#define DD_SIZE 800 /* Extra dialog data size */
struct _dialog {
dlist_t list;
EWin *ewin;
@ -164,7 +166,6 @@ struct _dialog {
DialogExitFunc *exit_func;
int num_bindings;
DKeyBind *keybindings;
void *data;
char redraw;
char update;
@ -172,6 +173,7 @@ struct _dialog {
char close;
char set_title;
int xu1, yu1, xu2, yu2;
int dd[DD_SIZE / sizeof(int)];
};
static EWin *FindEwinByDialog(Dialog * d);
@ -249,7 +251,6 @@ DialogDestroy(Dialog * d)
Efree(d->name);
Efree(d->title);
Efree(d->data);
DialogKeybindingsDestroy(d);
if (d->item)
DialogItemDestroy(d->item, 0);
@ -294,17 +295,10 @@ DialogCallExitFunction(Dialog * d)
d->exit_func(d);
}
void *
DialogDataSet(Dialog * d, unsigned int size)
{
d->data = Ecalloc(size, 1);
return d->data;
}
void *
DialogDataGet(Dialog * d)
{
return d->data;
return d->dd;
}
DItem *
@ -507,10 +501,9 @@ DialogFill(Dialog * d, DItem * parent, const DialogDef * dd, void *data)
if (!content)
return;
Efree(d->data);
d->data = NULL;
dd->fill(d, content, data);
memset(d->dd, 0, dd->dd_size);
if (dd->dd_size <= DD_SIZE)
dd->fill(d, content, data);
if (dd->func_apply)
DialogAddFooter(d, parent, dd->flags, dd->func_apply);

View File

@ -66,7 +66,8 @@ typedef struct {
const char *name;
const char *label;
const char *title;
int sound;
unsigned short dd_size;
short sound;
const char *header_image;
const char *header_text;
void (*fill) (Dialog * d, DItem * table, void *data);
@ -85,10 +86,8 @@ void DialogSetTitle(Dialog * d, const char *title);
void DialogSetExitFunction(Dialog * d, DialogExitFunc * func);
void DialogCallExitFunction(Dialog * d);
void *DialogDataSet(Dialog * d, unsigned int size);
void *DialogDataGet(Dialog * d);
#define DLG_DATA_SET(dlg, type) (type*)DialogDataSet(dlg, sizeof(type))
#define DLG_DATA_GET(dlg, type) (type*)DialogDataGet(dlg)
void DialogShow(Dialog * d);

View File

@ -787,12 +787,8 @@ _DlgApplyFocus(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillFocus(Dialog * d, DItem * table, void *data __UNUSED__)
{
FocusDlgData *dd = DLG_DATA_GET(d, FocusDlgData);
DItem *di, *radio, *radio2;
FocusDlgData *dd;
dd = DLG_DATA_SET(d, FocusDlgData);
if (!dd)
return;
dd->focus.mode = Conf.focus.mode;
dd->focus.clickalways = Conf.focus.clickraises;
@ -991,8 +987,8 @@ _DlgFillFocus(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgFocus = {
"CONFIGURE_FOCUS",
N_("Focus"),
N_("Focus Settings"),
N_("Focus"), N_("Focus Settings"),
sizeof(FocusDlgData),
SOUND_SETTINGS_FOCUS,
"pix/focus.png",
N_("Enlightenment Focus\n" "Settings Dialog"),

View File

@ -465,8 +465,8 @@ _DlgFillFx(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgFx = {
"CONFIGURE_FX",
N_("FX"),
N_("Special FX Settings"),
N_("FX"), N_("Special FX Settings"),
0,
SOUND_SETTINGS_FX,
"pix/fx.png",
N_("Enlightenment Special Effects\n" "Settings Dialog"),

View File

@ -660,14 +660,10 @@ GroupCallback(Dialog * d, int val, void *data __UNUSED__)
static void
_DlgFillGroupChoose(Dialog * d, DItem * table, void *data)
{
GroupSelDlgData *dd = DLG_DATA_GET(d, GroupSelDlgData);
DItem *di, *radio;
int i, num_groups;
char **group_member_strings;
GroupSelDlgData *dd;
dd = DLG_DATA_SET(d, GroupSelDlgData);
if (!dd)
return;
*dd = *(GroupSelDlgData *) data;
@ -702,8 +698,8 @@ _DlgFillGroupChoose(Dialog * d, DItem * table, void *data)
static const DialogDef DlgGroupChoose = {
"GROUP_SELECTION",
NULL,
N_("Window Group Selection"),
NULL, N_("Window Group Selection"),
sizeof(GroupSelDlgData),
SOUND_SETTINGS_GROUP,
"pix/group.png",
N_("Enlightenment Window Group\n" "Selection Dialog"),
@ -836,15 +832,11 @@ GroupSelectCallback(Dialog * d, int val, void *data __UNUSED__)
static void
_DlgFillGroups(Dialog * d, DItem * table, void *data)
{
EwinGroupDlgData *dd = DLG_DATA_GET(d, EwinGroupDlgData);
EWin *ewin = (EWin *) data;
DItem *radio, *di;
int i;
char **group_member_strings;
EwinGroupDlgData *dd;
dd = DLG_DATA_SET(d, EwinGroupDlgData);
if (!dd)
return;
dd->ewin = ewin;
dd->cfgs = EMALLOC(GroupConfig, ewin->num_groups);
@ -931,8 +923,8 @@ _DlgFillGroups(Dialog * d, DItem * table, void *data)
static const DialogDef DlgGroups = {
"CONFIGURE_GROUP",
NULL,
N_("Window Group Settings"),
NULL, N_("Window Group Settings"),
sizeof(EwinGroupDlgData),
SOUND_SETTINGS_GROUP,
"pix/group.png",
N_("Enlightenment Window Group\n" "Settings Dialog"),
@ -978,12 +970,8 @@ _DlgApplyGroupDefaults(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillGroupDefaults(Dialog * d, DItem * table, void *data __UNUSED__)
{
GroupCfgDlgData *dd = DLG_DATA_GET(d, GroupCfgDlgData);
DItem *di;
GroupCfgDlgData *dd;
dd = DLG_DATA_SET(d, GroupCfgDlgData);
if (!dd)
return;
dd->group_cfg = Conf_groups.dflt;
dd->group_swap = Conf_groups.swapmove;
@ -1049,8 +1037,8 @@ _DlgFillGroupDefaults(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgGroupDefaults = {
"CONFIGURE_DEFAULT_GROUP_CONTROL",
N_("Groups"),
N_("Default Group Control Settings"),
N_("Groups"), N_("Default Group Control Settings"),
sizeof(GroupCfgDlgData),
SOUND_SETTINGS_GROUP,
"pix/group.png",
N_("Enlightenment Default\n" "Group Control Settings Dialog"),

View File

@ -1969,12 +1969,8 @@ _DlgCbIconSize(Dialog * d, int val __UNUSED__, void *data)
static void
_DlgFillMenus(Dialog * d, DItem * table, void *data __UNUSED__)
{
MenudDlgData *dd = DLG_DATA_GET(d, MenudDlgData);
DItem *di, *label;
MenudDlgData *dd;
dd = DLG_DATA_SET(d, MenudDlgData);
if (!dd)
return;
dd->warp = Conf.menus.warp;
dd->animate = Conf.menus.animate;
@ -2012,8 +2008,8 @@ _DlgFillMenus(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgMenus = {
"CONFIGURE_MENUS",
N_("Menus"),
N_("Menu Settings"),
N_("Menus"), N_("Menu Settings"),
sizeof(MenudDlgData),
SOUND_SETTINGS_MENUS,
"pix/place.png",
N_("Enlightenment Menu\n" "Settings Dialog"),

View File

@ -110,14 +110,10 @@ CB_ThemeTransparency(Dialog * d, int val __UNUSED__, void *data)
static void
_DlgFillThemeTrans(Dialog * d, DItem * table, void *data __UNUSED__)
{
TransDlgData *dd = DLG_DATA_GET(d, TransDlgData);
DItem *di, *label;
DItem *radio_border, *radio_widget, *radio_menu,
*radio_dialog, *radio_tooltip, *radio_hilight;
TransDlgData *dd;
dd = DLG_DATA_SET(d, TransDlgData);
if (!dd)
return;
dd->st_border = Conf.trans.border;
dd->st_widget = Conf.trans.widget;
@ -257,8 +253,8 @@ _DlgFillThemeTrans(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgThemeTrans = {
"CONFIGURE_TRANS",
N_("Transparency"),
N_("Selective Transparency Settings"),
N_("Transparency"), N_("Selective Transparency Settings"),
sizeof(TransDlgData),
SOUND_SETTINGS_TRANS,
"pix/tips.png",
N_("Enlightenment Selective Transparency\n" "Settings Dialog"),

View File

@ -1774,7 +1774,7 @@ _DlgApplyPagers(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
}
static void
CB_PagerScanSlide(Dialog * d __UNUSED__, int val __UNUSED__, void *data)
CB_PagerScanSlide(Dialog * d, int val __UNUSED__, void *data)
{
PagerDlgData *dd = DLG_DATA_GET(d, PagerDlgData);
DItem *di = (DItem *) data;
@ -1788,13 +1788,9 @@ CB_PagerScanSlide(Dialog * d __UNUSED__, int val __UNUSED__, void *data)
static void
_DlgFillPagers(Dialog * d, DItem * table, void *data __UNUSED__)
{
PagerDlgData *dd = DLG_DATA_GET(d, PagerDlgData);
DItem *di, *radio, *label;
char s[256];
PagerDlgData *dd;
dd = DLG_DATA_SET(d, PagerDlgData);
if (!dd)
return;
dd->show_pagers = Conf_pagers.enable;
dd->pager_hiq = Conf_pagers.hiq;
@ -1965,8 +1961,8 @@ _DlgFillPagers(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgPagers = {
"CONFIGURE_PAGER",
N_("Pagers"),
N_("Pager Settings"),
N_("Pagers"), N_("Pager Settings"),
sizeof(PagerDlgData),
SOUND_SETTINGS_PAGER,
"pix/pager.png",
N_("Enlightenment Desktop & Area\n" "Pager Settings Dialog"),

View File

@ -795,8 +795,8 @@ _DlgFillSession(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgSession = {
"CONFIGURE_SESSION",
N_("Session"),
N_("Session Settings"),
N_("Session"), N_("Session Settings"),
0,
SOUND_SETTINGS_SESSION,
"pix/miscellaneous.png",
N_("Enlightenment Session\n" "Settings Dialog"),

View File

@ -61,14 +61,10 @@ _DlgApplyMoveResize(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
}
static void
_DlgFillMoveResize(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
_DlgFillMoveResize(Dialog * d, DItem * table, void *data __UNUSED__)
{
MovResDlgData *dd = DLG_DATA_GET(d, MovResDlgData);
DItem *di, *radio1, *radio2, *radio3, *radio4;
MovResDlgData *dd;
dd = DLG_DATA_SET(d, MovResDlgData);
if (!dd)
return;
dd->move = Conf.movres.mode_move;
dd->resize = Conf.movres.mode_resize;
@ -240,8 +236,8 @@ _DlgFillMoveResize(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgMoveResize = {
"CONFIGURE_MOVERESIZE",
N_("Move/Resize"),
N_("Move & Resize Settings"),
N_("Move/Resize"), N_("Move & Resize Settings"),
sizeof(MovResDlgData),
SOUND_SETTINGS_MOVERESIZE,
"pix/moveres.png",
N_("Enlightenment Move & Resize\n" "Method Settings Dialog"),
@ -305,14 +301,10 @@ _DlgApplyPlacement(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
}
static void
_DlgFillPlacement(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
_DlgFillPlacement(Dialog * d, DItem * table, void *data __UNUSED__)
{
PlaceDlgData *dd = DLG_DATA_GET(d, PlaceDlgData);
DItem *di, *radio;
PlaceDlgData *dd;
dd = DLG_DATA_SET(d, PlaceDlgData);
if (!dd)
return;
dd->with_leader = Conf.focus.transientsfollowleader;
dd->switch_popup = Conf.focus.switchfortransientmap;
@ -482,8 +474,8 @@ _DlgFillPlacement(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgPlacement = {
"CONFIGURE_PLACEMENT",
N_("Placement"),
N_("Window Placement Settings"),
N_("Placement"), N_("Window Placement Settings"),
sizeof(PlaceDlgData),
SOUND_SETTINGS_PLACEMENT,
"pix/place.png",
N_("Enlightenment Window Placement\n" "Settings Dialog"),
@ -514,14 +506,10 @@ _DlgApplyMisc(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
}
static void
_DlgFillMisc(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
_DlgFillMisc(Dialog * d, DItem * table, void *data __UNUSED__)
{
MiscDlgData *dd = DLG_DATA_GET(d, MiscDlgData);
DItem *di;
MiscDlgData *dd;
dd = DLG_DATA_SET(d, MiscDlgData);
if (!dd)
return;
dd->dialog_headers = Conf.dialogs.headers;
dd->button_image = Conf.dialogs.button_image;
@ -577,8 +565,8 @@ _DlgFillMisc(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgMisc = {
"CONFIGURE_MISCELLANEOUS",
N_("Miscellaneous"),
N_("Miscellaneous Settings"),
N_("Miscellaneous"), N_("Miscellaneous Settings"),
sizeof(MiscDlgData),
SOUND_SETTINGS_MISCELLANEOUS,
"pix/miscellaneous.png",
N_("Enlightenment Miscellaneous\n" "Settings Dialog"),
@ -606,12 +594,8 @@ _DlgApplyComposite(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillComposite(Dialog * d, DItem * table, void *data __UNUSED__)
{
cfg_composite *dd = DLG_DATA_GET(d, cfg_composite);
DItem *di, *radio;
cfg_composite *dd;
dd = DLG_DATA_SET(d, cfg_composite);
if (!dd)
return;
/* Get current settings */
ECompMgrConfigGet(dd);
@ -710,8 +694,8 @@ _DlgFillComposite(Dialog * d, DItem * table, void *data __UNUSED__)
const DialogDef DlgComposite = {
"CONFIGURE_COMPOSITE",
N_("Composite"),
N_("Composite Settings"),
N_("Composite"), N_("Composite Settings"),
sizeof(cfg_composite),
SOUND_SETTINGS_COMPOSITE,
"pix/pager.png",
N_("Enlightenment Composite\n" "Settings Dialog"),
@ -798,8 +782,8 @@ _DlgFillConfiguration(Dialog * d, DItem * table, void *data __UNUSED__)
static const DialogDef DlgConfiguration = {
"CONFIGURE_ALL",
NULL,
N_("Enlightenment Settings"),
NULL, N_("Enlightenment Settings"),
0,
SOUND_SETTINGS_ALL,
NULL,
NULL,

View File

@ -648,16 +648,12 @@ _DlgApplySnap(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
static void
_DlgFillSnap(Dialog * d, DItem * table, void *data)
{
SnapDlgData *sd = DLG_DATA_GET(d, SnapDlgData);
DItem *di;
Snapshot *sn;
SnapDlgData *sd;
char s[1024];
const EWin *ewin = (EWin *) data;
sd = DLG_DATA_SET(d, SnapDlgData);
if (!sd)
return;
sd->client = EwinGetClientXwin(ewin);
sn = ewin->snap;
@ -910,8 +906,8 @@ _DlgFillSnap(Dialog * d, DItem * table, void *data)
static const DialogDef DlgSnap = {
NULL,
NULL,
N_("Remembered Application Attributes"),
NULL, N_("Remembered Application Attributes"),
sizeof(SnapDlgData),
SOUND_NONE,
"pix/snapshots.png",
N_("Select the attributes of this\n"
@ -1059,8 +1055,8 @@ _DlgFillRemember(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgRemember = {
"CONFIGURE_PAGER",
N_("Remember"),
N_("Remembered Windows Settings"),
N_("Remember"), N_("Remembered Windows Settings"),
0,
SOUND_SETTINGS_PAGER,
"pix/snapshots.png",
N_("Enlightenment Remembered\n" "Windows Settings Dialog"),

View File

@ -466,8 +466,8 @@ _DlgFillSound(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgSound = {
"CONFIGURE_AUDIO",
N_("Sound"),
N_("Audio Settings"),
N_("Sound"), N_("Audio Settings"),
0,
SOUND_SETTINGS_AUDIO,
"pix/sound.png",
N_("Enlightenment Audio\n" "Settings Dialog"),

View File

@ -407,8 +407,8 @@ _DlgThemeFill(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgTheme = {
"CONFIGURE_AUDIO",
N_("Theme"),
N_("Theme Settings"),
N_("Theme"), N_("Theme Settings"),
0,
SOUND_SETTINGS_MISCELLANEOUS,
"pix/miscellaneous.png",
N_("Enlightenment Theme\n" "Settings Dialog"),

View File

@ -866,8 +866,8 @@ _DlgFillTooltips(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
const DialogDef DlgTooltips = {
"CONFIGURE_TOOLTIPS",
N_("Tooltips"),
N_("Tooltip Settings"),
N_("Tooltips"), N_("Tooltip Settings"),
0,
SOUND_SETTINGS_TOOLTIPS,
"pix/tips.png",
N_("Enlightenment Tooltip\n" "Settings Dialog"),