コード例 #1
0
    def record(self, obj, signal, *args):
        # Don't log "destroy" signals, because they're sent for every
        # object that's destroyed, not just the one that initiated the
        # action.
        if signal == 'destroy':
            return self.ignore
        if signal == 'delete-event':

            # Simply re-emitting the delete event doesn't actually
            # destroy a window, so we have to explicitly destroy it.
            # This may be the wrong thing to do if a window intercepts
            # delete-event and doesn't propagate the signal.

            ##            return ["%s.destroy()" % self.location(obj, *args)]
            wvar = loggers.localvar('widget')
            hvar = loggers.localvar('handled')
            return [
                "%s=%s" % (wvar, self.location(obj, *args)),
                "%(h)s=%(w)s.event(event(gtk.gdk.DELETE,window=%(w)s.window))"
                % dict(w=wvar, h=hvar),
                "postpone if not %(h)s: %(w)s.destroy()" %
                dict(w=wvar, h=hvar),
            ]
        if signal == 'configure-event':
            event = args[0]
            return [
                "%s.resize(%d, %d)" %
                (self.location(obj, *args), event.width, event.height)
            ]
        return super(WindowLogger, self).record(obj, signal, *args)
コード例 #2
0
ファイル: windowlogger.py プロジェクト: pombredanne/guilogger
    def record(self, obj, signal, *args):
        # Don't log "destroy" signals, because they're sent for every
        # object that's destroyed, not just the one that initiated the
        # action.
        if signal == 'destroy':
            return self.ignore
        if signal == 'delete-event':

            # Simply re-emitting the delete event doesn't actually
            # destroy a window, so we have to explicitly destroy it.
            # This may be the wrong thing to do if a window intercepts
            # delete-event and doesn't propagate the signal.
            
##            return ["%s.destroy()" % self.location(obj, *args)]
            wvar = loggers.localvar('widget')
            hvar = loggers.localvar('handled')
            return [
                "%s=%s" % (wvar, self.location(obj, *args)),
                "%(h)s=%(w)s.event(event(gtk.gdk.DELETE,window=%(w)s.window))"
                % dict(w=wvar, h=hvar),
                "postpone if not %(h)s: %(w)s.destroy()" % dict(w=wvar, h=hvar),
                    ]
        if signal == 'configure-event':
            event = args[0]
            return ["%s.resize(%d, %d)" % (self.location(obj, *args),
                                          event.width, event.height)]
        return super(WindowLogger, self).record(obj, signal, *args)
コード例 #3
0
 def record(self, obj, signal, *args):
     if signal == 'button-release-event':
         event = args[0]
         wvar = loggers.localvar('widget')
         return [
 "%s=%s" % (wvar, self.location(obj, *args)),
 "%(w)s.event(event(gtk.gdk.BUTTON_RELEASE,button=%(b)d,window=%(w)s.window))"
 % dict(w=wvar, b=event.button)
 ]
     if signal == 'row-activated':
         path = args[0]
         col = args[1]               # gtk.TreeViewColumn obj
         cols = obj.get_columns()
         for i in range(len(cols)):
             # TODO is there a better way to find the column number?
             if cols[i] is col:
                 return ["tree=%s" % self.location(obj, *args),
                         "column = tree.get_column(%d)" % i,
                         "tree.row_activated(%s, column)" % `path`]
     if signal == 'row-expanded':
         path = args[1]
         return ["%s.expand_row(%s, open_all=False)"
                 % (self.location(obj, *args), `path`)]
     if signal == 'row-collapsed':
         path = args[1]
         return ["%s.collapse_row(%s)"
                 % (self.location(obj,*args), `path`)]
     return super(TreeViewLogger, self).record(obj, signal, *args)
