Update for 0.52.0. This is a test version, which brings the Appearance
[wmaker-crm.git] / src / winspector.c
blobf3b0c8ce77c636af131aae281feb67d5e0fc00b1
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);
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 value = (WMGetButtonSelected(panel->moreChk[7])!=0) ? Yes : No;
538 insertAttribute(dict, winDic, AFullMaximize, value, &different, flags);
540 /* application wide settings for when */
541 /* the window is the leader, save the attribute with the others */
542 if (panel->inspected->main_window == panel->inspected->client_win) {
544 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
545 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
547 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
548 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
551 PLRemoveDictionaryEntry(dict, key);
552 if (different) {
553 PLInsertDictionaryEntry(dict, key, winDic);
556 PLRelease(key);
557 PLRelease(winDic);
559 different = 0;
561 /* application wide settings */
562 if (panel->inspected->main_window != panel->inspected->client_win
563 && !(flags & UPDATE_DEFAULTS)) {
564 WApplication *wapp;
565 proplist_t appDic;
567 wapp = wApplicationOf(panel->inspected->main_window);
568 if (wapp) {
569 char *iconFile;
571 appDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
573 assert(wapp->main_window_desc->wm_instance!=NULL);
574 assert(wapp->main_window_desc->wm_class!=NULL);
576 strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), ".");
577 strcat(buffer, wwin->wm_class);
578 key = PLMakeString(buffer);
580 iconFile = wDefaultGetIconFile(wwin->screen_ptr,
581 wapp->main_window_desc->wm_instance,
582 wapp->main_window_desc->wm_class,
583 False);
585 if (iconFile && iconFile[0]!=0) {
586 value = PLMakeString(iconFile);
587 insertAttribute(dict, appDic, AIcon, value, &different,
588 flags&~IS_BOOLEAN);
589 PLRelease(value);
592 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
593 insertAttribute(dict, appDic, AStartHidden, value, &different, flags);
595 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
596 insertAttribute(dict, appDic, ANoAppIcon, value, &different, flags);
598 PLRemoveDictionaryEntry(dict, key);
599 if (different) {
600 PLInsertDictionaryEntry(dict, key, appDic);
602 PLRelease(key);
603 PLRelease(appDic);
607 PLSave(dict, YES);
609 /* clean up */
610 PLSetStringCmpHook(StringCompareHook);
614 static void
615 makeAppIconFor(WApplication *wapp)
617 WScreen *scr = wapp->main_window_desc->screen_ptr;
619 if (wapp->app_icon)
620 return;
622 if (!WFLAGP(wapp->main_window_desc, no_appicon))
623 wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
624 else
625 wapp->app_icon = NULL;
627 if (wapp->app_icon) {
628 WIcon *icon = wapp->app_icon->icon;
629 WDock *clip = scr->workspaces[scr->current_workspace]->clip;
630 int x=0, y=0;
632 wapp->app_icon->main_window = wapp->main_window;
634 if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
635 wapp->app_icon->attracted = 1;
636 if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {
637 wapp->app_icon->icon->shadowed = 1;
638 wapp->app_icon->icon->force_paint = 1;
640 wDockAttachIcon(clip, wapp->app_icon, x, y);
641 } else {
642 PlaceIcon(scr, &x, &y);
643 wAppIconMove(wapp->app_icon, x, y);
645 if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
646 XMapWindow(dpy, icon->core->window);
648 if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted)
649 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
654 static void
655 removeAppIconFor(WApplication *wapp)
657 if (!wapp->app_icon)
658 return;
660 if (wapp->app_icon->docked &&
661 (!wapp->app_icon->attracted || wapp->app_icon->dock->keep_attracted)) {
662 wapp->app_icon->running = 0;
663 /* since we keep it, we don't care if it was attracted or not */
664 wapp->app_icon->attracted = 0;
665 wapp->app_icon->icon->shadowed = 0;
666 wapp->app_icon->main_window = None;
667 wapp->app_icon->pid = 0;
668 wapp->app_icon->icon->owner = NULL;
669 wapp->app_icon->icon->icon_win = None;
670 wapp->app_icon->icon->force_paint = 1;
671 wAppIconPaint(wapp->app_icon);
672 } else if (wapp->app_icon->docked) {
673 wapp->app_icon->running = 0;
674 wDockDetach(wapp->app_icon->dock, wapp->app_icon);
675 } else {
676 wAppIconDestroy(wapp->app_icon);
678 wapp->app_icon = NULL;
679 if (wPreferences.auto_arrange_icons)
680 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
684 static void
685 applySettings(WMButton *button, InspectorPanel *panel)
687 WWindow *wwin = panel->inspected;
688 WApplication *wapp = wApplicationOf(wwin->main_window);
689 int floating, sunken, skip_window_list;
690 int old_omnipresent;
691 int old_no_bind_keys;
692 int old_no_bind_mouse;
694 old_omnipresent = WFLAGP(wwin, omnipresent);
695 old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
696 old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse);
698 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
700 WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0]));
701 WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1]));
702 WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2]));
703 WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3]));
704 floating = WMGetButtonSelected(panel->attrChk[4]);
705 sunken = WMGetButtonSelected(panel->attrChk[5]);
706 WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[6]));
707 WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[7]));
708 WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[8]));
709 skip_window_list = WMGetButtonSelected(panel->attrChk[9]);
711 WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[0]));
712 WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[1]));
713 WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[2]));
714 WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[3]));
715 WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4]));
716 WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[5]));
717 WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[6]));
718 WSETUFLAG(wwin, full_maximize, WMGetButtonSelected(panel->moreChk[7]));
719 WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
721 if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
722 wUnshadeWindow(wwin);
724 WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));
726 if (floating) {
727 if (!WFLAGP(wwin, floating))
728 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
729 } else if (sunken) {
730 if (!WFLAGP(wwin, sunken))
731 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
732 } else {
733 if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
734 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
737 WSETUFLAG(wwin, sunken, sunken);
738 WSETUFLAG(wwin, floating, floating);
739 wwin->flags.omnipresent = 0;
741 if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
742 WSETUFLAG(wwin, skip_window_list, skip_window_list);
743 UpdateSwitchMenu(wwin->screen_ptr, wwin,
744 skip_window_list ? ACTION_REMOVE : ACTION_ADD);
745 } else {
746 if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
747 UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
751 if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
752 if (WFLAGP(wwin, no_bind_keys)) {
753 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
754 } else {
755 wWindowSetKeyGrabs(wwin);
759 if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
760 wWindowResetMouseGrabs(wwin);
763 wwin->frame->flags.need_texture_change = 1;
764 wWindowConfigureBorders(wwin);
765 wFrameWindowPaint(wwin->frame);
768 * Can't apply emulate_appicon because it will probably cause problems.
771 if (wapp) {
772 /* do application wide stuff */
773 WSETUFLAG(wapp->main_window_desc, start_hidden,
774 WMGetButtonSelected(panel->appChk[0]));
776 WSETUFLAG(wapp->main_window_desc, no_appicon,
777 WMGetButtonSelected(panel->appChk[1]));
779 if (WFLAGP(wapp->main_window_desc, no_appicon))
780 removeAppIconFor(wapp);
781 else
782 makeAppIconFor(wapp);
784 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
785 char *file = WMGetTextFieldText(panel->fileText);
787 if (file[0] == 0) {
788 free(file);
789 file = NULL;
791 wIconChangeImageFile(wapp->app_icon->icon, file);
792 if (file)
793 free(file);
794 wAppIconPaint(wapp->app_icon);
800 static void
801 revertSettings(WMButton *button, InspectorPanel *panel)
803 WWindow *wwin = panel->inspected;
804 WApplication *wapp = wApplicationOf(wwin->main_window);
805 int i, n;
806 char *wm_instance = NULL;
807 char *wm_class = NULL;
808 int workspace, level;
810 if (WMGetButtonSelected(panel->instRb) != 0)
811 wm_instance = wwin->wm_instance;
812 else if (WMGetButtonSelected(panel->clsRb) != 0)
813 wm_class = wwin->wm_class;
814 else if (WMGetButtonSelected(panel->bothRb) != 0) {
815 wm_instance = wwin->wm_instance;
816 wm_class = wwin->wm_class;
818 memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
819 memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
820 memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
822 wWindowSetupInitialAttributes(wwin, &level, &workspace);
824 for (i=0; i < 10; i++) {
825 int flag = 0;
827 switch (i) {
828 case 0:
829 flag = WFLAGP(wwin, no_titlebar);
830 break;
831 case 1:
832 flag = WFLAGP(wwin, no_resizebar);
833 break;
834 case 2:
835 flag = WFLAGP(wwin, no_close_button);
836 break;
837 case 3:
838 flag = WFLAGP(wwin, no_miniaturize_button);
839 break;
840 case 4:
841 flag = WFLAGP(wwin, floating);
842 break;
843 case 5:
844 flag = WFLAGP(wwin, sunken);
845 break;
846 case 6:
847 flag = WFLAGP(wwin, omnipresent);
848 break;
849 case 7:
850 flag = WFLAGP(wwin, start_miniaturized);
851 break;
852 case 8:
853 flag = WFLAGP(wwin, start_maximized!=0);
854 break;
855 case 9:
856 flag = WFLAGP(wwin, skip_window_list);
857 break;
859 WMSetButtonSelected(panel->attrChk[i], flag);
861 for (i=0; i < 8; i++) {
862 int flag = 0;
864 switch (i) {
865 case 0:
866 flag = WFLAGP(wwin, no_hide_others);
867 break;
868 case 1:
869 flag = WFLAGP(wwin, no_bind_keys);
870 break;
871 case 2:
872 flag = WFLAGP(wwin, no_bind_mouse);
873 break;
874 case 3:
875 flag = WFLAGP(wwin, dont_move_off);
876 break;
877 case 4:
878 flag = WFLAGP(wwin, no_focusable);
879 break;
880 case 5:
881 flag = WFLAGP(wwin, dont_save_session);
882 break;
883 case 6:
884 flag = WFLAGP(wwin, emulate_appicon);
885 break;
886 case 7:
887 flag = WFLAGP(wwin, full_maximize);
888 break;
890 WMSetButtonSelected(panel->moreChk[i], flag);
892 if (panel->appFrm && wapp) {
893 for (i=0; i < 2; i++) {
894 int flag = 0;
896 switch (i) {
897 case 0:
898 flag = WFLAGP(wapp->main_window_desc, start_hidden);
899 break;
900 case 1:
901 flag = WFLAGP(wapp->main_window_desc, no_appicon);
902 break;
904 WMSetButtonSelected(panel->appChk[i], flag);
907 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
909 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
910 REVERT_TO_DEFAULT);
912 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
914 if (n >= 0 && n <= wwin->screen_ptr->workspace_count) {
915 WMPerformButtonClick(panel->setRb);
916 WMSetTextFieldText(panel->wsText, wwin->screen_ptr->workspaces[n]->name);
917 } else {
918 WMPerformButtonClick(panel->curRb);
923 static void
924 chooseIconCallback(WMWidget *self, void *clientData)
926 char *file;
927 InspectorPanel *panel = (InspectorPanel*)clientData;
928 int result;
930 panel->choosingIcon = 1;
932 WMSetButtonEnabled(panel->browseIconBtn, False);
934 result = wIconChooserDialog(panel->frame->screen_ptr, &file,
935 panel->inspected->wm_instance,
936 panel->inspected->wm_class);
938 panel->choosingIcon = 0;
940 if (!panel->destroyed) { /* kluge */
941 if (result) {
942 WMSetTextFieldText(panel->fileText, file);
943 showIconFor(WMWidgetScreen(self), panel, NULL, NULL,
944 USE_TEXT_FIELD);
945 free(file);
947 WMSetButtonEnabled(panel->browseIconBtn, True);
948 } else {
949 freeInspector(panel);
954 static void
955 textEditedObserver(void *observerData, WMNotification *notification)
957 InspectorPanel *panel = (InspectorPanel*)observerData;
959 if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement)
960 return;
962 if (WMGetNotificationObject(notification) == panel->fileText) {
963 showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL,
964 USE_TEXT_FIELD);
966 WMPerformButtonClick(panel->updateIconBtn);
968 } else
969 WMPerformButtonClick(panel->setRb);
973 static void
974 selectSpecification(WMWidget *bPtr, void *data)
976 InspectorPanel *panel = (InspectorPanel*)data;
978 if (bPtr == panel->defaultRb) {
979 WMSetButtonEnabled(panel->applyBtn, False);
980 } else {
981 WMSetButtonEnabled(panel->applyBtn, True);
986 static InspectorPanel*
987 createInspectorForWindow(WWindow *wwin)
989 WScreen *scr = wwin->screen_ptr;
990 InspectorPanel *panel;
991 Window parent;
992 char charbuf[128];
993 int i;
994 int x, y;
995 int btn_width, frame_width;
996 #ifdef wrong_behaviour
997 WMPixmap *pixmap;
998 #endif
999 panel = wmalloc(sizeof(InspectorPanel));
1000 memset(panel, 0, sizeof(InspectorPanel));
1002 panel->destroyed = 0;
1005 panel->inspected = wwin;
1007 panel->nextPtr = panelList;
1008 panelList = panel;
1011 sprintf(charbuf, "Inspecting %s.%s",
1012 wwin->wm_instance ? wwin->wm_instance : "?",
1013 wwin->wm_class ? wwin->wm_class : "?");
1015 panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
1016 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1019 /**** create common stuff ****/
1021 /* command buttons */
1022 /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
1023 btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
1024 panel->saveBtn = WMCreateCommandButton(panel->win);
1025 WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);
1026 WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, 310);
1027 WMSetButtonText(panel->saveBtn, _("Save"));
1028 WMResizeWidget(panel->saveBtn, btn_width, 28);
1029 if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance))
1030 WMSetButtonEnabled(panel->saveBtn, False);
1032 panel->applyBtn = WMCreateCommandButton(panel->win);
1033 WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);
1034 WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);
1035 WMSetButtonText(panel->applyBtn, _("Apply"));
1036 WMResizeWidget(panel->applyBtn, btn_width, 28);
1038 panel->revertBtn = WMCreateCommandButton(panel->win);
1039 WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);
1040 WMMoveWidget(panel->revertBtn, 15, 310);
1041 WMSetButtonText(panel->revertBtn, _("Reload"));
1042 WMResizeWidget(panel->revertBtn, btn_width, 28);
1044 /* page selection popup button */
1045 panel->pagePopUp = WMCreatePopUpButton(panel->win);
1046 WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);
1047 WMMoveWidget(panel->pagePopUp, 25, 15);
1048 WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);
1050 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));
1051 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));
1052 WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));
1053 WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));
1054 WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));
1056 /**** window spec ****/
1057 frame_width = PWIDTH - (2 * 15);
1059 panel->specFrm = WMCreateFrame(panel->win);
1060 WMSetFrameTitle(panel->specFrm, _("Window Specification"));
1061 WMMoveWidget(panel->specFrm, 15, 65);
1062 WMResizeWidget(panel->specFrm, frame_width, 105);
1065 panel->defaultRb = WMCreateRadioButton(panel->specFrm);
1066 WMMoveWidget(panel->defaultRb, 10, 78);
1067 WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);
1068 WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));
1069 WMSetButtonSelected(panel->defaultRb, False);
1070 WMSetButtonAction(panel->defaultRb, selectSpecification, panel);
1073 if (wwin->wm_class && wwin->wm_instance) {
1074 sprintf(charbuf, "%s.%s", wwin->wm_instance, wwin->wm_class);
1075 panel->bothRb = WMCreateRadioButton(panel->specFrm);
1076 WMMoveWidget(panel->bothRb, 10, 18);
1077 WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);
1078 WMSetButtonText(panel->bothRb, charbuf);
1079 WMSetButtonSelected(panel->bothRb, True);
1080 WMGroupButtons(panel->defaultRb, panel->bothRb);
1082 WMSetButtonAction(panel->bothRb, selectSpecification, panel);
1085 if (wwin->wm_instance) {
1086 panel->instRb = WMCreateRadioButton(panel->specFrm);
1087 WMMoveWidget(panel->instRb, 10, 38);
1088 WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);
1089 WMSetButtonText(panel->instRb, wwin->wm_instance);
1090 WMSetButtonSelected(panel->instRb, False);
1091 WMGroupButtons(panel->defaultRb, panel->instRb);
1093 WMSetButtonAction(panel->instRb, selectSpecification, panel);
1096 if (wwin->wm_class) {
1097 panel->clsRb = WMCreateRadioButton(panel->specFrm);
1098 WMMoveWidget(panel->clsRb, 10, 58);
1099 WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);
1100 WMSetButtonText(panel->clsRb, wwin->wm_class);
1101 WMSetButtonSelected(panel->clsRb, False);
1102 WMGroupButtons(panel->defaultRb, panel->clsRb);
1104 WMSetButtonAction(panel->clsRb, selectSpecification, panel);
1107 panel->specLbl = WMCreateLabel(panel->win);
1108 WMMoveWidget(panel->specLbl, 15, 170);
1109 WMResizeWidget(panel->specLbl, frame_width, 100);
1110 WMSetLabelText(panel->specLbl,
1111 _("The configuration will apply to all\n"
1112 "windows that have their WM_CLASS property"
1113 " set to the above selected\nname, when saved."));
1114 WMSetLabelTextAlignment(panel->specLbl, WACenter);
1116 /**** attributes ****/
1117 panel->attrFrm = WMCreateFrame(panel->win);
1118 WMSetFrameTitle(panel->attrFrm, _("Attributes"));
1119 WMMoveWidget(panel->attrFrm, 15, 45);
1120 WMResizeWidget(panel->attrFrm, frame_width, 250);
1122 for (i=0; i < 10; i++) {
1123 char *caption = NULL;
1124 int flag = 0;
1126 switch (i) {
1127 case 0:
1128 caption = _("Disable Titlebar");
1129 flag = WFLAGP(wwin, no_titlebar);
1130 break;
1131 case 1:
1132 caption = _("Disable Resizebar");
1133 flag = WFLAGP(wwin, no_resizebar);
1134 break;
1135 case 2:
1136 caption = _("Disable Close Button");
1137 flag = WFLAGP(wwin, no_close_button);
1138 break;
1139 case 3:
1140 caption = _("Disable Miniaturize Button");
1141 flag = WFLAGP(wwin, no_miniaturize_button);
1142 break;
1143 case 4:
1144 caption = _("Keep on Top / Floating");
1145 flag = WFLAGP(wwin, floating);
1146 break;
1147 case 5:
1148 caption = _("Keep at Bottom / Sunken");
1149 flag = WFLAGP(wwin, sunken);
1150 break;
1151 case 6:
1152 caption = _("Omnipresent");
1153 flag = WFLAGP(wwin, omnipresent);
1154 break;
1155 case 7:
1156 caption = _("Start Miniaturized");
1157 flag = WFLAGP(wwin, start_miniaturized);
1158 break;
1159 case 8:
1160 caption = _("Start Maximized");
1161 flag = WFLAGP(wwin, start_maximized!=0);
1162 break;
1163 case 9:
1164 caption = _("Skip Window List");
1165 flag = WFLAGP(wwin, skip_window_list);
1166 break;
1168 panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
1169 WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));
1170 WMResizeWidget(panel->attrChk[i], frame_width-15, 20);
1171 WMSetButtonSelected(panel->attrChk[i], flag);
1172 WMSetButtonText(panel->attrChk[i], caption);
1176 /**** more attributes ****/
1177 panel->moreFrm = WMCreateFrame(panel->win);
1178 WMSetFrameTitle(panel->moreFrm, _("Advanced"));
1179 WMMoveWidget(panel->moreFrm, 15, 45);
1180 WMResizeWidget(panel->moreFrm, frame_width, 250);
1182 for (i=0; i < 8; i++) {
1183 char *caption = NULL;
1184 int flag = 0;
1186 switch (i) {
1187 case 0:
1188 caption = _("Ignore HideOthers");
1189 flag = WFLAGP(wwin, no_hide_others);
1190 break;
1191 case 1:
1192 caption = _("Don't Bind Keyboard Shortcuts");
1193 flag = WFLAGP(wwin, no_bind_keys);
1194 break;
1195 case 2:
1196 caption = _("Don't Bind Mouse Clicks");
1197 flag = WFLAGP(wwin, no_bind_mouse);
1198 break;
1199 case 3:
1200 caption = _("Keep Inside Screen");
1201 flag = WFLAGP(wwin, dont_move_off);
1202 break;
1203 case 4:
1204 caption = _("Don't Let It Take Focus");
1205 flag = WFLAGP(wwin, no_focusable);
1206 break;
1207 case 5:
1208 caption = _("Don't Save Session");
1209 flag = WFLAGP(wwin, dont_save_session);
1210 break;
1211 case 6:
1212 caption = _("Emulate Application Icon");
1213 flag = WFLAGP(wwin, emulate_appicon);
1214 break;
1215 case 7:
1216 caption = _("Full Screen Maximization");
1217 flag = WFLAGP(wwin, full_maximize);
1218 break;
1220 panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
1221 WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));
1222 WMResizeWidget(panel->moreChk[i], frame_width-15, 20);
1223 WMSetButtonSelected(panel->moreChk[i], flag);
1224 WMSetButtonText(panel->moreChk[i], caption);
1227 panel->moreLbl = WMCreateLabel(panel->moreFrm);
1228 WMResizeWidget(panel->moreLbl, frame_width - (2 * 5), 60);
1229 WMMoveWidget(panel->moreLbl, 5, 180);
1230 WMSetLabelText(panel->moreLbl,
1231 _("Enable the \"Don't bind...\" options to allow the "
1232 "application to receive all mouse or keyboard events."));
1234 /* miniwindow/workspace */
1235 panel->iconFrm = WMCreateFrame(panel->win);
1236 WMMoveWidget(panel->iconFrm, 15, 50);
1237 WMResizeWidget(panel->iconFrm, PWIDTH - (2 * 15), 170);
1238 WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
1240 panel->iconLbl = WMCreateLabel(panel->iconFrm);
1241 WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
1242 WMResizeWidget(panel->iconLbl, 64, 64);
1243 WMSetLabelRelief(panel->iconLbl, WRRaised);
1244 WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
1246 panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
1247 WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
1248 WMMoveWidget(panel->browseIconBtn, 22, 30);
1249 WMResizeWidget(panel->browseIconBtn, 100, 26);
1250 WMSetButtonText(panel->browseIconBtn, _("Browse..."));
1252 #if 0
1253 panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
1254 WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
1255 WMMoveWidget(panel->updateIconBtn, 22, 65);
1256 WMResizeWidget(panel->updateIconBtn, 100, 26);
1257 WMSetButtonText(panel->updateIconBtn, _("Update"));
1258 #endif
1259 #ifdef wrong_behaviour
1260 WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
1261 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
1262 WMSetButtonImage(panel->updateIconBtn, pixmap);
1263 WMReleasePixmap(pixmap);
1264 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
1265 WMSetButtonAltImage(panel->updateIconBtn, pixmap);
1266 WMReleasePixmap(pixmap);
1267 #endif
1269 panel->fileLbl = WMCreateLabel(panel->iconFrm);
1270 WMMoveWidget(panel->fileLbl, 20, 95);
1271 WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
1272 WMSetLabelText(panel->fileLbl, _("Icon File Name:"));
1274 panel->fileText = WMCreateTextField(panel->iconFrm);
1275 WMMoveWidget(panel->fileText, 20, 115);
1276 WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
1277 WMSetTextFieldText(panel->fileText, NULL);
1278 WMAddNotificationObserver(textEditedObserver, panel,
1279 WMTextDidEndEditingNotification,
1280 panel->fileText);
1281 panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
1282 WMMoveWidget(panel->alwChk, 20, 140);
1283 WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
1284 WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
1285 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
1288 panel->wsFrm = WMCreateFrame(panel->win);
1289 WMMoveWidget(panel->wsFrm, 15, 225);
1290 WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);
1291 WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));
1293 panel->curRb = WMCreateRadioButton(panel->wsFrm);
1294 WMMoveWidget(panel->curRb, 10, 15);
1295 WMResizeWidget(panel->curRb, frame_width - (2 * 10), 20);
1296 WMSetButtonText(panel->curRb, _("Nowhere in particular"));
1299 panel->setRb = WMCreateRadioButton(panel->wsFrm);
1300 WMMoveWidget(panel->setRb, 10, 40);
1301 WMResizeWidget(panel->setRb, 25, 20);
1302 WMGroupButtons(panel->curRb, panel->setRb);
1303 WMSetButtonText(panel->setRb, NULL);
1305 panel->wsText = WMCreateTextField(panel->wsFrm);
1306 WMMoveWidget(panel->wsText, 30, 40);
1307 WMResizeWidget(panel->wsText, PWIDTH - (2 * 15) - 25 - 10 - (2 * 5), 20);
1308 WMAddNotificationObserver(textEditedObserver, panel,
1309 WMTextDidEndEditingNotification,
1310 panel->wsText);
1313 i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
1314 wwin->wm_class);
1315 if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
1316 WMSetButtonSelected(panel->curRb, False);
1317 WMSetButtonSelected(panel->setRb, True);
1318 WMSetTextFieldText(panel->wsText,
1319 wwin->screen_ptr->workspaces[i]->name);
1320 } else {
1321 WMSetButtonSelected(panel->curRb, True);
1322 WMSetButtonSelected(panel->setRb, False);
1325 /* application wide attributes */
1326 if (wwin->main_window != None) {
1327 WApplication *wapp = wApplicationOf(wwin->main_window);
1329 panel->appFrm = WMCreateFrame(panel->win);
1330 WMSetFrameTitle(panel->appFrm, _("Application Wide"));
1331 WMMoveWidget(panel->appFrm, 15, 50);
1332 WMResizeWidget(panel->appFrm, frame_width, 240);
1334 for (i=0; i < 2; i++) {
1335 char *caption = NULL;
1336 int flag = 0;
1338 switch (i) {
1339 case 0:
1340 caption = _("Start Hidden");
1341 flag = WFLAGP(wapp->main_window_desc, start_hidden);
1342 break;
1343 case 1:
1344 caption = _("No Application Icon");
1345 flag = WFLAGP(wapp->main_window_desc, no_appicon);
1346 break;
1348 panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
1349 WMMoveWidget(panel->appChk[i], 10, 20*(i+1));
1350 WMResizeWidget(panel->appChk[i], 205, 20);
1351 WMSetButtonSelected(panel->appChk[i], flag);
1352 WMSetButtonText(panel->appChk[i], caption);
1355 if (WFLAGP(wwin, emulate_appicon)) {
1356 WMSetButtonEnabled(panel->appChk[1], False);
1357 WMSetButtonEnabled(panel->moreChk[6], True);
1358 } else {
1359 WMSetButtonEnabled(panel->appChk[1], True);
1360 WMSetButtonEnabled(panel->moreChk[6], False);
1362 } else {
1363 int tmp;
1365 if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win)
1366 || !wwin->wm_class || !wwin->wm_instance)
1367 tmp = False;
1368 else
1369 tmp = True;
1370 WMSetButtonEnabled(panel->moreChk[6], tmp);
1372 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
1373 panel->appFrm = NULL;
1376 /* if the window is a transient, don't let it have a miniaturize
1377 * button */
1378 if (wWindowFor(wwin->transient_for)!=NULL)
1379 WMSetButtonEnabled(panel->attrChk[3], False);
1380 else
1381 WMSetButtonEnabled(panel->attrChk[3], True);
1384 if (!wwin->wm_class && !wwin->wm_instance) {
1385 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);
1389 WMRealizeWidget(panel->win);
1391 WMMapSubwidgets(panel->win);
1392 WMMapSubwidgets(panel->specFrm);
1393 WMMapSubwidgets(panel->attrFrm);
1394 WMMapSubwidgets(panel->moreFrm);
1395 WMMapSubwidgets(panel->iconFrm);
1396 WMMapSubwidgets(panel->wsFrm);
1397 if (panel->appFrm)
1398 WMMapSubwidgets(panel->appFrm);
1400 WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
1401 changePage(panel->pagePopUp, panel);
1404 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
1405 0, 0, 0);
1406 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
1407 panel->parent = parent;
1408 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1410 WMMapWidget(panel->win);
1412 XSetTransientForHint(dpy, parent, wwin->client_win);
1414 x = wwin->frame_x+wwin->frame->core->width/2;
1415 y = wwin->frame_y+wwin->frame->top_width*2;
1416 if (y + PHEIGHT > scr->scr_height)
1417 y = scr->scr_height - PHEIGHT - 30;
1418 if (x + PWIDTH > scr->scr_width)
1419 x = scr->scr_width - PWIDTH;
1420 panel->frame = wManageInternalWindow(scr, parent, wwin->client_win,
1421 charbuf, x, y, PWIDTH, PHEIGHT);
1423 /* kluge to know who should get the key events */
1424 panel->frame->client_leader = WMWidgetXID(panel->win);
1426 WSETUFLAG(panel->frame, no_closable, 0);
1427 WSETUFLAG(panel->frame, no_close_button, 0);
1428 wWindowUpdateButtonImages(panel->frame);
1429 wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
1430 panel->frame->frame->on_click_right = destroyInspector;
1432 wWindowMap(panel->frame);
1434 showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance,
1435 wwin->wm_class, UPDATE_TEXT_FIELD);
1437 return panel;
1441 void
1442 wShowInspectorForWindow(WWindow *wwin)
1444 if (wwin->flags.inspector_open)
1445 return;
1447 make_keys();
1448 wwin->flags.inspector_open = 1;
1449 wwin->inspector = createInspectorForWindow(wwin);;