Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 02 Oct 2014, 06:28
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Default button in Xdialog
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 402
Location: Japan

PostPosted: Sat 12 Feb 2011, 09:12    Post_subject:  Default button in Xdialog  

How can I make the 'No' button the default in a yesno box?
The documentation says '--default-no' or '--defaultno', but none of them seems to have an effect:
Code:
#!/bin/sh
Xdialog --default-no --yesno "No button should have focus!" 0 0
Back to top
View user's profile Send_private_message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sat 12 Feb 2011, 10:48    Post_subject:  

MochiMoppel

here is a more complete way to have control of the selection

Joe


Code:
#!/bin/bash
Xdialog --title "Question" --backtitle "Yes or no" \
--yesno  "\nYes to continue and No to cancel" 0 0
value=$?

case $value in
0) echo "yes"
   echo "do something here "
;;

1) echo "no"
 echo  "LEAVING"
#exit
;;

255) echo "You closed the box "
 echo "LEAVING"
#exit
;;
esac

yes-no.tar.gz
Description 
gz

 Download 
Filename  yes-no.tar.gz 
Filesize  309 Bytes 
Downloaded  446 Time(s) 

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 402
Location: Japan

PostPosted: Sat 12 Feb 2011, 11:26    Post_subject:  

Thanks, maybe my example was too barebone, but processing the return values is not the problem. My question was: How do I achieve that the 'No' and not the 'Yes' button (like in your sample script) has the focus. In other words: 'No' should be pushed when the user hits the ENTER key.
Back to top
View user's profile Send_private_message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sat 12 Feb 2011, 17:34    Post_subject:  

I see what you are saying now this confirms it

https://bugs.archlinux.org/task/18630?opened=6193&status[0]=


you could use gtkdialog here and change the order of the buttons so cancel is default when you press enter

http://xpt.sourceforge.net/techdocs/language/gtkdialog/gtkde02-GtkdialogExamples/

many more examples
http://www.murga-linux.com/puppy/viewtopic.php?search_id=1205526393&t=38608

Code:

#! /bin/bash

export MAIN_DIALOG='
 <vbox>
  <text>
    <label>This is a static text.</label>
  </text>
  <hbox>
   <button cancel></button>
   <button ok></button>
  </hbox>
 </vbox>
'

gtkdialog3 --program=MAIN_DIALOG

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 402
Location: Japan

PostPosted: Sun 13 Feb 2011, 09:21    Post_subject:  

big_bass wrote:
I see what you are saying now this confirms it
https://bugs.archlinux.org/task/18630?opened=6193&status[0]=

Bottomline: Xdialog in Puppy might not work correctly. So I'll be careful and grateful when it works as expected.

big_bass wrote:

you could use gtkdialog here and change the order of the buttons so cancel is default when you press enter

That's the only way? Looks a bit clunky and might confuse the user if the button locations in dialogs are not consistent. In that case I would rather rephrase the question than change the locations. I also noticed from your example that I cannot leave the dialog by pressing the ESC key (I would have to change my habit...). And the amount of code for a simple box...oh boy! But I'll study gtkdialog, it seems to be very powerful. Thank you, big_bass, for showing me alternatives. I very much appreciate that.
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2252

PostPosted: Sun 13 Feb 2011, 10:09    Post_subject:  

I also found some quirks the other day with Xdialog (supposedly) compiled for gtk2 -it wouldn't start properly unless gtk-1.2 was present. I'm with you, though, about gtkdialog being a bit clumsy for simple boxes. Joe and I both like Xdialog -I'll see if I can find any patches which fix any of the gtk2 problems.
Back to top
View user's profile Send_private_message 
rcrsn51


Joined: 05 Sep 2006
Posts: 9160
Location: Stratford, Ontario

PostPosted: Sun 13 Feb 2011, 10:47    Post_subject:  

You could also look at gxmessage. It lets you set the default focus on your buttons.
Back to top
View user's profile Send_private_message 
trapster


Joined: 28 Nov 2005
Posts: 2005
Location: Maine, USA

PostPosted: Sun 13 Feb 2011, 10:52    Post_subject:  

xmessage?

Code:
#!/bin/sh
#use xmessage to ask first.

answer=$(xmessage  "Would you like start a terminal? " -buttons yes,no -default no -print)
if [ $answer = "yes" ]
then
xterm
fi

_________________
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Puppeee4.31 + 1.0, Puppy4.10 + Lupu52
Currently using Slacko AND lupu52 w/ fluxbox
Back to top
View user's profile Send_private_message Visit_website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 402
Location: Japan

