Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#521 Post by zigbert »

The sort functions of clist would be VERY handy.

I did not understand what I could expect of
gtk_clist_set_compare_func() :oops:


Thanks a lot :!:
Sigmund

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#522 Post by vovchik »

Dear Zigmund and thunor,

Zigmund's example works for me under Lucid....no segfault.

With kind regards,
vovchik

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#523 Post by zigbert »

doublecheck - Slacko 5.3.2.10

version 375 - OK (well, <input file> didn't work :wink: )
version 388 - Segmentation fault

Code: Select all

# ./table 
./table: line 23:  3174 Segmentation fault      gtkdialog --program=MAIN_DIALOG

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#524 Post by thunor »

Thanks for testing guys :)

I've just commited r390 and I've:
  • Fixed the table widget's signal and action handling issues.
  • Added "exported-column" support to the table widget.
  • Added initial "selection-mode" support to the table widget but not yet multiple selection mode.
[EDIT]
I won't interfere with its current behaviour. Refreshing currently adds items to the list and if you want to clear it beforehand then you can use the clear action. I won't interfere with the selected item on refresh either. I think it would be useful to have a tag attribute that enables the auto-selection of a particular row on refresh which will fire a select-row signal and you can disable that using block-function-signals. This way the current behaviour remains unaffected but you've got the option to modify it.

Using Sigmund's example code you can also try the "exported-column" and "selection-mode" tag attributes and add some buttons at the bottom for the clear and removeselected actions.

I'll code multiple selection mode later tonight.

Cheers.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#525 Post by zigbert »

Testing r390 and
<action>refresh:TABLE</action>
works great.

What I don't understand is why the following input file gives a 'Segmentation fault'?
Can anyone try it and see how it works on your system?

Code: Select all

#! /bin/bash

echo -e "

  pmusic_rating|M O S T   P L A Y E D   (last month)
  /mnt/sdb1/musikk/mp3/Ræva Rockers - Depp (LP).mp3|    Ræva Rockers - Depp (LP).mp3| 11
  /mnt/sdb1/musikk/mp3/Black sabbath - Heaven and hell.mp3|    Black sabbath - Heaven and hell.mp3| 9
  /mnt/home/mp3_streamripper/RadioLive.no_top40_Norway_192/Alexis Jordan - Hush Hush.mp3|    Alexis Jordan - Hush Hush.mp3| 8
  /mnt/sdb1/musikk/mp3/Saint deamon - My heart.mp3|    Saint deamon - My heart.mp3| 7
  /mnt/sdb1/musikk/mp3/Dimmu borgir - Vredesbyrd.mp3|    Dimmu borgir - Vredesbyrd.mp3| 7
  /mnt/sdb1/musikk/flac/Candlemass - At the gallows end.flac|    Candlemass - At the gallows end.flac| 7
  /mnt/sdb1/musikk/mp3/Halvdan Sivertsen - Lonesome Traveller.mp3|    Halvdan Sivertsen - Lonesome Traveller.mp3| 7
  /mnt/sdb1/musikk/mp3/Dimmu borgir - Burn in hell.mp3|    Dimmu borgir - Burn in hell.mp3| 7
  /mnt/sdb1/musikk/mp3/Twisted sister - The beast.mp3|    Twisted sister - The beast.mp3| 5
  /mnt/sdb1/musikk/mp3/TNT - 10.000 lovers (in one).mp3|    TNT - 10.000 lovers (in one).mp3| 5
  /mnt/home/mp3_streamripper/Radio3 Norge/Morten Harket - Lightning.mp3|    Morten Harket - Lightning.mp3| 5
  /mnt/home/mp3_streamripper/RadioLive.no_top40_Norway_192/Rihanna - Roc Me Out.mp3|    Rihanna - Roc Me Out.mp3| 4
  /mnt/sdb1/musikk/mp3/Rihanna - Rehab.mp3|    Rihanna - Rehab.mp3| 4
  /mnt/sdb1/musikk/mp3/Ræva Rockers - Lille Lenin (LP).mp3|    Ræva Rockers - Lille Lenin (LP).mp3| 4
  /mnt/sdb1/musikk/mp3/Morten Harket - Just believe it.mp3|    Morten Harket - Just believe it.mp3| 4
  /mnt/sdb1/musikk/mp3/Twisted sister - Love is for suckers.mp3|    Twisted sister - Love is for suckers.mp3| 3
  /mnt/home/mp3_streamripper/RadioLive.no_top40_Norway_192/Rihanna - Where You Been.mp3|    Rihanna - Where You Been.mp3| 3
  /mnt/sdb1/musikk/mp3/Judas priest - Parental guidance (LP).mp3|    Judas priest - Parental guidance (LP).mp3| 3
  /mnt/sdb1/musikk/mp3/Nightwish - Bye bye beautiful.mp3|    Nightwish - Bye bye beautiful.mp3| 3
  /mnt/sdb1/musikk/mp3/TNT - Everyone's a star.mp3|    TNT - Everyone's a star.mp3| 3
  /mnt/sdb1/musikk/mp3/TNT - Knights of the thunder.mp3|    TNT - Knights of the thunder.mp3| 3
  /mnt/sdb1/musikk/flac/Candlemass - Samarithan.flac|    Candlemass - Samarithan.flac| 3
  /mnt/home/mp3_streamripper/100HitRadio_top40_USA_128/Cher Lloyd - Want U Back.mp3|    Cher Lloyd - Want U Back.mp3| 3
  /mnt/sdb1/musikk/mp3/Morten Harket - Out of my hands.mp3|    Morten Harket - Out of my hands.mp3| 3
  /mnt/sdb1/musikk/mp3/Twisted sister - Destroyer.mp3|    Twisted sister - Destroyer.mp3| 2
  /mnt/sdb1/musikk/mp3/Nightwish - For the heart I once had.mp3|    Nightwish - For the heart I once had.mp3| 2
  /mnt/sdb1/musikk/mp3/Savatage - Dead winter dead.mp3|    Savatage - Dead winter dead.mp3| 2
  /mnt/sdb1/musikk/mp3/Bertine Zetlitz - Adore me.mp3|    Bertine Zetlitz - Adore me.mp3| 2
  /mnt/sdb1/musikk/mp3/TNT - Tell no tales.mp3|    TNT - Tell no tales.mp3| 2
  /mnt/home/mp3_streamripper/RadioLive.no_top40_Norway_192/Jenny Langlo - Million Dollar Signs.mp3|    Jenny Langlo - Million Dollar Signs.mp3| 2

