Exemplo n.º 1
0
static void storeData(_Panel * panel)
{
	char buffer[64];
	int i;
	char *tmp, *p;
	WMUserDefaults *udb = WMGetStandardUserDefaults();

	if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
		tmp = WMGetTextFieldText(panel->threT);
		if (strlen(tmp) == 0) {
			wfree(tmp);
			tmp = wstrdup("4");
		}

		sprintf(buffer, XSET " m %i/%i %s\n", (int)(panel->acceleration * 10), 10, tmp);
		storeCommandInScript(XSET " m", buffer);

		wfree(tmp);
	}

	tmp = WMGetTextFieldText(panel->ddelaT);
	if (sscanf(tmp, "%i", &i) == 1 && i > 0)
		SetIntegerForKey(i, "DoubleClickTime");
	wfree(tmp);

	SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");

	for (i = 0; i < wlengthof(button_list); i++) {
		const char *db_value;
		int action;

		action = WMGetPopUpButtonSelectedItem(panel->mouse_action[i].popup);
		if (button_list[i].type == T_BUTTON)
			db_value = button_actions[action].db_value;
		else
			db_value = wheel_actions[action].db_value;
		SetStringForKey(db_value, button_list[i].db_key);
	}

	tmp = WMGetPopUpButtonItem(panel->grabP, WMGetPopUpButtonSelectedItem(panel->grabP));
	tmp = wstrdup(tmp);
	p = strchr(tmp, ' ');
	if (p != NULL)
		*p = '\0';

	SetStringForKey(tmp, "ModifierKey");

	wfree(tmp);
}
Exemplo n.º 2
0
static void browseForFile(WMWidget * self, void *clientData)
{
	_Panel *panel = (_Panel *) clientData;
	WMFilePanel *filePanel;
	char *text, *oldprog, *newprog;

	filePanel = WMGetOpenPanel(WMWidgetScreen(self));
	text = WMGetTextFieldText(panel->commandT);

	oldprog = wtrimspace(text);
	wfree(text);

	if (oldprog[0] == 0 || oldprog[0] != '/') {
		wfree(oldprog);
		oldprog = wstrdup("/");
	} else {
		char *ptr = oldprog;
		while (*ptr && !isspace(*ptr))
			ptr++;
		*ptr = 0;
	}

	WMSetFilePanelCanChooseDirectories(filePanel, False);

	if (WMRunModalFilePanelForDirectory(filePanel, panel->parent, oldprog, _("Select Program"), NULL) == True) {
		newprog = WMGetFilePanelFileName(filePanel);
		WMSetTextFieldText(panel->commandT, newprog);
		updateMenuItem(panel, panel->currentItem, panel->commandT);
		wfree(newprog);
	}

	wfree(oldprog);
}
Exemplo n.º 3
0
Arquivo: Focus.c Projeto: jafd/wmaker
static void storeData(_Panel * panel)
{
	char *str;
	int i;

	if (WMGetButtonSelected(panel->kfocB[1]))
		str = "sloppy";
	else
		str = "manual";

	SetStringForKey(str, "FocusMode");

	if (WMGetButtonSelected(panel->manB)) {
		SetStringForKey("manual", "ColormapMode");
	} else {
		SetStringForKey("auto", "ColormapMode");
	}

	str = WMGetTextFieldText(panel->raisT);
	if (sscanf(str, "%i", &i) != 1)
		i = 0;
	SetIntegerForKey(i, "RaiseDelay");

	SetBoolForKey(WMGetButtonSelected(panel->ignB), "IgnoreFocusClick");
	SetBoolForKey(WMGetButtonSelected(panel->newB), "AutoFocus");
	SetBoolForKey(WMGetButtonSelected(panel->craisB), "CirculateRaise");
}
Exemplo n.º 4
0
static void speedChange(WMWidget * w, void *data)
{
	_Panel *panel = (_Panel *) data;
	int i;
	char buffer[64];
	int threshold;
	char *tmp;

	if (w == NULL) {
		float accel;

		tmp = WMGetTextFieldText(panel->acceT);
		if (sscanf(tmp, "%f", &accel) != 1 || accel < 0) {
			WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(),
					_("Error"),
					_("Invalid mouse acceleration value. Must be a positive real value."),
					_("OK"), NULL, NULL);
			wfree(tmp);
			return;
		}
		panel->acceleration = accel;
		wfree(tmp);
	} else {
		i = (int)WMGetSliderValue(panel->speedS);

		panel->acceleration = 0.25 + (i * 0.25);

		sprintf(buffer, "%.2f", 0.25 + (i * 0.25));
		WMSetTextFieldText(panel->acceT, buffer);
	}

	tmp = WMGetTextFieldText(panel->threT);
	if (sscanf(tmp, "%i", &threshold) != 1 || threshold < 0 || threshold > panel->maxThreshold) {
		WMRunAlertPanel(WMWidgetScreen(panel->parent), GetWindow(), _("Error"),
				_
				("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."),
				_("OK"), NULL, NULL);
	} else {
		setMouseAccel(WMWidgetScreen(panel->parent), panel->acceleration, threshold);
	}
	wfree(tmp);
}
Exemplo n.º 5
0
Arquivo: Docks.c Projeto: jafd/wmaker
static void storeData(_Panel *panel)
{
	int i;
	for (i = 0; i < 4; i++)
	{
		SetStringForKey(WMGetTextFieldText(panel->autoDelayT[i]), auto_delay[i].key);
	}
	for (i = 0; i < 3; i++)
	{
		SetBoolForKey(!WMGetButtonSelected(panel->docksB[i]), dock_config[i].disable_key);
	}
}
Exemplo n.º 6
0
Arquivo: Docks.c Projeto: jafd/wmaker
static void autoDelayChanged(void *observerData, WMNotification *notification)
{
	_Panel *panel = (_Panel *) observerData;
	int row;
	WMTextField *anAutoDelayT = (WMTextField *) WMGetNotificationObject(notification);
	for (row = 0; row < 4; row++)
	{
		if (anAutoDelayT != panel->autoDelayT[row])
		{
			continue;
		}
		char *value = WMGetTextFieldText(anAutoDelayT);
		adjustButtonSelectionBasedOnValue(panel, row, value);
		return;
	}
}
Exemplo n.º 7
0
static void updateSettingsPanelIcon(AppSettingsPanel * panel)
{
	char *file;

	file = WMGetTextFieldText(panel->iconField);
	if (!file)
		WMSetLabelImage(panel->iconLabel, NULL);
	else {
		char *path;

		path = FindImage(wPreferences.icon_path, file);
		if (!path) {
			wwarning(_("could not find icon %s, used in a docked application"), file);
			wfree(file);
			WMSetLabelImage(panel->iconLabel, NULL);
			return;
		} else {
			WMPixmap *pixmap;
			RColor color;

			color.red = 0xae;
			color.green = 0xaa;
			color.blue = 0xae;
			color.alpha = 0;
			pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color);
			if (!pixmap) {
				WMSetLabelImage(panel->iconLabel, NULL);
			} else {
				WMSetLabelImage(panel->iconLabel, pixmap);
				WMReleasePixmap(pixmap);
			}
		}
		wfree(file);
		wfree(path);
	}
}
Exemplo n.º 8
0
static void updateMenuItem(_Panel * panel, WEditMenuItem * item, WMWidget * changedWidget)
{
	ItemData *data = WGetEditMenuItemData(item);

	assert(data != NULL);

#define REPLACE(v, d) if (v) wfree(v); v = d

	switch (data->type) {
	case ExecInfo:
		if (changedWidget == panel->commandT) {
			REPLACE(data->param.exec.command, WMGetTextFieldText(panel->commandT));
		}
		if (changedWidget == panel->shortT) {
			REPLACE(data->param.exec.shortcut, WMGetTextFieldText(panel->shortT));
		}
		break;

	case CommandInfo:
		if (changedWidget == panel->icommandL) {
			data->param.command.command = WMGetListSelectedItemRow(panel->icommandL);
		}
		switch (data->param.command.command) {
		case 3:
		case 4:
			if (changedWidget == panel->quickB) {
				REPLACE(data->param.command.parameter, WMGetButtonSelected(panel->quickB)
					? wstrdup("QUICK") : NULL);
			}
			break;

		case 6:
			if (changedWidget == panel->paramT) {
				REPLACE(data->param.command.parameter, WMGetTextFieldText(panel->paramT));
			}
			break;
		}
		if (changedWidget == panel->shortT) {
			REPLACE(data->param.command.shortcut, WMGetTextFieldText(panel->shortT));
		}

		break;

	case PipeInfo:
		if (changedWidget == panel->pipeT) {
			REPLACE(data->param.pipe.command, WMGetTextFieldText(panel->pipeT));
		}
		if (changedWidget == panel->pipeCacheB) {
			data->param.pipe.cached = WMGetButtonSelected(panel->pipeCacheB);
		}
		break;

	case PLPipeInfo:
		if (changedWidget == panel->plpipeT) {
			REPLACE(data->param.pipe.command, WMGetTextFieldText(panel->plpipeT));
		}
		if (changedWidget == panel->plpipeCacheB) {
			data->param.pipe.cached = WMGetButtonSelected(panel->plpipeCacheB);
		}
		break;

	case ExternalInfo:
		if (changedWidget == panel->pathT) {
			REPLACE(data->param.external.path, WMGetTextFieldText(panel->pathT));
		}
		break;

	case DirectoryInfo:
		if (changedWidget == panel->dpathT) {
			REPLACE(data->param.directory.directory, WMGetTextFieldText(panel->dpathT));
		}
		if (changedWidget == panel->dcommandT) {
			REPLACE(data->param.directory.command, WMGetTextFieldText(panel->dcommandT));
		}
		if (changedWidget == panel->dstripB) {
			data->param.directory.stripExt = WMGetButtonSelected(panel->dstripB);
		}
		break;

	default:
		assert(0);
		break;
	}

#undef REPLACE
}
Exemplo n.º 9
0
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);
}
Exemplo n.º 10
0
static void saveSettings(WMWidget *button, void *client_data)
{
	InspectorPanel *panel = (InspectorPanel *) client_data;
	WWindow *wwin = panel->inspected;
	WDDomain *db = w_global.domain.window_attr;
	WMPropList *dict = NULL;
	WMPropList *winDic, *appDic, *value, *value1, *key = NULL, *key2;
	char *icon_file, *buf1, *buf2;
	int flags = 0, i = 0, different = 0, different2 = 0;

	/* Save will apply the changes and save them */
	applySettings(panel->applyBtn, panel);

	if (WMGetButtonSelected(panel->instRb) != 0) {
		key = WMCreatePLString(wwin->wm_instance);
	} else if (WMGetButtonSelected(panel->clsRb) != 0) {
		key = WMCreatePLString(wwin->wm_class);
	} else if (WMGetButtonSelected(panel->bothRb) != 0) {
		buf1 = StrConcatDot(wwin->wm_instance, wwin->wm_class);
		key = WMCreatePLString(buf1);
		wfree(buf1);
	} else if (WMGetButtonSelected(panel->defaultRb) != 0) {
		key = WMRetainPropList(AnyWindow);
		flags = UPDATE_DEFAULTS;
	}

	if (!key)
		return;

	dict = db->dictionary;
	if (!dict) {
		dict = WMCreatePLDictionary(NULL, NULL);
		if (dict) {
			db->dictionary = dict;
		} else {
			WMReleasePropList(key);
			return;
		}
	}

	if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD) < 0)
		return;

	WMPLSetCaseSensitive(True);

	winDic = WMCreatePLDictionary(NULL, NULL);
	appDic = WMCreatePLDictionary(NULL, NULL);

	/* Save the icon info */
	/* The flag "Ignore client suplied icon is not selected" */
	buf1 = wmalloc(4);
	snprintf(buf1, 4, "%s", (WMGetButtonSelected(panel->alwChk) != 0) ? "Yes" : "No");
	value1 = WMCreatePLString(buf1);
	different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value1, flags);
	WMReleasePropList(value1);
	wfree(buf1);

	/* The icon filename (if exists) */
	icon_file = WMGetTextFieldText(panel->fileText);
	if (icon_file != NULL) {
		if (icon_file[0] != '\0') {
			value = WMCreatePLString(icon_file);
			different |= insertAttribute(dict, winDic, AIcon, value, flags);
			different2 |= insertAttribute(dict, appDic, AIcon, value, flags);
			WMReleasePropList(value);
		}
		wfree(icon_file);
	}

	i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
	if (i >= 0 && i < w_global.workspace.count) {
		value = WMCreatePLString(w_global.workspace.array[i]->name);
		different |= insertAttribute(dict, winDic, AStartWorkspace, value, flags);
		WMReleasePropList(value);
	}

	flags |= IS_BOOLEAN;

	value = (WMGetButtonSelected(panel->attrChk[0]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoTitlebar, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[1]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoResizebar, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[2]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoCloseButton, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[3]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMiniaturizeButton, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[4]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoBorder, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[5]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepOnTop, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[6]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepOnBottom, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[7]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AOmnipresent, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[8]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AStartMiniaturized, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[9]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AStartMaximized, value, flags);

	value = (WMGetButtonSelected(panel->attrChk[10]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AFullMaximize, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[0]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoKeyBindings, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[1]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMouseBindings, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[2]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ASkipWindowList, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[3]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ASkipSwitchPanel, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[4]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AUnfocusable, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[5]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AKeepInsideScreen, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[6]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoHideOthers, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[7]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ADontSaveSession, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[8]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AEmulateAppIcon, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[9]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, AFocusAcrossWorkspace, value, flags);

	value = (WMGetButtonSelected(panel->moreChk[10]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoMiniaturizable, value, flags);

#ifdef XKB_BUTTON_HINT
	value = (WMGetButtonSelected(panel->moreChk[11]) != 0) ? Yes : No;
	different |= insertAttribute(dict, winDic, ANoLanguageButton, value, flags);
#endif

	if (wwin->main_window != None && wApplicationOf(wwin->main_window) != NULL) {
		value = (WMGetButtonSelected(panel->appChk[0]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, AStartHidden, value, flags);

		value = (WMGetButtonSelected(panel->appChk[1]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, ANoAppIcon, value, flags);

		value = (WMGetButtonSelected(panel->appChk[2]) != 0) ? Yes : No;
		different2 |= insertAttribute(dict, appDic, ASharedAppIcon, value, flags);
	}

	if (wwin->fake_group) {
		key2 = WMCreatePLString(wwin->fake_group->identifier);
		if (WMIsPropListEqualTo(key, key2)) {
			WMMergePLDictionaries(winDic, appDic, True);
			different |= different2;
		} else {
			WMRemoveFromPLDictionary(dict, key2);
			if (different2)
				WMPutInPLDictionary(dict, key2, appDic);
		}
		WMReleasePropList(key2);
	} else if (wwin->main_window != wwin->client_win) {
		WApplication *wapp = wApplicationOf(wwin->main_window);

		if (wapp) {
			buf2 = StrConcatDot(wapp->main_window_desc->wm_instance,
					      wapp->main_window_desc->wm_class);
			key2 = WMCreatePLString(buf2);
			wfree(buf2);

			if (WMIsPropListEqualTo(key, key2)) {
				WMMergePLDictionaries(winDic, appDic, True);
				different |= different2;
			} else {
				WMRemoveFromPLDictionary(dict, key2);
				if (different2)
					WMPutInPLDictionary(dict, key2, appDic);
			}
			WMReleasePropList(key2);
		}
	} else {
		WMMergePLDictionaries(winDic, appDic, True);
		different |= different2;
	}
	WMReleasePropList(appDic);

	WMRemoveFromPLDictionary(dict, key);
	if (different)
		WMPutInPLDictionary(dict, key, winDic);

	WMReleasePropList(key);
	WMReleasePropList(winDic);

	UpdateDomainFile(db);

	/* clean up */
	WMPLSetCaseSensitive(False);
}
Exemplo n.º 11
0
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;
}
Exemplo n.º 12
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);
}