Beispiel #1
0
    def test_custom_getset(self):
        class C(APTestClass):
            def __init__(self):
                APTestClass.__init__(self)
                self.custom = 10

            def do_set_property_readwrite(self, name, value):
                assert name == "readwrite"
                self.custom = value

            def do_get_property_readwrite(self, name):
                assert name == "readwrite"
                return self.custom

        gobject.type_register(C)

        c = C()
        assert c.get_property("readwrite") == 10
        c.set_property("readwrite", 3)
        assert c.custom == 3
        assert c.get_property("readwrite") == 3

        def setit(obj):
            obj._internal_set_property("readwrite", 12)

        assert_emits(setit, c, "notify::readwrite")
        assert c.get_property("readwrite") == 12
        c.custom = 15
        assert c.get_property("readwrite") == 15
Beispiel #2
0
    def __init__(self, window):
        """Class initialiser"""
        if isinstance(window.get_child(), gtk.Notebook):
            err('There is already a Notebook at the top of this window')
            raise(ValueError)

        Container.__init__(self)
        gtk.Notebook.__init__(self)
        self.terminator = Terminator()
        self.window = window
        gobject.type_register(Notebook)
        self.register_signals(Notebook)
        self.connect('switch-page', self.deferred_on_tab_switch)
        self.configure()

        child = window.get_child()
        window.remove(child)
        window.add(self)
        window_last_active_term = window.last_active_term
        self.newtab(widget=child)
        if window_last_active_term:
            self.set_last_active_term(window_last_active_term)
            window.last_active_term = None

        self.show_all()
Beispiel #3
0
def register():
    gobject.type_register(ResizeSink)
    gst.element_register (ResizeSink, 'myresize', gst.RANK_MARGINAL)
        
    gobject.type_register(CaptureSink)
    # Register the element into this process' registry.
    gst.element_register (CaptureSink, 'capturesink', gst.RANK_MARGINAL)
Beispiel #4
0
    def __init__(self):
        """Class initialiser"""
        self.terminator = Terminator()
        self.terminator.register_window(self)

        Container.__init__(self)
        gtk.Window.__init__(self)
        gobject.type_register(Window)
        self.register_signals(Window)

        self.set_property("allow-shrink", True)
        self.apply_icon()

        self.register_callbacks()
        self.apply_config()

        self.title = WindowTitle(self)
        self.title.update()

        options = self.config.options_get()
        if options:
            if options.forcedtitle is not None:
                self.title.force_title(options.forcedtitle)

            if options.role is not None:
                self.set_role(options.role)

            if options.geometry is not None:
                if not self.parse_geometry(options.geometry):
                    err("Window::__init__: Unable to parse geometry: %s" % options.geometry)

        self.pending_set_rough_geometry_hint = False
Beispiel #5
0
 def _add_source_bin(self, pipeline):
     if gstreamer.element_factory_exists("appsrc") and \
         gstreamer.get_plugin_version("app") >= (0, 10, 22, 0):
         self.source = gst.element_factory_make('appsrc', 'source')
         self.source.set_property('do-timestamp', True)
         self.source.connect('need-data', self.push_buffer)
     else:
         #FIXME: fluoverlaysrc only needed on gst-plugins-base < 0.10.22
         gobject.type_register(OverlayImageSource)
         gst.element_register(OverlayImageSource, "fluoverlaysrc",
             gst.RANK_MARGINAL)
         self.source = gst.element_factory_make('fluoverlaysrc', 'source')
     # create the source bin
     self.sourceBin = gst.Bin()
     # create the alphacolor element
     alphacolor = gst.element_factory_make('alphacolor')
     # add the elements to the source bin and link them
     self.sourceBin.add_many(self.source, alphacolor)
     self.source.link(alphacolor)
     pipeline.add(self.sourceBin)
     # create the source ghost pad
     self.sourceBin.add_pad(gst.GhostPad('src', alphacolor.get_pad('src')))
     # set the locked state and wait until we get the first caps change
     # and we know the widht and height of the input stream
     self.sourceBin.set_locked_state(True)
    def __init__(self, *args):

        dbus.service.Object.__init__(self, *args)
        # State Variables
        self.playing = False
        self.audioChan = 0x20;
        self.selectedAudioChan = self.audioChan
        self.subChan = 0;  #most likely will refere to a tetrode sub-channel
        self.selectedSubChan = self.subChan    

        self.eio = NetEventIO("10.0.0.2")
        
        # AudioControl Event Constants setup on 10/13/08
        self.AUDIO_EVENT_CMD = 0x12
        self.ENABLE_AUDIO_EVENTS = 1
        self.DISABLE_AUDIO_EVENTS = 0
        self.AUDIO_REQUEST = 0
        self.AUDIO_UPDATE = 1

        #Create GST elements - pipeline will not be created
        gobject.type_register(SomaAudioEventFilter)
        self.eventSource = gst.element_factory_make('somaeventsource', "SomaEventSource")
        self.audioEventFilter = SomaAudioEventFilter()
        self.AUDIO_SINK = "pulsesink"
        self.audioSink = gst.element_factory_make(self.AUDIO_SINK)
        self.audioConverter = gst.element_factory_make("audioconvert")
        self.audioResampler= gst.element_factory_make("audioresample")
        self.queue = gst.element_factory_make("queue")
        self.pipeline = None
