Page 30 of 42

gtkdialog memory usage: new versus old versions

Posted: Thu 27 Sep 2012, 00:15
by mcewanw
thunor wrote:Let's test :)
...
Let's concentrate on htop's RES (resident memory) column -> VIRT, RES and SHR in top output
gtkdialog memory usage. My results aren't quite so kind. Using some actual gtkdialog3 (ver 0.7.20) compatible apps:

On slacko-5.3.3 with supplied gtkdialog version 0.8.0

Precord-8.0.8: VIRT:34768 RES:8486 SHR:6984
Pwsget: VIRT:34300 RES:8316 SHR:6872
Pfetch: VIRT:34856 RES:8788 SHR:7188
-----

On slacko-5.3.3 with oldyeller compiled gtkdialog 0.8.2

Precord-8.0.8: VIRT:30440 RES:8976 SHR:7484
Pwsget: VIRT:30408 RES:8844 SHR:7372
Pfetch: VIRT:30580 RES:9072 SHR:7468
-----

On Wary 5.3 with supplied gtkdialog3 version 0.7.20

Precord-8.0.8: VIRT:20344 RES:7820 SHR:6464
Pwsget: VIRT:20396 RES:7704 SHR:6340
Pfetch: VIRT:20464 RES:8024 SHR:6504

So main increase in resource usage is in VIRT. But still around one MByte increase for each running gtkdialog application for the RES portion. The increase probably doesn't matter on most people's systems though and the programmer can certainly do a lot more with the new version.

Posted: Thu 27 Sep 2012, 21:50
by technosaurus
comparing apples to oranges I see... the entire backend environment was different (look at the difference between any gtk program between those systems)

Anyhow that's not why I came ... beginning of gtkbuilder transition - got the gui to display but still need to figure out the signals (I couldn't find a 1 to 1 replacement, so I used my best guess and apparently guessed wrong)

just open up existing glade files with glade-3 and save-as then click gtkbuilder and overwrite the existing file

Edit: I wanted to clarify that this will remove glade support an replace it with gtk's builtin gtkbuilder but is not finished (callbacks aren't working and the build system still checks for glade, I removed libglade from the final link manually when I built it)

Posted: Fri 28 Sep 2012, 05:13
by mcewanw
technosaurus wrote:comparing apples to oranges I see... the entire backend environment was different (look at the difference between any gtk program between those systems)
Yes, of course. That explains the difference indeed. It isn't the version of gtkdialog being used that changes the resource usage, it is the background environment between these puppies. I feel at peace with using Thunor's new one now, which was a great deal of good work on his part! :-)

Alas that Linux more generally bloats over time too.

Posted: Sat 29 Sep 2012, 06:09
by technosaurus
I have gtkbuilder figured out - the handler callback requires this format:

Code: Select all

static gboolean
gtk_button_signal_handler_connector(
		GtkBuilder *builder,
		GObject *object, 
		const gchar *signal_name, 
		const gchar *signal_handler, 
		GObject *connect_object, 
		GConnectFlags flags, 
		gpointer user_data){
	gint n;
	gchar *signal_names[] = {
		"activate", "clicked", "enter", "leave", "pressed", "released", NULL };


for (n = 0; signal_names[n] != NULL; ++n) {
		if (g_ascii_strcasecmp(signal_name, signal_names[n]) == 0) {
			g_signal_connect(object, 
					signal_names[n], 
					G_CALLBACK(on_any_button_clicked), 
					g_strdup(signal_handler));
			return TRUE;
		}
	}
	return FALSE;
}


static gboolean 
signal_handler_connector(
		GtkBuilder *builder,
		GObject *object,
		const gchar *signal_name,
		const gchar *signal_handler,
		GObject *connect_object,
		GConnectFlags flags,
		gpointer user_data)
{


	if (GTK_IS_TOOL_BUTTON(object))
		if (gtk_button_signal_handler_connector(builder,
			object, 
			signal_name, 
			signal_handler, 
			connect_object, 
			flags, 
			user_data))
			return; //may need TRUE?
}
The rest _could_ just be cut/paste, but it looks like it could use stuff from automaton.c, but the functions are declared static, so the question is move it to automaton so that we can use the code and keep it static to help the compiler keep it small? leave it as is and write a bunch of duplicate functions? or add some function headers to automaton.h and remove some static declarations? I'm going to stop here until further input, but I am leaning toward putting it in automaton.

