PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:gtk-apply icon (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:gtk-apply icon
#850
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
First up thanks for a awesome resource. I've already gotten a lot of what I need done just by reading your examples.

Basically what i'm chasing is a way to add an icon to a hbox.

The example is a log output slowly being appended to a vbox.

Each log line will be text with either a green tick for success or a red cross for failure. I see both of these icons are there by default.

Thanks for any help or direction you can give.

Tom
 
  The administrator has disabled public write access.
#851
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
So far I'm trying to use something like the following. Although it doesn't seem to work.

Code:
$hbox = new GtkHBox();
$img = new GtkImage();
$img->render_icon('gtk-apply', Gtk::ICON_SIZE_DIALOG); 
$hbox->pack_start(new GtkLabel('Testing'), 0, 0);
$hbox->pack_start($img);
$vbox->pack_start($hbox,0);
$window->show_all();
T
 
  The administrator has disabled public write access.
#852
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
OK sorted it ;)

changed

Code:
$hbox = new GtkHBox();
$img = new GtkImage();
$img->render_icon('gtk-apply', Gtk::ICON_SIZE_DIALOG); 
$hbox->pack_start(new GtkLabel('Testing'), 0, 0);
$hbox->pack_start($img);
$vbox->pack_start($hbox,0);
$window->show_all();
to
Code:
$hbox = new GtkHBox();
$img = GtkImage::new_from_stock('gtk-apply', Gtk::ICON_SIZE_DIALOG);
$hbox->pack_start(new GtkLabel('Testing'), 0, 0);
$hbox->pack_start($img);
$vbox1->pack_start($hbox,0);
$window->show_all();
Now doing what I wanted. T
 
  The administrator has disabled public write access.
#853
kksou (Admin)
Admin
Posts: 391
graph
User Online Now Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 8  
Hi,

Glad you got it working.

Since yours is a log output, assuming the log will grow more than a screen size, here are a few "enhancements" you might want to try:

- you can use a treeview stuffed inside a scrolledwindow
- you can even stuff the vbox inside a scrolledwindow so that user can scroll the vbox
- you can also use a textview

There are ready sample codes for any of the above. If you have problem finding them, let me know, ok?

Regards,
/kksou
 
  The administrator has disabled public write access.
#855
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
Thanx for your reponse.

Already got sorted a lot of it now.

Have placed the scrolledwindow in a vbox.

Then another vbox in the scrolled window via add_with_viewport.

Have gotten a process spawned via idle_add such that processing automatically starts. Also got the window scrolling and the scroll bar going in the right direction.

Only two outstaning things at the moment are,

a) I'd like to change the background color of the scrolling vbox to be white.

b) I'd like for the application to close itself if it doesn't encounter any errors. At the moment if I call window->destroy or GTK::quit() I get a errors and the php process doesn't end.

Attached is an example of my app thus far.

T

 
  The administrator has disabled public write access.
#856
kksou (Admin)
Admin
Posts: 391
graph
User Online Now Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 8  
a) I'd like to change the background color of the scrolling vbox

Please refer to
Sample Code 8: How to set the background color of GtkLabel?

Like the GtkLabel, GtkVBox is also one of those "transparent" widgets. So you need to stuff the vbox inside a GtkEventBox and set the bg color on the eventbox.

b) I'd like for the application to close itself if it doesn't encounter any errors. At the moment if I call window->destroy or GTK::quit() I get a errors and the php process doesn't end.

What's the error message that you get?

Normally you can quit an application using GTK::quit(). I suspect you encounter some error because you didn't properly stop the Gtk::idle_add() or Gtk::timeout_add() before GTK::quit(). Try do a Gtk::idle_remove() before you do GTK::quit(). (Note: you need to take note of the handle id, which is returned by Gtk::idle_add(). You need the handle id for Gtk::idle_remove().)

Regards,
/kksou
 
  The administrator has disabled public write access.
#857
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
OK the background color certainly was a simple job.

Examing my code compared to your examples of idle_add .. you use a class for your long task where I'm only calling a function.

I'm starting to wonder if this is somehow the cause ?

Code:
$window->add($vbox);

$window->show_all();

Gtk::idle_add(start_processing()); 

Gtk::main();
The start_processing function runs a for loop at the moment and adds those green ticks and what not to the scrolledwindow. At the end of which I'd like to exit. Once again any thoughts would be appreciated. T
 
 
Last Edit: 2008/09/23 17:35 By CheSter.
  The administrator has disabled public write access.
#858
CheSter (User)
Fresh Boarder
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:gtk-apply icon 1 Month, 4 Weeks ago Karma: 0  
Sorted ;]

Changed

Code:
$window->add($vbox);

$window->show_all();

Gtk::idle_add(start_processing());

Gtk::main();
To
Code:
$window->add($vbox); 

$window->show_all(); 

$idleID = Gtk::idle_add('start_processing'); 
	
Gtk::main(); 
The idle_add lines being where I had screwed up. This resolved my exiting issues, warnings in the logs and awkward messages on the console. Thanx again for your help. T
 
 
Last Edit: 2008/09/23 17:43 By CheSter.
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2008. kksou.com. All Rights Reserved