PostPosted: Sun 13 Feb 2011, 11:28    Post_subject:  

...or dialog?

Code:
#!/bin/bash
dialog   --title "Test answers" --defaultno --yesno  "No button has focus" 0 0
   ANSWER=$?
      if [ $ANSWER = 0 ]; then
         dialog --msgbox "YES button pressed(Errcode $ANSWER)" 0 0
      elif [ $ANSWER = 1 ]; then
         dialog --msgbox "NO button pressed(Errcode $ANSWER)" 0 0
      else
         dialog --msgbox "Oher button pressed(Errcode $ANSWER)" 0 0
         return
      fi


Anything else? Lost in language ...VBscript was easier Wink
Back to top
View user's profile Send_private_message 
trapster


Joined: 28 Nov 2005
Posts: 2005
Location: Maine, USA

PostPosted: Sun 13 Feb 2011, 11:57    Post_subject:  

Code:
dialog --defaultno --yesno "Choose Yes or No" 5 50 && echo "Your answer was Yes." || echo "Your answer was No."

_________________
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Puppeee4.31 + 1.0, Puppy4.10 + Lupu52
Currently using Slacko AND lupu52 w/ fluxbox
Back to top
View user's profile Send_private_message Visit_website 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sun 13 Feb 2011, 18:53    Post_subject:  

Hey MochiMoppel

Well ,I just cant give up easily when it comes to my favorite little app Xdialog

This works !! Very Happy --default-no in GTK1 uglier but works
*somtimes just pasting the code doesnt work so I attached the file too

*you could uncomment the #exit and the program will terminate and exit


@amigo any GTK2 patches you do find for Xdialog I would like a copy too friend

Code:
#!/bin/bash
Xdialog --title "Question" --backtitle "Yes or no" \
 --default-no --yesno  "\nYes to continue and No to cancel" 0 0
value=$?

case $value in
0) echo "yes"
   echo "do something here "
;;

1) echo "no"
 echo  "LEAVING"
#exit
;;

255) echo "You closed the box "
 echo "LEAVING"
#exit
;;
esac
it-works-now.png
 Description   
 Filesize   4.85 KB
 Viewed   1565 Time(s)

it-works-now.png

default-no.tar.gz
Description 
gz

 Download 
Filename  default-no.tar.gz 
Filesize  316 Bytes 
Downloaded  437 Time(s) 

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 402
Location: Japan

PostPosted: Sun 13 Feb 2011, 22:46    Post_subject:  

big_bass, no, it doesn't work. It's the same approach as in my initial post and the same code as your first post (only with --default-no added). As far as I can figure out Wary 5 has GTK+2 installed, so there is no point to show that in works in GTK1. Do I miss something? Frankly, I have no clue about this GTK stuff.

Maybe I should be more specific on what I want to achieve with Xdialog:

I've set ROX pinboard to 'single-click to open', so any careless click on the desktop can trigger a program. This happened to me with the 'Save' icon - once clicked saving can't be stopped. So I needed a script to put a sanity check in front of such critical actions. And I wanted a solution that avoids opening of a console, so Xdialog came very handy. This is how the code looks now. Unfortunately still defaults to 'yes':
Code:
#!/bin/sh
# Confirmation dialog before saving session
Xdialog --title "script $0" --default-no --yesno "Save session?" 10 40
[ $? -eq 0 ] && exec /usr/sbin/save2flash
Back to top
View user's profile Send_private_message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Mon 14 Feb 2011, 11:44    Post_subject:  

Hey MochiMoppel


#to check gtk versions
Code:

pkg-config --modversion gtk+-2.0

pkg-config --modversion gtk+



you could recompile Xdialog to compile against gtk1 which was the default its uglier though
people have hacked Xdialog to "almost work correctly " compiled against GTK2


*I hope you know that programming can be fun and if you run the next example you can see that humor can be and should be used in special cases when things dont work as they should Very Happy



Code:
#!/bin/sh
# Confirmation dialog before saving session
Xdialog --title "script $0" --default-no --yesno "Save session?" 10 40

Xdialog --title "script $0" --default-no --yesno "Save session? are you really sure" 10 45
Xdialog --title "script $0" --default-no --yesno "Save session? this will happen now" 10 45
Xdialog --title "script $0" --default-no --yesno "Save session? just in case one more chance " 10 50
Xdialog --title "script $0" --default-no --yesno "Save session? I warned you but you selected yes " 10 55

