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 Sun 23 Nov 2014, 09:32
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Xdialog combobox: How to edit text in entry field?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [25 Posts]   Goto page: 1, 2 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 470
Location: Japan

PostPosted: Thu 19 Dec 2013, 07:37    Post subject:  Xdialog combobox: How to edit text in entry field?  

I can't figure out how to make text in the entry field of a combobox editable.
Code:
#!/bin/sh
ANSWER=`Xdialog  --editable --stdout --combobox "The stuff here should be editable" 0 0 "appel" "lemon"`
pupmessage "$ANSWER"

According to the manual the --editable option should do the trick, but doesn't.
The Xdialog manual wrote:
--editable

This option is for use with the combobox widget. Its effect is to allow the user to edit the entry field of the combo box (by default it is not allowed to do so: only one of the items into the combo box pull-down list may be choosed).


I'm using Xdialog 2.3.1 that came with Slacko 5.6. Any help appreciated.

P.S. Didn't know that I can quote a link. Laughing
Back to top
View user's profile Send private message 
rcrsn51


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

PostPosted: Thu 19 Dec 2013, 10:09    Post subject:  

This Xdialog widget has always been wonky. Here is a simple replacement built from gtkdialog. The syntax is
Code:
comboboxwidget Title Item1 Item2 .....
comboboxwidget-1.1.pet
Description 
pet

 Download 
Filename  comboboxwidget-1.1.pet 
Filesize  696 Bytes 
Downloaded  169 Time(s) 

Last edited by rcrsn51 on Thu 19 Dec 2013, 22:23; edited 1 time in total
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2276

PostPosted: Thu 19 Dec 2013, 10:40    Post subject:  

"ANSWER=`Xdialog --editable --stdout --combobox "The stuff here should be editable" 0 0 "appel" "lemon"` " works fine for me here -but you surely have a different version than I do. Oh wait, I have it for either gtk1 or gtk2 -the gtk2 version doesn't work. Someone here before did a bit of work on the gtk2 version -maybe they can help out here -or maybe one of their fixes broke that. I'll have a look, too.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2276

PostPosted: Thu 19 Dec 2013, 11:17    Post subject:  

He He, found it:
"gtk_entry_set_editable is deprecated and should not be used in newly-written code. Use gtk_editable_set_editable() instead." I'll create a patch and put it up. Ok, here it is:
Code:
--- ./src/interface.c.00   2013-12-19 16:59:13.000000000 +0000
+++ ./src/interface.c   2013-12-19 17:29:42.000000000 +0000
@@ -1246,8 +1246,12 @@
    if (strlen(Xdialog.default_item) != 0)
       gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), Xdialog.default_item);
 
+#ifdef USE_GTK2
+   gtk_editable_set_editable(GTK_ENTRY(Xdialog.widget1), Xdialog.editable);
+#else
    gtk_entry_set_editable(GTK_ENTRY(Xdialog.widget1), Xdialog.editable);
