コード例 #1
0
ファイル: QueryBox.cs プロジェクト: knocte/hyena
        private HBox BuildMatchHeader()
        {
            HBox header = new HBox();

            header.Show();

            terms_enabled_checkbox = new CheckButton(Catalog.GetString("_Match"));
            terms_enabled_checkbox.Show();
            terms_enabled_checkbox.Active   = true;
            terms_enabled_checkbox.Toggled += OnMatchCheckBoxToggled;
            header.PackStart(terms_enabled_checkbox, false, false, 0);

            terms_logic_combo = new ComboBoxText();
            terms_logic_combo.AppendText(Catalog.GetString("all"));
            terms_logic_combo.AppendText(Catalog.GetString("any"));
            terms_logic_combo.Show();
            terms_logic_combo.Active = 0;
            header.PackStart(terms_logic_combo, false, false, 0);

            terms_label = new Label(Catalog.GetString("of the following:"));
            terms_label.Show();
            terms_label.Xalign = 0.0f;
            header.PackStart(terms_label, true, true, 0);

            header.Spacing = 5;

            return(header);
        }
コード例 #2
0
        private void AttachWidgets(TextView textView)
        {
            // This is really different from the C version, but the
            // C versions seems a little pointless.

            Button button = new Button("Click Me");

            button.Clicked += new EventHandler(EasterEggCB);
            textView.AddChildAtAnchor(button, buttonAnchor);
            button.ShowAll();

            ComboBoxText combo = new ComboBoxText();

            combo.AppendText("Option 1");
            combo.AppendText("Option 2");
            combo.AppendText("Option 3");

            textView.AddChildAtAnchor(combo, menuAnchor);

            HScale scale = new HScale(null);

            scale.SetRange(0, 100);
            scale.SetSizeRequest(70, -1);
            textView.AddChildAtAnchor(scale, scaleAnchor);
            scale.ShowAll();

            Gtk.Image image = Gtk.Image.LoadFromResource("floppybuddy.gif");
            textView.AddChildAtAnchor(image, animationAnchor);
            image.ShowAll();

            Entry entry = new Entry();

            textView.AddChildAtAnchor(entry, entryAnchor);
            entry.ShowAll();
        }
コード例 #3
0
ファイル: QueryTermBox.cs プロジェクト: knocte/hyena
        private void HandleFieldChanged(object o, EventArgs args)
        {
            if (field_chooser.Active < 0 || field_chooser.Active >= sorted_fields.Length)
            {
                return;
            }

            QueryField field = sorted_fields [field_chooser.Active];

            // Leave everything as is unless the new field is a different type
            if (this.field != null && (field.ValueTypes.Length == 1 && this.field.ValueTypes.Length == 1 && field.ValueTypes[0] == this.field.ValueTypes[0]))
            {
                this.field = field;
                return;
            }

            op_chooser.Changed -= HandleOperatorChanged;

            this.field = field;

            // Remove old type's operators
            op_chooser.RemoveAll();

            // Add new field's operators
            int val_count = 0;

            value_entries.Clear();
            operators.Clear();
            operator_entries.Clear();
            foreach (QueryValue val in this.field.CreateQueryValues())
            {
                QueryValueEntry entry = QueryValueEntry.Create(val);
                value_entries.Add(entry);

                if (val_count++ > 0)
                {
                    op_chooser.AppendText(String.Empty);
                    operators.Add(null);
                }

                foreach (Operator op in val.OperatorSet)
                {
                    op_chooser.AppendText(op.Label);
                    operators.Add(op);
                    operator_entries [op] = entry;
                }
            }

            SetValueEntry(value_entries[0]);

            // TODO: If we have the same operator that was previously selected, select it
            op_chooser.Changed += HandleOperatorChanged;
            op_chooser.Active   = 0;
        }
コード例 #4
0
        public QueryLimitBox(QueryOrder [] orders, QueryLimit [] limits) : base()
        {
            this.orders = orders;
            this.limits = limits;

            Spacing = 5;

            enabled_checkbox          = new CheckButton(Catalog.GetString("_Limit to"));
            enabled_checkbox.Toggled += OnEnabledToggled;

            // workaround for bgo#727294, we doubt anyway that it's very useful to have a max higher than 2147483647
            const double max = int.MaxValue;

            count_spin         = new SpinButton(0, max, 1);
            count_spin.Numeric = true;
            count_spin.Digits  = 0;
            count_spin.Value   = 25;
            count_spin.SetSizeRequest(60, -1);

            limit_combo = new ComboBoxText();
            foreach (QueryLimit limit in limits)
            {
                limit_combo.AppendText(limit.Label);
            }

            order_combo = new ComboBoxText();
            order_combo.RowSeparatorFunc = IsRowSeparator;
            foreach (QueryOrder order in orders)
            {
                if (order == null)
                {
                    order_combo.AppendText(String.Empty);
                }
                else
                {
                    order_combo.AppendText(order.Label);
                }
            }

            PackStart(enabled_checkbox, false, false, 0);
            PackStart(count_spin, false, false, 0);
            PackStart(limit_combo, false, false, 0);
            PackStart(new Label(Catalog.GetString("selected by")), false, false, 0);
            PackStart(order_combo, false, false, 0);

            enabled_checkbox.Active = false;
            limit_combo.Active      = 0;
            order_combo.Active      = 0;

            OnEnabledToggled(null, null);

            ShowAll();
        }