[ $? -eq 0 ] && exec /usr/sbin/save2flash

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Mon 14 Feb 2011, 12:59    Post_subject:  

big_bass wrote:
Hey MochiMoppel


#to check gtk versions
Code:

pkg-config --modversion gtk+-2.0

pkg-config --modversion gtk+
It's been a while, but IIRC gtk12 used gtk-config instead of pkg-config (that is not to say that a patched version could not have its own .pc file for compatibility) I have posted a gtk1 version of Xdialog (as well as mtpaint and others) in the pupngo thread if anyone is interested in the much lighter (yet arguably uglier) versions.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2252

PostPosted: Tue 01 Mar 2011, 04:06    Post_subject:  

I have fixed the default-no for gtk2 in Xdialog-2.3.1 and also found a single patch out there which adds the 'extra-button' feature which is available in cdialog.

Here's the default-no patch:
Code:
This patch fixes the default-no feature when using the gtk2
features of Xdialog.
Patch by Gilbert Ashley <amigo@ibiblio.org>

diff -pruN Xdialog-2.3.1/src/interface.c Xdialog-2.3.1-yesno/src/interface.c
--- Xdialog-2.3.1/src/interface.c   2011-02-27 19:12:59.000000000 +0100
+++ Xdialog-2.3.1-yesno/src/interface.c   2011-02-27 19:16:06.000000000 +0100
@@ -742,7 +742,9 @@ static void set_timeout(void)
 void create_msgbox(gchar *optarg, gboolean yesno)
 {
    GtkWidget *hbuttonbox;
-
+   GtkWidget *button;
+   gboolean flag;
+   
    open_window();
 
    set_backtitle(TRUE);
@@ -758,8 +760,19 @@ void create_msgbox(gchar *optarg, gboole
             set_button(CANCEL , hbuttonbox, 1, FALSE);
          set_button(NEXT, hbuttonbox, 0, TRUE);
       } else {
-         set_button(YES, hbuttonbox, 0, !Xdialog.default_no);
-         set_button(NO , hbuttonbox, 1, Xdialog.default_no);
+         button = set_button(OK, hbuttonbox, 0, flag = !Xdialog.default_no);
+         if (flag)
+            gtk_widget_grab_focus(button);
+         
+         if (Xdialog.cancel_button) {
+            button = set_button(CANCEL, hbuttonbox, 1, flag = Xdialog.default_no );
+            if (flag)
+               gtk_widget_grab_focus(button);
+         } else {
+            button = set_button(NO, hbuttonbox, 1, flag = Xdialog.default_no );
+            if (flag)
+               gtk_widget_grab_focus(button);
+         }
       }
    } else
       set_button(OK, hbuttonbox, 0, TRUE);


And here's the extra-button patch (should be applied first):
Code:
Submitted By: David B. Cortarello (Nomius) <nomius at users dot berlios dot de>
Date: 31-10-2006
Initial Package Version: 2.3.1
Description: The patch was created from the original Xdialog package
This patch provides the following features:
    * Implementation of the --extra-button and --extra-label flags compatible
      with dialog.

diff -pruN Xdialog-2.3.1/src/callbacks.c Xdialog-2.3.1-extra/src/callbacks.c
--- Xdialog-2.3.1/src/callbacks.c   2006-08-18 18:19:14.000000000 +0200
+++ Xdialog-2.3.1-extra/src/callbacks.c   2011-02-27 18:49:13.000000000 +0100
@@ -88,6 +88,19 @@ gboolean exit_ok(gpointer object, gpoint
    return FALSE;
 }
 
