Commits

Erik Grinaker committed 7f9cbee

added preference to select doubleclick action; go to, or edit

Comments (0)

Files changed (8)

 
 ---------------[ xxxx-xx-xx : 0.4.1 ]---------------
 
-2005-03-16  Erik Grinaker <erikg@codepoet.no>
+2005-03-17  Erik Grinaker <erikg@codepoet.no>
 
 	* fix potential crash on quit with some pygtk versions
 
 	* improve the user interface for copying username/password
 	to clipboard
 
+	* added preference to select doubleclick action; go to, or edit
+
 2005-03-16  Erik Grinaker <erikg@codepoet.no>
 
 	* make io.file_monitor() handle NotSupportedError from gnome-vfs
 - check password strength while entering, using cracklib
 - option to autolock file after a period of inactivity
 - ask user to reload file if it is changed outside revelation
+- added preference to select doubleclick action; go to, or edit
 - improve user interface for copying passwords (and optionally
   usernames) to the clipboard
 
 - only copy/paste entries with keyboard shortcut when tree has focus
   (ctrl-c should copy selected label in dataview when focused)
 - bugfix: crash when gnome icon theme is missing or not configured
-- option to edit instead of run on doubleclick
 - bugfix: gnome.libgnome_module_info_get() removed in new gnome-python
 - clean up the build-system
 - examine drag/drop undo/redo crashes

data/revelation.schemas

 <gconfschemafile>
 	<schemalist>
 		<schema>
+			<key>/schemas/apps/revelation/behavior/doubleclick</key>
+			<applyto>/apps/revelation/behavior/doubleclick</applyto>
+			<owner>revelation</owner>
+			<type>string</type>
+			<default>goto</default>
+
+			<locale name="C">
+				<short>Action to take on doubleclick</short>
+				<long>
+					The action to take when doubleclicking an
+					account in the treeview - valid values
+					are "goto" and "edit".
+				</long>
+			</locale>
+		</schema>
+
+		<schema>
 			<key>/schemas/apps/revelation/clipboard/chain_username</key>
 			<applyto>/apps/revelation/clipboard/chain_username</applyto>
 			<owner>revelation</owner>

src/lib/config.py.in

 			self.get("launcher/website")
 			self.get("view/searchbar")
 			self.get("clipboard/chain_username")
+			self.get("behavior/doubleclick")
 
 		except ConfigError:
 			return False

src/lib/dialog.py

 		self.page_general = self.notebook.create_page("General")
 		self.__init_section_file(self.page_general)
 		self.__init_section_clipboard(self.page_general)
+		self.__init_section_doubleclick(self.page_general)
 		self.__init_section_pwgen(self.page_general)
 
 		self.page_gotocmd = self.notebook.create_page("Goto commands")
 		self.section_clipboard.append_widget(None, self.check_chain_username)
 
 
+	def __init_section_doubleclick(self, page):
+		"Sets up the doubleclick section"
+
+		self.section_doubleclick = page.add_section("Doubleclick")
+
+		# radio-button for go to
+		self.radio_doubleclick_goto = ui.RadioButton(None, "Go to account on doubleclick, if possible")
+		ui.config_bind(self.config, "behavior/doubleclick", self.radio_doubleclick_goto, "goto")
+
+		self.tooltips.set_tip(self.radio_doubleclick_goto, "Go to the account (open in external application) on doubleclick, if command is set and required data filled in")
+		self.section_doubleclick.append_widget(None, self.radio_doubleclick_goto)
+
+		# radio-button for edit
+		self.radio_doubleclick_edit = ui.RadioButton(self.radio_doubleclick_goto, "Edit account on doubleclick")
+		ui.config_bind(self.config, "behavior/doubleclick", self.radio_doubleclick_edit, "edit")
+
+		self.tooltips.set_tip(self.radio_doubleclick_edit, "Edit the account on doubleclick")
+		self.section_doubleclick.append_widget(None, self.radio_doubleclick_edit)
+
+
 	def __init_section_file(self, page):
 		"Sets up the file section"
 
 
 ##### FUNCTIONS #####
 
-def config_bind(cfg, key, widget):
+def config_bind(cfg, key, widget, data = None):
 	"Binds a config key to a UI widget"
 
-	if isinstance(widget, gtk.CheckMenuItem) or isinstance(widget, gtk.ToggleButton):
+	if isinstance(widget, gtk.RadioButton):
+		signal	= "toggled"
+
+		def cb_get(config, value, widget):
+			if value == data:
+				widget.set_active(True)
+
+		def cb_set(widget, key):
+			if widget.get_active() == True:
+				cfg.set(key, data)
+
+
+	elif isinstance(widget, gtk.CheckMenuItem) or isinstance(widget, gtk.ToggleButton):
 		signal	= "toggled"
 		cb_get	= lambda c,v,w:	w.set_active(v)
 		cb_set	= lambda w,k:	cfg.set(k, w.get_active())
 				self.set_active(i)
 
 
+class RadioButton(gtk.RadioButton):
+	"A radio button"
+
+	def __init__(self, group, label):
+		gtk.RadioButton.__init__(self, group, label)
+
+
 
 ##### MENU ITEMS #####
 

src/revelation.in

 	def __cb_tree_doubleclick(self, widget, data = None):
 		"Handles doubleclicks on the tree"
 
-		self.entry_goto(self.tree.get_selected())
+		if self.config.get("behavior/doubleclick") == "edit":
+			self.entry_edit(self.tree.get_active())
+
+		else:
+			self.entry_goto(self.tree.get_selected())
 
 
 	def __cb_tree_drag_received(self, tree, context, x, y, seldata, info, time):