Example #1
0
    def __init__(self, pipe, panel_view):
        self._rec_file = None
        self._panel_view = panel_view
        tag_table = panel_view.buffer.get_tag_table()
        self._tag = Gtk.TextTag()
        self._good_tag = GObject.new(Gtk.TextTag,
                                     weight=Pango.Weight.BOLD,
                                     foreground="darkgreen",
                                     paragraph_background="lightgreen")
        self._bad_tag = GObject.new(Gtk.TextTag,
                                    weight=Pango.Weight.BOLD,
                                    foreground="darkred",
                                    paragraph_background="pink")
        self._ugly_tag = GObject.new(Gtk.TextTag, foreground="red")
        self._rec_tag = GObject.new(Gtk.TextTag,
                                    weight=Pango.Weight.BOLD,
                                    foreground="white",
                                    paragraph_background="orange")
        tag_table.add(self._tag)
        tag_table.add(self._good_tag)
        tag_table.add(self._bad_tag)
        tag_table.add(self._ugly_tag)
        tag_table.add(self._rec_tag)

        self._watch_id = GObject.io_add_watch(
            pipe,
            GObject.IO_IN | GObject.IO_PRI | GObject.IO_ERR | GObject.IO_HUP,
            self._on_output)
Example #2
0
    def __init__(self, pipe, log_view):
        self.__log_view = log_view

        tag_table = log_view.buffer.get_tag_table()
        self.__tag = Gtk.TextTag()

        self.__good_tag = GObject.new(Gtk.TextTag,
            weight                  = Pango.Weight.BOLD,
            foreground              = "darkgreen",
            paragraph_background    = "lightgreen")

        self.__bad_tag = GObject.new(Gtk.TextTag,
            weight                  = Pango.Weight.BOLD,
            foreground              = "darkred",
            paragraph_background    = "pink")

        # for warnings, etc.
        self.__ugly_tag = GObject.new(Gtk.TextTag,
            #weight                  = pango.WEIGHT_BOLD,
            foreground              = "red")

        tag_table.add(self.__tag)
        tag_table.add(self.__good_tag)
        tag_table.add(self.__bad_tag)
        tag_table.add(self.__ugly_tag)

        self.__watch_id = GObject.io_add_watch(pipe,
            GObject.IO_IN |
            GObject.IO_PRI |
            GObject.IO_ERR |
            GObject.IO_HUP,
            self.__on_output)
    def __init__(self, pipe, log_view):
        self.__log_view = log_view

        tag_table = log_view.buffer.get_tag_table()
        self.__tag = Gtk.TextTag()

        self.__good_tag = GObject.new(Gtk.TextTag,
                                      weight=Pango.Weight.BOLD,
                                      foreground="darkgreen",
                                      paragraph_background="lightgreen")

        self.__bad_tag = GObject.new(Gtk.TextTag,
                                     weight=Pango.Weight.BOLD,
                                     foreground="darkred",
                                     paragraph_background="pink")

        # for warnings, etc.
        self.__ugly_tag = GObject.new(
            Gtk.TextTag,
            #weight                  = pango.WEIGHT_BOLD,
            foreground="red")

        tag_table.add(self.__tag)
        tag_table.add(self.__good_tag)
        tag_table.add(self.__bad_tag)
        tag_table.add(self.__ugly_tag)

        self.__watch_id = GObject.io_add_watch(
            pipe,
            GObject.IO_IN | GObject.IO_PRI | GObject.IO_ERR | GObject.IO_HUP,
            self.__on_output)
Example #4
0
def get_file_from_filechooser(main,
                              folder=False,
                              save_file=False,
                              save_to=None):

    if folder:
        open_action = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
    else:
        open_action = gtk.FILE_CHOOSER_ACTION_OPEN

    if platform.FREMANTLE:
        if save_file:
            dlg = gobject.new(hildon.FileChooserDialog, \
                    action=gtk.FILE_CHOOSER_ACTION_SAVE)
        else:
            dlg = gobject.new(hildon.FileChooserDialog, \
                    action=open_action)
    elif platform.MAEMO:
        if save_file:
            args = (main.main_window, gtk.FILE_CHOOSER_ACTION_SAVE)
        else:
            args = (main.main_window, open_action)

        dlg = hildon.FileChooserDialog(*args)
    else:
        if save_file:
            args = (_('Select file to save playlist to'), None,
                    gtk.FILE_CHOOSER_ACTION_SAVE,
                    ((gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_SAVE,
                      gtk.RESPONSE_OK)))
        else:
            args = (_('Select podcast or audiobook'), None, open_action,
                    ((gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OPEN,
                      gtk.RESPONSE_OK)))

        dlg = gtk.FileChooserDialog(*args)

    current_folder = os.path.expanduser(
        main.config.get("options", "default_folder"))

    if current_folder is not None and os.path.isdir(current_folder):
        dlg.set_current_folder(current_folder)

    if save_file and save_to is not None:
        dlg.set_current_name(save_to)

    if dlg.run() == gtk.RESPONSE_OK:
        filename = dlg.get_filename()
        main.config.set("options", "default_folder", dlg.get_current_folder())
    else:
        filename = None

    dlg.destroy()
    return filename
