AppInfo[] ApplicationsFor(IEnumerable<string> types)
 {
     List<AppInfo> app_infos = new List<AppInfo> ();
     List<string> existing_ids = new List<string> ();
     foreach (string type in types)
         foreach (AppInfo appinfo in AppInfoAdapter.GetAllForType (type)) {
             if (existing_ids.Contains (appinfo.Id))
                 continue;
             if (!appinfo.SupportsUris)
                 continue;
             if (ignore_apps != null && ignore_apps.Contains (appinfo.Executable))
                 continue;
             app_infos.Add (appinfo);
             existing_ids.Add (appinfo.Id);
         }
     return app_infos.ToArray ();
 }
Exemplo n.º 2
0
 public static bool FileIsMpeg(string filepath)
 {
     string extension = Path.GetExtension(filepath).Replace(".", "").ToLower();
     var extensions = new List<string> (MpegRemuxer.EXTENSIONS);
     return extensions.Contains(extension);
 }
        private bool reload_covers()
        {
            if (Timeline != null) {
                Timeline.Pause ();
            }
            HideAll ();
            Show ();
            if (covers != null && covers.Count != 0) {
                Console.WriteLine("ClutterFlow - Reloading Covers");

                // the old current index
                int old_target_index = CurrentCover!=null ? covers.IndexOf (CurrentCover) : 0;
                // the newly calculated index
                int new_target_index = 0;
                // whether or not to keep the current cover centered
                bool keep_current = false;

                List<ClutterFlowBaseActor> old_covers = new List<ClutterFlowBaseActor> (
                    SafeGetRange (covers, old_target_index - HalfVisCovers - 1, visibleCovers + 2));
                foreach (ClutterFlowBaseActor actor in covers) {
                    if (actor.Data.ContainsKey ("isOldCover")) {
                        actor.Data.Remove ("isOldCover");
                    }
                    actor.Index = -1;
                    if (old_covers.Contains (actor)) {
                        actor.Data.Add ("isOldCover", true);
                    }
                }

                ResetLetterLookup ();
                List<ClutterFlowBaseActor> persistent_covers = new List<ClutterFlowBaseActor>();

                covers = actor_loader.GetActors (this);
                covers.ForEach (delegate (ClutterFlowBaseActor actor) {
                    if (actor.Data.ContainsKey ("isOldCover")) {
                        persistent_covers.Add (actor);
                    }
                    if (CurrentCover==actor) {
                        keep_current = true;
                    }

                    UpdateLetterLookup (actor);
                });
                InvokeLetterLookupChanged ();

                if (covers.Count == 0) {
                    InstallEmptyActor ();
                    if (old_covers.Contains (EmptyActor)) {
                        EmptyActor.Show ();
                        return false;
                    }
                    keep_current = true;
                }

                //recalculate timeline progression and the target index
                if (covers.Count > 1) {
                    if (keep_current) {
                        new_target_index = CurrentCover.Index;
                    } else {
                        if (persistent_covers.Count==0) {
                            new_target_index = (int) Math.Round(Timeline.Progress * (covers.Count-1));
                        } else if (persistent_covers.Count==1) {
                            new_target_index = persistent_covers[0].Index;
                        } else {
                            new_target_index = persistent_covers[(int) (((float) persistent_covers.Count * 0.5f) - 1.0f)].Index;
                        }
                    }
                }
                TargetIndex = new_target_index;
                Timeline.JumpToTarget ();

                //Console.WriteLine ("Timeline progress set to " + Timeline.Progress + " Timeline.RelativeTarget is " + Timeline.RelativeTarget);

                List<ClutterFlowBaseActor> truly_pers = new List<ClutterFlowBaseActor> ();
                List<ClutterFlowBaseActor> new_covers = new List<ClutterFlowBaseActor>(SafeGetRange(covers, new_target_index - HalfVisCovers - 1, visibleCovers + 2));
                foreach (ClutterFlowBaseActor actor in persistent_covers) {
                    if (actor != null) {
                        if (actor.Data.ContainsKey ("isOldCover")) {
                            actor.Data.Remove ("isOldCover");
                        }
                        if (new_covers.Contains (actor)) {
                            truly_pers.Add (actor);
                            new_covers.Remove (actor);
                            old_covers.Remove (actor);
                            actor.Show ();
                        }
                    }
                }
                foreach (ClutterFlowBaseActor actor in old_covers) {
                    if (actor != null) {
                        actor.Data.Remove ("isOldCover");
                    }
                }

                /*Console.WriteLine ("old_covers          contains " + old_covers.Count + " elements:");
                foreach (ClutterFlowBaseActor cover in old_covers)
                    Console.WriteLine("\t- " + cover.Label.Replace("\n", " - "));
                Console.WriteLine ("persistent_covers   contains " + truly_pers.Count + " elements");
                foreach (ClutterFlowBaseActor cover in truly_pers)
                    Console.WriteLine("\t- " + cover.Label.Replace("\n", " - "));
                Console.WriteLine ("new_covers          contains " + new_covers.Count + " elements");
                foreach (ClutterFlowBaseActor cover in new_covers)
                    Console.WriteLine("\t- " + cover.Label.Replace("\n", " - "));*/

                System.EventHandler update_target = delegate (object o, System.EventArgs e) {
                    Timeline.Play ();
                    InvokeCoversChanged();
                };

                Behaviour.FadeCoversInAndOut (old_covers, truly_pers, new_covers, update_target);
            } else {
                Console.WriteLine("ClutterFlow - Loading Covers");
                ResetLetterLookup ();
                covers = actor_loader.GetActors (this);
                covers.ForEach (UpdateLetterLookup);
                InvokeLetterLookupChanged ();
                TargetIndex = 0;
                Timeline.JumpToTarget ();
                if (covers==null || covers.Count==0) {
                    InstallEmptyActor ();
                    Behaviour.UpdateActors ();
                    Behaviour.FadeInActor (EmptyActor);
                }
                Timeline.Play ();
                InvokeCoversChanged ();
            }

            return false;
        }
