Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/infoslicer/widgets/Readonly_Textbox.py
diff options
context:
space:
mode:
Diffstat (limited to 'infoslicer/widgets/Readonly_Textbox.py')
-rw-r--r--infoslicer/widgets/Readonly_Textbox.py39
1 files changed, 14 insertions, 25 deletions
diff --git a/infoslicer/widgets/Readonly_Textbox.py b/infoslicer/widgets/Readonly_Textbox.py
index 3d8e40f..958cfcd 100644
--- a/infoslicer/widgets/Readonly_Textbox.py
+++ b/infoslicer/widgets/Readonly_Textbox.py
@@ -1,9 +1,9 @@
# Copyright (C) IBM Corporation 2008
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import Pango
+import pygtk
+pygtk.require('2.0')
+import gtk
+import pango
import cPickle
-import logging
from Textbox import Textbox
SELECT_SENTENCE, SELECT_PARAGRAPH, SELECT_SECTION, FULL_EDIT = range(4)
@@ -24,8 +24,7 @@ class Readonly_Textbox( Textbox ):
self.use_as_drag_source = use_as_drag_source
self.set_mode(SELECT_SENTENCE)
self.block = True
- self.modify_font(Pango.FontDescription('arial 9'))
- self.MANUEL = 0
+ self.modify_font(pango.FontDescription('arial 9'))
def set_mode(self, mode):
@@ -42,17 +41,15 @@ class Readonly_Textbox( Textbox ):
self.event_handlers.append(self.connect("motion-notify-event", self.motion_notify, None))
self.event_handlers.append(self.connect("move-cursor", self.move_cursor, None))
self.event_handlers.append(self.connect("button-release-event", self.unclicked_event, None))
- self.event_handlers.append(self.connect("drag-data-get", self.drag_data_get_event, None))
- logging.debug('------------------------ SIGNALS ; %s', id(self))
+ self.event_handlers.append(self.connect("drag_data_get", self.drag_data_get_event, None))
self.event_handlers.append(self.connect("drag-motion", self.drag_motion, None))
def drag_motion(self, widget, context, x, y, timestamp, data):
- logging.debug('############ Readonly_Textbox.drag_motion')
- Gdk.drag_status(context, Gdk.DragAction.COPY, timestamp)
+ context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
return True
def clicked_event(self, widget, event, data):
- if event.type == Gdk.EventType._2BUTTON_PRESS or event.type == Gdk.EventType._3BUTTON_PRESS:
+ if event.type == gtk.gdk._2BUTTON_PRESS or event.type == gtk.gdk._3BUTTON_PRESS:
self.stop_emission("button_press_event")
return
if event.button == 3:
@@ -117,13 +114,7 @@ class Readonly_Textbox( Textbox ):
if self.block == True:
self.stop_emission("motion-notify-event")
self.block = False
- logging.debug('FIXME: this is a workaround due '
- 'https://bugzilla.gnome.org/show_bug.cgi?id=679795')
- # I was getting this error:
- # TypeError: could not convert type EventMotion
- # to GdkEvent required for parameter 0
- # self.emit("motion-notify-event", event)
- self.emit("motion-notify-event", Gdk.Event())
+ self.emit("motion-notify-event", event)
buf = self.get_buffer()
mouseiter = self.get_mouse_iter(int(event.x), int(event.y))
@@ -148,7 +139,7 @@ class Readonly_Textbox( Textbox ):
if self.selectionmode == SELECT_SECTION:
selectionstart = article.getSection(mouseiter).getStart()
selectionend = article.getSection(self.selectionstart).getEnd()
- self.scroll_to_iter(mouseiter, 0, False, 0.5, 0.5)
+ self.scroll_to_iter(mouseiter, 0)
article.highlight(selectionstart, selectionend)
else:
@@ -161,20 +152,18 @@ class Readonly_Textbox( Textbox ):
self.stop_emission("button-release-event")
def drag_data_get_event(self, widget, context, selection_data, info, time, data):
- logging.debug('######## Readonly_Textbox.drag_data_get_event')
- logging.debug('############################## %s', self.MANUEL)
+
a = self.article
if self.selectionmode == SELECT_SENTENCE:
- atom = Gdk.atom_intern("sentence", only_if_exists=False)
+ atom = gtk.gdk.atom_intern("sentence")
if self.selectionmode == SELECT_PARAGRAPH:
- atom = Gdk.atom_intern("paragraph", only_if_exists=False)
+ atom = gtk.gdk.atom_intern("paragraph")
if self.selectionmode == SELECT_SECTION:
- atom = Gdk.atom_intern("section", only_if_exists=False)
+ atom = gtk.gdk.atom_intern("section")
string = cPickle.dumps(a.getSelection())
selection_data.set(atom, 8, string)
self.stop_emission("drag-data-get")
self.set_editable(False)
- self.MANUEL += 1