Real time removal of toolitem
Hey I was wondering if it is possible to remove a tool item from a toolbar instantly, I am working with some preferences on my app and want to have the preference changes displayed instantly, I have tried to destroy the widget but it still works, am I missing something or is it just not supported? I don't see why it's not supported as a toolitem is a widget and should be destroyed like all other widgets and I have tried the while( gtk_pending_events( ) )... trick and that's not worked so does anyone have any ideas? Thanks, Neil Munro ___ 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
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
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 : > 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