#!/usr/bin/env python
# Testing if python have the same problem with overlapped
# ->get_name methods (AtkObject and AtkAction)
# More info here:
# http://mail.gnome.org/archives/gnome-shell-list/2010-August/msg00017.html
#
# How to use pygi from:
# http://live.gnome.org/PyGObject
#
# Author: Alejandro Pinheiro <apinheiro@igalia.com>

#import pyatspi don't import this!! or you would load manual python bindings, and the example will not work
import pygtk
pygtk.require ('2.0') # adds gi to the pythonpath

from gi.repository import Clutter
from gi.repository import Atk

def key_press_cb (self, event, label):
    atk_label = label.get_accessible ()

    name = atk_label.get_name ()
    name_using_class = Atk.Object.get_name (atk_label)
    action_name = Atk.Action.get_name (atk_label, 0)

    print "label name: " + name
    print "label name using class: " + name_using_class
    print "label action 0 name: " + action_name


if __name__ == "__main__":
    Clutter.init (None)

    color = Clutter.Color ()
    color.red = 0xff
    color.green = 0x00
    color.blue = 0x00
    color.alpha = 0xff

    label = Clutter.Text ()
    label.set_text ("Some text")
    label.set_font_name ("Sans Bold 32px")
    label.set_color (color)

    s = Clutter.Stage ()
    s.title = 'Overlapping methods'

    s.set_size (600, 200)
    s.connect ('destroy', lambda x: Clutter.main_quit())
    s.connect ('button-press-event', key_press_cb, label);

    s.add_actor (label)

    s.show_all ()
    Clutter.main ()