" > /tmp/input_table
export MAIN_DIALOG='
 <vbox>
  <table>
    <width>500</width><height>200</height>
    <variable>TABLE</variable>
    <label>"Column 1|Column 2|Column 3|column 4                  |column 5                   "</label>
    <input file>/tmp/input_table</input>
    <action>echo $TABLE</action>
  </table>
  <hbox>
   <button ok></button>
   <button>
       <label>refresh</label>
       <action>clear:TABLE</action>
       <action>refresh:TABLE</action>
   </button>
  </hbox>
 </vbox>
'

gtkdialog --program=MAIN_DIALOG

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#526 Post by thunor »

r393:
  • Added the "selected-row" tag attribute to the table widget to enable selecting a default row on initialisation and refresh (the firing of signals can be prevented with "block-function-signals").
  • Added multiple selection mode to the table widget and updated the envvar export functions and removeselected action to cope with it.
Sigmund, I'll look into that issue. I'm pretty much done with the refactoring so you might want to try r393 as it'll be a while now before I commit the sorting code.

Forgot to mention: the signal handling works properly now, so you can play around with all the signals listed in examples/miscellaneous/signals.

Thanks.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#527 Post by seaside »

zigbert wrote:Testing r390 and
<action>refresh:TABLE</action>
works great.

What I don't understand is why the following input file gives a 'Segmentation fault'?
Can anyone try it and see how it works on your system?

Code: Select all

#! /bin/bash

echo -e "

  pmusic_rating|M O S T   P L A Y E D   (last month)
  /mnt/sdb1/musikk/mp3/Ræva Rockers - Depp (LP).mp3|    Ræva Rockers - Depp (LP).mp3| 11 [/quote]

zigbert,

Perhaps the character set "ae"

Cheers,
s

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#528 Post by thunor »

It's segfaulting for me and I'm tracing it.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#529 Post by thunor »

Fixed in r394.

A utility function needed fixing to cope with splitting a string into substantially fewer columns than the table widget was expecting. It's good that that was found.

Bedtime...

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#530 Post by zigbert »

I feel myself like a pain in the ass, but I really want the table widget to improve....

Made some tests with Selection-mode and <action signal="button-press-event">. Works very nice, and I can fulfill the dream of a mouse-right-menu :)

Well, maybe not ... because speed (and cpu-usage) has became an issue. Here is an example script with 10000 rows in table. It shows up (fast), but when start clicking on items it feels like a freeze.... If I decrease it to 5000, it's like a turtle. 1000 rows works fine.

Code: Select all

#! /bin/bash