コード例 #5
0
        public static void Main(string[] args)
        {
            Application.Init();
            MainWindow   win       = new MainWindow();
            Entry        firstnum  = new Entry();
            Entry        secnum    = new Entry();
            Button       calculate = new Button();
            ComboBoxText combotext = new ComboBoxText();
            Label        summary   = new Label();
            Grid         maingrid  = new Grid();

            string[] adds = { "+", "x", "-", "÷" };
            combotext.AppendText(adds[0]);
            combotext.AppendText(adds[1]);
            combotext.AppendText(adds[2]);
            combotext.AppendText(adds[3]);
            calculate.Label = "Calculate!";
            maingrid.Attach(firstnum, 0, 0, 1, 1);
            maingrid.AttachNextTo(combotext, firstnum, PositionType.Bottom, 1, 1);
            maingrid.AttachNextTo(secnum, combotext, PositionType.Bottom, 1, 1);
            maingrid.AttachNextTo(calculate, secnum, PositionType.Bottom, 1, 1);
            maingrid.AttachNextTo(summary, calculate, PositionType.Bottom, 1, 1);
            calculate.Clicked += Calculate_Clicked;
            void Calculate_Clicked(object sender, EventArgs e)
            {
                if (combotext.ActiveText == "+")
                {
                    int sumadd = int.Parse(firstnum.Text) + int.Parse(secnum.Text);
                    summary.Text = sumadd.ToString();
                }
                if (combotext.ActiveText == "x")
                {
                    int summultiply = int.Parse(firstnum.Text) * int.Parse(secnum.Text);
                    summary.Text = summultiply.ToString();
                }
                if (combotext.ActiveText == "-")
                {
                    int sumsubstract = int.Parse(firstnum.Text) - int.Parse(secnum.Text);
                    summary.Text = sumsubstract.ToString();
                }
                if (combotext.ActiveText == "÷")
                {
                    int sumsubstract = int.Parse(firstnum.Text) / int.Parse(secnum.Text);
                    summary.Text = sumsubstract.ToString();
                }
            }

            win.Add(maingrid);
            win.ShowAll();
            Application.Run();
        }
コード例 #6
0
 public static void AppendTextCollection(this ComboBoxText comboBox, IEnumerable <string> stringCollection)
 {
     foreach (var str in stringCollection)
     {
         comboBox.AppendText(str);
     }
 }
コード例 #7
0
ファイル: QueryTermBox.cs プロジェクト: knocte/hyena
        private void BuildInterface()
        {
            field_chooser          = new ComboBoxText();
            field_chooser.Changed += HandleFieldChanged;

            op_chooser = new ComboBoxText();
            op_chooser.RowSeparatorFunc = IsRowSeparator;
            op_chooser.Changed         += HandleOperatorChanged;

            value_box = new HBox();

            remove_button          = new Button(new Image("gtk-remove", IconSize.Button));
            remove_button.Relief   = ReliefStyle.None;
            remove_button.Clicked += OnButtonRemoveClicked;

            add_button          = new Button(new Image("gtk-add", IconSize.Button));
            add_button.Relief   = ReliefStyle.None;
            add_button.Clicked += OnButtonAddClicked;

            button_box = new HBox();
            button_box.PackStart(remove_button, false, false, 0);
            button_box.PackStart(add_button, false, false, 0);

            foreach (QueryField field in sorted_fields)
            {
                field_chooser.AppendText(field.Label);
            }

            Show();
            field_chooser.Active = 0;
        }
コード例 #8
0
        public SmartPlaylistQueryValueEntry() : base()
        {
            combo = new ComboBoxText();
            combo.WidthRequest = DefaultWidth;

            int count = 0;
            SmartPlaylistSource playlist;

            foreach (Source child in ServiceManager.SourceManager.DefaultSource.Children)
            {
                playlist = child as SmartPlaylistSource;
                if (playlist != null && playlist.DbId != null)
                {
                    if (Editor.CurrentlyEditing == null || (Editor.CurrentlyEditing != playlist && !playlist.DependsOn(Editor.CurrentlyEditing)))
                    {
                        combo.AppendText(playlist.Name);
                        playlist_id_combo_map [playlist.DbId.Value] = count;
                        combo_playlist_id_map [count++]             = playlist.DbId.Value;
                    }
                }
            }

            Add(combo);
            combo.Active = 0;

            combo.Changed += HandleValueChanged;
        }
コード例 #9
0
        static ComboBox Create_ComboBox(string [] strings)
        {
            /*Menu menu = new Menu ();
             *
             * MenuItem menu_item = null;
             *
             * foreach (string str in strings) {
             *      menu_item = new MenuItem (str);
             *      menu_item.Show ();
             *      menu.Append (menu_item);
             * }
             *
             * OptionMenu option_menu = new OptionMenu ();
             * option_menu.Menu = menu;
             *
             * return option_menu;*/
            ComboBoxText combo_box = new ComboBoxText();

            foreach (string str in strings)
            {
                combo_box.AppendText(str);
            }

            return(combo_box);
        }
コード例 #10
0
        public MainScreen() : base("Desktop File Creator")
        {
            Grid grid = new Grid();

            this.Add(grid);
            this.Resizable = false;

            Label TypeLabel     = new Label("Type:");
            Label VersionLabel  = new Label("Version:");
            Label NameLabel     = new Label("Name:");
            Label CommentLabel  = new Label("Comment:");
            Label IconLabel     = new Label("Icon");
            Label ExecLabel     = new Label("Exec:");
            Label PathLabel     = new Label("Path:");
            Label TerminalLabel = new Label("Terminal:");
            Label KeywordsLabel = new Label("Keywords:");
            Label URLLabel      = new Label("URL:");

            grid.Add(TypeLabel);
            grid.Attach(VersionLabel, 0, 1, 1, 1);
            grid.Attach(NameLabel, 0, 2, 1, 1);
            grid.Attach(CommentLabel, 0, 3, 1, 1);
            grid.Attach(IconLabel, 0, 4, 1, 1);
            grid.Attach(ExecLabel, 0, 5, 1, 1);
            grid.Attach(PathLabel, 0, 6, 1, 1);
            grid.Attach(TerminalLabel, 0, 7, 1, 1);
            grid.Attach(KeywordsLabel, 0, 8, 1, 1);
            grid.Attach(URLLabel, 0, 9, 1, 1);

            for (int i = 0; i < values.Count; i++)
            {
                TypeCombo.AppendText(values[i]);
            }
            TypeCombo.Active = 0;

            grid.Attach(TypeCombo, 1, 0, 1, 1);
            grid.Attach(VersionEntry, 1, 1, 1, 1);
            grid.Attach(NameEntry, 1, 2, 1, 1);
            grid.Attach(CommentEntry, 1, 3, 1, 1);
            grid.Attach(IconChooser, 1, 4, 1, 1);
            grid.Attach(ExecChooser, 1, 5, 1, 1);
            grid.Attach(PathChooser, 1, 6, 1, 1);
            grid.Attach(TerminalToggle, 1, 7, 1, 1);
            grid.Attach(KeywordsEntry, 1, 8, 1, 1);
            grid.Attach(URLEntry, 1, 9, 1, 1);

            Button SaveButton = new Button("Save To File");

            grid.Attach(SaveButton, 0, 10, 2, 1);

            SaveButton.Clicked += new EventHandler(SaveClick);

            Button InstallButton = new Button("Install");

            grid.Attach(InstallButton, 0, 11, 2, 1);
            InstallButton.Clicked += new EventHandler(InstallClick);

            this.ShowAll();
        }
