static void killCallback(WMenu *menu, WMenuEntry *entry) { WApplication *wapp = (WApplication*)entry->clientdata; WFakeGroupLeader *fPtr; char *buffer; if (!WCHECK_STATE(WSTATE_NORMAL)) return; WCHANGE_STATE(WSTATE_MODAL); assert(entry->clientdata!=NULL); buffer = wstrconcat(wapp->app_icon ? wapp->app_icon->wm_class : NULL, _(" will be forcibly closed.\n" "Any unsaved changes will be lost.\n" "Please confirm.")); fPtr = wapp->main_window_desc->fake_group; wretain(wapp->main_window_desc); if (wPreferences.dont_confirm_kill || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), buffer, _("Yes"), _("No"), NULL)==WAPRDefault) { if (fPtr!=NULL) { WWindow *wwin, *twin; wwin = wapp->main_window_desc->screen_ptr->focused_window; while (wwin) { twin = wwin->prev; if (wwin->fake_group == fPtr) { wClientKill(wwin); } wwin = twin; } } else if (!wapp->main_window_desc->flags.destroyed) { wClientKill(wapp->main_window_desc); } } wrelease(wapp->main_window_desc); wfree(buffer); WCHANGE_STATE(WSTATE_NORMAL); }
static void shellCommandHandler(pid_t pid, unsigned char status, _tuple *data) { if (status == 127) { char *buffer; buffer = wstrconcat(_("Could not execute command: "), data->command); wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } else if (status != 127) { /* printf("%s: %i\n", data->command, status); */ } wfree(data->command); wfree(data); }
static void setIconCallback(WMenu *menu, WMenuEntry *entry) { WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon; char *file = NULL; virtual_screen *vscr; int result; /* Parameter not used, but tell the compiler that it is ok */ (void) menu; assert(icon != NULL); if (icon->editing) return; icon->editing = 1; vscr = icon->icon->vscr; wretain(icon); result = wIconChooserDialog(NULL, NULL, icon, &file); if (result) { if (!icon->destroyed) { if (!wIconChangeImageFile(icon->icon, file)) { wMessageDialog(vscr, _("Error"), _("Could not open specified icon file"), _("OK"), NULL, NULL); } else { wDefaultChangeIcon(icon->wm_instance, icon->wm_class, file); wAppIconPaint(icon); } } if (file) wfree(file); } icon->editing = 0; wrelease(icon); }
static void setIconCallback(WMenu *menu, WMenuEntry *entry) { WAppIcon *icon = ((WApplication*)entry->clientdata)->app_icon; char *file=NULL; WScreen *scr; int result; assert(icon!=NULL); if (icon->editing) return; icon->editing = 1; scr = icon->icon->core->screen_ptr; wretain(icon); result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class); if (result && !icon->destroyed) { if (file && *file==0) { wfree(file); file = NULL; } if (!wIconChangeImageFile(icon->icon, file)) { wMessageDialog(scr, _("Error"), _("Could not open specified icon file"), _("OK"), NULL, NULL); } else { wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file); wAppIconPaint(icon); } if (file) wfree(file); } icon->editing = 0; wrelease(icon); }
static void execMenuCommand(WMenu * menu, WMenuEntry * entry) { WWindow *wwin = (WWindow *) entry->clientdata; WApplication *wapp; CloseWindowMenu(menu->frame->screen_ptr); switch (entry->order) { case MC_CLOSE: /* send delete message */ wClientSendProtocol(wwin, w_global.atom.wm.delete_window, w_global.timestamp.last_event); break; case MC_KILL: wretain(wwin); if (wPreferences.dont_confirm_kill || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), _ ("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."), _("Yes"), _("No"), NULL) == WAPRDefault) { if (!wwin->flags.destroyed) wClientKill(wwin); } wrelease(wwin); break; case MC_MINIATURIZE: if (wwin->flags.miniaturized) { wDeiconifyWindow(wwin); } else { if (wwin->protocols.MINIATURIZE_WINDOW) { wClientSendProtocol(wwin, w_global.atom.gnustep.wm_miniaturize_window, w_global.timestamp.last_event); } else { wIconifyWindow(wwin); } } break; case MC_MAXIMIZE: if (wwin->flags.maximized) wUnmaximizeWindow(wwin); else wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL, wGetHeadForWindow(wwin)); break; case MC_SHADE: if (wwin->flags.shaded) wUnshadeWindow(wwin); else wShadeWindow(wwin); break; case MC_SELECT: if (!wwin->flags.miniaturized) wSelectWindow(wwin, !wwin->flags.selected); else wIconSelect(wwin->icon); break; case MC_MOVERESIZE: wKeyboardMoveResizeWindow(wwin); break; case MC_PROPERTIES: wShowInspectorForWindow(wwin); break; case MC_RELAUNCH: (void) RelaunchWindow(wwin); break; case MC_HIDE: wapp = wApplicationOf(wwin->main_window); wHideApplication(wapp); break; } }
static void applySettings(WMWidget *button, void *client_data) { InspectorPanel *panel = (InspectorPanel *) client_data; WWindow *wwin = panel->inspected; WApplication *wapp = wApplicationOf(wwin->main_window); int floating, sunken, skip_window_list; int old_omnipresent, old_no_bind_keys, old_no_bind_mouse; old_omnipresent = WFLAGP(wwin, omnipresent); old_no_bind_keys = WFLAGP(wwin, no_bind_keys); old_no_bind_mouse = WFLAGP(wwin, no_bind_mouse); showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD); /* Attributes... --> Window Attributes */ WSETUFLAG(wwin, no_titlebar, WMGetButtonSelected(panel->attrChk[0])); WSETUFLAG(wwin, no_resizebar, WMGetButtonSelected(panel->attrChk[1])); WSETUFLAG(wwin, no_close_button, WMGetButtonSelected(panel->attrChk[2])); WSETUFLAG(wwin, no_miniaturize_button, WMGetButtonSelected(panel->attrChk[3])); WSETUFLAG(wwin, no_border, WMGetButtonSelected(panel->attrChk[4])); floating = WMGetButtonSelected(panel->attrChk[5]); sunken = WMGetButtonSelected(panel->attrChk[6]); WSETUFLAG(wwin, omnipresent, WMGetButtonSelected(panel->attrChk[7])); WSETUFLAG(wwin, start_miniaturized, WMGetButtonSelected(panel->attrChk[8])); WSETUFLAG(wwin, start_maximized, WMGetButtonSelected(panel->attrChk[9])); WSETUFLAG(wwin, full_maximize, WMGetButtonSelected(panel->attrChk[10])); /* Attributes... --> Advanced Options */ WSETUFLAG(wwin, no_bind_keys, WMGetButtonSelected(panel->moreChk[0])); WSETUFLAG(wwin, no_bind_mouse, WMGetButtonSelected(panel->moreChk[1])); skip_window_list = WMGetButtonSelected(panel->moreChk[2]); WSETUFLAG(wwin, skip_switchpanel, WMGetButtonSelected(panel->moreChk[3])); WSETUFLAG(wwin, no_focusable, WMGetButtonSelected(panel->moreChk[4])); WSETUFLAG(wwin, dont_move_off, WMGetButtonSelected(panel->moreChk[5])); WSETUFLAG(wwin, no_hide_others, WMGetButtonSelected(panel->moreChk[6])); WSETUFLAG(wwin, dont_save_session, WMGetButtonSelected(panel->moreChk[7])); WSETUFLAG(wwin, emulate_appicon, WMGetButtonSelected(panel->moreChk[8])); WSETUFLAG(wwin, focus_across_wksp, WMGetButtonSelected(panel->moreChk[9])); WSETUFLAG(wwin, no_miniaturizable, WMGetButtonSelected(panel->moreChk[10])); #ifdef XKB_BUTTON_HINT WSETUFLAG(wwin, no_language_button, WMGetButtonSelected(panel->moreChk[11])); #endif WSETUFLAG(wwin, always_user_icon, WMGetButtonSelected(panel->alwChk)); if (WFLAGP(wwin, no_titlebar) && wwin->flags.shaded) wUnshadeWindow(wwin); WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar)); if (floating) { if (!WFLAGP(wwin, floating)) ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); } else if (sunken) { if (!WFLAGP(wwin, sunken)) ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); } else { if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken)) ChangeStackingLevel(wwin->frame->core, WMNormalLevel); } WSETUFLAG(wwin, sunken, sunken); WSETUFLAG(wwin, floating, floating); wwin->flags.omnipresent = 0; if (WFLAGP(wwin, skip_window_list) != skip_window_list) { WSETUFLAG(wwin, skip_window_list, skip_window_list); UpdateSwitchMenu(wwin->screen_ptr, wwin, skip_window_list ? ACTION_REMOVE : ACTION_ADD); } else { if (WFLAGP(wwin, omnipresent) != old_omnipresent) WMPostNotificationName(WMNChangedState, wwin, "omnipresent"); } if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) { if (WFLAGP(wwin, no_bind_keys)) XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); else wWindowSetKeyGrabs(wwin); } if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) wWindowResetMouseGrabs(wwin); wwin->frame->flags.need_texture_change = 1; wWindowConfigureBorders(wwin); wFrameWindowPaint(wwin->frame); wNETWMUpdateActions(wwin, False); /* Can't apply emulate_appicon because it will probably cause problems. */ if (wapp) { /* do application wide stuff */ WSETUFLAG(wapp->main_window_desc, start_hidden, WMGetButtonSelected(panel->appChk[0])); WSETUFLAG(wapp->main_window_desc, no_appicon, WMGetButtonSelected(panel->appChk[1])); WSETUFLAG(wapp->main_window_desc, shared_appicon, WMGetButtonSelected(panel->appChk[2])); if (WFLAGP(wapp->main_window_desc, no_appicon)) unpaint_app_icon(wapp); else paint_app_icon(wapp); char *file = WMGetTextFieldText(panel->fileText); if (file[0] == 0) { wfree(file); file = NULL; } /* If always_user_icon flag is set, but the user icon is not set * we use client supplied icon and we unset the flag */ if ((WFLAGP(wwin, always_user_icon) && (!file))) { /* Show the warning */ char *buf; int len = 100; buf = wmalloc(len); snprintf(buf, len, _("Ignore client supplied icon is set, but icon filename textbox is empty. Using client supplied icon")); wMessageDialog(panel->frame->screen_ptr, _("Warning"), buf, _("OK"), NULL, NULL); wfree(buf); wfree(file); /* Change the flags */ WSETUFLAG(wwin, always_user_icon, 0); WMSetButtonSelected(panel->alwChk, 0); } /* After test the always_user_icon flag value before, * the "else" block is used only if the flag is set and * the icon text box has an icon path */ if (!WFLAGP(wwin, always_user_icon)) { /* Change App Icon image, using the icon provided by the client */ if (wapp->app_icon) { RImage *image = get_rimage_icon_from_wm_hints(wapp->app_icon->icon); if (image) { set_icon_image_from_image(wapp->app_icon->icon, image); update_icon_pixmap(wapp->app_icon->icon); } else { wIconUpdate(wapp->app_icon->icon); } } /* Change icon image if the app is minimized, * using the icon provided by the client */ if (wwin->icon) { RImage *image = get_rimage_icon_from_wm_hints(wwin->icon); if (image) { set_icon_image_from_image(wwin->icon, image); update_icon_pixmap(wwin->icon); } else { wIconUpdate(wwin->icon); } } } else { /* Change App Icon image */ if (wapp->app_icon) wIconChangeImageFile(wapp->app_icon->icon, file); /* Change icon image if the app is minimized */ if (wwin->icon) wIconChangeImageFile(wwin->icon, file); } if (file) wfree(file); } wNETFrameExtents(wwin); }
static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, const char *wm_instance, const char *wm_class, int flags) { WMPixmap *pixmap = (WMPixmap *) NULL; char *file = NULL, *path = NULL; if ((flags & USE_TEXT_FIELD) != 0) { file = WMGetTextFieldText(panel->fileText); if (file && file[0] == 0) { wfree(file); file = NULL; } } else if (flags & REVERT_TO_DEFAULT) { const char *db_icon; /* Get the application icon, default NOT included */ db_icon = wDefaultGetIconFile(wm_instance, wm_class, False); if (db_icon != NULL) { file = wstrdup(db_icon); flags |= UPDATE_TEXT_FIELD; } } if ((flags & UPDATE_TEXT_FIELD) != 0) WMSetTextFieldText(panel->fileText, file); if (file) { path = FindImage(wPreferences.icon_path, file); if (!path) { char *buf; int len = strlen(file) + 80; buf = wmalloc(len); snprintf(buf, len, _("Could not find icon \"%s\" specified for this window"), file); wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, _("OK"), NULL, NULL); wfree(buf); wfree(file); return -1; } pixmap = WMCreatePixmapFromFile(scrPtr, path); wfree(path); if (!pixmap) { char *buf; int len = strlen(file) + 80; buf = wmalloc(len); snprintf(buf, len, _("Could not open specified icon \"%s\":%s"), file, RMessageForError(RErrorCode)); wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, _("OK"), NULL, NULL); wfree(buf); wfree(file); return -1; } wfree(file); } WMSetLabelImage(panel->iconLbl, pixmap); if (pixmap) WMReleasePixmap(pixmap); return 0; }
static void panelBtnCallback(WMWidget * self, void *data) { WMButton *btn = self; AppSettingsPanel *panel = (AppSettingsPanel *) data; char *text; int done = 1; if (panel->okBtn == btn) { text = WMGetTextFieldText(panel->iconField); if (text[0] == 0) { wfree(text); text = NULL; } if (!wIconChangeImageFile(panel->editedIcon->icon, text)) { char *buf; int len = strlen(text) + 64; buf = wmalloc(len); snprintf(buf, len, _("Could not open specified icon file: %s"), text); if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf, _("OK"), _("Ignore"), NULL) == WAPRDefault) { if (text) wfree(text); wfree(buf); return; } wfree(buf); } else { WAppIcon *aicon = panel->editedIcon; // Cf dock.c:dockIconPaint(WAppIcon *aicon)? if (aicon == aicon->icon->core->screen_ptr->clip_icon) wClipIconPaint(aicon); else if (wIsADrawer(aicon->icon->core->screen_ptr, aicon)) wDrawerIconPaint(aicon); else wAppIconPaint(aicon); wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, aicon->wm_class, text); } if (text) wfree(text); /* cannot free text from this, because it will be not be duplicated * in updateCommand */ text = WMGetTextFieldText(panel->commandField); if (text[0] == 0) { wfree(text); text = NULL; } updateCommand(panel->editedIcon, text); #ifdef XDND /* cannot free text from this, because it will be not be duplicated * in updateDNDCommand */ text = WMGetTextFieldText(panel->dndCommandField); updateDNDCommand(panel->editedIcon, text); #endif text = WMGetTextFieldText(panel->pasteCommandField); updatePasteCommand(panel->editedIcon, text); panel->editedIcon->auto_launch = WMGetButtonSelected(panel->autoLaunchBtn); panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn); } if (done) DestroyDockAppSettingsPanel(panel); }