echo -n > /tmp/input_table
for I in $(seq 1 1000); do
echo  "  /mnt/sdb1/musikk/mp3/Ræva Rockers - Depp (LP).mp3|    Ræva Rockers - Depp (LP).mp3| 11
  /mnt/sdb1/musikk/mp3/Black sabbath - Heaven and hell.mp3|    Black sabbath - Heaven and hell.mp3| 9
  /mnt/home/mp3_streamripper/RadioLive.no_top40_Norway_192/Alexis Jordan - Hush Hush.mp3|    Alexis Jordan - Hush Hush.mp3| 8
  /mnt/sdb1/musikk/mp3/Saint deamon - My heart.mp3|    Saint deamon - My heart.mp3| 7
  /mnt/sdb1/musikk/mp3/Dimmu borgir - Vredesbyrd.mp3|    Dimmu borgir - Vredesbyrd.mp3| 7
  /mnt/sdb1/musikk/flac/Candlemass - At the gallows end.flac|    Candlemass - At the gallows end.flac| 7
  /mnt/sdb1/musikk/mp3/Halvdan Sivertsen - Lonesome Traveller.mp3|    Halvdan Sivertsen - Lonesome Traveller.mp3| 7
  /mnt/sdb1/musikk/mp3/Dimmu borgir - Burn in hell.mp3|    Dimmu borgir - Burn in hell.mp3| 7
  /mnt/sdb1/musikk/mp3/Twisted sister - The beast.mp3|    Twisted sister - The beast.mp3| 5
  /mnt/sdb1/musikk/mp3/TNT - 10.000 lovers (in one).mp3|    TNT - 10.000 lovers (in one).mp3| 5" >> /tmp/input_table
done

func_button (){
	case $BUTTON in
	1) echo 'Mouse-button: Left' ;;
	2) echo 'Mouse-button: Middle' ;;
	3) echo 'Mouse-button: Right' ;;
	esac
}
export -f func_button

export MAIN_DIALOG='
 <vbox>
  <table selection-mode="3">
    <width>500</width><height>200</height>
    <variable>TABLE</variable>
    <label>"Column 1|Column 2                                               |Column 3"</label>
    <input file>/tmp/input_table</input>
    <action>echo $TABLE</action>
    <action signal="button-press-event">func_button</action>
  </table>
  <hbox>
   <button>
       <label>refresh</label>
       <action>clear:TABLE</action>
       <action>refresh:TABLE</action>
   </button>
  </hbox>
 </vbox>
'

gtkdialog --program=MAIN_DIALOG

Sigmund

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#531 Post by thunor »

Fixed in r396.

That was a good problem solved because that would've been affecting other widgets such as the list, comboboxentry/text and tree.

gtkdialog has a system of exporting variables on a signal so you can do <action>echo $TABLE</action> and get the currently selected item(s). Also for the list, comboboxentry/text, table and tree it exports the entire contents of the widget in the *_ALL variable so for example <action>echo $TABLE_ALL</action>. Because I've collected together all the code fragments of the table widget and placed them together in their own file and connected them up, this performance issue has now been highlighted so I've disabled this *_ALL exporting feature. It may have been useful when gtkdialog was first created for making simple dialogs, but it's now time for it to die. I'll make sure those widgets have a save action function.

I haven't tried but I imagine this will greatly increase the performance of complex comboboxentry/text and tree widgets and possibly it may have been responsible for BarryK's comboboxentry speed issues a while back -- seems plausible.

[EDIT]
Of course if anybody is actually making use of the exported *_ALL variables then their applications will now break; they were printed to the terminal too on exit. I guess we'll just have to wait for somebody to lodge a complaint to find out :P

Regards,
Thunor

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#532 Post by thunor »

zigbert wrote:...I can fulfill the dream of a mouse-right-menu :)
...
Have a look at examples/miscellaneous/press_and_release_events and change the <edit> widget at the top to a <table> and change its <default> directive to an <item>. You can get all sorts of information now, not just $BUTTON (equivalent to the new $PTR_BTN).

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#533 Post by zigbert »

Things are really getting good with the latest fixes.
<table> works like a charm. <tree> is much faster.
Have a look at examples/miscellaneous/press_and_release_events
Now I see that mouse-click-position is available - that is really handy!!!
Of course if anybody is actually making use of the exported *_ALL variables then their applications will now break; they were printed to the terminal too on exit. I guess we'll just have to wait for somebody to lodge a complaint to find out
Haven't seen much code using this, and as you say, it is easy to solve using savefile or grabbing input file.