コード例 #11
0
ファイル: Gui.cs プロジェクト: Anuken/BoardControl
        ComboBox CreateCombo(EventHandler handler)
        {
            ComboBoxText combo = new ComboBoxText();

            combo.Changed += handler;

            combo.AppendText("<none>");

            foreach (Key key in Keys.All)
            {
                combo.AppendText(key.name);
            }

            combo.Active = 0;

            return(combo);
        }
コード例 #12
0
        // Convenience function to create a combo box holding a number of strings
        private ComboBox CreateComboBox(string [] strings)
        {
            ComboBoxText combo = new ComboBoxText();

            foreach (string str in strings)
            {
                combo.AppendText(str);
            }

            combo.Active = 0;
            return(combo);
        }
コード例 #13
0
        /* Private members */

        private void FillComboBox()
        {
            DisconnectComboBoxChangedSignal();

            (comboBox.Model as ListStore).Clear();

            bool hasAdditionalActions = (additionalActions != null) && (additionalActions.Length > 0);

            /* Add additional actions */
            if (hasAdditionalActions)
            {
                foreach (string additionalAction in additionalActions)
                {
                    comboBox.AppendText(additionalAction);
                }
                comboBox.AppendText("-");
            }

            /* Prepare newline types to add */
            string      mac           = "Mac OS Classic";
            string      unix          = "Unix/Linux";
            string      windows       = "Windows";
            string      systemDefault = " (" + Catalog.GetString("System Default") + ")";
            NewlineType systemNewline = Core.Util.GetSystemNewlineType();

            SetSystemNewlineSuffix(systemNewline, ref mac, ref unix, ref windows, systemDefault);

            /* Add newline types */
            comboBox.AppendText(mac);
            comboBox.AppendText(unix);
            comboBox.AppendText(windows);

            if (newlineTypeToSelect != NewlineType.Unknown)
            {
                int activeItem = (int)newlineTypeToSelect - 1 + (hasAdditionalActions ? additionalActions.Length + 1 : 0);
                SetActiveItem(activeItem, false);         //Don't use silent change because the signal is already disabled
            }

            ConnectComboBoxChangedSignal();
        }
コード例 #14
0
ファイル: ComboBoxWidget.cs プロジェクト: mfcallahan/Pinta
        public ComboBoxWidget(string[] entries)
        {
            Build();

            foreach (var s in entries)
            {
                combobox.AppendText(s);
            }

            combobox.Changed += delegate {
                Changed?.Invoke(this, EventArgs.Empty);
            };
        }
コード例 #15
0
        public static Gtk.Window Create()
        {
            window = new Window("GtkComboBox");
            window.SetDefaultSize(200, 100);

            VBox box1 = new VBox(false, 0);

            window.Add(box1);

            VBox box2 = new VBox(false, 10);

            box2.BorderWidth = 10;
            box1.PackStart(box2, true, true, 0);

            ComboBoxText combo = ComboBoxText.NewWithEntry();

            combo.AppendText("Foo");
            combo.AppendText("Bar");
            combo.Changed       += new EventHandler(OnComboActivated);
            combo.Entry.Changed += new EventHandler(OnComboEntryChanged);
            box2.PackStart(combo, true, true, 0);

            HSeparator separator = new HSeparator();

            box1.PackStart(separator, false, false, 0);

            box2             = new VBox(false, 10);
            box2.BorderWidth = 10;
            box1.PackStart(box2, false, false, 0);

            Button button = new Button(Stock.Close);

            button.Clicked   += new EventHandler(OnCloseClicked);
            button.CanDefault = true;

            box2.PackStart(button, true, true, 0);
            button.GrabDefault();
            return(window);
        }
コード例 #16
0
        private void FillVideoComboBoxBasedOnCurrentFolder()
        {
            videoFiles     = null;
            videoFilenames = null;
            videoComboBox.RemoveAll();

            string folder = String.Empty;

            try {
                folder = (Dialog as FileChooserDialog).CurrentFolder;
            }
            catch (Exception e) {
                Logger.Error(e, "Caught exception when trying to get the current folder");
                SetVideoSelectionSensitivity(false);
                return;
            }

            if ((folder == null) || (folder == String.Empty))
            {
                Logger.Error("Error when trying to get the current folder.");
                SetVideoSelectionSensitivity(false);
                return;
            }

            videoFiles = VideoFiles.GetVideoFilesAtPath(folder);

            if ((videoFiles.Count == 0) || (videoFiles == null))
            {
                SetVideoSelectionSensitivity(false);
                return;
            }
            else
            {
                SetVideoSelectionSensitivity(true);
            }

            videoFiles.Sort();
            videoFilenames = new ArrayList();
            foreach (string file in videoFiles)
            {
                string filename = Path.GetFileName(file);
                videoComboBox.AppendText(filename);

                videoFilenames.Add(FilenameWithoutExtension(filename));
            }

            videoComboBox.PrependText("-");
            videoComboBox.PrependText(Catalog.GetString("None"));
            videoComboBox.Active = 0;
        }
コード例 #17
0
        private void LoadHistory()
        {
            string [] history_array = OpenLocationHistorySchema.Get();
            if (history_array == null || history_array.Length == 0)
            {
                return;
            }

            foreach (string uri in history_array)
            {
                history.Add(uri);
                address_entry.AppendText(uri);
            }
        }