Beispiel #7
0
    def __init__(self):
        gtk.VBox.__init__(self)
        
        #register pcalender as widget
        try:
            gobject.signal_new("month-changed",pcalendar, gobject.SIGNAL_RUN_LAST ,
                       gobject.TYPE_NONE, [gobject.TYPE_INT,gobject.TYPE_INT,gobject.TYPE_INT])
            gobject.signal_new("day_selected",pcalendar, gobject.SIGNAL_RUN_LAST ,
                       gobject.TYPE_NONE, [gobject.TYPE_INT,gobject.TYPE_INT,gobject.TYPE_INT])
            gobject.signal_new("day-selected-double-click",pcalendar, gobject.SIGNAL_RUN_LAST ,
                       gobject.TYPE_NONE, [gobject.TYPE_INT,gobject.TYPE_INT,gobject.TYPE_INT])
            gobject.type_register(pcalendar) 
        except:
            pass
        
        #get current date
        current_date =datetime.datetime.now()
        jdate_= utility.GregorianToJalali(current_date.year,current_date.month,current_date.day)
        self.year,self.month,self.day = jdate_.jyear,jdate_.jmonth,jdate_.jday

        self.lastday = self.day
        self.lastmin = -1       
        
        self.box2=gtk.Viewport()
        self.vbox2=gtk.VBox()
        self.vbox2.set_spacing(1)
        self.box2.add(self.vbox2)
        
        self.box1=gtk.Viewport()
        self.box1.set_border_width(5)
        self.vbox2.pack_start(self.box1,0,0,0)
        
        self.add(self.box2)
        
        self.connect("destroy",self.quit)
        self.vbox=gtk.VBox()
        self.vbox.set_spacing(3)
        self.box1.add(self.vbox)

        self.header=wmonth()
        self.vbox.pack_start(self.header.hbox,0,0,0)
        self.header.arrow_left2.connect("clicked",self.month_prev)
        self.header.arrow_right2.connect("clicked",self.month_next)
        self.header.arrow_left.connect("clicked",self.year_prev)
        self.header.arrow_right.connect("clicked",self.year_next)
        
        #add calendar widget
        self.cal=pcalendar(self.year,self.month,self.day)
        
        self.cal.connect("month-changed",self.monthchange)
        self.cal.connect("day_selected",self.daychange,'day_selected')
        self.cal.connect("day-selected-double-click",self.daychange,'day-selected-double-click')
        self.vbox.pack_start(self.cal ,1 ,1, 0)
        
        self.header.yearnum.set_label("<b>"+self.convert_to_str(self.year)+"</b>")
        self.header.monthname.set_label(' <b>'+mon_name[self.month-1]+'</b> ')

        self.box2.show_all()
        self.change_lable(self.day)
Beispiel #8
0
    def test_assert_emits(self):
        class C(gobject.GObject):
            __gsignals__ = {
                "foo": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                        (gobject.TYPE_PYOBJECT, )),
            }

        gobject.type_register(C)

        def do_emit(obj):
            obj.emit("foo", "asdf")

        def dont_emit(obj):
            pass

        c = C()
        assert_emits(do_emit, c, "foo")
        assert_raises(AssertionError, assert_emits, dont_emit, c, "foo")

        def slot_wants_asdf(obj, arg):
            assert isinstance(obj, C)
            assert arg == "asdf"

        def slot_wants_hjkl(obj, arg):
            assert isinstance(obj, C)
            assert arg == "hjkl"

        assert_emits(do_emit, c, "foo", slot_wants_asdf)
        assert_raises(AssertionError, assert_emits, do_emit, c, "foo",
                      slot_wants_hjkl)

        # Make sure that assert_emits disconnects after itself.
        self.gotcalled = False

        def f(*args):
            self.gotcalled = True

        assert_emits(do_emit, c, "foo", f)
        assert self.gotcalled
        self.gotcalled = False
        do_emit(c)
        assert not self.gotcalled

        # ...even if there was an error.
        # Errors can come from emission failure...
        assert_raises(AssertionError, assert_emits, dont_emit, c, "foo", f)

        # ..and from slots raising errors.
        def g(*args):
            assert False
            self.gotcalled = True

        assert_raises(AssertionError, assert_emits, do_emit, c, "foo", g)
        # In neither case should a handler be left around:
        self.gotcalled = False
        do_emit(c)
        assert not self.gotcalled
def ConsoleType(t=gtk.TextView):
    class console(t, _Console):
        def __init__(self, *args, **kwargs):
            t.__init__(self)
            _Console.__init__(self, *args, **kwargs)
        def do_key_press_event(self, event):
            return _Console.do_key_press_event(self, event, t)
    gobject.type_register(console)
    return console
Beispiel #10
0
def gobject_register(klass):
    """
    Register a given object by calling gobject.type_register.

    Actually gobject.type_register is only called if the pygtk version in use
    is not 2.8 at least.
    """
    if gtk_version_minor < 8:
        gobject.type_register(klass)
def ReadLineType(t=gtk.TextView):
    class readline(t, _ReadLine):
        def __init__(self, *args, **kwargs):
            t.__init__(self)
            _ReadLine.__init__(self, *args, **kwargs)
        def do_key_press_event(self, event):
            return _ReadLine.do_key_press_event(self, event, t)
    gobject.type_register(readline)
    return readline
Beispiel #12
0
	def __init__(self, device_name = "ZynAddSubFX"):
		self.tempo = 120
		self.channels = []
		self.control_channel = 1
		self.control_channel_cur = 0
		self.device = self.MidiDevice(device_name)
		self.global_pattern = []
		gobject.GObject.__init__(self)
		gobject.type_register(self.Channel)
		print "Starting Sequencer..."
Beispiel #13
0
def test_subclass_menubar():
    '''
    Ensure that subclassing the ``gtk.MenuBar`` class works as
    expected.
    '''
    class MyMenuBar(gtk.MenuBar):
        def __init__(self):
            gtk.MenuBar.__init__(self)
    gobject.type_register(MyMenuBar)
    bar = MyMenuBar()
Beispiel #14
0
def test_scrollbars_in_subclass_init():
    '''
    Ensure that the scrolled windows scrollbars are ``None`` within a
    subclass __init__ method.
    '''
    class Test124(gtk.ScrolledWindow):
        def __init__(self):
            super(Test124, self).__init__()
            assert not self.get_hscrollbar()
            assert not self.get_vscrollbar()
    gobject.type_register(Test124)
    gobject.new(Test124)    
Beispiel #15
0
def type_register(gtype):
    """Register the type, but only if it's not already registered
    :param gtype: the class to register
    """

    # copied from gobjectmodule.c:_wrap_type_register
    if (getattr(gtype, '__gtype__', None) !=
        getattr(gtype.__base__, '__gtype__', None)):
        return False

    gobject.type_register(gtype)

    return True
Beispiel #16
0
def main():
    # Registro la clase como un widget Gtk
    gobject.type_register(Velocimetro)

    win = gtk.Window()
    win.resize(210, 210)
    win.connect('delete-event', gtk.main_quit)

    velocimetro = Velocimetro(0, 100, 50.0)
    win.add(velocimetro)
    win.show()
    win.show_all()
    gtk.main()