Exemplo n.º 4
0
        public void Show(Connection connection, LdapEntry entry, bool showAll)
        {
            displayAll = showAll;
            conn = connection;
            currentDN = entry.DN;
            currentAttributes = new NameValueCollection ();

            // FIXME: crashes after an apply if I don't re-create the store;
            store = new ListStore (typeof (string), typeof(string));
            store.SetSortColumnId (0, SortType.Ascending);
            tv.Model = store;

            //			store.Clear ();

            allAttrs = new List<string> ();
            LdapAttribute a = entry.getAttribute ("objectClass");

            for (int i = 0; i < a.StringValueArray.Length; i++) {

                string o = (string) a.StringValueArray[i];
                store.AppendValues ("objectClass", o);
                currentAttributes.Add ("objectClass", o);

                string[] attrs = conn.Data.GetAllAttributes (o);
                if (attrs != null) {
                    foreach (string at in attrs)
                        if (!allAttrs.Contains (at))
                            allAttrs.Add (at);
                } else {
                    Log.Debug("Could not retrieve any attribute for objectClass " + o);
                }
            }

            LdapAttributeSet attributeSet = entry.getAttributeSet ();

            // Fedora Directory Server supports an Access Control Item (ACI)
            // but it is not listed as "allowed attribute" for any objectClass
            // found in Fedora's LDAP schema.
            if (showAll && conn.Settings.ServerType == LdapServerType.FedoraDirectory) {
                LdapEntry[] acientries = conn.Data.Search(	currentDN,
                                                        LdapConnection.SCOPE_BASE,
                                                        "objectclass=*",
                                                        new string[] {"aci"} );

                if (acientries.Length > 0) {
                    LdapEntry acientry = acientries[0];
                    LdapAttribute aciattr = acientry.getAttribute("aci");
                    if (aciattr != null)
                        if (attributeSet.Add(aciattr) == false)
                            Log.Debug ("Could not add ACI attribute.");
                }
            }

            foreach (LdapAttribute attr in attributeSet) {

                if (allAttrs.Contains (attr.Name))
                    allAttrs.Remove (attr.Name);

                if (attr.Name.ToLower() == "objectclass")
                    continue;

                try {

                    foreach (string s in attr.StringValueArray) {
                        store.AppendValues (attr.Name, s);
                        currentAttributes.Add (attr.Name, s);
                    }

                } catch (ArgumentOutOfRangeException e) {
                    // FIXME: this only happens with gmcs
                    store.AppendValues (attr.Name, "");
                    Log.Debug ("Show attribute arugment out of range: {0}", attr.Name);
                    Log.Debug (e.Message);
                }
            }

            if (!showAll)
                return;

            foreach (string n in allAttrs)
                store.AppendValues (n, "");
        }