Exemplo n.º 1
0
        void OnPopulatePopup(object o, PopulatePopupArgs args)
        {
            Gtk.MenuItem spacer = new Gtk.SeparatorMenuItem ();
            spacer.Show ();

            Gtk.CheckMenuItem edit = new Gtk.CheckMenuItem (
                Catalog.GetString ("Edit Code Snippet"));
            MarkupLabel (edit);
            edit.Activated += OnEditActivate;
            edit.Show ();

            Gtk.ImageMenuItem lang_select = new Gtk.ImageMenuItem (
                        Catalog.GetString ("Select Language"));
            lang_select.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu);
            lang_select .Show ();
            Gtk.Menu langs_menu = new Gtk.Menu ();

            //default language should be setted
            Gtk.RadioMenuItem pre_item = new Gtk.RadioMenuItem (Language);

            MarkupLabel (pre_item);
            pre_item.Active = true;
            langs_menu.Append (pre_item);
            pre_item.Activated += OnLanguageSelected;
            pre_item.Show ();

            string [] langs = manager.LanguageIds;
            ArrayList lang_array = new ArrayList (langs);
            lang_array.Sort ();
            foreach (String lang in lang_array) {
                if (lang.Equals (Language))
                    continue;
                Gtk.RadioMenuItem tmp = new Gtk.RadioMenuItem (
                        pre_item.Group, Catalog.GetString (lang));
                MarkupLabel (tmp);
                langs_menu.Append (tmp);
                tmp.Activated += OnLanguageSelected;
                tmp.Show ();
                pre_item = tmp;
            }
            lang_select.Submenu = langs_menu;
            args.Menu.Prepend (spacer);
            args.Menu.Prepend (edit);
            args.Menu.Prepend (lang_select);
        }
Exemplo n.º 2
0
    private SharpMusique( string [] args )
    {
        int i;
        string strPath;
        TreeViewColumn tvc;
        CellRenderer rendr;

        string [] strColumns = new string[]
        {
            "Title", "Artist", "Album", "Time", "Price"
        };

        string [] strCWidths = new string[]
        {
            "260", "190", "180", "70", "70"
        };

        if( Environment.OSVersion.ToString().IndexOf( "Unix" ) != -1 )
        {
            strHomeDir = Environment.GetEnvironmentVariable( "HOME" );
            strSongDir = Path.Combine( strHomeDir, "Music" );
            strDataDir = Path.Combine( strHomeDir, ".SharpMusique" );
        }
        else
        {
            strHomeDir = Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData );
            strSongDir = Environment.GetFolderPath(
                Environment.SpecialFolder.MyMusic );
            strDataDir = Path.Combine( strHomeDir, "SharpMusique" );
        }

        Utility.CreateDirectory( strDataDir );

        strPath = Path.Combine( strDataDir, "songdir" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            strSongDir = sr.ReadToEnd().Trim();
            sr.Close();
        }

        Utility.CreateDirectory( strSongDir );

        strPath = Path.Combine( strDataDir, "cwidths" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            string [] strTmp = sr.ReadToEnd().Split( ',' );
            sr.Close();

            if( strTmp.Length == strCWidths.Length )
                strCWidths = strTmp;
        }

        Application.Init();

        Glade.XML gxml = new Glade.XML( null, "SharpMusique.glade",
                                        "MainWindow", null );
        gxml.Autoconnect( this );

        MainWindow.Icon = new Gdk.Pixbuf( null, "sharpmusique.png" );

        songls = new ListStore( GType.String, GType.String, GType.String,
                                GType.String, GType.String, GType.Int );

        songtv.Model = songls;
        songtv.HeadersClickable = true;
        songtv.Selection.Changed += new EventHandler( OnTreeViewSelection );

        for( i = 0; i < strColumns.Length; i++ )
        {
            tvc = new TreeViewColumn();
            rendr = new CellRendererText();
            tvc.Title = strColumns[ i ];
            tvc.PackStart( rendr, true );
            tvc.AddAttribute( rendr, "text", i );
            tvc.Sizing = TreeViewColumnSizing.Fixed;
            tvc.FixedWidth = Convert.ToInt32( strCWidths[ i ] );
            tvc.Resizable = true;
            tvc.SortColumnId = i;
            songtv.AppendColumn( tvc );
        }

        strPath = Path.Combine( strDataDir, "country" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            strCountry = sr.ReadToEnd().Trim();
            sr.Close();
        }

        SList group = new SList( IntPtr.Zero );
        Menu cmenu = new Menu();
        micountry.Submenu = cmenu;
        string [] countries = FairStore.Countries.AllKeys;
        for( i = 0; i < countries.Length; i++ )
        {
            RadioMenuItem rmi = new RadioMenuItem( group, countries[ i ] );
            rmi.Toggled += new EventHandler( OnCountrySelect );
            rmi.Name = countries[ i ];
            if( (((i + 1) == countries.Length) && (strCountry == null)) ||
                countries[ i ].Equals( strCountry ) )
            {
                rmi.Active = true;
            }
            group = rmi.Group;
            cmenu.Append( rmi );
            rmi.Show();
        }

        mipending.Sensitive = false;
        mipepsicap.Sensitive = false;
        migiftcert.Sensitive = false;
        mipreview.Sensitive = false;
        mipurchase.Sensitive = false;
        mipurchasealbum.Sensitive = false;
        miviewalbum.Sensitive = false;

        cidStatus = sbar.GetContextId( "Status" );
        cidProgress = sbar.GetContextId( "Progress" );

        sbar.Push( cidStatus, "Not Logged In" );

        mutex = new Mutex();

        Application.Run();
    }