コード例 #18
0
ファイル: TaskEditor.cs プロジェクト: loganek/loganek-planer
        void InitPriorityComboBox()
        {
            Array priorityValues = Enum.GetValues(typeof(Priority));

            foreach (var priority in priorityValues)
            {
                priorityComboBoxText.AppendText(priority.ToString());
            }

            if (priorityValues.Length > 0)
            {
                priorityComboBoxText.Active = 0;
            }
        }
コード例 #19
0
        // Relative: [<|>] [num] [minutes|hours] ago
        // TODO: Absolute: [>|>=|=|<|<=] [date/time]
        public FileSizeQueryValueEntry() : base()
        {
            spin_button            = new SpinButton(0.0, 1.0, 1.0);
            spin_button.Digits     = 1;
            spin_button.WidthChars = 4;
            spin_button.SetRange(0.0, Double.MaxValue);
            Add(spin_button);

            combo = new ComboBoxText();
            combo.AppendText(Catalog.GetString("bytes"));
            combo.AppendText(Catalog.GetString("KB"));
            combo.AppendText(Catalog.GetString("MB"));
            combo.AppendText(Catalog.GetString("GB"));
            combo.Realized += delegate { if (!combo_set)
                                         {
                                             combo.Active = 2;
                                         }
            };
            Add(combo);

            spin_button.ValueChanged += HandleValueChanged;
            combo.Changed            += HandleValueChanged;
        }
コード例 #20
0
        /* Private members */

        private void FillComboBox()
        {
            DisconnectComboBoxChangedSignal();

            (comboBox.Model as ListStore).Clear();

            int currentItem = 0;
            int activeItem  = 0;

            bool hasAdditionalActions = (additionalActions != null) && (additionalActions.Length > 0);

            /* Add additional actions */
            if (hasAdditionalActions)
            {
                foreach (string additionalAction in additionalActions)
                {
                    comboBox.AppendText(additionalAction);
                }
                comboBox.AppendText("-");
                currentItem += additionalActions.Length + 1;
            }

            /* Add subtitle formats */
            foreach (SubtitleTypeInfo typeInfo in subtitleTypes)
            {
                comboBox.AppendText(typeInfo.Name + " (" + ConcatenateExtensions(typeInfo.Extensions) + ")");
                if (typeInfo.Type == fixedSubtitleType)
                {
                    activeItem = currentItem;
                }
                currentItem++;
            }

            SetActiveItem(activeItem, false);     //Don't use silent change because the signal is already disabled

            ConnectComboBoxChangedSignal();
        }
コード例 #21
0
        private void FillComboBox()
        {
            DisconnectComboBoxChangedSignal();

            (comboBox.Model as ListStore).Clear();

            int activeItem  = comboBoxActiveItem;
            int currentItem = 0;

            /* Add auto detect */
            if (hasAutoDetect)
            {
                AddAutoDetect();
                currentItem++;
            }

            /* Add additional actions */
            if (additionalActions != null)
            {
                foreach (string additionalAction in additionalActions)
                {
                    comboBox.AppendText(additionalAction);
                    currentItem++;
                }
            }

            if (currentItem != 0)
            {
                comboBox.AppendText("-");
                currentItem++;
            }

            /* Add encodings */
            foreach (EncodingDescription encoding in encodings)
            {
                comboBox.AppendText(encoding.Description + " (" + encoding.Name + ")");
                if (encoding.CodePage == fixedEncoding)
                {
                    activeItem = currentItem;
                }
                currentItem++;
            }

            /* Add add/remove action */
            comboBox.AppendText("-");
            comboBox.AppendText(Catalog.GetString("Add or Remove…"));

            SetActiveItem(activeItem, false);     //Don't use silent change because the signal is already disabled

            ConnectComboBoxChangedSignal();
        }
コード例 #22
0
        public ProfileWindow(
            string profileId,
            ProfileData profileData,
            CachedPrefixInfo[] prefixes,
            Action <string, ProfileData> doSave)
            : this(new Builder("ProfileWindow.glade"))
        {
            _prefixes = prefixes;
            _doSave   = doSave;

            _entryName.Text = profileId;

            foreach (var prefixName in prefixes.Select(p => p.About))
            {
                _comboPrefixes.AppendText(prefixName);
            }

            _toggleCheckVersion.Active = profileData.CheckVersionFiles;

            _comboPrefixes.Changed += UpdateVersionsCombo;
            _buttonSave.Clicked    += OnSaveClicked;

            var index = prefixes.ToList().FindIndex(p => p.Id == profileData.FullVersion.Prefix);

            if (index >= 0 && index < _prefixes.Length)
            {
                _comboPrefixes.Active = index;
                _comboVersions.Active = Array.IndexOf(prefixes[index].Versions, profileData.FullVersion.Version);
            }

            _buttonJavaPath.SelectFilename(profileData.CustomJavaPath);
            _entryJavaArgs.Text = profileData.CustomJavaArgs;

            _toggleJavaPath.Active    = profileData.UseCustomJavaPath;
            _buttonJavaPath.Sensitive = profileData.UseCustomJavaPath;

            _toggleJavaArgs.Active   = profileData.UseCustomJavaArgs;
            _entryJavaArgs.Sensitive = profileData.UseCustomJavaArgs;

            _toggleJavaPath.Toggled += (s, a) => _buttonJavaPath.Sensitive = _toggleJavaPath.Active;
            _toggleJavaArgs.Toggled += (s, a) => _entryJavaArgs.Sensitive = _toggleJavaArgs.Active;
        }
コード例 #23
0
        private void UpdateVersionsCombo(object sender, EventArgs e)
        {
            _comboVersions.RemoveAll();

            var index = _comboPrefixes.Active;

            if (index < 0 || index >= _prefixes.Length)
            {
                return;
            }

            var prefix = _prefixes[index];

            foreach (var version in prefix.Versions)
            {
                _comboVersions.AppendText(version);
            }

            _comboVersions.Active = Array.IndexOf(prefix.Versions, prefix.LatestVersion);
        }
