[gnoduino/gnoduino-0-4-0] add shift key to force upload with selected programer



commit c8ea23e4dac29c90407f4912228594c153f2aa6e
Author: Lucian Langa <lucilanga gnome org>
Date:   Sun May 6 11:06:11 2012 +0200

    add shift key to force upload with selected programer

 src/config.py     |    1 +
 src/programmer.py |    2 +-
 src/ui.py         |   13 +++++++++++++
 src/uploader.py   |    2 +-
 4 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/config.py b/src/config.py
index 959d22e..ac607df 100644
--- a/src/config.py
+++ b/src/config.py
@@ -12,3 +12,4 @@ user_library = -1
 serial_baud_rate = -1
 show_numbers = -1
 sketchdir = -1
+force_protocol = False
diff --git a/src/programmer.py b/src/programmer.py
index 259be09..5eda346 100644
--- a/src/programmer.py
+++ b/src/programmer.py
@@ -1,5 +1,5 @@
 # Arduino python implementation
-# Copyright (C) 2010  Lucian Langa <cooly gnome eu org>
+# Copyright (C) 2010,2012  Lucian Langa <cooly gnome eu org>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
diff --git a/src/ui.py b/src/ui.py
index 27a5234..c46216c 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -718,6 +718,17 @@ def populateExamples():
 	ex.set_submenu(submenu)
 	gui.get_object("filemenu").insert(ex, 2)
 
+def getKeyREvent(widget, event, data=None):
+	config.force_protocol = False
+	gui.get_object("upload").set_tooltip_text(_("Upload"))
+
+def getKeyPEvent(widget, event, data=None):
+	if event == -1 or (event.type == gtk.gdk.KEY_PRESS) and \
+		(gtk.gdk.keyval_name(event.keyval) == 'Shift_R' or \
+			gtk.gdk.keyval_name(event.keyval) == 'Shift_L'):
+				config.force_protocol = True
+				gui.get_object("upload").set_tooltip_text(_("Upload using programmer"))
+
 def run():
 	try:
 		global gui
@@ -778,6 +789,8 @@ def run():
 		if (mw and mh):
 			mainwin.set_default_size(mw, mh)
 		mainwin.connect("configure-event", cb_configure_event)
+		mainwin.connect("key-press-event", getKeyPEvent)
+		mainwin.connect("key-release-event", getKeyREvent)
 		vbox = gui.get_object("vpan")
 		sb = gui.get_object("statusbar1")
 		sb.set_has_resize_grip(False)
diff --git a/src/uploader.py b/src/uploader.py
index c2fac87..7bb2057 100644
--- a/src/uploader.py
+++ b/src/uploader.py
@@ -138,7 +138,7 @@ def upload(obj, serial, output, notify):
 	protocol = b.getPGM(b.getBoard())
 	# avrdude wants "stk500v1" to distinguish it from stk500v2
 	if protocol == "stk500": protocol = "stk500v1"
-	if protocol == "":
+	if protocol == "" or config.force_protocol is True:
 		protocol =  pgm.getProtocol(pgm.getProgrammer())
 		try:
 			comm = pgm.getCommunication(pgm.getProgrammer())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]