Update for 0.51.0
[wmaker-crm.git] / src / winspector.c
blob71f4b557079a70f6f5996ceb7bb523d5f6fca1fd
1 /* winspector.c - window attribute inspector
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
23 #include "wconfig.h"
25 #include <X11/Xlib.h>
26 #include <X11/Xutil.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
31 #include "WindowMaker.h"
32 #include "screen.h"
33 #include "wcore.h"
34 #include "framewin.h"
35 #include "window.h"
36 #include "workspace.h"
37 #include "funcs.h"
38 #include "defaults.h"
39 #include "dialog.h"
40 #include "icon.h"
41 #include "stacking.h"
42 #include "application.h"
43 #include "appicon.h"
44 #include "actions.h"
45 #include "winspector.h"
46 #include "dock.h"
48 #include <proplist.h>
50 extern WDDomain *WDWindowAttributes;
52 static InspectorPanel *panelList=NULL;
54 extern WPreferences wPreferences;
56 static proplist_t ANoTitlebar = NULL;
57 static proplist_t ANoResizebar;
58 static proplist_t ANoMiniaturizeButton;
59 static proplist_t ANoCloseButton;
60 static proplist_t ANoHideOthers;
61 static proplist_t ANoMouseBindings;
62 static proplist_t ANoKeyBindings;
63 static proplist_t ANoAppIcon;
64 static proplist_t AKeepOnTop;
65 static proplist_t AKeepOnBottom;
66 static proplist_t AOmnipresent;
67 static proplist_t ASkipWindowList;
68 static proplist_t AKeepInsideScreen;
69 static proplist_t AUnfocusable;
70 static proplist_t AAlwaysUserIcon;
71 static proplist_t AStartMiniaturized;
72 static proplist_t AStartMaximized;
73 static proplist_t ADontSaveSession;
74 static proplist_t AEmulateAppIcon;
76 static proplist_t AStartWorkspace;
78 static proplist_t AIcon;
80 /* application wide options */
81 static proplist_t AStartHidden;
84 static proplist_t AnyWindow;
85 static proplist_t EmptyString;
86 static proplist_t Yes, No;
89 #define PWIDTH 270
90 #define PHEIGHT 350
93 static void applySettings(WMButton *button, InspectorPanel *panel);
95 static void
96 make_keys()
98 if (ANoTitlebar!=NULL)
99 return;
101 AIcon = PLMakeString("Icon");
102 ANoTitlebar = PLMakeString("NoTitlebar");
103 ANoResizebar = PLMakeString("NoResizebar");
104 ANoMiniaturizeButton = PLMakeString("NoMiniaturizeButton");
105 ANoCloseButton = PLMakeString("NoCloseButton");
106 ANoHideOthers = PLMakeString("NoHideOthers");
107 ANoMouseBindings = PLMakeString("NoMouseBindings");
108 ANoKeyBindings = PLMakeString("NoKeyBindings");
109 ANoAppIcon = PLMakeString("NoAppIcon");
110 AKeepOnTop = PLMakeString("KeepOnTop");
111 AKeepOnBottom = PLMakeString("KeepOnBottom");
112 AOmnipresent = PLMakeString("Omnipresent");
113 ASkipWindowList = PLMakeString("SkipWindowList");
114 AKeepInsideScreen = PLMakeString("KeepInsideScreen");
115 AUnfocusable = PLMakeString("Unfocusable");
116 AAlwaysUserIcon = PLMakeString("AlwaysUserIcon");
117 AStartMiniaturized = PLMakeString("StartMiniaturized");
118 AStartMaximized = PLMakeString("StartMaximized");
119 AStartHidden = PLMakeString("StartHidden");
120 ADontSaveSession = PLMakeString("DontSaveSession");
121 AEmulateAppIcon = PLMakeString("EmulateAppIcon");
123 AStartWorkspace = PLMakeString("StartWorkspace");
125 AnyWindow = PLMakeString("*");
126 EmptyString = PLMakeString("");
127 Yes = PLMakeString("Yes");
128 No = PLMakeString("No");
133 static void
134 freeInspector(InspectorPanel *panel)
136 panel->destroyed = 1;
137 if (panel->choosingIcon)
138 return;
140 WMDestroyWidget(panel->win);
142 XDestroyWindow(dpy, panel->parent);
144 free(panel);
148 static void
149 destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
151 InspectorPanel *panel;
152 InspectorPanel *tmp;
154 panel = panelList;
155 while (panel->frame!=data)
156 panel = panel->nextPtr;
158 if (panelList == panel)
159 panelList = panel->nextPtr;
160 else {
161 tmp = panelList;
162 while (tmp->nextPtr!=panel) {
163 tmp = tmp->nextPtr;
165 tmp->nextPtr = panel->nextPtr;
167 panel->inspected->flags.inspector_open = 0;
168 panel->inspected->inspector = NULL;
170 WMRemoveNotificationObserver(panel);
172 panel->frame->flags.mapped = 0;
173 wUnmanageWindow(panel->frame, True, False);
175 freeInspector(panel);
180 void
181 wDestroyInspectorPanels()
183 InspectorPanel *panel;
185 while (panelList != NULL) {
186 panel = panelList;
187 panelList = panelList->nextPtr;
188 wUnmanageWindow(panel->frame, False, False);
189 WMDestroyWidget(panel->win);
191 panel->inspected->flags.inspector_open = 0;
192 panel->inspected->inspector = NULL;
194 free(panel);
199 static void
200 changePage(WMPopUpButton *bPtr, InspectorPanel *panel)
202 int page;
204 page = WMGetPopUpButtonSelectedItem(bPtr);
206 if (page == 0) {
207 WMMapWidget(panel->specFrm);
208 WMMapWidget(panel->specLbl);
209 } else if (page == 1) {
210 WMMapWidget(panel->attrFrm);
211 } else if (page == 2) {
212 WMMapWidget(panel->moreFrm);
213 } else if (page == 3) {
214 WMMapWidget(panel->iconFrm);
215 WMMapWidget(panel->wsFrm);
216 } else {
217 WMMapWidget(panel->appFrm);
220 if (page != 0) {
221 WMUnmapWidget(panel->specFrm);
222 WMUnmapWidget(panel->specLbl);
224 if (page != 1)
225 WMUnmapWidget(panel->attrFrm);
226 if (page != 2)
227 WMUnmapWidget(panel->moreFrm);
228 if (page != 3) {
229 WMUnmapWidget(panel->iconFrm);
230 WMUnmapWidget(panel->wsFrm);
232 if (page != 4 && panel->appFrm)
233 WMUnmapWidget(panel->appFrm);
237 #define USE_TEXT_FIELD 1
238 #define UPDATE_TEXT_FIELD 2
239 #define REVERT_TO_DEFAULT 4
242 static int
243 showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
244 char *wm_instance, char *wm_class, int flags)
246 WMPixmap *pixmap = (WMPixmap*) NULL;
247 char *file=NULL, *path=NULL;
248 char *db_icon=NULL;
250 if ((flags & USE_TEXT_FIELD) != 0) {
251 file = WMGetTextFieldText(panel->fileText);
252 if (file && file[0] == 0) {
253 free(file);
254 file = NULL;
256 } else {
257 db_icon = wDefaultGetIconFile(panel->inspected->screen_ptr,
258 wm_instance, wm_class, False);
259 if(db_icon != NULL)
260 file = wstrdup(db_icon);
262 if (db_icon!=NULL && (flags & REVERT_TO_DEFAULT)!=0) {
263 if (file)
264 file = wstrdup(db_icon);
265 flags |= UPDATE_TEXT_FIELD;
268 if ((flags & UPDATE_TEXT_FIELD) != 0) {
269 WMSetTextFieldText(panel->fileText, file);
272 if (file) {
273 path = FindImage(wPreferences.icon_path, file);
275 if (!path) {
276 char *buf;
278 buf = wmalloc(strlen(file)+80);
279 sprintf(buf, _("Could not find icon \"%s\" specified for this window"),
280 file);
281 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
282 _("OK"), NULL, NULL);
283 free(buf);
284 free(file);
285 return -1;
288 pixmap = WMCreatePixmapFromFile(scrPtr, path);
289 free(path);
291 if (!pixmap) {
292 char *buf;
294 buf = wmalloc(strlen(file)+80);
295 sprintf(buf, _("Could not open specified icon \"%s\":%s"),
296 file, RMessageForError(RErrorCode));
297 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
298 _("OK"), NULL, NULL);
299 free(buf);
300 free(file);
301 return -1;
303 free(file);
306 WMSetLabelImage(panel->iconLbl, pixmap);
307 if (pixmap)
308 WMReleasePixmap(pixmap);
310 return 0;
313 #if 0
314 static void
315 updateIcon(WMButton *button, InspectorPanel *panel)
317 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
319 #endif
321 static int
322 getBool(proplist_t value)
324 char *val;
326 if (!PLIsString(value)) {
327 return 0;
329 if (!(val = PLGetString(value))) {
330 return 0;
333 if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T'
334 || val[0]=='t' || val[0]=='1'))
335 || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) {
337 return 1;
338 } else if ((val[1]=='\0'
339 && (val[0]=='n' || val[0]=='N' || val[0]=='F'
340 || val[0]=='f' || val[0]=='0'))
341 || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) {
343 return 0;
344 } else {
345 wwarning(_("can't convert \"%s\" to boolean"), val);
346 return 0;
351 #define UPDATE_DEFAULTS 1
352 #define IS_BOOLEAN 2
356 * Will insert the attribute = value; pair in window's list,
357 * if it's different from the defaults.
358 * Defaults means either defaults database, or attributes saved
359 * for the default window "*". This is to let one revert options that are
360 * global because they were saved for all windows ("*").
365 static void
366 insertAttribute(proplist_t dict, proplist_t window, proplist_t attr,
367 proplist_t value, int *modified, int flags)
369 proplist_t def_win, def_value=NULL;
370 int update = 0;
372 if (!(flags & UPDATE_DEFAULTS) && dict) {
373 if ((def_win = PLGetDictionaryEntry(dict, AnyWindow)) != NULL) {
374 def_value = PLGetDictionaryEntry(def_win, attr);
378 /* If we could not find defaults in database, fall to hardcoded values.
379 * Also this is true if we save defaults for all windows
381 if (!def_value)
382 def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
384 if ((flags & IS_BOOLEAN))
385 update = (getBool(value) != getBool(def_value));
386 else {
387 update = !PLIsEqual(value, def_value);
390 if (update) {
391 PLInsertDictionaryEntry(window, attr, value);
392 *modified = 1;
397 static void
398 saveSettings(WMButton *button, InspectorPanel *panel)
400 WWindow *wwin = panel->inspected;
401 WDDomain *db = WDWindowAttributes;
402 proplist_t dict = db->dictionary;
403 proplist_t winDic, value, key;
404 char buffer[256], *icon_file;
405 int flags = 0;
406 int different = 0;
408 /* Save will apply the changes and save them */
409 applySettings(panel->applyBtn, panel);
411 if (WMGetButtonSelected(panel->instRb) != 0)
412 key = PLMakeString(wwin->wm_instance);
413 else if (WMGetButtonSelected(panel->clsRb) != 0)
414 key = PLMakeString(wwin->wm_class);
415 else if (WMGetButtonSelected(panel->bothRb) != 0) {
416 strcat(strcat(strcpy(buffer, wwin->wm_instance), "."), wwin->wm_class);
417 key = PLMakeString(buffer);
419 else if (WMGetButtonSelected(panel->defaultRb) != 0) {
420 key = PLRetain(AnyWindow);
421 flags = UPDATE_DEFAULTS;
423 else
424 key = NULL;
426 if (!key)
427 return;
429 if (!dict) {
430 dict = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
431 if (dict) {
432 db->dictionary = dict;
433 value = PLMakeString(db->path);
434 PLSetFilename(dict, value);
435 PLRelease(value);
437 else {
438 PLRelease(key);
439 return;
443 if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL,
444 USE_TEXT_FIELD) < 0)
445 return;
447 PLSetStringCmpHook(NULL);
449 winDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
451 /* Update icon for window */
452 icon_file = WMGetTextFieldText(panel->fileText);
453 if (icon_file) {
454 if (icon_file[0] != 0) {
455 value = PLMakeString(icon_file);
456 insertAttribute(dict, winDic, AIcon, value, &different, flags);
457 PLRelease(value);
459 free(icon_file);
462 if (WMGetButtonSelected(panel->curRb) != 0) {
463 value = PLMakeString("");
464 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
465 PLRelease(value);
466 } else if (WMGetButtonSelected(panel->setRb) != 0) {
467 char *ws_name = WMGetTextFieldText(panel->wsText);
468 if (ws_name) {
469 if (ws_name[0] != 0) {
470 value = PLMakeString(ws_name);
471 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
472 PLRelease(value);
474 free(ws_name);
478 flags |= IS_BOOLEAN;
480 value = (WMGetButtonSelected(panel->alwChk)!=0) ? Yes : No;
481 insertAttribute(dict, winDic, AAlwaysUserIcon, value, &different, flags);
483 value = (WMGetButtonSelected(panel->attrChk[0])!=0) ? Yes : No;
484 insertAttribute(dict, winDic, ANoTitlebar, value, &different, flags);
486 value = (WMGetButtonSelected(panel->attrChk[1])!=0) ? Yes : No;
487 insertAttribute(dict, winDic, ANoResizebar, value, &different, flags);
489 value = (WMGetButtonSelected(panel->attrChk[2])!=0) ? Yes : No;
490 insertAttribute(dict, winDic, ANoCloseButton, value, &different, flags);
492 value = (WMGetButtonSelected(panel->attrChk[3])!=0) ? Yes : No;
493 insertAttribute(dict, winDic, ANoMiniaturizeButton, value, &different, flags);
495 value = (WMGetButtonSelected(panel->attrChk[4])!=0) ? Yes : No;
496 insertAttribute(dict, winDic, AKeepOnTop, value, &different, flags);
498 value = (WMGetButtonSelected(panel->attrChk[5])!=0) ? Yes : No;
499 insertAttribute(dict, winDic, AKeepOnBottom, value, &different, flags);
501 value = (WMGetButtonSelected(panel->attrChk[6])!=0) ? Yes : No;
502 insertAttribute(dict, winDic, AOmnipresent, value, &different, flags);
504 value = (WMGetButtonSelected(panel->attrChk[7])!=0) ? Yes : No;
505 insertAttribute(dict, winDic, AStartMiniaturized, value, &different, flags);
507 value = (WMGetButtonSelected(panel->attrChk[8])!=0) ? Yes : No;
508 insertAttribute(dict, winDic, AStartMaximized, value, &different, flags);
510 value = (WMGetButtonSelected(panel->attrChk[9])!=0) ? Yes : No;
511 insertAttribute(dict, winDic, ASkipWindowList, value, &different, flags);
514 value = (WMGetButtonSelected(panel->moreChk[0])!=0) ? Yes : No;
515 insertAttribute(dict, winDic, ANoHideOthers, value, &different, flags);
517 value = (WMGetButtonSelected(panel->moreChk[1])!=0) ? Yes : No;
518 insertAttribute(dict, winDic, ANoKeyBindings, value, &different, flags);
520 value = (WMGetButtonSelected(panel->moreChk[2])!=0) ? Yes : No;
521 insertAttribute(dict, winDic, ANoMouseBindings, value, &different, flags);
523 value = (WMGetButtonSelected(panel->moreChk[3])!=0) ? Yes : No;
524 insertAttribute(dict, winDic, AKeepInsideScreen, value, &different, flags);
526 value = (WMGetButtonSelected(panel->moreChk[4])!=0) ? Yes : No;
527 insertAttribute(dict, winDic, AUnfocusable, value, &different, flags);
529 value = (WMGetButtonSelected(panel->moreChk[5])!=0) ? Yes : No;
530 insertAttribute(dict, winDic, ADontSaveSession, value, &different, flags);
532 value = (WMGetButtonSelected(panel->moreChk[6])!=0) ? Yes : No;
533 insertAttribute(dict, winDic, AEmulateAppIcon, value, &different, flags);
535 /* application wide settings for when */
536 /* the window is the leader, save the attribute with the others */
537 if (panel->inspected->main_window == panel->inspected->client_win) {
539 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
540 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
542 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
543 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
546 PLRemoveDictionaryEntry(dict, key);
547 if (different) {
548 PLInsertDictionaryEntry(dict, key, winDic);
550 PLRelease(key);
551 PLRelease(winDic);
553 different = 0;
555 /* application wide settings */
556 if (panel->inspected->main_window != panel->inspected->client_win
557 && !(flags & UPDATE_DEFAULTS)) {
558 WApplication *wapp;
559 proplist_t appDic;
561 wapp = wApplicationOf(panel->inspected->main_window);
562 if (wapp) {
563 char *iconFile;
565 appDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
567 assert(wapp->main_window_desc->wm_instance!=NULL);
568 assert(wapp->main_window_desc->wm_class!=NULL);
570 strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), ".");
571 strcat(buffer, wwin->wm_class);
572 key = PLMakeString(buffer);
574 iconFile = wDefaultGetIconFile(wwin->screen_ptr,
575 wapp->main_window_desc->wm_instance,
576 wapp->main_window_desc->wm_class,
577 False);
579 if (iconFile && iconFile[0]!=0) {
580 value = PLMakeString(iconFile);
581 insertAttribute(dict, appDic, AIcon, value, &different,
582 flags&~IS_BOOLEAN);
583 PLRelease(value);
586 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
587 insertAttribute(dict, appDic, AStartHidden, value, &different, flags);
589 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
590 insertAttribute(dict, appDic, ANoAppIcon, value, &different, flags);
592 PLRemoveDictionaryEntry(dict, key);
593 if (different) {
594 PLInsertDictionaryEntry(dict, key, appDic);
596 PLRelease(key);
597 PLRelease(appDic);
601 PLSave(dict, YES);
603 /* clean up */
604 PLSetStringCmpHook(StringCompareHook);
608 static void
609 makeAppIconFor(WApplication *wapp)
611 WScreen *scr = wapp->main_window_desc->screen_ptr;
613 if (wapp->app_icon)
614 return;
616 if (!WFLAGP(wapp->main_window_desc, no_appicon))
617 wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
618 else
619 wapp->app_icon = NULL;
621 if (wapp->app_icon) {
622 WIcon *icon = wapp->app_icon->icon;
623 WDock *clip = scr->workspaces[scr->current_workspace]->clip;
624 int x=0, y=0;
626 wapp->app_icon->main_window = wapp->main_window;
628 if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
629 wapp->app_icon->attracted = 1;
630 if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {
631 wapp->app_icon->icon->shadowed = 1;
632 wapp->app_icon->icon->force_paint = 1;
634 wDockAttachIcon(clip, wapp->app_icon, x, y);
635 } else {
636 PlaceIcon(scr, &x, &y);
637 wAppIconMove(wapp->app_icon, x, y);
639 if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
640 XMapWindow(dpy, icon->core->window);
642 if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted)
643 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
648 static void
649 removeAppIconFor(WApplication *wapp)
651 if (!wapp->app_icon)
652 return;
654 if (wapp->app_icon->docked &&
655 (!wapp->app_icon->attracted || wapp->app_icon->dock->keep_attracted)) {
656 wapp->app_icon->running = 0;
657 /* since we keep it, we don't care if it was attracted or not */
658 wapp->app_icon->attracted = 0;
659 wapp->app_icon->icon->shadowed = 0;
660 wapp->app_icon->main_window = None;
661 wapp->app_icon->pid = 0;
662 wapp->app_icon->icon->owner = NULL;
663 wapp->app_icon->icon->icon_win = None;
664 wapp->app_icon->icon->force_paint = 1;
665 wAppIconPaint(wapp->app_icon);
666 } else if (wapp->app_icon->docked) {
667 wapp->app_icon->running = 0;
668 wDockDetach(wapp->app_icon->dock, wapp->app_icon);
669 } else {
670 wAppIconDestroy(wapp->app_icon);
672 wapp->app_icon = NULL;
673 if (wPreferences.auto_arrange_icons)
674 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
678 static void
679 applySettings(WMButton *button, InspectorPanel *panel)
681 WWindow *wwin = panel->inspected;
682 WApplication *wapp = wApplicationOf(wwin->main_window);
683 int floating, sunken, skip_window_list;
684 int old_omnipresent;
685 int old_no_bind_keys;
686 int old_no_bind_mouse;
688 old_omnipresent = WFLAGP(wwin, omnipresent);
689 old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
690 old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse);
692 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
694 WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0]));
695 WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1]));
696 WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2]));
697 WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3]));
698 floating = WMGetButtonSelected(panel->attrChk[4]);
699 sunken = WMGetButtonSelected(panel->attrChk[5]);
700 WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[6]));
701 WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[7]));
702 WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[8]));
703 skip_window_list = WMGetButtonSelected(panel->attrChk[9]);
705 WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[0]));
706 WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[1]));
707 WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[2]));
708 WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[3]));
709 WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4]));
710 WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[5]));
711 WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[6]));
712 WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
714 if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
715 wUnshadeWindow(wwin);
717 WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));
719 if (floating) {
720 if (!WFLAGP(wwin, floating))
721 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
722 } else if (sunken) {
723 if (!WFLAGP(wwin, sunken))
724 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
725 } else {
726 if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
727 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
730 WSETUFLAG(wwin, sunken, sunken);
731 WSETUFLAG(wwin, floating, floating);
732 wwin->flags.omnipresent = 0;
734 if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
735 WSETUFLAG(wwin, skip_window_list, skip_window_list);
736 UpdateSwitchMenu(wwin->screen_ptr, wwin,
737 skip_window_list ? ACTION_REMOVE : ACTION_ADD);
738 } else {
739 if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
740 UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
744 if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
745 if (WFLAGP(wwin, no_bind_keys)) {
746 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
747 } else {
748 wWindowSetKeyGrabs(wwin);
752 if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
753 wWindowResetMouseGrabs(wwin);
756 wwin->frame->flags.need_texture_change = 1;
757 wWindowConfigureBorders(wwin);
758 wFrameWindowPaint(wwin->frame);
761 * Can't apply emulate_appicon because it will probably cause problems.
764 if (wapp) {
765 /* do application wide stuff */
766 WSETUFLAG(wapp->main_window_desc, start_hidden,
767 WMGetButtonSelected(panel->appChk[0]));
769 WSETUFLAG(wapp->main_window_desc, no_appicon,
770 WMGetButtonSelected(panel->appChk[1]));
772 if (WFLAGP(wapp->main_window_desc, no_appicon))
773 removeAppIconFor(wapp);
774 else
775 makeAppIconFor(wapp);
777 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
778 char *file = WMGetTextFieldText(panel->fileText);
780 if (file[0] == 0) {
781 free(file);
782 file = NULL;
784 wIconChangeImageFile(wapp->app_icon->icon, file);
785 if (file)
786 free(file);
787 wAppIconPaint(wapp->app_icon);
793 static void
794 revertSettings(WMButton *button, InspectorPanel *panel)
796 WWindow *wwin = panel->inspected;
797 WApplication *wapp = wApplicationOf(wwin->main_window);
798 int i, n;
799 char *wm_instance = NULL;
800 char *wm_class = NULL;
801 int workspace, level;
803 if (WMGetButtonSelected(panel->instRb) != 0)
804 wm_instance = wwin->wm_instance;
805 else if (WMGetButtonSelected(panel->clsRb) != 0)
806 wm_class = wwin->wm_class;
807 else if (WMGetButtonSelected(panel->bothRb) != 0) {
808 wm_instance = wwin->wm_instance;
809 wm_class = wwin->wm_class;
811 memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
812 memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
813 memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
815 wWindowSetupInitialAttributes(wwin, &level, &workspace);
817 for (i=0; i < 10; i++) {
818 int flag = 0;
820 switch (i) {
821 case 0:
822 flag = WFLAGP(wwin, no_titlebar);
823 break;
824 case 1:
825 flag = WFLAGP(wwin, no_resizebar);
826 break;
827 case 2:
828 flag = WFLAGP(wwin, no_close_button);
829 break;
830 case 3:
831 flag = WFLAGP(wwin, no_miniaturize_button);
832 break;
833 case 4:
834 flag = WFLAGP(wwin, floating);
835 break;
836 case 5:
837 flag = WFLAGP(wwin, sunken);
838 break;
839 case 6:
840 flag = WFLAGP(wwin, omnipresent);
841 break;
842 case 7:
843 flag = WFLAGP(wwin, start_miniaturized);
844 break;
845 case 8:
846 flag = WFLAGP(wwin, start_maximized!=0);
847 break;
848 case 9:
849 flag = WFLAGP(wwin, skip_window_list);
850 break;
852 WMSetButtonSelected(panel->attrChk[i], flag);
854 for (i=0; i < 7; i++) {
855 int flag = 0;
857 switch (i) {
858 case 0:
859 flag = WFLAGP(wwin, no_hide_others);
860 break;
861 case 1:
862 flag = WFLAGP(wwin, no_bind_keys);
863 break;
864 case 2:
865 flag = WFLAGP(wwin, no_bind_mouse);
866 break;
867 case 3:
868 flag = WFLAGP(wwin, dont_move_off);
869 break;
870 case 4:
871 flag = WFLAGP(wwin, no_focusable);
872 break;
873 case 5:
874 flag = WFLAGP(wwin, dont_save_session);
875 break;
876 case 6:
877 flag = WFLAGP(wwin, emulate_appicon);
878 break;
880 WMSetButtonSelected(panel->moreChk[i], flag);
882 if (panel->appFrm && wapp) {
883 for (i=0; i < 2; i++) {
884 int flag = 0;
886 switch (i) {
887 case 0:
888 flag = WFLAGP(wapp->main_window_desc, start_hidden);
889 break;
890 case 1:
891 flag = WFLAGP(wapp->main_window_desc, no_appicon);
892 break;
894 WMSetButtonSelected(panel->appChk[i], flag);
897 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
899 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
900 REVERT_TO_DEFAULT);
902 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
904 if (n >= 0 && n <= wwin->screen_ptr->workspace_count) {
905 WMPerformButtonClick(panel->setRb);
906 WMSetTextFieldText(panel->wsText, wwin->screen_ptr->workspaces[n]->name);
907 } else {
908 WMPerformButtonClick(panel->curRb);
913 static void
914 chooseIconCallback(WMWidget *self, void *clientData)
916 char *file;
917 InspectorPanel *panel = (InspectorPanel*)clientData;
918 int result;
920 panel->choosingIcon = 1;
922 WMSetButtonEnabled(panel->browseIconBtn, False);
924 result = wIconChooserDialog(panel->frame->screen_ptr, &file,
925 panel->inspected->wm_instance,
926 panel->inspected->wm_class);
928 panel->choosingIcon = 0;
930 if (!panel->destroyed) { /* kluge */
931 if (result) {
932 WMSetTextFieldText(panel->fileText, file);
933 showIconFor(WMWidgetScreen(self), panel, NULL, NULL,
934 USE_TEXT_FIELD);
935 free(file);
937 WMSetButtonEnabled(panel->browseIconBtn, True);
938 } else {
939 freeInspector(panel);
944 static void
945 textEditedObserver(void *observerData, WMNotification *notification)
947 InspectorPanel *panel = (InspectorPanel*)observerData;
949 if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement)
950 return;
952 if (observerData == panel->fileText) {
953 showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL,
954 USE_TEXT_FIELD);
956 WMPerformButtonClick(panel->updateIconBtn);
958 } else
959 WMPerformButtonClick(panel->setRb);
963 static void
964 selectSpecification(WMWidget *bPtr, void *data)
966 InspectorPanel *panel = (InspectorPanel*)data;
968 if (bPtr == panel->defaultRb) {
969 WMSetButtonEnabled(panel->applyBtn, False);
970 } else {
971 WMSetButtonEnabled(panel->applyBtn, True);
976 static InspectorPanel*
977 createInspectorForWindow(WWindow *wwin)
979 WScreen *scr = wwin->screen_ptr;
980 InspectorPanel *panel;
981 Window parent;
982 char charbuf[128];
983 int i;
984 int x, y;
985 int btn_width, frame_width;
986 #ifdef wrong_behaviour
987 WMPixmap *pixmap;
988 #endif
989 panel = wmalloc(sizeof(InspectorPanel));
991 panel->destroyed = 0;
994 panel->inspected = wwin;
996 panel->nextPtr = panelList;
997 panelList = panel;
1000 sprintf(charbuf, "Inspecting %s.%s",
1001 wwin->wm_instance ? wwin->wm_instance : "?",
1002 wwin->wm_class ? wwin->wm_class : "?");
1004 panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
1005 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1008 /**** create common stuff ****/
1010 /* command buttons */
1011 /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
1012 btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
1013 panel->saveBtn = WMCreateCommandButton(panel->win);
1014 WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);
1015 WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, 310);
1016 WMSetButtonText(panel->saveBtn, _("Save"));
1017 WMResizeWidget(panel->saveBtn, btn_width, 28);
1018 if (wPreferences.flags.noupdates)
1019 WMSetButtonEnabled(panel->saveBtn, False);
1021 panel->applyBtn = WMCreateCommandButton(panel->win);
1022 WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);
1023 WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);
1024 WMSetButtonText(panel->applyBtn, _("Apply"));
1025 WMResizeWidget(panel->applyBtn, btn_width, 28);
1027 panel->revertBtn = WMCreateCommandButton(panel->win);
1028 WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);
1029 WMMoveWidget(panel->revertBtn, 15, 310);
1030 WMSetButtonText(panel->revertBtn, _("Reload"));
1031 WMResizeWidget(panel->revertBtn, btn_width, 28);
1033 /* page selection popup button */
1034 panel->pagePopUp = WMCreatePopUpButton(panel->win);
1035 WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);
1036 WMMoveWidget(panel->pagePopUp, 25, 15);
1037 WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);
1039 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));
1040 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));
1041 WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));
1042 WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));
1043 WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));
1045 /**** window spec ****/
1046 frame_width = PWIDTH - (2 * 15);
1048 panel->specFrm = WMCreateFrame(panel->win);
1049 WMSetFrameTitle(panel->specFrm, _("Window Specification"));
1050 WMMoveWidget(panel->specFrm, 15, 65);
1051 WMResizeWidget(panel->specFrm, frame_width, 105);
1054 panel->defaultRb = WMCreateRadioButton(panel->specFrm);
1055 WMMoveWidget(panel->defaultRb, 10, 78);
1056 WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);
1057 WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));
1058 WMSetButtonSelected(panel->defaultRb, False);
1059 WMSetButtonAction(panel->defaultRb, selectSpecification, panel);
1062 if (wwin->wm_class && wwin->wm_instance) {
1063 sprintf(charbuf, "%s.%s", wwin->wm_instance, wwin->wm_class);
1064 panel->bothRb = WMCreateRadioButton(panel->specFrm);
1065 WMMoveWidget(panel->bothRb, 10, 18);
1066 WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);
1067 WMSetButtonText(panel->bothRb, charbuf);
1068 WMSetButtonSelected(panel->bothRb, True);
1069 WMGroupButtons(panel->defaultRb, panel->bothRb);
1071 WMSetButtonAction(panel->bothRb, selectSpecification, panel);
1074 if (wwin->wm_instance) {
1075 panel->instRb = WMCreateRadioButton(panel->specFrm);
1076 WMMoveWidget(panel->instRb, 10, 38);
1077 WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);
1078 WMSetButtonText(panel->instRb, wwin->wm_instance);
1079 WMSetButtonSelected(panel->instRb, False);
1080 WMGroupButtons(panel->defaultRb, panel->instRb);
1082 WMSetButtonAction(panel->instRb, selectSpecification, panel);
1085 if (wwin->wm_class) {
1086 panel->clsRb = WMCreateRadioButton(panel->specFrm);
1087 WMMoveWidget(panel->clsRb, 10, 58);
1088 WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);
1089 WMSetButtonText(panel->clsRb, wwin->wm_class);
1090 WMSetButtonSelected(panel->clsRb, False);
1091 WMGroupButtons(panel->defaultRb, panel->clsRb);
1093 WMSetButtonAction(panel->clsRb, selectSpecification, panel);
1096 panel->specLbl = WMCreateLabel(panel->win);
1097 WMMoveWidget(panel->specLbl, 15, 170);
1098 WMResizeWidget(panel->specLbl, frame_width, 100);
1099 WMSetLabelText(panel->specLbl,
1100 _("The configuration will apply to all\n"
1101 "windows that have their WM_CLASS property"
1102 " set to the above selected\nname, when saved."));
1103 WMSetLabelTextAlignment(panel->specLbl, WACenter);
1105 /**** attributes ****/
1106 panel->attrFrm = WMCreateFrame(panel->win);
1107 WMSetFrameTitle(panel->attrFrm, _("Attributes"));
1108 WMMoveWidget(panel->attrFrm, 15, 50);
1109 WMResizeWidget(panel->attrFrm, frame_width, 240);
1111 for (i=0; i < 10; i++) {
1112 char *caption = NULL;
1113 int flag = 0;
1115 switch (i) {
1116 case 0:
1117 caption = _("Disable titlebar");
1118 flag = WFLAGP(wwin, no_titlebar);
1119 break;
1120 case 1:
1121 caption = _("Disable resizebar");
1122 flag = WFLAGP(wwin, no_resizebar);
1123 break;
1124 case 2:
1125 caption = _("Disable close button");
1126 flag = WFLAGP(wwin, no_close_button);
1127 break;
1128 case 3:
1129 caption = _("Disable miniaturize button");
1130 flag = WFLAGP(wwin, no_miniaturize_button);
1131 break;
1132 case 4:
1133 caption = _("Keep on top / floating");
1134 flag = WFLAGP(wwin, floating);
1135 break;
1136 case 5:
1137 caption = _("Keep at bottom / sunken");
1138 flag = WFLAGP(wwin, sunken);
1139 break;
1140 case 6:
1141 caption = _("Omnipresent");
1142 flag = WFLAGP(wwin, omnipresent);
1143 break;
1144 case 7:
1145 caption = _("Start Miniaturized");
1146 flag = WFLAGP(wwin, start_miniaturized);
1147 break;
1148 case 8:
1149 caption = _("Start Maximized");
1150 flag = WFLAGP(wwin, start_maximized!=0);
1151 break;
1152 case 9:
1153 caption = _("Skip window list");
1154 flag = WFLAGP(wwin, skip_window_list);
1155 break;
1157 panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
1158 WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));
1159 WMResizeWidget(panel->attrChk[i], frame_width-15, 20);
1160 WMSetButtonSelected(panel->attrChk[i], flag);
1161 WMSetButtonText(panel->attrChk[i], caption);
1165 /**** more attributes ****/
1166 panel->moreFrm = WMCreateFrame(panel->win);
1167 WMSetFrameTitle(panel->moreFrm, _("Advanced"));
1168 WMMoveWidget(panel->moreFrm, 15, 50);
1169 WMResizeWidget(panel->moreFrm, frame_width, 240);
1171 for (i=0; i < 7; i++) {
1172 char *caption = NULL;
1173 int flag = 0;
1175 switch (i) {
1176 case 0:
1177 caption = _("Ignore HideOthers");
1178 flag = WFLAGP(wwin, no_hide_others);
1179 break;
1180 case 1:
1181 caption = _("Don't bind keyboard shortcuts");
1182 flag = WFLAGP(wwin, no_bind_keys);
1183 break;
1184 case 2:
1185 caption = _("Don't bind mouse clicks");
1186 flag = WFLAGP(wwin, no_bind_mouse);
1187 break;
1188 case 3:
1189 caption = _("Keep inside screen");
1190 flag = WFLAGP(wwin, dont_move_off);
1191 break;
1192 case 4:
1193 caption = _("Don't let it take focus");
1194 flag = WFLAGP(wwin, no_focusable);
1195 break;
1196 case 5:
1197 caption = _("Don't Save Session");
1198 flag = WFLAGP(wwin, dont_save_session);
1199 break;
1200 case 6:
1201 caption = _("Emulate Application Icon");
1202 flag = WFLAGP(wwin, emulate_appicon);
1203 break;
1205 panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
1206 WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));
1207 WMResizeWidget(panel->moreChk[i], frame_width-15, 20);
1208 WMSetButtonSelected(panel->moreChk[i], flag);
1209 WMSetButtonText(panel->moreChk[i], caption);
1212 panel->moreLbl = WMCreateLabel(panel->moreFrm);
1213 WMResizeWidget(panel->moreLbl, frame_width - (2 * 5), 60);
1214 WMMoveWidget(panel->moreLbl, 5, 160);
1215 WMSetLabelText(panel->moreLbl,
1216 _("Enable the \"Don't bind...\" options to allow the "
1217 "application to receive all mouse or keyboard events."));
1219 /* miniwindow/workspace */
1220 panel->iconFrm = WMCreateFrame(panel->win);
1221 WMMoveWidget(panel->iconFrm, 15, 50);
1222 WMResizeWidget(panel->iconFrm, PWIDTH - (2 * 15), 170);
1223 WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
1225 panel->iconLbl = WMCreateLabel(panel->iconFrm);
1226 WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
1227 WMResizeWidget(panel->iconLbl, 64, 64);
1228 WMSetLabelRelief(panel->iconLbl, WRRaised);
1229 WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
1231 panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
1232 WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
1233 WMMoveWidget(panel->browseIconBtn, 22, 30);
1234 WMResizeWidget(panel->browseIconBtn, 100, 26);
1235 WMSetButtonText(panel->browseIconBtn, _("Browse..."));
1237 #if 0
1238 panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
1239 WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
1240 WMMoveWidget(panel->updateIconBtn, 22, 65);
1241 WMResizeWidget(panel->updateIconBtn, 100, 26);
1242 WMSetButtonText(panel->updateIconBtn, _("Update"));
1243 #endif
1244 #ifdef wrong_behaviour
1245 WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
1246 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
1247 WMSetButtonImage(panel->updateIconBtn, pixmap);
1248 WMReleasePixmap(pixmap);
1249 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
1250 WMSetButtonAltImage(panel->updateIconBtn, pixmap);
1251 WMReleasePixmap(pixmap);
1252 #endif
1254 panel->fileLbl = WMCreateLabel(panel->iconFrm);
1255 WMMoveWidget(panel->fileLbl, 20, 95);
1256 WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
1257 WMSetLabelText(panel->fileLbl, _("Icon file name:"));
1259 panel->fileText = WMCreateTextField(panel->iconFrm);
1260 WMMoveWidget(panel->fileText, 20, 115);
1261 WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
1262 WMSetTextFieldText(panel->fileText, NULL);
1263 WMAddNotificationObserver(textEditedObserver, panel,
1264 WMTextDidEndEditingNotification,
1265 panel->fileText);
1266 panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
1267 WMMoveWidget(panel->alwChk, 20, 140);
1268 WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
1269 WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
1270 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
1273 panel->wsFrm = WMCreateFrame(panel->win);
1274 WMMoveWidget(panel->wsFrm, 15, 225);
1275 WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);
1276 WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));
1278 panel->curRb = WMCreateRadioButton(panel->wsFrm);
1279 WMMoveWidget(panel->curRb, 10, 15);
1280 WMResizeWidget(panel->curRb, frame_width - (2 * 10), 20);
1281 WMSetButtonText(panel->curRb, _("Nowhere in particular"));
1284 panel->setRb = WMCreateRadioButton(panel->wsFrm);
1285 WMMoveWidget(panel->setRb, 10, 40);
1286 WMResizeWidget(panel->setRb, 25, 20);
1287 WMGroupButtons(panel->curRb, panel->setRb);
1288 WMSetButtonText(panel->setRb, NULL);
1290 panel->wsText = WMCreateTextField(panel->wsFrm);
1291 WMMoveWidget(panel->wsText, 30, 40);
1292 WMResizeWidget(panel->wsText, PWIDTH - (2 * 15) - 25 - 10 - (2 * 5), 20);
1293 WMAddNotificationObserver(textEditedObserver, panel,
1294 WMTextDidEndEditingNotification,
1295 panel->wsText);
1298 i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
1299 wwin->wm_class);
1300 if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
1301 WMSetButtonSelected(panel->curRb, False);
1302 WMSetButtonSelected(panel->setRb, True);
1303 WMSetTextFieldText(panel->wsText,
1304 wwin->screen_ptr->workspaces[i]->name);
1305 } else {
1306 WMSetButtonSelected(panel->curRb, True);
1307 WMSetButtonSelected(panel->setRb, False);
1310 /* application wide attributes */
1311 if (wwin->main_window != None) {
1312 WApplication *wapp = wApplicationOf(wwin->main_window);
1314 panel->appFrm = WMCreateFrame(panel->win);
1315 WMSetFrameTitle(panel->appFrm, _("Application Wide"));
1316 WMMoveWidget(panel->appFrm, 15, 50);
1317 WMResizeWidget(panel->appFrm, frame_width, 240);
1319 for (i=0; i < 2; i++) {
1320 char *caption = NULL;
1321 int flag = 0;
1323 switch (i) {
1324 case 0:
1325 caption = _("Start Hidden");
1326 flag = WFLAGP(wapp->main_window_desc, start_hidden);
1327 break;
1328 case 1:
1329 caption = _("No application icon");
1330 flag = WFLAGP(wapp->main_window_desc, no_appicon);
1331 break;
1333 panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
1334 WMMoveWidget(panel->appChk[i], 10, 20*(i+1));
1335 WMResizeWidget(panel->appChk[i], 205, 20);
1336 WMSetButtonSelected(panel->appChk[i], flag);
1337 WMSetButtonText(panel->appChk[i], caption);
1340 if (WFLAGP(wwin, emulate_appicon)) {
1341 WMSetButtonEnabled(panel->appChk[1], False);
1342 WMSetButtonEnabled(panel->moreChk[6], True);
1343 } else {
1344 WMSetButtonEnabled(panel->appChk[1], True);
1345 WMSetButtonEnabled(panel->moreChk[6], False);
1347 } else {
1348 int tmp;
1350 if (wwin->transient_for!=None
1351 && wwin->transient_for!=scr->root_win)
1352 tmp = False;
1353 else
1354 tmp = True;
1355 WMSetButtonEnabled(panel->moreChk[6], tmp);
1357 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
1358 panel->appFrm = NULL;
1361 /* if the window is a transient, don't let it have a miniaturize
1362 * button */
1363 if (wWindowFor(wwin->transient_for)!=NULL)
1364 WMSetButtonEnabled(panel->attrChk[3], False);
1365 else
1366 WMSetButtonEnabled(panel->attrChk[3], True);
1369 WMRealizeWidget(panel->win);
1371 WMMapSubwidgets(panel->win);
1372 WMMapSubwidgets(panel->specFrm);
1373 WMMapSubwidgets(panel->attrFrm);
1374 WMMapSubwidgets(panel->moreFrm);
1375 WMMapSubwidgets(panel->iconFrm);
1376 WMMapSubwidgets(panel->wsFrm);
1377 if (panel->appFrm)
1378 WMMapSubwidgets(panel->appFrm);
1380 WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
1381 changePage(panel->pagePopUp, panel);
1384 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
1385 0, 0, 0);
1386 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
1387 panel->parent = parent;
1388 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1390 WMMapWidget(panel->win);
1392 XSetTransientForHint(dpy, parent, wwin->client_win);
1394 x = wwin->frame_x+wwin->frame->core->width/2;
1395 y = wwin->frame_y+wwin->frame->top_width*2;
1396 if (y + PHEIGHT > scr->scr_height)
1397 y = scr->scr_height - PHEIGHT - 30;
1398 if (x + PWIDTH > scr->scr_width)
1399 x = scr->scr_width - PWIDTH;
1400 panel->frame = wManageInternalWindow(scr, parent, wwin->client_win,
1401 charbuf, x, y, PWIDTH, PHEIGHT);
1403 /* kluge to know who should get the key events */
1404 panel->frame->client_leader = WMWidgetXID(panel->win);
1406 WSETUFLAG(panel->frame, no_closable, 0);
1407 WSETUFLAG(panel->frame, no_close_button, 0);
1408 wWindowUpdateButtonImages(panel->frame);
1409 wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
1410 panel->frame->frame->on_click_right = destroyInspector;
1412 wWindowMap(panel->frame);
1414 showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance,
1415 wwin->wm_class, UPDATE_TEXT_FIELD);
1416 return panel;
1420 void
1421 wShowInspectorForWindow(WWindow *wwin)
1423 if (wwin->flags.inspector_open)
1424 return;
1426 make_keys();
1427 wwin->flags.inspector_open = 1;
1428 wwin->inspector = createInspectorForWindow(wwin);;