コード例 #24
0
        public TimeSpanQueryValueEntry() : base()
        {
            spin_button            = new SpinButton(0.0, 1.0, 1.0);
            spin_button.Digits     = 1;
            spin_button.WidthChars = 4;
            spin_button.SetRange(0.0, Double.MaxValue);
            Add(spin_button);

            combo = new ComboBoxText();
            combo.AppendText(Catalog.GetString("seconds"));
            combo.AppendText(Catalog.GetString("minutes"));
            combo.AppendText(Catalog.GetString("hours"));
            combo.AppendText(Catalog.GetString("days"));
            combo.AppendText(Catalog.GetString("weeks"));
            combo.AppendText(Catalog.GetString("months"));
            combo.AppendText(Catalog.GetString("years"));
            combo.Realized += delegate { combo.Active = set_combo; };
            Add(combo);

            spin_button.ValueChanged += HandleValueChanged;
            combo.Changed            += HandleValueChanged;
        }
コード例 #25
0
        public PlaylistQueryValueEntry() : base()
        {
            combo = new ComboBoxText();
            combo.WidthRequest = DefaultWidth;

            int            count = 0;
            PlaylistSource playlist;

            foreach (Source child in ServiceManager.SourceManager.DefaultSource.Children)
            {
                playlist = child as PlaylistSource;
                if (playlist != null && playlist.DbId != null)
                {
                    combo.AppendText(playlist.Name);
                    playlist_id_combo_map [(int)playlist.DbId] = count;
                    combo_playlist_id_map [count++]            = (int)playlist.DbId;
                }
            }

            Add(combo);
            combo.Active = 0;

            combo.Changed += HandleValueChanged;
        }
コード例 #26
0
        private void Build()
        {
            WindowPosition = WindowPosition.CenterOnParent;
            Resizable      = false;

            const int spacing = 6;
            var       hbox1   = new HBox()
            {
                Spacing = spacing
            };

            hbox1.PackStart(new Label(Translations.GetString("Transfer Map")), false, false, 0);
            hbox1.PackStart(new HSeparator(), true, true, 0);
            ContentArea.PackStart(hbox1, false, false, 0);

            var hbox2 = new HBox()
            {
                Spacing = spacing
            };

            comboMap = new ComboBoxText();
            comboMap.AppendText(Translations.GetString("RGB"));
            comboMap.AppendText(Translations.GetString("Luminosity"));
            comboMap.Active = 1;
            hbox2.PackStart(comboMap, false, false, 0);

            labelPoint = new Label("(256, 256)");
            var labelAlign = new Alignment(1, 0.5f, 1, 0);

            labelAlign.Add(labelPoint);
            hbox2.PackEnd(labelAlign, false, false, 0);
            ContentArea.PackStart(hbox2, false, false, 0);

            drawing = new DrawingArea()
            {
                WidthRequest  = 256,
                HeightRequest = 256,
                Events        = (Gdk.EventMask) 795646,
                CanFocus      = true
            };
            ContentArea.PackStart(drawing, false, false, 8);

            var hbox3 = new HBox();

            checkRed = new CheckButton(Translations.GetString("Red  "))
            {
                Active = true
            };
            checkGreen = new CheckButton(Translations.GetString("Green"))
            {
                Active = true
            };
            checkBlue = new CheckButton(Translations.GetString("Blue "))
            {
                Active = true
            };
            hbox3.PackStart(checkRed, false, false, 0);
            hbox3.PackStart(checkGreen, false, false, 0);
            hbox3.PackStart(checkBlue, false, false, 0);

            buttonReset = new Button()
            {
                WidthRequest  = 81,
                HeightRequest = 30,
                Label         = Translations.GetString("Reset")
            };
            hbox3.PackEnd(buttonReset, false, false, 0);
            ContentArea.PackStart(hbox3, false, false, 0);

            labelTip = new Label(Translations.GetString("Tip: Right-click to remove control points."));
            ContentArea.PackStart(labelTip, false, false, 0);

            ContentArea.ShowAll();
            checkRed.Hide();
            checkGreen.Hide();
            checkBlue.Hide();
        }
コード例 #27
0
        public void InitializeDialog()
        {
            FillGenreList();

            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Title           = String.Empty;
            SkipTaskbarHint = true;

            BorderWidth     = 6;
            DefaultResponse = ResponseType.Ok;

            ContentArea.Spacing = 6;

            HBox split_box = new HBox();

            split_box.Spacing     = 12;
            split_box.BorderWidth = 6;

            Image image = new Image();

            image.IconSize = (int)IconSize.Dialog;
            image.IconName = "radio";
            image.Yalign   = 0.0f;
            image.Show();

            VBox main_box = new VBox();

            main_box.BorderWidth = 5;
            main_box.Spacing     = 10;

            Label header = new Label();

            header.Text = String.Format(AddinManager.CurrentLocalizer.GetString("{0}Radiostation fetcher{1}\n({2})"),
                                        "<span weight=\"bold\" size=\"larger\">", "</span>", source_name);
            header.Xalign    = 0.0f;
            header.Yalign    = 0.0f;
            header.UseMarkup = true;
            header.Wrap      = true;
            header.Show();

            Label message = new Label();

            message.Text = AddinManager.CurrentLocalizer.GetString("Choose a genre or enter a text that you wish to be queried, " +
                                                                   "then press the Get stations button. Found stations will be added to internet-radio source.");
            message.Xalign = 0.0f;
            message.Wrap   = true;
            message.Show();

            table               = new Table(5, 2, false);
            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            genre_entry    = new ComboBoxText();
            freeText_entry = new Entry();

            genre_button    = new Button(AddinManager.CurrentLocalizer.GetString("Get stations"));
            freeText_button = new Button(AddinManager.CurrentLocalizer.GetString("Get stations"));

            genre_button.CanDefault = true;
            genre_button.UseStock   = true;
            genre_button.Clicked   += OnGenreQueryButtonClick;
            genre_button.Show();


            freeText_button.CanDefault = true;
            freeText_button.UseStock   = true;
            freeText_button.Clicked   += OnFreetextQueryButtonClick;
            freeText_button.Show();

            foreach (string genre in genre_list)
            {
                if (!String.IsNullOrEmpty(genre))
                {
                    genre_entry.AppendText(genre);
                }
            }

            if (this is IGenreSearchable)
            {
                AddRow(AddinManager.CurrentLocalizer.GetString("Query by genre:"), genre_entry, genre_button);
            }

            if (this is IFreetextSearchable)
            {
                AddRow(AddinManager.CurrentLocalizer.GetString("Query by free text:"), freeText_entry, freeText_button);
            }

            table.ShowAll();

            main_box.PackStart(header, false, false, 0);
            main_box.PackStart(message, false, false, 0);
            main_box.PackStart(table, false, false, 0);
            main_box.Show();

            split_box.PackStart(image, false, false, 0);
            split_box.PackStart(main_box, true, true, 0);
            split_box.Show();

            ContentArea.PackStart(split_box, true, true, 0);

            close_button            = new Button();
            close_button.Image      = new Image("gtk-close", IconSize.Button);
            close_button.Label      = AddinManager.CurrentLocalizer.GetString("_Close");
            close_button.CanDefault = true;
            close_button.UseStock   = true;
            close_button.Show();
            AddActionWidget(close_button, ResponseType.Close);

            close_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                        0, Gtk.AccelFlags.Visible);

            close_button.Clicked += OnCloseButtonClick;

            statusbar = new Statusbar();
            SetStatusBarMessage(source_name);
            main_box.PackEnd(statusbar, false, false, 0);
        }
