Re: [pygtk] gtk theme switch

2002-07-30 Thread Philippe Gendreau

* James Henstridge [EMAIL PROTECTED] [2002-07-30 09:15]:
 For gtk 1.2, pretty much the only way to cause all future apps to use 
 the new theme, you need to write out a ~/.gtkrc file.

This is for python 1.5.2
When you say write out a ~/.gtkrc what do you mean exactly.

I am trying to switch from one theme to the other and to do it
I parse the different gtkrc files. 

Why would I want to write it out and where.
--
Philippe Gendreau
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] gtk theme switch

2002-07-29 Thread Philippe Gendreau

I'd really like to make that work...

I settled for updating just the window theme (it's running full screen
anyway). I could not find more information than what's in the pygtk
tutorial (rc_parse('rc file')).

I'd really appreciate it if someone could point me in the direction of some
docs or programs that make use of this kind of stuff.

My main question now is:
How do I update the application theme for all present and future widgets?

Thanks again.
--
Philippe Gendreau
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] gtk theme switch

2002-07-22 Thread Philippe Gendreau

Hi,
I have been trying to offer a theme selection in an application,
but I can't get the chosen theme to update the screen. I'm not sure if
I'd like it to update only the application it runs from or the whole
desktop theme, but if I could get at least get one of both working I'd 
be happy. Ideally, I'd like to have a desktop-theme switcher too.

I have made a little example-app to test it. If someone could look at it 
and tell me what I am missing it would be really appreciated.

Thanks a lot.
--
Philippe Gendreau


#!/usr/bin/env python

# theme.py

import gtk
import isys, os
from _gtk import gtk_set_locale, gtk_rc_init, gtk_rc_reparse_all
from _gtk import _gtk_nuke_rc_files, _gtk_nuke_rc_mtimes

class ThemeWindow:

def get_themes(self,clist):
for dir in os.listdir('/usr/share/themes'):
row = clist.append (((dir),))
clist.set_row_data (row, dir)

# If we come here, then the user has selected a row in the list.
def selection_made(self, clist, row, event, data=None):
# Get the text that is stored in the selected row
# which was clicked in. We will receive it as a pointer in the
# argument text.
text = clist.get_text(row, 0)

# Just prints some information about the selected row
#print (You selected row %d.\n % row)
print (You selected row %d.\n
   The text in this cell is %s\n % (row, text))

rcfile = '/usr/share/themes/' + text + '/gtk/gtkrc'
gtk.rc_parse(rcfile)

_gtk_nuke_rc_mtimes ()
_gtk_nuke_rc_files ()
gtk_rc_reparse_all ()
gtk_rc_init ()

return

def __init__(self):
window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)
window.set_usize(300, 150)

window.set_title(Gtk+ Theme Chooser)
window.connect(destroy, gtk.mainquit)

vbox = gtk.GtkVBox(gtk.FALSE, 5)
vbox.set_border_width(5)
window.add(vbox)
vbox.show()

# Create a scrolled window to pack the CList widget into
scrolled_window = gtk.GtkScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)

vbox.pack_start(scrolled_window, gtk.TRUE, gtk.TRUE, 0)
scrolled_window.show()

# Create the CList.
clist = gtk.GtkCList()

# When a selection is made, we want to know about it. The callback
# used is selection_made, and its code can be found further down
clist.connect(select_row, self.selection_made)

# It isn't necessary to shadow the border, but it looks nice :)
clist.set_shadow_type(gtk.SHADOW_OUT)

# What however is important, is that we set the column widths as
# they will never be right otherwise. Note that the columns are
# numbered from 0 and up (to 1 in this case).
clist.set_column_width(0, 150)

# Add the CList widget to the vertical box and show it.
scrolled_window.add(clist)
clist.show()

self.get_themes(clist)

# The interface is completely set up so we show the window and
# enter the gtk_main loop.
window.show()

def main():
gtk.mainloop()
return 0

if __name__ == __main__:
ThemeWindow()
main()