Example #5
0
def get_file_from_filechooser(main, folder=False, save_file=False, save_to=None):

    if folder:
        open_action = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
    else:
        open_action = gtk.FILE_CHOOSER_ACTION_OPEN

    if platform.FREMANTLE:
        if save_file:
            dlg = gobject.new(hildon.FileChooserDialog, \
                    action=gtk.FILE_CHOOSER_ACTION_SAVE)
        else:
            dlg = gobject.new(hildon.FileChooserDialog, \
                    action=open_action)
    elif platform.MAEMO:
        if save_file:
            args = ( main.main_window, gtk.FILE_CHOOSER_ACTION_SAVE )
        else:
            args = ( main.main_window, open_action )

        dlg = hildon.FileChooserDialog( *args )
    else:
        if save_file:
            args = ( _('Select file to save playlist to'), None,
                gtk.FILE_CHOOSER_ACTION_SAVE,
                (( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                gtk.STOCK_SAVE, gtk.RESPONSE_OK )) )
        else:
            args = ( _('Select podcast or audiobook'), None, open_action,
                (( gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                gtk.STOCK_OPEN, gtk.RESPONSE_OK )) )

        dlg = gtk.FileChooserDialog(*args)

    current_folder = os.path.expanduser(main.config.get("options", "default_folder"))

    if current_folder is not None and os.path.isdir(current_folder):
        dlg.set_current_folder(current_folder)

    if save_file and save_to is not None:
        dlg.set_current_name(save_to)

    if dlg.run() == gtk.RESPONSE_OK:
        filename = dlg.get_filename()
        main.config.set("options", "default_folder", dlg.get_current_folder())
    else:
        filename = None

    dlg.destroy()
    return filename
    def do_activate(self):
        shell = self.object
        sp = shell.props.shell_player
        self.db = shell.get_property('db')
        self.qm = RB.RhythmDBQueryModel.new_empty(self.db)
        self.pec_id = sp.connect('playing-song-changed',
                                 self.playing_entry_changed)
        self.pc_id = sp.connect('playing-changed', self.playing_changed)
        self.sc_id = sp.connect('playing-source-changed', self.source_changed)
        self.current_entry = None

        self.entry_type = RB.RhythmDBEntryType()
        playlist_group = RB.DisplayPageGroup.get_by_id("playlists")
        self.echonest_source = GObject.new(EchoNestSource,
                                           entry_type=self.entry_type,
                                           shell=shell,
                                           pixbuf=None,
                                           plugin=self)
        shell.register_entry_type_for_source(self.echonest_source,
                                             self.entry_type)
        shell.append_display_page(self.echonest_source, playlist_group)

        self.lookup_query_model = self.echonest_source.props.query_model

        glade_file = self.find_file("source.glade")
        gconf = GConf.Client.get_default()
        self.echonest_source.initialize_ui(glade_file, gconf)

        # a mapping of a url to similar artist data from that url.
        # similar artist data is a mapping of sanitized_artist -> artist
        self.similar_artists_obj = SimilarArtists()

        self.initialize_icon()
Example #7
0
    def do_activate(self):
        """Activate the pandora plugin. Called when checked within the Rhythmbox plugin pane."""
        print("Activating pandora plugin.")

        shell = self.object
        db = shell.props.db
        entry_type = PandoraEntryType()
        db.register_entry_type(entry_type)

        _, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
        pandora_icon = GdkPixbuf.Pixbuf.new_from_file_at_size(rb.find_plugin_file(self, "pandora.png"), width, height)

        self.source = GObject.new(
            PandoraSource,
            shell=shell,
            name="Pandora",
            plugin=self,
            icon=pandora_icon,
            entry_type=entry_type)
        library_group = RB.DisplayPageGroup.get_by_id("library")
        shell.append_display_page(self.source, library_group)
        shell.register_entry_type_for_source(self.source, entry_type)

        # hack, should be done within gobject constructor
        self.source.init();

        self.pec_id = shell.props.shell_player.connect_after('playing-song-changed', self.playing_entry_changed)
        self.psc_id = shell.props.shell_player.connect_after('playing-source-changed', self.playing_source_changed)
Example #8
0
	def do_activate(self):
		print("activating vk plugin")
		#connecting to GSettings
		schema_source = Gio.SettingsSchemaSource.new_from_directory(self.plugin_info.get_data_dir(), Gio.SettingsSchemaSource.get_default(), False,)
		schema = schema_source.lookup('org.gnome.rhythmbox.plugins.vk', False)
		self.settings = Gio.Settings.new_full(schema, None, None)
		#system settings
		shell = self.object
		db = shell.props.db
		vk_entry_type = VKEntryType()
		self.entry_type = vk_entry_type
		db.register_entry_type(vk_entry_type)
		#icon
		iconfile = Gio.File.new_for_path(self.plugin_info.get_data_dir()+"/vk-symbolic.svg")
		#create Source (aka tab)
		self.source = GObject.new (VKSource, shell=shell,
						name="VK "+_("Music"),
						entry_type=vk_entry_type,
						plugin=self,)
						#icon=Gio.FileIcon.new(iconfile))
		self.source.setup(db, self.settings)
		shell.register_entry_type_for_source(self.source, vk_entry_type)
		#append source to the library
		group = RB.DisplayPageGroup.get_by_id ("library")
		shell.append_display_page(self.source, group)
    def do_activate(self):
        shell = self.object
        sp = shell.props.shell_player
        self.db = shell.get_property('db')
        self.qm = RB.RhythmDBQueryModel.new_empty(self.db)
        self.pec_id = sp.connect('playing-song-changed', self.playing_entry_changed)
        self.pc_id = sp.connect('playing-changed', self.playing_changed)
        self.sc_id = sp.connect('playing-source-changed', self.source_changed)
        self.current_entry = None

        self.entry_type = RB.RhythmDBEntryType()
        playlist_group = RB.DisplayPageGroup.get_by_id("playlists")
        self.echonest_source = GObject.new(EchoNestSource,
                                           entry_type = self.entry_type,
                                           shell = shell,
                                           pixbuf=None, 
                                           plugin=self)
        shell.register_entry_type_for_source(self.echonest_source, self.entry_type)
        shell.append_display_page(self.echonest_source, playlist_group)

        self.lookup_query_model = self.echonest_source.props.query_model
        
        glade_file = self.find_file("source.glade")
        gconf = GConf.Client.get_default()
        self.echonest_source.initialize_ui(glade_file, gconf)

        # a mapping of a url to similar artist data from that url.
        # similar artist data is a mapping of sanitized_artist -> artist
        self.similar_artists_obj = SimilarArtists()

        self.initialize_icon()
Example #10
0
 def get_c_widget(self, mod_id):
     extension = self.extension_point.get_extension_by_name(mod_id)
     if extension is None:
         print("Could not load %s module; is the cinnamon-control-center package installed?" % mod_id)
         return None
     panel_type = extension.get_type()
     return GObject.new(panel_type)
