Example #1
0
        public void ReloadProfiles()
        {
            Profile  active_profile = ActiveProfile;
            TreeIter active_iter;

            store.Clear();

            List <Profile> mimetype_profiles = null;

            if (mimetype_filter != null && mimetype_filter.Length > 0)
            {
                mimetype_profiles = new List <Profile>();
                foreach (string mimetype in mimetype_filter)
                {
                    Profile profile = manager.GetProfileForMimeType(mimetype);
                    if (profile != null && !mimetype_profiles.Contains(profile))
                    {
                        mimetype_profiles.Add(profile);
                    }
                }
            }

            if (manager.AvailableProfileCount == 0 || (mimetype_profiles != null &&
                                                       mimetype_profiles.Count == 0 && mimetype_filter != null))
            {
                store.AppendValues(Catalog.GetString("No available profiles"), null);
                Sensitive = false;
            }
            else
            {
                Sensitive = true;
            }

            if (mimetype_profiles != null)
            {
                foreach (Profile profile in mimetype_profiles)
                {
                    store.AppendValues(String.Format("{0}", profile.Name), profile);
                }
            }
            else
            {
                foreach (Profile profile in manager.GetAvailableProfiles())
                {
                    store.AppendValues(String.Format("{0}", profile.Name), profile);
                }
            }

            if (store.IterNthChild(out active_iter, 0))
            {
                SetActiveIter(active_iter);
            }
            ActiveProfile = active_profile;
        }
        public bool ActivateFirstEqualizer()
        {
            TreeIter iter;

            if (store.IterNthChild(out iter, 0))
            {
                ActiveEqualizer = GetEqualizerSettingForIter(iter);
                return(true);
            }

            return(false);
        }
Example #3
0
    protected virtual void AddLineButton(object sender, System.EventArgs e)
    {
        int      page = 0;
        TreeIter lastItem;
        bool     got = tModel.IterNthChild(out lastItem, tModel.IterNChildren() - 1);

        if (got)
        {
            page = (int)tModel.GetValue(lastItem, (int)Columns.COL_PAGE);
        }

        TreeIter iter = tModel.AppendValues(CatalogueParser.GetInstance().UpdateHighestID(),
                                            "Test", page, true);

        mainTreeView.ScrollToCell(tModel.GetPath(iter),
                                  mainTreeView.GetColumn((int)Columns.COL_TITLE),
                                  true, .0F, .0F);
    }
        private void OnControllerTokenMatchingFinished(object sender,
                                                       TokenMatchingFinishedArgs _args)
        {
            Application.Invoke(sender,
                               _args,
                               delegate(object resender, EventArgs a)
            {
                TokenMatchingFinishedArgs args = (TokenMatchingFinishedArgs)a;

                string tokenType = args.ExpectedType;

                if (args.MatchedToken != null)
                {
                    int idx = SearchToken(args.MatchedToken);
                    remainingItemsStore.IterNthChild(out selectedRemainingItem,
                                                     idx);
                    TreePath selectedPath =
                        remainingItemsStore.GetPath(selectedRemainingItem);

                    remainingItemsIconView.SelectPath(selectedPath);
                    remainingItemsIconView.ScrollToPath(selectedPath, 0.5f, 0f);

                    this.MarkImage(args.MatchedToken);

                    parsingTaskLabel.Markup =
                        String.Format("<b>Se encontró un item válido del tipo <i>{0}</i>, <i>{1}</i> entre los items restantes</b>",
                                      GLib.Markup.EscapeText(tokenType),
                                      GLib.Markup.EscapeText(args.MatchedToken.Text));

                    currentNode.AddMatchedToken(args.MatchedToken);
                    currentNode.Select();

                    remainingItemsStore.Remove(ref selectedRemainingItem);

                    TreeIter first;
                    if (remainingItemsStore.GetIterFirst(out first))
                    {
                        remainingItemsIconView.ScrollToPath(remainingItemsStore.GetPath(first));
                    }
                }
                else
                {
                    parsingTaskLabel.Markup =
                        String.Format("<b>No se encotró un item válido del tipo <i>{0}</i> entre los items restantes</b>",
                                      GLib.Markup.EscapeText(tokenType));
                }

                if (controller.StepMode != ControllerStepMode.UntilEnd)
                {
                    parsingNextButtonsAlign.Sensitive = true;
                }
            });
        }
