diff --git a/WPrefs.app/Icons.c b/WPrefs.app/Icons.c index 798b5b48..74329642 100644 --- a/WPrefs.app/Icons.c +++ b/WPrefs.app/Icons.c @@ -66,6 +66,10 @@ typedef struct _Panel { WMFrame *posVF; WMFrame *posV; + struct { + int width, height; + } icon_position; + WMButton *posB[wlengthof_nocheck(icon_position_dbvalue)]; WMFrame *animF; @@ -76,12 +80,28 @@ typedef struct _Panel { WMButton *omnB; WMButton *sclB; + struct { + WMFrame *frame; + WMSlider *slider; + WMLabel *label; + } apercu; + WMFrame *sizeF; WMPopUpButton *sizeP; int iconPos; } _Panel; +/* + * Minimum size for an Apercu: + * This value is actually twice the size of the minimum icon size choosable. + * We set the slider min to taht number minus one, because when set to this + * value WPrefs will consider that the user wants the feature turned off. + */ +static const int apercu_minimum_size = 2 * 24 - 1; + +static const int apercu_maximum_size = 512; /* Arbitrary limit for the slider */ + #define ICON_FILE "iconprefs" static void showIconLayout(WMWidget * widget, void *data) @@ -111,21 +131,44 @@ static void showIconLayout(WMWidget * widget, void *data) WMMoveWidget(panel->posV, 2, 2); break; case 2: - WMMoveWidget(panel->posV, 95 - 2 - w, 2); + WMMoveWidget(panel->posV, panel->icon_position.width - 2 - w, 2); break; case 4: - WMMoveWidget(panel->posV, 2, 70 - 2 - h); + WMMoveWidget(panel->posV, 2, panel->icon_position.height - 2 - h); break; default: - WMMoveWidget(panel->posV, 95 - 2 - w, 70 - 2 - h); + WMMoveWidget(panel->posV, panel->icon_position.width - 2 - w, panel->icon_position.height - 2 - h); break; } } +static void apercu_slider_changed(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel *) data; + char buffer[64]; + int value; + + /* Parameter is not used, but tell the compiler that it is ok */ + (void) w; + + value = WMGetSliderValue(panel->apercu.slider); + + /* Round the value to a multiple of 8 because it makes the displayed value look better */ + value &= ~7; + + if (value <= apercu_minimum_size) + sprintf(buffer, _("OFF")); + else + sprintf(buffer, "%i", value); + + WMSetLabelText(panel->apercu.label, buffer); +} + static void showData(_Panel * panel) { int i; char *str; + Bool b; WMSetButtonSelected(panel->arrB, GetBoolForKey("AutoArrangeIcons")); WMSetButtonSelected(panel->omnB, GetBoolForKey("StickyIcons")); @@ -154,6 +197,19 @@ static void showData(_Panel * panel) i = 9; WMSetPopUpButtonSelectedItem(panel->sizeP, i); + /* Apercu */ + b = GetBoolForKey("MiniwindowApercuBalloons"); + if (b) { + i = GetIntegerForKey("ApercuSize"); + if (i <= apercu_minimum_size) + i = apercu_minimum_size; + } else { + i = apercu_minimum_size; + } + WMSetSliderValue(panel->apercu.slider, i); + apercu_slider_changed(panel->apercu.slider, panel); + + /* Animation */ str = GetStringForKey("IconificationStyle"); if (str != NULL) { for (i = 0; i < wlengthof(icon_animation); i++) { @@ -174,50 +230,87 @@ static void showData(_Panel * panel) static void createPanel(Panel * p) { _Panel *panel = (_Panel *) p; + WMScreen *scr; WMColor *color; int i; char buf[16]; + int swidth, sheight; + int width, height; + int startx, starty; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /***************** Positioning of Icons *****************/ panel->posF = WMCreateFrame(panel->box); - WMResizeWidget(panel->posF, 210, 140); - WMMoveWidget(panel->posF, 20, 10); + WMResizeWidget(panel->posF, 268, 155); + WMMoveWidget(panel->posF, 12, 6); WMSetFrameTitle(panel->posF, _("Icon Positioning")); + /* + * There is an available area of 240 x 122, starting at x=14 y=20 + * We have to keep 14 pixels on each side for the buttons, + * and an extra pixel for spacing. We also want the final dimension + * to be an even number so we can have the 2 buttons per side of + * the same size. + * In this area, we want to have a rectangle with the same aspect + * ratio as the screen. + */ + scr = WMWidgetScreen(panel->parent); + swidth = WidthOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr))); + sheight = HeightOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr))); + + width = swidth * (122 - 15 * 2) / sheight; + if (width <= (240 - 15 * 2)) { + height = 122 - 15 * 2; + } else { + width = 240 - 15 * 2; + height = sheight * (240 - 15 * 2) / swidth; + } + + panel->icon_position.width = width; + panel->icon_position.height = height; + + startx = 14 + (240 - 15 * 2 - width) / 2; + starty = 20 + (122 - 15 * 2 - height) / 2; + for (i = 0; i < wlengthof(icon_position_dbvalue); i++) { + int x, y, w, h; + panel->posB[i] = WMCreateButton(panel->posF, WBTOnOff); WMSetButtonAction(panel->posB[i], showIconLayout, panel); if (i > 0) WMGroupButtons(panel->posB[0], panel->posB[i]); + + if (i & 1) { /* 0=Vertical, 1=Horizontal */ + w = width / 2; + h = 14; + } else { + w = 14; + h = height / 2; + } + WMResizeWidget(panel->posB[i], w, h); + + x = startx; + y = starty; + switch (i) { + case 0: x += 0; y += 15; break; + case 1: x += 15; y += 0; break; + case 2: x += 15 + width; y += 15; break; + case 3: x += 15 + w; y += 0; break; + case 4: x += 0; y += 15 + h; break; + case 5: x += 15; y += 15 + height; break; + case 6: x += 15 + width; y += 15 + h; break; + case 7: x += 15 + w; y += 15 + height; break; + } + WMMoveWidget(panel->posB[i], x, y); } - WMMoveWidget(panel->posB[1], 58, 25); - WMResizeWidget(panel->posB[1], 47, 15); - WMMoveWidget(panel->posB[3], 58 + 47, 25); - WMResizeWidget(panel->posB[3], 47, 15); - - WMMoveWidget(panel->posB[0], 43, 40); - WMResizeWidget(panel->posB[0], 15, 35); - WMMoveWidget(panel->posB[4], 43, 40 + 35); - WMResizeWidget(panel->posB[4], 15, 35); - - WMMoveWidget(panel->posB[5], 58, 40 + 70); - WMResizeWidget(panel->posB[5], 47, 15); - WMMoveWidget(panel->posB[7], 58 + 47, 40 + 70); - WMResizeWidget(panel->posB[7], 47, 15); - - WMMoveWidget(panel->posB[2], 58 + 95, 40); - WMResizeWidget(panel->posB[2], 15, 35); - WMMoveWidget(panel->posB[6], 58 + 95, 40 + 35); - WMResizeWidget(panel->posB[6], 15, 35); color = WMCreateRGBColor(WMWidgetScreen(panel->parent), 0x5100, 0x5100, 0x7100, True); panel->posVF = WMCreateFrame(panel->posF); - WMResizeWidget(panel->posVF, 95, 70); - WMMoveWidget(panel->posVF, 58, 40); + WMResizeWidget(panel->posVF, width, height); + WMMoveWidget(panel->posVF, startx + 15, starty + 15); WMSetFrameRelief(panel->posVF, WRSunken); WMSetWidgetBackgroundColor(panel->posVF, color); WMReleaseColor(color); @@ -229,16 +322,16 @@ static void createPanel(Panel * p) /***************** Icon Size ****************/ panel->sizeF = WMCreateFrame(panel->box); - WMResizeWidget(panel->sizeF, 210, 70); - WMMoveWidget(panel->sizeF, 20, 155); + WMResizeWidget(panel->sizeF, 100, 52); + WMMoveWidget(panel->sizeF, 12, 168); WMSetFrameTitle(panel->sizeF, _("Icon Size")); WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"), WMWidgetView(panel->sizeF)); panel->sizeP = WMCreatePopUpButton(panel->sizeF); - WMResizeWidget(panel->sizeP, 161, 20); - WMMoveWidget(panel->sizeP, 25, 30); + WMResizeWidget(panel->sizeP, 80, 20); + WMMoveWidget(panel->sizeP, 10, 19); for (i = 24; i <= 96; i += 8) { sprintf(buf, "%ix%i", i, i); WMAddPopUpButtonItem(panel->sizeP, buf); @@ -246,16 +339,40 @@ static void createPanel(Panel * p) WMMapSubwidgets(panel->sizeF); + /***************** Apercu ****************/ + panel->apercu.frame = WMCreateFrame(panel->box); + WMResizeWidget(panel->apercu.frame, 156, 52); + WMMoveWidget(panel->apercu.frame, 124, 168); + WMSetFrameTitle(panel->apercu.frame, _("Miniwindow aperçus")); + + WMSetBalloonTextForView(_("The Aperçu provides a small view of the content of the\n" + "window when the mouse is placed over the icon."), + WMWidgetView(panel->apercu.frame)); + + panel->apercu.slider = WMCreateSlider(panel->apercu.frame); + WMResizeWidget(panel->apercu.slider, 109, 15); + WMMoveWidget(panel->apercu.slider, 11, 23); + WMSetSliderMinValue(panel->apercu.slider, apercu_minimum_size); + WMSetSliderMaxValue(panel->apercu.slider, apercu_maximum_size); + WMSetSliderAction(panel->apercu.slider, apercu_slider_changed, panel); + + panel->apercu.label = WMCreateLabel(panel->apercu.frame); + WMResizeWidget(panel->apercu.label, 33, 15); + WMMoveWidget(panel->apercu.label, 120, 23); + WMSetLabelText(panel->apercu.label, _("OFF")); + + WMMapSubwidgets(panel->apercu.frame); + /***************** Animation ****************/ panel->animF = WMCreateFrame(panel->box); - WMResizeWidget(panel->animF, 260, 110); - WMMoveWidget(panel->animF, 240, 10); + WMResizeWidget(panel->animF, 215, 110); + WMMoveWidget(panel->animF, 292, 6); WMSetFrameTitle(panel->animF, _("Iconification Animation")); for (i = 0; i < wlengthof(icon_animation); i++) { panel->animB[i] = WMCreateRadioButton(panel->animF); - WMResizeWidget(panel->animB[i], 145, 20); - WMMoveWidget(panel->animB[i], 15, 18 + i * 22); + WMResizeWidget(panel->animB[i], 192, 20); + WMMoveWidget(panel->animB[i], 12, 16 + i * 22); if (i > 0) WMGroupButtons(panel->animB[0], panel->animB[i]); @@ -267,27 +384,27 @@ static void createPanel(Panel * p) /***************** Options ****************/ panel->optF = WMCreateFrame(panel->box); - WMResizeWidget(panel->optF, 260, 95); - WMMoveWidget(panel->optF, 240, 130); + WMResizeWidget(panel->optF, 215, 90); + WMMoveWidget(panel->optF, 292, 130); /* WMSetFrameTitle(panel->optF, _("Icon Display")); */ panel->arrB = WMCreateSwitchButton(panel->optF); - WMResizeWidget(panel->arrB, 235, 20); - WMMoveWidget(panel->arrB, 15, 10); + WMResizeWidget(panel->arrB, 198, 20); + WMMoveWidget(panel->arrB, 12, 10); WMSetButtonText(panel->arrB, _("Auto-arrange icons")); WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."), WMWidgetView(panel->arrB)); panel->omnB = WMCreateSwitchButton(panel->optF); - WMResizeWidget(panel->omnB, 235, 20); - WMMoveWidget(panel->omnB, 15, 37); + WMResizeWidget(panel->omnB, 198, 20); + WMMoveWidget(panel->omnB, 12, 35); WMSetButtonText(panel->omnB, _("Omnipresent miniwindows")); WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."), WMWidgetView(panel->omnB)); panel->sclB = WMCreateSwitchButton(panel->optF); - WMResizeWidget(panel->sclB, 235, 28); - WMMoveWidget(panel->sclB, 15, 60); + WMResizeWidget(panel->sclB, 198, 28); + WMMoveWidget(panel->sclB, 12, 56); WMSetButtonText(panel->sclB, _("Single click activation")); WMSetBalloonTextForView(_("Launch applications and restore windows with a single click."), WMWidgetView(panel->sclB)); @@ -312,6 +429,22 @@ static void storeData(_Panel * panel) SetStringForKey(icon_position_dbvalue[panel->iconPos], "IconPosition"); + i = WMGetSliderValue(panel->apercu.slider); + if (i <= apercu_minimum_size) { + SetBoolForKey(False, "MiniwindowApercuBalloons"); + } else { + SetBoolForKey(True, "MiniwindowApercuBalloons"); + if (i < apercu_maximum_size) { + /* + * If the value is bigger, it means it was edited by the user manually + * so we keep as-is. Otherwise, we round it to a multiple of 8 like it + * was done for display + */ + i &= ~7; + } + SetIntegerForKey(i, "ApercuSize"); + } + for (i = 0; i < wlengthof(icon_animation); i++) { if (WMGetButtonSelected(panel->animB[i])) { SetStringForKey(icon_animation[i].db_value, "IconificationStyle"); diff --git a/WPrefs.app/Preferences.c b/WPrefs.app/Preferences.c index dfa04272..57f94461 100644 --- a/WPrefs.app/Preferences.c +++ b/WPrefs.app/Preferences.c @@ -52,7 +52,6 @@ static const struct { } balloon_choices[] = { { "WindowTitleBalloons", N_("incomplete window titles"), }, { "MiniwindowTitleBalloons", N_("miniwindow titles"), }, - { "MiniwindowApercuBalloons", N_("miniwindow apercus"), }, { "AppIconBalloons", N_("application/dock icons"), }, { "HelpBalloons", N_("internal help"), } }; @@ -266,14 +265,14 @@ static void createPanel(Panel * p) /***************** Balloon Text ****************/ panel->ballF = WMCreateFrame(panel->box); - WMResizeWidget(panel->ballF, 220, 132); + WMResizeWidget(panel->ballF, 220, 130); WMMoveWidget(panel->ballF, 285, 7); WMSetFrameTitle(panel->ballF, _("Show balloon for...")); for (i = 0; i < wlengthof(balloon_choices); i++) { panel->ballB[i] = WMCreateSwitchButton(panel->ballF); WMResizeWidget(panel->ballB[i], 198, 20); - WMMoveWidget(panel->ballB[i], 11, 16 + i * 22); + WMMoveWidget(panel->ballB[i], 11, 20 + i * 26); WMSetButtonText(panel->ballB[i], _(balloon_choices[i].label)); } diff --git a/WPrefs.app/po/nl.po b/WPrefs.app/po/nl.po index 1723ea55..25ceb801 100644 --- a/WPrefs.app/po/nl.po +++ b/WPrefs.app/po/nl.po @@ -1892,8 +1892,8 @@ msgid "miniwindow titles" msgstr "minivenster-titels" #: ../../WPrefs.app/Preferences.c:31 -msgid "miniwindow apercus" -msgstr "minivenster-voorbeelden" +msgid "Miniwindow aperçus" +msgstr "Minivenster-voorbeelden" #: ../../WPrefs.app/Preferences.c:32 msgid "application/dock icons"