[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6045 - in trunk/gnue-forms/src: . uidrivers/gtk2 uidrivers/gtk2/widgets
From: |
johannes |
Subject: |
r6045 - in trunk/gnue-forms/src: . uidrivers/gtk2 uidrivers/gtk2/widgets |
Date: |
Fri, 23 Jul 2004 04:04:28 -0500 (CDT) |
Author: johannes
Date: 2004-07-23 04:04:27 -0500 (Fri, 23 Jul 2004)
New Revision: 6045
Modified:
trunk/gnue-forms/src/GFDisplayHandler.py
trunk/gnue-forms/src/GFKeyMapper.py
trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
trunk/gnue-forms/src/uidrivers/gtk2/common.py
trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
Log:
Copy & Pase for Entry- and TextView-widgets
Modified: trunk/gnue-forms/src/GFDisplayHandler.py
===================================================================
--- trunk/gnue-forms/src/GFDisplayHandler.py 2004-07-23 08:38:27 UTC (rev
6044)
+++ trunk/gnue-forms/src/GFDisplayHandler.py 2004-07-23 09:04:27 UTC (rev
6045)
@@ -382,10 +382,10 @@
# Select the entire text of the entry and move
# the cursor to the end
- def selectAll(self, event):
+ def selectAll (self, event):
self.selection1 = 0
- self.moveCursorToEnd(event, True)
+ self.moveCursorToEnd (event, True)
self.selection2 = self.cursor
@@ -431,10 +431,11 @@
# Copy to the clipboard
def clipboardCopy(self, event):
+
if self.selection1 != None:
- sel1, sel2 = self.getSelectionArea()
- self.dispatchEvent(events.Event('setCLIPBOARD',
- text=self.display[sel1:sel2]))
+ sel1, sel2 = self.getSelectionArea ()
+ self.dispatchEvent (events.Event ('setCLIPBOARD',
+ text = self.display [sel1:sel2]))
event.refreshDisplay = False
Modified: trunk/gnue-forms/src/GFKeyMapper.py
===================================================================
--- trunk/gnue-forms/src/GFKeyMapper.py 2004-07-23 08:38:27 UTC (rev 6044)
+++ trunk/gnue-forms/src/GFKeyMapper.py 2004-07-23 09:04:27 UTC (rev 6045)
@@ -72,7 +72,7 @@
# calls this.
#
def setUserKeyMap(self, keymap):
- self.__functionMap = keymap
+ self.__functionMap.update (keymap)
self._translateUserKeyMap()
Modified: trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2004-07-23 08:38:27 UTC
(rev 6044)
+++ trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2004-07-23 09:04:27 UTC
(rev 6045)
@@ -88,7 +88,23 @@
gtk.RESPONSE_NO : False,
gtk.RESPONSE_CANCEL: None }
+
# ---------------------------------------------------------------------------
+ #
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, *args, **params):
+ commonToolkit.GFUserInterface.__init__ (self, *args, **params)
+
+ gDebug (1, "Creating clipboard instance")
+ self._display = gtk.gdk.display_manager_get ().get_default_display ()
+ gDebug (2, "Display is %s" % self._display)
+ self._clipboard = gtk.Clipboard(self._display, "CLIPBOARD")
+ gDebug (2, "Clipboard is %s" % self._clipboard)
+
+
+
+ # ---------------------------------------------------------------------------
# Initialize user interface
# ---------------------------------------------------------------------------
@@ -219,40 +235,44 @@
# Get some text from the clipboard
# ---------------------------------------------------------------------------
- def getClipboardContents(self, event):
- print "retrieving from clip"
- try:
- ui = self._gfObjToUIWidget [event._form]
- disp = ui.mainWindow.get_screen ().get_display ()
- clip = gtk.Clipboard (disp, 'CLIPBOARD')
+ def getClipboardContents (self, event):
+ gDebug (1, "Retrieving clipboard contents")
- data = clip.wait_for_text ()
- print "data:", data
+ widget = self._UIform.mainWindow.get_focus ()
+ if isinstance (widget, gtk.TextView):
+ gDebug (1, "Clipboard is %s" % self._clipboard)
- except:
- print "sorry ..."
- data = None
+ tBuffer = widget.get_buffer ()
+ pos = tBuffer.get_iter_at_mark (tBuffer.get_insert ())
+ tBuffer.paste_clipboard (self._clipboard, pos, widget.get_editable())
- event.__result__ = data
+ elif hasattr (widget, 'paste_clipboard'):
+ gDebug (3, "calling %s.paste_clipboard" % widget)
+ widget.paste_clipboard ()
+ event.__result__ = None
+
+
# ---------------------------------------------------------------------------
# Set some text into the clipboard
# ---------------------------------------------------------------------------
- def setClipboardContents(self, event):
- ui = self._gfObjToUIWidget [event._form]
- if ui.mainWindow.get_screen () is not None:
- text = "%s" % event.text
- if isinstance (text, types.StringType):
- text = unicode (text, i18n.encoding)
- disp = ui.mainWindow.get_screen ().get_display ()
- clip = gtk.Clipboard (disp, 'CLIPBOARD')
- clip.set_text (text.encode ('utf-8'), -1)
- print "... text sent"
+ def setClipboardContents (self, event):
+ gDebug (1, "Setting clipboard contents")
+ widget = self._UIform.mainWindow.get_focus ()
+ if isinstance (widget, gtk.TextView):
+ tBuffer = widget.get_buffer ()
+ tBuffer.copy_clipboard (self._clipboard)
+ if hasattr (widget, 'copy_clipboard'):
+ gDebug (3, "calling %s.copy_clipboard ()" % widget)
+ widget.copy_clipboard ()
+
+
+
# ---------------------------------------------------------------------------
# Set the forms title
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/gtk2/common.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/common.py 2004-07-23 08:38:27 UTC
(rev 6044)
+++ trunk/gnue-forms/src/uidrivers/gtk2/common.py 2004-07-23 09:04:27 UTC
(rev 6045)
@@ -24,7 +24,6 @@
import gtk
from gnue.common import events
-from gnue.common.apps import GDebug
# -----------------------------------------------------------------------------
@@ -38,7 +37,7 @@
newWidget.connect ("key-press-event", _keyPressHandler, uiDriver,
eventHandler, lookup)
- GDebug.printMesg (1, "Added key-press-event to %s" % newWidget)
+ gDebug (1, "Added key-press-event to %s" % newWidget)
# -----------------------------------------------------------------------------
@@ -46,7 +45,7 @@
# -----------------------------------------------------------------------------
def _keyPressHandler (widget, event, uiDriver, eventHandler, lookup):
- GDebug.printMesg (2, "Common-keypress: %s %s" % (event.type, event.keyval))
+ gDebug (2, "Common-keypress: %s %s" % (event.type, event.keyval))
if event.type != gtk.gdk.KEY_PRESS:
return False
@@ -60,11 +59,11 @@
isMod1 = event.state & gtk.gdk.MOD1_MASK > 0
if keycode == gtk.keysyms.ISO_Left_Tab:
- GDebug.printMesg (3, "Mapping Shit-Tab to Tab")
+ gDebug (3, "Mapping Shit-Tab to Tab")
keycode = gtk.keysyms.Tab
if not uiDriver._WidgetToGFObj.has_key (lookup):
- GDebug.printMesg (2, "can't find widget %s" % lookup)
+ gDebug (2, "can't find widget %s" % lookup)
return False
gfObject = uiDriver._WidgetToGFObj [lookup]
@@ -96,7 +95,6 @@
action = events.Event ('request%s' % command)
elif gfObject._type == 'GFButton':
- GDebug.printMesg (1, "Foo pressed button")
action = events.Event ('buttonActivated', gfObject)
elif gfObject.style == 'checkbox' and gfObject._type == 'GFEntry':
@@ -106,17 +104,15 @@
else:
pass
- GDebug.printMesg (1, "Action= %s " % action)
-
if action is not None:
# Add the gfObject's _form to the outgoing event
# rather than every event in the function
- GDebug.printMesg (3, "Calling %s" % action.__event__)
+ gDebug (3, "Calling %s" % action.__event__)
action.__dict__.update ({'_form': gfObject._form})
eventHandler (action)
return True
else:
- GDebug.printMesg (3, "Key dropped!")
+ gDebug (3, "Key dropped!")
Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py 2004-07-23
08:38:27 UTC (rev 6044)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py 2004-07-23
09:04:27 UTC (rev 6045)
@@ -204,11 +204,15 @@
def loseFocus (self):
for widget in self.widgets:
+ gDebug (3, "Lose focus: %s" % widget)
+
if isinstance (widget, gtk.Combo):
- GDebug.printMesg (3, "Lose focus: %s" % widget)
widget.entry.select_region (0, 0)
+ elif isinstance (widget, gtk.Entry):
+ widget.select_region (0, 0)
+
# ---------------------------------------------------------------------------
# Set the value of a widget
# ---------------------------------------------------------------------------
@@ -280,11 +284,12 @@
- def setSelectedArea(self, selection1, selection2, index=0):
+ def setSelectedArea (self, selection1, selection2, index=0):
try:
- self.widgets[index].select_region(selection1, selection2)
+ self.widgets [index].select_region (selection1, selection2)
+
except (AttributeError, TypeError):
- pass # For label-style & dropdown entries
+ pass
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6045 - in trunk/gnue-forms/src: . uidrivers/gtk2 uidrivers/gtk2/widgets,
johannes <=