Example #5
0
    protected void HandlePlayerButton(string playerId, int button)
    {
        int  playerIndex = -1;
        bool playerAdded = false;

        // Check if player is already registered
        lock (playerIds)
        {
            if (playerIds.Contains(playerId))
            {
                playerIndex = playerIds.IndexOf(playerId);
            }
            else
            {
                playerIds.Add(playerId);
                playerIndex = playerIds.Count - 1;
                playerAdded = true;
            }
        }

        if (playerAdded)
        {
            // Add player to store
            Application.Invoke(delegate
            {
                playerStore.AppendValues(playerId, GetPlayerString(playerId, button),
                                         Images.GetPlayerImage(playerIndex));
            });
        }
        else
        {
            // Send button press to clients
            HITTServer.SendToAll(new byte[] { (byte)playerIndex, (byte)button });

            if (!isInGame)
            {
                // Update players display
                Application.Invoke(delegate
                {
                    TreeIter iter;

                    if (playerStore.IterNthChild(out iter, playerIndex))
                    {
                        playerStore.SetValue(iter, 1, GetPlayerString(playerId, button));
                    }
                });
            }
        }
    }
Example #6
0
        void OnButtonUpClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            dirList.Selection.GetSelected(out it);
            string   dir     = (string)store.GetValue(it, 0);
            int      i       = directories.IndexOf(dir);
            string   prevDir = directories [i - 1];
            TreeIter pi;

            store.IterNthChild(out pi, i - 1);
            store.SetValue(pi, 0, dir);
            store.SetValue(it, 0, prevDir);
            directories [i - 1] = dir;
            directories [i]     = prevDir;
            FocusRow(pi);
        }
Example #7
0
        void UpdateDefaultProject()
        {
            int selectedIndex = projectsComboBox.Active;

            if (selectedIndex < 0)
            {
                viewModel.DefaultProject = null;
                return;
            }

            TreeIter iter;

            projectListStore.IterNthChild(out iter, selectedIndex);
            var project = (Project)projectListStore.GetValue(iter, 1);

            viewModel.DefaultProject = project;
        }
Example #8
0
        public TreePath encontrarCaminhoPorNome(NodeView lvTabela, string nome)
        {
            string    slinha;
            ListStore lstore = (ListStore)lvTabela.Model;
            TreePath  path   = null;
            TreeIter  iter;

            for (int i = 0; i < lstore.IterNChildren(); i++)
            {
                lstore.IterNthChild(out iter, i);
                slinha = (string)lstore.GetValue(iter, 1);

                if (slinha.Equals(nome))
                {
                    path = lstore.GetPath(iter);
                    break;
                }
            }

            return(path);
        }
Example #9
0
        private TreeIter IterFor(T val)
        {
            if (val == null)
            {
                return(TreeIter.Zero);
            }

            for (int i = 0, n = store.IterNChildren(); i < n; i++)
            {
                TreeIter iter;
                if (store.IterNthChild(out iter, i))
                {
                    T compare = (T)store.GetValue(iter, 1);
                    if (val.Equals(compare))
                    {
                        return(iter);
                    }
                }
            }

            return(TreeIter.Zero);
        }
        private Widget BuildCombo(PipelineVariable variable)
        {
            ListStore model = new ListStore(typeof(string), typeof(string));
            PipelineVariableComboBox box = new PipelineVariableComboBox(variable, model);
            TreeIter active_iter         = TreeIter.Zero;

            box.Changed += OnComboChanged;

            if (variable.PossibleValuesCount > 0)
            {
                foreach (string key in variable.PossibleValuesKeys)
                {
                    TreeIter iter = ComboAppend(model, variable, variable.PossibleValues[key].Display, key);

                    if (variable.CurrentValue == key || (active_iter.Equals(TreeIter.Zero) &&
                                                         variable.DefaultValue == key))
                    {
                        active_iter = iter;
                    }
                }
            }
            else
            {
                double min     = variable.MinValue;
                double max     = variable.MaxValue;
                double step    = variable.StepValue;
                double current = min;

                for (; current <= max; current += step)
                {
                    ComboAppend(model, variable, current.ToString(), current.ToString());
                }
            }

            if (active_iter.Equals(TreeIter.Zero))
            {
                for (int i = 0, n = model.IterNChildren(); i < n; i++)
                {
                    TreeIter iter;
                    if (model.IterNthChild(out iter, i))
                    {
                        string value = (string)model.GetValue(iter, 1);
                        if (value == variable.CurrentValue)
                        {
                            active_iter = iter;
                            break;
                        }
                    }
                }
            }

            CellRendererText text_renderer = new CellRendererText();

            box.PackStart(text_renderer, true);
            box.AddAttribute(text_renderer, "text", 0);

            box.Model = model;

            if (active_iter.Equals(TreeIter.Zero))
            {
                if (model.IterNthChild(out active_iter, 0))
                {
                    box.SetActiveIter(active_iter);
                }
            }
            else
            {
                box.SetActiveIter(active_iter);
            }

            return(box);
        }
