Пример #1
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);
	}
}
Пример #2
0
static void createPanel(Panel * p)
{
	_Panel *panel = (_Panel *) p;
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WMPixmap *icon;
	char *buf1, *buf2;
	int i;
	RColor color;
	char *path;

	color.red = 0xae;
	color.green = 0xaa;
	color.blue = 0xae;

	panel->box = WMCreateBox(panel->parent);
	WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);

    /**************** Mouse Speed ****************/
	panel->speedF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->speedF, 219, 85);
	WMMoveWidget(panel->speedF, 9, 54);
	WMSetFrameTitle(panel->speedF, _("Mouse Speed"));

	panel->speedL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->speedL, 40, 46);
	WMMoveWidget(panel->speedL, 8, 10);
	WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
	path = LocateImage(SPEED_ICON_FILE);
	if (path) {
		icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
		if (icon) {
			WMSetLabelImage(panel->speedL, icon);
			WMReleasePixmap(icon);
		} else {
			wwarning(_("could not load icon %s"), path);
		}
		wfree(path);
	}

	panel->speedS = WMCreateSlider(panel->speedF);
	WMResizeWidget(panel->speedS, 150, 15);
	WMMoveWidget(panel->speedS, 58, 30);
	WMSetSliderMinValue(panel->speedS, 0);
	WMSetSliderMaxValue(panel->speedS, 40);
	WMSetSliderContinuous(panel->speedS, False);
	WMSetSliderAction(panel->speedS, speedChange, panel);

	panel->acceL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->acceL, 50, 16);
	WMMoveWidget(panel->acceL, 8, 58);
	WMSetLabelTextAlignment(panel->acceL, WARight);
	WMSetLabelText(panel->acceL, _("Accel.:"));

	panel->acceT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->acceT, 40, 20);
	WMMoveWidget(panel->acceT, 58, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT);

	panel->threL = WMCreateLabel(panel->speedF);
	WMResizeWidget(panel->threL, 80, 16);
	WMMoveWidget(panel->threL, 98, 58);
	WMSetLabelTextAlignment(panel->threL, WARight);
	WMSetLabelText(panel->threL, _("Threshold:"));

	panel->threT = WMCreateTextField(panel->speedF);
	WMResizeWidget(panel->threT, 30, 20);
	WMMoveWidget(panel->threT, 178, 56);
	WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT);

	WMMapSubwidgets(panel->speedF);

	/* ************** Grab Modifier **************** */
	panel->grabF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->grabF, 219, 46);
	WMMoveWidget(panel->grabF, 9, 5);
	WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));

	WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
				  "involve dragging windows with the mouse,\n"
				  "clicking inside the window."), WMWidgetView(panel->grabF));

	panel->grabP = WMCreatePopUpButton(panel->grabF);
	WMResizeWidget(panel->grabP, 178, 20);
	WMMoveWidget(panel->grabP, 20, 17);

	fillModifierPopUp(panel->grabP);
	WMMapSubwidgets(panel->grabF);

	/***************** Doubleclick Delay ****************/

	panel->ddelaF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->ddelaF, 219, 80);
	WMMoveWidget(panel->ddelaF, 9, 142);
	WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));

	buf1 = wmalloc(strlen(DELAY_ICON) + 2);
	buf2 = wmalloc(strlen(DELAY_ICON_S) + 2);

	for (i = 0; i < wlengthof(panel->ddelaB); i++) {
		panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask);
		WMResizeWidget(panel->ddelaB[i], 25, 25);
		WMMoveWidget(panel->ddelaB[i], 18 + (40 * i), 18);
		WMSetButtonBordered(panel->ddelaB[i], False);
		WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
		WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
		if (i > 0) {
			WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
		}
		sprintf(buf1, DELAY_ICON, i + 1);
		sprintf(buf2, DELAY_ICON_S, i + 1);
		path = LocateImage(buf1);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
		path = LocateImage(buf2);
		if (path) {
			icon = WMCreatePixmapFromFile(scr, path);
			if (icon) {
				WMSetButtonAltImage(panel->ddelaB[i], icon);
				WMReleasePixmap(icon);
			} else {
				wwarning(_("could not load icon file %s"), path);
			}
			wfree(path);
		}
	}
	wfree(buf1);
	wfree(buf2);

	panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
	WMResizeWidget(panel->tester, 84, 24);
	WMMoveWidget(panel->tester, 20, 48);

	panel->ddelaT = WMCreateTextField(panel->ddelaF);
	WMResizeWidget(panel->ddelaT, 40, 20);
	WMMoveWidget(panel->ddelaT, 130, 50);

	panel->ddelaL = WMCreateLabel(panel->ddelaF);
	WMResizeWidget(panel->ddelaL, 40, 16);
	WMMoveWidget(panel->ddelaL, 173, 54);
	{
		WMFont *font;
		WMColor *color;

		font = WMSystemFontOfSize(scr, 10);
		color = WMDarkGrayColor(scr);
		WMSetLabelTextColor(panel->ddelaL, color);
		WMSetLabelFont(panel->ddelaL, font);
		WMReleaseFont(font);
		WMReleaseColor(color);
	}
	WMSetLabelText(panel->ddelaL, _("ms"));

	WMMapSubwidgets(panel->ddelaF);

	/* ************** Workspace Action Buttons **************** */

	panel->menuF = WMCreateFrame(panel->box);
	WMResizeWidget(panel->menuF, 276, 217);
	WMMoveWidget(panel->menuF, 236, 5);
	WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));

	panel->disaB = WMCreateSwitchButton(panel->menuF);
	WMResizeWidget(panel->disaB, 254, 18);
	WMMoveWidget(panel->disaB, 10, 15);
	WMSetButtonText(panel->disaB, _("Disable mouse actions"));
	WMSetButtonAction(panel->disaB, toggle_disabling_of_mouse_actions, panel);

	for (i = 0; i < wlengthof(button_list); i++) {
		int j;

		panel->mouse_action[i].label = WMCreateLabel(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].label, 115, 20);
		WMMoveWidget(panel->mouse_action[i].label, 4, 37 + 25 * i);
		WMSetLabelTextAlignment(panel->mouse_action[i].label, WARight);
		WMSetLabelText(panel->mouse_action[i].label, _(button_list[i].display_label));

		panel->mouse_action[i].popup = WMCreatePopUpButton(panel->menuF);
		WMResizeWidget(panel->mouse_action[i].popup, 145, 20);
		WMMoveWidget(panel->mouse_action[i].popup, 121, 37 + 25 * i);

		if (button_list[i].type == T_BUTTON) {
			for (j = 0; j < wlengthof(button_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(button_actions[j].label));
		} else {
			for (j = 0; j < wlengthof(wheel_actions); j++)
				WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(wheel_actions[j].label));
		}
	}
	WMMapSubwidgets(panel->menuF);

	WMRealizeWidget(panel->box);
	WMMapSubwidgets(panel->box);

	showData(panel);
}
Пример #3
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;
}