summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2004-03-05 23:14:00 +0000
committerMarcel Holtmann <marcel@holtmann.org>2004-03-05 23:14:00 +0000
commite1d0ebd7b44b29e9ef54ec98f07c42c01e2fd173 (patch)
tree614803460309f969043d56879ac8a81958ae54d4 /scripts
parent49d9fac05db902dcd7e3909fcc1380f907c9b55b (diff)
Update bluepin script for GTK2
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bluepin47
1 files changed, 26 insertions, 21 deletions
diff --git a/scripts/bluepin b/scripts/bluepin
index 66eec987..607facba 100755
--- a/scripts/bluepin
+++ b/scripts/bluepin
@@ -3,11 +3,13 @@
# Bluetooth PIN helper
# Written by Maxim Krasnyansky <maxk@qualcomm.com>
#
-import sys, os, string, popen2
+import sys, os, string, popen2, pygtk
+
+pygtk.require('2.0')
# X Display initialization.
-# Find running X Server and parse it's arguments.
-# Set enviroment variables DISPLAY and XAUTHORITY
+# Find running X Server and parse its arguments.
+# Set environment variables DISPLAY and XAUTHORITY
# using info extracted from X Server args.
#
def set_display():
@@ -31,55 +33,58 @@ def set_display():
# Set X display before initializing GTK
set_display()
-from gtk import *
+# Some versions of fontconfig will segfault if HOME isn't set.
+os.environ['HOME'] = ""
+
+import gtk
# Dialog Class
DLG_OK = 1
DLG_CANCEL = 2
-class Dialog(GtkDialog):
+class Dialog(gtk.Dialog):
result = DLG_CANCEL
args = {}
- def __init__(self, modal=FALSE, mesg=None, args = {}):
- GtkDialog.__init__(self)
+ def __init__(self, modal=gtk.FALSE, mesg=None, args = {}):
+ gtk.Dialog.__init__(self)
self.args = args
self.set_modal(modal)
- self.set_usize(400, 0)
- self.set_uposition(300,300)
+# self.set_usize(400, 0)
+# self.set_uposition(300,300)
self.connect("destroy", self.quit)
self.connect("delete_event", self.quit)
self.action_area.set_border_width(2)
- ok = GtkButton("Accept")
+ ok = gtk.Button("Accept")
ok.connect("clicked", self.ok)
self.action_area.pack_start(ok, padding = 20)
ok.show()
- cl = GtkButton("Reject")
+ cl = gtk.Button("Reject")
cl.connect("clicked", self.cancel)
self.action_area.pack_start(cl, padding = 20)
cl.show()
if mesg:
- msg = GtkLabel()
+ msg = gtk.Label("")
msg.set_text(mesg)
self.vbox.pack_start(msg, padding = 10)
msg.show()
self.ents = []
for k in self.args.keys():
- hbox = GtkHBox()
+ hbox = gtk.HBox()
hbox.set_border_width(5)
self.vbox.pack_start(hbox)
hbox.show()
- l = GtkLabel()
- e = GtkEntry()
+ l = gtk.Label("")
+ e = gtk.Entry()
l.set_text( k )
e.set_text( self.args[k] )
e.connect("key_press_event", self.key_press)
- hbox.pack_start(l, padding = 10, expand = FALSE)
+ hbox.pack_start(l, padding = 10, expand = gtk.FALSE)
hbox.pack_start(e)
l.show()
e.show()
@@ -89,10 +94,10 @@ class Dialog(GtkDialog):
self.ents[0][1].grab_focus()
def key_press(self, entry, event):
- if event.keyval == GDK.Return:
+ if event.keyval == gtk.keysyms.Return:
entry.emit_stop_by_name("key_press_event")
self.ok()
- elif event.keyval == GDK.Escape:
+ elif event.keyval == gtk.keysyms.Escape:
entry.emit_stop_by_name("key_press_event")
self.cancel()
@@ -110,13 +115,13 @@ class Dialog(GtkDialog):
def quit(self, *args):
self.hide()
self.destroy()
- mainquit()
+ gtk.mainquit()
-def dialog(title, mesg, args, modal = FALSE):
+def dialog(title, mesg, args, modal = gtk.FALSE):
dlg = Dialog(args = args, mesg = mesg, modal = modal)
dlg.set_title(title)
dlg.show()
- mainloop()
+ gtk.mainloop()
return dlg.result
def main(*args):