Example #11
0
        void OnDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Console.WriteLine("OnDragDataReceived: {0}", (TargetType)args.Info);
            Console.WriteLine("Position: {0} {1}", args.X, args.Y);
            switch ((TargetType)args.Info)
            {
            case TargetType.Text:
                // preprocess input string...
                String        input  = Encoding.UTF8.GetString(args.SelectionData.Data).Trim();
                string[]      words  = input.Split('\n');
                List <string> nwords = new List <string>();
                foreach (string word in words)
                {
                    String nword = word;
                    // let's just ignore anything that's not a zip or jar
                    if (!word.ToLower().Contains(".jar") && !word.ToLower().Contains(".zip"))
                    {
                        continue;
                    }
                    // trim nonsense
                    if (word.StartsWith("file://"))
                    {
                        nword = nword.Substring(7);
                    }
                    nwords.Add(nword);
                }
                // filtered away everything... just stop.
                if (nwords.Count == 0)
                {
                    return;
                }
                // if the drop target is the jar list
                if (o == jarModList)
                {
                    TreePath             path;
                    TreeIter             iter;
                    TreeViewDropPosition droppos;
                    jarModList.GetDestRowAtPos(args.X, args.Y, out path, out droppos);
                    jarModList.Model.GetIter(out iter, path);
                    if (path != null)
                    {
                        Console.WriteLine("Got position ;) " + path.Indices[0]);
                        switch (droppos)
                        {
                        case TreeViewDropPosition.Before:
                        case TreeViewDropPosition.IntoOrBefore:
                            AddJarMods(nwords.ToArray(), path.Indices[0]);
                            break;

                        case TreeViewDropPosition.After:
                        case TreeViewDropPosition.IntoOrAfter:
                            AddJarMods(nwords.ToArray(), path.Indices[0] + 1);
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Indeterminate position... ");
                        AddJarMods(nwords.ToArray(), -1);
                    }
                }
                // if it's the modloader list
                else if (o == mlModList)
                {
                    AddMLMods(nwords.ToArray());
                }
                break;

            // let's hope this never happens, because it sure doesn't happen here. :whistles:
            case TargetType.Uri:
                foreach (string uri in Encoding.UTF8.GetString(args.SelectionData.Data).Trim().Split('\n'))
                {
                    Console.WriteLine("Uri: {0}", Uri.UnescapeDataString(uri));
                }
                break;

            // Handle reorder events inside the list.
            // This is only needed because the Reorderable property stops working
            // when you use custom drag&drop handling
            case TargetType.Movement:
                if (o == jarModList)
                {
                    TreePath             path;
                    TreeIter             srcIter;
                    TreeIter             destIter;
                    TreeViewDropPosition droppos;
                    jarModList.GetDestRowAtPos(args.X, args.Y, out path, out droppos);
                    String sourceStr = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);
                    int    sourceInt = int.Parse(sourceStr);
                    int    destInt   = -1;
                    modStore.IterNthChild(out srcIter, sourceInt);
                    if (path != null)
                    {
                        jarModList.Model.GetIter(out destIter, path);
                        destInt = path.Indices[0];
                        switch (droppos)
                        {
                        case TreeViewDropPosition.Before:
                        case TreeViewDropPosition.IntoOrBefore:
                            modStore.MoveBefore(srcIter, destIter);
                            break;

                        case TreeViewDropPosition.After:
                        case TreeViewDropPosition.IntoOrAfter:
                            modStore.MoveAfter(srcIter, destIter);
                            break;
                        }

                        Console.WriteLine("Moving something!: from {0} to {1}", sourceInt, destInt);
                    }
                    else
                    {
                        // HACK : this is needed becuase of a GTK# API bug.
                        // See: http://mono.1490590.n4.nabble.com/On-a-ListStore-moving-items-on-the-list-some-questions-td2222829.html
                        TreeIter stDestIter;
                        modStore.GetIterFromString(out stDestIter, (Convert.ToUInt16(modStore.IterNChildren()) - 1).ToString());
                        modStore.MoveAfter(srcIter, stDestIter);
                        Console.WriteLine("Moving something!: from {0} to End", sourceInt);
                    }
                    // mod order most probably did change.
                    changed_mod_order = true;
                }
                break;
            }
            Console.WriteLine();
            bool success = true;

            Gtk.Drag.Finish(args.Context, success, false, args.Time);
        }