Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
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);
}