This is really great work.
The downside is that I get heaps to do.....
Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#534 Post by zigbert »

Thunor
If (hopefully when) you look at sorting in <table>, please consider to sort numbers not by char, but the whole number. Today the <tree> sorts column like this:

Code: Select all

1
14
167890
2
2367
3
31
350

Thank you
Sigmund

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#535 Post by thunor »

Updated the table widget

Gtk properties: GtkCList.properties
Widget reference: table widget
Example: examples/table/table

I'd say that my work updating the table widget is complete apart from dealing with the right mouse button which I'll come to in a moment.

Sorting works in the table widget and I've written a natural sort algorithm which can also be case insensitive. By default the data is unsorted but auto-sorting is possible on initialisation and when refreshing. I've modelled the column header clicking on the tree widget with a slight modification (see last two clicks of tree widget):

Code: Select all

/* Table Widget Behaviour
 * ----------------------
 * Assuming that the default sort direction is ascending:
 * 
 * Click column 0 and it'll sort ascending.
 * Click column 1 and it'll sort ascending.
 * Click column 1 and it'll sort descending having flipped.
 * Click column 0 and it'll sort descending.
 * Click column 1 and it'll sort descending.
 * 
 * Tree Widget Behaviour
 * ---------------------
 * Assuming that the default sort direction is ascending:
 * 
 * Click column 0 and it'll sort ascending.
 * Click column 1 and it'll sort ascending.
 * Click column 1 and it'll sort descending having flipped.
 * Click column 0 and it'll sort ascending.
 * Click column 1 and it'll sort ascending.
 */
Other useful features are locking of select column headers and hiding of select columns, therefore you can now hide data but still export it from that column e.g. show a filename, hide the fullpath.

Sigmund, there is a function gtk_clist_set_button_actions() that enables me to modify the behaviour of the right mouse button so do you want it to select an item in the same way as left-clicking? You can then read $PTR_BTN ($BUTTON) to check which button was used.

Regards,
Thunor
Last edited by thunor on Wed 05 Sep 2012, 00:43, edited 1 time in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#536 Post by technosaurus »

I played around with making a basic file/archive manager with gtkdialog, but stopped primarily because of sort - great news!
:)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#537 Post by thunor »

technosaurus wrote:I played around with making a basic file/archive manager with gtkdialog, but stopped primarily because of sort - great news!
:)
Well, looking at XArchive I'd say that it would be possible to create an application of that complexity now. If you open XArchive, underneath the toolbar (buttons with relief="2" and some vseparators) you get a message about the wrappers in a scrolled window and if you open an archive you get a list so you could have a text widget in a scrollable box and a table and hide the widget you don't want :) I think I'll have a look at the tree widget next and see if I can make that more useful/interesting.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#538 Post by technosaurus »

thunor wrote:
technosaurus wrote:I played around with making a basic file/archive manager with gtkdialog, but stopped primarily because of sort - great news!
:)
Well, looking at XArchive I'd say that it would be possible to create an application of that complexity now. If you open XArchive, underneath the toolbar (buttons with relief="2" and some vseparators) you get a message about the wrappers in a scrolled window and if you open an archive you get a list so you could have a text widget in a scrollable box and a table and hide the widget you don't want :) I think I'll have a look at the tree widget next and see if I can make that more useful/interesting.
yes, exactly ... A combo of xarchive and pprocess using techniques similar to rodent and gentoo file managers for file ops, although I don't recall if there was a way to get the content of rows on a multiple selection... Seems like maybe it only gave 1 row and only the 1st field.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#539 Post by zigbert »

Thunor wrote:Sigmund, there is a function gtk_clist_set_button_actions() that enables me to modify the behaviour of the right mouse button so do you want it to select an item in the same way as left-clicking? You can then read $PTR_BTN ($BUTTON) to check which button was used.
The way I think, it would be good if right clicks did NOT affect selection. I want right-click to show a menu, and now it also select the given item - that means it 'deselect' an existing multiple selection.

Else I must say the new table-stuff looks awesome. Before I start working in depth with it, I try to figure out a strategy how to actually set up the next version pMusic. Your improvements to gtkdialog opens up a new world of opportunities.


Thank you
Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#540 Post by zigbert »

I have done some sorting i the <table> :)

Sort-functions 1 and 2 (strnatcmp, strcasenatcmp) is better with numbers, but still there is an issue.

testresult:

Code: Select all

1
2
3
..
01
02
03
..
11
12
13
..
21
22
23
Is it possible to get

Code: Select all

1
01
2
02
3
03
..
11
12
13
..
21
22
23

Sigmund

Post Reply