mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
nice gui ;)
This commit is contained in:
parent
337e16391c
commit
be6427ceb8
38
jumpapplet
38
jumpapplet
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#Copyright Joel Schaerer 2008, 2009
|
#Copyright Joel Schaerer and Pierre Gueth 2008, 2009
|
||||||
#This file is part of autojump
|
#This file is part of autojump
|
||||||
|
|
||||||
#autojump is free software: you can redistribute it and/or modify
|
#autojump is free software: you can redistribute it and/or modify
|
||||||
@ -114,13 +114,12 @@ def popup(sender,button,activation):
|
|||||||
def collapse_home(path):
|
def collapse_home(path):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
menu=gtk.Menu()
|
menu=gtk.Menu()
|
||||||
if defaults["invert"]:
|
if defaults["invert"]:
|
||||||
item=gtk.MenuItem("quit")
|
item=gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
|
||||||
item.connect("activate",quit)
|
item.connect("activate",quit)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
item=gtk.MenuItem("settings")
|
item=gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES)
|
||||||
item.connect("activate",settings)
|
item.connect("activate",settings)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
@ -154,10 +153,10 @@ def popup(sender,button,activation):
|
|||||||
|
|
||||||
menu.append(gtk.SeparatorMenuItem())
|
menu.append(gtk.SeparatorMenuItem())
|
||||||
|
|
||||||
item=gtk.MenuItem("settings")
|
item=gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES)
|
||||||
item.connect("activate",settings)
|
item.connect("activate",settings)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
item=gtk.MenuItem("quit")
|
item=gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
|
||||||
item.connect("activate",quit)
|
item.connect("activate",quit)
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
@ -165,14 +164,15 @@ def popup(sender,button,activation):
|
|||||||
menu.popup(None,None,gtk.status_icon_position_menu,button,activation,sender)
|
menu.popup(None,None,gtk.status_icon_position_menu,button,activation,sender)
|
||||||
|
|
||||||
def settings(sender):
|
def settings(sender):
|
||||||
window=gtk.Window(gtk.WINDOW_TOPLEVEL)
|
window=gtk.Dialog("jump applet preferences",None,gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_SAVE,gtk.RESPONSE_OK,gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL))
|
||||||
window.set_title("jump applet settings")
|
|
||||||
window.set_border_width(3)
|
window.set_border_width(3)
|
||||||
window.set_resizable(False)
|
window.set_resizable(False)
|
||||||
|
if os.path.isfile("icon.png"): window.set_icon_from_file("icon.png")
|
||||||
|
elif os.path.isfile("/usr/share/autojump/icon.png"): window.set_icon_from_file("/usr/share/autojump/icon.png")
|
||||||
|
|
||||||
vbox=gtk.Table(6,2)
|
vbox=gtk.Table(5,2)
|
||||||
vbox.set_row_spacings(3)
|
vbox.set_row_spacings(3)
|
||||||
window.add(vbox)
|
window.get_child().add(vbox)
|
||||||
def add_string_setting(name,label,nsettings):
|
def add_string_setting(name,label,nsettings):
|
||||||
label=gtk.Label(label+' ')
|
label=gtk.Label(label+' ')
|
||||||
label.set_alignment(1.,.5)
|
label.set_alignment(1.,.5)
|
||||||
@ -205,19 +205,19 @@ def settings(sender):
|
|||||||
return (name,entry)
|
return (name,entry)
|
||||||
|
|
||||||
entries=[]
|
entries=[]
|
||||||
entries.append(add_string_setting("terminal","terminal program",0))
|
entries.append(add_string_setting("terminal","Terminal program",0))
|
||||||
entries.append(add_string_setting("navigator","navigator program",1))
|
entries.append(add_string_setting("navigator","Navigator program",1))
|
||||||
entries.append(add_integer_setting("maxpath","number of directories",2))
|
entries.append(add_integer_setting("maxpath","Number of directories",2))
|
||||||
entries.append(add_bool_setting("invert","list directories in reverse order",3))
|
entries.append(add_bool_setting("invert","List directories in reverse order",3))
|
||||||
entries.append(add_bool_setting("collapse","collapse home directory to ~",4))
|
entries.append(add_bool_setting("collapse","Collapse home directory to ~",4))
|
||||||
button=gtk.Button("save")
|
|
||||||
button.connect("clicked",save_settings,entries,window)
|
|
||||||
vbox.attach(button,0,2,5,6)
|
|
||||||
|
|
||||||
|
window.connect("response",save_settings,entries,window)
|
||||||
window.show_all();
|
window.show_all();
|
||||||
|
|
||||||
def save_settings(sender,entries,window):
|
def save_settings(sender,response,entries,window):
|
||||||
window.hide_all()
|
window.hide_all()
|
||||||
|
if response!=gtk.RESPONSE_OK: return
|
||||||
|
|
||||||
global defaults
|
global defaults
|
||||||
for name,entry in entries:
|
for name,entry in entries:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user