diff --git a/src/E.h b/src/E.h index 262b8871..c80fd317 100644 --- a/src/E.h +++ b/src/E.h @@ -795,13 +795,6 @@ void ProgressbarHide(Progressbar * p); /* regex.c */ int matchregexp(const char *rx, const char *s); -/* settings.c */ -void SettingsMoveResize(void); -void SettingsPlacement(void); -void SettingsAutoRaise(void); -void SettingsMiscellaneous(void); -void SettingsComposite(void); - /* setup.c */ void MapUnmap(int start); void SetupX(const char *dstr); diff --git a/src/Makefile.am b/src/Makefile.am index 28f7ebdb..c97e669c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -100,6 +100,7 @@ e16_SOURCES = \ session.c \ session.h \ settings.c \ + settings.h \ setup.c \ size.c \ slideout.c \ diff --git a/src/actions.c b/src/actions.c index 15dfda6e..ff5de556 100644 --- a/src/actions.c +++ b/src/actions.c @@ -278,25 +278,15 @@ ActionsEnd(EWin * ewin) return did_end; } -void -About(void) +static void +_DlgFillAbout(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; + DItem *di; char buf[1024]; - d = DialogFind("ABOUT_ENLIGHTENMENT"); - if (d) - { - DialogShow(d); - return; - } - - d = DialogCreate("ABOUT_ENLIGHTENMENT"); Esnprintf(buf, sizeof(buf), _("About Enlightenment %s"), e_wm_version); DialogSetTitle(d, buf); - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); di = DialogAddItem(table, DITEM_IMAGE); @@ -320,7 +310,20 @@ About(void) DialogItemSetText(di, buf); DialogAddButton(d, _("OK"), NULL, 1, DLG_BUTTON_OK); - DialogShow(d); +} + +static const DialogDef DlgAbout = { + "ABOUT_ENLIGHTENMENT", + NULL, + NULL, + NULL, + _DlgFillAbout +}; + +void +About(void) +{ + DialogShowSimple(&DlgAbout, NULL); } #if 0 /* FIXME - Fix */ diff --git a/src/backgrounds.c b/src/backgrounds.c index 1b73b0d4..73bf8911 100644 --- a/src/backgrounds.c +++ b/src/backgrounds.c @@ -1801,7 +1801,7 @@ CB_BGScan(Dialog * d, int val __UNUSED__, void *data __UNUSED__) } static void -CB_BGAreaEvent(int val __UNUSED__, void *data) +CB_BGAreaEvent(DItem * di __UNUSED__, int val __UNUSED__, void *data) { int x, num, w, h; Background *bg; @@ -1993,23 +1993,22 @@ CB_BGSortContent(Dialog * d __UNUSED__, int val __UNUSED__, } static void -SettingsBackground(Background * bg) +CB_DesktopMiniDisplayAreaRedraw(DItem * di, int val __UNUSED__, + void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *table2, *area, *slider, *slider2, *label; + CB_DesktopMiniDisplayRedraw(DialogItemGetDialog(di), 1, di); + BGSettingsGoTo(tmp_bg); +} + +static void +_DlgFillBackground(Dialog * d, DItem * table, void *data) +{ + Background *bg = data; + DItem *di, *table2, *area, *slider, *slider2, *label; DItem *w1, *w2, *w3, *w4, *w5, *w6; int num; char s[1024]; - d = DialogFind("CONFIGURE_BG"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_BG"); - if (!bg) bg = BackgroundFind("NONE"); tmp_bg = bg; @@ -2021,10 +2020,8 @@ SettingsBackground(Background * bg) tmp_root_hint = Conf.hints.set_xroot_info_on_root_window; tmp_bg_timeout = Conf.backgrounds.timeout; - d = bg_sel_dialog = DialogCreate("CONFIGURE_BG"); - DialogSetTitle(d, _("Desktop Background Settings")); + bg_sel_dialog = d; - table = DialogInitItem(d); DialogItemTableSetOptions(table, 3, 0, 0, 0); if (Conf.dialogs.headers) @@ -2140,6 +2137,7 @@ SettingsBackground(Background * bg) di = bg_mini_disp = area = DialogAddItem(table2, DITEM_AREA); DialogItemAreaSetSize(di, 64, 48); + DialogItemAreaSetInitFunc(di, CB_DesktopMiniDisplayAreaRedraw); DialogItemSetCallback(w1, CB_DesktopMiniDisplayRedraw, 0, (void *)area); DialogItemSetCallback(w2, CB_DesktopMiniDisplayRedraw, 0, (void *)area); @@ -2272,13 +2270,16 @@ SettingsBackground(Background * bg) DialogItemCheckButtonSetPtr(di, &tmp_root_hint); DialogAddFooter(d, DLG_OAC, CB_ConfigureBG); - - DialogShow(d); - - CB_DesktopMiniDisplayRedraw(NULL, 1, area); - BGSettingsGoTo(tmp_bg); } +const DialogDef DlgBackground = { + "CONFIGURE_BG", + N_("Background"), + N_("Desktop Background Settings"), + "SOUND_SETTINGS_BG", + _DlgFillBackground +}; + /* * IPC functions */ @@ -2472,7 +2473,7 @@ BackgroundsIpc(const char *params, Client * c __UNUSED__) } else if (!strncmp(cmd, "cfg", 2)) { - SettingsBackground(DeskBackgroundGet(DesksGetCurrent())); + DialogShowSimple(&DlgBackground, DeskBackgroundGet(DesksGetCurrent())); } else if (!strncmp(cmd, "del", 2)) { diff --git a/src/desktops.c b/src/desktops.c index 19d5f93b..75c4a7eb 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -2221,11 +2221,10 @@ DesksSighan(int sig, void *prm __UNUSED__) } /* - * Dialodgs + * Dialogs */ static int tmp_desktops; static DItem *tmp_desk_text; -static Dialog *tmp_desk_dialog; static char tmp_desktop_slide; static int tmp_desktop_slide_speed; static char tmp_desktop_wraparound; @@ -2258,7 +2257,7 @@ CB_ConfigureDesktops(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -CB_DesktopDisplayRedraw(Dialog * d __UNUSED__, int val, void *data) +CB_DesktopDisplayRedraw(Dialog * d, int val, void *data) { static char called = 0; static int prev_desktops = -1; @@ -2343,24 +2342,21 @@ CB_DesktopDisplayRedraw(Dialog * d __UNUSED__, int val, void *data) else Esnprintf(s, sizeof(s), _("%i Desktop"), tmp_desktops); DialogItemSetText(tmp_desk_text, s); - DialogDrawItems(tmp_desk_dialog, tmp_desk_text, 0, 0, 99999, 99999); + DialogDrawItems(d, tmp_desk_text, 0, 0, 99999, 99999); } static void -SettingsDesktops(void) +CB_DesktopDisplayAreaRedraw(DItem * di, int val __UNUSED__, + void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *area, *slider, *radio; - char s[64]; + CB_DesktopDisplayRedraw(DialogItemGetDialog(di), 1, di); +} - d = DialogFind("CONFIGURE_DESKTOPS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_DESKTOPS"); +static void +_DlgFillDesks(Dialog * d, DItem * table, void *data __UNUSED__) +{ + DItem *di, *area, *slider, *radio; + char s[64]; tmp_desktops = Conf.desks.num; tmp_desktop_slide = Conf.desks.slidein; @@ -2372,10 +2368,6 @@ SettingsDesktops(void) tmp_dragbar = 1; tmp_dragdir = Conf.desks.dragdir; - d = tmp_desk_dialog = DialogCreate("CONFIGURE_DESKTOPS"); - DialogSetTitle(d, _("Multiple Desktop Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -2405,6 +2397,9 @@ SettingsDesktops(void) di = area = DialogAddItem(table, DITEM_AREA); DialogItemSetColSpan(di, 2); DialogItemAreaSetSize(di, 128, 96); + DialogItemAreaSetInitFunc(area, CB_DesktopDisplayAreaRedraw); + + DialogItemSetCallback(slider, CB_DesktopDisplayRedraw, 0, area); di = DialogAddItem(table, DITEM_SEPARATOR); DialogItemSetColSpan(di, 2); @@ -2473,19 +2468,21 @@ SettingsDesktops(void) DialogItemRadioButtonGroupSetValPtr(radio, &tmp_dragdir); DialogAddFooter(d, DLG_OAC, CB_ConfigureDesktops); - - DialogShow(d); - - DialogItemSetCallback(slider, CB_DesktopDisplayRedraw, 0, (void *)area); - CB_DesktopDisplayRedraw(d, 1, area); } +const DialogDef DlgDesks = { + "CONFIGURE_DESKTOPS", + N_("Desks"), + N_("Multiple Desktop Settings"), + "SOUND_SETTINGS_DESKTOPS", + _DlgFillDesks +}; + static int tmp_area_x; static int tmp_area_y; static int tmp_edge_resist; static char tmp_edge_flip; static DItem *tmp_area_text; -static Dialog *tmp_area_dialog; static char tmp_area_wraparound; static void @@ -2564,24 +2561,20 @@ CB_AreaDisplayRedraw(Dialog * d __UNUSED__, int val, void *data) else Esnprintf(s, sizeof(s), _("1\nScreen in size")); DialogItemSetText(tmp_area_text, s); - DialogDrawItems(tmp_area_dialog, tmp_area_text, 0, 0, 99999, 99999); + DialogDrawItems(d, tmp_area_text, 0, 0, 99999, 99999); } static void -SettingsArea(void) +CB_AreaDisplayAreaRedraw(DItem * di, int val __UNUSED__, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *area, *slider, *slider2, *table2; - char s[64]; + CB_AreaDisplayRedraw(DialogItemGetDialog(di), 1, di); +} - d = DialogFind("CONFIGURE_AREA"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_AREA"); +static void +_DlgFillAreas(Dialog * d, DItem * table, void *data __UNUSED__) +{ + DItem *di, *area, *slider, *slider2, *table2; + char s[64]; tmp_area_wraparound = Conf.desks.areas_wraparound; tmp_edge_resist = Conf.edge_flip_resistance; @@ -2592,10 +2585,6 @@ SettingsArea(void) DesksGetAreaSize(&tmp_area_x, &tmp_area_y); tmp_area_y = 9 - tmp_area_y; - d = tmp_area_dialog = DialogCreate("CONFIGURE_AREA"); - DialogSetTitle(d, _("Virtual Desktop Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 1, 0, 0, 0); if (Conf.dialogs.headers) @@ -2636,9 +2625,10 @@ SettingsArea(void) di = area = DialogAddItem(table2, DITEM_AREA); DialogItemAreaSetSize(di, 160, 120); + DialogItemAreaSetInitFunc(area, CB_AreaDisplayAreaRedraw); - DialogItemSetCallback(slider, CB_AreaDisplayRedraw, 0, (void *)area); - DialogItemSetCallback(slider2, CB_AreaDisplayRedraw, 0, (void *)area); + DialogItemSetCallback(slider, CB_AreaDisplayRedraw, 0, area); + DialogItemSetCallback(slider2, CB_AreaDisplayRedraw, 0, area); di = DialogAddItem(table, DITEM_SEPARATOR); @@ -2661,12 +2651,16 @@ SettingsArea(void) DialogItemSliderSetValPtr(di, &tmp_edge_resist); DialogAddFooter(d, DLG_OAC, CB_ConfigureAreas); - - DialogShow(d); - - CB_AreaDisplayRedraw(d, 1, area); } +const DialogDef DlgAreas = { + "CONFIGURE_AREA", + N_("Areas"), + N_("Virtual Desktop Settings"), + "SOUND_SETTINGS_AREA", + _DlgFillAreas +}; + /* * IPC functions */ @@ -2731,7 +2725,7 @@ DesksIpcDesk(const char *params, Client * c __UNUSED__) } else if (!strncmp(cmd, "cfg", 3)) { - SettingsDesktops(); + DialogShowSimple(&DlgDesks, NULL); } else if (!strncmp(cmd, "set", 3)) { @@ -2825,7 +2819,7 @@ DesksIpcArea(const char *params, Client * c __UNUSED__) } else if (!strncmp(cmd, "cfg", 3)) { - SettingsArea(); + DialogShowSimple(&DlgAreas, NULL); } else if (!strncmp(cmd, "set", 3)) { diff --git a/src/dialog.c b/src/dialog.c index 1626aef8..bf580e58 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -75,6 +75,7 @@ typedef struct { Win area_win; int w, h; + DialogItemCallbackFunc *init_func; DialogItemCallbackFunc *event_func; } DItemArea; @@ -691,6 +692,36 @@ DialogClose(Dialog * d) EwinHide(d->ewin); } +void +DialogShowSimple(const DialogDef * dd, void *data) +{ + Dialog *d; + DItem *table; + + d = DialogFind(dd->name); + if (d) + { + SoundPlay("SOUND_SETTINGS_ACTIVE"); + DialogShow(d); + return; + } + SoundPlay(dd->sound); + + d = DialogCreate(dd->name); + if (!d) + return; + + DialogSetTitle(d, _(dd->title)); + + table = DialogInitItem(d); + if (!table) + return; + + dd->fill(d, table, data); + + DialogShow(d); +} + static DItem * DialogItemCreate(int type) { @@ -749,10 +780,8 @@ DialogAddItem(DItem * dii, int type) default: break; case DITEM_AREA: - di->item.area.area_win = 0; di->item.area.w = 32; di->item.area.h = 32; - di->item.area.event_func = NULL; break; case DITEM_CHECKBUTTON: di->item.check_button.check_win = 0; @@ -888,6 +917,12 @@ DialogAddFooter(Dialog * d, int flags, DialogCallbackFunc * cb) DialogSetExitFunction(d, cb, 2); } +Dialog * +DialogItemGetDialog(DItem * di) +{ + return di->dlg; +} + void DialogItemSetCallback(DItem * di, DialogCallbackFunc * func, int val, void *data) @@ -1673,8 +1708,12 @@ DialogDrawItem(Dialog * d, DItem * di) break; case DITEM_AREA: + if (!d->redraw) + break; ImageclassApply(di->iclass, di->win, di->w, di->h, 0, 0, STATE_NORMAL, ST_DIALOG); + if (di->item.area.init_func) + di->item.area.init_func(di, 0, NULL); break; case DITEM_CHECKBUTTON: @@ -1980,6 +2019,12 @@ DialogItemAreaGetSize(DItem * di, int *w, int *h) *h = di->item.area.h; } +void +DialogItemAreaSetInitFunc(DItem * di, DialogItemCallbackFunc * func) +{ + di->item.area.init_func = func; +} + void DialogItemAreaSetEventFunc(DItem * di, DialogItemCallbackFunc * func) { @@ -2133,7 +2178,7 @@ DItemEventMotion(Win win __UNUSED__, DItem * di, XEvent * ev) { case DITEM_AREA: if (di->item.area.event_func) - di->item.area.event_func(0, ev); + di->item.area.event_func(di, 0, ev); break; case DITEM_SLIDER: @@ -2193,7 +2238,7 @@ DItemEventMouseDown(Win win, DItem * di, XEvent * ev) { case DITEM_AREA: if (di->item.area.event_func) - di->item.area.event_func(0, ev); + di->item.area.event_func(di, 0, ev); break; case DITEM_SLIDER: @@ -2299,7 +2344,7 @@ DItemEventMouseUp(Win win, DItem * di, XEvent * ev) { case DITEM_AREA: if (di->item.area.event_func) - di->item.area.event_func(0, ev); + di->item.area.event_func(di, 0, ev); break; case DITEM_CHECKBUTTON: @@ -2341,12 +2386,12 @@ DItemEventMouseIn(Win win __UNUSED__, DItem * di, XEvent * ev) { case DITEM_AREA: if (di->item.area.event_func) - di->item.area.event_func(0, ev); + di->item.area.event_func(di, 0, ev); break; case DITEM_RADIOBUTTON: if (di->item.radio_button.event_func) - di->item.radio_button.event_func(di->item.radio_button.val, ev); + di->item.radio_button.event_func(di, di->item.radio_button.val, ev); break; } @@ -2362,12 +2407,13 @@ DItemEventMouseOut(Win win __UNUSED__, DItem * di, XEvent * ev) { case DITEM_AREA: if (di->item.area.event_func) - di->item.area.event_func(0, ev); + di->item.area.event_func(di, 0, ev); break; case DITEM_RADIOBUTTON: if (di->item.radio_button.event_func) - di->item.radio_button.event_func(di->item.radio_button.val, NULL); + di->item.radio_button.event_func(di, di->item.radio_button.val, + NULL); break; } diff --git a/src/dialog.h b/src/dialog.h index 27aca863..a38b8342 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -51,7 +51,16 @@ typedef struct _dialog Dialog; typedef struct _ditem DItem; typedef void (DialogCallbackFunc) (Dialog * d, int val, void *data); -typedef void (DialogItemCallbackFunc) (int val, void *data); +typedef void (DialogItemCallbackFunc) (DItem * di, int val, void *data); + +typedef struct +{ + const char *name; + const char *label; + const char *title; + const char *sound; + void (*fill) (Dialog * d, DItem * table, void *data); +} DialogDef; /* dialog.c */ Dialog *DialogCreate(const char *name); @@ -67,6 +76,7 @@ void *DialogGetData(Dialog * d); void DialogShow(Dialog * d); void DialogShowCentered(Dialog * d); +void DialogShowSimple(const DialogDef * dd, void *data); void DialogRedraw(Dialog * d); void DialogAddButton(Dialog * d, const char *text, @@ -78,6 +88,7 @@ void DialogAddFooter(Dialog * d, int flags, DialogCallbackFunc * cb); DItem *DialogInitItem(Dialog * d); DItem *DialogAddItem(DItem * dii, int type); +Dialog *DialogItemGetDialog(DItem * di); void DialogItemSetCallback(DItem * di, DialogCallbackFunc * func, int val, void *data); void DialogItemSetClass(DItem * di, ImageClass * ic, @@ -122,6 +133,8 @@ void DialogItemSliderGetBounds(DItem * di, int *lower, void DialogItemAreaSetSize(DItem * di, int w, int h); void DialogItemAreaGetSize(DItem * di, int *w, int *h); Win DialogItemAreaGetWindow(DItem * di); +void DialogItemAreaSetInitFunc(DItem * di, + DialogItemCallbackFunc * func); void DialogItemAreaSetEventFunc(DItem * di, DialogItemCallbackFunc * func); diff --git a/src/ecompmgr.c b/src/ecompmgr.c index 96071645..3e4d19e6 100644 --- a/src/ecompmgr.c +++ b/src/ecompmgr.c @@ -33,6 +33,7 @@ #include "ecompmgr.h" #include "emodule.h" #include "eobj.h" +#include "settings.h" #include "timers.h" #include "xwin.h" diff --git a/src/focus.c b/src/focus.c index 385b35e4..7d2328db 100644 --- a/src/focus.c +++ b/src/focus.c @@ -678,19 +678,9 @@ CB_ConfigureFocus(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -SettingsFocus(void) +_DlgFillFocus(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *radio, *radio2; - - d = DialogFind("CONFIGURE_FOCUS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_FOCUS"); + DItem *di, *radio, *radio2; tmp_focus = Conf.focus.mode; tmp_new_focus = Conf.focus.all_new_windows_get_focus; @@ -711,10 +701,6 @@ SettingsFocus(void) tmp_clickalways = Conf.focus.clickraises; - d = DialogCreate("CONFIGURE_FOCUS"); - DialogSetTitle(d, _("Focus Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -852,10 +838,16 @@ SettingsFocus(void) DialogItemRadioButtonGroupSetValPtr(radio2, &tmp_warp_icon_mode); DialogAddFooter(d, DLG_OAC, CB_ConfigureFocus); - - DialogShow(d); } +const DialogDef DlgFocus = { + "CONFIGURE_FOCUS", + N_("Focus"), + N_("Focus Settings"), + "SOUND_SETTINGS_FOCUS", + _DlgFillFocus +}; + /* * Focus Module */ @@ -920,7 +912,7 @@ FocusIpc(const char *params, Client * c __UNUSED__) } else if (!strcmp(cmd, "cfg")) { - SettingsFocus(); + DialogShowSimple(&DlgFocus, NULL); } else if (!strncmp(cmd, "mode", 2)) { diff --git a/src/fx.c b/src/fx.c index 92ee5ad2..3e0999fa 100644 --- a/src/fx.c +++ b/src/fx.c @@ -971,28 +971,14 @@ CB_ConfigureFX(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -FxSettings(void) +_DlgFillFx(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_FX"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_FX"); + DItem *di; tmp_effect_raindrops = FX_IsOn("raindrops"); tmp_effect_ripples = FX_IsOn("ripples"); tmp_effect_waves = FX_IsOn("waves"); - d = DialogCreate("CONFIGURE_FX"); - DialogSetTitle(d, _("Special FX Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 1, 0, 0, 0); if (Conf.dialogs.headers) @@ -1016,10 +1002,16 @@ FxSettings(void) DialogItemCheckButtonSetPtr(di, &tmp_effect_waves); DialogAddFooter(d, DLG_OAC, CB_ConfigureFX); - - DialogShow(d); } +const DialogDef DlgFx = { + "CONFIGURE_FX", + N_("FX"), + N_("Special FX Settings"), + "SOUND_SETTINGS_FX", + _DlgFillFx +}; + static void FxIpc(const char *params, Client * c __UNUSED__) { @@ -1051,7 +1043,7 @@ FxIpc(const char *params, Client * c __UNUSED__) } else if (!strncmp(word1, "cfg", 2)) { - FxSettings(); + DialogShowSimple(&DlgFx, NULL); } } diff --git a/src/groups.c b/src/groups.c index 413f629c..87c97724 100644 --- a/src/groups.c +++ b/src/groups.c @@ -787,40 +787,14 @@ GroupSelectCallback(Dialog * d, int val, void *data __UNUSED__) } static void -SettingsGroups(EWin * ewin) +_DlgFillGroups(Dialog * d, DItem * table, void *data) { - Dialog *d; - DItem *table, *radio, *di; + EWin *ewin = data; + DItem *radio, *di; int i; char **group_member_strings; EwinGroupDlgData *dd; - if (!ewin) - return; - - if (ewin->num_groups == 0) - { - DialogOK(_("Window Group Error"), - _ - ("\n This window currently does not belong to any groups. \n\n")); - return; - } - - d = DialogFind("CONFIGURE_GROUP"); - if (d) - { - SoundPlay("GROUP_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - - SoundPlay("SOUND_SETTINGS_GROUP"); - - d = DialogCreate("CONFIGURE_GROUP"); - if (!d) - return; - DialogSetTitle(d, _("Window Group Settings")); - dd = Ecalloc(1, sizeof(EwinGroupDlgData)); if (!dd) return; @@ -836,7 +810,6 @@ SettingsGroups(EWin * ewin) ShowHideWinGroups(ewin, 0, SET_ON); - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -921,8 +894,31 @@ SettingsGroups(EWin * ewin) DialogItemCheckButtonSetPtr(di, &(dd->cfg.mirror)); DialogAddFooter(d, DLG_OAC, CB_ConfigureGroup); +} - DialogShow(d); +static const DialogDef DlgGroups = { + "CONFIGURE_GROUP", + NULL, + N_("Window Group Settings"), + "SOUND_SETTINGS_GROUP", + _DlgFillGroups +}; + +static void +SettingsGroups(EWin * ewin) +{ + if (!ewin) + return; + + if (ewin->num_groups == 0) + { + DialogOK(_("Window Group Error"), + _ + ("\n This window currently does not belong to any groups. \n\n")); + return; + } + + DialogShowSimple(&DlgGroups, ewin); } static GroupConfig tmp_group_cfg; @@ -940,27 +936,13 @@ CB_ConfigureDefaultGroupSettings(Dialog * d __UNUSED__, int val, } static void -SettingsDefaultGroupControl(void) +_DlgFillGroupDefaults(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_DEFAULT_GROUP_CONTROL"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_GROUP"); + DItem *di; CopyGroupConfig(&(Conf_groups.dflt), &tmp_group_cfg); tmp_group_swap = Conf_groups.swapmove; - d = DialogCreate("CONFIGURE_DEFAULT_GROUP_CONTROL"); - DialogSetTitle(d, _("Default Group Control Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -1030,10 +1012,16 @@ SettingsDefaultGroupControl(void) DialogItemCheckButtonSetPtr(di, &(tmp_group_swap)); DialogAddFooter(d, DLG_OAC, CB_ConfigureDefaultGroupSettings); - - DialogShow(d); } +const DialogDef DlgGroupDefaults = { + "CONFIGURE_DEFAULT_GROUP_CONTROL", + N_("Groups"), + N_("Default Group Control Settings"), + "SOUND_SETTINGS_GROUP", + _DlgFillGroupDefaults +}; + /* * Groups module */ @@ -1060,7 +1048,7 @@ GroupsConfigure(const char *params) } else if (!s[0] || !strcmp(s, "group_defaults")) { - SettingsDefaultGroupControl(); + DialogShowSimple(&DlgGroupDefaults, NULL); } else if (!strcmp(s, "group_membership")) { diff --git a/src/iconify.c b/src/iconify.c index ebc878d2..764d93a4 100644 --- a/src/iconify.c +++ b/src/iconify.c @@ -2135,25 +2135,16 @@ CB_IconSizeSlider(Dialog * d, int val __UNUSED__, void *data) } static void -IconboxConfigure(Iconbox * ib) +_DlgFillIconbox(Dialog * d, DItem * table, void *data) { - Dialog *d; - DItem *di, *table, *table2; + Iconbox *ib = data; + DItem *di, *table2; DItem *radio1, *radio2, *radio3, *radio4, *label; char s[256]; if (!ib) return; - d = DialogFind("CONFIGURE_ICONBOX"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_ICONBOX"); - tmp_ib_nobg = ib->nobg; tmp_ib_shownames = ib->shownames; tmp_ib_vert = ib->orientation; @@ -2171,13 +2162,11 @@ IconboxConfigure(Iconbox * ib) Efree(tmp_ib_name); tmp_ib_name = Estrdup(ib->name); - d = DialogCreate("CONFIGURE_ICONBOX"); if (ib->type == IB_TYPE_ICONBOX) DialogSetTitle(d, _("Iconbox Settings")); else DialogSetTitle(d, _("Systray Settings")); - table = DialogInitItem(d); DialogItemTableSetOptions(table, 1, 0, 0, 0); if (Conf.dialogs.headers) @@ -2347,10 +2336,16 @@ IconboxConfigure(Iconbox * ib) DialogItemRadioButtonGroupSetValPtr(radio3, &tmp_ib_arrows); DialogAddFooter(d, DLG_OAC, CB_ConfigureIconbox); - - DialogShow(d); } +const DialogDef DlgIconbox = { + "CONFIGURE_ICONBOX", + NULL, + NULL, + "SOUND_SETTINGS_ICONBOX", + _DlgFillIconbox +}; + /* * Configuration load/save */ @@ -2557,7 +2552,7 @@ IconboxesConfigure(const char *params) ib = IconboxFind(params); if (ib) - IconboxConfigure(ib); + DialogShowSimple(&DlgIconbox, ib); } /* diff --git a/src/menus.c b/src/menus.c index e1aa658b..1f1aef0d 100644 --- a/src/menus.c +++ b/src/menus.c @@ -2031,28 +2031,14 @@ CB_ConfigureMenus(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -MenusSettings(void) +_DlgFillMenus(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_MENUS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_MENUS"); + DItem *di; tmp_warpmenus = Conf.menus.warp; tmp_animated_menus = Conf.menus.animate; tmp_menusonscreen = Conf.menus.onscreen; - d = DialogCreate("CONFIGURE_MENUS"); - DialogSetTitle(d, _("Menu Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 3, 0, 0, 0); if (Conf.dialogs.headers) @@ -2075,10 +2061,16 @@ MenusSettings(void) DialogItemCheckButtonSetPtr(di, &tmp_warpmenus); DialogAddFooter(d, DLG_OAC, CB_ConfigureMenus); - - DialogShow(d); } +const DialogDef DlgMenus = { + "CONFIGURE_MENUS", + N_("Menus"), + N_("Menu Settings"), + "SOUND_SETTINGS_MENUS", + _DlgFillMenus +}; + static void MenusIpc(const char *params, Client * c __UNUSED__) { @@ -2102,7 +2094,7 @@ MenusIpc(const char *params, Client * c __UNUSED__) } else if (!strncmp(cmd, "cfg", 2)) { - MenusSettings(); + DialogShowSimple(&DlgMenus, NULL); } else if (!strncmp(cmd, "list", 2)) { diff --git a/src/mod-misc.c b/src/mod-misc.c index 5b36538e..df9ee7fa 100644 --- a/src/mod-misc.c +++ b/src/mod-misc.c @@ -21,8 +21,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "dialog.h" #include "emodule.h" #include "session.h" +#include "settings.h" #include "snaps.h" /*********************************************************************** @@ -199,17 +201,17 @@ MiscIpcConfig(const char *params, Client * c __UNUSED__) else if (!strncmp(cmd, "cfg", 3)) { if (!strncmp(prm, "autoraise", 2)) - SettingsAutoRaise(); + DialogShowSimple(&DlgAutoraise, NULL); else if (!strncmp(prm, "misc", 2)) - SettingsMiscellaneous(); + DialogShowSimple(&DlgMisc, NULL); else if (!strncmp(prm, "moveresize", 2)) - SettingsMoveResize(); + DialogShowSimple(&DlgMoveResize, NULL); else if (!strncmp(prm, "placement", 2)) - SettingsPlacement(); + DialogShowSimple(&DlgPlacement, NULL); else if (!strncmp(prm, "remember", 2)) - SettingsRemember(); + DialogShowSimple(&DlgRemember, NULL); else if (!strncmp(prm, "session", 2)) - SettingsSession(); + DialogShowSimple(&DlgSession, NULL); } else if (!strncmp(cmd, "arrange", 3)) { diff --git a/src/mod-trans.c b/src/mod-trans.c index ff58e166..2e88919e 100644 --- a/src/mod-trans.c +++ b/src/mod-trans.c @@ -107,23 +107,13 @@ CB_ThemeTransparency(Dialog * d __UNUSED__, int val __UNUSED__, void *data) } static void -SettingsTransparency(void) +_DlgFillThemeTrans(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *label; + DItem *di, *label; DItem *radio_border, *radio_widget, *radio_menu, *radio_dialog, *radio_tooltip, *radio_hilight; char s[256]; - d = DialogFind("CONFIGURE_TRANS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_TRANS"); - tmp_st_border = Conf.trans.border; tmp_st_widget = Conf.trans.widget; tmp_st_dialog = Conf.trans.dialog; @@ -133,10 +123,6 @@ SettingsTransparency(void) tmp_theme_transparency = Conf.trans.alpha; - d = DialogCreate("CONFIGURE_TRANS"); - DialogSetTitle(d, _("Selective Transparency Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 7, 0, 0, 0); if (Conf.dialogs.headers) @@ -282,10 +268,16 @@ SettingsTransparency(void) DialogItemSetCallback(di, CB_ThemeTransparency, 0, (void *)label); DialogAddFooter(d, DLG_OAC, CB_ConfigureTrans); - - DialogShow(d); } +const DialogDef DlgThemeTrans = { + "CONFIGURE_TRANS", + N_("Transparency"), + N_("Selective Transparency Settings"), + "SOUND_SETTINGS_TRANS", + _DlgFillThemeTrans +}; + static void TransparencySighan(int sig, void *prm __UNUSED__) { @@ -302,7 +294,7 @@ TransparencyIpc(const char *params, Client * c __UNUSED__) { if (params && !strncmp(params, "cfg", 3)) { - SettingsTransparency(); + DialogShowSimple(&DlgThemeTrans, NULL); } } diff --git a/src/pager.c b/src/pager.c index 02df476a..7690dfeb 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1684,7 +1684,6 @@ static int tmp_pager_sel_button; static int tmp_pager_win_button; static int tmp_pager_menu_button; static DItem *pager_scan_speed_label = NULL; -static Dialog *pager_settings_dialog = NULL; static void CB_ConfigurePager(Dialog * d __UNUSED__, int val, void *data __UNUSED__) @@ -1716,34 +1715,22 @@ CB_ConfigurePager(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -CB_PagerScanSlide(Dialog * d __UNUSED__, int val __UNUSED__, - void *data __UNUSED__) +CB_PagerScanSlide(Dialog * d, int val __UNUSED__, void *data __UNUSED__) { char s[256]; Esnprintf(s, sizeof(s), "%s %03i %s", _("Pager scanning speed:"), tmp_pager_scan_speed, _("lines per second")); DialogItemSetText(pager_scan_speed_label, s); - DialogDrawItems(pager_settings_dialog, pager_scan_speed_label, 0, 0, 99999, - 99999); + DialogDrawItems(d, pager_scan_speed_label, 0, 0, 99999, 99999); } static void -SettingsPager(void) +_DlgFillPagers(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *radio; + DItem *di, *radio; char s[256]; - d = DialogFind("CONFIGURE_PAGER"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_PAGER"); - tmp_show_pagers = Conf_pagers.enable; tmp_pager_hiq = Conf_pagers.hiq; tmp_pager_snap = Conf_pagers.snap; @@ -1758,10 +1745,6 @@ SettingsPager(void) tmp_pager_do_scan = 1; tmp_pager_scan_speed = Conf_pagers.scanspeed; - d = pager_settings_dialog = DialogCreate("CONFIGURE_PAGER"); - DialogSetTitle(d, _("Pager Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -1892,10 +1875,16 @@ SettingsPager(void) DialogItemRadioButtonGroupSetValPtr(radio, &tmp_pager_menu_button); DialogAddFooter(d, DLG_OAC, CB_ConfigurePager); - - DialogShow(d); } +const DialogDef DlgPagers = { + "CONFIGURE_PAGER", + N_("Pagers"), + N_("Pager Settings"), + "SOUND_SETTINGS_PAGER", + _DlgFillPagers +}; + /* * Pagers Module */ @@ -1977,7 +1966,7 @@ IPC_Pager(const char *params, Client * c __UNUSED__) if (!strncmp(prm1, "cfg", 3)) { - SettingsPager(); + DialogShowSimple(&DlgPagers, NULL); } else if (!strcmp(prm1, "on")) { diff --git a/src/session.c b/src/session.c index 5490dd81..d4a2115c 100644 --- a/src/session.c +++ b/src/session.c @@ -769,29 +769,15 @@ CB_ConfigureSession(Dialog * d __UNUSED__, int val, void *data __UNUSED__) autosave(); } -void -SettingsSession(void) +static void +_DlgFillSession(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_SESSION"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_SESSION"); + DItem *di; tmp_session_script = Conf.session.enable_script; tmp_logout_dialog = Conf.session.enable_logout_dialog; tmp_reboot_halt = Conf.session.enable_reboot_halt; - d = DialogCreate("CONFIGURE_SESSION"); - DialogSetTitle(d, _("Session Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -814,6 +800,12 @@ SettingsSession(void) DialogItemCheckButtonSetPtr(di, &tmp_reboot_halt); DialogAddFooter(d, DLG_OAC, CB_ConfigureSession); - - DialogShow(d); } + +const DialogDef DlgSession = { + "CONFIGURE_SESSION", + N_("Session"), + N_("Session Settings"), + "SOUND_SETTINGS_SESSION", + _DlgFillSession +}; diff --git a/src/settings.c b/src/settings.c index a58c62ec..eb62789d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "dialog.h" +#include "settings.h" static int tmp_move; static int tmp_resize; @@ -42,30 +43,16 @@ CB_ConfigureMoveResize(Dialog * d __UNUSED__, int val, void *data __UNUSED__) autosave(); } -void -SettingsMoveResize(void) +static void +_DlgFillMoveResize(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *radio1, *radio2, *radio3; - - d = DialogFind("CONFIGURE_MOVERESIZE"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_MOVERESIZE"); + DItem *di, *radio1, *radio2, *radio3; tmp_move = Conf.movres.mode_move; tmp_resize = Conf.movres.mode_resize; tmp_geominfo = Conf.movres.mode_info; tmp_update_while_moving = Conf.movres.update_while_moving; - d = DialogCreate("CONFIGURE_MOVERESIZE"); - DialogSetTitle(d, _("Move & Resize Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -179,10 +166,16 @@ SettingsMoveResize(void) DialogItemCheckButtonSetPtr(di, &tmp_update_while_moving); DialogAddFooter(d, DLG_OAC, CB_ConfigureMoveResize); - - DialogShow(d); } +const DialogDef DlgMoveResize = { + "CONFIGURE_MOVERESIZE", + N_("Move/Resize"), + N_("Move & Resize Settings"), + "SOUND_SETTINGS_MOVERESIZE", + _DlgFillMoveResize +}; + static char tmp_with_leader; static char tmp_switch_popup; static char tmp_manual_placement; @@ -231,20 +224,10 @@ CB_ConfigurePlacement(Dialog * d __UNUSED__, int val, void *data __UNUSED__) autosave(); } -void -SettingsPlacement(void) +static void +_DlgFillPlacement(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di, *radio; - - d = DialogFind("CONFIGURE_PLACEMENT"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_PLACEMENT"); + DItem *di, *radio; tmp_with_leader = Conf.focus.transientsfollowleader; tmp_switch_popup = Conf.focus.switchfortransientmap; @@ -268,10 +251,6 @@ SettingsPlacement(void) tmp_extra_head = Conf.extra_head; #endif - d = DialogCreate("CONFIGURE_PLACEMENT"); - DialogSetTitle(d, _("Window Placement Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 1, 0); if (Conf.dialogs.headers) @@ -409,10 +388,16 @@ SettingsPlacement(void) #endif DialogAddFooter(d, DLG_OAC, CB_ConfigurePlacement); - - DialogShow(d); } +const DialogDef DlgPlacement = { + "CONFIGURE_PLACEMENT", + N_("Placement"), + N_("Window Placement Settings"), + "SOUND_SETTINGS_PLACEMENT", + _DlgFillPlacement +}; + static char tmp_autoraise; static int tmp_autoraisetime; @@ -427,28 +412,14 @@ CB_ConfigureAutoraise(Dialog * d __UNUSED__, int val, void *data __UNUSED__) autosave(); } -void -SettingsAutoRaise(void) +static void +_DlgFillAutoraise(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_AUTORAISE"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_AUTORAISE"); + DItem *di; tmp_autoraise = Conf.autoraise.enable; tmp_autoraisetime = Conf.autoraise.delay / 10; - d = DialogCreate("CONFIGURE_AUTORAISE"); - DialogSetTitle(d, _("Autoraise Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -473,10 +444,16 @@ SettingsAutoRaise(void) DialogItemSliderSetValPtr(di, &tmp_autoraisetime); DialogAddFooter(d, DLG_OAC, CB_ConfigureAutoraise); - - DialogShow(d); } +const DialogDef DlgAutoraise = { + "CONFIGURE_AUTORAISE", + N_("Autoraise"), + N_("Autoraise Settings"), + "SOUND_SETTINGS_AUTORAISE", + _DlgFillAutoraise +}; + static char tmp_dialog_headers; static char tmp_button_image; static char tmp_animate_startup; @@ -495,30 +472,16 @@ CB_ConfigureMiscellaneous(Dialog * d __UNUSED__, int val, void *data __UNUSED__) autosave(); } -void -SettingsMiscellaneous(void) +static void +_DlgFillMisc(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_MISCELLANEOUS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_MISCELLANEOUS"); + DItem *di; tmp_dialog_headers = Conf.dialogs.headers; tmp_button_image = Conf.dialogs.button_image; tmp_animate_startup = Conf.startup.animate; tmp_saveunders = Conf.save_under; - d = DialogCreate("CONFIGURE_MISCELLANEOUS"); - DialogSetTitle(d, _("Miscellaneous Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -552,10 +515,16 @@ SettingsMiscellaneous(void) DialogItemCheckButtonSetPtr(di, &tmp_saveunders); DialogAddFooter(d, DLG_OAC, CB_ConfigureMiscellaneous); - - DialogShow(d); } +const DialogDef DlgMisc = { + "CONFIGURE_MISCELLANEOUS", + N_("Miscellaneous"), + N_("Miscellaneous Settings"), + "SOUND_SETTINGS_MISCELLANEOUS", + _DlgFillMisc +}; + #if USE_COMPOSITE #include "ecompmgr.h" @@ -577,30 +546,19 @@ CB_ConfigureComposite(Dialog * d, int val, void *data __UNUSED__) ECompMgrConfigGet(cfg); } -void -SettingsComposite(void) +static void +_DlgFillComposite(Dialog * d, DItem * table, void *data __UNUSED__) { static cfg_composite Cfg_composite; - Dialog *d; - DItem *table, *di, *radio; + DItem *di, *radio; - d = DialogFind("CONFIGURE_COMPOSITE"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_COMPOSITE"); - - d = DialogCreate("CONFIGURE_COMPOSITE"); DialogSetTitle(d, _("Composite Settings")); /* Get current settings */ ECompMgrConfigGet(&Cfg_composite); DialogSetData(d, &Cfg_composite); - table = DialogInitItem(d); + /* Layout */ DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -660,7 +618,19 @@ SettingsComposite(void) DialogItemSliderSetValPtr(di, &Cfg_composite.fade_speed); DialogAddFooter(d, DLG_OAC, CB_ConfigureComposite); +} - DialogShow(d); +const DialogDef DlgComposite = { + "CONFIGURE_COMPOSITE", + N_("Composite"), + N_("Composite Settings"), + "SOUND_SETTINGS_COMPOSITE", + _DlgFillComposite +}; + +void +SettingsComposite(void) +{ + DialogShowSimple(&DlgComposite, NULL); } #endif diff --git a/src/settings.h b/src/settings.h new file mode 100644 index 00000000..f31f2b24 --- /dev/null +++ b/src/settings.h @@ -0,0 +1,16 @@ + +/* settings.c */ +void SettingsComposite(void); + +#ifdef _DIALOG_H_ +extern const DialogDef DlgAutoraise; +extern const DialogDef DlgComposite; +extern const DialogDef DlgGroupDefaults; +extern const DialogDef DlgMisc; +extern const DialogDef DlgMoveResize; +extern const DialogDef DlgPlacement; +extern const DialogDef DlgRemember; +extern const DialogDef DlgSession; +extern const DialogDef DlgSound; +extern const DialogDef DlgTooltips; +#endif diff --git a/src/snaps.c b/src/snaps.c index cc31da66..40d56502 100644 --- a/src/snaps.c +++ b/src/snaps.c @@ -1003,30 +1003,15 @@ CB_RememberWindowSettings(Dialog * d __UNUSED__, int val __UNUSED__, void *data) SnapshotEwinDialog(sn->used); } -void -SettingsRemember(void) +static void +_DlgFillRemember(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; + DItem *di; Snapshot *sn; int i, num; char buf[128]; const char *s; - /* init remember window */ - d = DialogFind("REMEMBER_WINDOW"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_REMEMBER"); - - d = DialogCreate("REMEMBER_WINDOW"); - DialogSetTitle(d, _("Remembered Windows Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 3, 0, 0, 0); if (Conf.dialogs.headers) @@ -1095,10 +1080,16 @@ SettingsRemember(void) } DialogAddFooter(d, DLG_OC, CB_ApplyRemember); - - DialogShow(d); } +const DialogDef DlgRemember = { + "CONFIGURE_PAGER", + NULL, + N_("Remembered Windows Settings"), + "SOUND_SETTINGS_PAGER", + _DlgFillRemember +}; + /* ... combine writes, only save after a timeout */ void diff --git a/src/sound.c b/src/sound.c index fa694bd6..7b40caf7 100644 --- a/src/sound.c +++ b/src/sound.c @@ -439,26 +439,12 @@ CB_ConfigureAudio(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -SettingsAudio(void) +_DlgFillSound(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_AUDIO"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_AUDIO"); + DItem *di; tmp_audio = Conf_sound.enable; - d = DialogCreate("CONFIGURE_AUDIO"); - DialogSetTitle(d, _("Audio Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -479,10 +465,16 @@ SettingsAudio(void) #endif DialogAddFooter(d, DLG_OAC, CB_ConfigureAudio); - - DialogShow(d); } +const DialogDef DlgSound = { + "CONFIGURE_AUDIO", + N_("Sound"), + N_("Audio Settings"), + "SOUND_SETTINGS_AUDIO", + _DlgFillSound +}; + /* * IPC functions */ @@ -506,7 +498,7 @@ SoundIpc(const char *params, Client * c __UNUSED__) if (!strncmp(cmd, "cfg", 3)) { - SettingsAudio(); + DialogShowSimple(&DlgSound, NULL); } else if (!strncmp(cmd, "del", 3)) { diff --git a/src/tooltips.c b/src/tooltips.c index 4906b351..88690e5b 100644 --- a/src/tooltips.c +++ b/src/tooltips.c @@ -839,28 +839,14 @@ CB_ConfigureTooltips(Dialog * d __UNUSED__, int val, void *data __UNUSED__) } static void -SettingsTooltips(void) +_DlgFillTooltips(Dialog * d, DItem * table, void *data __UNUSED__) { - Dialog *d; - DItem *table, *di; - - d = DialogFind("CONFIGURE_TOOLTIPS"); - if (d) - { - SoundPlay("SOUND_SETTINGS_ACTIVE"); - DialogShow(d); - return; - } - SoundPlay("SOUND_SETTINGS_TOOLTIPS"); + DItem *di; tmp_tooltips = Conf_tooltips.enable; tmp_tooltiptime = Conf_tooltips.delay / 10; tmp_roottip = Conf_tooltips.showroottooltip; - d = DialogCreate("CONFIGURE_TOOLTIPS"); - DialogSetTitle(d, _("Tooltip Settings")); - - table = DialogInitItem(d); DialogItemTableSetOptions(table, 2, 0, 0, 0); if (Conf.dialogs.headers) @@ -888,16 +874,22 @@ SettingsTooltips(void) DialogItemSliderSetValPtr(di, &tmp_tooltiptime); DialogAddFooter(d, DLG_OAC, CB_ConfigureTooltips); - - DialogShow(d); } +const DialogDef DlgTooltips = { + "CONFIGURE_TOOLTIPS", + N_("Tooltips"), + N_("Tooltip Settings"), + "SOUND_SETTINGS_TOOLTIPS", + _DlgFillTooltips +}; + static void TooltipsIpc(const char *params, Client * c __UNUSED__) { if (params && !strncmp(params, "cfg", 3)) { - SettingsTooltips(); + DialogShowSimple(&DlgTooltips, NULL); } }