コード例 #4
0
ファイル: widgetlogger.py プロジェクト: pk-organics/OOF3D
    def record(self, obj, signal, *args):
        if signal in ('button-press-event', 'button-release-event'):
            evnt = args[0]
            if signal == 'button-press-event':
                eventname = "BUTTON_PRESS"
            else:
                eventname = "BUTTON_RELEASE"
            wvar = loggers.localvar('widget')
            return [
                "%s = %s" % (wvar, self.location(obj, *args)),
                "%s.event(event(gtk.gdk.%s,x=%20.13e,y=%20.13e,button=%d,state=%d,window=%s.window))"
                % (wvar, eventname, evnt.x, evnt.y, evnt.button, evnt.state,
                   wvar)
            ]
        if signal == 'motion-notify-event':
            evnt = args[0]
            if logutils.suppress_motion_events(obj):
                return self.ignore
            wvar = loggers.localvar('widget')
            return [
                "%s = %s" % (wvar, self.location(obj, *args)),
                "%s.event(event(gtk.gdk.MOTION_NOTIFY,x=%20.13e,y=%20.13e,state=%d,window=%s.window))"
                % (wvar, evnt.x, evnt.y, evnt.state, wvar)
            ]
        if signal == 'focus-in-event':
            wvar = loggers.localvar('widget')
            return [
                "%s=%s" % (wvar, self.location(obj, *args)),
                "%(widget)s.event(event(gtk.gdk.FOCUS_CHANGE, in_=1, window=%(widget)s.window))"
                % dict(widget=wvar)
            ]
        if signal == 'focus-out-event':
            wvar = loggers.localvar('widget')
            return [
                "%s=%s" % (wvar, self.location(obj, *args)),
                "%(widget)s.event(event(gtk.gdk.FOCUS_CHANGE, in_=0, window=%(widget)s.window))"
                % dict(widget=wvar)
            ]

        if signal == 'size-allocate':
            alloc = obj.get_allocation()
            parent = obj.get_parent()
            return ["%s.size_allocate(gtk.gdk.Rectangle(%d, %d, %d, %d))" \
                   % (self.location(obj, *args),
                      alloc.x, alloc.y, alloc.width, alloc.height)]
        return super(WidgetLogger, self).record(obj, signal, *args)
コード例 #5
0
ファイル: widgetlogger.py プロジェクト: pombredanne/guilogger
 def record(self, obj, signal, *args):
     if signal in ('button-press-event', 'button-release-event'):
         evnt = args[0]
         if signal == 'button-press-event':
             eventname = "BUTTON_PRESS"
         else:
             eventname = "BUTTON_RELEASE"
         wvar = loggers.localvar('widget')
         return [
             "%s = %s" % (wvar, self.location(obj, *args)),
             "%s.event(event(gtk.gdk.%s,x=%20.13e,y=%20.13e,button=%d,state=%d,window=%s.window))"
             % (wvar, eventname,
                evnt.x, evnt.y, evnt.button, evnt.state, wvar)
             ]
     if signal == 'motion-notify-event':
         evnt = args[0]
         if logutils.suppress_motion_events(obj):
             return self.ignore
         wvar = loggers.localvar('widget')
         return [
             "%s = %s" % (wvar, self.location(obj, *args)),
             "%s.event(event(gtk.gdk.MOTION_NOTIFY,x=%20.13e,y=%20.13e,state=%d,window=%s.window))"
             % (wvar, evnt.x, evnt.y, evnt.state, wvar)
             ]
     if signal == 'focus-in-event':
         wvar = loggers.localvar('widget')
         return [
    "%s=%s" % (wvar, self.location(obj, *args)),
    "%(widget)s.event(event(gtk.gdk.FOCUS_CHANGE, in_=1, window=%(widget)s.window))" % dict(widget=wvar)
             ]
     if signal == 'focus-out-event':
         wvar = loggers.localvar('widget')
         return [
    "%s=%s" % (wvar,self.location(obj, *args)),
    "%(widget)s.event(event(gtk.gdk.FOCUS_CHANGE, in_=0, window=%(widget)s.window))" % dict(widget=wvar)
             ]
         
     if signal == 'size-allocate':
         alloc = obj.get_allocation()
         parent = obj.get_parent()
         return ["%s.size_allocate(gtk.gdk.Rectangle(%d, %d, %d, %d))" \
                % (self.location(obj, *args),
                   alloc.x, alloc.y, alloc.width, alloc.height)]
     return super(WidgetLogger, self).record(obj, signal, *args)
