1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wmaker: moved the list of Application Attributes into an array, for the Window Inspector

The Window Inspector is used to let user change a list of advanced options
for all the windows of an application. This list was defined through many
hard-coded things; by defining an array with everything at the beginning of
the file it is easier to maintain (the code is simpler because it is more
generic) and to make it evolve.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2015-05-10 19:56:02 +02:00
committed by Carlos R. Mafra
parent 8276ff1331
commit a8f6abc9ea

View File

@@ -162,6 +162,20 @@ static const struct {
,{ "NoLanguageButton", { .no_language_button = 1 }, N_("Disable language button"), ,{ "NoLanguageButton", { .no_language_button = 1 }, N_("Disable language button"),
N_("Remove the `toggle language' button of the window.") } N_("Remove the `toggle language' button of the window.") }
#endif #endif
}, application_attr[] = {
{ "StartHidden", { .start_hidden = 1 }, N_("Start hidden"),
N_("Automatically hide application when it's started.") },
{ "NoAppIcon", { .no_appicon = 1 }, N_("No application icon"),
N_("Disable the application icon for the application.\n"
"Note that you won't be able to dock it anymore,\n"
"and any icons that are already docked will stop\n"
"working correctly.") },
{ "SharedAppIcon", { .shared_appicon = 1 }, N_("Shared application icon"),
N_("Use a single shared application icon for all of\n"
"the instances of this application.\n") }
}; };
typedef struct InspectorPanel { typedef struct InspectorPanel {
@@ -207,7 +221,7 @@ typedef struct InspectorPanel {
/* 5th page. application wide attributes */ /* 5th page. application wide attributes */
WMFrame *appFrm; WMFrame *appFrm;
WMButton *appChk[3]; WMButton *appChk[sizeof(application_attr) / sizeof(application_attr[0])];
unsigned int done:1; unsigned int done:1;
unsigned int destroyed:1; unsigned int destroyed:1;
@@ -225,15 +239,13 @@ static InspectorPanel *panelList = NULL;
*/ */
static WMPropList *pl_attribute[sizeof(window_attribute) / sizeof(window_attribute[0])] = { [0] = NULL }; static WMPropList *pl_attribute[sizeof(window_attribute) / sizeof(window_attribute[0])] = { [0] = NULL };
static WMPropList *pl_advoptions[sizeof(advanced_option) / sizeof(advanced_option[0])]; static WMPropList *pl_advoptions[sizeof(advanced_option) / sizeof(advanced_option[0])];
static WMPropList *pl_appattrib[sizeof(application_attr) / sizeof(application_attr[0])];
static WMPropList *ANoAppIcon;
static WMPropList *AAlwaysUserIcon; static WMPropList *AAlwaysUserIcon;
static WMPropList *ASharedAppIcon;
static WMPropList *AStartWorkspace; static WMPropList *AStartWorkspace;
static WMPropList *AIcon; static WMPropList *AIcon;
/* application wide options */ /* application wide options */
static WMPropList *AStartHidden;
static WMPropList *AnyWindow; static WMPropList *AnyWindow;
static WMPropList *EmptyString; static WMPropList *EmptyString;
static WMPropList *Yes, *No; static WMPropList *Yes, *No;
@@ -311,11 +323,11 @@ static void make_keys(void)
for (i = 0; i < wlengthof(advanced_option); i++) for (i = 0; i < wlengthof(advanced_option); i++)
pl_advoptions[i] = WMCreatePLString(advanced_option[i].key_name); pl_advoptions[i] = WMCreatePLString(advanced_option[i].key_name);
for (i = 0; i < wlengthof(application_attr); i++)
pl_appattrib[i] = WMCreatePLString(application_attr[i].key_name);
AIcon = WMCreatePLString("Icon"); AIcon = WMCreatePLString("Icon");
ANoAppIcon = WMCreatePLString("NoAppIcon");
AAlwaysUserIcon = WMCreatePLString("AlwaysUserIcon"); AAlwaysUserIcon = WMCreatePLString("AlwaysUserIcon");
AStartHidden = WMCreatePLString("StartHidden");
ASharedAppIcon = WMCreatePLString("SharedAppIcon");
AStartWorkspace = WMCreatePLString("StartWorkspace"); AStartWorkspace = WMCreatePLString("StartWorkspace");
@@ -640,15 +652,12 @@ static void saveSettings(WMWidget *button, void *client_data)
different |= insertAttribute(dict, winDic, pl_advoptions[i], value, flags); different |= insertAttribute(dict, winDic, pl_advoptions[i], value, flags);
} }
/* Attributes... --> Application Specific */
if (wwin->main_window != None && wApplicationOf(wwin->main_window) != NULL) { if (wwin->main_window != None && wApplicationOf(wwin->main_window) != NULL) {
value = (WMGetButtonSelected(panel->appChk[0]) != 0) ? Yes : No; for (i = 0; i < wlengthof(application_attr); i++) {
different2 |= insertAttribute(dict, appDic, AStartHidden, value, flags); value = (WMGetButtonSelected(panel->appChk[i]) != 0) ? Yes : No;
different2 |= insertAttribute(dict, appDic, pl_appattrib[i], value, flags);
value = (WMGetButtonSelected(panel->appChk[1]) != 0) ? Yes : No; }
different2 |= insertAttribute(dict, appDic, ANoAppIcon, value, flags);
value = (WMGetButtonSelected(panel->appChk[2]) != 0) ? Yes : No;
different2 |= insertAttribute(dict, appDic, ASharedAppIcon, value, flags);
} }
if (wwin->fake_group) { if (wwin->fake_group) {
@@ -780,9 +789,14 @@ static void applySettings(WMWidget *button, void *client_data)
/* Can't apply emulate_appicon because it will probably cause problems. */ /* Can't apply emulate_appicon because it will probably cause problems. */
if (wapp) { if (wapp) {
/* do application wide stuff */ /* do application wide stuff */
WSETUFLAG(wapp->main_window_desc, start_hidden, WMGetButtonSelected(panel->appChk[0])); for (i = 0; i < wlengthof(application_attr); i++) {
WSETUFLAG(wapp->main_window_desc, no_appicon, WMGetButtonSelected(panel->appChk[1])); if (WMGetButtonSelected(panel->appChk[i]))
WSETUFLAG(wapp->main_window_desc, shared_appicon, WMGetButtonSelected(panel->appChk[2])); set_attr_flag(&wapp->main_window_desc->user_flags, &application_attr[i].flag);
else
clear_attr_flag(&wapp->main_window_desc->user_flags, &application_attr[i].flag);
set_attr_flag(&wapp->main_window_desc->defined_user_flags, &application_attr[i].flag);
}
if (WFLAGP(wapp->main_window_desc, no_appicon)) if (WFLAGP(wapp->main_window_desc, no_appicon))
unpaint_app_icon(wapp); unpaint_app_icon(wapp);
@@ -907,21 +921,18 @@ static void revertSettings(WMWidget *button, void *client_data)
WMSetButtonSelected(panel->moreChk[i], flag); WMSetButtonSelected(panel->moreChk[i], flag);
} }
if (panel->appFrm && wapp) {
for (i = 0; i < wlengthof(panel->appChk); i++) {
int flag = 0;
switch (i) { /* Attributes... --> Application Specific */
case 0: if (panel->appFrm && wapp) {
flag = WFLAGP(wapp->main_window_desc, start_hidden); for (i = 0; i < wlengthof(application_attr); i++) {
break; int is_userdef, flag = 0;
case 1:
flag = WFLAGP(wapp->main_window_desc, no_appicon); is_userdef = get_attr_flag(&wapp->main_window_desc->defined_user_flags, &application_attr[i].flag);
break; if (is_userdef)
case 2: flag = get_attr_flag(&wapp->main_window_desc->user_flags, &application_attr[i].flag);
flag = WFLAGP(wapp->main_window_desc, shared_appicon); else
break; flag = get_attr_flag(&wapp->main_window_desc->client_flags, &application_attr[i].flag);
}
WMSetButtonSelected(panel->appChk[i], flag); WMSetButtonSelected(panel->appChk[i], flag);
} }
} }
@@ -1414,9 +1425,7 @@ static void create_tab_icon_workspace(WWindow *wwin, InspectorPanel *panel)
static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width) static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width)
{ {
WScreen *scr = wwin->screen_ptr; WScreen *scr = wwin->screen_ptr;
int i = 0, flag = 0, tmp; int i = 0, tmp;
char *caption = NULL, *descr = NULL;
if (wwin->main_window != None) { if (wwin->main_window != None) {
WApplication *wapp = wApplicationOf(wwin->main_window); WApplication *wapp = wApplicationOf(wwin->main_window);
@@ -1426,34 +1435,23 @@ static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int fr
WMMoveWidget(panel->appFrm, 15, 50); WMMoveWidget(panel->appFrm, 15, 50);
WMResizeWidget(panel->appFrm, frame_width, 240); WMResizeWidget(panel->appFrm, frame_width, 240);
for (i = 0; i < wlengthof(panel->appChk); i++) { for (i = 0; i < wlengthof(application_attr); i++) {
switch (i) { int is_userdef, flag;
case 0:
caption = _("Start hidden"); is_userdef = get_attr_flag(&wapp->main_window_desc->defined_user_flags, &application_attr[i].flag);
flag = WFLAGP(wapp->main_window_desc, start_hidden); if (is_userdef)
descr = _("Automatically hide application when it's started."); flag = get_attr_flag(&wapp->main_window_desc->user_flags, &application_attr[i].flag);
break; else
case 1: flag = get_attr_flag(&wapp->main_window_desc->client_flags, &application_attr[i].flag);
caption = _("No application icon");
flag = WFLAGP(wapp->main_window_desc, no_appicon);
descr = _("Disable the application icon for the application.\n"
"Note that you won't be able to dock it anymore,\n"
"and any icons that are already docked will stop\n"
"working correctly.");
break;
case 2:
caption = _("Shared application icon");
flag = WFLAGP(wapp->main_window_desc, shared_appicon);
descr = _("Use a single shared application icon for all of\n"
"the instances of this application.\n");
break;
}
panel->appChk[i] = WMCreateSwitchButton(panel->appFrm); panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
WMMoveWidget(panel->appChk[i], 10, 20 * (i + 1)); WMMoveWidget(panel->appChk[i], 10, 20 * (i + 1));
WMResizeWidget(panel->appChk[i], 205, 20); WMResizeWidget(panel->appChk[i], 205, 20);
WMSetButtonSelected(panel->appChk[i], flag); WMSetButtonSelected(panel->appChk[i], flag);
WMSetButtonText(panel->appChk[i], caption); WMSetButtonText(panel->appChk[i], _(application_attr[i].caption));
WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i]));
WMSetBalloonTextForView(_(application_attr[i].description),
WMWidgetView(panel->appChk[i]));
} }
if (WFLAGP(wwin, emulate_appicon)) { if (WFLAGP(wwin, emulate_appicon)) {