Posted: Sat 29 Sep 2012, 22:00
by thunor
Thanks technosaurus, added to issue tracker for a future update.

http://code.google.com/p/gtkdialog/issues/detail?id=12

Posted: Sat 29 Sep 2012, 22:35
by technosaurus
thunor wrote:Thanks technosaurus, added to issue tracker for a future update.

http://code.google.com/p/gtkdialog/issues/detail?id=12
thanks, I got a little burnt out tracking everything down and feel like I should consider an alternative to just cut/pasting to the original considering all the improvements made to the rest of the toolchain since the last time glade was touched - it may be straight forward enough to use shared code, but I didn't delve that far, - just enough to get the toolbar button example to work.

Posted: Sat 29 Sep 2012, 22:57
by zigbert
Thunor
I have been working with great new stuff in 0.8.2, and most of it is working great. However, I have met some limitations....

I am struggling with signals in the <tree> widget.

The dream is to move items in list, and that didn't look too advanced at first, but now...
The attribute reorderable="true" works as expected, and with the support of <output file> in gtkdialog-0.8.2 everything should be fine. - But no go.
I have tried several attempts, and this is the closest I get.

In pMusic it is required to update the <input file> after moved a track in playlist (<tree>). Else, the new sort order won't be kept the next time the user adds a track to the list (refresh <input file>) . The first issue I met was that <output file> only kept data from the exported column - not the whole tree which I find more logical. I see input/output as one data-flow. Second, I couldn't get the <action>save: happen before I grab the output file for further work. (ie. to update the <input file> depending on the new sort-order in the <output file>.) The code-example shows the problem.

The first issue has a possible workaround with an extra grep-loop, while I can't see an immediate solution to the second issue.

Code: Select all

#!/bin/sh

echo -e "1\n2\n3" > /tmp/input
echo > /tmp/output

echo '
<window>
 <vbox>
  <text><label>Move items in list and check output in terminal</label></text>
  <tree reorderable="true" column-header-active="0">
   <label>A</label>
   <variable>TREE</variable>
   <input file>/tmp/input</input>
   <output file>/tmp/output</output>
   <action signal="button-release-event">echo "button-release-event get the signal first. That is why I save:TREE"</action>
   <action signal="enter-notify-event">echo "enter-notify-event gets the signal later. But output file is not updated"</action>
   <action signal="button-release-event">save:TREE</action>
   <action signal="enter-notify-event">cat /tmp/output</action>
  </tree>
  <hbox><button ok></button></hbox>
 </vbox>
</window>
' | gtkdialog -s
When talking about the <tree> widget, I want to mention the other 'weakness' that makes me sometimes use the <table> instead. The <tree> auto-resize the column-width to show all content of input file. Maybe a nice feature sometimes, but with large input data, mostly not (my opinion). But worse, - it does only auto-expand column-width, never shrink again.


Thank you for all the goodies
Sigmund

Posted: Sun 30 Sep 2012, 00:51
by oldyeller
I have a couple of questions;

1) what are the names of the gtk icons that I can use for buttons?

2) How can I use the menubar widget and the text widget together?

I am planning on making a reader and than a simple word processeor and any help would be great.

Thanks

Posted: Sun 30 Sep 2012, 03:27
by smokey01
Is this what you are looking for?