コード例 #6
0
ファイル: treeviewlogger.py プロジェクト: creuzige/OOF2
    def record(self, obj, signal, *args):
        # Drag-and-drop of a line within a ListStore creates a pair of
        # row-inserted and row-deleted signals, with row-inserted
        # coming first.  The two must be logged together, so we don't
        # actually return a non-trivial result until getting the
        # second signal.  If the user has two mice and drags rows of
        # two ListStores simultaneously, this won't work.
        if signal == "row-inserted":
            ListStoreLogger.insertrow = args[0][
                0]  # args[0] is a gtk tree path
            return self.ignore
        if signal == "row-deleted":
            if ListStoreLogger.insertrow is None:
                return self.ignore
            deleterow = args[0][0]  # args[0] is a gtk tree path
            destrow = ListStoreLogger.insertrow  # destination row
            # The row to be deleted contains the data that has to be
            # inserted in the new row. "deleterow" was set after the
            # new row was inserted (because 'row-deleted' was sent
            # after 'row-inserted'), so if the new row comes before
            # the deleted row in the list, then on replay, where
            # nothing has happened yet, the row to be deleted has a
            # different index than the source row.
            if ListStoreLogger.insertrow < deleterow:
                sourcerow = deleterow - 1
            else:
                sourcerow = deleterow
            ListStoreLogger.insertrow = None
            lvar = loggers.localvar('ls')
            dvar = loggers.localvar('data')
            return [
                "%s = %s" % (lvar, self.location(obj, *args)),
                "%(data)s = [%(ls)s.get_value(%(ls)s.get_iter((%(r)d,)),i) for i in range(%(ls)s.get_n_columns())]"
                % dict(r=sourcerow, data=dvar, ls=lvar),
                "%s.insert(%d, %s)" % (lvar, destrow, dvar),
                "%(ls)s.remove(%(ls)s.get_iter((%(r)d,)))" %
                dict(r=deleterow, ls=lvar)
            ]

        return super(ListStoreLogger, self).record(obj, signal, *args)
コード例 #7
0
ファイル: treeviewlogger.py プロジェクト: anilkunwar/OOF2
    def record(self, obj, signal, *args):
        # Drag-and-drop of a line within a ListStore creates a pair of
        # row-inserted and row-deleted signals, with row-inserted
        # coming first.  The two must be logged together, so we don't
        # actually return a non-trivial result until getting the
        # second signal.  If the user has two mice and drags rows of
        # two ListStores simultaneously, this won't work.
        if signal == "row-inserted":
            ListStoreLogger.insertrow = args[0][0] # args[0] is a gtk tree path
            return self.ignore
        if signal == "row-deleted":
            if ListStoreLogger.insertrow is None:
                return self.ignore
            deleterow = args[0][0]      # args[0] is a gtk tree path
            destrow = ListStoreLogger.insertrow # destination row
            # The row to be deleted contains the data that has to be
            # inserted in the new row. "deleterow" was set after the
            # new row was inserted (because 'row-deleted' was sent
            # after 'row-inserted'), so if the new row comes before
            # the deleted row in the list, then on replay, where
            # nothing has happened yet, the row to be deleted has a
            # different index than the source row.
            if ListStoreLogger.insertrow < deleterow:
                sourcerow = deleterow - 1
            else:
                sourcerow = deleterow
            ListStoreLogger.insertrow = None
            lvar = loggers.localvar('ls')
            dvar = loggers.localvar('data')
            return [
"%s = %s" % (lvar, self.location(obj, *args)),
"%(data)s = [%(ls)s.get_value(%(ls)s.get_iter((%(r)d,)),i) for i in range(%(ls)s.get_n_columns())]" % dict(r=sourcerow, data=dvar, ls=lvar),
"%s.insert(%d, %s)" % (lvar, destrow, dvar),
"%(ls)s.remove(%(ls)s.get_iter((%(r)d,)))" % dict(r=deleterow, ls=lvar)
                ]

        return super(ListStoreLogger, self).record(obj, signal, *args)