+gboolean exit_extra(gpointer object, gpointer data)
+{
+   if (Xdialog.check) {
+      if (Xdialog.checked)
+         fprintf(Xdialog.output, "checked\n");
+      else
+         fprintf(Xdialog.output, "unchecked\n");
+   }
+   gtk_widget_destroy(Xdialog.window);
+   Xdialog.exit_code = 3;
+   return FALSE;
+}
+
 gboolean exit_cancel(gpointer object, gpointer data)
 {
    Xdialog.exit_code = 1;
diff -pruN Xdialog-2.3.1/src/callbacks.h Xdialog-2.3.1-extra/src/callbacks.h
--- Xdialog-2.3.1/src/callbacks.h   2005-11-19 19:49:34.000000000 +0100
+++ Xdialog-2.3.1-extra/src/callbacks.h   2011-02-27 18:49:13.000000000 +0100
@@ -7,6 +7,8 @@ gboolean destroy_event(gpointer object,
 
 gboolean exit_ok(gpointer object, gpointer data);
 
+gboolean exit_extra(gpointer object, gpointer data);
+
 gboolean exit_cancel(gpointer object, gpointer data);
 
 gboolean exit_keypress(gpointer object, GdkEventKey *event, gpointer data);
diff -pruN Xdialog-2.3.1/src/extra.xpm Xdialog-2.3.1-extra/src/extra.xpm
--- Xdialog-2.3.1/src/extra.xpm   1970-01-01 01:00:00.000000000 +0100
+++ Xdialog-2.3.1-extra/src/extra.xpm   2011-02-27 18:49:13.000000000 +0100
@@ -0,0 +1,92 @@
+/* XPM */
+static char * extra_xpm[] = {
+"16 16 73 1",
+"    c None",
+".   c #959595",
+"+   c #C8C8C8",
+"@   c #777777",
+"#   c #B9B9B9",
+"$   c #F5F5F5",
+"%   c #DADADA",
+"&   c #393838",
+"*   c #717171",
+"=   c #F4F4F4",
+"-   c #FCFCFC",
+";   c #636363",
+">   c #7E7E7E",
+",   c #FBFBFB",
+"'   c #F8F7F7",
+")   c #7F7E7E",
+"!   c #3B3B3B",
+"~   c #676666",
+"{   c #EFEFEF",
+"]   c #BABABA",
+"^   c #7E7D7D",
+"/   c #666565",
+"(   c #B8B8B8",
+"_   c #9B9A9A",
+":   c #3C3C3C",
+"<   c #E6E5E5",
+"[   c #E7E7E7",
+"}   c #DEDDDD",
+"|   c #D5D4D4",
+"1   c #CBCBCB",
+"2   c #C2C1C1",
+"3   c #686868",
+"4   c #9C7A25",
+"5   c #9C9276",
+"6   c #E7E6E6",
+"7   c #C4C4C4",
+"8   c #C8C7C7",
+"9   c #CCCBCB",
+"0   c #C3C2C2",
+"a   c #A68229",
+"b   c #E5C35E",
+"c   c #DAB248",
+"d   c #86754E",
+"e   c #313131",
+"f   c #282727",
+"g   c #535252",
+"h   c #464646",
+"i   c #A8852C",
+"j   c #E6C460",
+"k   c #DFB546",
+"l   c #D49D1C",
+"m   c #674C0E",
+"n   c #AB8830",
+"o   c #E6C562",
+"p   c #DEB241",
+"q   c #D39C1B",
+"r   c #654C10",
+"s   c #AD8B33",
+"t   c #E6C563",
+"u   c #DDB03D",
+"v   c #D39B1B",
+"w   c #624A10",
+"x   c #A48534",
+"y   c #DCAD39",
+"z   c #D29B1A",
+"A   c #604811",
+"B   c #AD944A",
+"C   c #DBAB35",
+"D   c #D29B1B",
+"E   c #5D4712",
+"F   c #423619",
+"G   c #87671D",
+"H   c #574312",
+"                ",
+"         .+@    ",
+"        #$%&    ",
+"       *=-;     ",
+"       >,')  !~ ",
+"        ={]^/(_ ",
+"       :<[}|123 ",
+"      4567890)  ",
+"     abcdefgh   ",
+"    ijklm       ",
+"   nopqr        ",
+"  stuvw         ",
+" xtyzA          ",
+" BCDE           ",
+" FGH            ",
+"                "};
diff -pruN Xdialog-2.3.1/src/interface.c Xdialog-2.3.1-extra/src/interface.c
--- Xdialog-2.3.1/src/interface.c   2006-08-18 18:13:12.000000000 +0200
+++ Xdialog-2.3.1-extra/src/interface.c   2011-02-27 18:50:23.000000000 +0100
@@ -29,6 +29,7 @@
 #include "help.xpm"
 #include "print.xpm"
 #include "next.xpm"
+#include "extra.xpm"
 #include "previous.xpm"
 #endif
 
@@ -387,6 +388,8 @@ static GtkWidget *set_button(gchar *defa
          stock_id = "gtk-close";
       else if (!strcmp(text, HELP))
          stock_id = "gtk-help";
+      else if (!strcmp(text, EXTRA))
+         stock_id = "gtk-execute";
       else if (!strcmp(text, PRINT))
          stock_id = "gtk-print";
       else if (!strcmp(text, NEXT) || !strcmp(text, ADD))
@@ -402,6 +405,8 @@ static GtkWidget *set_button(gchar *defa
          xpm = no_xpm;
       else if (!strcmp(text, HELP))
          xpm = help_xpm;
+      else if (!strcmp(text, EXTRA))
+         xpm = extra_xpm;
       else if (!strcmp(text, PRINT))
          xpm = print_xpm;
       else if (!strcmp(text, NEXT) || !strcmp(text, ADD))
@@ -413,6 +418,8 @@ static GtkWidget *set_button(gchar *defa
 
    if (strlen(Xdialog.ok_label) != 0 && (!strcmp(text, OK) || !strcmp(text, YES)))
       text = Xdialog.ok_label;
+   if (strlen(Xdialog.extra_label) != 0 && (!strcmp(text, EXTRA)))
+      text = Xdialog.extra_label;
    else if (strlen(Xdialog.cancel_label) != 0 && (!strcmp(text, CANCEL) || !strcmp(text, NO)))
       text = Xdialog.cancel_label;
 
@@ -475,6 +482,12 @@ static GtkWidget *set_button(gchar *defa
                    GTK_SIGNAL_FUNC(print_text),
                    NULL);
          break;
+      case 5:
+         gtk_signal_connect_after(GTK_OBJECT(button), "clicked",
+                   GTK_SIGNAL_FUNC(exit_extra),
+                   NULL);
+         break;
+
    }
    if (grab_default)
       gtk_widget_grab_default(button);
@@ -526,8 +539,13 @@ static GtkWidget *set_all_buttons(gboole
 
    if (Xdialog.wizard)
       set_button(PREVIOUS , hbuttonbox, 3, FALSE);
-   else if (ok)
-      button_ok = set_button(OK, hbuttonbox, 0, !Xdialog.default_no);
+   else {
+      if(Xdialog.extra_button)
+         button_ok = set_button(EXTRA, hbuttonbox, 5, !Xdialog.default_no);
+
+      if (ok)
+         button_ok = set_button(OK, hbuttonbox, 0, !Xdialog.default_no);
+   }
    if (Xdialog.cancel_button)
       set_button(CANCEL , hbuttonbox, 1, Xdialog.default_no && !Xdialog.wizard);
    if (Xdialog.wizard)
diff -pruN Xdialog-2.3.1/src/interface.h Xdialog-2.3.1-extra/src/interface.h
--- Xdialog-2.3.1/src/interface.h   2006-08-13 20:16:09.000000000 +0200
+++ Xdialog-2.3.1-extra/src/interface.h   2011-02-27 18:52:48.000000000 +0100
@@ -61,6 +61,7 @@
 #ifdef FRENCH            /* french translations without NLS */
 #   define OK "OK"
 #   define CANCEL "Annuler"
+#   define EXTRA "Supplémentaire"
 #   define YES "Oui"
 #   define NO "Non"
 #   define HELP "Aide"
@@ -76,6 +77,7 @@
 #   define HIDE_TYPING "Masquer la saisie"
 #else
 #   define OK _("OK")
+#   define EXTRA _("Extra")
 #   define CANCEL _("Cancel")
 #   define YES _("Yes")
 #   define NO _("No")
@@ -129,6 +131,7 @@ typedef struct   {
    gchar      check_label[MAX_CHECK_LABEL_LENGTH];   /* Check button label text */
    gchar      ok_label[MAX_BUTTON_LABEL_LENGTH];   /* OK button label text */
    gchar      cancel_label[MAX_BUTTON_LABEL_LENGTH];   /* CANCEL button label text */
+   gchar      extra_label[MAX_BUTTON_LABEL_LENGTH];   /* EXTRA button label text */
    gchar      default_item[MAX_ITEM_LENGTH];      /* Tag of the default item */
    gchar      separator[2];            /* Xdialog output result separator */
    gint      xsize;               /* Xdialog window X size */
@@ -156,6 +159,7 @@ typedef struct   {
    gboolean   buttons;            /* FALSE to prevent setting up buttons */
    gboolean   ok_button;            /* FALSE to prevent setting up OK button in tailbox/logbox */
    gboolean   cancel_button;            /* FALSE to prevent setting up Cancel button */
+   gboolean   extra_button;         /* FALSE to prevent setting up EXTRA */
    gboolean   help;               /* TRUE to setup the Help button */
    gboolean   default_no;            /* When TRUE No/Cancel is the default button */
    gboolean   wizard;               /* TRUE to setup Wizard buttons */
diff -pruN Xdialog-2.3.1/src/main.c Xdialog-2.3.1-extra/src/main.c
--- Xdialog-2.3.1/src/main.c   2006-08-13 20:22:58.000000000 +0200
+++ Xdialog-2.3.1-extra/src/main.c   2011-02-27 18:56:40.000000000 +0100
@@ -87,6 +87,8 @@ Transient options:\n\
   --check <label> [<status>]\n\
   --ok-label <label>\n\
   --cancel-label <label>\n\
+  --extra-button\n\
+  --extra-label <label>\n\
   --beep\n\
   --beep-after\n\
   --begin <Yorg> <Xorg>\n\
@@ -223,6 +225,7 @@ enum {
    T_REVERSE,
    T_KEEPCOLORS,
    T_NOOK,
+   T_EXTRA,
    T_NOCANCEL,
    T_NOBUTTONS,
    T_NOTAGS,
@@ -234,6 +237,7 @@ enum {
    T_DEFAULTNO,
    T_OKLABEL,
    T_CANCELLABEL,
+   T_EXTRALABEL,
    T_ICON,
    T_INTERVAL,
    T_TIMEOUT,
@@ -276,7 +280,7 @@ static void print_help_info(char *name,
 
    strcpysafe(Xdialog.title, "Usage for ", MAX_TITLE_LENGTH);
    strcatsafe(Xdialog.title, cmd, MAX_TITLE_LENGTH);
-   Xdialog.cancel_button = Xdialog.help = Xdialog.icon = Xdialog.check = FALSE;
+   Xdialog.cancel_button = Xdialog.help = Xdialog.icon = Xdialog.check = Xdialog.extra_button = FALSE;
    if (!Xdialog.print) {
       Xdialog.print = TRUE;
       Xdialog.printer[0] = 0;
@@ -630,6 +634,9 @@ int main(int argc, char *argv[])
                 {"version",      0, 0, S_VERSION},
                 {"print-version",   0, 0, S_PRINTVERSION},
                 {"clear",      0, 0, S_CLEAR},
+      /* Nomius patch for extra button */
+                {"extra-button",      0, 0, T_EXTRA},
+                {"extra-label",   1, 0, T_EXTRALABEL},
       /* End of options marker */
       {0, 0, 0, 0}
    };
@@ -680,7 +687,8 @@ int main(int argc, char *argv[])
    Xdialog.buttons_style   = ICON_AND_TEXT;   /* Default buttons style (icon+text) */
    Xdialog.buttons      = TRUE;         /* Display buttons as default */
    Xdialog.ok_button   = TRUE;         /* Display "OK" button as default */
-   Xdialog.cancel_button   = TRUE;         /* Display "Cancel" button as default */
+   Xdialog.cancel_button   = TRUE;      /* Display "Cancel" button as default */
+   Xdialog.extra_button   = FALSE;   /* Don't Display "Extra" button as default */
    Xdialog.tags      = TRUE;         /* Display tags before items in lists */
 #if 0   /* Not needed because of the memset: listed here as a reminder only... */
    Xdialog.passwd      = 0;         /* Don't use passwd input as default */
@@ -1159,6 +1167,12 @@ show_again:
          case T_CANCELLABEL:      /* --ok-label option */
             strcpysafe(Xdialog.cancel_label, optarg, MAX_BUTTON_LABEL_LENGTH);
             break;
+         case T_EXTRA:   /* --extra-button option */
+            Xdialog.extra_button = TRUE;
+            break;
+         case T_EXTRALABEL:      /* --extra-label option */
+            strcpysafe(Xdialog.extra_label, optarg, MAX_BUTTON_LABEL_LENGTH);
+            break;
          case T_ICON:      /* --icon option */
             strcpysafe(Xdialog.icon_file, optarg, MAX_FILENAME_LENGTH);
             Xdialog.icon = TRUE;
@@ -1300,6 +1314,7 @@ show_again:
          Xdialog.default_item[0]   = 0;
          Xdialog.ok_label[0]   = 0;
          Xdialog.cancel_label[0]   = 0;
+         Xdialog.extra_label[0]   = 0;
          Xdialog.ignore_eof   = FALSE;
          Xdialog.smooth      = FALSE;
       }


I have a full set of patches for Xdialog-2.3.1 from various sources which I'll make available elsewhere.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 2 Posts_count   Goto page: 1, 2 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1624s ][ Queries: 12 (0.0109s) ][ GZIP on ]