コード例 #28
0
        public StationEditor(DatabaseTrackInfo track) : base()
        {
            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Title           = String.Empty;
            SkipTaskbarHint = true;
            Modal           = true;

            this.track = track;

            string title = track == null
                ? Catalog.GetString("Add new radio station")
                : Catalog.GetString("Edit radio station");

            BorderWidth     = 6;
            DefaultResponse = ResponseType.Ok;
            Modal           = true;

            ContentArea.Spacing = 6;

            HBox split_box = new HBox();

            split_box.Spacing     = 12;
            split_box.BorderWidth = 6;

            Image image = new Image();

            image.IconSize = (int)IconSize.Dialog;
            image.IconName = "radio";
            image.Yalign   = 0.0f;
            image.Show();

            VBox main_box = new VBox();

            main_box.BorderWidth = 5;
            main_box.Spacing     = 10;

            Label header = new Label();

            header.Markup = String.Format("<big><b>{0}</b></big>", GLib.Markup.EscapeText(title));
            header.Xalign = 0.0f;
            header.Show();

            Label message = new Label();

            message.Text   = Catalog.GetString("Enter the Genre, Title and URL of the radio station you wish to add. A description is optional.");
            message.Xalign = 0.0f;
            message.Wrap   = true;
            message.Show();

            table               = new Table(5, 2, false);
            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            genre_entry = ComboBoxText.NewWithEntry();

            foreach (string genre in ServiceManager.DbConnection.QueryEnumerable <string> ("SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre"))
            {
                if (!String.IsNullOrEmpty(genre))
                {
                    genre_entry.AppendText(genre);
                }
            }

            if (track != null && !String.IsNullOrEmpty(track.Genre))
            {
                genre_entry.Entry.Text = track.Genre;
            }

            AddRow(Catalog.GetString("Station Genre:"), genre_entry);

            name_entry        = AddEntryRow(Catalog.GetString("Station Name:"));
            stream_entry      = AddEntryRow(Catalog.GetString("Stream URL:"));
            creator_entry     = AddEntryRow(Catalog.GetString("Station Creator:"));
            description_entry = AddEntryRow(Catalog.GetString("Description:"));

            rating_entry = new RatingEntry();
            HBox rating_box = new HBox();

            rating_box.PackStart(rating_entry, false, false, 0);
            AddRow(Catalog.GetString("Rating:"), rating_box);

            table.ShowAll();

            main_box.PackStart(header, false, false, 0);
            main_box.PackStart(message, false, false, 0);
            main_box.PackStart(table, false, false, 0);
            main_box.Show();

            split_box.PackStart(image, false, false, 0);
            split_box.PackStart(main_box, true, true, 0);
            split_box.Show();

            ContentArea.PackStart(split_box, true, true, 0);

            Button cancel_button = new Button(Stock.Cancel);

            cancel_button.CanDefault = false;
            cancel_button.UseStock   = true;
            cancel_button.Show();
            AddActionWidget(cancel_button, ResponseType.Close);

            cancel_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                         0, Gtk.AccelFlags.Visible);

            save_button            = new Button(Stock.Save);
            save_button.CanDefault = true;
            save_button.UseStock   = true;
            save_button.Sensitive  = false;
            save_button.Show();
            AddActionWidget(save_button, ResponseType.Ok);

            save_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                       0, Gtk.AccelFlags.Visible);

            name_entry.HasFocus = true;

            if (track != null)
            {
                if (!String.IsNullOrEmpty(track.TrackTitle))
                {
                    name_entry.Text = track.TrackTitle;
                }

                if (!String.IsNullOrEmpty(track.Uri.AbsoluteUri))
                {
                    stream_entry.Text = track.Uri.AbsoluteUri;
                }

                if (!String.IsNullOrEmpty(track.Comment))
                {
                    description_entry.Text = track.Comment;
                }

                if (!String.IsNullOrEmpty(track.ArtistName))
                {
                    creator_entry.Text = track.ArtistName;
                }

                rating_entry.Value = track.Rating;
            }

            error_container            = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            error_container.TopPadding = 6;
            HBox error_box = new HBox();

            error_box.Spacing = 4;

            Image error_image = new Image();

            error_image.Stock    = Stock.DialogError;
            error_image.IconSize = (int)IconSize.Menu;
            error_image.Show();

            error        = new Label();
            error.Xalign = 0.0f;
            error.Show();

            error_box.PackStart(error_image, false, false, 0);
            error_box.PackStart(error, true, true, 0);
            error_box.Show();

            error_container.Add(error_box);

            table.Attach(error_container, 0, 2, 6, 7, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

            genre_entry.Entry.Changed += OnFieldsChanged;
            name_entry.Changed        += OnFieldsChanged;
            stream_entry.Changed      += OnFieldsChanged;

            OnFieldsChanged(this, EventArgs.Empty);
        }
