Esempio n. 1
0
        // Constructor
        /// <summary>
        ///	Creates a new <see cref="CoverGetter" />.
        /// </summary>
        /// <remarks>
        ///	This object is used to retrieve album covers in a
        ///	variety of ways.
        /// </remarks>
        /// <param name="db">
        ///	The <see cref="CoverDatabase" /> which stores the covers.
        /// </param>
        public CoverGetter(CoverDatabase db)
        {
            this.db = db;

            amazon_locale = (string)Config.Get(GConfKeyAmazonLocale,
                                               GConfDefaultAmazonLocale);

            Config.AddNotify(GConfKeyAmazonLocale,
                             new GConf.NotifyEventHandler(OnAmazonLocaleChanged));

            Config.AddNotify(GConfKeyAmazonDevTag,
                             new GConf.NotifyEventHandler(OnAmazonDevTagChanged));

            proxy = new GnomeProxy();

            amazon_thread = new GetAmazonThread(this);
        }
Esempio n. 2
0
        // Main
        /// <summary>
        ///	The main method.
        /// </summary>
        /// <param name="args">
        ///	An array of <see cref="String">strings</see>,
        ///	representing command-line arguments.
        /// </param>
        public static void Main(string [] args)
        {
            try {
                NDesk.DBus.BusG.Init();
            } catch {}

            try {
                Global.SetProcessName("muine");
            } catch {}

            Application.Init();
            Gnome.Vfs.Vfs.Initialize();

            // Try to find a running Muine
            try {
                dbus_object = DBusLib.Player.FindInstance();
            } catch {
            }

            // Check if an instance of Muine is already running
            if (dbus_object != null)
            {
                // Handle command line args and exit.
                if (args.Length > 0)
                {
                    ProcessCommandLine(args);
                }
                else
                {
                    dbus_object.SetWindowVisible(true, 0);
                }

                Gdk.Global.NotifyStartupComplete();
                return;
            }

            Catalog.Init("muine", Defines.GNOME_LOCALE_DIR);

            new Gnome.Program
                ("muine", Defines.VERSION, Gnome.Modules.UI, args);

            // Initialize D-Bus
            //   We initialize here but don't connect to it until later.
            try {
                dbus_object = new DBusLib.Player();

                DBusService.Instance.RegisterObject(dbus_object,
                                                    "/org/gnome/Muine/Player");
            } catch (Exception e) {
                Console.WriteLine(string_dbus_failed, e.Message);
            }

            // Init GConf
            Config.Init();

            // Init files
            try {
                FileUtils.Init();
            } catch (Exception e) {
                Error(e.Message);
            }

            // Register stock icons
            StockIcons.Initialize();

            // Set default window icon
            SetDefaultWindowIcon();

            // Open cover database
            try {
                cover_db = new CoverDatabase(3);
            } catch (Exception e) {
                Error(String.Format(string_coverdb_failed, e.Message));
            }

            cover_db.DoneLoading += OnCoversDoneLoading;

            // Load song database
            try {
                db = new SongDatabase(6);
            } catch (Exception e) {
                Error(String.Format(string_songdb_failed, e.Message));
            }

            db.Load();

            // Setup Actions
            actions = new Actions();

            // Create playlist window
            try {
                playlist = new PlaylistWindow();
            } catch (PlayerException e) {
                Error(e.Message);
            }

            // D-Bus
            //  Hook up D-Bus object before loading any songs into the
            //	playlist, to make sure that the song change gets emitted
            //	to the bus
            Muine.DBusLib.Player exported_dbus_object = dbus_object as Muine.DBusLib.Player;
            if (exported_dbus_object != null)
            {
                exported_dbus_object.HookUp(playlist);
            }

            // PluginManager
            //	Initialize plug-ins (also before loading any songs, to make
            //	sure that the song change gets through to all the plug-ins)
            new PluginManager(playlist);

            // Hook up multimedia keys
            if (!GnomeMMKeys.Initialize())
            {
                new MmKeys(playlist);
            }

            // Process command line options
            bool opened_file = ProcessCommandLine(args);

            // Load playlist
            if (!opened_file)
            {
                playlist.RestorePlaylist();
            }

            // Show UI
            playlist.Run();

            while (MainContext.Pending())
            {
                Gtk.Main.Iteration();
            }

            // Load Covers
            cover_db.Load();

            // Hook up to the session manager
            session_client               = Gnome.Global.MasterClient();
            session_client.Die          += OnDieEvent;
            session_client.SaveYourself += OnSaveYourselfEvent;

            // Run!
            Application.Run();
        }