Question about Shell Script (#!/bin/sh)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#46 Post by jpeps »

A little tricky, but I found a way to get it working. I don't think it has a scroll bar, which makes it kind of useless for long lists. Maybe an idea for our own gtkdialog development, though, since I'm sure it would get used a lot.
Attachments
gnewpet-greq.png
(58.39 KiB) Downloaded 848 times

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

#47 Post by Moose On The Loose »

jpeps wrote:A little tricky, but I found a way to get it working. I don't think it has a scroll bar, which makes it kind of useless for long lists. Maybe an idea for our own gtkdialog development, though, since I'm sure it would get used a lot.
I just thought of a way to do long lists. Here is the basic idea:

Place a button above and below the space where a subset of the full list is shown.

When someone clicks on the up button, the dialog closes, and a new one opens with the list scrolled down by 1/2 the length of the sub-list you are showing. Te script needs to keep track of the state ON/OFF of the items in the full list and give the subset back with the right combination of check marks.

I have made a thing that works like a combo-box but allows the user entry to be filtered on a keystroke basis. This used the fact that there is an event for the loss of focus. If the scrolled list is done in its own box, this trick could be used to make the list a stand alone thing.

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

#48 Post by seaside »

Could this be used-

Code: Select all

<tree selection-mode="3"
It gives you multiple selection capability with a scroll bar.

Cheers,
s

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#49 Post by RSH »

Could this be used-

Code:
<tree selection-mode="3"
This works fine. It ( selection-mode="3") gives you the possibility to select several files.

But how to distinguish (sort out) the selected and unselected items?
Attachments
tree-works.jpg
(31.81 KiB) Downloaded 794 times
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

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

#50 Post by seaside »

RSH,
But how to distinguish (sort out) the selected and unselected items?
All the selected items are returned separated in this variable-

Code: Select all

<variable>TREECHOICES</variable>
Cheers,
s

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#51 Post by jpeps »

Not as pretty as checklists, but works nicely. <ctrl> clicking returns multiple items.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#52 Post by RSH »

jpeps wrote:Not as pretty as checklists, but works nicely.
Yes, checklists would be my favorite as well, but "tree" is also usable. I'd just never heard about the attribute "selection-mode". Everything i'd tried gives me only single-file-selection. But this one works and i can use it for my work.

To put the whole selection into a text file use

Code: Select all

echo $TREE1 > /tmp/list
To write the whole selection as single lines into a text file use

Code: Select all

for i in $TREE1;
	do
		echo $i >> /tmp/list
	done
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#53 Post by jpeps »

Here's a version using tree. In batch mode, the "batch copy" button opens the tree list. Select with <ctrl> click, and then push the "select pets" button.
This opens an editable box for final selection. Push the "Make Pets" button for creation in /tmp

edit: added a "select all" button in tree list
Attachments
gnewpet-4.1.pet
(2.47 KiB) Downloaded 510 times
gnewpet-tree.png
(66.6 KiB) Downloaded 778 times

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#54 Post by jpeps »

added a "select-all" button for batch

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

#55 Post by seaside »

jpeps,

Nicely done.

I've found it easier to build gtkdialog menu items this way-

Code: Select all

for i in *.files;do 
i=${i//.files/}
LIST="$LIST<item>"$i"</item>"
done
echo $LIST # becomes input variable item list for combobox
It grabs only the ".files", cuts off the ".files" extension, and makes up the list variable all in one shot.

Regards,
s

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#56 Post by RSH »

seaside wrote:jpeps,

Nicely done.

I've found it easier to build gtkdialog menu items this way-
Code:

for i in *.files;do
i=${i//.files/}
LIST="$LIST<item>"$i"</item>"
done
echo $LIST # becomes input variable item list for combobox


It grabs only the ".files", cuts off the ".files" extension, and makes up the list variable all in one shot.
I do use this one, which works also fine. It uses original funcItemCreate.

Code: Select all

  <tree selection-mode="3" stock="gtk-file">
    <label>"'$WFNALST'"</label>
    <height>200</height><width>300</width>
	'"$(funcItemCreate)"'
    <variable>TREEOUTPUT</variable>
  </tree>
To write complete selection as single lines into a text file use

Code: Select all

for i in $TREEOUTPUT;
   do
      echo $i >> /tmp/list
   done
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#57 Post by jpeps »

Figured a way to do the scrollable checklist with a createcheckbox function within a scrollable vbox
Attachments
gnewpet-checkbox.png
(65.1 KiB) Downloaded 771 times

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#58 Post by RSH »

I select "Batch Mode" then clicking on "Batch Copy" - nothing happens.

Output after running gnewpet:

Code: Select all

** (gtkdialog:31852): WARNING **: create_tree(): A TreeView with no label.
**
ERROR:automaton.c:1833:connect_tree_signals: assertion failed: (tree_view != NULL && Attr != NULL)
Aborted
sh-4.1# 
jpeps wrote:Figured a way to do the scrollable checklist with a createcheckbox function within a scrollable vbox
Yes, this is exactly, what i'd meant and it looks good. Does it work or is it just step 1?
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#59 Post by RSH »

Inserting "<label>Batch Pets</label>" after <tree selection-mode="3"> inside your gnewpet script executes the batch window - but it is empty. :?

Clicking on "Select Pets" opens another empty window. :shock:

Clicking on "Select All" opens a window with all files listed. :)

Clicking OK inside full list window executes nothing. :shock: :?

Batch list in /tmp/batch is existing :!:
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#60 Post by jpeps »

Here's a version using gtkdialog checkboxes:

version 5.1 Put checklist in it's own scrollable vbox. Thanks RSH
version 5.2 1/23/12 Restored file report function
Attachments
gnewpet-5.2.pet
(2.74 KiB) Downloaded 600 times
gnewpet.png
(78.54 KiB) Downloaded 886 times
Last edited by jpeps on Mon 23 Jan 2012, 09:15, edited 3 times in total.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#61 Post by RSH »

Here's a version using gtkdialog checkboxes:
Yes, and this one works out of the box (something is wrong with 4.1?)

I did not have a look into the 5.0 script yet, but i must say:

:idea: Great Work! :idea:

:!: Fantastic! :!:
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#62 Post by jpeps »

RSH wrote:
Here's a version using gtkdialog checkboxes:
Yes, and this one works out of the box (something is wrong with 4.1?)
Works on my end. If you hack the script, all bets are off.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#63 Post by RSH »

jpeps wrote:Works on my end. If you hack the script, all bets are off.
Yes, by having a look into previous scripts, i meant to know this already.

However: great work, again.

Maybe you can go to the GtkDialog Development Section agin, post your .pet or script and point out that it is necessary to get this one - with a handle like the tree-item is handled (to get easily out the selected items just like the tree-item gives it to the programmer).

This would be a nice and useful GtkDialog-Feature...

Edit: maybe calling it CheckboxTree.
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#64 Post by RSH »

Code: Select all

	#echo -e "$(Xdialog --title "$WTITLE $WMTUSER" --stdout --no-cancel --editbox /tmp/applist_tmp  16 50)" >/usr/share/applications-desktop-files/$SPATH/applist-new
	EdNewList="$(Xdialog --title "$WTITLE $WMTUSER" --stdout --no-cancel --editbox /tmp/applist_tmp  16 50)"
	#echo -e $EdNewList >/usr/share/applications-desktop-files/$SPATH/applist-new
	
	# remove old list
	if [ "$EdNewList" != "" ]; then
		rm /usr/share/applications-desktop-files/$SPATH/applist
	fi
	
	# put into file
	for i in $EdNewList
	do
		if [ "$EdNewList" != "" ]; then
			echo -e $i >> /usr/share/applications-desktop-files/$SPATH/applist
		fi
	done
This will write output as single lines into a file.

f.e.:

file1
file2
file3...

Also the batch file (here=applist) will stay and will not loose it's data when closing the window (not using ok button)

Maybe good to know?
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#65 Post by jpeps »

The output from batch selection already remains in /tmp

Code: Select all

/tmp $ cat batch-list
CPUtemp_usage-2.0
flashplayer

Post Reply