コード例 #1
0
ファイル: WorkspaceTree.cs プロジェクト: moscrif/ide
        // Icon,Show Name, Full Path, TypFile
        public WorkspaceTree()
        {
            treeView = new TreeView();

            treeView.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnButtonRelease);
            treeView.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args) {
                if(args.Event.Key == Gdk.Key.Delete){
                    MainClass.MainWindow.DeleteFile();
                }
            };

            //treeView.Model = modelStore = store;

            filter = new Gtk.TreeModelFilter(store, null);
            filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(FilterTree);
            treeView.Model = filter;

            treeView.HeadersVisible = true;
            //this.ExpandAll();
            treeView.Selection.Mode = Gtk.SelectionMode.Single;
            treeView.RowActivated += OnRowActivate;
            treeView.Selection.Changed+= OnRowSelection;
            treeView.ShowExpanders = true;

            //	TreeViewColumn display_column.PackStart (text_render, true);

            CellRendererPixbuf crp = new CellRendererPixbuf();
            crp.Ypad = 0;
            crp.Yalign = 0;

            Gtk.CellRendererText fileNameRenderer = new Gtk.CellRendererText();
            fileNameRenderer.Ypad =0;

            TreeViewColumn icon_column = new TreeViewColumn();//("Icon", crp, "pixbuf", ICO_ROW);
            icon_column.PackStart (crp, false);
            icon_column.AddAttribute(crp,"pixbuf",ICO_ROW);

            icon_column.PackStart (fileNameRenderer, true);
            icon_column.AddAttribute (fileNameRenderer, "markup", NAME_ROW);

            treeView.AppendColumn(icon_column);

            //treeView.AppendColumn("Icon", crp, "pixbuf", ICO_ROW);

            treeView.AppendColumn("Name", fileNameRenderer, "text", NAME_ROW);
            treeView.Columns[NAME_ROW].Visible = false;

            CellRendererText textRenderer = new CellRendererText();
            textRenderer.Ypad =0;

            treeView.AppendColumn("FullPath", textRenderer, "text", PATH_ROW);
            treeView.Columns[PATH_ROW].Visible = false;
            treeView.HeadersVisible = false;
            treeView.EnableTreeLines = true;
            treeView.HoverExpand = false;
            treeView.HoverSelection = false;

            treeView.Columns[NAME_ROW].SetCellDataFunc(fileNameRenderer, new Gtk.TreeCellDataFunc(RenderFileNme));

            sw.ShadowType = ShadowType.Out;
            sw.Add(treeView);

            this.PackEnd(sw, true, true, 0);

            Toolbar toolbar = new Toolbar ();

            refreshButton = new ToolButton ("refresh.png");//Stock.Home);
            refreshButton.IsImportant = true;
            refreshButton.Label = MainClass.Languages.Translate("menu_refresh");
            refreshButton.BorderWidth = 1;
            refreshButton.Clicked+= delegate {
                MainClass.MainWindow.RefreshProject();
            };
            toolbar.Insert (refreshButton, -1);

            Gtk.Menu menuAdd = new Gtk.Menu ();

            MenuItem mi = new MenuItem (MainClass.Languages.Translate("menu_create_file"));
            mi.Activated += delegate(object sender, EventArgs e) {
                NewAction nw = new NewAction();
                nw.Activate();
            };

            menuAdd.Insert (mi, -1);
            mi = new MenuItem (MainClass.Languages.Translate("menu_create_dir"));
            mi.Activated += delegate(object sender, EventArgs e) {
                NewDirectoryAction nw = new NewDirectoryAction();
                nw.Activate();
            };

            menuAdd.Insert (mi, -1);
            menuAdd.ShowAll ();

            mtbCreate= new MenusToolButton(menuAdd,"file-new.png");
            mtbCreate.IsImportant = true;
            mtbCreate.Label = "Create";
            toolbar.Insert (mtbCreate, -1);

            if(MainClass.Settings.LogicalSort == null)
                MainClass.Settings.LogicalSort = LogicalSystem.GetDefaultLogicalSystem();

            Gtk.Menu menuFilter = new Gtk.Menu ();

            MenuItem menuItemFilter = new MenuItem (MainClass.Languages.Translate("all_files") );
            menuItemFilter.Activated += delegate(object sender, EventArgs e) {
                activetFilter = null;
                filter.Refilter();
                treeView.QueueDraw();
            };
            menuFilter.Insert (menuItemFilter, -1);

            foreach (LogicalSystem ls in MainClass.Settings.LogicalSort){
                LogicalSystem lsTemp = ls;
                menuItemFilter = new MenuItem (lsTemp.Display);
                menuItemFilter.Activated += delegate(object sender, EventArgs e) {
                    if (lsTemp != null) {
                        activetFilter = lsTemp;
                    } else {
                        activetFilter = null;
                    }
                    filter.Refilter();
                    treeView.QueueDraw();
                };
                menuFilter.Insert (menuItemFilter, -1);
                //filterModel.AppendValues(ls.Display, "", ls);
            }
            menuFilter.ShowAll();

            MenusToolButton mtbFilter= new MenusToolButton(menuFilter,"filter.png");
            mtbFilter.IsImportant = true;
            mtbFilter.Label = "Filter";
            toolbar.Insert (mtbFilter, -1);
            this.PackStart(toolbar, false, false, 0);
            //this.PackStart(ComboFilter, false, false, 0);
            //ComboFilter.Active = 0;
        }