Beispiel #17
0
    def overrides(self):
        import gobject
        import gtk

        class NullTextView(gtk.TextView):
            set_tab_width = lambda *args: None
            set_show_line_numbers = lambda *args: None
            set_insert_spaces_instead_of_tabs = lambda *args: None
            set_draw_spaces = lambda *args: None
        gobject.type_register(NullTextView)

        self.GtkTextView = NullTextView
        self.GtkTextBuffer = gtk.TextBuffer
Beispiel #18
0
def test_subclass_init_calls_add():
    '''
    Ensure that adding items to a scrolled window within a subclass
    __init__ method works.

    :bug: #438114
    '''
    class MyScrolledWindow(gtk.ScrolledWindow):
        def __init__(self):
            super(MyScrolledWindow, self).__init__()
            self.add(gtk.TextView())
    gobject.type_register(MyScrolledWindow)
    gobject.new(MyScrolledWindow)
Beispiel #19
0
def main(args):

    dev = int(sys.argv[1])
    gobject.type_register(SomaAudioEventFilter)

    audioSrc = gst.element_factory_make('somaeventsource', 'SomaEventSource')
    #audioSrc = gst.element_factory_make('audiotestsrc', "test src")

    gst.info('About to create SomaAudioFilter')
    #somaAudioEventFilter = PyIdentity()
    somaAudioEventFilter = SomaAudioEventFilter()
    print "Created somaAudioEventFilter"
    somaAudioEventFilter.set_audio_src(dev)
    
    pipeline = gst.Pipeline()
    pipeline.add(audioSrc)
    pipeline.add(somaAudioEventFilter)

    finalSink = gst.element_factory_make("pulsesink")
    
    #finalSink = gst.element_factory_make("filesink")
    #finalSink.set_property("location", '/tmp/somaeventsourcetest.dat')

    pipeline.add(finalSink)
    ac = gst.element_factory_make("audioconvert")
    ars = gst.element_factory_make("audioresample")
    queue = gst.element_factory_make("queue")
    queue.set_property("max-size-buffers", 10000)
    pipeline.add(queue)
    pipeline.add(ac)
    pipeline.add(ars)

##     caps = gst.Caps("audio/x-raw-int,rate=44100")
##     filter = gst.element_factory_make("capsfilter", "filter")
##     filter.set_property("caps", caps)
##     pipeline.add(filter)
    
    gst.element_link_many(audioSrc, somaAudioEventFilter, queue,
                          ac, ars, finalSink)
    #gst.element_link_many(audioSrc,somaAudioEventFilter, ars, filter, finalSink)
    #gst.element_link_many(audioSrc,somaAudioEventFilter, queue, finalSink)
    #gst.element_link_many(audioSrc, finalSink)

    #gst.element_link_many(audioSrc,somaAudioEventFilter, finalSink)
    print "somaAudioFilter linked to finalSink"

    print "Pipeline setup, setting STATE to PLAYING"
    pipeline.set_state(gst.STATE_PLAYING)


    gobject.MainLoop().run()
Beispiel #20
0
def main():
    # Registro la clase como un widget Gtk
    gobject.type_register(StarHScale)

    win = gtk.Window()
    win.resize(200, 50)
    win.connect("delete-event", gtk.main_quit)

    starScale = StarHScale(3, 2)
    # starScale.set_property("sensitive", False)
    win.add(starScale)
    win.show()
    win.show_all()
    gtk.main()
Beispiel #21
0
	def __new__(cls, name, bases, dct):
		ret = type.__new__(cls, name, bases, dct)

		for name in dir(ret.__styles):
			value = getattr(ret.__styles, name)
			value_type = type(value)

			gtk.widget_class_install_style_property(ret, (
				name.replace("_", "-"), value_type, name.replace("_", "-"),
				value.__doc__.strip(),
				gobject.PARAM_READABLE))

		gobject.type_register(ret)
		return ret
    def setup(self, registry):
        # You will typically only implement one of the following things
        # in a single extension.

        # TODO: Edit or remove entirely
        from .frontend import FoobarFrontend
        registry.add('frontend', FoobarFrontend)

        # TODO: Edit or remove entirely
        from .backend import FoobarBackend
        registry.add('backend', FoobarBackend)

        # TODO: Edit or remove entirely
        from .mixer import FoobarMixer
        gobject.type_register(FoobarMixer)
        gst.element_register(FoobarMixer, 'foobarmixer', gst.RANK_MARGINAL)
Beispiel #23
0
    def __init__(self, *args, **kargs):
        gtk.ScrolledWindow.__init__(self, *args, **kargs)

        self.htmlview = HtmlTextView()
        self.htmlview.set_wrap_mode(gtk.WRAP_WORD)
        self.htmlview.show()

        self.set_property("hscrollbar-policy", gtk.POLICY_AUTOMATIC)
        self.set_property("vscrollbar-policy", gtk.POLICY_AUTOMATIC)
        self.set_property("border-width", 0)
        self.add(self.htmlview)
        self.show()

        if gobject.pygtk_version < (2, 8):
            gobject.type_register(HtmlTextView)
            print 'Registered HtmlTextView'
Beispiel #24
0
    def __new__(cls, *args, **kwargs):
        try:
            newcls = SignalManager.registered_classes[cls]
            obj = newcls.__new__(newcls, *args, **kwargs)
            gobject.GObject.__init__(obj)
            newcls.__init__(obj, *args, **kwargs)

            return obj
        except KeyError:
            pass

        def make_signal_prop(signal):
            def inner(self):
                return BoundedSignal(self, signal)

            return property(inner)

        newdict = dict(cls.__dict__)
        signals = {}
        for sname, signal in cls.__dict__.iteritems():
            if isinstance(signal, Signal):
                signal.name = sname.replace('_', '-')
                signals[signal.name] = (signal.signal_type,
                    signal.return_type, signal.arg_types)

                newdict[sname] = make_signal_prop(signal)

        if not signals:
            return super(SignalManager, cls).__new__(cls, *args, **kwargs)

        newdict['__gsignals__'] = signals
        newdict['weak_connect'] = SignalManager.weak_connect
        newdict['connect_signals'] = SignalManager.connect_signals

        for k, v in newdict.iteritems():
            if hasattr(v, 'im_func'):
                newdict[k] = v.im_func

        newcls = type(cls.__name__, (gobject.GObject,), newdict)
        gobject.type_register(newcls)
        SignalManager.registered_classes[cls] = newcls

        obj = newcls.__new__(newcls, *args, **kwargs)
        gobject.GObject.__init__(obj)
        newcls.__init__(obj, *args, **kwargs)

        return obj
