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

winspector.c: Full clean patch

This patch sets a correct style on winspector.c. It removes some
empty lines, moves variable definitions to the function heads,
moves preprocessor definitions to the top of the file and removes
some extra curly brackets.

The function to create the winspector panel is so big, and is hard
to understand it. This patch split the function createInspectorForWindow
in some extra functions:

create_tab_window_attributes
create_tab_window_advanced
create_tab_icon_workspace
create_tab_app_specific

This functions don't do nothing extra, only the code is moved to them.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-11-25 21:44:36 +01:00
committed by Carlos R. Mafra
parent bf2f942138
commit 99e5a7a9eb
2 changed files with 246 additions and 309 deletions

View File

@@ -869,20 +869,18 @@ void wReadStaticDefaults(WMPropList * dict)
else else
plvalue = NULL; plvalue = NULL;
if (!plvalue) {
/* no default in the DB. Use builtin default */ /* no default in the DB. Use builtin default */
if (!plvalue)
plvalue = entry->plvalue; plvalue = entry->plvalue;
}
if (plvalue) { if (plvalue) {
/* convert data */ /* convert data */
(*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata); (*entry->convert) (NULL, entry, plvalue, entry->addr, &tdata);
if (entry->update) { if (entry->update)
(*entry->update) (NULL, entry, tdata, entry->extra_data); (*entry->update) (NULL, entry, tdata, entry->extra_data);
} }
} }
} }
}
void wDefaultsCheckDomains(void* arg) void wDefaultsCheckDomains(void* arg)
{ {
@@ -953,9 +951,10 @@ void wDefaultsCheckDomains(void* arg)
dict = shared_dict; dict = shared_dict;
shared_dict = NULL; shared_dict = NULL;
} }
if (WDWindowAttributes->dictionary) {
if (WDWindowAttributes->dictionary)
WMReleasePropList(WDWindowAttributes->dictionary); WMReleasePropList(WDWindowAttributes->dictionary);
}
WDWindowAttributes->dictionary = dict; WDWindowAttributes->dictionary = dict;
for (i = 0; i < wScreenCount; i++) { for (i = 0; i < wScreenCount; i++) {
scr = wScreenWithNumber(i); scr = wScreenWithNumber(i);
@@ -972,11 +971,11 @@ void wDefaultsCheckDomains(void* arg)
} else { } else {
wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes"); wwarning(_("could not load domain %s from user defaults database"), "WMWindowAttributes");
} }
WDWindowAttributes->timestamp = stbuf.st_mtime; WDWindowAttributes->timestamp = stbuf.st_mtime;
if (shared_dict) { if (shared_dict)
WMReleasePropList(shared_dict); WMReleasePropList(shared_dict);
} }
}
if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) { if (stat(WDRootMenu->path, &stbuf) >= 0 && WDRootMenu->timestamp < stbuf.st_mtime) {
dict = WMReadPropListFromFile(WDRootMenu->path); dict = WMReadPropListFromFile(WDRootMenu->path);
@@ -987,9 +986,9 @@ void wDefaultsCheckDomains(void* arg)
wwarning(_("Domain %s (%s) of defaults database is corrupted!"), wwarning(_("Domain %s (%s) of defaults database is corrupted!"),
"WMRootMenu", WDRootMenu->path); "WMRootMenu", WDRootMenu->path);
} else { } else {
if (WDRootMenu->dictionary) { if (WDRootMenu->dictionary)
WMReleasePropList(WDRootMenu->dictionary); WMReleasePropList(WDRootMenu->dictionary);
}
WDRootMenu->dictionary = dict; WDRootMenu->dictionary = dict;
wDefaultsMergeGlobalMenus(WDRootMenu); wDefaultsMergeGlobalMenus(WDRootMenu);
} }

View File

