WAppIcon* wAppIconCreate(WWindow *leader_win) { WAppIcon *aicon; WScreen *scr = leader_win->screen_ptr; aicon = wmalloc(sizeof(WAppIcon)); wretain(aicon); memset(aicon, 0, sizeof(WAppIcon)); aicon->yindex = -1; aicon->xindex = -1; aicon->prev = NULL; aicon->next = scr->app_icon_list; if (scr->app_icon_list) { scr->app_icon_list->prev = aicon; } scr->app_icon_list = aicon; if (leader_win->wm_class) aicon->wm_class = wstrdup(leader_win->wm_class); if (leader_win->wm_instance) aicon->wm_instance = wstrdup(leader_win->wm_instance); aicon->icon = wIconCreate(leader_win); #ifdef DEMATERIALIZE_ICON { XSetWindowAttributes attribs; attribs.save_under = True; XChangeWindowAttributes(dpy, aicon->icon->core->window, CWSaveUnder, &attribs); } #endif #ifdef XDND wXDNDMakeAwareness(aicon->icon->core->window); #endif /* will be overriden if docked */ aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown; aicon->icon->core->descriptor.handle_expose = iconExpose; aicon->icon->core->descriptor.parent_type = WCLASS_APPICON; aicon->icon->core->descriptor.parent = aicon; AddToStackList(aicon->icon->core); aicon->icon->show_title = 0; wIconUpdate(aicon->icon); return aicon; }
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 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 WAppIcon *dock_icon_create_core(virtual_screen *vscr, char *command, char *wm_class, char *wm_instance) { WAppIcon *btn; btn = wmalloc(sizeof(WAppIcon)); wretain(btn); btn->icon = icon_create_core(vscr); if (command) btn->command = wstrdup(command); if (wm_class) btn->wm_class = wstrdup(wm_class); if (wm_instance) btn->wm_instance = wstrdup(wm_instance); set_icon_image_from_database(btn->icon, btn->wm_instance, btn->wm_class, btn->command); return btn; }
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); }
WAppIcon* wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) { WAppIcon *dicon; char *path; dicon = wmalloc(sizeof(WAppIcon)); wretain(dicon); memset(dicon, 0, sizeof(WAppIcon)); dicon->yindex = -1; dicon->xindex = -1; dicon->prev = NULL; dicon->next = scr->app_icon_list; if (scr->app_icon_list) { scr->app_icon_list->prev = dicon; } scr->app_icon_list = dicon; if (command) { dicon->command = wstrdup(command); } if (wm_class) dicon->wm_class = wstrdup(wm_class); if (wm_instance) dicon->wm_instance = wstrdup(wm_instance); path = wDefaultGetIconFile(scr, wm_instance, wm_class, True); if (!path && command) { wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class); path = wDefaultGetIconFile(scr, wm_instance, wm_class, False); } if (path) path = FindImage(wPreferences.icon_path, path); dicon->icon = wIconCreateWithIconFile(scr, path, tile); if (path) wfree(path); #ifdef XDND wXDNDMakeAwareness(dicon->icon->core->window); #endif #ifdef DEMATERIALIZE_ICON { XSetWindowAttributes attribs; attribs.save_under = True; XChangeWindowAttributes(dpy, dicon->icon->core->window, CWSaveUnder, &attribs); } #endif /* will be overriden by dock */ dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown; dicon->icon->core->descriptor.handle_expose = iconExpose; dicon->icon->core->descriptor.parent_type = WCLASS_APPICON; dicon->icon->core->descriptor.parent = dicon; AddToStackList(dicon->icon->core); return dicon; }
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; } }