Beispiel #25
0
def main(args):

    # Need to register our derived widget types for implicit event
    # handlers to get called.
    gobject.type_register(ScannerUI)
    gobject.type_register(VideoWidget)

    s = Scanner();

    if len(args) == 2:
        if gst.uri_is_valid(args[1]):
            s.set_uri(args[1])
        else:
            sys.stderr.write("Error: Invalid URI: %s\n" % args[1])
            sys.exit(1)

    gtk.main()
Beispiel #26
0
            if len(reg):
                if not first:
                    first = name
                self.__registries[name] = reg
        self.__build_list()
        if first is not None:
            self.__list.set_selected(first)

    def cb_list_clicked(self, listview, item):
        self.__build_page(item.key)

    def cb_undo_clicked(self, button):
        self.__reset()

    def cb_apply_clicked(self, button):
        self.__apply()

    def cb_save_clicked(self, button):
        self.__apply()
        self.__save()
        self.close()

    def cb_cancel_clicked(self, button):
        self.close()

    def show_page(self, pagename):
        self.__list.set_selected(pagename)


gobject.type_register(config_view)
Beispiel #27
0
        lambda self: self.window_widget.masterer.music_list_gateway)

    def write_files(self):
        return Application.write_files(self, self.window_widget)

    # TODO: decouple the window from SerpentineApplication ?
    def show_window(self):
        # Starts the window operation
        self.__window.start()
        self.operations.append(self.__window)

    def close_window(self):
        # Stops the window operation
        if self.__window.running:
            self.__window.stop()

    def stop(self):
        # Clean window object
        Application.stop(self)
        self.__window.destroy()
        del self.__window


gobject.type_register(SerpentineWindow)

if __name__ == '__main__':
    s = Serpentine()
    s.preferences.simulate = len(sys.argv) == 2 and sys.argv[1] == '--simulate'
    s.show()
    gtk.main()
Beispiel #28
0
    def __init__(self):
        gtk.VBox.__init__(self)

        #register pcalender as widget
        try:
            gobject.signal_new(
                "month-changed", pcalendar, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE,
                [gobject.TYPE_INT, gobject.TYPE_INT, gobject.TYPE_INT])
            gobject.signal_new(
                "day_selected", pcalendar, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE,
                [gobject.TYPE_INT, gobject.TYPE_INT, gobject.TYPE_INT])
            gobject.signal_new(
                "day-selected-double-click", pcalendar,
                gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                [gobject.TYPE_INT, gobject.TYPE_INT, gobject.TYPE_INT])
            gobject.type_register(pcalendar)
        except:
            pass

        #get current date
        current_date = datetime.datetime.now()
        jdate_ = utility.GregorianToJalali(current_date.year,
                                           current_date.month,
                                           current_date.day)
        self.year, self.month, self.day = jdate_.jyear, jdate_.jmonth, jdate_.jday

        self.lastday = self.day
        self.lastmin = -1

        self.box2 = gtk.Viewport()
        self.vbox2 = gtk.VBox()
        self.vbox2.set_spacing(1)
        self.box2.add(self.vbox2)

        self.box1 = gtk.Viewport()
        self.box1.set_border_width(5)
        self.vbox2.pack_start(self.box1, 0, 0, 0)

        self.add(self.box2)

        self.connect("destroy", self.quit)
        self.vbox = gtk.VBox()
        self.vbox.set_spacing(3)
        self.box1.add(self.vbox)

        self.header = wmonth()
        self.vbox.pack_start(self.header.hbox, 0, 0, 0)
        self.header.arrow_left2.connect("clicked", self.month_prev)
        self.header.arrow_right2.connect("clicked", self.month_next)
        self.header.arrow_left.connect("clicked", self.year_prev)
        self.header.arrow_right.connect("clicked", self.year_next)

        #add calendar widget
        self.cal = pcalendar(self.year, self.month, self.day)

        self.cal.connect("month-changed", self.monthchange)
        self.cal.connect("day_selected", self.daychange, 'day_selected')
        self.cal.connect("day-selected-double-click", self.daychange,
                         'day-selected-double-click')
        self.vbox.pack_start(self.cal, 1, 1, 0)

        self.header.yearnum.set_label("<b>" + self.convert_to_str(self.year) +
                                      "</b>")
        self.header.monthname.set_label(' <b>' + mon_name[self.month - 1] +
                                        '</b> ')

        self.box2.show_all()
        self.change_lable(self.day)
Beispiel #29
0
            self.mute = False

    def changeValve(self, value):
        valve1 = self.get_by_name('gc-firewire-valve')
        valve1.set_property('drop', value)

    def getVideoSink(self):
        return self.get_by_name("gc-firewire-preview")

    def getSource(self):
        return self.get_by_name("gc-firewire-src")

    def send_event_to_src(self, event):
        src1 = self.get_by_name("gc-firewire-src")
        src1.send_event(event)

    def mute_preview(self, value):
        if not self.mute:
            element = self.get_by_name("gc-firewire-volume")
            element.set_property("mute", value)

    def configure(self):
        ##
        # v4l2-ctl -d self.options["location"] -s self.options["standard"]
        # v4l2-ctl -d self.options["location"] -i self.options["input"]
        pass


gobject.type_register(GCfirewire)
gst.element_register(GCfirewire, "gc-firewire-bin")
Beispiel #30
0
    def cleanup(self):
        #this must be called from the UI thread!
        remove_event_receiver(self._root, self)
        self._root.set_events(self._saved_event_mask)
        if self._own_x11_filter:
            #only remove the x11 filter if we initialized it (ie: when running in client)
            try:
                trap.call_synced(cleanup_x11_filter)
            except Exception, e:
                log.error("failed to remove x11 event filter: %s", e)
            try:
                trap.call_synced(cleanup_all_event_receivers)
            except Exception, e:
                log.error("failed to remove event receivers: %s", e)

    def do_xpra_property_notify_event(self, event):
        log("XRootPropWatcher.do_xpra_property_notify_event(%s)", event)
        if event.atom in self._props:
            self.do_notify(event.atom)

    def do_notify(self, prop):
        log("XRootPropWatcher.do_notify(%s)", prop)
        self.emit("root-prop-changed", prop)

    def notify_all(self):
        for prop in self._props:
            self.do_notify(prop)