コード例 #29
0
        public AddinView()
        {
            var hbox = new HBox()
            {
                Spacing = 6
            };

            var filter_label = new Label(Catalog.GetString("Show:"));
            var filter_combo = new ComboBoxText();

            filter_combo.AppendText(Catalog.GetString("All"));
            filter_combo.AppendText(Catalog.GetString("Enabled"));
            filter_combo.AppendText(Catalog.GetString("Not Enabled"));
            filter_combo.Active = 0;

            var search_label = new Label(Catalog.GetString("Search:"));
            var search_entry = new Banshee.Widgets.SearchEntry()
            {
                WidthRequest = 160,
                Visible      = true,
                Ready        = true
            };

            hbox.PackStart(filter_label, false, false, 0);
            hbox.PackStart(filter_combo, false, false, 0);
            hbox.PackEnd(search_entry, false, false, 0);
            hbox.PackEnd(search_label, false, false, 0);

            var model = new TreeStore(typeof(bool), typeof(bool), typeof(string), typeof(Addin));

            var addins = AddinManager.Registry.GetAddins().Where(a => { return
                                                                        (a.Name != a.Id && a.Description != null &&
                                                                         !String.IsNullOrEmpty(a.Description.Category) && !a.Description.Category.StartsWith("required:") &&
                                                                         (!a.Description.Category.Contains("Debug") || ApplicationContext.Debugging)); });

            var categorized_addins = addins.GroupBy <Addin, string> (a => a.Description.Category)
                                     .Select(c => new {
                Addins        = c.OrderBy(a => Catalog.GetString(a.Name)).ToList(),
                Name          = c.Key,
                NameLocalized = Catalog.GetString(c.Key)
            })
                                     .OrderBy(c => c.NameLocalized)
                                     .ToList();

            tree_view = new TreeView()
            {
                FixedHeightMode = false,
                HeadersVisible  = false,
                SearchColumn    = 1,
                RulesHint       = true,
                Model           = model
            };

            var update_model = new System.Action(() => {
                string search = search_entry.Query;
                bool?enabled  = filter_combo.Active > 0 ? (bool?)(filter_combo.Active == 1 ? true : false) : null;
                model.Clear();
                foreach (var cat in categorized_addins)
                {
                    var cat_iter = model.AppendValues(false, false, String.Format("<b>{0}</b>", GLib.Markup.EscapeText(cat.NameLocalized)), null);
                    bool any     = false;
                    foreach (var a in cat.Addins.Matching(search))
                    {
                        if (enabled == null || (a.Enabled == enabled.Value))
                        {
                            model.AppendValues(cat_iter, true,
                                               a.Enabled,
                                               String.Format(
                                                   "<b>{0}</b>\n<small>{1}</small>",
                                                   GLib.Markup.EscapeText(Catalog.GetString(a.Name)),
                                                   GLib.Markup.EscapeText(Catalog.GetString(a.Description.Description))),
                                               a
                                               );
                            any = true;
                        }
                    }

                    if (!any)
                    {
                        model.Remove(ref cat_iter);
                    }
                }
                tree_view.ExpandAll();
            });

            var txt_cell = new CellRendererText()
            {
                WrapMode = Pango.WrapMode.Word
            };

            tree_view.AppendColumn("Name", txt_cell, "markup", Columns.Name);

            var check_cell = new CellRendererToggle()
            {
                Activatable = true
            };

            tree_view.AppendColumn("Enable", check_cell, "visible", Columns.IsAddin, "active", Columns.IsEnabled);
            check_cell.Toggled += (o, a) => {
                TreeIter iter;
                if (model.GetIter(out iter, new TreePath(a.Path)))
                {
                    var  addin   = model.GetValue(iter, 3) as Addin;
                    bool enabled = (bool)model.GetValue(iter, 1);
                    addin.Enabled = !enabled;
                    model.SetValue(iter, 1, addin.Enabled);
                    model.Foreach(delegate(ITreeModel current_model, TreePath path, TreeIter current_iter) {
                        var an = current_model.GetValue(current_iter, 3) as Addin;
                        if (an != null)
                        {
                            current_model.SetValue(current_iter, 1, an.Enabled);
                        }
                        return(false);
                    });
                }
            };

            update_model();
            search_entry.Changed += (o, a) => update_model();
            filter_combo.Changed += (o, a) => update_model();

            var tree_scroll = new Hyena.Widgets.ScrolledWindow()
            {
                HscrollbarPolicy = PolicyType.Never
            };

            tree_scroll.AddWithFrame(tree_view);

            Spacing = 6;
            PackStart(hbox, false, false, 0);
            PackStart(tree_scroll, true, true, 0);
            ShowAll();
            search_entry.GrabFocus();

            txt_cell.WrapWidth = 300;
        }
