Changed initial workspace specification in window attributes panel.
[wmaker-crm.git] / src / winspector.c
blob57f1664bfd641387c5ba2a47d16779f194c21f0d
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;
75 static proplist_t AFullMaximize;
77 static proplist_t AStartWorkspace;
79 static proplist_t AIcon;
81 /* application wide options */
82 static proplist_t AStartHidden;
85 static proplist_t AnyWindow;
86 static proplist_t EmptyString;
87 static proplist_t Yes, No;
90 #define PWIDTH 270
91 #define PHEIGHT 350
94 static void applySettings(WMButton *button, InspectorPanel *panel);
96 static void
97 make_keys()
99 if (ANoTitlebar!=NULL)
100 return;
102 AIcon = PLMakeString("Icon");
103 ANoTitlebar = PLMakeString("NoTitlebar");
104 ANoResizebar = PLMakeString("NoResizebar");
105 ANoMiniaturizeButton = PLMakeString("NoMiniaturizeButton");
106 ANoCloseButton = PLMakeString("NoCloseButton");
107 ANoHideOthers = PLMakeString("NoHideOthers");
108 ANoMouseBindings = PLMakeString("NoMouseBindings");
109 ANoKeyBindings = PLMakeString("NoKeyBindings");
110 ANoAppIcon = PLMakeString("NoAppIcon");
111 AKeepOnTop = PLMakeString("KeepOnTop");
112 AKeepOnBottom = PLMakeString("KeepOnBottom");
113 AOmnipresent = PLMakeString("Omnipresent");
114 ASkipWindowList = PLMakeString("SkipWindowList");
115 AKeepInsideScreen = PLMakeString("KeepInsideScreen");
116 AUnfocusable = PLMakeString("Unfocusable");
117 AAlwaysUserIcon = PLMakeString("AlwaysUserIcon");
118 AStartMiniaturized = PLMakeString("StartMiniaturized");
119 AStartMaximized = PLMakeString("StartMaximized");
120 AStartHidden = PLMakeString("StartHidden");
121 ADontSaveSession = PLMakeString("DontSaveSession");
122 AEmulateAppIcon = PLMakeString("EmulateAppIcon");
123 AFullMaximize = PLMakeString("FullMaximize");
125 AStartWorkspace = PLMakeString("StartWorkspace");
127 AnyWindow = PLMakeString("*");
128 EmptyString = PLMakeString("");
129 Yes = PLMakeString("Yes");
130 No = PLMakeString("No");
135 static void
136 freeInspector(InspectorPanel *panel)
138 panel->destroyed = 1;
139 if (panel->choosingIcon)
140 return;
142 WMDestroyWidget(panel->win);
144 XDestroyWindow(dpy, panel->parent);
146 free(panel);
150 static void
151 destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
153 InspectorPanel *panel;
154 InspectorPanel *tmp;
156 panel = panelList;
157 while (panel->frame!=data)
158 panel = panel->nextPtr;
160 if (panelList == panel)
161 panelList = panel->nextPtr;
162 else {
163 tmp = panelList;
164 while (tmp->nextPtr!=panel) {
165 tmp = tmp->nextPtr;
167 tmp->nextPtr = panel->nextPtr;
169 panel->inspected->flags.inspector_open = 0;
170 panel->inspected->inspector = NULL;
172 WMRemoveNotificationObserver(panel);
174 wWindowUnmap(panel->frame);
175 wUnmanageWindow(panel->frame, True, False);
177 freeInspector(panel);
182 void
183 wDestroyInspectorPanels()
185 InspectorPanel *panel;
187 while (panelList != NULL) {
188 panel = panelList;
189 panelList = panelList->nextPtr;
190 wUnmanageWindow(panel->frame, False, False);
191 WMDestroyWidget(panel->win);
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);
465 int i = WMGetPopUpButtonSelectedItem(panel->wsP);
467 i--;
469 if (i>=0 && i < panel->frame->screen_ptr->workspace_count) {
470 value = PLMakeString(panel->frame->screen_ptr->workspaces[i]->name);
471 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
472 PLRelease(value);
476 flags |= IS_BOOLEAN;
478 value = (WMGetButtonSelected(panel->alwChk)!=0) ? Yes : No;
479 insertAttribute(dict, winDic, AAlwaysUserIcon, value, &different, flags);
481 value = (WMGetButtonSelected(panel->attrChk[0])!=0) ? Yes : No;
482 insertAttribute(dict, winDic, ANoTitlebar, value, &different, flags);
484 value = (WMGetButtonSelected(panel->attrChk[1])!=0) ? Yes : No;
485 insertAttribute(dict, winDic, ANoResizebar, value, &different, flags);
487 value = (WMGetButtonSelected(panel->attrChk[2])!=0) ? Yes : No;
488 insertAttribute(dict, winDic, ANoCloseButton, value, &different, flags);
490 value = (WMGetButtonSelected(panel->attrChk[3])!=0) ? Yes : No;
491 insertAttribute(dict, winDic, ANoMiniaturizeButton, value, &different, flags);
493 value = (WMGetButtonSelected(panel->attrChk[4])!=0) ? Yes : No;
494 insertAttribute(dict, winDic, AKeepOnTop, value, &different, flags);
496 value = (WMGetButtonSelected(panel->attrChk[5])!=0) ? Yes : No;
497 insertAttribute(dict, winDic, AKeepOnBottom, value, &different, flags);
499 value = (WMGetButtonSelected(panel->attrChk[6])!=0) ? Yes : No;
500 insertAttribute(dict, winDic, AOmnipresent, value, &different, flags);
502 value = (WMGetButtonSelected(panel->attrChk[7])!=0) ? Yes : No;
503 insertAttribute(dict, winDic, AStartMiniaturized, value, &different, flags);
505 value = (WMGetButtonSelected(panel->attrChk[8])!=0) ? Yes : No;
506 insertAttribute(dict, winDic, AStartMaximized, value, &different, flags);
508 value = (WMGetButtonSelected(panel->attrChk[9])!=0) ? Yes : No;
509 insertAttribute(dict, winDic, ASkipWindowList, value, &different, flags);
512 value = (WMGetButtonSelected(panel->moreChk[0])!=0) ? Yes : No;
513 insertAttribute(dict, winDic, ANoHideOthers, value, &different, flags);
515 value = (WMGetButtonSelected(panel->moreChk[1])!=0) ? Yes : No;
516 insertAttribute(dict, winDic, ANoKeyBindings, value, &different, flags);
518 value = (WMGetButtonSelected(panel->moreChk[2])!=0) ? Yes : No;
519 insertAttribute(dict, winDic, ANoMouseBindings, value, &different, flags);
521 value = (WMGetButtonSelected(panel->moreChk[3])!=0) ? Yes : No;
522 insertAttribute(dict, winDic, AKeepInsideScreen, value, &different, flags);
524 value = (WMGetButtonSelected(panel->moreChk[4])!=0) ? Yes : No;
525 insertAttribute(dict, winDic, AUnfocusable, value, &different, flags);
527 value = (WMGetButtonSelected(panel->moreChk[5])!=0) ? Yes : No;
528 insertAttribute(dict, winDic, ADontSaveSession, value, &different, flags);
530 value = (WMGetButtonSelected(panel->moreChk[6])!=0) ? Yes : No;
531 insertAttribute(dict, winDic, AEmulateAppIcon, value, &different, flags);
533 value = (WMGetButtonSelected(panel->moreChk[7])!=0) ? Yes : No;
534 insertAttribute(dict, winDic, AFullMaximize, value, &different, flags);
536 /* application wide settings for when */
537 /* the window is the leader, save the attribute with the others */
538 if (panel->inspected->main_window == panel->inspected->client_win) {
540 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
541 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
543 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
544 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
547 PLRemoveDictionaryEntry(dict, key);
548 if (different) {
549 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, full_maximize, WMGetButtonSelected(panel->moreChk[7]));
715 WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
717 if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
718 wUnshadeWindow(wwin);
720 WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));
722 if (floating) {
723 if (!WFLAGP(wwin, floating))
724 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
725 } else if (sunken) {
726 if (!WFLAGP(wwin, sunken))
727 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
728 } else {
729 if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
730 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
733 WSETUFLAG(wwin, sunken, sunken);
734 WSETUFLAG(wwin, floating, floating);
735 wwin->flags.omnipresent = 0;
737 if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
738 WSETUFLAG(wwin, skip_window_list, skip_window_list);
739 UpdateSwitchMenu(wwin->screen_ptr, wwin,
740 skip_window_list ? ACTION_REMOVE : ACTION_ADD);
741 } else {
742 if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
743 UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
747 if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
748 if (WFLAGP(wwin, no_bind_keys)) {
749 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
750 } else {
751 wWindowSetKeyGrabs(wwin);
755 if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
756 wWindowResetMouseGrabs(wwin);
759 wwin->frame->flags.need_texture_change = 1;
760 wWindowConfigureBorders(wwin);
761 wFrameWindowPaint(wwin->frame);
764 * Can't apply emulate_appicon because it will probably cause problems.
767 if (wapp) {
768 /* do application wide stuff */
769 WSETUFLAG(wapp->main_window_desc, start_hidden,
770 WMGetButtonSelected(panel->appChk[0]));
772 WSETUFLAG(wapp->main_window_desc, no_appicon,
773 WMGetButtonSelected(panel->appChk[1]));
775 if (WFLAGP(wapp->main_window_desc, no_appicon))
776 removeAppIconFor(wapp);
777 else
778 makeAppIconFor(wapp);
780 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
781 char *file = WMGetTextFieldText(panel->fileText);
783 if (file[0] == 0) {
784 free(file);
785 file = NULL;
787 wIconChangeImageFile(wapp->app_icon->icon, file);
788 if (file)
789 free(file);
790 wAppIconPaint(wapp->app_icon);
798 static void
799 revertSettings(WMButton *button, InspectorPanel *panel)
801 WWindow *wwin = panel->inspected;
802 WApplication *wapp = wApplicationOf(wwin->main_window);
803 int i, n;
804 char *wm_instance = NULL;
805 char *wm_class = NULL;
806 int workspace, level;
808 if (WMGetButtonSelected(panel->instRb) != 0)
809 wm_instance = wwin->wm_instance;
810 else if (WMGetButtonSelected(panel->clsRb) != 0)
811 wm_class = wwin->wm_class;
812 else if (WMGetButtonSelected(panel->bothRb) != 0) {
813 wm_instance = wwin->wm_instance;
814 wm_class = wwin->wm_class;
816 memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
817 memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
818 memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
820 wWindowSetupInitialAttributes(wwin, &level, &workspace);
822 for (i=0; i < 10; i++) {
823 int flag = 0;
825 switch (i) {
826 case 0:
827 flag = WFLAGP(wwin, no_titlebar);
828 break;
829 case 1:
830 flag = WFLAGP(wwin, no_resizebar);
831 break;
832 case 2:
833 flag = WFLAGP(wwin, no_close_button);
834 break;
835 case 3:
836 flag = WFLAGP(wwin, no_miniaturize_button);
837 break;
838 case 4:
839 flag = WFLAGP(wwin, floating);
840 break;
841 case 5:
842 flag = WFLAGP(wwin, sunken);
843 break;
844 case 6:
845 flag = WFLAGP(wwin, omnipresent);
846 break;
847 case 7:
848 flag = WFLAGP(wwin, start_miniaturized);
849 break;
850 case 8:
851 flag = WFLAGP(wwin, start_maximized!=0);
852 break;
853 case 9:
854 flag = WFLAGP(wwin, skip_window_list);
855 break;
857 WMSetButtonSelected(panel->attrChk[i], flag);
859 for (i=0; i < 8; i++) {
860 int flag = 0;
862 switch (i) {
863 case 0:
864 flag = WFLAGP(wwin, no_hide_others);
865 break;
866 case 1:
867 flag = WFLAGP(wwin, no_bind_keys);
868 break;
869 case 2:
870 flag = WFLAGP(wwin, no_bind_mouse);
871 break;
872 case 3:
873 flag = WFLAGP(wwin, dont_move_off);
874 break;
875 case 4:
876 flag = WFLAGP(wwin, no_focusable);
877 break;
878 case 5:
879 flag = WFLAGP(wwin, dont_save_session);
880 break;
881 case 6:
882 flag = WFLAGP(wwin, emulate_appicon);
883 break;
884 case 7:
885 flag = WFLAGP(wwin, full_maximize);
886 break;
888 WMSetButtonSelected(panel->moreChk[i], flag);
890 if (panel->appFrm && wapp) {
891 for (i=0; i < 2; i++) {
892 int flag = 0;
894 switch (i) {
895 case 0:
896 flag = WFLAGP(wapp->main_window_desc, start_hidden);
897 break;
898 case 1:
899 flag = WFLAGP(wapp->main_window_desc, no_appicon);
900 break;
902 WMSetButtonSelected(panel->appChk[i], flag);
905 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
907 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
908 REVERT_TO_DEFAULT);
910 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
912 if (n >= 0 && n < wwin->screen_ptr->workspace_count) {
913 WMSetPopUpButtonSelectedItem(panel->wsP, n+1);
914 } else {
915 WMSetPopUpButtonSelectedItem(panel->wsP, 0);
920 static void
921 chooseIconCallback(WMWidget *self, void *clientData)
923 char *file;
924 InspectorPanel *panel = (InspectorPanel*)clientData;
925 int result;
927 panel->choosingIcon = 1;
929 WMSetButtonEnabled(panel->browseIconBtn, False);
931 result = wIconChooserDialog(panel->frame->screen_ptr, &file,
932 panel->inspected->wm_instance,
933 panel->inspected->wm_class);
935 panel->choosingIcon = 0;
937 if (!panel->destroyed) { /* kluge */
938 if (result) {
939 WMSetTextFieldText(panel->fileText, file);
940 showIconFor(WMWidgetScreen(self), panel, NULL, NULL,
941 USE_TEXT_FIELD);
942 free(file);
944 WMSetButtonEnabled(panel->browseIconBtn, True);
945 } else {
946 freeInspector(panel);
951 static void
952 textEditedObserver(void *observerData, WMNotification *notification)
954 InspectorPanel *panel = (InspectorPanel*)observerData;
956 if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement)
957 return;
959 showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL,
960 USE_TEXT_FIELD);
962 WMPerformButtonClick(panel->updateIconBtn);
967 static void
968 selectSpecification(WMWidget *bPtr, void *data)
970 InspectorPanel *panel = (InspectorPanel*)data;
972 if (bPtr == panel->defaultRb) {
973 WMSetButtonEnabled(panel->applyBtn, False);
974 } else {
975 WMSetButtonEnabled(panel->applyBtn, True);
980 static InspectorPanel*
981 createInspectorForWindow(WWindow *wwin)
983 WScreen *scr = wwin->screen_ptr;
984 InspectorPanel *panel;
985 Window parent;
986 char charbuf[128];
987 int i;
988 int x, y;
989 int btn_width, frame_width;
990 #ifdef wrong_behaviour
991 WMPixmap *pixmap;
992 #endif
993 panel = wmalloc(sizeof(InspectorPanel));
994 memset(panel, 0, sizeof(InspectorPanel));
996 panel->destroyed = 0;
999 panel->inspected = wwin;
1001 panel->nextPtr = panelList;
1002 panelList = panel;
1005 sprintf(charbuf, "Inspecting %s.%s",
1006 wwin->wm_instance ? wwin->wm_instance : "?",
1007 wwin->wm_class ? wwin->wm_class : "?");
1009 panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
1010 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1013 /**** create common stuff ****/
1015 /* command buttons */
1016 /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
1017 btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
1018 panel->saveBtn = WMCreateCommandButton(panel->win);
1019 WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);
1020 WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, 310);
1021 WMSetButtonText(panel->saveBtn, _("Save"));
1022 WMResizeWidget(panel->saveBtn, btn_width, 28);
1023 if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance))
1024 WMSetButtonEnabled(panel->saveBtn, False);
1026 panel->applyBtn = WMCreateCommandButton(panel->win);
1027 WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);
1028 WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);
1029 WMSetButtonText(panel->applyBtn, _("Apply"));
1030 WMResizeWidget(panel->applyBtn, btn_width, 28);
1032 panel->revertBtn = WMCreateCommandButton(panel->win);
1033 WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);
1034 WMMoveWidget(panel->revertBtn, 15, 310);
1035 WMSetButtonText(panel->revertBtn, _("Reload"));
1036 WMResizeWidget(panel->revertBtn, btn_width, 28);
1038 /* page selection popup button */
1039 panel->pagePopUp = WMCreatePopUpButton(panel->win);
1040 WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);
1041 WMMoveWidget(panel->pagePopUp, 25, 15);
1042 WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);
1044 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));
1045 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));
1046 WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));
1047 WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));
1048 WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));
1050 /**** window spec ****/
1051 frame_width = PWIDTH - (2 * 15);
1053 panel->specFrm = WMCreateFrame(panel->win);
1054 WMSetFrameTitle(panel->specFrm, _("Window Specification"));
1055 WMMoveWidget(panel->specFrm, 15, 65);
1056 WMResizeWidget(panel->specFrm, frame_width, 105);
1059 panel->defaultRb = WMCreateRadioButton(panel->specFrm);
1060 WMMoveWidget(panel->defaultRb, 10, 78);
1061 WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);
1062 WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));
1063 WMSetButtonSelected(panel->defaultRb, False);
1064 WMSetButtonAction(panel->defaultRb, selectSpecification, panel);
1067 if (wwin->wm_class && wwin->wm_instance) {
1068 sprintf(charbuf, "%s.%s", wwin->wm_instance, wwin->wm_class);
1069 panel->bothRb = WMCreateRadioButton(panel->specFrm);
1070 WMMoveWidget(panel->bothRb, 10, 18);
1071 WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);
1072 WMSetButtonText(panel->bothRb, charbuf);
1073 WMSetButtonSelected(panel->bothRb, True);
1074 WMGroupButtons(panel->defaultRb, panel->bothRb);
1076 WMSetButtonAction(panel->bothRb, selectSpecification, panel);
1079 if (wwin->wm_instance) {
1080 panel->instRb = WMCreateRadioButton(panel->specFrm);
1081 WMMoveWidget(panel->instRb, 10, 38);
1082 WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);
1083 WMSetButtonText(panel->instRb, wwin->wm_instance);
1084 WMSetButtonSelected(panel->instRb, False);
1085 WMGroupButtons(panel->defaultRb, panel->instRb);
1087 WMSetButtonAction(panel->instRb, selectSpecification, panel);
1090 if (wwin->wm_class) {
1091 panel->clsRb = WMCreateRadioButton(panel->specFrm);
1092 WMMoveWidget(panel->clsRb, 10, 58);
1093 WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);
1094 WMSetButtonText(panel->clsRb, wwin->wm_class);
1095 WMSetButtonSelected(panel->clsRb, False);
1096 WMGroupButtons(panel->defaultRb, panel->clsRb);
1098 WMSetButtonAction(panel->clsRb, selectSpecification, panel);
1101 panel->specLbl = WMCreateLabel(panel->win);
1102 WMMoveWidget(panel->specLbl, 15, 170);
1103 WMResizeWidget(panel->specLbl, frame_width, 100);
1104 WMSetLabelText(panel->specLbl,
1105 _("The configuration will apply to all\n"
1106 "windows that have their WM_CLASS property"
1107 " set to the above selected\nname, when saved."));
1108 WMSetLabelTextAlignment(panel->specLbl, WACenter);
1110 /**** attributes ****/
1111 panel->attrFrm = WMCreateFrame(panel->win);
1112 WMSetFrameTitle(panel->attrFrm, _("Attributes"));
1113 WMMoveWidget(panel->attrFrm, 15, 45);
1114 WMResizeWidget(panel->attrFrm, frame_width, 250);
1116 for (i=0; i < 10; i++) {
1117 char *caption = NULL;
1118 int flag = 0;
1120 switch (i) {
1121 case 0:
1122 caption = _("Disable Titlebar");
1123 flag = WFLAGP(wwin, no_titlebar);
1124 break;
1125 case 1:
1126 caption = _("Disable Resizebar");
1127 flag = WFLAGP(wwin, no_resizebar);
1128 break;
1129 case 2:
1130 caption = _("Disable Close Button");
1131 flag = WFLAGP(wwin, no_close_button);
1132 break;
1133 case 3:
1134 caption = _("Disable Miniaturize Button");
1135 flag = WFLAGP(wwin, no_miniaturize_button);
1136 break;
1137 case 4:
1138 caption = _("Keep on Top / Floating");
1139 flag = WFLAGP(wwin, floating);
1140 break;
1141 case 5:
1142 caption = _("Keep at Bottom / Sunken");
1143 flag = WFLAGP(wwin, sunken);
1144 break;
1145 case 6:
1146 caption = _("Omnipresent");
1147 flag = WFLAGP(wwin, omnipresent);
1148 break;
1149 case 7:
1150 caption = _("Start Miniaturized");
1151 flag = WFLAGP(wwin, start_miniaturized);
1152 break;
1153 case 8:
1154 caption = _("Start Maximized");
1155 flag = WFLAGP(wwin, start_maximized!=0);
1156 break;
1157 case 9:
1158 caption = _("Skip Window List");
1159 flag = WFLAGP(wwin, skip_window_list);
1160 break;
1162 panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
1163 WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));
1164 WMResizeWidget(panel->attrChk[i], frame_width-15, 20);
1165 WMSetButtonSelected(panel->attrChk[i], flag);
1166 WMSetButtonText(panel->attrChk[i], caption);
1170 /**** more attributes ****/
1171 panel->moreFrm = WMCreateFrame(panel->win);
1172 WMSetFrameTitle(panel->moreFrm, _("Advanced"));
1173 WMMoveWidget(panel->moreFrm, 15, 45);
1174 WMResizeWidget(panel->moreFrm, frame_width, 250);
1176 for (i=0; i < 8; i++) {
1177 char *caption = NULL;
1178 int flag = 0;
1180 switch (i) {
1181 case 0:
1182 caption = _("Ignore HideOthers");
1183 flag = WFLAGP(wwin, no_hide_others);
1184 break;
1185 case 1:
1186 caption = _("Don't Bind Keyboard Shortcuts");
1187 flag = WFLAGP(wwin, no_bind_keys);
1188 break;
1189 case 2:
1190 caption = _("Don't Bind Mouse Clicks");
1191 flag = WFLAGP(wwin, no_bind_mouse);
1192 break;
1193 case 3:
1194 caption = _("Keep Inside Screen");
1195 flag = WFLAGP(wwin, dont_move_off);
1196 break;
1197 case 4:
1198 caption = _("Don't Let It Take Focus");
1199 flag = WFLAGP(wwin, no_focusable);
1200 break;
1201 case 5:
1202 caption = _("Don't Save Session");
1203 flag = WFLAGP(wwin, dont_save_session);
1204 break;
1205 case 6:
1206 caption = _("Emulate Application Icon");
1207 flag = WFLAGP(wwin, emulate_appicon);
1208 break;
1209 case 7:
1210 caption = _("Full Screen Maximization");
1211 flag = WFLAGP(wwin, full_maximize);
1212 break;
1214 panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
1215 WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));
1216 WMResizeWidget(panel->moreChk[i], frame_width-15, 20);
1217 WMSetButtonSelected(panel->moreChk[i], flag);
1218 WMSetButtonText(panel->moreChk[i], caption);
1221 panel->moreLbl = WMCreateLabel(panel->moreFrm);
1222 WMResizeWidget(panel->moreLbl, frame_width - (2 * 5), 60);
1223 WMMoveWidget(panel->moreLbl, 5, 180);
1224 WMSetLabelText(panel->moreLbl,
1225 _("Enable the \"Don't bind...\" options to allow the "
1226 "application to receive all mouse or keyboard events."));
1228 /* miniwindow/workspace */
1229 panel->iconFrm = WMCreateFrame(panel->win);
1230 WMMoveWidget(panel->iconFrm, 15, 50);
1231 WMResizeWidget(panel->iconFrm, PWIDTH - (2 * 15), 170);
1232 WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
1234 panel->iconLbl = WMCreateLabel(panel->iconFrm);
1235 WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
1236 WMResizeWidget(panel->iconLbl, 64, 64);
1237 WMSetLabelRelief(panel->iconLbl, WRGroove);
1238 WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
1240 panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
1241 WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
1242 WMMoveWidget(panel->browseIconBtn, 22, 30);
1243 WMResizeWidget(panel->browseIconBtn, 100, 26);
1244 WMSetButtonText(panel->browseIconBtn, _("Browse..."));
1246 #if 0
1247 panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
1248 WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
1249 WMMoveWidget(panel->updateIconBtn, 22, 65);
1250 WMResizeWidget(panel->updateIconBtn, 100, 26);
1251 WMSetButtonText(panel->updateIconBtn, _("Update"));
1252 #endif
1253 #ifdef wrong_behaviour
1254 WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
1255 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
1256 WMSetButtonImage(panel->updateIconBtn, pixmap);
1257 WMReleasePixmap(pixmap);
1258 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
1259 WMSetButtonAltImage(panel->updateIconBtn, pixmap);
1260 WMReleasePixmap(pixmap);
1261 #endif
1263 panel->fileLbl = WMCreateLabel(panel->iconFrm);
1264 WMMoveWidget(panel->fileLbl, 20, 95);
1265 WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
1266 WMSetLabelText(panel->fileLbl, _("Icon File Name:"));
1268 panel->fileText = WMCreateTextField(panel->iconFrm);
1269 WMMoveWidget(panel->fileText, 20, 115);
1270 WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
1271 WMSetTextFieldText(panel->fileText, NULL);
1272 WMAddNotificationObserver(textEditedObserver, panel,
1273 WMTextDidEndEditingNotification,
1274 panel->fileText);
1275 panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
1276 WMMoveWidget(panel->alwChk, 20, 140);
1277 WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
1278 WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
1279 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
1282 panel->wsFrm = WMCreateFrame(panel->win);
1283 WMMoveWidget(panel->wsFrm, 15, 225);
1284 WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);
1285 WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));
1287 panel->wsP = WMCreatePopUpButton(panel->wsFrm);
1288 WMMoveWidget(panel->wsP, 20, 30);
1289 WMResizeWidget(panel->wsP, PWIDTH - (2 * 15) - (2 * 20), 20);
1290 WMAddPopUpButtonItem(panel->wsP, _("Nowhere in particular"));
1291 for (i = 0; i < wwin->screen_ptr->workspace_count; i++) {
1292 WMAddPopUpButtonItem(panel->wsP, scr->workspaces[i]->name);
1295 i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
1296 wwin->wm_class);
1297 if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
1298 WMSetPopUpButtonSelectedItem(panel->wsP, i);
1299 } else {
1300 WMSetPopUpButtonSelectedItem(panel->wsP, 0);
1303 /* application wide attributes */
1304 if (wwin->main_window != None) {
1305 WApplication *wapp = wApplicationOf(wwin->main_window);
1307 panel->appFrm = WMCreateFrame(panel->win);
1308 WMSetFrameTitle(panel->appFrm, _("Application Wide"));
1309 WMMoveWidget(panel->appFrm, 15, 50);
1310 WMResizeWidget(panel->appFrm, frame_width, 240);
1312 for (i=0; i < 2; i++) {
1313 char *caption = NULL;
1314 int flag = 0;
1316 switch (i) {
1317 case 0:
1318 caption = _("Start Hidden");
1319 flag = WFLAGP(wapp->main_window_desc, start_hidden);
1320 break;
1321 case 1:
1322 caption = _("No Application Icon");
1323 flag = WFLAGP(wapp->main_window_desc, no_appicon);
1324 break;
1326 panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
1327 WMMoveWidget(panel->appChk[i], 10, 20*(i+1));
1328 WMResizeWidget(panel->appChk[i], 205, 20);
1329 WMSetButtonSelected(panel->appChk[i], flag);
1330 WMSetButtonText(panel->appChk[i], caption);
1333 if (WFLAGP(wwin, emulate_appicon)) {
1334 WMSetButtonEnabled(panel->appChk[1], False);
1335 WMSetButtonEnabled(panel->moreChk[6], True);
1336 } else {
1337 WMSetButtonEnabled(panel->appChk[1], True);
1338 WMSetButtonEnabled(panel->moreChk[6], False);
1340 } else {
1341 int tmp;
1343 if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win)
1344 || !wwin->wm_class || !wwin->wm_instance)
1345 tmp = False;
1346 else
1347 tmp = True;
1348 WMSetButtonEnabled(panel->moreChk[6], tmp);
1350 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
1351 panel->appFrm = NULL;
1354 /* if the window is a transient, don't let it have a miniaturize
1355 * button */
1356 if (wWindowFor(wwin->transient_for)!=NULL)
1357 WMSetButtonEnabled(panel->attrChk[3], False);
1358 else
1359 WMSetButtonEnabled(panel->attrChk[3], True);
1362 if (!wwin->wm_class && !wwin->wm_instance) {
1363 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);
1367 WMRealizeWidget(panel->win);
1369 WMMapSubwidgets(panel->win);
1370 WMMapSubwidgets(panel->specFrm);
1371 WMMapSubwidgets(panel->attrFrm);
1372 WMMapSubwidgets(panel->moreFrm);
1373 WMMapSubwidgets(panel->iconFrm);
1374 WMMapSubwidgets(panel->wsFrm);
1375 if (panel->appFrm)
1376 WMMapSubwidgets(panel->appFrm);
1378 WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
1379 changePage(panel->pagePopUp, panel);
1382 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
1383 0, 0, 0);
1384 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
1385 panel->parent = parent;
1386 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1388 WMMapWidget(panel->win);
1390 XSetTransientForHint(dpy, parent, wwin->client_win);
1392 x = wwin->frame_x+wwin->frame->core->width/2;
1393 y = wwin->frame_y+wwin->frame->top_width*2;
1394 if (y + PHEIGHT > scr->scr_height)
1395 y = scr->scr_height - PHEIGHT - 30;
1396 if (x + PWIDTH > scr->scr_width)
1397 x = scr->scr_width - PWIDTH;
1398 panel->frame = wManageInternalWindow(scr, parent, wwin->client_win,
1399 charbuf, x, y, PWIDTH, PHEIGHT);
1401 /* kluge to know who should get the key events */
1402 panel->frame->client_leader = WMWidgetXID(panel->win);
1404 WSETUFLAG(panel->frame, no_closable, 0);
1405 WSETUFLAG(panel->frame, no_close_button, 0);
1406 wWindowUpdateButtonImages(panel->frame);
1407 wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
1408 panel->frame->frame->on_click_right = destroyInspector;
1410 wWindowMap(panel->frame);
1412 showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance,
1413 wwin->wm_class, UPDATE_TEXT_FIELD);
1415 return panel;
1419 void
1420 wShowInspectorForWindow(WWindow *wwin)
1422 if (wwin->flags.inspector_open)
1423 return;
1425 make_keys();
1426 wwin->flags.inspector_open = 1;
1427 wwin->inspector = createInspectorForWindow(wwin);;