#! /bin/bash
export MAIN_DIALOG='
<vbox>
<frame Stock>
<tree rules_hint="true" exported_column="1">
<height>400</height><width>250</width>
<label>Stock ID</label>
<item stock="gtk-dialog-authentication">gtk-dialog-authentication</item>
<item stock="gtk-dialog-info">gtk-dialog-info</item>
<item stock="gtk-dialog-warning">gtk-dialog-warning</item>
<item stock="gtk-dialog-error">gtk-dialog-error</item>
<item stock="gtk-dialog-question">gtk-dialog-question</item>
<item stock="gtk-dnd">gtk-dnd</item>
<item stock="gtk-dnd-multiple">gtk-dnd-multiple</item>
<item stock="gtk-about">gtk-about</item>
<item stock="gtk-add">gtk-add</item>
<item stock="gtk-apply">gtk-apply</item>
<item stock="gtk-bold">gtk-bold</item>
<item stock="gtk-cancel">gtk-cancel</item>
<item stock="gtk-cdrom">gtk-cdrom</item>
<item stock="gtk-clear">gtk-clear</item>
<item stock="gtk-close">gtk-close</item>
<item stock="gtk-color-picker">gtk-color-picker</item>
<item stock="gtk-convert">gtk-convert</item>
<item stock="gtk-connect">gtk-connect</item>
<item stock="gtk-copy">gtk-copy</item>
<item stock="gtk-cut">gtk-cut</item>
<item stock="gtk-delete">gtk-delete</item>
<item stock="gtk-directory">gtk-directory</item>
<item stock="gtk-disconnect">gtk-disconnect</item>
<item stock="gtk-edit">gtk-edit</item>
<item stock="gtk-execute">gtk-execute</item>
<item stock="gtk-file">gtk-file</item>
<item stock="gtk-find">gtk-find</item>
<item stock="gtk-find-and-replace">gtk-find-and-replace</item>
<item stock="gtk-floppy">gtk-floppy</item>
<item stock="gtk-fullscreen">gtk-fullscreen</item>
<item stock="gtk-goto-bottom">gtk-goto-bottom</item>
<item stock="gtk-goto-first">gtk-goto-first</item>
<item stock="gtk-goto-last">gtk-goto-last</item>
<item stock="gtk-goto-top">gtk-goto-top</item>
<item stock="gtk-go-back">gtk-go-back</item>
<item stock="gtk-go-down">gtk-go-down</item>
<item stock="gtk-go-forward">gtk-go-forward</item>
<item stock="gtk-go-up">gtk-go-up</item>
<item stock="gtk-harddisk">gtk-harddisk</item>
<item stock="gtk-help">gtk-help</item>
<item stock="gtk-home">gtk-home</item>
<item stock="gtk-index">gtk-index</item>
<item stock="gtk-indent">gtk-indent</item>
<item stock="gtk-info">gtk-info</item>
<item stock="gtk-unindent">gtk-unindent</item>
<item stock="gtk-italic">gtk-italic</item>
<item stock="gtk-jump-to">gtk-jump-to</item>
<item stock="gtk-justify-center">gtk-justify-center</item>
<item stock="gtk-justify-fill">gtk-justify-fill</item>
<item stock="gtk-justify-left">gtk-justify-left</item>
<item stock="gtk-justify-right">gtk-justify-right</item>
<item stock="gtk-leave-fullscreen">gtk-leave-fullscreen</item>
<item stock="gtk-missing-image">gtk-missing-image</item>
<item stock="gtk-media-forward">gtk-media-forward</item>
<item stock="gtk-media-next">gtk-media-next</item>
<item stock="gtk-media-pause">gtk-media-pause</item>
<item stock="gtk-media-play">gtk-media-play</item>
<item stock="gtk-media-previous">gtk-media-previous</item>
<item stock="gtk-media-record">gtk-media-record</item>
<item stock="gtk-media-rewind">gtk-media-rewind</item>
<item stock="gtk-media-stop">gtk-media-stop</item>
<item stock="gtk-network">gtk-network</item>
<item stock="gtk-new">gtk-new</item>
<item stock="gtk-no">gtk-no</item>
<item stock="gtk-ok">gtk-ok</item>
<item stock="gtk-open">gtk-open</item>
<item stock="gtk-paste">gtk-paste</item>
<item stock="gtk-preferences">gtk-preferences</item>
<item stock="gtk-print">gtk-print</item>
<item stock="gtk-print-preview">gtk-print-preview</item>
<item stock="gtk-properties">gtk-properties</item>
<item stock="gtk-quit">gtk-quit</item>
<item stock="gtk-redo">gtk-redo</item>
<item stock="gtk-refresh">gtk-refresh</item>
<item stock="gtk-remove">gtk-remove</item>
<item stock="gtk-revert-to-saved">gtk-revert-to-saved</item>
<item stock="gtk-save">gtk-save</item>
<item stock="gtk-save-as">gtk-save-as</item>
<item stock="gtk-select-color">gtk-select-color</item>
<item stock="gtk-select-font">gtk-select-font</item>
<item stock="gtk-sort-ascending">gtk-sort-ascending</item>
<item stock="gtk-sort-descending">gtk-sort-descending</item>
<item stock="gtk-spell-check">gtk-spell-check</item>
<item stock="gtk-stop">gtk-stop</item>
<item stock="gtk-strikethrough">gtk-strikethrough</item>
<item stock="gtk-undelete">gtk-undelete</item>
<item stock="gtk-underline">gtk-underline</item>
<item stock="gtk-undo">gtk-undo</item>
<item stock="gtk-yes">gtk-yes</item>
<item stock="gtk-zoom-100">gtk-zoom-100</item>
<item stock="gtk-zoom-fit">gtk-zoom-fit</item>
<item stock="gtk-zoom-in">gtk-zoom-in</item>
<item stock="gtk-zoom-out">gtk-zoom-out</item>
</tree>
</frame>
<hbox>
<button cancel></button>
<button ok></button>
</hbox>
</vbox>
'