Example #11
0
    def _launchPipeline(self):
        self.debug(
            'Now generating waveforms for: %s', path_from_uri(self._uri))
        self.pipeline = Gst.parse_launch("uridecodebin name=decode uri=" +
                                         self._uri + " ! waveformbin name=wave"
                                         " ! fakesink qos=false name=faked")
        # This line is necessary so we can instantiate GstTranscoder's
        # GstCpuThrottlingClock below.
        Gst.ElementFactory.make("uritranscodebin", None)
        clock = GObject.new(GObject.type_from_name("GstCpuThrottlingClock"))
        clock.props.cpu_usage = self._max_cpu_usage
        self.pipeline.use_clock(clock)
        faked = self.pipeline.get_by_name("faked")
        faked.props.sync = True
        self._wavebin = self.pipeline.get_by_name("wave")
        asset = self.ges_elem.get_parent().get_asset()
        self._wavebin.props.uri = asset.get_id()
        self._wavebin.props.duration = asset.get_duration()
        decode = self.pipeline.get_by_name("decode")
        decode.connect("autoplug-select", self._autoplug_select_cb)
        bus = self.pipeline.get_bus()
        bus.add_signal_watch()

        asset = self.ges_elem.get_parent().get_asset()
        self.n_samples = asset.get_duration() / SAMPLE_DURATION
        bus.connect("message", self._busMessageCb)
	def do_activate(self):
		self.shell = self.object
		self.player = self.shell.props.shell_player

		# create and register an entry type
		self.db = self.shell.props.db
		self.entry_type = DoubanFMEntryType()
		self.db.register_entry_type(self.entry_type)
		self.entry_type.can_sync_metadata = True
		self.entry_type.sync_metadata = None

		# load doubanfm icon from file
		icon = GdkPixbuf.Pixbuf.new_from_file(PLUGIN_DIR + ICON_FILE)

		# create a source under 'stores' group
		group = RB.DisplayPageGroup.get_by_id ('stores')
		self.source = GObject.new(DoubanFMSource, shell=self.shell,
			entry_type=self.entry_type, pixbuf=icon, plugin=self)
		self.shell.register_entry_type_for_source(self.source, self.entry_type)
		self.shell.append_display_page(self.source, group)

		# create ui, connect ui to actions, and add them to ui manager
		self.ui_manager = self.shell.props.ui_manager
		self.build_actions()
		self.ui_manager.insert_action_group(self.action_group)
		self.ui_merge_id = self.ui_manager.add_ui_from_file(PLUGIN_DIR + UI_FILE)
		self.change_menu_item_state(False)
		self.ui_manager.ensure_update()

		# connect signals
		self.player.connect('playing-source-changed', self.on_playing_source_changed)
		self.set_handle_signals(True)
Example #13
0
    def do_activate(self):
        print "CoverArtBrowser DEBUG - do_activate"
        self.shell = self.object
        self.db = self.shell.props.db
        
        try:
            entry_type = CoverArtBrowserEntryType()
            self.db.register_entry_type(entry_type)
        except NotImplementedError:
            entry_type = db.entry_register_type("CoverArtBrowserEntryType")

        entry_type.category = RB.RhythmDBEntryCategory.NORMAL

        # load plugin icon
        theme = Gtk.IconTheme.get_default()
        rb.append_plugin_source_path(theme, "/icons")

        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
        pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size(rb.find_plugin_file(self, "covermgr.png"), width, height)

        group = RB.DisplayPageGroup.get_by_id ("library")

        self.source = GObject.new ( CoverArtBrowserSource,
                                    shell=self.shell,
                                    name=_("CoverArt"),
                                    entry_type=entry_type,
                                    plugin=self,
                                    pixbuf=pxbf)

        self.shell.register_entry_type_for_source(self.source, entry_type)
        self.shell.append_display_page(self.source, group)
        
        print "CoverArtBrowser DEBUG - end do_activate"
Example #14
0
 def do_activate(self):
     print "activating vk plugin"
     #connecting to GSettings
     schema_source = Gio.SettingsSchemaSource.new_from_directory(
         self.plugin_info.get_data_dir(),
         Gio.SettingsSchemaSource.get_default(),
         False,
     )
     schema = schema_source.lookup('org.gnome.rhythmbox.plugins.vk', False)
     self.settings = Gio.Settings.new_full(schema, None, None)
     #system settings
     shell = self.object
     db = shell.props.db
     #model = RB.RhythmDBQueryModel.new_empty(db)
     vk_entry_type = VKEntryType()
     self.entry_type = vk_entry_type
     db.register_entry_type(vk_entry_type)
     #icon
     what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
     icon = GdkPixbuf.Pixbuf.new_from_file_at_size(
         self.plugin_info.get_data_dir() + "/vk.png", width, height)
     #create Source (aka tab)
     self.source = GObject.new(VKSource,
                               shell=shell,
                               name="VK " + _("Music"),
                               entry_type=vk_entry_type,
                               plugin=self,
                               pixbuf=icon)  #query_model=model,
     self.source.setup(db, self.settings)
     shell.register_entry_type_for_source(self.source, vk_entry_type)
     #append source to the library
     group = RB.DisplayPageGroup.get_by_id("library")
     shell.append_display_page(self.source, group)
Example #15
0
    def _launch_pipeline(self):
        self.pipeline = Gst.parse_launch("uridecodebin name=decode uri=" +
                                         self._uri + " ! waveformbin name=wave"
                                         " ! fakesink qos=false name=faked")

        Gst.ElementFactory.make("uritranscodebin", None)

        clock = GObject.new(GObject.type_from_name("GstCpuThrottlingClock"))
        clock.props.cpu_usage = 90
        self.pipeline.use_clock(clock)

        faked = self.pipeline.get_by_name("faked")
        faked.props.sync = True
        self._wavebin = self.pipeline.get_by_name("wave")

        self._wavebin.props.uri = self._asset.get_id()
        self._wavebin.props.duration = self._asset.get_duration()
        decode = self.pipeline.get_by_name("decode")
        decode.connect("autoplug-select", self._autoplug_select_cb)
        bus = self.pipeline.get_bus()
        self.pipeline.set_state(Gst.State.PLAYING)
        bus.add_signal_watch()
        self.n_samples = self._asset.get_duration() / SAMPLE_DURATION
        bus.connect("message::error", self.__on_bus_error)
        bus.connect("message::eos", self.__on_bus_eos)
