[PATCH 1/2] WINGs: wpopupbutton add two functions to change the displayed item

2 views
Skip to first unread message

david.m...@gmail.com

unread,
Jan 24, 2026, 5:00:19 PM (9 days ago) Jan 24
to Window Maker Development
This patch is adding WMSelectPopUpButtonPreviousItem and
WMSelectPopUpButtonNextItem functions to the widget.
The WINGs lib version is bumped.
---
 WINGs/WINGs/WINGs.h  |  4 ++++
 WINGs/wpopupbutton.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
 configure.ac         |  4 ++--
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index b6192bdb..f8bb53f1 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -1462,6 +1462,10 @@ void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
 
 Bool WMGetPopUpButtonEnabled(WMPopUpButton *bPtr);
 
+int WMSelectPopUpButtonPreviousItem(WMPopUpButton *bPtr);
+
+int WMSelectPopUpButtonNextItem(WMPopUpButton *bPtr);
+
 /* ---[ WINGs/wprogressindicator.c ]------------------------------------- */
 
 WMProgressIndicator* WMCreateProgressIndicator(WMWidget *parent);
diff --git a/WINGs/wpopupbutton.c b/WINGs/wpopupbutton.c
index 1a8156b4..61d60846 100644
--- a/WINGs/wpopupbutton.c
+++ b/WINGs/wpopupbutton.c
@@ -252,6 +252,56 @@ WMMenuItem *WMGetPopUpButtonMenuItem(WMPopUpButton * bPtr, int index)
  return WMGetFromArray(bPtr->items, index);
 }
 
+int WMSelectPopUpButtonPreviousItem(WMPopUpButton * bPtr)
+{
+ int testIndex;
+
+ CHECK_CLASS(bPtr, WC_PopUpButton);
+
+ if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0)
+ return -1;
+
+ testIndex = bPtr->selectedItemIndex - 1;
+
+ while (testIndex >= 0 && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
+ testIndex--;
+
+ if (testIndex != -1) {
+ WMSetPopUpButtonSelectedItem(bPtr, testIndex);
+ if (bPtr->action)
+ (*bPtr->action) (bPtr, bPtr->clientData);
+ return testIndex;
+ }
+
+ return -1;
+}
+
+int WMSelectPopUpButtonNextItem(WMPopUpButton * bPtr)
+{
+ int itemCount;
+ int testIndex;
+
+ CHECK_CLASS(bPtr, WC_PopUpButton);
+
+ if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0)
+ return -1;
+
+ itemCount = WMGetArrayItemCount(bPtr->items);
+ testIndex = bPtr->selectedItemIndex + 1;
+
+ while (testIndex < itemCount && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
+ testIndex++;
+
+ if (testIndex != itemCount) {
+ WMSetPopUpButtonSelectedItem(bPtr, testIndex);
+ if (bPtr->action)
+ (*bPtr->action) (bPtr, bPtr->clientData);
+ return testIndex;
+ }
+
+ return -1;
+}
+
 static void paintPopUpButton(PopUpButton * bPtr)
 {
  W_Screen *scr = bPtr->view->screen;
diff --git a/configure.ac b/configure.ac
index 1d2bbe6e..7048524d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,9 +78,9 @@ WRASTER_VERSION=$WRASTER_CURRENT:$WRASTER_REVISION:$WRASTER_AGE
 AC_SUBST(WRASTER_VERSION)
 dnl
 dnl libWINGs
-WINGS_CURRENT=5
+WINGS_CURRENT=6
 WINGS_REVISION=0
-WINGS_AGE=2
+WINGS_AGE=3
 WINGS_VERSION=$WINGS_CURRENT:$WINGS_REVISION:$WINGS_AGE
 AC_SUBST(WINGS_VERSION)
 dnl
--
2.43.0
0001-WINGs-wpopupbutton-add-two-functions-to-change-the-d.patch
Reply all
Reply to author
Forward
0 new messages