gobject.type_register(XRootPropWatcher)
Beispiel #31
0
        # gtk.STATE_ACTIVE
        # gtk.STATE_PRELIGHT
        # gtk.STATE_SELECTED
        # gtk.STATE_INSENSITIVE        
        
    def highlight(self):
        pass
    
    def unhighlight(self):
        pass

    def show(self):
        gtk.EventBox.show_all(self)


gobject.type_register(BaseWidget)
gobject.signal_new("init", BaseWidget, gobject.SIGNAL_RUN_LAST, 
                   gobject.TYPE_NONE, ())


class RichTextSep (BaseWidget):
    """Separator widget for a Horizontal Rule"""

    # TODO: dynamically resize
    
    def __init__(self):
        BaseWidget.__init__(self)
        self._sep = gtk.HSeparator()
        self.add(self._sep)
        self._size = None
        
Beispiel #32
0
    def getValue(self):
        return self.get_property("value")

    ##
    ##  Signal-emitting methods
    ##
    def emitInputUpdated(self, obj, prop):
        self.emit("input-updated", self.input)

    ##
    ##  GObject methods
    ##
    def do_get_property(self, property):
        name = property.name

        if name in self.__dict__.keys():
            return self.__dict__[name]
        else:
            raise AttributeError, "No such attribute"

    def do_set_property(self, property, value):
        name = property.name

        if name in self.__dict__.keys():
            self.__dict__[name] = value
        else:
            raise AttributeError, "Not such attribute"


gobject.type_register(TransferSynapse)
Beispiel #33
0
        self.title_text.pop(position)
        self.notebook.remove_page(position)

    def show(self):
        self.window.show_all()
        self.current_page = 0
        self.notebook.set_current_page(self.current_page)
        self.update_title()
        self.set_buttons()
        self.emit('page-changed', self.notebook.get_current_page())
        if self.uistate:
            ManagedWindow.ManagedWindow.show(self)


if gtk.pygtk_version < (2, 8, 0):
    gobject.type_register(Assistant)

if __name__ == "__main__":

    def complete():
        gtk.main_quit()

    def make_label(table, val, y, x1, x2, x3, x4):
        label = gtk.Label(val)
        label.set_alignment(0, 0.5)
        text = gtk.Entry()
        table.attach(label, x1, x2, y, y + 1, gtk.SHRINK | gtk.FILL)
        table.attach(text, x3, x4, y, y + 1, gtk.EXPAND | gtk.FILL)
        return text

    a = Assistant(complete)
Beispiel #34
0
            self.bold_font = self.font.copy()
            self.bold_font.set_weight(pango.WEIGHT_BOLD)
        if self.read_only:
            self.set_font(self.bold_font)
        else:
            self.set_font(self.normal_font)
        self.queue_draw()

    def set_impossible(self, val):
        if val:
            self.set_text('X')
        else:
            self.set_text('')


gobject.type_register(NumberBox)

if __name__ == '__main__':
    window = gtk.Window()
    window.connect('delete-event', gtk.main_quit)

    def test_number_selector():
        nselector = NumberSelector(default=3)

        def tell_me(b):
            print 'value->', b.get_value()

        nselector.connect('changed', tell_me)
        window.add(nselector)

    def test_number_box():
Beispiel #35
0
def gobject_register(klass):
    if gtk_version_minor < 8:
        gobject.type_register(klass)
Beispiel #36
0
        # about this window are the _NET_SUPPORTING_WM_CHECK property, and
        # its title (which is supposed to be the name of the window manager).

        # NB, GDK will do strange things to this window.  We don't want to use
        # it for anything.  (In particular, it will call XSelectInput on it,
        # which is fine normally when GDK is running in a client, but since it
        # happens to be using the same connection as we the WM, it will
        # clobber any XSelectInput calls that *we* might have wanted to make
        # on this window.)  Also, GDK might silently swallow all events that
        # are detected on it, anyway.
        self._ewmh_window = gtk.gdk.Window(
            self._root,
            width=1,
            height=1,
            window_type=gtk.gdk.WINDOW_TOPLEVEL,
            event_mask=0,  # event mask
            wclass=gtk.gdk.INPUT_ONLY,
            title="%s-EWMH" % self._name)
        prop_set(self._ewmh_window, "_NET_SUPPORTING_WM_CHECK", "window",
                 self._ewmh_window)
        self.root_set("_NET_SUPPORTING_WM_CHECK", "window", self._ewmh_window)

    # Other global actions:

    def _make_window_pseudoclient(self, win):
        "Used by PseudoclientWindow, only."
        win.set_screen(self._alt_display.get_default_screen())


gobject.type_register(Wm)
Beispiel #37
0
        widths = self.__compute_column_widths(width - total_column_spacing)
        heights = self.__compute_row_heights(height - total_row_spacing)

        #        _logger.debug("allocate: widths=%s, heights=%s", widths, heights)

        x = 0
        xs = []
        for width in widths:
            xs.append(x)
            x += width + self.__column_spacing
        xs.append(x)

        y = 0
        ys = []
        for height in heights:
            ys.append(y)
            y += height + self.__row_spacing
        ys.append(y)

        for box_child in self.__box.get_layout_children():
            x = xs[box_child.left]
            width = xs[box_child.right] - x - self.__column_spacing
            y = ys[box_child.top]
            height = ys[box_child.bottom] - y - self.__row_spacing

            box_child.allocate(x, y, width, height, origin_changed)


gobject.type_register(TableLayout)
Beispiel #38
0
        menu = gtk.Menu()
        self.populate_menu_with_notebooks(menu, list)
        menu.show_all()
        menu.popup(None, None, gtk.status_icon_position_menu, button,
                   activate_time, self)

    def do_popup_menu(self, button=3, activate_time=0):
        #~ print '>>', button, activate_time
        menu = self.get_trayicon_menu()
        menu.show_all()
        menu.popup(None, None, gtk.status_icon_position_menu, button,
                   activate_time, self)