Example #16
0
 def do_activate(self):
     print("activating vk plugin")
     # connecting to GSettings
     schema_source = Gio.SettingsSchemaSource.new_from_directory(
         self.plugin_info.get_data_dir(),
         Gio.SettingsSchemaSource.get_default(),
         False,
     )
     schema = schema_source.lookup('org.gnome.rhythmbox.plugins.vk', False)
     self.settings = Gio.Settings.new_full(schema, None, None)
     # system settings
     shell = self.object
     db = shell.props.db
     vk_entry_type = VKEntryType()
     self.entry_type = vk_entry_type
     db.register_entry_type(vk_entry_type)
     # icon
     iconfile = Gio.File.new_for_path(self.plugin_info.get_data_dir() +
                                      "/vk-symbolic.svg")
     # create Source (aka tab)
     self.source = GObject.new(VKSource,
                               shell=shell,
                               name="VK " + _("Music"),
                               entry_type=vk_entry_type,
                               plugin=self,
                               icon=Gio.FileIcon.new(iconfile))
     self.source.setup(db, self.settings)
     shell.register_entry_type_for_source(self.source, vk_entry_type)
     # append source to the library
     group = RB.DisplayPageGroup.get_by_id("library")
     shell.append_display_page(self.source, group)
Example #17
0
    def do_activate(self):
        print "activating PlayLast.fm plugin"
        self.shell = self.object
        self.db = self.shell.get_property("db")
        self.qm = RB.RhythmDBQueryModel.new_empty(self.db)
        self.entry_type = RB.RhythmDBEntryType()

        ## Create source
        playlist_group = RB.DisplayPageGroup.get_by_id("playlists")
        self.plfm_source = GObject.new( \
                      PlayLastfmSource,
                      entry_type = self.entry_type,
                      shell=self.shell,
                      pixbuf=None,
                      plugin=self)
        self.shell.register_entry_type_for_source(self.plfm_source , self.entry_type)
        self.shell.append_display_page(self.plfm_source, playlist_group)

        ## The following code sets the correct size for your source icon,
        ## finds it by its filename and adds it to a pixbuf.
## FIXME: restore icon support
##        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
##        theme = Gtk.IconTheme.get_default()
##        rb.append_plugin_source_path(theme, "/icons/")
##        icon = rb.try_load_icon(theme, "lastfm", width, 0)
##        # The following code sets the sources "icon" property to the image stored in the pixbuf created above.
##        self.plfm_source.set_property( "pixbuf",  icon) 

        print 'test'
        self.plfm_source.initialise()
        #self.ev = self.plfm_source.entry_view
        self.db_connect_signal()

        self.plfm_source.button.connect("clicked", self.populate)
Example #18
0
 def get_c_widget(self, mod_id):
     extension = self.extension_point.get_extension_by_name(mod_id)
     if extension is None:
         print("Could not load %s module; is the cinnamon-control-center package installed?" % mod_id)
         return None
     panel_type = extension.get_type()
     return GObject.new(panel_type)
Example #19
0
        def load_iterate():
            try:
                cache = self.__caches.popleft()

                print('process playlist: %s' % cache)

                if cache == self.__songs_cache:
                    load_songs(self.__songs_cache_filename, False, self)
                else:
                    # create AmpachePlaylist source
                    playlist_source = GObject.new(AmpachePlaylist,
                                                  shell=self.__shell,
                                                  entry_type=self.__entry_type,
                                                  name=_(cache))
                    self.__playlist_sources.append(playlist_source)

                    # insert AmpachePlaylist source into AmpacheBrowser source
                    self.__shell.append_display_page(playlist_source, self)

                    load_songs(
                        os.path.join(self.__cache_directory,
                                     ''.join([cache, '.xml'])), True,
                        playlist_source)

            except Exception, e:
                print('no more playlists to process')
                return
Example #20
0
    def _launchPipeline(self):
        self.debug('Now generating waveforms for: %s',
                   path_from_uri(self._uri))
        self.pipeline = Gst.parse_launch("uridecodebin name=decode uri=" +
                                         self._uri + " ! waveformbin name=wave"
                                         " ! fakesink qos=false name=faked")
        # This line is necessary so we can instantiate GstTranscoder's
        # GstCpuThrottlingClock below.
        Gst.ElementFactory.make("uritranscodebin", None)
        clock = GObject.new(GObject.type_from_name("GstCpuThrottlingClock"))
        clock.props.cpu_usage = self._max_cpu_usage
        self.pipeline.use_clock(clock)
        faked = self.pipeline.get_by_name("faked")
        faked.props.sync = True
        self._wavebin = self.pipeline.get_by_name("wave")
        asset = self.ges_elem.get_asset().get_filesource_asset()
        self._wavebin.props.uri = asset.get_id()
        self._wavebin.props.duration = asset.get_duration()
        decode = self.pipeline.get_by_name("decode")
        decode.connect("autoplug-select", self._autoplug_select_cb)
        bus = self.pipeline.get_bus()
        bus.add_signal_watch()

        self.n_samples = asset.get_duration() / SAMPLE_DURATION
        bus.connect("message", self._busMessageCb)
Example #21
0
    def testGobjectNew(self):
        entry = GObject.new(ProxyEntry)
        self.assertEqual(entry.get_property('data_type'), None)

        entry = GObject.new(ProxyEntry, data_type=int)
        entry.set_property("data-type", str)
        self.assertEqual(entry.get_property('data_type'), 'str')
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertEqual(entry.get_property('data_type'), 'str')

        entry = GObject.new(ProxyEntry, data_type=int)
        self.assertEqual(entry.get_property('data_type'), 'int')
        entry.set_property("data-type", str)
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.assertEqual(entry.get_property('data_type'), 'str')
Example #22
0
    def create(self, msgid, **kwargs):
        tp = self.lookup(msgid)

        if not tp.is_a(GitgExt.Message.__gtype__):
            return None

        kwargs['id'] = msgid

        return GObject.new(tp, **kwargs)
