Beispiel #1
0
        public EditPackagesDialog(CProject project)
        {
            this.Build();

            this.project = project;

            selectedPackages.Project = project;
            selectedPackages.AddRange(project.Packages);

            Gtk.CellRendererText textRenderer = new Gtk.CellRendererText();

            CellRendererImage pixbufRenderer = new CellRendererImage();

            pixbufRenderer.StockId = "md-package";

            normalPackageListStore.DefaultSortFunc   = NormalPackageCompareNodes;
            projectPackageListStore.DefaultSortFunc  = ProjectPackageCompareNodes;
            selectedPackageListStore.DefaultSortFunc = SelectedPackageCompareNodes;

            normalPackageListStore.SetSortColumnId(NormalPackageNameID, Gtk.SortType.Ascending);
            projectPackageListStore.SetSortColumnId(ProjectPackageNameID, Gtk.SortType.Ascending);
            selectedPackageListStore.SetSortColumnId(SelectedPackageNameID, Gtk.SortType.Ascending);

            normalPackageTreeView.SearchColumn   = NormalPackageNameID;
            projectPackageTreeView.SearchColumn  = ProjectPackageNameID;
            selectedPackageTreeView.SearchColumn = SelectedPackageNameID;

            // <!-- Normal packages -->

            Gtk.CellRendererToggle normalPackageToggleRenderer = new Gtk.CellRendererToggle();
            normalPackageToggleRenderer.Activatable = true;
            normalPackageToggleRenderer.Toggled    += OnNormalPackageToggled;
            normalPackageToggleRenderer.Xalign      = 0;

            Gtk.TreeViewColumn normalPackageColumn = new Gtk.TreeViewColumn();
            normalPackageColumn.Title = "Package";
            normalPackageColumn.PackStart(pixbufRenderer, false);
            normalPackageColumn.PackStart(textRenderer, true);
            normalPackageColumn.AddAttribute(textRenderer, "text", NormalPackageNameID);

            normalPackageTreeView.Model          = normalPackageListStore;
            normalPackageTreeView.HeadersVisible = true;
            normalPackageTreeView.AppendColumn("", normalPackageToggleRenderer, "active", NormalPackageToggleID);
            normalPackageTreeView.AppendColumn(normalPackageColumn);
            normalPackageTreeView.AppendColumn("Version", textRenderer, "text", NormalPackageVersionID);

            // <!-- Project packages -->

            Gtk.CellRendererToggle projectPackageToggleRenderer = new Gtk.CellRendererToggle();
            projectPackageToggleRenderer.Activatable = true;
            projectPackageToggleRenderer.Toggled    += OnProjectPackageToggled;
            projectPackageToggleRenderer.Xalign      = 0;

            Gtk.TreeViewColumn projectPackageColumn = new Gtk.TreeViewColumn();
            projectPackageColumn.Title = "Package";
            projectPackageColumn.PackStart(pixbufRenderer, false);
            projectPackageColumn.PackStart(textRenderer, true);
            projectPackageColumn.AddAttribute(textRenderer, "text", ProjectPackageNameID);

            projectPackageTreeView.Model          = projectPackageListStore;
            projectPackageTreeView.HeadersVisible = true;
            projectPackageTreeView.AppendColumn("", projectPackageToggleRenderer, "active", ProjectPackageToggleID);
            projectPackageTreeView.AppendColumn(projectPackageColumn);
            projectPackageTreeView.AppendColumn("Version", textRenderer, "text", ProjectPackageVersionID);


            // <!-- Selected packages -->

            Gtk.TreeViewColumn selectedPackageColumn = new Gtk.TreeViewColumn();
            selectedPackageColumn.Title = "Package";
            selectedPackageColumn.PackStart(pixbufRenderer, false);
            selectedPackageColumn.PackStart(textRenderer, true);
            selectedPackageColumn.AddAttribute(textRenderer, "text", SelectedPackageNameID);

            selectedPackageTreeView.Model          = selectedPackageListStore;
            selectedPackageTreeView.HeadersVisible = true;
            selectedPackageTreeView.AppendColumn(selectedPackageColumn);
            selectedPackageTreeView.AppendColumn("Version", textRenderer, "text", SelectedPackageVersionID);

            // Fill up the project tree view
            packagesOfProjects = GetPackagesOfProjects(project);

            foreach (Package p in packagesOfProjects)
            {
                if (p.Name == project.Name)
                {
                    continue;
                }

                packages.Add(p);
                string version   = p.Version;
                bool   inProject = selectedPackages.Contains(p);

                if (!IsPackageInStore(projectPackageListStore, p.Name, version, ProjectPackageNameID, ProjectPackageVersionID))
                {
                    projectPackageListStore.AppendValues(inProject, p.Name, version);

                    if (inProject)
                    {
                        selectedPackageListStore.AppendValues(p.Name, version);
                    }
                }
            }

            // Fill up the normal tree view
            foreach (string dir in ScanDirs())
            {
                if (Directory.Exists(dir))
                {
                    DirectoryInfo di = new DirectoryInfo(dir);
                    FileInfo[]    availablePackages = di.GetFiles("*.pc");

                    foreach (FileInfo f in availablePackages)
                    {
                        if (!IsValidPackage(f.FullName))
                        {
                            continue;
                        }

                        Package package = new Package(f.FullName);

                        packages.Add(package);

                        string name      = package.Name;
                        string version   = package.Version;
                        bool   inProject = selectedPackages.Contains(package);

                        if (!IsPackageInStore(normalPackageListStore, name, version, NormalPackageNameID, NormalPackageVersionID))
                        {
                            normalPackageListStore.AppendValues(inProject, name, version);

                            if (inProject)
                            {
                                selectedPackageListStore.AppendValues(name, version);
                            }
                        }
                    }
                }
            }
        }
        public EditPackagesDialog(CProject project)
        {
            this.Build();

            this.project = project;

            selectedPackages.AddRange(project.Packages);

            Gtk.CellRendererText textRenderer = new Gtk.CellRendererText();

            Gtk.CellRendererPixbuf pixbufRenderer = new Gtk.CellRendererPixbuf();
            pixbufRenderer.StockId = "md-package";

            // <!-- Normal packages -->

            Gtk.CellRendererToggle normalPackageToggleRenderer = new Gtk.CellRendererToggle();
            normalPackageToggleRenderer.Activatable = true;
            normalPackageToggleRenderer.Toggled    += OnNormalPackageToggled;
            normalPackageToggleRenderer.Xalign      = 0;

            Gtk.TreeViewColumn normalPackageColumn = new Gtk.TreeViewColumn();
            normalPackageColumn.Title = "Package";
            normalPackageColumn.PackStart(pixbufRenderer, false);
            normalPackageColumn.PackStart(textRenderer, true);
            normalPackageColumn.AddAttribute(textRenderer, "text", 1);

            normalPackageTreeView.Model          = normalPackageListStore;
            normalPackageTreeView.HeadersVisible = true;
            normalPackageTreeView.AppendColumn("", normalPackageToggleRenderer, "active", 0);
            normalPackageTreeView.AppendColumn(normalPackageColumn);
            normalPackageTreeView.AppendColumn("Version", textRenderer, "text", 2);

            // <!-- Project packages -->

            Gtk.CellRendererToggle projectPackageToggleRenderer = new Gtk.CellRendererToggle();
            projectPackageToggleRenderer.Activatable = true;
            projectPackageToggleRenderer.Toggled    += OnProjectPackageToggled;
            projectPackageToggleRenderer.Xalign      = 0;

            Gtk.TreeViewColumn projectPackageColumn = new Gtk.TreeViewColumn();
            projectPackageColumn.Title = "Package";
            projectPackageColumn.PackStart(pixbufRenderer, false);
            projectPackageColumn.PackStart(textRenderer, true);
            projectPackageColumn.AddAttribute(textRenderer, "text", 1);

            projectPackageTreeView.Model          = projectPackageListStore;
            projectPackageTreeView.HeadersVisible = true;
            projectPackageTreeView.AppendColumn("", projectPackageToggleRenderer, "active", 0);
            projectPackageTreeView.AppendColumn(projectPackageColumn);
            projectPackageTreeView.AppendColumn("Version", textRenderer, "text", 2);


            // <!-- Selected packages -->

            Gtk.TreeViewColumn selectedPackageColumn = new Gtk.TreeViewColumn();
            selectedPackageColumn.Title = "Package";
            selectedPackageColumn.PackStart(pixbufRenderer, false);
            selectedPackageColumn.PackStart(textRenderer, true);
            selectedPackageColumn.AddAttribute(textRenderer, "text", 0);

            selectedPackagesTreeView.Model          = selectedPackagesListStore;
            selectedPackagesTreeView.HeadersVisible = true;
            selectedPackagesTreeView.AppendColumn(selectedPackageColumn);
            selectedPackagesTreeView.AppendColumn("Version", textRenderer, "text", 1);

            // Fill up the project tree view
            projectPackages = ProjectPackages(project);

            foreach (ProjectPackage p in projectPackages)
            {
                if (p.Name == project.Name)
                {
                    continue;
                }
                string version   = GetPackageVersion(p.File);
                bool   inProject = IsInProject(p.File);
                projectPackageListStore.AppendValues(inProject, p.Name, version);

                if (inProject)
                {
                    selectedPackagesListStore.AppendValues(p.Name, version);
                }
            }

            // Fill up the normal tree view
            foreach (string dir in ScanDirs())
            {
                if (Directory.Exists(dir))
                {
                    DirectoryInfo di = new DirectoryInfo(dir);
                    FileInfo[]    availablePackages = di.GetFiles("*.pc");

                    foreach (FileInfo f in availablePackages)
                    {
                        if (!IsValidPackage(f.FullName))
                        {
                            continue;
                        }
                        string name      = f.Name.Substring(0, f.Name.LastIndexOf('.'));
                        string version   = GetPackageVersion(f.FullName);
                        bool   inProject = IsInProject(name);
                        normalPackageListStore.AppendValues(inProject, name, version);

                        if (inProject)
                        {
                            selectedPackagesListStore.AppendValues(name, version);
                        }
                    }
                }
            }
        }