gtkdialog --program=MAIN_DIALOG

Posted: Sun 30 Sep 2012, 07:10
by oldyeller
Thanks for the list smokey01

1 questioned answered. thanks again

Posted: Sun 30 Sep 2012, 10:07
by zigbert
Minor updates in my test-script

Posted: Sun 30 Sep 2012, 10:14
by vovchik
@ oldyeller

Make an hbox that contains both the menubar and the text widget. I just added a few lines to Thunor's example:

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

IMAGEFILE=( $(find /usr/share/icons -maxdepth 1 -type f | head -3) )

export MAIN_DIALOG='
<window title="MenuBar" resizable="false" width-request="360" height-request="240"  border-width="0">
	<vbox spacing="0">
	<hbox>
		<menubar>
			<menu label="_Stock Images" use-underline="true">
				<menuitem stock-id="gtk-about"></menuitem>
				<menuitem stock-id="gtk-add"></menuitem>
				<menuitemseparator></menuitemseparator>
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
			</menu>
			<menu use-underline="true">
				<menuitem icon-name="abiword" label="AbiWord"></menuitem>
				<menuitem icon-name="gnumeric" label="Gnumeric 32px">
					<height>32</height>
				</menuitem>
				<menuitem icon-name="gimp" label="_Gimp 48px" use-underline="true">
					<height>48</height>
				</menuitem>
				<label>"_Theme Images"</label>
			</menu>
			<menu use-underline="true">
				<menuitem image-name="'"${IMAGEFILE[0]}"'" label="Original Size"></menuitem>
				<menuitem image-name="'"${IMAGEFILE[1]}"'">
					<label>32px</label>
					<height>32</height>
					<width>32</width>
				</menuitem>
				<menuitem image-name="'"${IMAGEFILE[2]}"'" label="48px">
					<height>48</height>
					<width>48</width>
				</menuitem>
				<label>"_File Images"</label>
			</menu>
		</menubar>
			<text>
				<label>This is static text.</label>
			</text>
	</hbox>
	</vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

Posted: Sun 30 Sep 2012, 15:58
by oldyeller
@ vovchik,


Thanks I will check out what you did and go from there and see what I can do.

Posted: Sun 30 Sep 2012, 18:42
by vovchik
@ oldyeller

You can also put the text tag into another vbox together with the menubar:

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

IMAGEFILE=( $(find /usr/share/icons -maxdepth 1 -type f | head -3) )

export MAIN_DIALOG='
<window title="MenuBar" resizable="false" width-request="360" height-request="240"  border-width="0">
	<vbox spacing="0">
	<vbox>
		<menubar>
			<menu label="_Stock Images" use-underline="true">
				<menuitem stock-id="gtk-about"></menuitem>
				<menuitem stock-id="gtk-add"></menuitem>
				<menuitemseparator></menuitemseparator>
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
			</menu>
			<menu use-underline="true">
				<menuitem icon-name="abiword" label="AbiWord"></menuitem>
				<menuitem icon-name="gnumeric" label="Gnumeric 32px">
					<height>32</height>
				</menuitem>
				<menuitem icon-name="gimp" label="_Gimp 48px" use-underline="true">
					<height>48</height>
				</menuitem>
				<label>"_Theme Images"</label>
			</menu>
			<menu use-underline="true">
				<menuitem image-name="'"${IMAGEFILE[0]}"'" label="Original Size"></menuitem>
				<menuitem image-name="'"${IMAGEFILE[1]}"'">
					<label>32px</label>
					<height>32</height>
					<width>32</width>
				</menuitem>
				<menuitem image-name="'"${IMAGEFILE[2]}"'" label="48px">
					<height>48</height>
					<width>48</width>
				</menuitem>
				<label>"_File Images"</label>
			</menu>
		</menubar>
			<text>
				<label>This is static text.</label>
			</text>
	</vbox>
	</vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

Posted: Mon 01 Oct 2012, 01:13
by oldyeller
@ vovchik