コード例 #30
0
ファイル: DetailsView.cs プロジェクト: thoja21/banshee-1
        private void BuildFilesBox()
        {
            var vbox = new VBox();

            vbox.Spacing = 6;

            var file_list = new BaseTrackListView()
            {
                HeaderVisible     = true,
                IsEverReorderable = false
            };

            var files_model = source.TrackModel as MemoryTrackListModel;
            var columns     = new DefaultColumnController();

            columns.TrackColumn.Title = "#";
            var file_columns = new ColumnController();

            file_columns.AddRange(
                columns.IndicatorColumn,
                columns.TrackColumn,
                columns.TitleColumn,
                columns.DurationColumn,
                columns.FileSizeColumn
                );

            foreach (var col in file_columns)
            {
                col.Visible = true;
            }

            var file_sw = new Gtk.ScrolledWindow();

            file_sw.Child = file_list;

            var tracks = new List <TrackInfo> ();

            var files = new List <IA.DetailsFile> (details.Files);

            string [] format_blacklist = new string [] { "metadata", "fingerprint", "checksums", "xml", "m3u", "dublin core", "unknown" };
            var       formats          = new List <string> ();

            foreach (var f in files)
            {
                var track = new TrackInfo()
                {
                    Uri         = new SafeUri(f.Location),
                    FileSize    = f.Size,
                    TrackNumber = f.Track,
                    ArtistName  = f.Creator ?? details.Creator,
                    AlbumTitle  = item.Title,
                    TrackTitle  = f.Title,
                    BitRate     = f.BitRate,
                    MimeType    = f.Format,
                    Duration    = f.Length
                };

                // Fix up duration/track#/title
                if ((f.Length == TimeSpan.Zero || f.Title == null || f.Track == 0) && !f.Location.Contains("zip") && !f.Location.EndsWith("m3u"))
                {
                    foreach (var b in files)
                    {
                        if ((f.Title != null && f.Title == b.Title) ||
                            (f.OriginalFile != null && b.Location != null && b.Location.EndsWith(f.OriginalFile)) ||
                            (f.OriginalFile != null && f.OriginalFile == b.OriginalFile))
                        {
                            if (track.Duration == TimeSpan.Zero)
                            {
                                track.Duration = b.Length;
                            }

                            if (track.TrackTitle == null)
                            {
                                track.TrackTitle = b.Title;
                            }

                            if (track.TrackNumber == 0)
                            {
                                track.TrackNumber = b.Track;
                            }

                            if (track.Duration != TimeSpan.Zero && track.TrackTitle != null && track.TrackNumber != 0)
                            {
                                break;
                            }
                        }
                    }
                }

                track.TrackTitle = track.TrackTitle ?? System.IO.Path.GetFileName(f.Location);

                tracks.Add(track);

                if (f.Format != null && !formats.Contains(f.Format))
                {
                    if (!format_blacklist.Any(fmt => f.Format.ToLower().Contains(fmt)))
                    {
                        formats.Add(f.Format);
                    }
                }
            }

            // Order the formats according to the preferences
            string format_order = String.Format(", {0}, {1}, {2},", HomeSource.VideoTypes.Get(), HomeSource.AudioTypes.Get(), HomeSource.TextTypes.Get()).ToLower();

            var sorted_formats = formats.Select(f => new { Format = f, Order = Math.Max(format_order.IndexOf(", " + f.ToLower() + ","), format_order.IndexOf(f.ToLower())) })
                                 .OrderBy(o => o.Order == -1 ? Int32.MaxValue : o.Order);

            // See if all the files contain their track #
            bool all_tracks_have_num_in_title = tracks.All(t => t.TrackNumber == 0 || t.TrackTitle.Contains(t.TrackNumber.ToString()));

            // Make these columns snugly fix their data
            if (tracks.Count > 0)
            {
                // Mono in openSUSE 11.0 doesn't like this
                //SetWidth (columns.TrackColumn,    all_tracks_have_num_in_title ? 0 : tracks.Max (f => f.TrackNumber), 0);
                int  max_track = 0;
                long max_size  = 0;
                foreach (var t in tracks)
                {
                    max_track = Math.Max(max_track, t.TrackNumber);
                    max_size  = Math.Max(max_size, t.FileSize);
                }
                SetWidth(columns.TrackColumn, all_tracks_have_num_in_title ? 0 : max_track, 0);

                // Mono in openSUSE 11.0 doesn't like this
                //SetWidth (columns.FileSizeColumn, tracks.Max (f => f.FileSize), 0);
                SetWidth(columns.FileSizeColumn, max_size, 0);
                SetWidth(columns.DurationColumn, tracks.Max(f => f.Duration), TimeSpan.Zero);
            }

            string max_title = "     ";

            if (tracks.Count > 0)
            {
                var sorted_by_title = files.Where(t => !t.Location.Contains("zip"))
                                      .OrderBy(f => f.Title == null ? 0 : f.Title.Length)
                                      .ToList();
                string nine_tenths = sorted_by_title[(int)Math.Floor(.90 * sorted_by_title.Count)].Title ?? "";
                string max         = sorted_by_title[sorted_by_title.Count - 1].Title ?? "";
                max_title = ((double)max.Length >= (double)(1.6 * (double)nine_tenths.Length)) ? nine_tenths : max;
            }
            (columns.TitleColumn.GetCell(0) as ColumnCellText).SetMinMaxStrings(max_title);

            file_list.ColumnController = file_columns;
            file_list.SetModel(files_model);

            var format_list = new ComboBoxText();

            format_list.RowSeparatorFunc = (model, iter) => {
                return((string)model.GetValue(iter, 0) == "---");
            };

            bool have_sep      = false;
            int  active_format = 0;

            foreach (var fmt in sorted_formats)
            {
                if (fmt.Order == -1 && !have_sep)
                {
                    have_sep = true;
                    if (format_list.Model.IterNChildren() > 0)
                    {
                        format_list.AppendText("---");
                    }
                }

                format_list.AppendText(fmt.Format);

                if (active_format == 0 && fmt.Format == item.SelectedFormat)
                {
                    active_format = format_list.Model.IterNChildren() - 1;
                }
            }

            format_list.Changed += (o, a) => {
                files_model.Clear();

                var selected_fmt = format_list.ActiveText;
                foreach (var track in tracks)
                {
                    if (track.MimeType == selected_fmt)
                    {
                        files_model.Add(track);
                    }
                }

                files_model.Reload();

                item.SelectedFormat = selected_fmt;
                item.Save();
            };

            if (formats.Count > 0)
            {
                format_list.Active = active_format;
            }

            vbox.PackStart(file_sw, true, true, 0);
            vbox.PackStart(format_list, false, false, 0);

            file_list.SizeAllocated += (o, a) => {
                int target_list_width = file_list.MaxWidth;
                if (file_sw.VScrollbar != null && file_sw.VScrollbar.IsMapped)
                {
                    target_list_width += file_sw.VScrollbar.Allocation.Width + 2;
                }

                // Don't let the track list be too wide
                target_list_width = Math.Min(target_list_width, (int)(0.5 * (double)Allocation.Width));

                if (a.Allocation.Width != target_list_width && target_list_width > 0)
                {
                    file_sw.SetSizeRequest(target_list_width, -1);
                }
            };

            PackStart(vbox, false, false, 0);
        }