# Need to register classes overriding gobject signals
gobject.type_register(StatusIconTrayIcon)


class StandAloneTrayIcon(StatusIconTrayIcon):
    '''This class defines the tray icon used for a
	single stand-alone notebook.
	'''
    def __init__(self, window):
        StatusIconTrayIcon.__init__(self)
        self.window = window
        self.notebook = self.window.ui.notebook  # XXX
        self.set_tooltip(self.notebook.name)
        if self.notebook.icon:
            self.set_from_file(self.notebook.icon)

    def list_open_notebooks(self):
                if self.input_mode:
                    return True
                iter = self.buffer.get_iter_at_mark(self.buffer.get_insert())
                if iter.get_line_offset() == PSLEN:
                    self.quit_handler()
                return True

            # Ctrl-L
            elif event.keyval in (gtk.keysyms.L, gtk.keysyms.l):
                if not self.input_mode:
                    self.clear()
                return True
        return False


gobject.type_register(Console)


# =============================================================================
class ConsoleWindow:
    """ Interactive GTK console window """
    def __init__(self, ns, title='Python', command=None):
        """ Initialize s console window """

        self.win = gtk.Window()
        self.win.set_default_size(640, 400)
        self.win.set_border_width(3)
        self.win.connect("destroy", lambda w: gtk.main_quit())
        self.win.connect("delete_event", lambda w, e: gtk.main_quit())
        self.win.set_title(title)
        self.console = Console(namespace=ns)
        if self.get_child():
            child_width, child_height = self.get_child().size_request()
            requesition.width = max(child_width, requesition.width)
            requesition.height = max(child_height, requesition.height)

    def do_expose_event(self, event):
        CustomDrawingMixin.do_expose_event(self, event)
        if self.get_child():
            self.propagate_expose(self.get_child(), event)

    def do_size_allocate(self, allocation):
        gtk.Bin.do_size_allocate(self, allocation)
        if self.get_child():
            self.get_child().size_allocate(allocation)

gobject.type_register(MiroDrawingArea)
gobject.type_register(BackgroundWidget)

class Drawable:
    def __init__(self):
        self.squish_width = self.squish_height = False

    def set_squish_width(self, setting):
        self.squish_width = setting

    def set_squish_height(self, setting):
        self.squish_height = setting

    def set_widget(self, drawing_widget):
        if self.is_opaque() and 0:
            box = gtk.EventBox()
Beispiel #41
0
    def bind(self, keybinding):
        if self.bound:
            self.unbind()

        LOGGER.info('Binding Global shortcut %s to focus the deskbar',
                    keybinding)
        try:
            self.bound = deskbar.core.keybinder.tomboy_keybinder_bind(
                keybinding, self.on_keyboard_shortcut)
            self.prevbinding = keybinding
        except KeyError:
            # binding failed
            self.bound = False

        return self.bound

    def unbind(self):
        LOGGER.info('Unbinding Global shortcut %s to focus the deskbar',
                    self.prevbinding)
        try:
            deskbar.core.keybinder.tomboy_keybinder_unbind(self.prevbinding)
            self.bound = False
        except KeyError:
            # if the requested keybinding is not bound, a KeyError will be thrown
            pass


if gtk.pygtk_version < (2, 8, 0):
    gobject.type_register(Keybinder)
Beispiel #42
0
            if cond & (gobject.IO_ERR | gobject.IO_HUP):
                self.close()
                return False

            if cond & gobject.IO_OUT:
                if len(self._outgoing_queue) > 0: # send next item
                    item = self._outgoing_queue[0]
                    try:
                        ret = self._transport.send(item.read())
                    except (OpenSSL.WantX509LookupError,
                            OpenSSL.WantReadError, OpenSSL.WantWriteError):
                        return True
                    except OpenSSL.Error:
                        self.close()
                        return False
                    item.sent(ret)
                    if item.is_complete(): # sent item
                        self.emit("sent", item.buffer, item.size)
                        item.callback()
                        del self._outgoing_queue[0]
                        del item
                    if len(self._outgoing_queue) == 0:
                        self._watch_remove_cond(gobject.IO_OUT)
                else:
                    self._watch_remove_cond(gobject.IO_OUT)

        return True