Example #23
0
    def create(self, msgid, **kwargs):
        tp = self.lookup(msgid)

        if not tp.is_a(GitgExt.Message.__gtype__):
            return None

        kwargs['id'] = msgid

        return GObject.new(tp, **kwargs)
Example #24
0
    def test_floating(self):
        e = Everything.TestFloating()
        self.assertEqual(e.__grefcount__, 1)

        e = GObject.new(Everything.TestFloating)
        self.assertEqual(e.__grefcount__, 1)

        e = Everything.TestFloating.new()
        self.assertEqual(e.__grefcount__, 1)
Example #25
0
    def test_floating(self):
        e = Everything.TestFloating()
        self.assertEqual(e.__grefcount__, 1)

        e = GObject.new(Everything.TestFloating)
        self.assertEqual(e.__grefcount__, 1)

        e = Everything.TestFloating.new()
        self.assertEqual(e.__grefcount__, 1)
Example #26
0
    def create(self, object_path, method, **kwargs):
        tp = self.lookup(object_path, method)

        if not tp.is_a(Gedit.Message.__gtype__):
            return None

        kwargs['object-path'] = object_path
        kwargs['method'] = method

        return GObject.new(tp, **kwargs)
Example #27
0
    def create(self, object_path, method, **kwargs):
        tp = self.lookup(object_path, method)

        if not tp.is_a(Gedit.Message.__gtype__):
            return None

        kwargs['object-path'] = object_path
        kwargs['method'] = method

        return GObject.new(tp, **kwargs)
Example #28
0
	def do_activate(self):
		print("activating sample python plugin")

		shell = self.object
		db = shell.props.db
		model = RB.RhythmDBQueryModel.new_empty(db)
		self.source = GObject.new (PythonSource, shell=shell, name=_("Python Source"), query_model=model)
		self.source.setup()
		group = RB.DisplayPageGroup.get_by_id ("library")
		shell.append_display_page(self.source, group)
Example #29
0
 def send_message(window, object_path, method, **kwargs):
     bus = window.get_message_bus()
     tp = bus.lookup(object_path, method)
     if not tp.is_a(Gedit.Message.__gtype__):
         return None
     kwargs['object-path'] = object_path
     kwargs['method'] = method
     msg = GObject.new(tp, **kwargs)
     bus.send_message(msg)
     return msg
Example #30
0
	def do_activate(self):
		shell = self.object
		self.db = shell.props.db

		self.entry_type = MagnatuneEntryType()
		self.db.register_entry_type(self.entry_type)

		self.settings = Gio.Settings("org.gnome.rhythmbox.plugins.magnatune")

		theme = Gtk.IconTheme.get_default()
		rb.append_plugin_source_path(theme, "/icons")

		what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
		icon = rb.try_load_icon(theme, "magnatune", width, 0)

		group = RB.DisplayPageGroup.get_by_id ("stores")
		settings = Gio.Settings("org.gnome.rhythmbox.plugins.magnatune")
		self.source = GObject.new(MagnatuneSource,
					  shell=shell,
					  entry_type=self.entry_type,
					  pixbuf=icon,
					  plugin=self,
					  settings=settings.get_child("source"),
					  name=_("Magnatune"),
					  toolbar_path="/MagnatuneToolBar")

		shell.register_entry_type_for_source(self.source, self.entry_type)
		shell.append_display_page(self.source, group)

		manager = shell.props.ui_manager
		# Add the popup menu actions
		self.action_group = Gtk.ActionGroup(name='MagnatunePluginActions')

		action = Gtk.Action(name='MagnatuneDownloadAlbum', label=_("Download Album"),
				tooltip=_("Download this album from Magnatune"),
				stock_id='gtk-save')
		action.connect('activate', lambda a: shell.props.selected_page.download_album())
		self.action_group.add_action(action)
		action = Gtk.Action(name='MagnatuneArtistInfo', label=_("Artist Information"),
				tooltip=_("Get information about this artist"),
				stock_id='gtk-info')
		action.connect('activate', lambda a: shell.props.selected_page.display_artist_info())
		self.action_group.add_action(action)
		action = Gtk.Action(name='MagnatuneCancelDownload', label=_("Cancel Downloads"),
				tooltip=_("Stop album downloads"),
				stock_id='gtk-stop')
		action.connect('activate', lambda a: shell.props.selected_page.cancel_downloads())
		action.set_sensitive(False)
		self.action_group.add_action(action)

		manager.insert_action_group(self.action_group, 0)
		self.ui_id = manager.add_ui_from_string(popup_ui)

		self.pec_id = shell.props.shell_player.connect('playing-song-changed', self.playing_entry_changed)
		manager.ensure_update()
Example #31
0
    def test_floating_and_sunk_using_gobject_new(self):
        # Upon creation, the refcount of the object should be 2:
        # - someone already has a reference on the new object.
        # - the python wrapper should hold its own reference.
        obj = GObject.new(testhelper.FloatingAndSunk)
        self.assertEqual(obj.__grefcount__, 2)

        # We ask the library to release its reference, so the only
        # remaining ref should be our wrapper's. Once the wrapper
        # will run out of scope, the object will get finalized.
        obj.release()
        self.assertEqual(obj.__grefcount__, 1)
Example #32
0
    def __init__(self):
        '''
        Initialises the object.
        '''
        super(AltToolbarShared, self).__init__()

        # Prepare Album Art Displaying
        self.album_art_db = GObject.new(RB.ExtDB, name="album-art")

        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)
        self.icon_width = width
        self.cover_pixbuf = None
    def __init__(self):
        '''
        Initialises the object.
        '''
        super(AltToolbarShared, self).__init__()

        # Prepare Album Art Displaying
        self.album_art_db = GObject.new(RB.ExtDB, name="album-art")

        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)
        self.icon_width = width
        self.cover_pixbuf = None
Example #34
0
 def init_authenticated(self):
     GBaseSource.init_authenticated(self)
     self.playlists = []
     playlists = api.get_all_playlist_ids()
     user, instant = playlists.get('user', {}), playlists.get('instant', {})
     shell = self.props.shell 
     db = shell.props.db
     for name, id in user.items() + instant.items():
         model = RB.RhythmDBQueryModel.new_empty(db)
         pl = GObject.new (GPlaylist, shell=shell, name=name.encode('utf8'), query_model=model)
         pl.setup(id)
         shell.append_display_page(pl, self)
Example #35
0
    def test_floating_and_sunk_using_gobject_new(self):
        # Upon creation, the refcount of the object should be 2:
        # - someone already has a reference on the new object.
        # - the python wrapper should hold its own reference.
        obj = GObject.new(testhelper.FloatingAndSunk)
        self.assertEqual(obj.__grefcount__, 2)

        # We ask the library to release its reference, so the only
        # remaining ref should be our wrapper's. Once the wrapper
        # will run out of scope, the object will get finalized.
        obj.release()
        self.assertEqual(obj.__grefcount__, 1)
Example #36
0
    def do_activate(self):
        print "activating sample python plugin"

        shell = self.object
        db = shell.props.db
        model = RB.RhythmDBQueryModel.new_empty(db)
        self.source = GObject.new(PythonSource,
                                  shell=shell,
                                  name=_("Python Source"),
                                  query_model=model)
        self.source.setup()
        group = RB.DisplayPageGroup.get_by_id("library")
        shell.append_display_page(self.source, group)
 def do_activate(self):
     shell = self.object
     db = shell.props.db
     model = RB.RhythmDBQueryModel.new_empty(db)
     entry_type = VkontakteEntryType()
     db.register_entry_type(entry_type)
     what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
     icon = GdkPixbuf.Pixbuf.new_from_file_at_size(rb.find_plugin_file(self, "icon.ico"), width, height)
     source_group = RB.DisplayPageGroup.get_by_id("library")
     self.source = GObject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, query_model=model, plugin=self, pixbuf=icon, entry_type=entry_type)
     shell.append_display_page(self.source, source_group)
     shell.register_entry_type_for_source(self.source, entry_type)
     self.source.initialise()
Example #38
0
 def do_activate(self):
     shell = self.object
     db = shell.props.db
     model = RB.RhythmDBQueryModel.new_empty(db)
     iconfile = Gio.File.new_for_path(rb.find_plugin_file(self,'favicon.ico'))
     self.source = GObject.new(xiamiSource,
                               shell=shell,
                               name=_("虾米"),
                               icon=Gio.FileIcon.new(iconfile),
                               query_model=model)
     self.source.setup()
     group = RB.DisplayPageGroup.get_by_id("library")
     shell.append_display_page(self.source, group)
Example #39
0
	def do_activate(self):
		shell = self.object
		db = shell.props.db
		model = RB.RhythmDBQueryModel.new_empty(db)
		entry_type = PleerEntryType()
		db.register_entry_type(entry_type)
		what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
		# iconfile = Gio.File.new_for_path(self.plugin_info.get_data_dir()+"/icon.ico")
		iconfile = Gio.File.new_for_path(self.plugin_info.get_data_dir()+"/vk-symbolic.svg")
		source_group = RB.DisplayPageGroup.get_by_id("library")
		self.source = GObject.new(PleerSource, name=_("Pleer"), shell=shell, query_model=model, plugin=self, entry_type=entry_type, icon=Gio.FileIcon.new(iconfile))
		shell.append_display_page(self.source, source_group)
		shell.register_entry_type_for_source(self.source, entry_type)
		self.source.initialise()
Example #40
0
                def download_iterate():
                        try:
                                if len(self.__playlists) > 0:
                                        playlist = self.__playlists.popleft()
                                        print('process playlist: %s' % playlist[1])
                                        if playlist[0] == 0:
                                                download_songs(
                                                        '%s/server/xml.server.php?action=songs&auth=%s' %
                                                                (self.__settings['url'],
                                                                self.__handshake_auth),
                                                        self.__handshake_songs,
                                                        False,
                                                        self,
                                                        self.__songs_cache_filename,
                                                        playlist[1])
                                        else:
                                                # create AmpachePlaylist source
                                                playlist_source = GObject.new(
                                                        AmpachePlaylist,
                                                        is_local=False,
                                                        shell=self.__shell,
                                                        entry_type=self.__entry_type,
                                                        name=_(playlist[1])
                                                )
                                                self.__playlist_sources.append(playlist_source)

                                                # insert AmpachePlaylist source into AmpacheBrowser source
                                                self.__shell.append_display_page(playlist_source, self)

                                                download_songs(
                                                        '%s/server/xml.server.php?action=playlist_songs&filter=%d&auth=%s' % \
                                                                (self.__settings['url'],
                                                                playlist[0],
                                                                self.__handshake_auth),
                                                        playlist[2],
                                                        True,
                                                        playlist_source,
                                                        os.path.join(
                                                                self.__cache_directory,
                                                                ''.join([playlist[1], '.xml'])),
                                                        playlist[1])

                                else:
                                        print('no more playlists to process, refilter display page model')
                                        self.__shell.props.display_page_model.refilter()

                        except Exception as e:
                                print('Exception: %s' % e)
                                return
Example #41
0
File: ffs.py Project: jku/ffs
    def __init__(self, port=0, allow_uploads=False, change_callback=None):

        # This should be a call to Soup.Server.__init__(), see note in __getattr__
        self._obj = GObject.new(Soup.Server, port=port, server_header="friendly-file-server")

        self.allow_upload = allow_uploads
        self.change_callback = change_callback
        self.shared_file = None
        self.archive_state = ArchiveState.NA
        self.igd = None
        try:
            self.zipper = FriendlyZipper()
        except:
            self.zipper = None

        self.upload_count = 0
        self.upload_bytes = 0
        self.upload_dir = None

        self.local_ip = find_ip()
        self.local_ip_state = IPState.UNKNOWN

        self.add_handler(None, self.on_soup_request, None)
        print ("Server starting, guessed uri http://%s:%d" % (self.local_ip, self.get_port()))
        self.run_async()

        # Is URI really available (at least from this machine)?
        self.confirm_uri(self.local_ip, self.get_port(), False)

        self.upnp_ip = None
        self.upnp_port = None
        self.upnp_ip_state = IPState.UNAVAILABLE
        try:
            self.igd = GUPnPIgd.SimpleIgd()
            self.igd.connect("mapped-external-port", self.on_igd_mapped_port)
            # FAILED: python/GI can't cope with signals with GError
            # self.igd.connect ("error-mapping-port", self.on_igd_error)
            self.igd.add_port(
                "TCP", self.get_port(), self.local_ip, self.get_port(), 0, FFS_APP_NAME  # remote port really
            )
        except:
            self.igd = None
            self.upnp_ip_state = IPState.UNKNOWN

        try:
            name = GLib.get_real_name() + "'s " + FFS_APP_NAME
            self.zeroconf = FriendlyZeroconfService(name, self.get_port())
        except:
            self.zeroconf = None
Example #42
0
 def do_activate(self):
     shell = self.object
     db = shell.props.db
     model = RB.RhythmDBQueryModel.new_empty(db)
     what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
     self.source = GObject.new(
         ChromecastSource.ChromecastSource,
         name=_("Chromecast"),
         shell=shell,
         query_model=model,
         plugin=self
     )
     # source_group = RB.DisplayPageGroup.get_by_id("library")
     # shell.append_display_page(self.source, source_group)
     self.source.setup()
    def __init__(self):
        """
        Initialises the object.
        """
        super(AltToolbarShared, self).__init__()

        # Prepare Album Art Displaying
        self.album_art_db = GObject.new(RB.ExtDB, name="album-art")

        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)
        self.icon_width = width
        self.cover_pixbuf = None
        self._controllers = {}
        self._tooltip_exceptions = ['album_cover']
        self._moved_controls = []
Example #44
0
    def __init__(self):
        """
        Initialises the object.
        """
        super(AltToolbarShared, self).__init__()

        # Prepare Album Art Displaying
        self.album_art_db = GObject.new(RB.ExtDB, name="album-art")

        what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.SMALL_TOOLBAR)
        self.icon_width = width
        self.cover_pixbuf = None
        self._controllers = {}
        self._tooltip_exceptions = ['album_cover']
        self._moved_controls = []
	def do_activate(self):
		print("Plugin activated")
		
		shell = self.object
		db = shell.props.db
		entry_type = BeetsEntryType()
		db.register_entry_type(entry_type)
		source = GObject.new(
			BeetsSource,
			shell=shell,
			name=_("Beets Library"),
			entry_type=entry_type,
		)
		group = RB.DisplayPageGroup.get_by_id ("library")
		shell.append_display_page (source, group)
		shell.register_entry_type_for_source(source, entry_type)
Example #46
0
    def _busMessageCb(self, bus, message):
        if message.type == Gst.MessageType.EOS:
            self._prepareSamples()
            self._startRendering()
            self.stopGeneration()

        elif message.type == Gst.MessageType.ERROR:
            if self.adapter:
                self.adapter.stop()
                self.adapter = None
            # Something went wrong TODO : recover
            self.stopGeneration()
            self._num_failures += 1
            if self._num_failures < 2:
                self.warning(
                    "Issue during waveforms generation: %s"
                    " for the %ith time, trying again with no rate "
                    " modulation", message.parse_error(), self._num_failures)
                bus.disconnect_by_func(self._busMessageCb)
                self._launchPipeline()
                self.becomeControlled()
            else:
                Gst.debug_bin_to_dot_file_with_ts(
                    self.pipeline, Gst.DebugGraphDetails.ALL,
                    "error-generating-waveforms")
                self.error("Aborting due to waveforms generation issue: %s",
                           message.parse_error())

        elif message.type == Gst.MessageType.STATE_CHANGED:
            prev, new, unused_pending_state = message.parse_state_changed()
            if message.src == self.pipeline:
                if prev == Gst.State.READY and new == Gst.State.PAUSED:
                    self.pipeline.seek(
                        1.0, Gst.Format.TIME,
                        Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE,
                        Gst.SeekType.SET, 0, Gst.SeekType.NONE, -1)

                # In case we failed previously, we won't modulate next time
                elif not self.adapter and prev == Gst.State.PAUSED and \
                        new == Gst.State.PLAYING and self._num_failures == 0:
                    # This line is necessary so we can instantiate GstTranscoder's
                    # GstCpuThrottlingClock below.
                    Gst.ElementFactory.make("uritranscodebin", None)
                    clock = GObject.new(
                        GObject.type_from_name("GstCpuThrottlingClock"))
                    clock.props.cpu_usage = self.app.settings.previewers_max_cpu
                    self.pipeline.use_clock(clock)
Example #47
0
    def test_floating_and_sunk_out_of_scope_using_gobject_new(self):
        obj = GObject.new(testhelper.FloatingAndSunk)
        self.assertEqual(obj.__grefcount__, 2)

        # We are manually taking the object out of scope. This means
        # that our wrapper has been freed, and its reference dropped. We
        # cannot check it but the refcount should now be 1 (the ref held
        # by the library is still there, we didn't call release()
        obj = None

        # When we get the object back from the lib, the wrapper is
        # re-created, so our refcount will be 2 once again.
        obj = testhelper.floating_and_sunk_get_instance_list()[0]
        self.assertEqual(obj.__grefcount__, 2)

        obj.release()
        self.assertEqual(obj.__grefcount__, 1)
Example #48
0
 def do_activate(self):
     shell = self.object
     db = shell.props.db
     model = RB.RhythmDBQueryModel.new_empty(db)
     theme = Gtk.IconTheme.get_default()
     what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
     icon = rb.try_load_icon(theme, "media-playback-start", width, 0)
     self.source = GObject.new(
         GPlaySource, shell=shell, 
         name="Google Music",
         query_model=model,
         plugin=self,
         pixbuf=icon,
     )
     self.source.setup()
     group = RB.DisplayPageGroup.get_by_id ("library")
     shell.append_display_page(self.source, group)
Example #49
0
 def do_activate(self):
     shell = self.object
     db = shell.props.db
     model = RB.RhythmDBQueryModel.new_empty(db)
     theme = Gtk.IconTheme.get_default()
     what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
     icon = rb.try_load_icon(theme, "media-playback-start", width, 0)
     self.source = GObject.new(
         GPlaySource, shell=shell,
         name="Google Music",
         query_model=model,
         plugin=self,
         pixbuf=icon,
     )
     self.source.setup()
     group = RB.DisplayPageGroup.get_by_id("library")
     shell.append_display_page(self.source, group)
Example #50
0
    def test_floating_and_sunk_out_of_scope_using_gobject_new(self):
        obj = GObject.new(testhelper.FloatingAndSunk)
        self.assertEqual(obj.__grefcount__, 2)

        # We are manually taking the object out of scope. This means
        # that our wrapper has been freed, and its reference dropped. We
        # cannot check it but the refcount should now be 1 (the ref held
        # by the library is still there, we didn't call release()
        obj = None

        # When we get the object back from the lib, the wrapper is
        # re-created, so our refcount will be 2 once again.
        obj = testhelper.floating_and_sunk_get_instance_list()[0]
        self.assertEqual(obj.__grefcount__, 2)

        obj.release()
        self.assertEqual(obj.__grefcount__, 1)
Example #51
0
    def testOwnedByLibraryOutOfScopeUsingGobjectNew(self):
        obj = GObject.new(testhelper.OwnedByLibrary)
        self.assertEqual(obj.__grefcount__, 2)

        # We are manually taking the object out of scope. This means
        # that our wrapper has been freed, and its reference dropped. We
        # cannot check it but the refcount should now be 1 (the ref held
        # by the library is still there, we didn't call release()
        obj = None

        # When we get the object back from the lib, the wrapper is
        # re-created, so our refcount will be 2 once again.
        obj = testhelper.owned_by_library_get_instance_list()[0]
        self.assertEqual(obj.__grefcount__, 2)

        obj.release()
        self.assertEqual(obj.__grefcount__, 1)
Example #52
0
 def setFileBrowserRoot(self, location):
     object_path = '/plugins/filebrowser'
     method = "set_root"
     arg1 = Gio.file_new_for_path(location)
     arg2 = None
     bus = self.window.get_message_bus()
     if bus.is_registered(object_path, method):
         msgType = bus.lookup(object_path, method)
         msg = GObject.new(msgType, object_path=object_path, method=method, location=arg1, virtual=arg2)
         bus.send_message(msg)
         #bus = Gedit.MessageBus.get_default()
         #bus.send(object_path, method, location=arg1, virtual=arg2)
         side_panel = Gedit.App.get_default().get_active_window().get_side_panel()
         side_panel.set_property("visible", True)
     else:
         Gedit.App.get_default().get_active_window().get_bottom_panel().set_property("visible", True)
         self.outputPanel.activate()
         self.outputPanel.setText("File browser plugin was not enabled or not installed.")
Example #53
0
 def init_authenticated(self):
     GBaseSource.init_authenticated(self)
     self.playlists = []
     try:
         playlists = api.get_all_playlist_ids()
     except KeyError:
         playlists = {}
     user, instant = playlists.get('user', {}), playlists.get('instant', {})
     shell = self.props.shell
     db = shell.props.db
     for name, id in user.items() + instant.items():
         model = RB.RhythmDBQueryModel.new_empty(db)
         pl = GObject.new(
             GPlaylist, shell=shell, name=name.encode('utf8'),
             query_model=model,
         )
         pl.setup(id)
         shell.append_display_page(pl, self)
Example #54
0
    def do_activate(self):
        shell = self.object
        self.db = shell.props.db

        rb.append_plugin_source_path(self, "icons")

        self.entry_type = MagnatuneEntryType()
        self.db.register_entry_type(self.entry_type)

        self.settings = Gio.Settings.new(
            "org.gnome.rhythmbox.plugins.magnatune")

        app = Gio.Application.get_default()
        action = Gio.SimpleAction(name="magnatune-album-download")
        action.connect("activate", self.download_album_action_cb)
        app.add_action(action)

        action = Gio.SimpleAction(name="magnatune-artist-info")
        action.connect("activate", self.artist_info_action_cb)
        app.add_action(action)

        builder = Gtk.Builder()
        builder.add_from_file(rb.find_plugin_file(self,
                                                  "magnatune-toolbar.ui"))
        toolbar = builder.get_object("magnatune-toolbar")
        app.link_shared_menus(toolbar)

        group = RB.DisplayPageGroup.get_by_id("stores")
        settings = Gio.Settings.new("org.gnome.rhythmbox.plugins.magnatune")
        self.source = GObject.new(
            MagnatuneSource,
            shell=shell,
            entry_type=self.entry_type,
            icon=Gio.ThemedIcon.new("magnatune-symbolic"),
            plugin=self,
            settings=settings.get_child("source"),
            name=_("Magnatune"),
            toolbar_menu=toolbar)

        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_display_page(self.source, group)

        self.pec_id = shell.props.shell_player.connect(
            'playing-song-changed', self.playing_entry_changed)
Example #55
0
    def __on_equalizer_press(self, widget) -> None:

        if "equalizer" not in self._exaile.plugins.enabled_plugins:
            return None

        eq_plugin_win = self._exaile.plugins.enabled_plugins[
            "equalizer"].window
        if not eq_plugin_win:
            eq_win = GObject.new("EqualizerWindow")
            eq_win.set_transient_for(self._exaile.gui.main.window)
            self._exaile.plugins.enabled_plugins["equalizer"].window = eq_win
            self._equalizer_win = eq_win

        def _destroy(w):
            self._equalizer_win = None
            self._exaile.plugins.enabled_plugins["equalizer"].window = None

        eq_win.connect("destroy", _destroy)
        eq_win.show_all()