-
+#endif
+   
    if (Xdialog.buttons) {
       button_ok = set_all_buttons(FALSE, TRUE);
       gtk_signal_connect(GTK_OBJECT(button_ok), "clicked", GTK_SIGNAL_FUNC(inputbox_ok), NULL);


Thanks for finding this on a day when I really should be warming up my grinch mood... Edit: Oops, that doesn't seem to fix it after all. Now I *am* felling grinchy...
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 470
Location: Japan

PostPosted: Thu 19 Dec 2013, 22:09    Post subject:  

@rcrsn51:
Thanks. I know that I have choices, but Xdialog is so refreshingly simply for some tasks that I hate to give up on it. Your code works nicely but I dare to make a small suggestion: It should be
Code:
for P in "$@"; do

which would accommodate entries containing spaces (comboboxwidget Title "apple jam" "lemon juice")

@amigo:
I admit that I have no clue what you are doing but I watch with fascination and eager expectation Laughing
Back to top
View user's profile Send private message 
rcrsn51


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

PostPosted: Thu 19 Dec 2013, 22:24    Post subject:  

MochiMoppel wrote:
Code:
for P in "$@"; do

Good idea. I have posted v1.1 above.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2276

PostPosted: Fri 20 Dec 2013, 12:17    Post subject:  

MochiMoppel, what version of gtk2 are you using?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 470
Location: Japan

PostPosted: Fri 20 Dec 2013, 22:05    Post subject:  

Honestly, I don't know for sure. Is there command to find this out? The PPM tells me
gtk+-1.2.10 ALREADY INSTALLED
gtk+2-2.24.10 ALREADY INSTALLED
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Fri 20 Dec 2013, 23:50    Post subject:  

Refreshingly simple... Yeah, you could put it that way.

I`m about to post my own GtkDialog Q, and it`s a simple item also.
Whenever I`m going to use it I know I`ll spend all my time trying to get it to work.
If I go any further ( inconsistent syntax, unsupported props. & events ) this`ll be a rant.
.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2276

PostPosted: Sat 21 Dec 2013, 03:46    Post subject:  

MochiMoppel, gtk+2-2.24 is what I have also. I suspect that this might have still been working for 2.23 -but I'm not sure. As it is, it requires a re-write of a section of Xdialog sources to create an editable combo-box. I see that thunor was having a time with this in gtkdialog and pointing out how many times the function had been renamed or used differnt syntax -pretty close to a dozen times!
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sat 21 Dec 2013, 13:03    Post subject:  

Time to fork it out ( or start over...) and make a completely incompatible "what-ever-it`s-called".?

Both the user end and the back end are messed up. Start with a clean slate and fix it all.
Back to top
View user's profile Send private message 
rcrsn51


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

PostPosted: Sat 21 Dec 2013, 13:21    Post subject:  

sunburnt wrote:
Time to fork it out ( or start over...) and make a completely incompatible "what-ever-it`s-called".? Both the user end and the back end are messed up. Start with a clean slate and fix it all.

Are you talking about Xdialog or gtkdialog?

Other than the issue with combobox, I have no problems with Xdialog.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Sat 21 Dec 2013, 15:05    Post subject:  

Xdialog pretty much is what it is, it can`t be changed without forking it.

GtkDialog in my opinion is poorly conceived for a number of reasons.
As I`ve said before: I just pray for a good replacement for it.
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Tue 24 Dec 2013, 15:26    Post subject:  

sunburnt wrote:
Xdialog pretty much is what it is, it can`t be changed without forking it.

GtkDialog in my opinion is poorly conceived for a number of reasons.
As I`ve said before: I just pray for a good replacement for it.


For now, GtkDialog is the most powerfull solution for GUI shell scripting.
It have a lot of limitations, of course. And requires some tricks to get some results. Also, widgets have function limitations. But your XML based system is very good.

At this point, in think that shell is very easy to learn and so powerfull, but if you want to get a more sophisticated GUI .. the solution is trying with another language.

Maybe, a design a box of powerfull bash functions, that can draw gtk code in another scripting language that support natively gtk. For example: Perl. Or, a compiled language like Vala, that contain internally bash code, and executes it by "system calls" could be the solution.

If not, there is no way.. and gtkdialog will need steroids

PD: sorry for my english
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Wed 25 Dec 2013, 14:54    Post subject:  

I know what you`re saying, I`ve been using GtkDialog on and off for 6 years now.

GtkServer seems good, but I recall having trouble with it also.

Barry made a good choice with it, there`s not much else to replace it really ( sadly ).

As to xml being good...
The only 3 tags I see that need closing tags are the <hbox>, <vbox>, and <notebook>.
So all the rest of them are wasted effort.! Hard to read, understand, and prone to errors.

I made a wrapper for it years ago, but as usual I get disgusted with the results and quit.
.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [25 Posts]   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:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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