Thanks again for this one too, Will take a look also at this one and see what I can come up with.

Posted: Mon 01 Oct 2012, 09:26
by vovchik
@ oldyeller

This is the same stuff again, but with an edit box.

With kind regards,
vovchik

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

IMAGEFILE=( $(find /usr/share/icons -maxdepth 1 -type f | head -3) )

export MAIN_DIALOG='
<window title="MenuBar" resizable="false" width-request="360" height-request="240"  border-width="0">
	<vbox spacing="0">
	<vbox>
		<menubar>
			<menu label="_Stock Images" use-underline="true">
				<menuitem stock-id="gtk-about"></menuitem>
				<menuitem stock-id="gtk-add"></menuitem>
				<menuitemseparator></menuitemseparator>
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
			</menu>
			<menu use-underline="true">
				<menuitem icon-name="abiword" label="AbiWord"></menuitem>
				<menuitem icon-name="gnumeric" label="Gnumeric 32px">
					<height>32</height>
				</menuitem>
				<menuitem icon-name="gimp" label="_Gimp 48px" use-underline="true">
					<height>48</height>
				</menuitem>
				<label>"_Theme Images"</label>
			</menu>
			<menu use-underline="true">
				<menuitem image-name="'"${IMAGEFILE[0]}"'" label="Original Size"></menuitem>
				<menuitem image-name="'"${IMAGEFILE[1]}"'">
					<label>32px</label>
					<height>32</height>
					<width>32</width>
				</menuitem>
				<menuitem image-name="'"${IMAGEFILE[2]}"'" label="48px">
					<height>48</height>
					<width>48</width>
				</menuitem>
				<label>"_File Images"</label>
			</menu>
		</menubar>
		<edit>
			<variable>EDITOR</variable>
			<height>150</height>
			<width>350</width>
			<default>
				"This is the default text of the editor."
			</default>
		</edit>
		<hbox>
			<button cancel></button>
			<button ok></button>
		</hbox>
	</vbox>
	</vbox>
</window>
'

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

Posted: Mon 01 Oct 2012, 21:19
by oldyeller
@ vovchik

Thanks again. I will no longer be posting any more on this thread but instead will be posting any quwstions on the Gtkdialog-Tips by zigbert.

This is the thread I should be using correct?

Cheers

Posted: Tue 02 Oct 2012, 21:30
by smokey01
Is gtkdialog 0.8.2 suppose to be backward compatible with 0.8.1?

I have a small script that works fine in 0.8.1 but not 0.8.2.

BTW I compiled it in FD64-600.

Thanks

Posted: Wed 03 Oct 2012, 14:23
by thunor
I'm in the process of setting-up slacko 533 to use as my main distro so Sigmund I will look into your issues once I'm settled.

oldyeller: Just create a new topic in the Programming section asking for help with whatever it is you want help with.

smokey01: Can we see the small script please?

Posted: Wed 03 Oct 2012, 21:15
by smokey01
#!/bin/sh

# A simple GUI to give someone a "Nudge"
# (maybe add an icon on wbar to run this)

#set work dir
APPDIR=$(pwd)
export APPDIR

someone1 () {
echo "boo" | ncat -i 1 someone1.no-ip.info 1234
}
export -f someone1

someone2 () {
echo "boo" | ncat -i 1 someone2.no-ip.info 1234
}
export -f someone2

toggle () {
# If big-ears is already running, then kill it
if pidof ncat | grep [0-9] > /dev/null
then
exec killall ncat; exec killall big-ears
else
# Start big-ears running again
$APPDIR/big-ears
# change above path to point to your psip binary file.
exit
fi
}
export -f toggle

IMAGEFILE="$APPDIR/bill.jpg"
IMAGEFILE2="$APPDIR/bob.jpg"

export script='
<window title="Nudger" icon-name="gtk-preferences" 0 0>
<vbox>
<frame Contacts:>
<hbox>
<button>
<width>48</width>
<input file>'"$IMAGEFILE"'</input>
<action>someone1</action>
</button>
<button>
<width>48</width>
<input file>'"$IMAGEFILE2"'</input>
<action>someone2</action>
</button>
</hbox>
</frame>

<frame Listening Mode:>
<vbox>
<button>
<width>48</width>
<label>On / Off</label>
<action>toggle</action>
</button>
</vbox>
</frame>

<hbox>
<button use-stock="true" label="gtk-quit"></button>
</hbox>
</vbox>
</window>'

gtkdialog -p script