示例#1
0
 def set_builder_names(self):
     """Set widgets ID from their GtkBuilder ID."""
     for w in self.builder.get_objects():
         if 'GtkBuildable' in map(gobject.type_name, gobject.type_interfaces(w)):
             if hasattr(w, 'set_data'):
                 w.set_data('id', gtk.Buildable.get_name(w))
     return
    def fill_interfaces(self, full_class_name, class_name, class_type):

        self.app.areaInterfaces.foreach( lambda btn: self.app.areaInterfaces.remove(btn) )

        try:
            interfaces = gobject.type_interfaces( class_type )
        except:
            interfaces = []

        for interface in interfaces:
            iname = interface.name

            if iname[:3] == "Gtk":
                iname = "gtk." + iname[3:]
            elif iname[:3] == "Atk":
                iname = "atk." + iname[3:]

                if iname == 'atk.ImplementorIface':
                    iname = 'atk.Implementor'
            else:
                continue

            hb = gtk.HBox()
            hb.add( gtk.image_new_from_pixbuf( self.get_object_image( iname ) ) )
            hb.add( gtk.Label(iname) )
            hb.set_spacing( 2 )
            hb.show_all()

            b = gtk.Button()
            b.connect( "clicked", self.ancestry_button_event_on_click, iname )
            b.add( hb )
            b.show()

            self.app.areaInterfaces.add( b )
    def read_signals(self, obj):
        self.ide.storeSignals.clear()
        sobj = get_object_name( obj )

        try:
            sigs = gobject.signal_list_names( type(obj) )

            # gets signals from all implemented interfaces too.
            # for example, gtk.Entry implements gtk.Editable, which has
            # the "changed" signal, but that is not listed on
            # gtk.Entry's signals.
            # 
            interfaces = gobject.type_interfaces( type(obj) )
            for interface in interfaces:
                sigs += gobject.signal_list_names( interface )

        except:
            sigs = []


        parents = self.get_parent_list( obj )
        for parent in parents:
            try:
                sigs += gobject.signal_list_names( parent )
            except:
                pass


        for sig in sigs:
            details = gobject.signal_query( sig, type(obj) )

            if details[4].name == 'void':
                sig_ret = "return"
            else:
                sig_ret = "return " + details[4].name

            sig_params = details[5]
            if len(sig_params) > 0:

                sparams = ["self", "widget"]
                for sig_param in sig_params:
                    sp = sig_param.name

                    if sp[:3] == 'Gtk' or sp[:3] == 'Gdk':
                        sp = sp[3:]

                    sp = sp[0].lower() + sp[1:]
                    sparams.append( sp )

                s_sig_params = ", ".join( sparams )
            else:
                s_sig_params = "self, widget"

            s_sig_params = "(" + s_sig_params + ")"

            img = get_image_by_name( 'signal_default' )

            if details[2].pytype != type(obj):
                img = get_image_by_name( 'signal_parent' )

            if "-event" in sig:
                img = get_image_by_name( 'signal_event' )


            sig_implemented, sig_line = self.ide.analyser.check_obj_signal( \
                sobj, sig )

            sig_markup = sig

            if sig_implemented:
                sig_markup = "<b>" + sig + "</b> <span foreground='gray'><i>" + \
                    "(source line %d)</i></span>" % sig_line

            self.ide.storeSignals.append( [img, sig, s_sig_params, sig_ret, \
                sig_line, sig_markup] )