Re: Real time removal of toolitem

2012-01-14 Thread David Nečas
On Sat, Jan 14, 2012 at 12:34:10PM +, Neil Munro wrote:
   I was wondering if it is possible to remove a tool item from a
 toolbar instantly,

=
from gi.repository import Gtk

def modify(b, t):
if t.get_n_items() == 1:
b.set_stock_id(Gtk.STOCK_REMOVE)
b2 = Gtk.ToolButton.new_from_stock(Gtk.STOCK_HELP)
b2.show_all()
t.insert(b2, 1)
else:
b.set_stock_id(Gtk.STOCK_ADD)
t.get_nth_item(1).destroy()
print t.get_n_items()

w = Gtk.Window()
w.connect('destroy', Gtk.main_quit)
w.set_default_size(200,40)

t = Gtk.Toolbar()
w.add(t)

b = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ADD)
b.connect('clicked', modify, t)
t.insert(b, 0)

w.show_all()
Gtk.main()
=

 I have tried
 to destroy the widget but it still works, am I missing something

Yes.  Hard to tell what.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Real time removal of toolitem

2012-01-14 Thread Neil Munro
Strange, I don't know why perhaps I had a typo I missed but it's
working now with a simple show/hide:

// Deal with terminal now, since it would just waste cpu cycles
dealing with it in a for loop
if( g_strrstr( sets-terminal, :false ) )
gtk_widget_hide( GTK_WIDGET( pd-tb_cmd ) );

else
gtk_widget_show( GTK_WIDGET( pd-tb_cmd ) );

Thanks though.

2012/1/14 David Nečas y...@physics.muni.cz:
 On Sat, Jan 14, 2012 at 12:34:10PM +, Neil Munro wrote:
       I was wondering if it is possible to remove a tool item from a
 toolbar instantly,

 =
 from gi.repository import Gtk

 def modify(b, t):
    if t.get_n_items() == 1:
        b.set_stock_id(Gtk.STOCK_REMOVE)
        b2 = Gtk.ToolButton.new_from_stock(Gtk.STOCK_HELP)
        b2.show_all()
        t.insert(b2, 1)
    else:
        b.set_stock_id(Gtk.STOCK_ADD)
        t.get_nth_item(1).destroy()
    print t.get_n_items()

 w = Gtk.Window()
 w.connect('destroy', Gtk.main_quit)
 w.set_default_size(200,40)

 t = Gtk.Toolbar()
 w.add(t)

 b = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ADD)
 b.connect('clicked', modify, t)
 t.insert(b, 0)

 w.show_all()
 Gtk.main()
 =

 I have tried
 to destroy the widget but it still works, am I missing something

 Yes.  Hard to tell what.

 Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: is thaere a way to exit(1)?

2012-01-14 Thread Gary Kline
On Fri, Jan 13, 2012 at 10:09:43PM +0100, David Ne??as wrote:
 
 On Fri, Jan 13, 2012 at 11:59:45AM -0800, Gary Kline wrote:
  I finally know =where= i want to exit my gtk program, but exit 
  just doesn't break me out of my while() loop.  what's the magin?
 
 exit() *does* terminate the program no matter what loop or whatever it
 might be running.
 
 So, most likely, you think your code calls exit() at some point but that
 actually never happens.
 
 The program might get stuck in the finalisation phase if some exit
 handler (e.g. atexit()-registered) or finaliser gets stuck but I suppose
 if you were registering such things you (a) would have told us (b) did
 not wonder what happened.
 
 Yeti
 
 
 P.S.: Calling exit() while within the Gtk+ main loop is a bit harsh.
 Normally one calls gtk_main_quit() and the program continues execution
 after gtk_main() ??? which typically means it then reaches the end of
 main() and terminates.
 


you were abs correct about exit().  i moved it around and
was able to verify that my code was doing what i had
thought.  that puts me back to the problem of my gtk
application going dark/dim; it looks like this may be a
feature of ubuntu linux.  i've posted to unubtuforums and
waiting.  --at any rate, thanks for your help.

gary

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
   Journey Toward the Dawn, E-Book: http://www.thought.org
  The 8.57a release of Jottings: http://jottings.thought.org
 Twenty-five years of service to the Unix community.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Iconview stock items

2012-01-14 Thread Neil Munro
I am working with an icon view and am trying to load stock items into
the gdk_pixbuf_new_from_file( ) but it's not working, I assume that is
perhaps because I am using the function wrong, is there a way to do
what I am trying to do?

I am following the tutorial here:
http://zetcode.com/tutorials/gtktutorial/gtkwidgetsII/ and simply
trying to swap out custom images for stock ones to use in my real
application once I have understood the principles correctly.

If anyone knows where I may be going wrong I would appreciate some
pointers, I know it's a widget like a treeview so requires a model and
that the model has a label and an image but beyond that without
getting the examples working I don't know how much I am understanding
is accurate or not.

Thanks,
Neil
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


how to have a dialog ask user if he want to type AGAIN?

2012-01-14 Thread Gary Kline

ok, one function runs in a recursive loop, endlessly.  i could do this
differently, say from main.  that is my question:  how do i get the
value 1 or TRUE back from a dialogue that asks simply: Talk again?

i have a slice of code that is a dialog with an OK button. 

gary

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
   Journey Toward the Dawn, E-Book: http://www.thought.org
  The 8.57a release of Jottings: http://jottings.thought.org
 Twenty-five years of service to the Unix community.

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list