diff --git a/jumpapplet b/jumpapplet index 197ee55..9665da5 100755 --- a/jumpapplet +++ b/jumpapplet @@ -1,6 +1,6 @@ #!/usr/bin/env python -#Copyright Joel Schaerer 2008, 2009 +#Copyright Joel Schaerer and Pierre Gueth 2008, 2009 #This file is part of autojump #autojump is free software: you can redistribute it and/or modify @@ -113,14 +113,13 @@ def popup(sender,button,activation): else: def collapse_home(path): return path - - + menu=gtk.Menu() if defaults["invert"]: - item=gtk.MenuItem("quit") + item=gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT) item.connect("activate",quit) menu.append(item) - item=gtk.MenuItem("settings") + item=gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES) item.connect("activate",settings) menu.append(item) @@ -154,10 +153,10 @@ def popup(sender,button,activation): menu.append(gtk.SeparatorMenuItem()) - item=gtk.MenuItem("settings") + item=gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES) item.connect("activate",settings) menu.append(item) - item=gtk.MenuItem("quit") + item=gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT) item.connect("activate",quit) menu.append(item) @@ -165,14 +164,15 @@ def popup(sender,button,activation): menu.popup(None,None,gtk.status_icon_position_menu,button,activation,sender) def settings(sender): - window=gtk.Window(gtk.WINDOW_TOPLEVEL) - window.set_title("jump applet settings") + 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_border_width(3) 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) - window.add(vbox) + window.get_child().add(vbox) def add_string_setting(name,label,nsettings): label=gtk.Label(label+' ') label.set_alignment(1.,.5) @@ -205,19 +205,19 @@ def settings(sender): return (name,entry) entries=[] - entries.append(add_string_setting("terminal","terminal program",0)) - entries.append(add_string_setting("navigator","navigator program",1)) - 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("collapse","collapse home directory to ~",4)) - button=gtk.Button("save") - button.connect("clicked",save_settings,entries,window) - vbox.attach(button,0,2,5,6) + entries.append(add_string_setting("terminal","Terminal program",0)) + entries.append(add_string_setting("navigator","Navigator program",1)) + 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("collapse","Collapse home directory to ~",4)) + window.connect("response",save_settings,entries,window) window.show_all(); -def save_settings(sender,entries,window): +def save_settings(sender,response,entries,window): window.hide_all() + if response!=gtk.RESPONSE_OK: return + global defaults for name,entry in entries: try: