def item_create_callback(result, auth_token, user_data):
     assert user_data == "user data"
     if result is None:
         print "result is ok"
         mateconf.client_get_default().set_int(MATECONF_AUTH_KEY, auth_token)
     else:
         print "result:", result
     gtk.main_quit()
Example #2
0
    def prepare_single (self, prefix, user, password):
        # No good way to load specific files into Banshee's database, so point
        # the music collection to our directory and tell Banshee to watch for
        # changes.

        print ("Banshee directories", file = sys.stderr)
        self.rmdirs ("~/.config/banshee-1")
        self.mkdir ("~/.config/banshee-1/addin-db-001")
        print ("Banshee config file", file = sys.stderr)
        with open (os.path.expanduser ("~/.config/banshee-1/addin-db-001/config.xml"), "w") as conf:
            print ("<Configuration>", file = conf)
            print ("  <AddinStatus>", file = conf)
            print ("    <Addin id=\"Banshee.LibraryWatcher,1.0\" enabled=\"True\"/>", file = conf)
            print ("  </AddinStatus>", file = conf)
            print ("</Configuration>", file = conf)

        print ("Banshee MateConf", file = sys.stderr)
        client = mateconf.client_get_default ()
        client.recursive_unset ("/apps/banshee-1", 0)
        client.set_string ("/apps/banshee-1/sources/_music_library_source_-_library/library-location",
                           panflute.defs.PKG_DATA_DIR)

        print ("Banshee launch", file = sys.stderr)
        path = os.path.join (prefix, "bin/banshee-1")
        child = self.run_command ([path])
        self.set_child (child)

        print ("Banshee wait", file = sys.stderr)
        self.wait_for ("org.bansheeproject.Banshee", True)
Example #3
0
    def launch_via_command(self):
        """
        Start the player via the command stored in MateConf.  This is normally
        used as the if-all-else-fails way to launch a player.
        """

        client = mateconf.client_get_default()
        key = "/apps/panflute/daemon/{0}/launch_command".format(
            self.props.internal_name)
        command = client.get_string(key)

        self.log.debug("Running \"{0}\"".format(command))

        with open("/dev/null", "r+") as null:
            # Running under the shell means we have no idea if it worked or not,
            # since spawning the shell itself will always succeed.
            subprocess.Popen(command,
                             shell=True,
                             close_fds=True,
                             preexec_fn=os.setsid,
                             stdin=null,
                             stdout=null,
                             stderr=null)

        # No way to tell if the command was successful because of the subshell
        return True
Example #4
0
 def __init__(self):
     totem.Plugin.__init__(self)
     self.debug = True
     self.gstreamer_plugins_present = True
     self.totem = None
     self.mateconf = mateconf.client_get_default()
     self.init_settings()
Example #5
0
    def __init__(self):
        # load our glade ui file in
        self.gladefile = '/usr/lib/linuxmint/mintDesktop/mintDesktop.glade'
        self.wTree = gtk.glade.XML(self.gladefile, "main_window")
        self.get_widget("main_window").connect("destroy", gtk.main_quit)

        # say hi to gconf
        client = mateconf.client_get_default()
        client.add_dir("/apps/caja/desktop", mateconf.CLIENT_PRELOAD_NONE)
        client.add_dir("/apps/marco/general", mateconf.CLIENT_PRELOAD_NONE)
        client.add_dir("/desktop/mate/interface", mateconf.CLIENT_PRELOAD_NONE)
        client.add_dir("/apps/caja/preferences", mateconf.CLIENT_PRELOAD_NONE)
               
        side_gnome_desktop_options = SidePage(0, _("Desktop"), "user-desktop")
        side_gnome_windows = SidePage(1, _("Windows"), "preferences-system-windows")
        side_gnome_interface = SidePage(2, _("Interface"), "preferences-desktop")
        side_terminal = SidePage(3, _("Terminal"), "terminal")
        
        # Define which side-options apply to which desktop
        self.sidePages = [side_terminal]
        
        try:
            desktop = os.environ["DESKTOP_SESSION"].lower()
            if desktop in ["cinnamon", "gnome", "gnome-shell", "kde", "lxde", "xfce", "fluxbox"]:
                print desktop
                self.sidePages = [side_terminal]
            else:
                self.sidePages = [side_gnome_desktop_options, side_gnome_windows, side_gnome_interface, side_terminal]            
        except Exception, detail:
            print "Error: %s " % detail
Example #6
0
 def __init__(self):
     """
     *Do not* use the constructor directly. Always use L{get_instance}
     """
     super(GconfStore, self).__init__()
     self._client = mateconf.client_get_default()
     self.__connect_notifications()
Example #7
0
 def __init__(self):
     idol.Plugin.__init__(self)
     self.debug = True
     self.gstreamer_plugins_present = True
     self.idol = None
     self.mateconf = mateconf.client_get_default()
     self.init_settings()
Example #8
0
def moc_command(arg_string):
    """
    Return a command line for invoking MOC.
    """

    client = mateconf.client_get_default()
    base_command = client.get_string("/apps/panflute/daemon/moc/command")
    return "{0} {1}".format(base_command, arg_string)
Example #9
0
def moc_command (arg_string):
    """
    Return a command line for invoking MOC.
    """

    client = mateconf.client_get_default ()
    base_command = client.get_string ("/apps/panflute/daemon/moc/command")
    return "{0} {1}".format (base_command, arg_string)
Example #10
0
    def __init__(self, applet):
        self.__root = applet.get_preferences_key()

        if self.__root == None:
            self.log.warn("applet.get_preferences_key did return None")
            self.__root = "/apps/panflute-applet"

        self.__client = mateconf.client_get_default()
        self.log.info("MateConf root is {0}".format(self.__root))
Example #11
0
    def __init__ (self, applet):
        self.__root = applet.get_preferences_key ()

        if self.__root == None:
               self.log.warn ("applet.get_preferences_key did return None")
               self.__root = "/apps/panflute-applet"

        self.__client = mateconf.client_get_default ()
        self.log.info ("MateConf root is {0}".format (self.__root))
Example #12
0
	def __init__( self, gconfDir = None, client = None ):

		if not client:
			client = mateconf.client_get_default()
		
		self.client = client
		self.gconfDir = gconfDir

		self.client.add_dir( self.gconfDir[:-1], mateconf.CLIENT_PRELOAD_NONE )

		self.handlerIds = [ ]
Example #13
0
    def preferred_player_changed_cb (self, preferred):
        """
        Update the daemon's MateConf setting with the newly selected preferred
        player.
        """

        model = preferred.get_model ()
        iter = preferred.get_active_iter ()

        client = mateconf.client_get_default ()
        client.set_string ("/apps/panflute/daemon/preferred_player", model[iter][self.CONN_COL_INTERNAL_NAME])
Example #14
0
    def preferred_player_changed_cb(self, preferred):
        """
        Update the daemon's MateConf setting with the newly selected preferred
        player.
        """

        model = preferred.get_model()
        iter = preferred.get_active_iter()

        client = mateconf.client_get_default()
        client.set_string("/apps/panflute/daemon/preferred_player",
                          model[iter][self.CONN_COL_INTERNAL_NAME])
Example #15
0
	def enable_debugging(self, action, totem_object):
		msg = _("After you press OK, Totem will wait until you connect to it with winpdb or rpdb2. If you have not set a debugger password in MateConf, it will use the default password ('totem').")
		dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK_CANCEL, msg)
		if dialog.run() == gtk.RESPONSE_OK:
			mateconfclient = mateconf.client_get_default()
			password = mateconfclient.get_string('/apps/totem/plugins/pythonconsole/rpdb2_password') or "totem"
			def start_debugger(password):
				rpdb2.start_embedded_debugger(password)
				return False

			gobject.idle_add(start_debugger, password)
		dialog.destroy()
Example #16
0
    def metadata_default_clicked_cb (self, button):
        """
        Restore the metadata buffer to its default value.
        """

        client = mateconf.client_get_default ()
        schema = client.get_schema ("/schemas/apps/panflute/applet/prefs/metadata_lines")
        default = schema.get_default_value ()
        strings = [v.get_string () for v in default.get_list ()]

        buffer = self.__builder.get_object ("metadata_buffer")
        buffer.set_text ("\n".join (strings))
Example #17
0
    def metadata_default_clicked_cb(self, button):
        """
        Restore the metadata buffer to its default value.
        """

        client = mateconf.client_get_default()
        schema = client.get_schema(
            "/schemas/apps/panflute/applet/prefs/metadata_lines")
        default = schema.get_default_value()
        strings = [v.get_string() for v in default.get_list()]

        buffer = self.__builder.get_object("metadata_buffer")
        buffer.set_text("\n".join(strings))
Example #18
0
    def prepare_single(self, prefix, user, password):
        self.rmdirs("~/.local/share/rhythmbox")
        client = mateconf.client_get_default()
        client.recursive_unset("/apps/rhythmbox", 0)

        path = os.path.join(prefix, "bin/rhythmbox")
        child = self.run_command([path])
        self.set_child(child)

        self.wait_for("org.gnome.Rhythmbox", True)
        proxy = self.bus.get_object("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell")
        self.__shell = dbus.Interface(proxy, "org.gnome.Rhythmbox.Shell")

        for uri in self.TONE_URIS:
            self.__shell.loadURI(uri, 0)
Example #19
0
 def start_browser():
     if sys.platform == 'darwin':
         # use Mac OS X internet config module (removed in Python 3.0)
         import ic
         ic.launchurl(url)
     else:
         try:
             import mateconf
             client = mateconf.client_get_default()
             browser = client.get_string(
                 '/desktop/mate/url-handlers/http/command') + '&'
             os.system(browser % url)
         except ImportError:
             # If mateconf is not found, fall back to old standard
             os.system('firefox ' + url)
Example #20
0
    def prepare_single (self, prefix, user, password):
        self.rmdirs ("~/.local/share/rhythmbox")
        client = mateconf.client_get_default ()
        client.recursive_unset ("/apps/rhythmbox", 0)

        path = os.path.join (prefix, "bin/rhythmbox")
        child = self.run_command ([path])
        self.set_child (child)

        self.wait_for ("org.gnome.Rhythmbox", True)
        proxy = self.bus.get_object ("org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell")
        self.__shell = dbus.Interface (proxy, "org.gnome.Rhythmbox.Shell")

        for uri in self.TONE_URIS:
            self.__shell.loadURI (uri, 0)
Example #21
0
        def start_browser():
            if sys.platform == "darwin":
                # use Mac OS X internet config module (removed in Python 3.0)
                import ic

                ic.launchurl(url)
            else:
                try:
                    import mateconf

                    client = mateconf.client_get_default()
                    browser = client.get_string("/desktop/mate/url-handlers/http/command") + "&"
                    os.system(browser % url)
                except ImportError:
                    # If mateconf is not found, fall back to old standard
                    os.system("firefox " + url)
Example #22
0
    def prepare_single(self, prefix, user, password):
        self.rmdirs("~/.mate2/muine")

        client = mateconf.client_get_default()
        client.recursive_unset("/apps/muine", 0)

        path = os.path.join(prefix, "bin/muine")
        child = self.run_command([path])
        self.set_child(child)

        self.wait_for("org.gnome.Muine", True)
        proxy = self.bus.get_object("org.gnome.Muine", "/org/gnome/Muine/Player")
        self.__muine = dbus.Interface(proxy, "org.gnome.Muine.Player")

        for path in self.TONE_PATHS:
            self.__muine.QueueFile(path)
Example #23
0
    def __init__( self, mintMenuWin, toggleButton, de ):

        self.Win = mintMenuWin
        self.toggleButton = toggleButton
        self.de = de

        #The Glade file for the plugin
        self.gladefile = os.path.join( os.path.dirname( __file__ ), "recent.glade" )

        #Read GLADE file
        self.wTree = gtk.glade.XML( self.gladefile, "window1" )

        #Set 'window' property for the plugin (Must be the root widget)
        self.window = self.wTree.get_widget( "window1" )

        #Set 'heading' property for plugin
        self.heading = _("Recent documents")

        #This should be the first item added to the window in glade
        self.content_holder = self.wTree.get_widget( "eventbox1" )

        #Specify plugin width
        self.width = 250

        #Plugin icon
        self.icon = 'mate-folder.png'

        self.gconf_dir = '/apps/mintMenu/plugins/recent'
        self.client = mateconf.client_get_default()
        self.client.add_dir( '/apps/mintMenu/plugins/recent', mateconf.CLIENT_PRELOAD_NONE )
        self.client.notify_add( '/apps/mintMenu/plugins/recent/height', self.RegenPlugin )
        self.client.notify_add( '/apps/mintMenu/plugins/recent/width', self.RegenPlugin )
        self.client.notify_add( '/apps/mintMenu/plugins/recent/num_recent_docs_to_show', self.RegenPlugin )
        self.client.notify_add( '/apps/mintMenu/plugins/recent/recent_font_size', self.RegenPlugin )

        self.FileList=[]
        self.RecManagerInstance = gtk.recent_manager_get_default()
        self.RecManagerInstance.connect("changed",self.DoRecent)


        self.RegenPlugin()
        self.wTree.get_widget( "RecentTabs" ).set_current_page(1)

        #Connect event handlers
        dic = { "on_ClrBtn_clicked" : self.clrmenu}
        self.wTree.signal_autoconnect( dic )
Example #24
0
    def prepare_single(self, prefix, user, password):
        self.rmdirs("~/.mate2/muine")

        client = mateconf.client_get_default()
        client.recursive_unset("/apps/muine", 0)

        path = os.path.join(prefix, "bin/muine")
        child = self.run_command([path])
        self.set_child(child)

        self.wait_for("org.gnome.Muine", True)
        proxy = self.bus.get_object("org.gnome.Muine",
                                    "/org/gnome/Muine/Player")
        self.__muine = dbus.Interface(proxy, "org.gnome.Muine.Player")

        for path in self.TONE_PATHS:
            self.__muine.QueueFile(path)
Example #25
0
    def enable_debugging(self, action, totem_object):
        msg = _(
            "After you press OK, Totem will wait until you connect to it with winpdb or rpdb2. If you have not set a debugger password in MateConf, it will use the default password ('totem')."
        )
        dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO,
                                   gtk.BUTTONS_OK_CANCEL, msg)
        if dialog.run() == gtk.RESPONSE_OK:
            mateconfclient = mateconf.client_get_default()
            password = mateconfclient.get_string(
                '/apps/totem/plugins/pythonconsole/rpdb2_password') or "totem"

            def start_debugger(password):
                rpdb2.start_embedded_debugger(password)
                return False

            gobject.idle_add(start_debugger, password)
        dialog.destroy()
Example #26
0
	def __init__(self, applet):
		self.applet = applet
		self.applet.set_tooltip_text("Tilo")
		mateconf_app_key = '/apps/tilo'
		self.dokey = '/apps/mate-do/Docky/Utilities/DockPreferences'
		self.mateconf_client = mateconf.client_get_default()
		#print self.applet.get_size()
		#print self.applet.get_position()
		self.orient = self.mateconf_client.get_string(mateconf_app_key + '/Orientation')
		if self.orient == 'Top':
			self.mateconf_client.set_string(mateconf_app_key + '/orientation', 'top')
		else:
			self.mateconf_client.set_string(mateconf_app_key + '/orientation', 'bottom')
		proc = os.popen("""ps axo "%p,%a" | grep "Tilo.py" | grep -v grep|cut -d',' -f1""").read()
		procs = proc.split('\n')
		if len(procs) > 2:
			import wnck
			try:
				wnck.set_client_type(wnck.CLIENT_TYPE_PAGER)
			except AttributeError:
				print "Error: Failed to set libwnck client type, window " \
						"activation may not work"
			screen = wnck.screen_get_default()
			while gtk.events_pending():
				gtk.main_iteration()
			wins = screen.get_windows_stacked()
			
			for win in wins:
				name = win.get_name()
				if name == 'GnoMeny.py':
		
					if win and win.is_hidden():
						sys.exit(1)
					elif win and win.is_minimized():
						win.unminimize(1)
					elif win and win.is_active() == False:
						win.activate(1)
		#Get the default icon theme
		import Globals as Globals
		self.Globals = Globals
		#self.theme.connect('changed', self.icon_theme_changed)
		from Menu_Main import Main_Menu
		self.hwg = Main_Menu(self.HideMenu)
		#print self.hwg.window.window.is_visible()
		self.ShowMenu()
Example #27
0
def main():
    # Get the default client
    client = mateconf.client_get_default()

    # Tell MateConfClient that we're interested in the given directory.
    # This means MateConfClient will receive notification of changes
    # to this directory, and cache keys under this directory.
    # So _don't_ add "/" or something silly like that or you'll end
    # up with a copy of the whole MateConf database. ;-)
    #
    # We use PRELOAD_NONE to avoid loading all config keys on
    # startup. If your app pretty much reads all config keys
    # on startup, then preloading the cache may make sense.

    client.add_dir("/apps/basic-mateconf-app", mateconf.CLIENT_PRELOAD_NONE)

    main_window = create_main_window(client)
    main_window.show_all()

    gtk.main()
Example #28
0
    def prepare_single (self, prefix, user, password):
        # The daemon sets up a watch on the fifo in ~/.moc, and deleting the
        # directory screws that up, so just nuke the configs.

        self.mkdir ("~/.moc")
        self.rmfile ("~/.moc/playlist.m3u")
        self.rmfile ("~/.moc/pid")

        # Since the daemon will be invoking the MOC program, tell it where
        # the version of MOC being tested.

        self.__path = os.path.join (prefix, "bin/mocp")

        client = mateconf.client_get_default ()
        client.set_string ("/apps/panflute/daemon/moc/command", self.__path)

        child = self.run_command ([self.__path, "--server"])
        self.set_child (child)

        other_child = self.run_command ([self.__path, "--append"] + self.TONE_PATHS)
        other_child.wait ()
def main ():
  # Get the default client
  client = mateconf.client_get_default ();

  # Tell MateConfClient that we're interested in the given directory.
  # This means MateConfClient will receive notification of changes
  # to this directory, and cache keys under this directory.
  # So _don't_ add "/" or something silly like that or you'll end
  # up with a copy of the whole MateConf database. ;-)
  #
  # We use PRELOAD_NONE to avoid loading all config keys on
  # startup. If your app pretty much reads all config keys
  # on startup, then preloading the cache may make sense.
   
  client.add_dir ("/apps/basic-mateconf-app",
                  mateconf.CLIENT_PRELOAD_NONE)

  main_window = create_main_window (client)
  main_window.show_all ()

  gtk.main ()
 def __init__(self, applet, schema_path, standalone_key):
     object.__init__(self)
     self._connection_ids = []
     
     self._client = mateconf.client_get_default()
     
     # Get preferences key path for the given applet instance.
     self._base_path = applet.get_preferences_key()
     if self._base_path is not None:
         # Apply the schema to the applet instance preferences key.
         applet.add_preferences(schema_path)
     else:
         # NOTE: Don't need to apply schema here because the Timer Applet schema file
         # already specifies that the schema be automatically applied to the standalone key.
         
         self._base_path = standalone_key
         
         # Applet would usually do this for us, but since we're running in standalone mode,
         # we have to do this ourselves in order to receive MateConf change notifications.
         self._client.add_dir(self._base_path, mateconf.CLIENT_PRELOAD_RECURSIVE) 
         
     print 'Base prefs path = %s' % self._base_path
Example #31
0
    def prepare_single(self, prefix, user, password):
        # The daemon sets up a watch on the fifo in ~/.moc, and deleting the
        # directory screws that up, so just nuke the configs.

        self.mkdir("~/.moc")
        self.rmfile("~/.moc/playlist.m3u")
        self.rmfile("~/.moc/pid")

        # Since the daemon will be invoking the MOC program, tell it where
        # the version of MOC being tested.

        self.__path = os.path.join(prefix, "bin/mocp")

        client = mateconf.client_get_default()
        client.set_string("/apps/panflute/daemon/moc/command", self.__path)

        child = self.run_command([self.__path, "--server"])
        self.set_child(child)

        other_child = self.run_command([self.__path, "--append"] +
                                       self.TONE_PATHS)
        other_child.wait()
Example #32
0
    def __init__(self, applet, schema_path, standalone_key):
        object.__init__(self)
        self._connection_ids = []

        self._client = mateconf.client_get_default()

        # Get preferences key path for the given applet instance.
        self._base_path = applet.get_preferences_key()
        if self._base_path is not None:
            # Apply the schema to the applet instance preferences key.
            applet.add_preferences(schema_path)
        else:
            # NOTE: Don't need to apply schema here because the Timer Applet schema file
            # already specifies that the schema be automatically applied to the standalone key.

            self._base_path = standalone_key

            # Applet would usually do this for us, but since we're running in standalone mode,
            # we have to do this ourselves in order to receive MateConf change notifications.
            self._client.add_dir(self._base_path,
                                 mateconf.CLIENT_PRELOAD_RECURSIVE)

        print 'Base prefs path = %s' % self._base_path
def get_login_password():
    keyring = matekeyring.get_default_keyring_sync()
    auth_token = mateconf.client_get_default().get_int(MATECONF_AUTH_KEY)
    if auth_token > 0:
        def item_get_info_cb(result, item, data):
            if result is None:
                secret = item.get_secret()
                data.append(secret)
            else:
                print "get_item_info result:", result
            gtk.main_quit()
        data = []
        matekeyring.item_get_info(keyring, auth_token, item_get_info_cb, data)
        gtk.main()
        try:
            secret, = data
        except ValueError:
            login = None
            password = None
            auth_token = 0
        else:
            login, password = secret.split('\n')
    else:
        login = None
        password = None
    
    dialog = gtk.Dialog("Enter login", None, 0,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                         gtk.STOCK_OK, gtk.RESPONSE_OK))
    dialog.props.has_separator = False
    dialog.set_default_response(gtk.RESPONSE_OK)

    hbox = gtk.HBox(False, 8)
    hbox.set_border_width(8)
    dialog.vbox.pack_start(hbox, False, False, 0)

    stock = gtk.image_new_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION,
                                     gtk.ICON_SIZE_DIALOG)
    hbox.pack_start(stock, False, False, 0)

    table = gtk.Table(2, 2)
    table.set_row_spacings(4)
    table.set_col_spacings(4)
    hbox.pack_start(table, True, True, 0)

    label = gtk.Label("_Login")
    label.set_use_underline(True)
    table.attach(label, 0, 1, 0, 1)
    local_entry1 = gtk.Entry()
    local_entry1.set_activates_default(True)
    if login is not None:
        local_entry1.set_text(login)
    table.attach(local_entry1, 1, 2, 0, 1)
    label.set_mnemonic_widget(local_entry1)

    label = gtk.Label("_Password")
    label.set_use_underline(True)
    table.attach(label, 0, 1, 1, 2)
    local_entry2 = gtk.Entry()
    local_entry2.set_visibility(False)
    local_entry2.set_activates_default(True)
    if password is not None:
        local_entry2.set_text(password)
    table.attach(local_entry2, 1, 2, 1, 2)
    label.set_mnemonic_widget(local_entry2)

    dialog.show_all()
    while 1:
        response = dialog.run()

        if response == gtk.RESPONSE_OK:
            login = local_entry1.get_text()
            password = local_entry2.get_text()
            if not login or not password:
                continue
            def item_create_callback(result, auth_token, user_data):
                assert user_data == "user data"
                if result is None:
                    print "result is ok"
                    mateconf.client_get_default().set_int(MATECONF_AUTH_KEY, auth_token)
                else:
                    print "result:", result
                gtk.main_quit()
            auth_token = matekeyring.item_create(
                keyring,
                matekeyring.ITEM_GENERIC_SECRET,
                "MatePythonDesktop keyring example, login information",
                dict(appname="MatePythonDesktop, sync keyring example"),
                "\n".join((login, password)), True,
                item_create_callback, "user data")
            gtk.main()
            return login, password
        else:
            raise SystemExit
 def __init__(self):
     """Caja crashes if a plugin doesn't implement the __init__ method"""
     self.mateconf_client = mateconf.client_get_default()
Example #35
0
 def __init__(self):
     totem.Plugin.__init__(self)
     self.dialog = None
     self.mateconf_client = mateconf.client_get_default()
     self.MATECONF_BASE_DIR = "/apps/totem/plugins/opensubtitles/"
     self.MATECONF_LANGUAGE = "language"
Example #36
0
 def __init__(self):
     """Caja crashes if a plugin doesn't implement the __init__ method"""
     self.mateconf_client = mateconf.client_get_default()
     self.mateconf_client.add_dir("/apps/caja-pyextensions",
                                  mateconf.CLIENT_PRELOAD_NONE)
Example #37
0
 def __init__ (self, appname, allowed={}):
     self._domain = '/apps/%s/' % appname
     self._allowed = allowed
     self._mateconf_client = mateconf.client_get_default ()
Example #38
0
 def set_string(self, key, value):
     client = mateconf.client_get_default()
     client.set_string(key, value)
 def __init__(self):
     """Caja crashes if a plugin doesn't implement the __init__ method"""
     self.mateconf_client = mateconf.client_get_default()
     self.mateconf_client.add_dir("/apps/caja-pyextensions", mateconf.CLIENT_PRELOAD_NONE)
Example #40
0
 def __init__(self, store):
     """Instantiate the Glade Widgets Wrapper, create the view, initialize the statusbar"""
     # add the needed icons to the gtk stock
     factory = gtk.IconFactory()
     for filename, stock_name in cons.ICONS_FILENAMES:
         pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
         iconset = gtk.IconSet(pixbuf)
         factory.add(stock_name, iconset)
     factory.add_default()
     # instantiate the Glade Widgets Wrapper
     self.glade = GladeWidgetsWrapper(cons.GLADE_PATH + 'caja-pyextensions.glade', self)
     # ui manager
     actions = gtk.ActionGroup("Actions")
     actions.add_actions(cons.get_entries(self))
     self.ui = gtk.UIManager()
     self.ui.insert_action_group(actions, 0)
     self.glade.window.add_accel_group(self.ui.get_accel_group())
     self.ui.add_ui_from_string(cons.UI_INFO)
     # menubar add
     self.glade.vbox_main.pack_start(self.ui.get_widget("/MenuBar"), False, False)
     self.glade.vbox_main.reorder_child(self.ui.get_widget("/MenuBar"), 0)
     # toolbar add
     self.glade.vbox_main.pack_start(self.ui.get_widget("/ToolBar"), False, False)
     self.glade.vbox_main.reorder_child(self.ui.get_widget("/ToolBar"), 1)
     self.ui.get_widget("/ToolBar").set_style(gtk.TOOLBAR_ICONS)
     # create a variable pointing to the instance of the InfoModel class
     self.store = store
     # create the view
     self.view = gtk.TreeView(store.get_model())
     self.renderer_checkbox = gtk.CellRendererToggle()
     self.renderer_checkbox.set_property('activatable', True)
     self.renderer_checkbox.connect('toggled', self.toggle_active, store.get_model())
     self.renderer_pixbuf = gtk.CellRendererPixbuf()
     self.renderer_text = gtk.CellRendererText()
     self.columns = [None]*3
     self.columns[0] = gtk.TreeViewColumn(_("Active"), self.renderer_checkbox, active=0) # active=0 <> read from column 0 of model
     self.columns[1] = gtk.TreeViewColumn(_("Icon"), self.renderer_pixbuf)
     self.columns[1].set_cell_data_func(self.renderer_pixbuf, self.make_pixbuf)
     self.columns[2] = gtk.TreeViewColumn(_("PyExtension"), self.renderer_text, text=2) # text=2 <> read from column 2 of model
     for n in range(3):
         self.view.append_column(self.columns[n])
     self.viewselection = self.view.get_selection()
     self.glade.scrolledwindow.add(self.view)
     # initialize the statusbar
     self.statusbar_context_id = self.glade.statusbar.get_context_id('')
     self.glade.statusbar.push(self.statusbar_context_id, _("Version %s") % cons.VERSION)
     self.glade.aboutdialog.set_version(cons.VERSION)
     # retrieve the mateconf settings, set them if this is the first run
     self.mateconf_client = mateconf.client_get_default()
     self.mateconf_client.add_dir("/apps/caja-pyextensions", mateconf.CLIENT_PRELOAD_NONE)
     if self.mateconf_client.get_string("/apps/caja-pyextensions/picking_dir") == None:
         self.mateconf_client.set_string("/apps/caja-pyextensions/picking_dir", os.path.expanduser('~'))
     self.win_size_n_pos = {}
     # window restore size
     self.win_size_n_pos['win_size'] = [self.mateconf_client.get_int("/apps/caja-pyextensions/win_size_w"),
                                        self.mateconf_client.get_int("/apps/caja-pyextensions/win_size_h")]
     if 0 not in self.win_size_n_pos['win_size']:
         self.glade.window.resize(self.win_size_n_pos['win_size'][0], self.win_size_n_pos['win_size'][1])
     # have the window and all child widgets visible
     self.glade.window.show_all()
     # window restore position
     self.win_size_n_pos['win_position'] = [self.mateconf_client.get_int("/apps/caja-pyextensions/win_position_x"),
                                            self.mateconf_client.get_int("/apps/caja-pyextensions/win_position_y")]
     self.glade.window.move(self.win_size_n_pos['win_position'][0], self.win_size_n_pos['win_position'][1])
Example #41
0
 def get_bool(self, key):
     client = mateconf.client_get_default()
     return client.get_bool(key)
 def __init__(self):
     idol.Plugin.__init__(self)
     self.dialog = None
     self.mateconf_client = mateconf.client_get_default()
     self.MATECONF_BASE_DIR = "/apps/idol/plugins/opensubtitles/"
     self.MATECONF_LANGUAGE = "language"
Example #43
0
 def get_string(self, key):
     client = mateconf.client_get_default()
     return client.get_string(key)
Example #44
0
    ART_DATA_DIR = SHARED_DATA_DIR

USER_INVEST_DIR = expanduser("~/.config/mate/invest-applet")
if not exists(USER_INVEST_DIR):
    try:
        os.makedirs(USER_INVEST_DIR, 0744)
    except Exception, msg:
        error('Could not create user dir (%s): %s' % (USER_INVEST_DIR, msg))
# ------------------------------------------------------------------------------

# Set the cwd to the home directory so spawned processes behave correctly
# when presenting save/open dialogs
os.chdir(expanduser("~"))

#Gconf client
MATECONF_CLIENT = mateconf.client_get_default()

# MateConf directory for invest in window mode and shared settings
MATECONF_DIR = "/apps/invest"

# MateConf key for list of enabled handlers, when uninstalled, use a debug key to not conflict
# with development version
#MATECONF_ENABLED_HANDLERS = MATECONF_DIR + "/enabled_handlers"

# Preload mateconf directories
#MATECONF_CLIENT.add_dir(MATECONF_DIR, mateconf.CLIENT_PRELOAD_RECURSIVE)


# tests whether the given stocks are in the old labelless format
def labelless_stock_format(stocks):
    if len(stocks) == 0:
Example #45
0
class Conf:
    """
    Helper object for managing the applet's preferences.

    The "client" object is a convenience instance of a MateConf client, which
    plugin writers will use directly most of the time.  The Conf object
    itself is primarily useful in mapping keys into where they're actually
    stored in MateConf, since each instance of the applet has its preferences
    stored in a different location.
    
    There are also methods that bind a MateConf entry to some other object, so
    that changes in one automatically cause a change in the other.
    """

    # For convenience
    client = mateconf.client_get_default()

    def __init__(self, applet):
        self.__applet = applet
        print "DEBUG: MateConf root is %s" % applet.get_preferences_key()

    def bind_boolean(self, full_key, object, property):
        """
        Bind a MateConf boolean value to a GObject's property.
        """
        def mateconf_cb(client, id, entry, unused):
            if entry.value is not None and entry.value.get_bool(
            ) != object.get_property(property):
                object.set_property(property, entry.value.get_bool())

        def object_cb(object, pspec):
            if object.get_property(property) != self.client.get_bool(full_key):
                self.client.set_bool(full_key, object.get_property(property))

        def destroy_cb(object, id):
            self.client.notify_remove(id)

        object.set_property(property, self.client.get_bool(full_key))
        id = self.client.notify_add(full_key, mateconf_cb)
        object.connect("notify::%s" % property, object_cb)
        object.connect("destroy", destroy_cb, id)

    def bind_int(self, full_key, object, property):
        """
        Bind a MateConf int value to a GObject's property.
        """
        def mateconf_cb(client, id, entry, unused):
            if entry.value is not None and entry.value.get_int(
            ) != object.get_property(property):
                object.set_property(property, entry.value.get_int())

        def object_cb(object, pspec):
            if object.get_property(property) != self.client.get_int(full_key):
                self.client.set_int(full_key,
                                    int(object.get_property(property)))

        def destroy_cb(object, id):
            self.client.notify_remove(id)

        object.set_property(property, self.client.get_int(full_key))
        id = self.client.notify_add(full_key, mateconf_cb)
        object.connect("notify::%s" % property, object_cb)
        object.connect("destroy", destroy_cb, id)

    def bind_string(self, full_key, object, property):
        """
        Bind a MateConf string value to a GObject's property.
        """
        def mateconf_cb(client, id, entry, unused):
            if entry.value is not None and entry.value.get_string(
            ) != object.get_property(property):
                object.set_property(property, entry.value.get_string())

        def object_cb(object, pspec):
            if object.get_property(property) != self.client.get_string(
                    full_key):
                self.client.set_string(full_key, object.get_property(property))

        def destroy_cb(object, id):
            self.client.notify_remove(id)

        object.set_property(property, self.client.get_string(full_key))
        id = self.client.notify_add(full_key, mateconf_cb)
        object.connect("notify::%s" % property, object_cb)
        object.connect("destroy", destroy_cb, id)

    def bind_string_boolean(self, full_key, value, object, property):
        """
        Bind a MateConf string value to a GObject's boolean property, by
        setting the property to true iff the string matches a particular
        value, and vice versa.
        """
        def mateconf_cb(client, id, entry, unused):
            if entry.value is not None:
                bval = (entry.value.get_string() == value)
                if bval != object.get_property(property):
                    object.set_property(property, bval)

        def object_cb(object, pspec):
            if object.get_property(
                    property) and self.client.get_string(full_key) != value:
                self.client.set_string(full_key, value)

        def destroy_cb(object, id):
            self.client.notify_remove(id)

        object.set_property(property,
                            self.client.get_string(full_key) == value)
        id = self.client.notify_add(full_key, mateconf_cb)
        object.connect("notify::%s" % property, object_cb)
        object.connect("destroy", destroy_cb, id)

    def bind_combo_string(self, full_key, combo, column):
        """
        Bind a MateConf string value to a ComboBox column.
        """
        def mateconf_cb(client, id, entry, unused):
            if entry.value is not None:
                iter = musicapplet.util.search_model(combo.get_model(), column,
                                                     entry.value.get_string())
                if iter is not None and iter != combo.get_active_iter():
                    combo.set_active_iter(iter)

        def combo_cb(combo):
            model = combo.get_model()
            value = model.get_value(combo.get_active_iter(), column)
            if value != self.client.get_string(full_key):
                self.client.set_string(full_key, value)

        def destroy_cb(combo, id):
            self.client.notify_remove(id)

        iter = musicapplet.util.search_model(combo.get_model(), column,
                                             self.client.get_string(full_key))
        if iter is not None:
            combo.set_active_iter(iter)
        id = self.client.notify_add(full_key, mateconf_cb)
        combo.connect("changed", combo_cb)
        combo.connect("destroy", destroy_cb, id)

    def resolve_key(self, key):
        """
        Resolve the full name of a key for general applet preferences.
        """

        return "%s/%s" % (self.__applet.get_preferences_key(), key)

    def resolve_plugin_key(self, plugin, key):
        """
        Resolve the full name of a key for a particular plugin.

        This function will try the preferred key style "Player-Name/key",
        falling back on the legacy, deprecated style "player-name_key".
        Ultimately, the schema determines which will be used.
        """

        escaped = plugin.internal_name.replace(" ", "-")
        legacy_key = self.resolve_key("%s_%s" % (escaped.lower(), key))
        if self.client.get(legacy_key) is not None:
            return legacy_key
        else:
            return self.resolve_key("%s/%s" % (escaped, key))
Example #46
0
 def set_bool(self, key, value):
     client = mateconf.client_get_default()
     client.set_bool(key, value.get_active())
Example #47
0
 def add_notify(self, key, widget):
     client = mateconf.client_get_default()
     notify_id = client.notify_add(key, self.key_changed_callback, widget)
     widget.set_data('notify_id', notify_id)
     widget.set_data('client', client)
     widget.connect("destroy", self.destroy_callback)
