Advertisement
Guest User

Untitled

a guest
Apr 8th, 2010
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. # A nifty GUI controlling the window controls position
  4. #
  5. # Depends on python-gconf (started from a python-gconf example)
  6. #
  7. # @version 0.1
  8. # @author alex(at)eftimie(dot)ro
  9. #
  10.  
  11. import gtk
  12. import gconf
  13.    
  14. def callback(button, client):
  15.     global left, right, key, entry
  16.     if left.get_active():
  17.         s = "maximize,minimize,close:"
  18.     elif right.get_active():
  19.         s = ":maximize,minimize,close"
  20.     else:
  21.         s = entry.get_text()
  22.     client.set_string (key, s)
  23.     entry.set_text(s)
  24.  
  25. # Gconf stuff
  26. client = gconf.client_get_default ()
  27. key = "/apps/metacity/general/button_layout"
  28.  
  29. # Gtk window
  30. window = gtk.Window()
  31. window.set_title("Settings")
  32. left = gtk.RadioButton(group=None, label='Left')
  33. right = gtk.RadioButton(left, 'Right')
  34. custom = gtk.RadioButton(left, 'Custom')
  35. entry = gtk.Entry()
  36. box = gtk.VBox(False, 0)
  37. box.add(gtk.Label("Choose window controls position: "))
  38. box.add(left)
  39. box.add(right)
  40. # Custom
  41. box2 = gtk.HBox(False, 0)
  42. box2.add(custom)
  43. #box2.add(entry)
  44. box.add(box2)
  45. box.add(entry)
  46. apply_button = gtk.Button('Apply')
  47. done = gtk.Button('Done')
  48. box3 = gtk.HBox(False, 0)
  49. box3.add(apply_button)
  50. box3.add(done)
  51. box.add(box3)
  52. custom.set_active(True)
  53. window.add (box)
  54. window.show_all ()
  55.  
  56. # Widget events
  57. window.connect('delete_event', gtk.main_quit)
  58. done.connect('clicked', gtk.main_quit)
  59. left.connect ('toggled', callback, client)
  60. right.connect ('toggled', callback, client)
  61. custom.connect ('toggled', callback, client)
  62. apply_button.connect('clicked', callback, client)
  63.  
  64. # If key isn't writable, then set insensitive
  65. left.set_sensitive (client.key_is_writable (key))
  66. right.set_sensitive (client.key_is_writable (key))
  67.  
  68. # Get current settings
  69. entry.set_text(client.get_string(key))
  70.  
  71. gtk.main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement