Пример #1
0
        //Add the shows to the table
        //Each one is stored in an eventbox
        protected void populateTable()
        {
            int curShow;

            if (isSearch)
            {
                curShow = start;
            }
            else
            {
                curShow = 0;
            }

            for (uint i = 0; i < 5; i++)
            {
                if (curShow >= shows.Count)
                {
                    break;
                }

                for (uint j = 0; j < 5; j++)
                {
                    if (curShow >= shows.Count)
                    {
                        break;
                    }

                    //show item
                    Gtk.Image img = new Gtk.Image();
                    if (shows[curShow].thumb != null)
                    {
                        img.Pixbuf = shows[curShow].thumb;
                    }

                    Gtk.Label lbl = new Gtk.Label(shows[curShow].title);
                    lbl.ModifyFont(Pango.FontDescription.FromString("12"));
                    Gtk.VBox box = new Gtk.VBox();
                    box.Add(img);
                    box.Add(lbl);
                    Gtk.EventBox eventbox = new Gtk.EventBox();
                    eventbox.Add(box);

                    //create event for clicking show
                    Func <Show, Gtk.ButtonPressEventHandler> ButtonPressWrapper = ((show) => ((s, e) => { OnShowSelected(s, e, show); }));
                    eventbox.ButtonPressEvent += ButtonPressWrapper(shows[curShow]);

                    //create hover events
                    Func <Gtk.EventBox, Gtk.EnterNotifyEventHandler> EnterNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverEnter(s, e, eBox); }));
                    eventbox.EnterNotifyEvent += EnterNotifyWrapper(eventbox);

                    Func <Gtk.EventBox, Gtk.LeaveNotifyEventHandler> LeaveNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverLeave(s, e, eBox); }));
                    eventbox.LeaveNotifyEvent += LeaveNotifyWrapper(eventbox);

                    table.Attach(eventbox, j, j + 1, i, i + 1);

                    curShow++;
                }
            }
        }
        public WelcomePageTipOfTheDaySection() : base(GettextCatalog.GetString("Did you know?"))
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(System.IO.Path.Combine(System.IO.Path.Combine(PropertyService.DataPath, "options"), "TipsOfTheDay.xml"));

            foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes)
            {
                tips.Add(StringParserService.Parse(xmlNode.InnerText));
            }

            if (tips.Count != 0)
            {
                currentTip = new Random().Next() % tips.Count;
            }
            else
            {
                currentTip = -1;
            }

            Gtk.VBox box = new Gtk.VBox(false, 12);

            label              = new Gtk.Label();
            label.Xalign       = 0;
            label.Wrap         = true;
            label.WidthRequest = 200;
            label.ModifyFont(FontService.SansFont.CopyModified(Gui.Styles.FontScale11));
            label.SetPadding(0, 10);

            label.Text = currentTip != -1 ? tips[currentTip] : "";
            box.PackStart(label, true, true, 0);

            var next = new Gtk.Button(GettextCatalog.GetString("Next Tip"));

            next.Relief   = Gtk.ReliefStyle.Normal;
            next.Clicked += delegate {
                if (tips.Count == 0)
                {
                    return;
                }
                currentTip = currentTip + 1;
                if (currentTip >= tips.Count)
                {
                    currentTip = 0;
                }
                label.Text = tips[currentTip];
            };

            var al = new Gtk.Alignment(0, 0, 0, 0);

            al.Add(next);
            box.PackStart(al, false, false, 0);
            SetContent(box);
        }
Пример #3
0
 void AddLabel()
 {
     if (label == null)
     {
         alignment = new Gtk.Alignment(0.5f, 0.5f, 1f, 1f);
         alignment.SetPadding(4, 5, 4, 4);
         label = new Gtk.Label();
         label.ModifyFont(Theme.Font);
         alignment.Add(label);
         ContentBox.Add(alignment);
         alignment.ShowAll();
     }
 }
        //Add the seasons to the table
        //Each one is stored in an eventbox
        protected void populateTable()
        {
            int curSeason = start;

            for (uint i = 0; i < 5; i++)
            {
                if (curSeason >= show.numOfSeasons)
                {
                    break;
                }

                for (uint j = 0; j < 5; j++)
                {
                    if (curSeason >= show.numOfSeasons)
                    {
                        break;
                    }

                    //season item
                    Gtk.Image img = new Gtk.Image();
                    if (show.thumb != null)
                    {
                        img.Pixbuf = show.thumb;
                    }

                    Gtk.Label lbl = new Gtk.Label("Season " + (curSeason + 1).ToString());
                    lbl.ModifyFont(Pango.FontDescription.FromString("12"));

                    Gtk.VBox box = new Gtk.VBox();
                    box.Add(img);
                    box.Add(lbl);
                    Gtk.EventBox eventbox = new Gtk.EventBox();
                    eventbox.Add(box);

                    //create event for clicking season
                    Func <int, Gtk.ButtonPressEventHandler> ButtonPressWrapper = ((season) => ((s, e) => { OnSeasonSelected(s, e, season); }));
                    eventbox.ButtonPressEvent += ButtonPressWrapper(curSeason);

                    //create hover events
                    Func <Gtk.EventBox, Gtk.EnterNotifyEventHandler> EnterNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverEnter(s, e, eBox); }));
                    eventbox.EnterNotifyEvent += EnterNotifyWrapper(eventbox);

                    Func <Gtk.EventBox, Gtk.LeaveNotifyEventHandler> LeaveNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverLeave(s, e, eBox); }));
                    eventbox.LeaveNotifyEvent += LeaveNotifyWrapper(eventbox);

                    table.Attach(eventbox, j, j + 1, i, i + 1);

                    curSeason++;
                }
            }
        }
        //Add the seasons to the table
        //Each one is stored in an eventbox
        protected void populateTable()
        {
            int curEpisode = start;

            for (uint i = 0; i < 5; i++)
            {
                if (curEpisode >= season.episodes.Count)
                {
                    break;
                }

                for (uint j = 0; j < 5; j++)
                {
                    if (curEpisode >= season.episodes.Count)
                    {
                        break;
                    }

                    //episode item
                    Gtk.Image img = new Gtk.Image();
                    if (season.episodes[curEpisode].thumb != null)
                    {
                        img.Pixbuf = season.episodes[curEpisode].thumb;
                    }

                    Gtk.Label lbl = new Gtk.Label((curEpisode + 1).ToString() + ". " + season.episodes[curEpisode].title);
                    lbl.ModifyFont(Pango.FontDescription.FromString("12"));
                    Gtk.VBox box = new Gtk.VBox();
                    box.Add(img);
                    box.Add(lbl);
                    Gtk.EventBox eventbox = new Gtk.EventBox();
                    eventbox.Add(box);

                    //create event for clicking an episode
                    Func <Episode, Gtk.ButtonPressEventHandler> ButtonPressWrapper = ((ep) => ((s, e) => { OnEpisodeSelected(s, e, ep); }));
                    eventbox.ButtonPressEvent += ButtonPressWrapper(season.episodes[curEpisode]);

                    //create hover events
                    Func <Gtk.EventBox, Gtk.EnterNotifyEventHandler> EnterNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverEnter(s, e, eBox); }));
                    eventbox.EnterNotifyEvent += EnterNotifyWrapper(eventbox);

                    Func <Gtk.EventBox, Gtk.LeaveNotifyEventHandler> LeaveNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverLeave(s, e, eBox); }));
                    eventbox.LeaveNotifyEvent += LeaveNotifyWrapper(eventbox);

                    table.Attach(eventbox, j, j + 1, i, i + 1);

                    curEpisode++;
                }
            }
        }
Пример #6
0
        //This shows a loading graphic and a message
        //it uses a table to center both items
        private void showLoadingScreen(string message = "Loading")
        {
            clearContainer();

            Gtk.Table table = new Gtk.Table(((uint)(6)), ((uint)(6)), true);
            table.BorderWidth = 2;
            Gtk.Image img = new Gtk.Image(loadingAnimation);
            table.Attach(img, 2, 4, 2, 3);

            Gtk.Label lbl = new Gtk.Label(message);
            lbl.ModifyFont(Pango.FontDescription.FromString("12"));
            table.Attach(lbl, 2, 4, 3, 4);

            container.PackStart(table);
            this.ShowAll();
        }
Пример #7
0
        //Makes the box that holds the image and description of episode/movie
        //puts it above the table
        protected void makeDescriptionBox()
        {
            Gtk.Image img = new Gtk.Image();
            if (thumb != null)
            {
                img.Pixbuf = thumb;
            }

            Gtk.Label lbl = new Gtk.Label(desc);
            lbl.LineWrap = true;
            lbl.ModifyFont(Pango.FontDescription.FromString("12"));
            lbl.WidthRequest = 600;
            Gtk.VBox box = new Gtk.VBox();
            box.Add(img);
            box.Add(lbl);
            containerVbox.PackStart(box);
        }
		public WelcomePageTipOfTheDaySection (): base (GettextCatalog.GetString ("Did you know?"))
		{
			XmlDocument xmlDocument = new XmlDocument ();
			xmlDocument.Load (System.IO.Path.Combine (System.IO.Path.Combine (PropertyService.DataPath, "options"), "TipsOfTheDay.xml"));

			foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) {
				tips.Add (StringParserService.Parse (xmlNode.InnerText));
			}
			
			if (tips.Count != 0)  
				currentTip = new Random ().Next () % tips.Count;
			else
				currentTip = -1;

			Gtk.VBox box = new Gtk.VBox (false, 12);

			label = new Gtk.Label ();
			label.Xalign = 0;
			label.Wrap = true;
			label.WidthRequest = 200;
			label.ModifyFont (FontService.SansFont.CopyModified (Gui.Styles.FontScale11));
			label.SetPadding (0, 10);

			label.Text = currentTip != -1 ? tips[currentTip] : "";
			box.PackStart (label, true, true, 0);

			var next = new Gtk.Button (GettextCatalog.GetString ("Next Tip"));
			next.Relief = Gtk.ReliefStyle.Normal;
			next.Clicked += delegate {
				if (tips.Count == 0)
					return;
				currentTip = currentTip + 1;
				if (currentTip >= tips.Count)
					currentTip = 0;
				label.Text = tips[currentTip];
			};

			var al = new Gtk.Alignment (0, 0, 0, 0);
			al.Add (next);
			box.PackStart (al, false, false, 0);
			SetContent (box);
		}
Пример #9
0
        public MainWindow() : base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            backButton.Sensitive   = false;
            searchButton.Sensitive = false;
            previousWidgets        = new Stack <EmbeddedWidget> ();
            errorLabel             = new Gtk.Label();
            errorLabel.ModifyFont(Pango.FontDescription.FromString("12"));


            //load the loading animation
            using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("loadingAnimation")) {
                loadingAnimation = new Gdk.PixbufAnimation(imgStream);
            }

            //load the source images
            using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("hulu_logo")) {
                huluLogo = new Gdk.Pixbuf(imgStream);
            }

            using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("amazon_logo")) {
                amazonLogo = new Gdk.Pixbuf(imgStream);
            }

            using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("youtube_logo")) {
                youtubeLogo = new Gdk.Pixbuf(imgStream);
            }

            //make a new CancellationSource for a new task
            loadingResultsCancellationSource = new CancellationTokenSource();

            showLoadingScreen();
            getPopShows(0);                             //first embedded widget is popular shows

            this.ShowAll();
        }
Пример #10
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            Widget.UseUnderline = useMnemonic;
            this.image          = image;

            if (label != null && label.Length == 0)
            {
                label = null;
            }

            Button b = (Button)Frontend;

            if (label != null && image.Backend == null && b.Type == ButtonType.Normal)
            {
                Widget.Label = label;
                return;
            }

            if (b.Type == ButtonType.Disclosure)
            {
                Widget.Label = null;
                Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                Widget.Image.ShowAll();
                return;
            }

            Gtk.Widget contentWidget = null;

            Gtk.Widget imageWidget = null;
            if (image.Backend != null)
            {
                imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button));
            }

            labelWidget = null;

            if (label != null && imageWidget == null)
            {
                contentWidget = labelWidget = new Gtk.Label(label);
            }
            else if (label == null && imageWidget != null)
            {
                contentWidget = imageWidget;
            }
            else if (label != null && imageWidget != null)
            {
                Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3);
                labelWidget = new Gtk.Label(label)
                {
                    UseUnderline = useMnemonic
                };

                if (position == ContentPosition.Left || position == ContentPosition.Top)
                {
                    box.PackStart(imageWidget, false, false, 0);
                    box.PackStart(labelWidget, false, false, 0);
                }
                else
                {
                    box.PackStart(labelWidget, false, false, 0);
                    box.PackStart(imageWidget, false, false, 0);
                }

                contentWidget = box;
            }
            var expandButtonContent = false;

            if (b.Type == ButtonType.DropDown)
            {
                if (contentWidget != null)
                {
                    Gtk.HBox box = new Gtk.HBox(false, 3);
                    box.PackStart(contentWidget, true, true, 3);
                    box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0);
                    contentWidget       = box;
                    expandButtonContent = true;
                }
                else
                {
                    contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out);
                }
            }
            if (contentWidget != null)
            {
                contentWidget.ShowAll();
                Widget.Label = null;
                Widget.Image = contentWidget;
                var alignment = Widget.Child as Gtk.Alignment;
                if (alignment != null)
                {
                    if (expandButtonContent)
                    {
                        var box = alignment.Child as Gtk.Box;
                        if (box != null)
                        {
                            alignment.Xscale = 1;
                            box.SetChildPacking(box.Children [0], true, true, 0, Gtk.PackType.Start);
                            if (labelWidget != null)
                            {
                                labelWidget.Xalign = 0;
                            }
                        }
                    }
                    else if (position == ContentPosition.Left && (contentWidget is Gtk.Box))
                    {
                        // in case the button is wider than its natural size and has text and an image on the left,
                        // optimize its alignment to make the text more centered.
                        // FIXME: more sophisticated size calculation
                        alignment.Xalign = 0.475f;
                    }
                }
                if (labelWidget != null)
                {
                    labelWidget.UseUnderline = useMnemonic;
                    if (customFont != null)
                    {
                        labelWidget.ModifyFont(customFont);
                    }
                    if (customLabelColor.HasValue)
                    {
                        labelWidget.SetForegroundColor(customLabelColor.Value);
                        labelWidget.SetForegroundColor(Gtk.StateType.Prelight, customLabelColor.Value);
                    }
                }
            }
            else
            {
                Widget.Label = null;
            }
        }
Пример #11
0
        //populate the table with the sources
        //each source is in an eventbox
        protected void populateTable()
        {
            List <string> srcs = sources.Keys.ToList();

            //change what will be displayed based on the active source
            switch (activeSource)
            {
            case Source.All:
                break;

            case Source.Hulu:
                if (srcs.Contains("Hulu"))
                {
                    srcs = new List <string> {
                        "Hulu"
                    }
                }
                ;
                else
                {
                    srcs = new List <string> ();
                }
                break;

            case Source.Amazon:
                if (srcs.Contains("Amazon"))
                {
                    srcs = new List <string> {
                        "Amazon"
                    }
                }
                ;
                else
                {
                    srcs = new List <string> ();
                }
                break;

            case Source.YouTube:
                if (srcs.Contains("YouTube"))
                {
                    srcs = new List <string> {
                        "YouTube"
                    }
                }
                ;
                else
                {
                    srcs = new List <string> ();
                }
                break;
            }

            //loop through table
            int curSource = 0;

            for (uint i = 0; i < 1; i++)
            {
                if (curSource >= srcs.Count)
                {
                    break;
                }

                for (uint j = 0; j < 3; j++)
                {
                    if (curSource >= srcs.Count)
                    {
                        break;
                    }

                    //image for the sources are stored in the MainWindow
                    Gtk.Image img = new Gtk.Image();
                    if (srcs [curSource] == "Hulu")
                    {
                        img.Pixbuf = MainWindow.huluLogo;
                    }
                    else if ((srcs[curSource] == "Amazon"))
                    {
                        img.Pixbuf = MainWindow.amazonLogo;
                    }
                    else if ((srcs[curSource] == "YouTube"))
                    {
                        img.Pixbuf = MainWindow.youtubeLogo;
                    }


                    //source item
                    Gtk.Label lbl = new Gtk.Label(srcs[curSource]);
                    lbl.ModifyFont(Pango.FontDescription.FromString("12"));
                    Gtk.VBox box = new Gtk.VBox();
                    box.Add(img);
                    box.Add(lbl);
                    Gtk.EventBox eventbox = new Gtk.EventBox();
                    eventbox.Add(box);

                    //create event for clicking a source
                    Func <string, Gtk.ButtonPressEventHandler> ButtonPressWrapper = ((src) => ((s, e) => { OnSourceSelected(s, e, src); }));
                    eventbox.ButtonPressEvent += ButtonPressWrapper(srcs[curSource]);

                    //create hover events
                    Func <Gtk.EventBox, Gtk.EnterNotifyEventHandler> EnterNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverEnter(s, e, eBox); }));
                    eventbox.EnterNotifyEvent += EnterNotifyWrapper(eventbox);

                    Func <Gtk.EventBox, Gtk.LeaveNotifyEventHandler> LeaveNotifyWrapper = ((Gtk.EventBox eBox) => ((s, e) => { OnHoverLeave(s, e, eBox); }));
                    eventbox.LeaveNotifyEvent += LeaveNotifyWrapper(eventbox);


                    table.Attach(eventbox, j, j + 1, i, i + 1);

                    curSource++;
                    if (curSource >= sources.Keys.Count)
                    {
                        break;
                    }
                }
            }
        }
Пример #12
0
 static Gtk.Label CreateLabel(string text){
     var label = new Gtk.Label (text);
     label.ModifyFont (new Pango.FontDescription { Weight = Pango.Weight.Bold });
     return label;
 }
Пример #13
0
 public void ModifyLabelFont(Pango.FontDescription font)
 {
     label.ModifyFont(font);
 }
		void AddLabel ()
		{
			if (label == null) {
				alignment = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
				alignment.SetPadding (4, 5, 4, 4);
				label = new Gtk.Label ();
				label.ModifyFont (Theme.Font);
				alignment.Add (label);
				ContentBox.Add (alignment);
				alignment.ShowAll ();
			}
		}