Removed titlebar drop shadow code and add plugin to draw text on titlebars.
[wmaker-crm.git] / src / winspector.c
bloba3ce7b5fd40b3a1400471bff5bc8a6035082a404
1 /* winspector.c - window attribute inspector
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
24 #include "wconfig.h"
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
32 #include "WindowMaker.h"
33 #include "screen.h"
34 #include "wcore.h"
35 #include "framewin.h"
36 #include "window.h"
37 #include "workspace.h"
38 #include "funcs.h"
39 #include "defaults.h"
40 #include "dialog.h"
41 #include "icon.h"
42 #include "stacking.h"
43 #include "application.h"
44 #include "appicon.h"
45 #include "actions.h"
46 #include "winspector.h"
47 #include "dock.h"
49 #include <proplist.h>
51 extern WDDomain *WDWindowAttributes;
53 static InspectorPanel *panelList=NULL;
55 extern WPreferences wPreferences;
57 static proplist_t ANoTitlebar = NULL;
58 static proplist_t ANoResizebar;
59 static proplist_t ANoMiniaturizeButton;
60 static proplist_t ANoCloseButton;
61 static proplist_t ANoHideOthers;
62 static proplist_t ANoMouseBindings;
63 static proplist_t ANoKeyBindings;
64 static proplist_t ANoAppIcon;
65 static proplist_t AKeepOnTop;
66 static proplist_t AKeepOnBottom;
67 static proplist_t AOmnipresent;
68 static proplist_t ASkipWindowList;
69 static proplist_t AKeepInsideScreen;
70 static proplist_t AUnfocusable;
71 static proplist_t AAlwaysUserIcon;
72 static proplist_t AStartMiniaturized;
73 static proplist_t AStartMaximized;
74 static proplist_t ADontSaveSession;
75 static proplist_t AEmulateAppIcon;
76 static proplist_t AFullMaximize;
77 #ifdef XKB_BUTTON_HINT
78 static proplist_t ANoLanguageButton;
79 #endif
81 static proplist_t AStartWorkspace;
83 static proplist_t AIcon;
85 /* application wide options */
86 static proplist_t AStartHidden;
89 static proplist_t AnyWindow;
90 static proplist_t EmptyString;
91 static proplist_t Yes, No;
94 #define PWIDTH 270
95 #define PHEIGHT 350
98 static void applySettings(WMButton *button, InspectorPanel *panel);
100 static void
101 make_keys()
103 if (ANoTitlebar!=NULL)
104 return;
106 AIcon = PLMakeString("Icon");
107 ANoTitlebar = PLMakeString("NoTitlebar");
108 ANoResizebar = PLMakeString("NoResizebar");
109 ANoMiniaturizeButton = PLMakeString("NoMiniaturizeButton");
110 ANoCloseButton = PLMakeString("NoCloseButton");
111 ANoHideOthers = PLMakeString("NoHideOthers");
112 ANoMouseBindings = PLMakeString("NoMouseBindings");
113 ANoKeyBindings = PLMakeString("NoKeyBindings");
114 ANoAppIcon = PLMakeString("NoAppIcon");
115 AKeepOnTop = PLMakeString("KeepOnTop");
116 AKeepOnBottom = PLMakeString("KeepOnBottom");
117 AOmnipresent = PLMakeString("Omnipresent");
118 ASkipWindowList = PLMakeString("SkipWindowList");
119 AKeepInsideScreen = PLMakeString("KeepInsideScreen");
120 AUnfocusable = PLMakeString("Unfocusable");
121 AAlwaysUserIcon = PLMakeString("AlwaysUserIcon");
122 AStartMiniaturized = PLMakeString("StartMiniaturized");
123 AStartMaximized = PLMakeString("StartMaximized");
124 AStartHidden = PLMakeString("StartHidden");
125 ADontSaveSession = PLMakeString("DontSaveSession");
126 AEmulateAppIcon = PLMakeString("EmulateAppIcon");
127 AFullMaximize = PLMakeString("FullMaximize");
128 #ifdef XKB_BUTTON_HINT
129 ANoLanguageButton = PLMakeString("NoLanguageButton");
130 #endif
132 AStartWorkspace = PLMakeString("StartWorkspace");
134 AnyWindow = PLMakeString("*");
135 EmptyString = PLMakeString("");
136 Yes = PLMakeString("Yes");
137 No = PLMakeString("No");
142 static void
143 freeInspector(InspectorPanel *panel)
145 panel->destroyed = 1;
146 if (panel->choosingIcon)
147 return;
149 WMDestroyWidget(panel->win);
151 XDestroyWindow(dpy, panel->parent);
153 free(panel);
157 static void
158 destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
160 InspectorPanel *panel;
161 InspectorPanel *tmp;
163 panel = panelList;
164 while (panel->frame!=data)
165 panel = panel->nextPtr;
167 if (panelList == panel)
168 panelList = panel->nextPtr;
169 else {
170 tmp = panelList;
171 while (tmp->nextPtr!=panel) {
172 tmp = tmp->nextPtr;
174 tmp->nextPtr = panel->nextPtr;
176 panel->inspected->flags.inspector_open = 0;
177 panel->inspected->inspector = NULL;
179 WMRemoveNotificationObserver(panel);
181 wWindowUnmap(panel->frame);
182 wUnmanageWindow(panel->frame, True, False);
184 freeInspector(panel);
189 void
190 wDestroyInspectorPanels()
192 InspectorPanel *panel;
194 while (panelList != NULL) {
195 panel = panelList;
196 panelList = panelList->nextPtr;
197 wUnmanageWindow(panel->frame, False, False);
198 WMDestroyWidget(panel->win);
200 panel->inspected->flags.inspector_open = 0;
201 panel->inspected->inspector = NULL;
203 free(panel);
208 static void
209 changePage(WMPopUpButton *bPtr, InspectorPanel *panel)
211 int page;
213 page = WMGetPopUpButtonSelectedItem(bPtr);
215 if (page == 0) {
216 WMMapWidget(panel->specFrm);
217 WMMapWidget(panel->specLbl);
218 } else if (page == 1) {
219 WMMapWidget(panel->attrFrm);
220 } else if (page == 2) {
221 WMMapWidget(panel->moreFrm);
222 } else if (page == 3) {
223 WMMapWidget(panel->iconFrm);
224 WMMapWidget(panel->wsFrm);
225 } else {
226 WMMapWidget(panel->appFrm);
229 if (page != 0) {
230 WMUnmapWidget(panel->specFrm);
231 WMUnmapWidget(panel->specLbl);
233 if (page != 1)
234 WMUnmapWidget(panel->attrFrm);
235 if (page != 2)
236 WMUnmapWidget(panel->moreFrm);
237 if (page != 3) {
238 WMUnmapWidget(panel->iconFrm);
239 WMUnmapWidget(panel->wsFrm);
241 if (page != 4 && panel->appFrm)
242 WMUnmapWidget(panel->appFrm);
246 #define USE_TEXT_FIELD 1
247 #define UPDATE_TEXT_FIELD 2
248 #define REVERT_TO_DEFAULT 4
251 static int
252 showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
253 char *wm_instance, char *wm_class, int flags)
255 WMPixmap *pixmap = (WMPixmap*) NULL;
256 char *file=NULL, *path=NULL;
257 char *db_icon=NULL;
259 if ((flags & USE_TEXT_FIELD) != 0) {
260 file = WMGetTextFieldText(panel->fileText);
261 if (file && file[0] == 0) {
262 free(file);
263 file = NULL;
265 } else {
266 db_icon = wDefaultGetIconFile(panel->inspected->screen_ptr,
267 wm_instance, wm_class, False);
268 if(db_icon != NULL)
269 file = wstrdup(db_icon);
271 if (db_icon!=NULL && (flags & REVERT_TO_DEFAULT)!=0) {
272 if (file)
273 file = wstrdup(db_icon);
274 flags |= UPDATE_TEXT_FIELD;
277 if ((flags & UPDATE_TEXT_FIELD) != 0) {
278 WMSetTextFieldText(panel->fileText, file);
281 if (file) {
282 path = FindImage(wPreferences.icon_path, file);
284 if (!path) {
285 char *buf;
287 buf = wmalloc(strlen(file)+80);
288 sprintf(buf, _("Could not find icon \"%s\" specified for this window"),
289 file);
290 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
291 _("OK"), NULL, NULL);
292 free(buf);
293 free(file);
294 return -1;
297 pixmap = WMCreatePixmapFromFile(scrPtr, path);
298 free(path);
300 if (!pixmap) {
301 char *buf;
303 buf = wmalloc(strlen(file)+80);
304 sprintf(buf, _("Could not open specified icon \"%s\":%s"),
305 file, RMessageForError(RErrorCode));
306 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
307 _("OK"), NULL, NULL);
308 free(buf);
309 free(file);
310 return -1;
312 free(file);
315 WMSetLabelImage(panel->iconLbl, pixmap);
316 if (pixmap)
317 WMReleasePixmap(pixmap);
319 return 0;
322 #if 0
323 static void
324 updateIcon(WMButton *button, InspectorPanel *panel)
326 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
328 #endif
330 static int
331 getBool(proplist_t value)
333 char *val;
335 if (!PLIsString(value)) {
336 return 0;
338 if (!(val = PLGetString(value))) {
339 return 0;
342 if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T'
343 || val[0]=='t' || val[0]=='1'))
344 || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) {
346 return 1;
347 } else if ((val[1]=='\0'
348 && (val[0]=='n' || val[0]=='N' || val[0]=='F'
349 || val[0]=='f' || val[0]=='0'))
350 || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) {
352 return 0;
353 } else {
354 wwarning(_("can't convert \"%s\" to boolean"), val);
355 return 0;
360 #define UPDATE_DEFAULTS 1
361 #define IS_BOOLEAN 2
365 * Will insert the attribute = value; pair in window's list,
366 * if it's different from the defaults.
367 * Defaults means either defaults database, or attributes saved
368 * for the default window "*". This is to let one revert options that are
369 * global because they were saved for all windows ("*").
374 static void
375 insertAttribute(proplist_t dict, proplist_t window, proplist_t attr,
376 proplist_t value, int *modified, int flags)
378 proplist_t def_win, def_value=NULL;
379 int update = 0;
381 if (!(flags & UPDATE_DEFAULTS) && dict) {
382 if ((def_win = PLGetDictionaryEntry(dict, AnyWindow)) != NULL) {
383 def_value = PLGetDictionaryEntry(def_win, attr);
387 /* If we could not find defaults in database, fall to hardcoded values.
388 * Also this is true if we save defaults for all windows
390 if (!def_value)
391 def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
393 if ((flags & IS_BOOLEAN))
394 update = (getBool(value) != getBool(def_value));
395 else {
396 update = !PLIsEqual(value, def_value);
399 if (update) {
400 PLInsertDictionaryEntry(window, attr, value);
401 *modified = 1;
406 static void
407 saveSettings(WMButton *button, InspectorPanel *panel)
409 WWindow *wwin = panel->inspected;
410 WDDomain *db = WDWindowAttributes;
411 proplist_t dict = db->dictionary;
412 proplist_t winDic, value, key;
413 char buffer[256], *icon_file;
414 int flags = 0;
415 int different = 0;
417 /* Save will apply the changes and save them */
418 applySettings(panel->applyBtn, panel);
420 if (WMGetButtonSelected(panel->instRb) != 0)
421 key = PLMakeString(wwin->wm_instance);
422 else if (WMGetButtonSelected(panel->clsRb) != 0)
423 key = PLMakeString(wwin->wm_class);
424 else if (WMGetButtonSelected(panel->bothRb) != 0) {
425 strcat(strcat(strcpy(buffer, wwin->wm_instance), "."), wwin->wm_class);
426 key = PLMakeString(buffer);
428 else if (WMGetButtonSelected(panel->defaultRb) != 0) {
429 key = PLRetain(AnyWindow);
430 flags = UPDATE_DEFAULTS;
432 else
433 key = NULL;
435 if (!key)
436 return;
438 if (!dict) {
439 dict = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
440 if (dict) {
441 db->dictionary = dict;
442 value = PLMakeString(db->path);
443 PLSetFilename(dict, value);
444 PLRelease(value);
446 else {
447 PLRelease(key);
448 return;
452 if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL,
453 USE_TEXT_FIELD) < 0)
454 return;
456 PLSetStringCmpHook(NULL);
458 winDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
460 /* Update icon for window */
461 icon_file = WMGetTextFieldText(panel->fileText);
462 if (icon_file) {
463 if (icon_file[0] != 0) {
464 value = PLMakeString(icon_file);
465 insertAttribute(dict, winDic, AIcon, value, &different, flags);
466 PLRelease(value);
468 free(icon_file);
472 int i = WMGetPopUpButtonSelectedItem(panel->wsP);
474 i--;
476 if (i>=0 && i < panel->frame->screen_ptr->workspace_count) {
477 value = PLMakeString(panel->frame->screen_ptr->workspaces[i]->name);
478 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
479 PLRelease(value);
483 flags |= IS_BOOLEAN;
485 value = (WMGetButtonSelected(panel->alwChk)!=0) ? Yes : No;
486 insertAttribute(dict, winDic, AAlwaysUserIcon, value, &different, flags);
488 value = (WMGetButtonSelected(panel->attrChk[0])!=0) ? Yes : No;
489 insertAttribute(dict, winDic, ANoTitlebar, value, &different, flags);
491 value = (WMGetButtonSelected(panel->attrChk[1])!=0) ? Yes : No;
492 insertAttribute(dict, winDic, ANoResizebar, value, &different, flags);
494 value = (WMGetButtonSelected(panel->attrChk[2])!=0) ? Yes : No;
495 insertAttribute(dict, winDic, ANoCloseButton, value, &different, flags);
497 value = (WMGetButtonSelected(panel->attrChk[3])!=0) ? Yes : No;
498 insertAttribute(dict, winDic, ANoMiniaturizeButton, value, &different, flags);
500 value = (WMGetButtonSelected(panel->attrChk[4])!=0) ? Yes : No;
501 insertAttribute(dict, winDic, AKeepOnTop, value, &different, flags);
503 value = (WMGetButtonSelected(panel->attrChk[5])!=0) ? Yes : No;
504 insertAttribute(dict, winDic, AKeepOnBottom, value, &different, flags);
506 value = (WMGetButtonSelected(panel->attrChk[6])!=0) ? Yes : No;
507 insertAttribute(dict, winDic, AOmnipresent, value, &different, flags);
509 value = (WMGetButtonSelected(panel->attrChk[7])!=0) ? Yes : No;
510 insertAttribute(dict, winDic, AStartMiniaturized, value, &different, flags);
512 value = (WMGetButtonSelected(panel->attrChk[8])!=0) ? Yes : No;
513 insertAttribute(dict, winDic, AStartMaximized, value, &different, flags);
515 value = (WMGetButtonSelected(panel->attrChk[9])!=0) ? Yes : No;
516 insertAttribute(dict, winDic, ASkipWindowList, value, &different, flags);
519 value = (WMGetButtonSelected(panel->moreChk[0])!=0) ? Yes : No;
520 insertAttribute(dict, winDic, ANoHideOthers, value, &different, flags);
522 value = (WMGetButtonSelected(panel->moreChk[1])!=0) ? Yes : No;
523 insertAttribute(dict, winDic, ANoKeyBindings, value, &different, flags);
525 value = (WMGetButtonSelected(panel->moreChk[2])!=0) ? Yes : No;
526 insertAttribute(dict, winDic, ANoMouseBindings, value, &different, flags);
528 value = (WMGetButtonSelected(panel->moreChk[3])!=0) ? Yes : No;
529 insertAttribute(dict, winDic, AKeepInsideScreen, value, &different, flags);
531 value = (WMGetButtonSelected(panel->moreChk[4])!=0) ? Yes : No;
532 insertAttribute(dict, winDic, AUnfocusable, value, &different, flags);
534 value = (WMGetButtonSelected(panel->moreChk[5])!=0) ? Yes : No;
535 insertAttribute(dict, winDic, ADontSaveSession, value, &different, flags);
537 value = (WMGetButtonSelected(panel->moreChk[6])!=0) ? Yes : No;
538 insertAttribute(dict, winDic, AEmulateAppIcon, value, &different, flags);
540 value = (WMGetButtonSelected(panel->moreChk[7])!=0) ? Yes : No;
541 insertAttribute(dict, winDic, AFullMaximize, value, &different, flags);
543 #ifdef XKB_BUTTON_HINT
544 value = (WMGetButtonSelected(panel->moreChk[8])!=0) ? Yes : No;
545 insertAttribute(dict, winDic, ANoLanguageButton, value, &different, flags);
546 #endif
548 /* application wide settings for when */
549 /* the window is the leader, save the attribute with the others */
550 if (panel->inspected->main_window == panel->inspected->client_win) {
552 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
553 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
555 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
556 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
559 PLRemoveDictionaryEntry(dict, key);
560 if (different) {
561 PLInsertDictionaryEntry(dict, key, winDic);
564 PLRelease(key);
565 PLRelease(winDic);
567 different = 0;
569 /* application wide settings */
570 if (panel->inspected->main_window != panel->inspected->client_win
571 && !(flags & UPDATE_DEFAULTS)) {
572 WApplication *wapp;
573 proplist_t appDic;
575 wapp = wApplicationOf(panel->inspected->main_window);
576 if (wapp) {
577 char *iconFile;
579 appDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
581 assert(wapp->main_window_desc->wm_instance!=NULL);
582 assert(wapp->main_window_desc->wm_class!=NULL);
584 strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), ".");
585 strcat(buffer, wwin->wm_class);
586 key = PLMakeString(buffer);
588 iconFile = wDefaultGetIconFile(wwin->screen_ptr,
589 wapp->main_window_desc->wm_instance,
590 wapp->main_window_desc->wm_class,
591 False);
593 if (iconFile && iconFile[0]!=0) {
594 value = PLMakeString(iconFile);
595 insertAttribute(dict, appDic, AIcon, value, &different,
596 flags&~IS_BOOLEAN);
597 PLRelease(value);
600 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
601 insertAttribute(dict, appDic, AStartHidden, value, &different, flags);
603 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
604 insertAttribute(dict, appDic, ANoAppIcon, value, &different, flags);
606 PLRemoveDictionaryEntry(dict, key);
607 if (different) {
608 PLInsertDictionaryEntry(dict, key, appDic);
610 PLRelease(key);
611 PLRelease(appDic);
615 PLSave(dict, YES);
617 /* clean up */
618 PLSetStringCmpHook(StringCompareHook);
622 static void
623 makeAppIconFor(WApplication *wapp)
625 WScreen *scr = wapp->main_window_desc->screen_ptr;
627 if (wapp->app_icon)
628 return;
630 if (!WFLAGP(wapp->main_window_desc, no_appicon))
631 wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
632 else
633 wapp->app_icon = NULL;
635 if (wapp->app_icon) {
636 WIcon *icon = wapp->app_icon->icon;
637 WDock *clip = scr->workspaces[scr->current_workspace]->clip;
638 int x=0, y=0;
640 wapp->app_icon->main_window = wapp->main_window;
642 if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
643 wapp->app_icon->attracted = 1;
644 if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {
645 wapp->app_icon->icon->shadowed = 1;
646 wapp->app_icon->icon->force_paint = 1;
648 wDockAttachIcon(clip, wapp->app_icon, x, y);
649 } else {
650 PlaceIcon(scr, &x, &y);
651 wAppIconMove(wapp->app_icon, x, y);
653 if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
654 XMapWindow(dpy, icon->core->window);
656 if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted)
657 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
662 static void
663 removeAppIconFor(WApplication *wapp)
665 if (!wapp->app_icon)
666 return;
668 if (wapp->app_icon->docked &&
669 (!wapp->app_icon->attracted || wapp->app_icon->dock->keep_attracted)) {
670 wapp->app_icon->running = 0;
671 /* since we keep it, we don't care if it was attracted or not */
672 wapp->app_icon->attracted = 0;
673 wapp->app_icon->icon->shadowed = 0;
674 wapp->app_icon->main_window = None;
675 wapp->app_icon->pid = 0;
676 wapp->app_icon->icon->owner = NULL;
677 wapp->app_icon->icon->icon_win = None;
678 wapp->app_icon->icon->force_paint = 1;
679 wAppIconPaint(wapp->app_icon);
680 } else if (wapp->app_icon->docked) {
681 wapp->app_icon->running = 0;
682 wDockDetach(wapp->app_icon->dock, wapp->app_icon);
683 } else {
684 wAppIconDestroy(wapp->app_icon);
686 wapp->app_icon = NULL;
687 if (wPreferences.auto_arrange_icons)
688 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
692 static void
693 applySettings(WMButton *button, InspectorPanel *panel)
695 WWindow *wwin = panel->inspected;
696 WApplication *wapp = wApplicationOf(wwin->main_window);
697 int floating, sunken, skip_window_list;
698 int old_omnipresent;
699 int old_no_bind_keys;
700 int old_no_bind_mouse;
702 old_omnipresent = WFLAGP(wwin, omnipresent);
703 old_no_bind_keys = WFLAGP(wwin, no_bind_keys);
704 old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse);
706 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
708 WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0]));
709 WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1]));
710 WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2]));
711 WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3]));
712 floating = WMGetButtonSelected(panel->attrChk[4]);
713 sunken = WMGetButtonSelected(panel->attrChk[5]);
714 WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[6]));
715 WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[7]));
716 WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[8]));
717 skip_window_list = WMGetButtonSelected(panel->attrChk[9]);
719 WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[0]));
720 WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[1]));
721 WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[2]));
722 WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[3]));
723 WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4]));
724 WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[5]));
725 WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[6]));
726 WSETUFLAG(wwin, full_maximize, WMGetButtonSelected(panel->moreChk[7]));
727 #ifdef XKB_BUTTON_HINT
728 WSETUFLAG(wwin, no_language_button, WMGetButtonSelected(panel->moreChk[8]));
729 #endif
730 WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk));
732 if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded)
733 wUnshadeWindow(wwin);
735 WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar));
737 if (floating) {
738 if (!WFLAGP(wwin, floating))
739 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
740 } else if (sunken) {
741 if (!WFLAGP(wwin, sunken))
742 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
743 } else {
744 if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken))
745 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
748 WSETUFLAG(wwin, sunken, sunken);
749 WSETUFLAG(wwin, floating, floating);
750 wwin->flags.omnipresent = 0;
752 if (WFLAGP(wwin, skip_window_list) != skip_window_list) {
753 WSETUFLAG(wwin, skip_window_list, skip_window_list);
754 UpdateSwitchMenu(wwin->screen_ptr, wwin,
755 skip_window_list ? ACTION_REMOVE : ACTION_ADD);
756 } else {
757 if (WFLAGP(wwin, omnipresent) != old_omnipresent) {
758 UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
762 if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) {
763 if (WFLAGP(wwin, no_bind_keys)) {
764 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
765 } else {
766 wWindowSetKeyGrabs(wwin);
770 if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) {
771 wWindowResetMouseGrabs(wwin);
774 wwin->frame->flags.need_texture_change = 1;
775 wWindowConfigureBorders(wwin);
776 wFrameWindowPaint(wwin->frame);
779 * Can't apply emulate_appicon because it will probably cause problems.
782 if (wapp) {
783 /* do application wide stuff */
784 WSETUFLAG(wapp->main_window_desc, start_hidden,
785 WMGetButtonSelected(panel->appChk[0]));
787 WSETUFLAG(wapp->main_window_desc, no_appicon,
788 WMGetButtonSelected(panel->appChk[1]));
790 if (WFLAGP(wapp->main_window_desc, no_appicon))
791 removeAppIconFor(wapp);
792 else
793 makeAppIconFor(wapp);
795 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
796 char *file = WMGetTextFieldText(panel->fileText);
798 if (file[0] == 0) {
799 free(file);
800 file = NULL;
802 wIconChangeImageFile(wapp->app_icon->icon, file);
803 if (file)
804 free(file);
805 wAppIconPaint(wapp->app_icon);
813 static void
814 revertSettings(WMButton *button, InspectorPanel *panel)
816 WWindow *wwin = panel->inspected;
817 WApplication *wapp = wApplicationOf(wwin->main_window);
818 int i, n;
819 char *wm_instance = NULL;
820 char *wm_class = NULL;
821 int workspace, level;
823 if (panel->instRb && WMGetButtonSelected(panel->instRb) != 0)
824 wm_instance = wwin->wm_instance;
825 else if (panel->clsRb && WMGetButtonSelected(panel->clsRb) != 0)
826 wm_class = wwin->wm_class;
827 else if (panel->bothRb && WMGetButtonSelected(panel->bothRb) != 0) {
828 wm_instance = wwin->wm_instance;
829 wm_class = wwin->wm_class;
831 memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes));
832 memset(&wwin->user_flags, 0, sizeof(WWindowAttributes));
833 memset(&wwin->client_flags, 0, sizeof(WWindowAttributes));
835 wWindowSetupInitialAttributes(wwin, &level, &workspace);
837 for (i=0; i < 10; i++) {
838 int flag = 0;
840 switch (i) {
841 case 0:
842 flag = WFLAGP(wwin, no_titlebar);
843 break;
844 case 1:
845 flag = WFLAGP(wwin, no_resizebar);
846 break;
847 case 2:
848 flag = WFLAGP(wwin, no_close_button);
849 break;
850 case 3:
851 flag = WFLAGP(wwin, no_miniaturize_button);
852 break;
853 case 4:
854 flag = WFLAGP(wwin, floating);
855 break;
856 case 5:
857 flag = WFLAGP(wwin, sunken);
858 break;
859 case 6:
860 flag = WFLAGP(wwin, omnipresent);
861 break;
862 case 7:
863 flag = WFLAGP(wwin, start_miniaturized);
864 break;
865 case 8:
866 flag = WFLAGP(wwin, start_maximized!=0);
867 break;
868 case 9:
869 flag = WFLAGP(wwin, skip_window_list);
870 break;
872 WMSetButtonSelected(panel->attrChk[i], flag);
874 for (i=0; i < 8; i++) {
875 int flag = 0;
877 switch (i) {
878 case 0:
879 flag = WFLAGP(wwin, no_hide_others);
880 break;
881 case 1:
882 flag = WFLAGP(wwin, no_bind_keys);
883 break;
884 case 2:
885 flag = WFLAGP(wwin, no_bind_mouse);
886 break;
887 case 3:
888 flag = WFLAGP(wwin, dont_move_off);
889 break;
890 case 4:
891 flag = WFLAGP(wwin, no_focusable);
892 break;
893 case 5:
894 flag = WFLAGP(wwin, dont_save_session);
895 break;
896 case 6:
897 flag = WFLAGP(wwin, emulate_appicon);
898 break;
899 case 7:
900 flag = WFLAGP(wwin, full_maximize);
901 break;
902 #ifdef XKB_BUTTON_HINT
903 case 8:
904 flag = WFLAGP(wwin, no_language_button);
905 break;
906 #endif
908 WMSetButtonSelected(panel->moreChk[i], flag);
910 if (panel->appFrm && wapp) {
911 for (i=0; i < 2; i++) {
912 int flag = 0;
914 switch (i) {
915 case 0:
916 flag = WFLAGP(wapp->main_window_desc, start_hidden);
917 break;
918 case 1:
919 flag = WFLAGP(wapp->main_window_desc, no_appicon);
920 break;
922 WMSetButtonSelected(panel->appChk[i], flag);
925 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
927 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
928 REVERT_TO_DEFAULT);
930 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
932 if (n >= 0 && n < wwin->screen_ptr->workspace_count) {
933 WMSetPopUpButtonSelectedItem(panel->wsP, n+1);
934 } else {
935 WMSetPopUpButtonSelectedItem(panel->wsP, 0);
940 static void
941 chooseIconCallback(WMWidget *self, void *clientData)
943 char *file;
944 InspectorPanel *panel = (InspectorPanel*)clientData;
945 int result;
947 panel->choosingIcon = 1;
949 WMSetButtonEnabled(panel->browseIconBtn, False);
951 result = wIconChooserDialog(panel->frame->screen_ptr, &file,
952 panel->inspected->wm_instance,
953 panel->inspected->wm_class);
955 panel->choosingIcon = 0;
957 if (!panel->destroyed) { /* kluge */
958 if (result) {
959 WMSetTextFieldText(panel->fileText, file);
960 showIconFor(WMWidgetScreen(self), panel, NULL, NULL,
961 USE_TEXT_FIELD);
962 free(file);
964 WMSetButtonEnabled(panel->browseIconBtn, True);
965 } else {
966 freeInspector(panel);
971 static void
972 textEditedObserver(void *observerData, WMNotification *notification)
974 InspectorPanel *panel = (InspectorPanel*)observerData;
976 if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement)
977 return;
979 showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL,
980 USE_TEXT_FIELD);
982 WMPerformButtonClick(panel->updateIconBtn);
987 static void
988 selectSpecification(WMWidget *bPtr, void *data)
990 InspectorPanel *panel = (InspectorPanel*)data;
991 char *str;
992 WWindow *wwin = panel->inspected;
994 if (bPtr == panel->defaultRb) {
995 WMSetButtonEnabled(panel->applyBtn, False);
996 } else {
997 WMSetButtonEnabled(panel->applyBtn, True);
1000 str = wmalloc(16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
1001 + strlen(wwin->wm_class ? wwin->wm_class : "?"));
1003 sprintf(str, "Inspecting %s.%s",
1004 wwin->wm_instance ? wwin->wm_instance : "?",
1005 wwin->wm_class ? wwin->wm_class : "?");
1007 wFrameWindowChangeTitle(panel->frame->frame, str);
1009 free(str);
1013 static InspectorPanel*
1014 createInspectorForWindow(WWindow *wwin)
1016 WScreen *scr = wwin->screen_ptr;
1017 InspectorPanel *panel;
1018 Window parent;
1019 int i;
1020 int x, y;
1021 int btn_width, frame_width;
1022 WMButton *selectedBtn = NULL;
1023 #ifdef wrong_behaviour
1024 WMPixmap *pixmap;
1025 #endif
1028 panel = wmalloc(sizeof(InspectorPanel));
1029 memset(panel, 0, sizeof(InspectorPanel));
1031 panel->destroyed = 0;
1034 panel->inspected = wwin;
1036 panel->nextPtr = panelList;
1037 panelList = panel;
1040 panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
1041 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1044 /**** create common stuff ****/
1046 /* command buttons */
1047 /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
1048 btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
1049 panel->saveBtn = WMCreateCommandButton(panel->win);
1050 WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);
1051 WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, 310);
1052 WMSetButtonText(panel->saveBtn, _("Save"));
1053 WMResizeWidget(panel->saveBtn, btn_width, 28);
1054 if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance))
1055 WMSetButtonEnabled(panel->saveBtn, False);
1057 panel->applyBtn = WMCreateCommandButton(panel->win);
1058 WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);
1059 WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);
1060 WMSetButtonText(panel->applyBtn, _("Apply"));
1061 WMResizeWidget(panel->applyBtn, btn_width, 28);
1063 panel->revertBtn = WMCreateCommandButton(panel->win);
1064 WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);
1065 WMMoveWidget(panel->revertBtn, 15, 310);
1066 WMSetButtonText(panel->revertBtn, _("Reload"));
1067 WMResizeWidget(panel->revertBtn, btn_width, 28);
1069 /* page selection popup button */
1070 panel->pagePopUp = WMCreatePopUpButton(panel->win);
1071 WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);
1072 WMMoveWidget(panel->pagePopUp, 25, 15);
1073 WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);
1075 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));
1076 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));
1077 WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));
1078 WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));
1079 WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));
1081 /**** window spec ****/
1082 frame_width = PWIDTH - (2 * 15);
1084 panel->specFrm = WMCreateFrame(panel->win);
1085 WMSetFrameTitle(panel->specFrm, _("Window Specification"));
1086 WMMoveWidget(panel->specFrm, 15, 65);
1087 WMResizeWidget(panel->specFrm, frame_width, 105);
1090 panel->defaultRb = WMCreateRadioButton(panel->specFrm);
1091 WMMoveWidget(panel->defaultRb, 10, 78);
1092 WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);
1093 WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));
1094 WMSetButtonSelected(panel->defaultRb, False);
1095 WMSetButtonAction(panel->defaultRb, selectSpecification, panel);
1097 if (wwin->wm_class && wwin->wm_instance) {
1098 char *str, *tmp;
1100 tmp = wstrappend(wwin->wm_instance, ".");
1101 str = wstrappend(tmp, wwin->wm_class);
1102 panel->bothRb = WMCreateRadioButton(panel->specFrm);
1103 WMMoveWidget(panel->bothRb, 10, 18);
1104 WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);
1105 WMSetButtonText(panel->bothRb, str);
1106 free(tmp);
1107 free(str);
1108 WMGroupButtons(panel->defaultRb, panel->bothRb);
1110 if (!selectedBtn)
1111 selectedBtn = panel->bothRb;
1113 WMSetButtonAction(panel->bothRb, selectSpecification, panel);
1116 if (wwin->wm_instance) {
1117 panel->instRb = WMCreateRadioButton(panel->specFrm);
1118 WMMoveWidget(panel->instRb, 10, 38);
1119 WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);
1120 WMSetButtonText(panel->instRb, wwin->wm_instance);
1121 WMGroupButtons(panel->defaultRb, panel->instRb);
1123 if (!selectedBtn)
1124 selectedBtn = panel->instRb;
1126 WMSetButtonAction(panel->instRb, selectSpecification, panel);
1129 if (wwin->wm_class) {
1130 panel->clsRb = WMCreateRadioButton(panel->specFrm);
1131 WMMoveWidget(panel->clsRb, 10, 58);
1132 WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);
1133 WMSetButtonText(panel->clsRb, wwin->wm_class);
1134 WMGroupButtons(panel->defaultRb, panel->clsRb);
1136 if (!selectedBtn)
1137 selectedBtn = panel->clsRb;
1139 WMSetButtonAction(panel->clsRb, selectSpecification, panel);
1142 if (selectedBtn)
1143 WMSetButtonSelected(selectedBtn, True);
1145 panel->specLbl = WMCreateLabel(panel->win);
1146 WMMoveWidget(panel->specLbl, 15, 170);
1147 WMResizeWidget(panel->specLbl, frame_width, 100);
1148 WMSetLabelText(panel->specLbl,
1149 _("The configuration will apply to all\n"
1150 "windows that have their WM_CLASS property"
1151 " set to the above selected\nname, when saved."));
1152 WMSetLabelTextAlignment(panel->specLbl, WACenter);
1154 /**** attributes ****/
1155 panel->attrFrm = WMCreateFrame(panel->win);
1156 WMSetFrameTitle(panel->attrFrm, _("Attributes"));
1157 WMMoveWidget(panel->attrFrm, 15, 45);
1158 WMResizeWidget(panel->attrFrm, frame_width, 250);
1160 for (i=0; i < 10; i++) {
1161 char *caption = NULL;
1162 int flag = 0;
1163 char *descr = NULL;
1165 switch (i) {
1166 case 0:
1167 caption = _("Disable Titlebar");
1168 flag = WFLAGP(wwin, no_titlebar);
1169 descr = _("Remove the titlebar of this window.\n"
1170 "To access the window commands menu of a window\n"
1171 "without it's titlebar, press Control+Esc (or the\n"
1172 "equivalent shortcut, if you changed the default\n"
1173 "settings).");
1174 break;
1175 case 1:
1176 caption = _("Disable Resizebar");
1177 flag = WFLAGP(wwin, no_resizebar);
1178 descr = _("Remove the resizebar of this window.");
1179 break;
1180 case 2:
1181 caption = _("Disable Close Button");
1182 flag = WFLAGP(wwin, no_close_button);
1183 descr = _("Remove the `close window' button of this window.");
1184 break;
1185 case 3:
1186 caption = _("Disable Miniaturize Button");
1187 flag = WFLAGP(wwin, no_miniaturize_button);
1188 descr = _("Remove the `miniaturize window' button of the window.");
1189 break;
1190 case 4:
1191 caption = _("Keep on Top / Floating");
1192 flag = WFLAGP(wwin, floating);
1193 descr = _("Keep the window over other windows, not allowing\n"
1194 "them to covert it.");
1195 break;
1196 case 5:
1197 caption = _("Keep at Bottom / Sunken");
1198 flag = WFLAGP(wwin, sunken);
1199 descr = _("Keep the window under all other windows.");
1200 break;
1201 case 6:
1202 caption = _("Omnipresent");
1203 flag = WFLAGP(wwin, omnipresent);
1204 descr = _("Make window occupy all workspaces.");
1205 break;
1206 case 7:
1207 caption = _("Start Miniaturized");
1208 flag = WFLAGP(wwin, start_miniaturized);
1209 descr = _("Make the window be automatically miniaturized when it's\n"
1210 "first shown.");
1211 break;
1212 case 8:
1213 caption = _("Start Maximized");
1214 flag = WFLAGP(wwin, start_maximized!=0);
1215 descr = _("Make the window be automatically maximized when it's\n"
1216 "first shown.");
1217 break;
1218 case 9:
1219 caption = _("Skip Window List");
1220 flag = WFLAGP(wwin, skip_window_list);
1221 descr = _("Do not list the window in the window list menu.");
1222 break;
1224 panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
1225 WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));
1226 WMResizeWidget(panel->attrChk[i], frame_width-15, 20);
1227 WMSetButtonSelected(panel->attrChk[i], flag);
1228 WMSetButtonText(panel->attrChk[i], caption);
1230 WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i]));
1234 /**** more attributes ****/
1235 panel->moreFrm = WMCreateFrame(panel->win);
1236 WMSetFrameTitle(panel->moreFrm, _("Advanced"));
1237 WMMoveWidget(panel->moreFrm, 15, 45);
1238 WMResizeWidget(panel->moreFrm, frame_width, 250);
1240 #ifdef XKB_BUTTON_HINT
1241 for (i=0; i < 9; i++) {
1242 #else
1243 for (i=0; i < 8; i++) {
1244 #endif
1245 char *caption = NULL;
1246 int flag = 0;
1247 char *descr = NULL;
1249 switch (i) {
1250 case 0:
1251 caption = _("Ignore HideOthers");
1252 flag = WFLAGP(wwin, no_hide_others);
1253 descr = _("Do not hide the window when issuing the\n"
1254 "`HideOthers' command.");
1255 break;
1256 case 1:
1257 caption = _("Don't Bind Keyboard Shortcuts");
1258 flag = WFLAGP(wwin, no_bind_keys);
1259 descr = _("Do not bind keyboard shortcuts from Window Maker\n"
1260 "when this window is focused. This will allow the\n"
1261 "window to receive all key combinations regardless\n"
1262 "of your shortcut configuration.");
1263 break;
1264 case 2:
1265 caption = _("Don't Bind Mouse Clicks");
1266 flag = WFLAGP(wwin, no_bind_mouse);
1267 descr = _("Do not bind mouse actions, such as `Alt'+drag\n"
1268 "in the window (when alt is the modifier you have"
1269 "configured).");
1270 break;
1271 case 3:
1272 caption = _("Keep Inside Screen");
1273 flag = WFLAGP(wwin, dont_move_off);
1274 descr = _("Do not allow the window to move itself completely\n"
1275 "outside the screen. For bug compatibility.\n");
1276 break;
1277 case 4:
1278 caption = _("Don't Let It Take Focus");
1279 flag = WFLAGP(wwin, no_focusable);
1280 descr = _("Do not let the window take keyboard focus when you\n"
1281 "click on it.");
1282 break;
1283 case 5:
1284 caption = _("Don't Save Session");
1285 flag = WFLAGP(wwin, dont_save_session);
1286 descr = _("Do not save the associated application in the\n"
1287 "session's state, so that it won't be restarted\n"
1288 "together with other applications when Window Maker\n"
1289 "starts.");
1290 break;
1291 case 6:
1292 caption = _("Emulate Application Icon");
1293 flag = WFLAGP(wwin, emulate_appicon);
1294 descr = _("Make this window act as an application that provides\n"
1295 "enough information to Window Maker for a dockable\n"
1296 "application icon to be created.");
1297 break;
1298 case 7:
1299 caption = _("Full Screen Maximization");
1300 flag = WFLAGP(wwin, full_maximize);
1301 descr = _("Make the window use the whole screen space when it's\n"
1302 "maximized. The titlebar and resizebar will be moved\n"
1303 "to outside the screen.");
1304 break;
1305 #ifdef XKB_BUTTON_HINT
1306 case 8:
1307 caption = _("Disable Language Button");
1308 flag = WFLAGP(wwin, no_language_button);
1309 descr = _("Remove the `toggle language' button of the window.");
1310 break;
1311 #endif
1313 panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
1314 WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));
1315 WMResizeWidget(panel->moreChk[i], frame_width-15, 20);
1316 WMSetButtonSelected(panel->moreChk[i], flag);
1317 WMSetButtonText(panel->moreChk[i], caption);
1319 WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i]));
1322 /* miniwindow/workspace */
1323 panel->iconFrm = WMCreateFrame(panel->win);
1324 WMMoveWidget(panel->iconFrm, 15, 50);
1325 WMResizeWidget(panel->iconFrm, PWIDTH - (2 * 15), 170);
1326 WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
1328 panel->iconLbl = WMCreateLabel(panel->iconFrm);
1329 WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
1330 WMResizeWidget(panel->iconLbl, 64, 64);
1331 WMSetLabelRelief(panel->iconLbl, WRGroove);
1332 WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
1334 panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
1335 WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
1336 WMMoveWidget(panel->browseIconBtn, 22, 30);
1337 WMResizeWidget(panel->browseIconBtn, 100, 26);
1338 WMSetButtonText(panel->browseIconBtn, _("Browse..."));
1340 #if 0
1341 panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
1342 WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
1343 WMMoveWidget(panel->updateIconBtn, 22, 65);
1344 WMResizeWidget(panel->updateIconBtn, 100, 26);
1345 WMSetButtonText(panel->updateIconBtn, _("Update"));
1346 #endif
1347 #ifdef wrong_behaviour
1348 WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
1349 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
1350 WMSetButtonImage(panel->updateIconBtn, pixmap);
1351 WMReleasePixmap(pixmap);
1352 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
1353 WMSetButtonAltImage(panel->updateIconBtn, pixmap);
1354 WMReleasePixmap(pixmap);
1355 #endif
1357 panel->fileLbl = WMCreateLabel(panel->iconFrm);
1358 WMMoveWidget(panel->fileLbl, 20, 95);
1359 WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
1360 WMSetLabelText(panel->fileLbl, _("Icon File Name:"));
1362 panel->fileText = WMCreateTextField(panel->iconFrm);
1363 WMMoveWidget(panel->fileText, 20, 115);
1364 WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
1365 WMSetTextFieldText(panel->fileText, NULL);
1366 WMAddNotificationObserver(textEditedObserver, panel,
1367 WMTextDidEndEditingNotification,
1368 panel->fileText);
1369 panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
1370 WMMoveWidget(panel->alwChk, 20, 140);
1371 WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
1372 WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
1373 WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));
1376 panel->wsFrm = WMCreateFrame(panel->win);
1377 WMMoveWidget(panel->wsFrm, 15, 225);
1378 WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);
1379 WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));
1381 WMSetBalloonTextForView(_("The workspace to place the window when it's"
1382 "first shown."), WMWidgetView(panel->wsFrm));
1384 panel->wsP = WMCreatePopUpButton(panel->wsFrm);
1385 WMMoveWidget(panel->wsP, 20, 30);
1386 WMResizeWidget(panel->wsP, PWIDTH - (2 * 15) - (2 * 20), 20);
1387 WMAddPopUpButtonItem(panel->wsP, _("Nowhere in particular"));
1388 for (i = 0; i < wwin->screen_ptr->workspace_count; i++) {
1389 WMAddPopUpButtonItem(panel->wsP, scr->workspaces[i]->name);
1392 i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
1393 wwin->wm_class);
1394 if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
1395 WMSetPopUpButtonSelectedItem(panel->wsP, i + 1);
1396 } else {
1397 WMSetPopUpButtonSelectedItem(panel->wsP, 0);
1400 /* application wide attributes */
1401 if (wwin->main_window != None) {
1402 WApplication *wapp = wApplicationOf(wwin->main_window);
1404 panel->appFrm = WMCreateFrame(panel->win);
1405 WMSetFrameTitle(panel->appFrm, _("Application Wide"));
1406 WMMoveWidget(panel->appFrm, 15, 50);
1407 WMResizeWidget(panel->appFrm, frame_width, 240);
1409 for (i=0; i < 2; i++) {
1410 char *caption = NULL;
1411 int flag = 0;
1412 char *descr = NULL;
1414 switch (i) {
1415 case 0:
1416 caption = _("Start Hidden");
1417 flag = WFLAGP(wapp->main_window_desc, start_hidden);
1418 descr = _("Automatically hide application when it's started.");
1419 break;
1420 case 1:
1421 caption = _("No Application Icon");
1422 flag = WFLAGP(wapp->main_window_desc, no_appicon);
1423 descr = _("Disable the application icon for the application.\n"
1424 "Note that you won't be able to dock it anymore,\n"
1425 "and any icons that are already docked will stop\n"
1426 "working correctly.");
1427 break;
1429 panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
1430 WMMoveWidget(panel->appChk[i], 10, 20*(i+1));
1431 WMResizeWidget(panel->appChk[i], 205, 20);
1432 WMSetButtonSelected(panel->appChk[i], flag);
1433 WMSetButtonText(panel->appChk[i], caption);
1435 WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i]));
1438 if (WFLAGP(wwin, emulate_appicon)) {
1439 WMSetButtonEnabled(panel->appChk[1], False);
1440 WMSetButtonEnabled(panel->moreChk[6], True);
1441 } else {
1442 WMSetButtonEnabled(panel->appChk[1], True);
1443 WMSetButtonEnabled(panel->moreChk[6], False);
1445 } else {
1446 int tmp;
1448 if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win)
1449 || !wwin->wm_class || !wwin->wm_instance)
1450 tmp = False;
1451 else
1452 tmp = True;
1453 WMSetButtonEnabled(panel->moreChk[6], tmp);
1455 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
1456 panel->appFrm = NULL;
1459 /* if the window is a transient, don't let it have a miniaturize
1460 * button */
1461 if (wWindowFor(wwin->transient_for)!=NULL)
1462 WMSetButtonEnabled(panel->attrChk[3], False);
1463 else
1464 WMSetButtonEnabled(panel->attrChk[3], True);
1467 if (!wwin->wm_class && !wwin->wm_instance) {
1468 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);
1472 WMRealizeWidget(panel->win);
1474 WMMapSubwidgets(panel->win);
1475 WMMapSubwidgets(panel->specFrm);
1476 WMMapSubwidgets(panel->attrFrm);
1477 WMMapSubwidgets(panel->moreFrm);
1478 WMMapSubwidgets(panel->iconFrm);
1479 WMMapSubwidgets(panel->wsFrm);
1480 if (panel->appFrm)
1481 WMMapSubwidgets(panel->appFrm);
1483 WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);
1484 changePage(panel->pagePopUp, panel);
1487 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
1488 0, 0, 0);
1489 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
1490 panel->parent = parent;
1491 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1493 WMMapWidget(panel->win);
1495 XSetTransientForHint(dpy, parent, wwin->client_win);
1497 x = wwin->frame_x+wwin->frame->core->width/2;
1498 y = wwin->frame_y+wwin->frame->top_width*2;
1499 if (y + PHEIGHT > scr->scr_height)
1500 y = scr->scr_height - PHEIGHT - 30;
1501 if (x + PWIDTH > scr->scr_width)
1502 x = scr->scr_width - PWIDTH;
1504 panel->frame = wManageInternalWindow(scr, parent, wwin->client_win,
1505 "Inspector", x, y, PWIDTH, PHEIGHT);
1507 if (!selectedBtn)
1508 selectedBtn = panel->defaultRb;
1510 selectSpecification(selectedBtn, panel);
1512 /* kluge to know who should get the key events */
1513 panel->frame->client_leader = WMWidgetXID(panel->win);
1515 WSETUFLAG(panel->frame, no_closable, 0);
1516 WSETUFLAG(panel->frame, no_close_button, 0);
1517 wWindowUpdateButtonImages(panel->frame);
1518 wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
1519 panel->frame->frame->on_click_right = destroyInspector;
1521 wWindowMap(panel->frame);
1523 showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance,
1524 wwin->wm_class, UPDATE_TEXT_FIELD);
1526 return panel;
1530 void
1531 wShowInspectorForWindow(WWindow *wwin)
1533 if (wwin->flags.inspector_open)
1534 return;
1536 WMSetBalloonEnabled(wwin->screen_ptr->wmscreen, wPreferences.help_balloon);
1538 make_keys();
1539 wwin->flags.inspector_open = 1;
1540 wwin->inspector = createInspectorForWindow(wwin);;