@@ -50,38 +50,39 @@
#include <WINGs/WUtil.h> #include <WINGs/WUtil.h>
#define USE_TEXT_FIELD 1
#define UPDATE_TEXT_FIELD 2
#define REVERT_TO_DEFAULT 4
#define PWIDTH 290
#define PHEIGHT 360
#define UNDEFINED_POS 0xffffff
#define UPDATE_DEFAULTS 1
#define IS_BOOLEAN 2
typedef struct InspectorPanel { typedef struct InspectorPanel {
struct InspectorPanel *nextPtr; struct InspectorPanel *nextPtr;
WWindow *frame; WWindow *frame;
WWindow *inspected; /* the window that's being inspected */ WWindow *inspected; /* the window that's being inspected */
WMWindow *win; WMWindow *win;
Window parent; Window parent;
/* common stuff */ /* common stuff */
WMButton *revertBtn; WMButton *revertBtn;
WMButton *applyBtn; WMButton *applyBtn;
WMButton *saveBtn; WMButton *saveBtn;
WMPopUpButton *pagePopUp; WMPopUpButton *pagePopUp;
/* first page. general stuff */ /* first page. general stuff */
WMFrame *specFrm; WMFrame *specFrm;
WMButton *instRb; WMButton *instRb;
WMButton *clsRb; WMButton *clsRb;
WMButton *bothRb; WMButton *bothRb;
WMButton *defaultRb; WMButton *defaultRb;
WMButton *selWinB; WMButton *selWinB;
WMLabel *specLbl; WMLabel *specLbl;
/* second page. attributes */ /* second page. attributes */
WMFrame *attrFrm; WMFrame *attrFrm;
WMButton *attrChk[11]; WMButton *attrChk[11];
@@ -99,11 +100,7 @@ typedef struct InspectorPanel {
WMLabel *fileLbl; WMLabel *fileLbl;
WMTextField *fileText; WMTextField *fileText;
WMButton *alwChk; WMButton *alwChk;
/*
WMButton *updateIconBtn;
*/
WMButton *browseIconBtn; WMButton *browseIconBtn;
WMFrame *wsFrm; WMFrame *wsFrm;
WMPopUpButton *wsP; WMPopUpButton *wsP;
@@ -158,16 +155,16 @@ static WMPropList *AnyWindow;
static WMPropList *EmptyString; static WMPropList *EmptyString;
static WMPropList *Yes, *No; static WMPropList *Yes, *No;
#define PWIDTH 290
#define PHEIGHT 360
static char *spec_text; static char *spec_text;
static void applySettings(WMButton *button, InspectorPanel *panel); static void applySettings(WMButton *button, InspectorPanel *panel);
#define UNDEFINED_POS 0xffffff
static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypos, Bool showSelectPanel); static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypos, Bool showSelectPanel);
static void create_tab_window_attributes(WWindow *wwin, InspectorPanel *panel, int frame_width);
static void create_tab_window_advanced(WWindow *wwin, InspectorPanel *panel, int frame_width);
static void create_tab_icon_workspace(WWindow *wwin, InspectorPanel *panel, int frame_width);
static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width);
static void make_keys(void) static void make_keys(void)
{ {
if (ANoTitlebar != NULL) if (ANoTitlebar != NULL)
@@ -226,20 +223,19 @@ static void freeInspector(InspectorPanel *panel)
static void destroyInspector(WCoreWindow *foo, void *data, XEvent *event) static void destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
{ {
InspectorPanel *panel; InspectorPanel *panel, *tmp;
InspectorPanel *tmp;
panel = panelList; panel = panelList;
while (panel->frame != data) while (panel->frame != data)
panel = panel->nextPtr; panel = panel->nextPtr;
if (panelList == panel) if (panelList == panel) {
panelList = panel->nextPtr; panelList = panel->nextPtr;
else { } else {
tmp = panelList; tmp = panelList;
while (tmp->nextPtr != panel) { while (tmp->nextPtr != panel)
tmp = tmp->nextPtr; tmp = tmp->nextPtr;
}
tmp->nextPtr = panel->nextPtr; tmp->nextPtr = panel->nextPtr;
} }
panel->inspected->flags.inspector_open = 0; panel->inspected->flags.inspector_open = 0;
@@ -306,15 +302,10 @@ static void changePage(WMPopUpButton *bPtr, InspectorPanel *panel)
WMUnmapWidget(panel->appFrm); WMUnmapWidget(panel->appFrm);
} }
#define USE_TEXT_FIELD 1
#define UPDATE_TEXT_FIELD 2
#define REVERT_TO_DEFAULT 4
static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instance, char *wm_class, int flags) static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instance, char *wm_class, int flags)
{ {
WMPixmap *pixmap = (WMPixmap *) NULL; WMPixmap *pixmap = (WMPixmap *) NULL;
char *file = NULL, *path = NULL; char *file = NULL, *path = NULL, *db_icon = NULL;
char *db_icon = NULL;
if ((flags & USE_TEXT_FIELD) != 0) { if ((flags & USE_TEXT_FIELD) != 0) {
file = WMGetTextFieldText(panel->fileText); file = WMGetTextFieldText(panel->fileText);
@@ -334,9 +325,8 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instanc
flags |= UPDATE_TEXT_FIELD; flags |= UPDATE_TEXT_FIELD;
} }
if ((flags & UPDATE_TEXT_FIELD) != 0) { if ((flags & UPDATE_TEXT_FIELD) != 0)
WMSetTextFieldText(panel->fileText, file); WMSetTextFieldText(panel->fileText, file);
}
if (file) { if (file) {
path = FindImage(wPreferences.icon_path, file); path = FindImage(wPreferences.icon_path, file);
@@ -378,32 +368,25 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instanc
return 0; return 0;
} }
#if 0
static void updateIcon(WMButton * button, InspectorPanel * panel)
{
showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
}
#endif
static int getBool(WMPropList *value) static int getBool(WMPropList *value)
{ {
char *val; char *val;
if (!WMIsPLString(value)) { if (!WMIsPLString(value))
return 0; return 0;
}
if (!(val = WMGetFromPLString(value))) { if (!(val = WMGetFromPLString(value)))
return 0; return 0;
}
if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' || val[0] == 't' || val[0] == '1'))
|| (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
if ((val[1] == '\0' &&
(val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' ||
val[0] == 't' || val[0] == '1')) ||
(strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
return 1; return 1;
} else if ((val[1] == '\0' } else if ((val[1] == '\0' &&
&& (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || val[0] == 'f' || val[0] == '0')) (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' ||
|| (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") == 0)) { val[0] == 'f' || val[0] == '0')) ||
(strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") == 0)) {
return 0; return 0;
} else { } else {
wwarning(_("can't convert \"%s\" to boolean"), val); wwarning(_("can't convert \"%s\" to boolean"), val);
@@ -411,42 +394,31 @@ static int getBool(WMPropList *value)
} }
} }
#define UPDATE_DEFAULTS 1 /* Will insert the attribute = value; pair in window's list,
#define IS_BOOLEAN 2
/*
* Will insert the attribute = value; pair in window's list,
* if it's different from the defaults. * if it's different from the defaults.
* Defaults means either defaults database, or attributes saved * Defaults means either defaults database, or attributes saved
* for the default window "*". This is to let one revert options that are * for the default window "*". This is to let one revert options that are
* global because they were saved for all windows ("*"). * global because they were saved for all windows ("*"). */
*
*/
static int static int
insertAttribute(WMPropList *dict, WMPropList *window, WMPropList *attr, WMPropList *value, int flags) insertAttribute(WMPropList *dict, WMPropList *window, WMPropList *attr, WMPropList *value, int flags)
{ {
WMPropList *def_win, *def_value = NULL; WMPropList *def_win, *def_value = NULL;
int update = 0; int update = 0, modified = 0;
int modified = 0;
if (!(flags & UPDATE_DEFAULTS) && dict) { if (!(flags & UPDATE_DEFAULTS) && dict) {
if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL) { if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL)
def_value = WMGetFromPLDictionary(def_win, attr); def_value = WMGetFromPLDictionary(def_win, attr);
} }
}
/* If we could not find defaults in database, fall to hardcoded values. /* If we could not find defaults in database, fall to hardcoded values.
* Also this is true if we save defaults for all windows * Also this is true if we save defaults for all windows */
*/
if (!def_value) if (!def_value)
def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString; def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
if ((flags & IS_BOOLEAN)) if (flags & IS_BOOLEAN)
update = (getBool(value) != getBool(def_value)); update = (getBool(value) != getBool(def_value));
else { else
update = !WMIsPropListEqualTo(value, def_value); update = !WMIsPropListEqualTo(value, def_value);
}
if (update) { if (update) {
WMPutInPLDictionary(window, attr, value); WMPutInPLDictionary(window, attr, value);
@@ -460,34 +432,31 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
{ {
WWindow *wwin = panel->inspected; WWindow *wwin = panel->inspected;
WDDomain *db = WDWindowAttributes; WDDomain *db = WDWindowAttributes;
WMPropList *dict = db->dictionary; WMPropList *dict = NULL;
WMPropList *winDic, *appDic, *value, *key, *key2; WMPropList *winDic, *appDic, *value, *key = NULL, *key2;
char *icon_file; char *icon_file, *buf1, *buf2;
int flags = 0; int flags = 0, i = 0, different = 0, different2 = 0;
int different = 0, different2 = 0;
/* Save will apply the changes and save them */ /* Save will apply the changes and save them */
applySettings(panel->applyBtn, panel); applySettings(panel->applyBtn, panel);
if (WMGetButtonSelected(panel->instRb) != 0) if (WMGetButtonSelected(panel->instRb) != 0) {
key = WMCreatePLString(wwin->wm_instance); key = WMCreatePLString(wwin->wm_instance);
else if (WMGetButtonSelected(panel->clsRb) != 0) } else if (WMGetButtonSelected(panel->clsRb) != 0) {
key = WMCreatePLString(wwin->wm_class); key = WMCreatePLString(wwin->wm_class);
else if (WMGetButtonSelected(panel->bothRb) != 0) { } else if (WMGetButtonSelected(panel->bothRb) != 0) {
char *buffer; buf1 = StrConcatDot(wwin->wm_instance, wwin->wm_class);
key = WMCreatePLString(buf1);
buffer = StrConcatDot(wwin->wm_instance, wwin->wm_class); wfree(buf1);
key = WMCreatePLString(buffer);
wfree(buffer);
} else if (WMGetButtonSelected(panel->defaultRb) != 0) { } else if (WMGetButtonSelected(panel->defaultRb) != 0) {
key = WMRetainPropList(AnyWindow); key = WMRetainPropList(AnyWindow);
flags = UPDATE_DEFAULTS; flags = UPDATE_DEFAULTS;
} else }
key = NULL;
if (!key) if (!key)
return; return;
dict = db->dictionary;
if (!dict) { if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL); dict = WMCreatePLDictionary(NULL, NULL);
if (dict) { if (dict) {
@@ -518,17 +487,12 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
wfree(icon_file); wfree(icon_file);
} }
{ i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
int i = WMGetPopUpButtonSelectedItem(panel->wsP);
i--;
if (i >= 0 && i < panel->frame->screen_ptr->workspace_count) { if (i >= 0 && i < panel->frame->screen_ptr->workspace_count) {
value = WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name); value = WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name);
different |= insertAttribute(dict, winDic, AStartWorkspace, value, flags); different |= insertAttribute(dict, winDic, AStartWorkspace, value, flags);
WMReleasePropList(value); WMReleasePropList(value);
} }
}
flags |= IS_BOOLEAN; flags |= IS_BOOLEAN;
@@ -624,23 +588,19 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
different |= different2; different |= different2;
} else { } else {
WMRemoveFromPLDictionary(dict, key2); WMRemoveFromPLDictionary(dict, key2);
if (different2) { if (different2)
WMPutInPLDictionary(dict, key2, appDic); WMPutInPLDictionary(dict, key2, appDic);
} }
}
WMReleasePropList(key2); WMReleasePropList(key2);
WMReleasePropList(appDic); WMReleasePropList(appDic);
} else if (wwin->main_window != wwin->client_win) { } else if (wwin->main_window != wwin->client_win) {
WApplication *wapp = wApplicationOf(wwin->main_window); WApplication *wapp = wApplicationOf(wwin->main_window);
if (wapp) { if (wapp) {
char *instance = wapp->main_window_desc->wm_instance; buf2 = StrConcatDot(wapp->main_window_desc->wm_instance,
char *class = wapp->main_window_desc->wm_class; wapp->main_window_desc->wm_class);
char *buffer; key2 = WMCreatePLString(buf2);
wfree(buf2);
buffer = StrConcatDot(instance, class);
key2 = WMCreatePLString(buffer);
wfree(buffer);
if (WMIsPropListEqualTo(key, key2)) { if (WMIsPropListEqualTo(key, key2)) {
WMMergePLDictionaries(winDic, appDic, True); WMMergePLDictionaries(winDic, appDic, True);
@@ -660,9 +620,8 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
} }
WMRemoveFromPLDictionary(dict, key); WMRemoveFromPLDictionary(dict, key);
if (different) { if (different)
WMPutInPLDictionary(dict, key, winDic); WMPutInPLDictionary(dict, key, winDic);
}
WMReleasePropList(key); WMReleasePropList(key);
WMReleasePropList(winDic); WMReleasePropList(winDic);
@@ -678,9 +637,7 @@ static void applySettings(WMButton *button, InspectorPanel *panel)
WWindow *wwin = panel->inspected; WWindow *wwin = panel->inspected;
WApplication *wapp = wApplicationOf(wwin->main_window); WApplication *wapp = wApplicationOf(wwin->main_window);
int floating, sunken, skip_window_list; int floating, sunken, skip_window_list;
int old_omnipresent; int old_omnipresent, old_no_bind_keys, old_no_bind_mouse;
int old_no_bind_keys;
int old_no_bind_mouse;
old_omnipresent = WFLAGP(wwin, omnipresent); old_omnipresent = WFLAGP(wwin, omnipresent);
old_no_bind_keys = WFLAGP(wwin, no_bind_keys); old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
@@ -742,31 +699,26 @@ static void applySettings(WMButton *button, InspectorPanel *panel)
WSETUFLAG(wwin, skip_window_list, skip_window_list); WSETUFLAG(wwin, skip_window_list, skip_window_list);
UpdateSwitchMenu(wwin->screen_ptr, wwin, skip_window_list ? ACTION_REMOVE : ACTION_ADD); UpdateSwitchMenu(wwin->screen_ptr, wwin, skip_window_list ? ACTION_REMOVE : ACTION_ADD);
} else { } else {
if (WFLAGP(wwin, omnipresent) != old_omnipresent) { if (WFLAGP(wwin, omnipresent) != old_omnipresent)
WMPostNotificationName(WMNChangedState, wwin, "omnipresent"); WMPostNotificationName(WMNChangedState, wwin, "omnipresent");
} }
}
if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) { if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
if (WFLAGP(wwin, no_bind_keys)) { if (WFLAGP(wwin, no_bind_keys))
XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
} else { else
wWindowSetKeyGrabs(wwin); wWindowSetKeyGrabs(wwin);
} }
}
if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) { if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse)
wWindowResetMouseGrabs(wwin); wWindowResetMouseGrabs(wwin);
}
wwin->frame->flags.need_texture_change = 1; wwin->frame->flags.need_texture_change = 1;
wWindowConfigureBorders(wwin); wWindowConfigureBorders(wwin);
wFrameWindowPaint(wwin->frame); wFrameWindowPaint(wwin->frame);
wNETWMUpdateActions(wwin, False); wNETWMUpdateActions(wwin, False);
/* /* 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])); WSETUFLAG(wapp->main_window_desc, start_hidden, WMGetButtonSelected(panel->appChk[0]));
@@ -813,10 +765,8 @@ static void revertSettings(WMButton *button, InspectorPanel *panel)
{ {
WWindow *wwin = panel->inspected; WWindow *wwin = panel->inspected;
WApplication *wapp = wApplicationOf(wwin->main_window); WApplication *wapp = wApplicationOf(wwin->main_window);
int i, n; int i, n, workspace, level;
char *wm_instance = NULL; char *wm_instance = NULL, *wm_class = NULL;
char *wm_class = NULL;
int workspace, level;
if (panel->instRb && WMGetButtonSelected(panel->instRb) != 0) if (panel->instRb && WMGetButtonSelected(panel->instRb) != 0)
wm_instance = wwin->wm_instance; wm_instance = wwin->wm_instance;
@@ -826,6 +776,7 @@ static void revertSettings(WMButton *button, InspectorPanel *panel)
wm_instance = wwin->wm_instance; wm_instance = wwin->wm_instance;
wm_class = wwin->wm_class; wm_class = wwin->wm_class;
} }
memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes)); memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
memset(&wwin->user_flags, 0, sizeof(WWindowAttributes)); memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
memset(&wwin->client_flags, 0, sizeof(WWindowAttributes)); memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
@@ -872,6 +823,7 @@ static void revertSettings(WMButton *button, InspectorPanel *panel)
} }
WMSetButtonSelected(panel->attrChk[i], flag); WMSetButtonSelected(panel->attrChk[i], flag);
} }
for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) { for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) {
int flag = 0; int flag = 0;
@@ -941,11 +893,10 @@ static void revertSettings(WMButton *button, InspectorPanel *panel)
n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class); n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
if (n >= 0 && n < wwin->screen_ptr->workspace_count) { if (n >= 0 && n < wwin->screen_ptr->workspace_count)
WMSetPopUpButtonSelectedItem(panel->wsP, n + 1); WMSetPopUpButtonSelectedItem(panel->wsP, n + 1);
} else { else
WMSetPopUpButtonSelectedItem(panel->wsP, 0); WMSetPopUpButtonSelectedItem(panel->wsP, 0);
}
/* must auto apply, so that there wno't be internal /* must auto apply, so that there wno't be internal
* inconsistencies between the state in the flags and * inconsistencies between the state in the flags and
@@ -964,7 +915,8 @@ static void chooseIconCallback(WMWidget *self, void *clientData)
WMSetButtonEnabled(panel->browseIconBtn, False); WMSetButtonEnabled(panel->browseIconBtn, False);
result = wIconChooserDialog(panel->frame->screen_ptr, &file, result = wIconChooserDialog(panel->frame->screen_ptr, &file,
panel->inspected->wm_instance, panel->inspected->wm_class); panel->inspected->wm_instance,
panel->inspected->wm_class);
panel->choosingIcon = 0; panel->choosingIcon = 0;
@@ -988,9 +940,6 @@ static void textEditedObserver(void *observerData, WMNotification *notification)
return; return;
showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL, USE_TEXT_FIELD); showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL, USE_TEXT_FIELD);
/*
WMPerformButtonClick(panel->updateIconBtn);
*/
} }
static void selectSpecification(WMWidget *bPtr, void *data) static void selectSpecification(WMWidget *bPtr, void *data)
@@ -1034,15 +983,11 @@ static void selectWindow(WMWidget *bPtr, void *data)
} }
WMSetLabelText(panel->specLbl, _("Click in the window you wish to inspect.")); WMSetLabelText(panel->specLbl, _("Click in the window you wish to inspect."));
WMMaskEvent(dpy, ButtonPressMask, &event); WMMaskEvent(dpy, ButtonPressMask, &event);
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
iwin = wWindowFor(event.xbutton.subwindow); iwin = wWindowFor(event.xbutton.subwindow);
if (iwin && !iwin->flags.internal_window && iwin != wwin && !iwin->flags.inspector_open) { if (iwin && !iwin->flags.internal_window && iwin != wwin && !iwin->flags.inspector_open) {
iwin->flags.inspector_open = 1; iwin->flags.inspector_open = 1;
iwin->inspector = createInspectorForWindow(iwin, iwin->inspector = createInspectorForWindow(iwin,
panel->frame->frame_x, panel->frame->frame_y, True); panel->frame->frame_x, panel->frame->frame_y, True);
@@ -1057,13 +1002,9 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WScreen *scr = wwin->screen_ptr; WScreen *scr = wwin->screen_ptr;
InspectorPanel *panel; InspectorPanel *panel;
Window parent; Window parent;
int i; char *str = NULL, *tmp = NULL;
int x, y; int x, y, btn_width, frame_width;
int btn_width, frame_width;
WMButton *selectedBtn = NULL; WMButton *selectedBtn = NULL;
#ifdef wrong_behaviour
WMPixmap *pixmap;
#endif
spec_text = _("The configuration will apply to all\n" spec_text = _("The configuration will apply to all\n"
"windows that have their WM_CLASS\n" "windows that have their WM_CLASS\n"
@@ -1073,19 +1014,14 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
memset(panel, 0, sizeof(InspectorPanel)); memset(panel, 0, sizeof(InspectorPanel));
panel->destroyed = 0; panel->destroyed = 0;
panel->inspected = wwin; panel->inspected = wwin;
panel->nextPtr = panelList; panel->nextPtr = panelList;
panelList = panel; panelList = panel;
panel->win = WMCreateWindow(scr->wmscreen, "windowInspector"); panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
WMResizeWidget(panel->win, PWIDTH, PHEIGHT); WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
/**** create common stuff ****/ /**** create common stuff ****/
/* command buttons */ /* command buttons */
/* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3; btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
panel->saveBtn = WMCreateCommandButton(panel->win); panel->saveBtn = WMCreateCommandButton(panel->win);
WMSetButtonAction(panel->saveBtn, (WMAction *) saveSettings, panel); WMSetButtonAction(panel->saveBtn, (WMAction *) saveSettings, panel);
@@ -1135,8 +1071,6 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetButtonAction(panel->defaultRb, selectSpecification, panel); WMSetButtonAction(panel->defaultRb, selectSpecification, panel);
if (wwin->wm_class && wwin->wm_instance) { if (wwin->wm_class && wwin->wm_instance) {
char *str, *tmp;
tmp = wstrconcat(wwin->wm_instance, "."); tmp = wstrconcat(wwin->wm_instance, ".");
str = wstrconcat(tmp, wwin->wm_class); str = wstrconcat(tmp, wwin->wm_class);
@@ -1195,16 +1129,145 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetLabelTextAlignment(panel->specLbl, WALeft); WMSetLabelTextAlignment(panel->specLbl, WALeft);
/**** attributes ****/ /**** attributes ****/
create_tab_window_attributes(wwin, panel, frame_width);
create_tab_window_advanced(wwin, panel, frame_width);
create_tab_icon_workspace(wwin, panel, frame_width);
create_tab_app_specific(wwin, panel, frame_width);
/* if the window is a transient, don't let it have a miniaturize button */
if (wwin->transient_for != None && wwin->transient_for != scr->root_win)
WMSetButtonEnabled(panel->attrChk[3], False);
else
WMSetButtonEnabled(panel->attrChk[3], True);
if (!wwin->wm_class && !wwin->wm_instance)
WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);
WMRealizeWidget(panel->win);
WMMapSubwidgets(panel->win);
WMMapSubwidgets(panel->specFrm);
WMMapSubwidgets(panel->attrFrm);
WMMapSubwidgets(panel->moreFrm);
WMMapSubwidgets(panel->iconFrm);
WMMapSubwidgets(panel->wsFrm);
if (panel->appFrm)
WMMapSubwidgets(panel->appFrm);
if (showSelectPanel) {
WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0);
changePage(panel->pagePopUp, panel);
} else {
WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
changePage(panel->pagePopUp, panel);
}
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 0, 0, 0);
XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);
panel->parent = parent;
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
WMMapWidget(panel->win);
XSetTransientForHint(dpy, parent, wwin->client_win);
if (xpos == UNDEFINED_POS) {
x = wwin->frame_x + wwin->frame->core->width / 2;
y = wwin->frame_y + wwin->frame->top_width * 2;
if (y + PHEIGHT > scr->scr_height)
y = scr->scr_height - PHEIGHT - 30;
if (x + PWIDTH > scr->scr_width)
x = scr->scr_width - PWIDTH;
} else {
x = xpos;
y = ypos;
}
panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, "Inspector", x, y, PWIDTH, PHEIGHT);
if (!selectedBtn)
selectedBtn = panel->defaultRb;
WMSetButtonSelected(selectedBtn, True);
selectSpecification(selectedBtn, panel);
/* kluge to know who should get the key events */
panel->frame->client_leader = WMWidgetXID(panel->win);
WSETUFLAG(panel->frame, no_closable, 0);
WSETUFLAG(panel->frame, no_close_button, 0);
wWindowUpdateButtonImages(panel->frame);
wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
panel->frame->frame->on_click_right = destroyInspector;
wWindowMap(panel->frame);
showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, wwin->wm_class, UPDATE_TEXT_FIELD);
return panel;
}
void wShowInspectorForWindow(WWindow *wwin)
{
if (wwin->flags.inspector_open)
return;
WMSetBalloonEnabled(wwin->screen_ptr->wmscreen, wPreferences.help_balloon);
make_keys();
wwin->flags.inspector_open = 1;
wwin->inspector = createInspectorForWindow(wwin, UNDEFINED_POS, UNDEFINED_POS, False);
}
void wHideInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame;
wWindowUnmap(pwin);
pwin->flags.hidden = 1;
wClientSetState(pwin, IconicState, None);
}
void wUnhideInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame;
pwin->flags.hidden = 0;
pwin->flags.mapped = 1;
XMapWindow(dpy, pwin->client_win);
XMapWindow(dpy, pwin->frame->core->window);
wClientSetState(pwin, NormalState, None);
}
WWindow *wGetWindowOfInspectorForWindow(WWindow *wwin)
{
if (!wwin->inspector)
return NULL;
assert(wwin->flags.inspector_open != 0);
return wwin->inspector->frame;
}
void wCloseInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame; /* the inspector window */
(*pwin->frame->on_click_right) (NULL, pwin, NULL);
}
static void create_tab_window_attributes(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
int i = 0;
char *caption = NULL, *descr = NULL;
int flag = 0;
panel->attrFrm = WMCreateFrame(panel->win); panel->attrFrm = WMCreateFrame(panel->win);
WMSetFrameTitle(panel->attrFrm, _("Attributes")); WMSetFrameTitle(panel->attrFrm, _("Attributes"));
WMMoveWidget(panel->attrFrm, 15, 45); WMMoveWidget(panel->attrFrm, 15, 45);
WMResizeWidget(panel->attrFrm, frame_width, 250); WMResizeWidget(panel->attrFrm, frame_width, 250);
for (i = 0; i < (sizeof(panel->attrChk) / sizeof(panel->attrChk[0])); i++) { for (i = 0; i < (sizeof(panel->attrChk) / sizeof(panel->attrChk[0])); i++) {
char *caption = NULL;
int flag = 0;
char *descr = NULL;
switch (i) { switch (i) {
case 0: case 0:
caption = _("Disable titlebar"); caption = _("Disable titlebar");
@@ -1275,18 +1338,20 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i])); WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i]));
} }
}
static void create_tab_window_advanced(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
int i = 0;
char *caption = NULL, *descr = NULL;
int flag = 0;
/**** more attributes ****/
panel->moreFrm = WMCreateFrame(panel->win); panel->moreFrm = WMCreateFrame(panel->win);
WMSetFrameTitle(panel->moreFrm, _("Advanced")); WMSetFrameTitle(panel->moreFrm, _("Advanced"));
WMMoveWidget(panel->moreFrm, 15, 45); WMMoveWidget(panel->moreFrm, 15, 45);
WMResizeWidget(panel->moreFrm, frame_width, 265); WMResizeWidget(panel->moreFrm, frame_width, 265);
for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) { for (i = 0; i < (sizeof(panel->moreChk) / sizeof(panel->moreChk[0])); i++) {
char *caption = NULL;
int flag = 0;
char *descr = NULL;
switch (i) { switch (i) {
case 0: case 0:
caption = _("Do not bind keyboard shortcuts"); caption = _("Do not bind keyboard shortcuts");
@@ -1370,6 +1435,12 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i])); WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i]));
} }
}
static void create_tab_icon_workspace(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
WScreen *scr = wwin->screen_ptr;
int i = 0;
/* miniwindow/workspace */ /* miniwindow/workspace */
panel->iconFrm = WMCreateFrame(panel->win); panel->iconFrm = WMCreateFrame(panel->win);
@@ -1389,16 +1460,6 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMResizeWidget(panel->browseIconBtn, 120, 26); WMResizeWidget(panel->browseIconBtn, 120, 26);
WMSetButtonText(panel->browseIconBtn, _("Browse...")); WMSetButtonText(panel->browseIconBtn, _("Browse..."));
#ifdef wrong_behaviour
WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
WMSetButtonImage(panel->updateIconBtn, pixmap);
WMReleasePixmap(pixmap);
pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
WMSetButtonAltImage(panel->updateIconBtn, pixmap);
WMReleasePixmap(pixmap);
#endif
panel->fileLbl = WMCreateLabel(panel->iconFrm); panel->fileLbl = WMCreateLabel(panel->iconFrm);
WMMoveWidget(panel->fileLbl, 20, 85); WMMoveWidget(panel->fileLbl, 20, 85);
WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14); WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
@@ -1437,8 +1498,15 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetPopUpButtonSelectedItem(panel->wsP, i + 1); WMSetPopUpButtonSelectedItem(panel->wsP, i + 1);
else else
WMSetPopUpButtonSelectedItem(panel->wsP, 0); WMSetPopUpButtonSelectedItem(panel->wsP, 0);
}
static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width)
{
WScreen *scr = wwin->screen_ptr;
int i = 0, flag = 0, tmp;
char *caption = NULL, *descr = NULL;
/* application wide attributes */
if (wwin->main_window != None) { if (wwin->main_window != None) {
WApplication *wapp = wApplicationOf(wwin->main_window); WApplication *wapp = wApplicationOf(wwin->main_window);
@@ -1448,10 +1516,6 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMResizeWidget(panel->appFrm, frame_width, 240); WMResizeWidget(panel->appFrm, frame_width, 240);
for (i = 0; i < (sizeof(panel->appChk) / sizeof(panel->appChk[0])); i++) { for (i = 0; i < (sizeof(panel->appChk) / sizeof(panel->appChk[0])); i++) {
char *caption = NULL;
int flag = 0;
char *descr = NULL;
switch (i) { switch (i) {
case 0: case 0:
caption = _("Start hidden"); caption = _("Start hidden");
@@ -1489,141 +1553,15 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo
WMSetButtonEnabled(panel->moreChk[7], False); WMSetButtonEnabled(panel->moreChk[7], False);
} }
} else { } else {
int tmp;
if ((wwin->transient_for != None && wwin->transient_for != scr->root_win) if ((wwin->transient_for != None && wwin->transient_for != scr->root_win)
|| !wwin->wm_class || !wwin->wm_instance) || !wwin->wm_class || !wwin->wm_instance)
tmp = False; tmp = False;
else else
tmp = True; tmp = True;
WMSetButtonEnabled(panel->moreChk[7], tmp); WMSetButtonEnabled(panel->moreChk[7], tmp);
WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False); WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
panel->appFrm = NULL; panel->appFrm = NULL;
} }
/* if the window is a transient, don't let it have a miniaturize
* button */
if (wwin->transient_for != None && wwin->transient_for != scr->root_win)
WMSetButtonEnabled(panel->attrChk[3], False);
else
WMSetButtonEnabled(panel->attrChk[3], True);
if (!wwin->wm_class && !wwin->wm_instance) {
WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);
}
WMRealizeWidget(panel->win);
WMMapSubwidgets(panel->win);
WMMapSubwidgets(panel->specFrm);
WMMapSubwidgets(panel->attrFrm);
WMMapSubwidgets(panel->moreFrm);
WMMapSubwidgets(panel->iconFrm);
WMMapSubwidgets(panel->wsFrm);
if (panel->appFrm)
WMMapSubwidgets(panel->appFrm);
if (showSelectPanel) {
WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0);
changePage(panel->pagePopUp, panel);
} else {
WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
changePage(panel->pagePopUp, panel);
}
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 0, 0, 0);
XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);
panel->parent = parent;
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
WMMapWidget(panel->win);
XSetTransientForHint(dpy, parent, wwin->client_win);
if (xpos == UNDEFINED_POS) {
x = wwin->frame_x + wwin->frame->core->width / 2;
y = wwin->frame_y + wwin->frame->top_width * 2;
if (y + PHEIGHT > scr->scr_height)
y = scr->scr_height - PHEIGHT - 30;
if (x + PWIDTH > scr->scr_width)
x = scr->scr_width - PWIDTH;
} else {
x = xpos;
y = ypos;
}
panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, "Inspector", x, y, PWIDTH, PHEIGHT);
if (!selectedBtn)
selectedBtn = panel->defaultRb;
WMSetButtonSelected(selectedBtn, True);
selectSpecification(selectedBtn, panel);
/* kluge to know who should get the key events */
panel->frame->client_leader = WMWidgetXID(panel->win);
WSETUFLAG(panel->frame, no_closable, 0);
WSETUFLAG(panel->frame, no_close_button, 0);
wWindowUpdateButtonImages(panel->frame);
wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
panel->frame->frame->on_click_right = destroyInspector;
wWindowMap(panel->frame);
showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, wwin->wm_class, UPDATE_TEXT_FIELD);
return panel;
}
void wShowInspectorForWindow(WWindow *wwin)
{
if (wwin->flags.inspector_open)
return;
WMSetBalloonEnabled(wwin->screen_ptr->wmscreen, wPreferences.help_balloon);
make_keys();
wwin->flags.inspector_open = 1;
wwin->inspector = createInspectorForWindow(wwin, UNDEFINED_POS, UNDEFINED_POS, False);
}
void wHideInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame;
wWindowUnmap(pwin);
pwin->flags.hidden = 1;
wClientSetState(pwin, IconicState, None);
}
void wUnhideInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame;
pwin->flags.hidden = 0;
pwin->flags.mapped = 1;
XMapWindow(dpy, pwin->client_win);
XMapWindow(dpy, pwin->frame->core->window);
wClientSetState(pwin, NormalState, None);
}
WWindow *wGetWindowOfInspectorForWindow(WWindow *wwin)
{
if (wwin->inspector) {
assert(wwin->flags.inspector_open != 0);
return wwin->inspector->frame;
} else
return NULL;
}
void wCloseInspectorForWindow(WWindow *wwin)
{
WWindow *pwin = wwin->inspector->frame; /* the inspector window */
(*pwin->frame->on_click_right) (NULL, pwin, NULL);
} }