Exemple #1
0
        public FindStation(PlayerWindow w)
            : base(Catalog.GetString("Find A Station"), w, DialogFlags.DestroyWithParent)
        {
            this.parentwindow = w;
            this.HasSeparator = false;
            this.SetDefaultSize (430, 290);

            Glade.XML glade_xml = new Glade.XML (null, "FindStation.glade", "search_contents", null);
            glade_xml.Autoconnect (this);
            this.VBox.Add (search_contents);

            Glade.XML similar_xml = new Glade.XML (null, "SimilarResults.glade", "similar_contents", null);
            similar_xml.Autoconnect (this);
            results_container.Add (similar_contents);

            Glade.XML tag_xml = new Glade.XML (null, "TagResults.glade", "tag_container", null);
            tag_xml.Autoconnect (this);
            tag_container.Visible = false;
            results_container.Add (tag_container);

            neighbour_container = new ScrolledWindow ();
            neighbour_view = new NeighbourView ();
            neighbour_view.Visible = true;

            TreeSelection selection = neighbour_view.Selection;
            selection.Changed += OnNeighbourChanged;

            neighbour_container.Add (neighbour_view);
            neighbour_container.Visible = false;

            results_container.Add (neighbour_container);

            this.AddButton (Catalog.GetString("Cancel"), ResponseType.Cancel);
            this.AddButton (Catalog.GetString("Change Station"), ResponseType.Ok);
            this.SetResponseSensitive (ResponseType.Ok, false);

            SetupUI ();

            search_button.Sensitive = false;

            similar_contents.Visible = false;
            search_contents.Visible = true;
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            // Search for existing DBus server
            IDBusPlayer dbus_core = DetectInstanceAndDbus();
            HandleDbusCommands (dbus_core, args);

            // If we are the only instance, start a new DBus server
            Console.WriteLine("Starting new Last Exit server");
            try {
                dbus_remote = new DBusRemote();
                dbus_player = new DBusPlayer();
                if (dbus_player != null) {
                    dbus_remote.RegisterObject(dbus_player, "Player");
                }
            } catch (Exception e) {
                Console.Error.WriteLine (e);
            }

            string username;
            string password;

            try {
                Driver.SetProcessName ("last-exit");
            } catch {} // Ignore exception if fail (not needed to run)

            Catalog.Init("last-exit", Defines.LOCALE_DIR);
            Application.Init("last-exit", ref args);

            StockIcons.Initialize ();

            SetDefaultWindowIcon ();

            config = new Config ();

            if (config.FirstRun) {
                FirstRunDialog frd = new FirstRunDialog ();

                int response = frd.Run ();

                frd.Visible = false;

                switch (response) {
                    case (int) ResponseType.Reject:
                        Gtk.Application.Quit();
                        Environment.Exit (0);
                        break;

                    case (int) ResponseType.Ok:
                        config.Username = frd.Username;
                        config.Password = frd.Password;
                        break;

                    default:
                        break;
                }

                frd.Destroy ();
                config.FirstRun = false;
            }

            Driver.SetUpConfigDirectory ();

            //TrayIcon.ShowNotifications = config.ShowNotifications;

            username = config.Username;
            password = config.Password;

            // We must get a reference to the JIT's SEGV handler because
            // GStreamer will set its own and not restore the previous, which
            // will cause what should be NullReferenceExceptions to be unhandled
            // segfaults for the duration of the instance, as the JIT is powerless!
            // FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=391777
            IntPtr mono_jit_segv_handler = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
            sigaction(Mono.Unix.Native.Signum.SIGSEGV, IntPtr.Zero, mono_jit_segv_handler);

            connection = new FMConnection (username, password);
            connection.Handshake ();

            Scrobbler scrobbler = new Scrobbler (username, password);
            Playlist playlist = new Playlist (connection);

            player = new Player (playlist);
            player.SongEnded += new Player.NewSongHandler (scrobbler.Scrobble);
            player.NewSong += new Player.NewSongHandler (scrobbler.NowPlayingNotification);

            actions = new Actions ();
            player_window = new PlayerWindow ();

            if (args.Length > 0) {
                player_window.InitialStation = args[0];
            }

            player_window.Run ();

            Application.Run ();

            // Reset the SEGV handle to that of the JIT again (SIGH!)
            sigaction(Mono.Unix.Native.Signum.SIGSEGV, mono_jit_segv_handler, IntPtr.Zero);
            System.Runtime.InteropServices.Marshal.FreeHGlobal(mono_jit_segv_handler);
        }