Example #48
0
        try:
            import panflute.daemon.xmms as xmms
            self.__register_connector (xmms.Connector ())
        except Exception, e:
            self.log.info ("Failed to load XMMS connector: {0}".format (e))

        try:
            import panflute.daemon.xmms2 as xmms2
            self.__register_connector (xmms2.Connector ())
        except Exception, e:
            self.log.info ("Failed to load XMMS2 connector: {0}".format (e))

        self.__manager_proxy = panflute.daemon.connproxy.ManagerProxy (self, bus_name = self.__panflute_bus_name)

        client = mateconf.client_get_default ()
        client.add_dir ("/apps/panflute/daemon", mateconf.CLIENT_PRELOAD_NONE)
        client.notify_add ("/apps/panflute/daemon/preferred_player", self.__preferred_player_changed_cb)
        self.__expose_preferred (client.get_string ("/apps/panflute/daemon/preferred_player"))

        self.__live = None
        self.__root = None
        self.__track_list = None
        self.__player = None

        self.__scan_for_connected ()


    def __register_connector (self, conn):
        """
        Add a connector to the list of connectors being used.
Example #49
0
 def __init__(self, store):
     """Instantiate the Glade Widgets Wrapper, create the view, initialize the statusbar"""
     # add the needed icons to the gtk stock
     factory = gtk.IconFactory()
     for filename, stock_name in cons.ICONS_FILENAMES:
         pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
         iconset = gtk.IconSet(pixbuf)
         factory.add(stock_name, iconset)
     factory.add_default()
     # instantiate the Glade Widgets Wrapper
     self.glade = GladeWidgetsWrapper(
         cons.GLADE_PATH + 'caja-pyextensions.glade', self)
     # ui manager
     actions = gtk.ActionGroup("Actions")
     actions.add_actions(cons.get_entries(self))
     self.ui = gtk.UIManager()
     self.ui.insert_action_group(actions, 0)
     self.glade.window.add_accel_group(self.ui.get_accel_group())
     self.ui.add_ui_from_string(cons.UI_INFO)
     # menubar add
     self.glade.vbox_main.pack_start(self.ui.get_widget("/MenuBar"), False,
                                     False)
     self.glade.vbox_main.reorder_child(self.ui.get_widget("/MenuBar"), 0)
     # toolbar add
     self.glade.vbox_main.pack_start(self.ui.get_widget("/ToolBar"), False,
                                     False)
     self.glade.vbox_main.reorder_child(self.ui.get_widget("/ToolBar"), 1)
     self.ui.get_widget("/ToolBar").set_style(gtk.TOOLBAR_ICONS)
     # create a variable pointing to the instance of the InfoModel class
     self.store = store
     # create the view
     self.view = gtk.TreeView(store.get_model())
     self.renderer_checkbox = gtk.CellRendererToggle()
     self.renderer_checkbox.set_property('activatable', True)
     self.renderer_checkbox.connect('toggled', self.toggle_active,
                                    store.get_model())
     self.renderer_pixbuf = gtk.CellRendererPixbuf()
     self.renderer_text = gtk.CellRendererText()
     self.columns = [None] * 3
     self.columns[0] = gtk.TreeViewColumn(
         _("Active"), self.renderer_checkbox,
         active=0)  # active=0 <> read from column 0 of model
     self.columns[1] = gtk.TreeViewColumn(_("Icon"), self.renderer_pixbuf)
     self.columns[1].set_cell_data_func(self.renderer_pixbuf,
                                        self.make_pixbuf)
     self.columns[2] = gtk.TreeViewColumn(
         _("PyExtension"), self.renderer_text,
         text=2)  # text=2 <> read from column 2 of model
     for n in range(3):
         self.view.append_column(self.columns[n])
     self.viewselection = self.view.get_selection()
     self.glade.scrolledwindow.add(self.view)
     # initialize the statusbar
     self.statusbar_context_id = self.glade.statusbar.get_context_id('')
     self.glade.statusbar.push(self.statusbar_context_id,
                               _("Version %s") % cons.VERSION)
     self.glade.aboutdialog.set_version(cons.VERSION)
     # retrieve the mateconf settings, set them if this is the first run
     self.mateconf_client = mateconf.client_get_default()
     self.mateconf_client.add_dir("/apps/caja-pyextensions",
                                  mateconf.CLIENT_PRELOAD_NONE)
     if self.mateconf_client.get_string(
             "/apps/caja-pyextensions/picking_dir") == None:
         self.mateconf_client.set_string(
             "/apps/caja-pyextensions/picking_dir", os.path.expanduser('~'))
     self.win_size_n_pos = {}
     # window restore size
     self.win_size_n_pos['win_size'] = [
         self.mateconf_client.get_int("/apps/caja-pyextensions/win_size_w"),
         self.mateconf_client.get_int("/apps/caja-pyextensions/win_size_h")
     ]
     if 0 not in self.win_size_n_pos['win_size']:
         self.glade.window.resize(self.win_size_n_pos['win_size'][0],
                                  self.win_size_n_pos['win_size'][1])
     # have the window and all child widgets visible
     self.glade.window.show_all()
     # window restore position
     self.win_size_n_pos['win_position'] = [
         self.mateconf_client.get_int(
             "/apps/caja-pyextensions/win_position_x"),
         self.mateconf_client.get_int(
             "/apps/caja-pyextensions/win_position_y")
     ]
     self.glade.window.move(self.win_size_n_pos['win_position'][0],
                            self.win_size_n_pos['win_position'][1])