Code update for Window Maker version 0.50.0
[wmaker-crm.git] / src / winspector.c
blob8109ba1bcee56c0e5c4ac87c74e466002788cd28
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 XUnmapWindow(dpy, panel->parent);
173 XReparentWindow(dpy, panel->parent, panel->frame->screen_ptr->root_win,
174 0, 0);
175 wUnmanageWindow(panel->frame, False);
177 freeInspector(panel);
182 void
183 wDestroyInspectorPanels()
185 InspectorPanel *panel;
187 while (panelList != NULL) {
188 panel = panelList;
189 panelList = panelList->nextPtr;
190 WMDestroyWidget(panel->win);
191 wUnmanageWindow(panel->frame, False);
193 panel->inspected->flags.inspector_open = 0;
194 panel->inspected->inspector = NULL;
196 free(panel);
201 static void
202 changePage(WMPopUpButton *bPtr, InspectorPanel *panel)
204 int page;
206 page = WMGetPopUpButtonSelectedItem(bPtr);
208 if (page == 0) {
209 WMMapWidget(panel->specFrm);
210 WMMapWidget(panel->specLbl);
211 } else if (page == 1) {
212 WMMapWidget(panel->attrFrm);
213 } else if (page == 2) {
214 WMMapWidget(panel->moreFrm);
215 } else if (page == 3) {
216 WMMapWidget(panel->iconFrm);
217 WMMapWidget(panel->wsFrm);
218 } else {
219 WMMapWidget(panel->appFrm);
222 if (page != 0) {
223 WMUnmapWidget(panel->specFrm);
224 WMUnmapWidget(panel->specLbl);
226 if (page != 1)
227 WMUnmapWidget(panel->attrFrm);
228 if (page != 2)
229 WMUnmapWidget(panel->moreFrm);
230 if (page != 3) {
231 WMUnmapWidget(panel->iconFrm);
232 WMUnmapWidget(panel->wsFrm);
234 if (page != 4 && panel->appFrm)
235 WMUnmapWidget(panel->appFrm);
239 #define USE_TEXT_FIELD 1
240 #define UPDATE_TEXT_FIELD 2
241 #define REVERT_TO_DEFAULT 4
244 static int
245 showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
246 char *wm_instance, char *wm_class, int flags)
248 WMPixmap *pixmap = (WMPixmap*) NULL;
249 char *file=NULL, *path=NULL;
250 char *db_icon=NULL;
252 if ((flags & USE_TEXT_FIELD) != 0) {
253 file = WMGetTextFieldText(panel->fileText);
254 if (file && file[0] == 0) {
255 free(file);
256 file = NULL;
258 } else {
259 db_icon = wDefaultGetIconFile(panel->inspected->screen_ptr,
260 wm_instance, wm_class, False);
261 if(db_icon != NULL)
262 file = wstrdup(db_icon);
264 if (db_icon!=NULL && (flags & REVERT_TO_DEFAULT)!=0) {
265 if (file)
266 file = wstrdup(db_icon);
267 flags |= UPDATE_TEXT_FIELD;
270 if ((flags & UPDATE_TEXT_FIELD) != 0) {
271 WMSetTextFieldText(panel->fileText, file);
274 if (file) {
275 path = FindImage(wPreferences.icon_path, file);
277 if (!path) {
278 char *buf;
280 buf = wmalloc(strlen(file)+80);
281 sprintf(buf, _("Could not find icon \"%s\" specified for this window"),
282 file);
283 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
284 _("OK"), NULL, NULL);
285 free(buf);
286 free(file);
287 return -1;
290 pixmap = WMCreatePixmapFromFile(scrPtr, path);
291 free(path);
293 if (!pixmap) {
294 char *buf;
296 buf = wmalloc(strlen(file)+80);
297 sprintf(buf, _("Could not open specified icon \"%s\":%s"),
298 file, RMessageForError(RErrorCode));
299 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
300 _("OK"), NULL, NULL);
301 free(buf);
302 free(file);
303 return -1;
305 free(file);
308 WMSetLabelImage(panel->iconLbl, pixmap);
309 if (pixmap)
310 WMReleasePixmap(pixmap);
312 return 0;
315 #if 0
316 static void
317 updateIcon(WMButton *button, InspectorPanel *panel)
319 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
321 #endif
323 static int
324 getBool(proplist_t value)
326 char *val;
328 if (!PLIsString(value)) {
329 return 0;
331 if (!(val = PLGetString(value))) {
332 return 0;
335 if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T'
336 || val[0]=='t' || val[0]=='1'))
337 || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) {
339 return 1;
340 } else if ((val[1]=='\0'
341 && (val[0]=='n' || val[0]=='N' || val[0]=='F'
342 || val[0]=='f' || val[0]=='0'))
343 || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) {
345 return 0;
346 } else {
347 wwarning(_("can't convert \"%s\" to boolean"), val);
348 return 0;
353 #define UPDATE_DEFAULTS 1
354 #define IS_BOOLEAN 2
358 * Will insert the attribute = value; pair in window's list,
359 * if it's different from the defaults.
360 * Defaults means either defaults database, or attributes saved
361 * for the default window "*". This is to let one revert options that are
362 * global because they were saved for all windows ("*").
367 static void
368 insertAttribute(proplist_t dict, proplist_t window, proplist_t attr,
369 proplist_t value, int *modified, int flags)
371 proplist_t def_win, def_value=NULL;
372 int update = 0;
374 if (!(flags & UPDATE_DEFAULTS) && dict) {
375 if ((def_win = PLGetDictionaryEntry(dict, AnyWindow)) != NULL) {
376 def_value = PLGetDictionaryEntry(def_win, attr);
380 /* If we could not find defaults in database, fall to hardcoded values.
381 * Also this is true if we save defaults for all windows
383 if (!def_value)
384 def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
386 if ((flags & IS_BOOLEAN))
387 update = (getBool(value) != getBool(def_value));
388 else {
389 update = !PLIsEqual(value, def_value);
392 if (update) {
393 PLInsertDictionaryEntry(window, attr, value);
394 *modified = 1;
399 static void
400 saveSettings(WMButton *button, InspectorPanel *panel)
402 WWindow *wwin = panel->inspected;
403 WDDomain *db = WDWindowAttributes;
404 proplist_t dict = db->dictionary;
405 proplist_t winDic, value, key;
406 char buffer[256], *icon_file;
407 int flags = 0;
408 int different = 0;
410 /* Save will apply the changes and save them */
411 applySettings(panel->applyBtn, panel);
413 if (WMGetButtonSelected(panel->instRb) != 0)
414 key = PLMakeString(wwin->wm_instance);
415 else if (WMGetButtonSelected(panel->clsRb) != 0)
416 key = PLMakeString(wwin->wm_class);
417 else if (WMGetButtonSelected(panel->bothRb) != 0) {
418 strcat(strcat(strcpy(buffer, wwin->wm_instance), "."), wwin->wm_class);
419 key = PLMakeString(buffer);
421 else if (WMGetButtonSelected(panel->defaultRb) != 0) {
422 key = PLRetain(AnyWindow);
423 flags = UPDATE_DEFAULTS;
425 else
426 key = NULL;
428 if (!key)
429 return;
431 if (!dict) {
432 dict = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
433 if (dict) {
434 db->dictionary = dict;
435 value = PLMakeString(db->path);
436 PLSetFilename(dict, value);
437 PLRelease(value);
439 else {
440 PLRelease(key);
441 return;
445 if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL,
446 USE_TEXT_FIELD) < 0)
447 return;
449 PLSetStringCmpHook(NULL);
451 winDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
453 /* Update icon for window */
454 icon_file = WMGetTextFieldText(panel->fileText);
455 if (icon_file) {
456 if (icon_file[0] != 0) {
457 value = PLMakeString(icon_file);
458 insertAttribute(dict, winDic, AIcon, value, &different, flags);
459 PLRelease(value);
461 free(icon_file);
464 if (WMGetButtonSelected(panel->curRb) != 0) {
465 value = PLMakeString("");
466 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
467 PLRelease(value);
468 } else if (WMGetButtonSelected(panel->setRb) != 0) {
469 char *ws_name = WMGetTextFieldText(panel->wsText);
470 if (ws_name) {
471 if (ws_name[0] != 0) {
472 value = PLMakeString(ws_name);
473 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
474 PLRelease(value);
476 free(ws_name);
480 flags |= IS_BOOLEAN;
482 value = (WMGetButtonSelected(panel->alwChk)!=0) ? Yes : No;
483 insertAttribute(dict, winDic, AAlwaysUserIcon, value, &different, flags);
485 value = (WMGetButtonSelected(panel->attrChk[0])!=0) ? Yes : No;
486 insertAttribute(dict, winDic, ANoTitlebar, value, &different, flags);
488 value = (WMGetButtonSelected(panel->attrChk[1])!=0) ? Yes : No;
489 insertAttribute(dict, winDic, ANoResizebar, value, &different, flags);
491 value = (WMGetButtonSelected(panel->attrChk[2])!=0) ? Yes : No;
492 insertAttribute(dict, winDic, ANoCloseButton, value, &different, flags);
494 value = (WMGetButtonSelected(panel->attrChk[3])!=0) ? Yes : No;
495 insertAttribute(dict, winDic, ANoMiniaturizeButton, value, &different, flags);
497 value = (WMGetButtonSelected(panel->attrChk[4])!=0) ? Yes : No;
498 insertAttribute(dict, winDic, AKeepOnTop, value, &different, flags);
500 value = (WMGetButtonSelected(panel->attrChk[5])!=0) ? Yes : No;
501 insertAttribute(dict, winDic, AKeepOnBottom, value, &different, flags);
503 value = (WMGetButtonSelected(panel->attrChk[6])!=0) ? Yes : No;
504 insertAttribute(dict, winDic, AOmnipresent, value, &different, flags);
506 value = (WMGetButtonSelected(panel->attrChk[7])!=0) ? Yes : No;
507 insertAttribute(dict, winDic, AStartMiniaturized, value, &different, flags);
509 value = (WMGetButtonSelected(panel->attrChk[8])!=0) ? Yes : No;
510 insertAttribute(dict, winDic, AStartMaximized, value, &different, flags);
512 value = (WMGetButtonSelected(panel->attrChk[9])!=0) ? Yes : No;
513 insertAttribute(dict, winDic, ASkipWindowList, value, &different, flags);
516 value = (WMGetButtonSelected(panel->moreChk[0])!=0) ? Yes : No;
517 insertAttribute(dict, winDic, ANoHideOthers, value, &different, flags);
519 value = (WMGetButtonSelected(panel->moreChk[1])!=0) ? Yes : No;
520 insertAttribute(dict, winDic, ANoKeyBindings, value, &different, flags);
522 value = (WMGetButtonSelected(panel->moreChk[2])!=0) ? Yes : No;
523 insertAttribute(dict, winDic, ANoMouseBindings, value, &different, flags);
525 value = (WMGetButtonSelected(panel->moreChk[3])!=0) ? Yes : No;
526 insertAttribute(dict, winDic, AKeepInsideScreen, value, &different, flags);
528 value = (WMGetButtonSelected(panel->moreChk[4])!=0) ? Yes : No;
529 insertAttribute(dict, winDic, AUnfocusable, value, &different, flags);
531 value = (WMGetButtonSelected(panel->moreChk[5])!=0) ? Yes : No;
532 insertAttribute(dict, winDic, ADontSaveSession, value, &different, flags);
534 value = (WMGetButtonSelected(panel->moreChk[6])!=0) ? Yes : No;
535 insertAttribute(dict, winDic, AEmulateAppIcon, value, &different, flags);
537 /* application wide settings for when */
538 /* the window is the leader, save the attribute with the others */
539 if (panel->inspected->main_window == panel->inspected->client_win) {
541 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
542 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
544 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
545 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
548 PLRemoveDictionaryEntry(dict, key);
549 if (different) {
550 PLInsertDictionaryEntry(dict, key, winDic);
552 PLRelease(key);
553 PLRelease(winDic);
555 different = 0;
557 /* application wide settings */
558 if (panel->inspected->main_window != panel->inspected->client_win
559 && !(flags & UPDATE_DEFAULTS)) {
560 WApplication *wapp;
561 proplist_t appDic;
563 wapp = wApplicationOf(panel->inspected->main_window);
564 if (wapp) {
565 char *iconFile;
567 appDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
569 assert(wapp->main_window_desc->wm_instance!=NULL);
570 assert(wapp->main_window_desc->wm_class!=NULL);
572 strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), ".");
573 strcat(buffer, wwin->wm_class);
574 key = PLMakeString(buffer);
576 iconFile = wDefaultGetIconFile(wwin->screen_ptr,
577 wapp->main_window_desc->wm_instance,
578 wapp->main_window_desc->wm_class,
579 False);
581 if (iconFile && iconFile[0]!=0) {
582 value = PLMakeString(iconFile);
583 insertAttribute(dict, appDic, AIcon, value, &different,
584 flags&~IS_BOOLEAN);
585 PLRelease(value);
588 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
589 insertAttribute(dict, appDic, AStartHidden, value, &different, flags);
591 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
592 insertAttribute(dict, appDic, ANoAppIcon, value, &different, flags);
594 PLRemoveDictionaryEntry(dict, key);
595 if (different) {
596 PLInsertDictionaryEntry(dict, key, appDic);
598 PLRelease(key);
599 PLRelease(appDic);
603 PLSave(dict, YES);
605 /* clean up */
606 PLSetStringCmpHook(StringCompareHook);
610 static void
611 makeAppIconFor(WApplication *wapp)
613 WScreen *scr = wapp->main_window_desc->screen_ptr;
615 if (wapp->app_icon)
616 return;
618 if (!WFLAGP(wapp->main_window_desc, no_appicon))
619 wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
620 else
621 wapp->app_icon = NULL;
623 if (wapp->app_icon) {
624 WIcon *icon = wapp->app_icon->icon;
625 WDock *clip = scr->workspaces[scr->current_workspace]->clip;
626 int x=0, y=0;
628 wapp->app_icon->main_window = wapp->main_window;
630 if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
631 wapp->app_icon->attracted = 1;
632 if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {
633 wapp->app_icon->icon->shadowed = 1;
634 wapp->app_icon->icon->force_paint = 1;
636 wDockAttachIcon(clip, wapp->app_icon, x, y);
637 } else {
638 PlaceIcon(scr, &x, &y);
639 wAppIconMove(wapp->app_icon, x, y);
641 if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
642 XMapWindow(dpy, icon->core->window);
644 if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted)
645 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
650 static void
651 removeAppIconFor(WApplication *wapp)
653 if (!wapp->app_icon)
654 return;
656 if (wapp->app_icon->docked &&
657 (!wapp->app_icon->attracted || wapp->app_icon->dock->keep_attracted)) {
658 wapp->app_icon->running = 0;
659 /* since we keep it, we don't care if it was attracted or not */
660 wapp->app_icon->attracted = 0;
661 wapp->app_icon->icon->shadowed = 0;
662 wapp->app_icon->main_window = None;
663 wapp->app_icon->pid = 0;
664 wapp->app_icon->icon->owner = NULL;
665 wapp->app_icon->icon->icon_win = None;
666 wapp->app_icon->icon->force_paint = 1;
667 wAppIconPaint(wapp->app_icon);
668 } else if (wapp->app_icon->docked) {
669 wapp->app_icon->running = 0;
670 wDockDetach(wapp->app_icon->dock, wapp->app_icon);
671 } else {
672 wAppIconDestroy(wapp->app_icon);
674 wapp->app_icon = NULL;
675 if (wPreferences.auto_arrange_icons)
676 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
680 static void
681 applySettings(WMButton *button, InspectorPanel *panel)
683 WWindow *wwin = panel->inspected;
684 WApplication *wapp = wApplicationOf(wwin->main_window);
685 int floating, sunken, skip_window_list;
686 int old_omnipresent;
687 int old_no_bind_keys;
688 int old_no_bind_mouse;
690 old_omnipresent = WFLAGP(wwin, omnipresent);
691 old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
692 old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse);
694 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
696 WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0]));
697 WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1]));
698 WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2]));
699 WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3]));
700 floating = WMGetButtonSelected(panel->attrChk[4]);
701 sunken = WMGetButtonSelected(panel->attrChk[5]);
702 WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[6]));
703 WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[7]));
704 WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[8]));
705 skip_window_list = WMGetButtonSelected(panel->attrChk[9]);
707 WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[0]));
708 WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[1]));
709 WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[2]));
710 WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[3]));
711 WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4]));
712 WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[5]));
713 WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[6]));
714 WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
716 if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
717 wUnshadeWindow(wwin);
719 WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));
721 if (floating) {
722 if (!WFLAGP(wwin, floating))
723 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
724 } else if (sunken) {
725 if (!WFLAGP(wwin, sunken))
726 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
727 } else {
728 if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
729 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
732 WSETUFLAG(wwin, sunken, sunken);
733 WSETUFLAG(wwin, floating, floating);
734 wwin->flags.omnipresent = 0;
736 if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
737 WSETUFLAG(wwin, skip_window_list, skip_window_list);
738 UpdateSwitchMenu(wwin->screen_ptr, wwin,
739 skip_window_list ? ACTION_REMOVE : ACTION_ADD);
740 } else {
741 if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
742 UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
746 if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
747 if (!WFLAGP(wwin, no_bind_keys)) {
748 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
749 } else {
750 wWindowSetKeyGrabs(wwin);
754 if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
755 wWindowResetMouseGrabs(wwin);
758 wwin->frame->flags.need_texture_change = 1;
759 wWindowConfigureBorders(wwin);
760 wFrameWindowPaint(wwin->frame);
763 * Can't apply emulate_appicon because it will probably cause problems.
766 if (wapp) {
767 /* do application wide stuff */
768 WSETUFLAG(wapp->main_window_desc, start_hidden,
769 WMGetButtonSelected(panel->appChk[0]));
771 WSETUFLAG(wapp->main_window_desc, no_appicon,
772 WMGetButtonSelected(panel->appChk[1]));
774 if (WFLAGP(wapp->main_window_desc, no_appicon))
775 removeAppIconFor(wapp);
776 else
777 makeAppIconFor(wapp);
779 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
780 char *file = WMGetTextFieldText(panel->fileText);
782 if (file[0] == 0) {
783 free(file);
784 file = NULL;
786 wIconChangeImageFile(wapp->app_icon->icon, file);
787 if (file)
788 free(file);
789 wAppIconPaint(wapp->app_icon);
795 static void
796 revertSettings(WMButton *button, InspectorPanel *panel)
798 WWindow *wwin = panel->inspected;
799 WApplication *wapp = wApplicationOf(wwin->main_window);
800 int i, n;
801 char *wm_instance = NULL;
802 char *wm_class = NULL;
803 int workspace, level;
805 if (WMGetButtonSelected(panel->instRb) != 0)
806 wm_instance = wwin->wm_instance;
807 else if (WMGetButtonSelected(panel->clsRb) != 0)
808 wm_class = wwin->wm_class;
809 else if (WMGetButtonSelected(panel->bothRb) != 0) {
810 wm_instance = wwin->wm_instance;
811 wm_class = wwin->wm_class;
813 memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
814 memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
815 memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
817 wWindowSetupInitialAttributes(wwin, &level, &workspace);
819 for (i=0; i < 10; i++) {
820 int flag = 0;
822 switch (i) {
823 case 0:
824 flag = WFLAGP(wwin, no_titlebar);
825 break;
826 case 1:
827 flag = WFLAGP(wwin, no_resizebar);
828 break;
829 case 2:
830 flag = WFLAGP(wwin, no_close_button);
831 break;
832 case 3:
833 flag = WFLAGP(wwin, no_miniaturize_button);
834 break;
835 case 4:
836 flag = WFLAGP(wwin, floating);
837 break;
838 case 5:
839 flag = WFLAGP(wwin, sunken);
840 break;
841 case 6:
842 flag = WFLAGP(wwin, omnipresent);
843 break;
844 case 7:
845 flag = WFLAGP(wwin, start_miniaturized);
846 break;
847 case 8:
848 flag = WFLAGP(wwin, start_maximized!=0);
849 break;
850 case 9:
851 flag = WFLAGP(wwin, skip_window_list);
852 break;
854 WMSetButtonSelected(panel->attrChk[i], flag);
856 for (i=0; i < 7; i++) {
857 int flag = 0;
859 switch (i) {
860 case 0:
861 flag = WFLAGP(wwin, no_hide_others);
862 break;
863 case 1:
864 flag = WFLAGP(wwin, no_bind_keys);
865 break;
866 case 2:
867 flag = WFLAGP(wwin, no_bind_mouse);
868 break;
869 case 3:
870 flag = WFLAGP(wwin, dont_move_off);
871 break;
872 case 4:
873 flag = WFLAGP(wwin, no_focusable);
874 break;
875 case 5:
876 flag = WFLAGP(wwin, dont_save_session);
877 break;
878 case 6:
879 flag = WFLAGP(wwin, emulate_appicon);
880 break;
882 WMSetButtonSelected(panel->moreChk[i], flag);
884 if (panel->appFrm && wapp) {
885 for (i=0; i < 2; i++) {
886 int flag = 0;
888 switch (i) {
889 case 0:
890 flag = WFLAGP(wapp->main_window_desc, start_hidden);
891 break;
892 case 1:
893 flag = WFLAGP(wapp->main_window_desc, no_appicon);
894 break;
896 WMSetButtonSelected(panel->appChk[i], flag);
899 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
901 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
902 REVERT_TO_DEFAULT);
904 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
906 if (n >= 0 && n <= wwin->screen_ptr->workspace_count) {
907 WMPerformButtonClick(panel->setRb);
908 WMSetTextFieldText(panel->wsText, wwin->screen_ptr->workspaces[n]->name);
909 } else {
910 WMPerformButtonClick(panel->curRb);
915 static void
916 chooseIconCallback(WMWidget *self, void *clientData)
918 char *file;
919 InspectorPanel *panel = (InspectorPanel*)clientData;
920 int result;
922 panel->choosingIcon = 1;
924 WMSetButtonEnabled(panel->browseIconBtn, False);
926 result = wIconChooserDialog(panel->frame->screen_ptr, &file);
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 ((int)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);;