コード例 #2
0
ファイル: FileExplorer.cs プロジェクト: moscrif/ide
        public FileExplorer()
        {
            navigBar = new NavigationBar(NavigationBar.NavigationType.favorites);

            navigBar.OnChangePath+= NavigateBarChange;

            Toolbar toolbar = new Toolbar ();
            //WinMenuBar  toolbar = new WinMenuBar ();
            this.PackStart (toolbar, false, false, 0);

            refreshButton = new ToolButton ("refresh.png");//Stock.Home);
            refreshButton.IsImportant = true;
            refreshButton.Label = MainClass.Languages.Translate("menu_refresh");
            refreshButton.BorderWidth = 1;
            refreshButton.Clicked+= delegate {
                FillStore (true);
            };
            toolbar.Insert (refreshButton, -1);

            upButton = new ToolButton  ("go-up.png");//Stock.GoUp
            upButton.Sensitive = false;
            upButton.Label ="Up";
            upButton.BorderWidth = 1;
            toolbar.Insert (upButton, -1);

            Gtk.Menu menu = new Gtk.Menu ();

            MenuItem mi = new MenuItem ("Workspace");
            mi.Activated += OnWorkspaceClicked;
            menu.Insert (mi, -1);
            mi = new MenuItem ("Project");
            mi.Activated += OnProjectClicked;
            menu.Insert (mi, -1);
            menu.ShowAll ();
            mi = new MenuItem ("User home folder");
            mi.Activated += OnHomeClicked;
            menu.Insert (mi, -1);
            menu.ShowAll ();
            mi = new MenuItem ("Output folder");
            mi.Activated += OnOutputClicked;
            menu.Insert (mi, -1);
            menu.ShowAll ();
            mi = new MenuItem ("Disk root");
            mi.Activated += OnOutputClicked;
            menu.Insert (mi, -1);
            menu.ShowAll ();

            if(MainClass.Platform.IsWindows){

                SeparatorMenuItem smi = new SeparatorMenuItem();
                menu.Insert (smi, -1);

                string[] drives = Environment.GetLogicalDrives();
                 foreach(string strDrive in drives)
                 {
                    mi = new MenuItem (strDrive);
                    mi.TooltipText = strDrive;
                    mi.Activated += delegate(object sender, EventArgs e)
                    {
                        string drive = (sender as  MenuItem).TooltipText;
                        parent = new DirectoryInfo(drive);
                        FillStore (true);
                        upButton.Sensitive = false;
                    };
                    menu.Insert (mi, -1);
                    menu.ShowAll ();

                };
            }

            MenusToolButton gotoButton= new MenusToolButton(menu,"workspace.png");
            gotoButton.IsImportant = true;
            gotoButton.Label = "Go To";
            toolbar.Insert (gotoButton, -1);

            Gtk.Menu menuAdd = new Gtk.Menu ();
            mi = new MenuItem (MainClass.Languages.Translate("menu_create_file"));
            mi.Activated += OnCreateFileClicked;
            menuAdd.Insert (mi, -1);
            mi = new MenuItem (MainClass.Languages.Translate("menu_create_dir"));
            mi.Activated += OnCreateDirectoryClicked;
            menuAdd.Insert (mi, -1);
            menuAdd.ShowAll ();

            MenusToolButton mtbCreate= new MenusToolButton(menuAdd,"file-new.png");
            mtbCreate.IsImportant = true;
            mtbCreate.Label = "Create";
            toolbar.Insert (mtbCreate, -1);

            fileIcon = GetIcon ("file.png");//Stock.File);
            dirIcon = GetIcon ("folder.png");//Stock.Open);
            upIcon = GetIcon ("go-up.png");

            ScrolledWindow sw = new ScrolledWindow ();
            sw.ShadowType = ShadowType.EtchedIn;
            sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
            this.PackStart (sw, true, true, 0);

            // Create the store and fill it with the contents of '/'
            store = CreateStore ();

            iconView = new IconView (store);
            iconView.ButtonReleaseEvent+= OnButtonRelease;

            iconView.SelectionMode = SelectionMode.Single;

            iconView.Columns = 1;
            iconView.Orientation = Orientation.Horizontal;

            upButton.Clicked += new EventHandler (OnUpClicked);

            iconView.TextColumn = COL_DISPLAY_NAME;
            iconView.PixbufColumn = COL_PIXBUF;
            iconView.TooltipColumn = COL_PATH;
            iconView.RowSpacing = -6;
            iconView.Spacing = -1;
            iconView.ColumnSpacing=0;
            iconView.Margin=-5;

            iconView.ItemActivated += new ItemActivatedHandler (OnItemActivated);

            sw.Add (iconView);

            iconView.SelectionChanged+= delegate(object sender, EventArgs e) {
                Gtk.TreePath[] selRow = iconView.SelectedItems;
                if(selRow.Length<1) return;

                Gtk.TreePath tp = selRow[0];
                TreeIter ti = new TreeIter();
                store.GetIter(out ti,tp);

                if(tp.Equals(TreeIter.Zero))return;

                string name = store.GetValue(ti, 1).ToString();
                if(name == ".."){
                    selectedItem = null;
                } else {
                    selectedItem = store.GetValue(ti, 0).ToString();
                    isDir = (bool)store.GetValue(ti, 3);
                }
            };
            this.PackEnd (navigBar, false, false, 0);
        }