gobject.type_register(SSLSocketClient)
Beispiel #43
0
	'dict'. Plugins should not modify page!
	'''

    # In theory it would be better to do this without a singleton, but in that
    # case there would need to be an instance of this object per NotebookInterface
    # object. Not impossible, but not needed for now.

    # define signals we want to use - (closure type, return type and arg types)
    __gsignals__ = {
        'process-page':
        (gobject.SIGNAL_RUN_LAST, None, (object, object, object)),
    }


# Need to register classes defining gobject signals
gobject.type_register(_TemplateManager)

TemplateManager = _TemplateManager()


class GenericTemplate(object):
    '''Base template class'''
    def __init__(self, input, name=None):
        '''Constructor takes a file path or an opened file handle'''
        if isinstance(input, basestring):
            input = input.splitlines(True)
        self.file = name or '<open file>'
        self.lineno = 0
        self.text = None  # needs to be set to None for use with TemplateError()
        self.tokens = TemplateTokenList()
        self.stack = [self.tokens]
Beispiel #44
0
class SearchEntry(InputEntry):
    def __init__(self, *args, **kwargs):

        entry_button = ImageButton(
            app_theme.get_pixbuf("toolbar/search_normal.png"),
            app_theme.get_pixbuf("toolbar/search_hover.png"),
            app_theme.get_pixbuf("toolbar/search_press.png"))
        super(SearchEntry, self).__init__(action_button=entry_button,
                                          *args,
                                          **kwargs)

        self.action_button = entry_button
        self.set_size(250, 24)


gobject.type_register(SearchEntry)


class ComplexButton(gtk.Button):
    def __init__(self,
                 bg_group,
                 icon,
                 content,
                 left_padding=20,
                 label_padding=10,
                 font_size=9):
        super(ComplexButton, self).__init__()

        # Init.
        self.normal_bg, self.hover_bg, self.press_bg = bg_group
        self.button_icon = icon
Beispiel #45
0
	return True

    def delete(self,key):
        """Pops up a dialog. If response is positive, deletes a MP."""
	logger.info("Delete: {0}".format(str(key)))
	package = self.repository.get(key)
	t1 = _("This action will remove the recording from the hard disk.")
	t2 = _('Recording: "{0}"').format(package.getTitle())
	text = {"title" : _("Media Manager"),
		"main" : _("Are you sure you want to delete?"),
		"text" : t1+"\n\n"+t2
		    }
	buttons = ( gtk.STOCK_DELETE, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
	warning = message.PopUp(message.WARNING, text,
                                context.get_mainwindow(),
                                buttons)

	if warning.response in message.POSITIVE:                
	    self.repository.delete(package)
	    return True
	else:
	    return False


    def network_status(self, signal, status):
        """Updates the signal status from a received signal"""
        self.network = status           

gobject.type_register(ManagerUI)
Beispiel #46
0
    def __init__(self, name=None):
        self._name = name
        self.__gobject_init__()
        self._stop_time = None
        self._start_time = time.time()

    def reset_start_time(self):
        self._start_time = time.time()
        self._stop_time = None

    def set_stop_time(self, stop_time):
        self._stop_time = stop_time


gobject.type_register(TimeredObj)


class TimerManager(gobject.GObject):

    timered_objs = []
    active_timered_objs = []
    done_timered_objs = []
    io_handler_id = 0

    def __init__(self):
        self.__gobject_init__()

    def add_timerd_obj(self, obj):
        if not isinstance(obj, TimeredObj):
            raise TypeError, "obj must be TimeredObj Object"
Beispiel #47
0
            emsg = _("Error looking up artist %s on jamendo.com") % (artist)
            Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO,
                              Gtk.ButtonsType.OK, emsg).run()
            return
        Gtk.show_uri(self.props.shell.props.window.get_screen(),
                     result + "donate/", Gdk.CURRENT_TIME)

    def playing_entry_changed(self, entry):
        if not self.__db or not entry:
            return

        if entry.get_entry_type() != self.__db.entry_type_get_by_name(
                "JamendoEntryType"):
            return

        gobject.idle_add(self.emit_cover_art_uri, entry)

    def emit_cover_art_uri(self, entry):
        stream = self.__db.entry_get_string(entry,
                                            RB.RhythmDBPropType.LOCATION)
        albumid = self.__db.entry_get_string(entry,
                                             RB.RhythmDBPropType.MB_ALBUMID)
        url = artwork_url % albumid

        self.__db.emit_entry_extra_metadata_notify(entry, "rb:coverArt-uri",
                                                   str(url))
        return False


gobject.type_register(JamendoSource)
Beispiel #48
0
                if isinstance(value, datetime.datetime):
                    value = value.date()
                assert isinstance(value, datetime.date), value
            self.__date = value
            self.update_label()
        elif prop.name == 'format':
            self.__format = value
            self.update_label()

    def do_get_property(self, prop):
        if prop.name == 'value':
            return self.__date
        elif prop.name == 'format':
            return self.__format

gobject.type_register(Date)


class CellRendererDate(gtk.CellRendererText):
    __gproperties__ = {
        'format': (gobject.TYPE_STRING,
            _('Format'),
            _('Display format'),
            '%x',
            gobject.PARAM_READABLE | gobject.PARAM_WRITABLE),
        }

    def __init__(self):
        self.__format = '%x'

        gtk.CellRendererText.__init__(self)
    __gsttemplates__ = (gst.PadTemplate("sink", gst.PAD_SINK, gst.PAD_ALWAYS,
                                        caps), )

    def __init__(self):
        gst.BaseSink.__init__(self)
        self.props.sync = False
        self.rate = 0
        self.duration = 0L
        self.reset()

    def reset(self):
        self.samples = array.array('f')

    def do_set_caps(self, caps):
        if not caps[0].get_name() == "audio/x-raw-float":
            return False
        self.rate = caps[0]["rate"]
        return True

    def do_render(self, buf):
        self.samples.fromstring(buf)
        self.duration += buf.duration
        return gst.FLOW_OK

    def do_preroll(self, buf):
        return self.do_render(buf)


gobject.type_register(ArraySink)
Beispiel #50
0
                                "base-size": (640, 640),
                                "minimum-size": (640, 640),
                                "increment": (128, 128),
                                "minimum-aspect-ratio": (1, 3),
                                "maximum-aspect-ratio": (3, 1),
                            })
        else:
            use_fixed_size()
        screenlog("size-hints=%s", size_hints)
        self._updateprop("size-hints", size_hints)

    def do_xpra_damage_event(self, event):
        self.emit("client-contents-changed", event)


gobject.type_register(DesktopModel)
"""
    A server class for RFB / VNC-like desktop displays,
    used with the "start-desktop" subcommand.
"""


class XpraDesktopServer(gobject.GObject, RFBServer, X11ServerBase):
    __gsignals__ = {
        "xpra-xkb-event": one_arg_signal,
        "xpra-cursor-event": one_arg_signal,
        "xpra-motion-event": one_arg_signal,
    }

    def __init__(self):
        gobject.GObject.__init__(self)
Beispiel #51
0
                return gst.FLOW_OK

        if len(self.buffer) < self.buffer_size:
            # we need to buffer more
            return gst.FLOW_OK

        buffer = self.buffer[self.buffer_size:]
        fake_header = self.get_fake_header()
        n_buf = gst.Buffer(fake_header + buffer)
        self.proxy = True
        self.srcpad.push(n_buf)

        return gst.FLOW_OK


gobject.type_register(FakeTransformer)


class DataSink(gst.Element, log.Loggable):

    logCategory = 'transcoder_datasink'

    _sinkpadtemplate = gst.PadTemplate("sinkpadtemplate", gst.PAD_SINK,
                                       gst.PAD_ALWAYS, gst.caps_new_any())

    def __init__(self, destination=None, request=None):
        gst.Element.__init__(self)
        self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink")
        self.add_pad(self.sinkpad)

        self.sinkpad.set_chain_function(self.chainfunc)
Beispiel #52
0
        if unparsed in self.normalized_hotkeys:
            target = self.normalized_hotkeys[unparsed]
            self.emit("hotkey::%s" % (target, ), target)

    def add_hotkeys(self, hotkeys):
        self.hotkeys.update(hotkeys)
        self._rebind()

    def del_hotkeys(self, keys):
        for k in keys:
            if k in self.hotkeys:
                del self.hotkeys[k]
        self._rebind()


gobject.type_register(HotkeyManager)

DEFAULT_MODIFIER_MEANINGS = {
    "Shift_L": "shift",
    "Shift_R": "shift",
    "Caps_Lock": "lock",
    "Control_L": "control",
    "Control_R": "control",
    "Alt_L": "mod1",
    "Alt_R": "mod1",
    "Num_Lock": "mod2",
    "Meta_L": "mod3",
    "Meta_R": "mod3",
    "Super_L": "mod4",
    "Super_R": "mod4",
    "Hyper_L": "mod4",
Beispiel #53
0
            self.ready_handler(self)

        # get the value of ContactAttributeInterfaces
        self[DBUS_PROPERTIES].Get(CONNECTION_INTERFACE_CONTACTS,
            'ContactAttributeInterfaces',
            reply_handler=reply, error_handler=error)

        self.signals.append(self[CONNECTION].connect_to_signal(
            'StatusChanged', self._status_changed))

    def do_disconnect(self):
        # required so that we don't transmit this over D-Bus
        pass

gobject.type_register(EConnection)

class EChannel(gobject.GObject,
               telepathy.client.Channel):
    __gsignals__ = {
        'closed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
    }

    def __init__(self, account_path, conn, path, properties, ready_handler):
        self.ready_handler = ready_handler
        self.account_path = account_path
        self.conn = conn
        self.properties = properties
        self.signals = []

        gobject.GObject.__init__(self)
Beispiel #54
0
        # CZECH THIS SHIT. You *can* set the fg/text on a label, but it
        # will still emboss the color in the INSENSITIVE state. The way
        # to avoid embossing is to use pango attributes (e.g. via
        # <span>), but then in INSENSITIVE you get stipple. Where is
        # this documented? Grumble.
        if sensitive:
            m = '<small>%s</small>' % self.name
        else:
            m = ('<small><span foreground="%s">%s</span></small>' %
                 (pc(self.fgi), self.name))
        self.label.set_markup(m)

        gtk.Button.set_sensitive(self, sensitive)


gobject.type_register(_SidebarButton)


class _SidebarSection(gtk.VBox):
    gsignal('step-chosen', str)

    def __init__(self, title, name):
        gtk.VBox.__init__(self)

        self.set_name(title)
        self._buttons = util.OrderedDict()

        self.title = _SidebarButton(title, 10)
        self.title.show()
        self.title.set_sensitive(False)
        self.pack_start(self.title, False, False)
Beispiel #55
0
    def __delete_messages_cb(self, messages):
        for message in messages:
            try:
                self._messages.remove(message)
            except ValueError:
                pass
        self.emit('messages-deleted')

    def __common_callback(self, signal, *args):
        self.emit(signal, *args)

    def __common_errback(self, error_code, *args):
        self.emit('error', error_code)


gobject.type_register(OfflineMessagesBox)

if __name__ == '__main__':
    import sys
    import getpass
    import signal
    import gobject
    import logging
    from papyon.service.SingleSignOn import *
    from papyon.service.AddressBook import AddressBook

    logging.basicConfig(level=logging.DEBUG)

    if len(sys.argv) < 2:
        account = raw_input('Account: ')
    else:
Beispiel #56
-1
 def __init__(cls,*kwds):
     gobject.GObjectMeta.__init__(cls,*kwds)
     cls.__gtype_name__ = cls.__name__
     gobject.signal_new('cursor-move', cls,
                        gobject.SIGNAL_RUN_FIRST,
                        gobject.TYPE_NONE,
                        (gobject.TYPE_DOUBLE,gobject.TYPE_DOUBLE))
     gobject.type_register(cls)
Beispiel #57
-1
def set_up():
	gobject.type_register(CommandText)
	gobject.type_register(IconSelector)

	gobject.signal_new("text-changed", CommandText, gobject.SIGNAL_RUN_FIRST,  gobject.TYPE_NONE, (gobject.TYPE_STRING,))
	gobject.signal_new("mode-changed", CommandText, gobject.SIGNAL_RUN_FIRST,  gobject.TYPE_NONE, (gobject.TYPE_STRING,))

	gobject.signal_new("image-changed", IconSelector, gobject.SIGNAL_RUN_FIRST,  gobject.TYPE_NONE, (gobject.TYPE_STRING,))
	gobject.signal_new("text-changed", IconSelector, gobject.SIGNAL_RUN_FIRST,  gobject.TYPE_NONE, (gobject.TYPE_STRING,))
	gobject.signal_new("mode-changed", IconSelector, gobject.SIGNAL_RUN_FIRST,  gobject.TYPE_NONE, (gobject.TYPE_STRING,))
Beispiel #58
-1
	def __init__(self):
		self.tempo = 120
		self.channels = []
		self.control_channel = 1
		self.control_channel_cur = 0
		self.device = self.MidiDevice()
		self.global_pattern = []
		gobject.GObject.__init__(self)
		gobject.type_register(self.Channel)
		gobject.signal_new("bar-end", self.Channel, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
		print "Starting Sequencer..."
 def __init__(self):
     print "Inicio"
     
     gobject.type_register(Sender)
     gobject.signal_new("z_signal", Sender, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
                
     sender = Sender()
     receiver = Reciever(sender)
     
     sender.connect('z_signal', self.user_callback)
     sender.emit('z_signal')
Beispiel #60
-1
 def __init__(cls,*kwds):
     gobject.GObjectMeta.__init__(cls,*kwds)
     cls.__gtype_name__ = cls.__name__
     gobject.signal_new('time_changed', cls,
                        gobject.SIGNAL_RUN_FIRST,
                        gobject.TYPE_NONE,
                        (gobject.TYPE_PYOBJECT,))
     gobject.signal_new('date_changed', cls,
                        gobject.SIGNAL_RUN_FIRST,
                        gobject.TYPE_NONE,
                        (gobject.TYPE_PYOBJECT,))
     gobject.type_register(cls)