void OnButtonRelease(object obj, ButtonReleaseEventArgs args) { if (args.Event.Button == 3) { this.popupMenu = new Menu(); Gtk.TreePath[] selRow = iconView.SelectedItems; if (selRow.Length < 1) { this.popupMenu = GenerateMenu(false); } else { Gtk.TreePath tp = selRow[0]; TreeIter ti = new TreeIter(); store.GetIter(out ti, tp); if (tp.Equals(TreeIter.Zero)) { return; } selectedItem = store.GetValue(ti, 0).ToString(); string name = store.GetValue(ti, 1).ToString(); isDir = (bool)store.GetValue(ti, 3); if (name == "..") // Up select { selectedItem = null; this.popupMenu = GenerateMenu(false); } else { this.popupMenu = GenerateMenu(true); } } this.popupMenu.ShowAll(); this.popupMenu.Popup(); } }
public int GetSelectedLine (TreePath cpath) { if (cpath.Equals (selctedPath)) return selectedLine; else return -1; }
public NewProjectWizzard_New(Window parent) { if (parent != null) { this.TransientFor = parent; } else { this.TransientFor = MainClass.MainWindow; } this.Build(); atrApplication = new FileTemplate.Attribute(); atrApplication.Name = "application"; atrApplication.Type = "text"; this.DefaultHeight = 390; this.Title = MainClass.Languages.Translate("moscrif_ide_title_f1"); ntbWizzard.ShowTabs = false; Pango.FontDescription customFont = lblNewProject.Style.FontDescription.Copy(); // Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont); customFont.Size = customFont.Size + (int)(customFont.Size / 2); customFont.Weight = Pango.Weight.Bold; lblNewProject.ModifyFont(customFont); storeTyp = new ListStore(typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(string), typeof(ProjectTemplate), typeof(bool)); storeOrientation = new ListStore(typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(string)); storeOutput = new ListStore(typeof(string), typeof(string), typeof(Gdk.Pixbuf)); nvOutput.Model = storeOutput; nvOutput.AppendColumn("", new Gtk.CellRendererText(), "text", 0); nvOutput.AppendColumn("", new Gtk.CellRendererText(), "text", 1); nvOutput.AppendColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 2); nvOutput.Columns[1].Expand = true; ivSelectTyp.Model = storeTyp; ivSelectTyp.SelectionMode = SelectionMode.Single; ivSelectTyp.Orientation = Orientation.Horizontal; CellRendererText rendererSelectTyp = new CellRendererText(); rendererSelectTyp.Ypad = 0; ivSelectTyp.PackEnd(rendererSelectTyp, false); ivSelectTyp.SetCellDataFunc(rendererSelectTyp, new Gtk.CellLayoutDataFunc(RenderTypProject)); ivSelectTyp.PixbufColumn = COL_PIXBUF; ivSelectTyp.TooltipColumn = COL_DISPLAY_TEXT; ivSelectTyp.AddAttribute(rendererSelectTyp, "sensitive", 5); Gdk.Pixbuf icon0 = MainClass.Tools.GetIconFromStock("project.png", IconSize.LargeToolbar); storeTyp.AppendValues("New Empty Project", "Create empty application", icon0, "", null, true); DirectoryInfo[] diTemplates = GetDirectory(MainClass.Paths.FileTemplateDir); foreach (DirectoryInfo di in diTemplates) { string name = di.Name; string iconFile = System.IO.Path.Combine(di.FullName, "icon.png"); string descFile = System.IO.Path.Combine(di.FullName, "description.xml"); if (!File.Exists(iconFile) || !File.Exists(descFile)) { continue; } string descr = name; ProjectTemplate pt = null; if (File.Exists(descFile)) { pt = ProjectTemplate.OpenProjectTemplate(descFile); if ((pt != null)) { descr = pt.Description; } } Gdk.Pixbuf icon = new Gdk.Pixbuf(iconFile); DirectoryInfo[] templates = di.GetDirectories(); bool sensitive = true; if (templates.Length < 1) { sensitive = false; } else { sensitive = true; } storeTyp.AppendValues(name, descr, icon, di.FullName, pt, sensitive); } ivSelectTyp.SelectionChanged += delegate(object sender, EventArgs e) { Gtk.TreePath[] selRow = ivSelectTyp.SelectedItems; if (selRow.Length < 1) { lblHint.Text = " "; btnNext.Sensitive = false; return; } Gtk.TreePath tp = selRow[0]; TreeIter ti = new TreeIter(); storeTyp.GetIter(out ti, tp); if (tp.Equals(TreeIter.Zero)) { return; } //string typ = storeTyp.GetValue (ti, 3).ToString(); string text1 = (string)storeTyp.GetValue(ti, 0); string text2 = (string)storeTyp.GetValue(ti, 1); bool sensitive = Convert.ToBoolean(storeTyp.GetValue(ti, 5)); if (!sensitive) { ivSelectTyp.SelectPath(selectedTypPrj); return; } selectedTypPrj = selRow[0]; lblHint.Text = text1 + " - " + text2; btnNext.Sensitive = true; }; CellRendererText rendererOrientation = new CellRendererText(); selectedTypPrj = new TreePath("0"); ivSelectTyp.SelectPath(selectedTypPrj); ivSelectOrientation.Model = storeOrientation; ivSelectOrientation.SelectionMode = SelectionMode.Single; ivSelectOrientation.Orientation = Orientation.Horizontal; ivSelectOrientation.PackEnd(rendererOrientation, false); ivSelectOrientation.SetCellDataFunc(rendererOrientation, new Gtk.CellLayoutDataFunc(RenderOrientationProject)); ivSelectOrientation.PixbufColumn = COL_PIXBUF; ivSelectOrientation.TooltipColumn = COL_DISPLAY_TEXT; foreach (SettingValue ds in MainClass.Settings.DisplayOrientations) { storeOrientation.AppendValues(ds.Display, ds.Display, null, ds.Value); } ivSelectOrientation.SelectPath(new TreePath("0")); storeWorkspace = new ListStore(typeof(string), typeof(string), typeof(int)); cbeWorkspace = new ComboBoxEntry(); cbeWorkspace.Model = storeWorkspace; cbeWorkspace.TextColumn = 0; cbeWorkspace.Changed += OnCbeWorkspaceChanged; this.feLocation = new FileEntry(); this.table3.Attach(this.feLocation, 1, 2, 2, 3); Gtk.Table.TableChild w9 = ((Gtk.Table.TableChild)(this.table3 [this.feLocation])); w9.XOptions = ((Gtk.AttachOptions)(4)); w9.YOptions = ((Gtk.AttachOptions)(4)); table3.Attach(cbeWorkspace, 1, 2, 1, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); CellRendererText rendererWorkspace = new CellRendererText(); cbeWorkspace.PackStart(rendererWorkspace, true); cbeWorkspace.SetCellDataFunc(rendererWorkspace, new Gtk.CellLayoutDataFunc(RenderWorkspacePath)); cbeWorkspace.WidthRequest = 125; cbeWorkspace.SetCellDataFunc(cbeWorkspace.Cells[0], new Gtk.CellLayoutDataFunc(RenderWorkspaceName)); string currentWorkspace = ""; if ((MainClass.Workspace != null) && !string.IsNullOrEmpty(MainClass.Workspace.FilePath)) { string name = System.IO.Path.GetFileNameWithoutExtension(MainClass.Workspace.FilePath); storeWorkspace.AppendValues(name, MainClass.Workspace.FilePath, 1); currentWorkspace = MainClass.Workspace.FilePath; } IList <RecentFile> lRecentProjects = MainClass.Settings.RecentFiles.GetWorkspace(); foreach (RecentFile rf in lRecentProjects) { if (rf.FileName == currentWorkspace) { continue; } if (File.Exists(rf.FileName)) { string name = System.IO.Path.GetFileNameWithoutExtension(rf.FileName); storeWorkspace.AppendValues(name, rf.FileName, 0); } } //storeWorkspace.AppendValues("","-------------",-1); worksDefaultName = "Workspace" + MainClass.Settings.WorkspaceCount.ToString(); TreeIter tiNewW = storeWorkspace.AppendValues(worksDefaultName, MainClass.Paths.WorkDir, 2); if (!String.IsNullOrEmpty(currentWorkspace)) { cbeWorkspace.Active = 0; } else { feLocation.DefaultPath = MainClass.Paths.WorkDir; cbeWorkspace.SetActiveIter(tiNewW); //storeWorkspace.AppendValues(worksDefaultName,MainClass.Paths.WorkDir,2); } prjDefaultName = "Project" + MainClass.Settings.ProjectCount.ToString(); entrProjectName.Text = prjDefaultName; cbeWorkspace.ShowAll(); feLocation.ShowAll(); CellRendererText rendererTemplate = new CellRendererText(); cbTemplate.PackStart(rendererTemplate, true); storeTemplate = new ListStore(typeof(string), typeof(string), typeof(string)); cbTemplate.Model = storeTemplate; cbTemplate.Changed += delegate(object sender, EventArgs e) { if (cbTemplate.Active < 0) { return; } if (cbTemplate.ActiveText != KEY_CUSTOM) { tblLibraries.Sensitive = false; tblScreens.Sensitive = false; ivSelectOrientation.Sensitive = false; } else { ivSelectOrientation.Sensitive = true; tblLibraries.Sensitive = true; tblScreens.Sensitive = true; } TreeIter tiChb = new TreeIter(); cbTemplate.GetActiveIter(out tiChb); if (tiChb.Equals(TreeIter.Zero)) { return; } string appPath = storeTemplate.GetValue(tiChb, 2).ToString(); if (File.Exists(appPath)) { AppFile app = new AppFile(appPath); List <string> libs = new List <string>(app.Libs); Widget[] widgets = tblLibraries.Children; foreach (Widget w in widgets) { int indx = libs.FindIndex(x => x == w.Name); if (indx > -1) { (w as CheckButton).Active = true; } else { (w as CheckButton).Active = false; } } } }; btnBack.Sensitive = false; }
protected void OnButtonOkClicked(object sender, EventArgs e) { if (page == 0) { if (!CheckPage0()) { return; } Gtk.TreePath[] selRow = ivSelectTyp.SelectedItems; if (selRow.Length < 1) { return; } Gtk.TreePath tp = selRow[0]; TreeIter ti = new TreeIter(); storeTyp.GetIter(out ti, tp); if (tp.Equals(TreeIter.Zero)) { return; } templateDir = storeTyp.GetValue(ti, 3).ToString(); projectTemplate = (ProjectTemplate)storeTyp.GetValue(ti, 4); projectName = MainClass.Tools.RemoveDiacriticsAndOther(entrProjectName.Text).Replace(" ", "_"); projectDir = projectName; if (String.IsNullOrEmpty(templateDir)) //Create Empty project { ntbWizzard.Page = 2; buttonCancel.Label = "_Close"; btnBack.Sensitive = false; btnNext.Sensitive = false; if (!CreateWorkspace(out workspaceName, out workspaceRoot, out workspaceOutput, out workspaceFile)) { return; } string projectFile = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".msp"); string appFile = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".app"); TreeIter tiPrj = AddMessage(MainClass.Languages.Translate("wizzard_create_project"), "....", null); Project prj = null; try{ prj = MainClass.Workspace.CreateProject(projectFile, projectName, MainClass.Workspace.RootDirectory, projectDir, appFile, null, null); } catch (Exception ex) { UpdateMessage(tiPrj, 1, ex.Message); return; } UpdateMessage(tiPrj, 1, "OK"); MainClass.MainWindow.AddAndShowProject(prj, true, true); AddMessage(MainClass.Languages.Translate("wizzard_finish"), "", null); if (entrProjectName.Text == prjDefaultName) { MainClass.Settings.ProjectCount = MainClass.Settings.ProjectCount + 1; } } else //Inicialize next page { lblCustom.LabelProp = projectTemplate.Custom; storeTemplate.Clear(); while (tblLibraries.Children.Length > 0) { tblLibraries.Remove(tblLibraries.Children[0]); } while (tblScreens.Children.Length > 0) { tblScreens.Remove(tblScreens.Children[0]); } btnBack.Sensitive = true; ntbWizzard.Page = 1; entrPage2PrjName.Text = projectName; DirectoryInfo[] diTemplates = GetDirectory(templateDir); //List<DirectoryInfo> customTemplate = new List<DirectoryInfo>(); List <string> customTemplate = new List <string>(); storeTemplate.Clear(); storeTemplate.AppendValues(KEY_CUSTOM, "", ""); foreach (DirectoryInfo di in diTemplates) { string name = System.IO.Path.GetFileNameWithoutExtension(di.FullName); string ex = System.IO.Path.GetExtension(di.FullName); FileInfo[] fiApp = di.GetFiles("*.app", SearchOption.TopDirectoryOnly); if ((fiApp == null) || (fiApp.Length < 1)) { continue; } if (ex == ".custom") { customTemplate.Add(fiApp[0].FullName); } else { storeTemplate.AppendValues(name, di.FullName, fiApp[0].FullName); } } cbTemplate.Active = 0; int x = 0; if (projectTemplate != null) { foreach (SettingValue sv in projectTemplate.Libs) { CheckButton chb = new CheckButton(sv.Display); chb.Name = sv.Value; tblLibraries.Attach(chb, 0, 1, (uint)x, (uint)(x + 1), AttachOptions.Fill, AttachOptions.Fill, 0, 0); x++; } tblLibraries.ShowAll(); } GenerateCustomTemplate(customTemplate); btnNext.Label = "Finish"; page++; } } else if (page == 1) { if (!CheckPage1()) { return; } ntbWizzard.Page = 2; buttonCancel.Label = "_Close"; while (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(); } page++; btnNext.Sensitive = false; btnBack.Sensitive = false; projectName = MainClass.Tools.RemoveDiacriticsAndOther(entrPage2PrjName.Text).Replace(" ", "_"); if (cbTemplate.ActiveText != KEY_CUSTOM) // Select App { if (!CreateWorkspace(out workspaceName, out workspaceRoot, out workspaceOutput, out workspaceFile)) { return; } btnNext.Sensitive = false; TreeIter tiChb = new TreeIter(); cbTemplate.GetActiveIter(out tiChb); string appPath = storeTemplate.GetValue(tiChb, 2).ToString(); if (File.Exists(appPath)) { Project prj = ImportProject(appPath, projectName, String.Empty, String.Empty); MainClass.MainWindow.AddAndShowProject(prj, true, true); AddMessage(MainClass.Languages.Translate("wizzard_finish"), "", null); } } else // SELECT Custom { if (!CreateWorkspace(out workspaceName, out workspaceRoot, out workspaceOutput, out workspaceFile)) { return; } Widget[] widgets = tblScreens.Children; string appPath = ""; foreach (Widget w in widgets) { if ((w as RadioButton).Active) { appPath = (w as RadioButton).TooltipMarkup; } } widgets = tblLibraries.Children; string libs = "core ui"; string orientation = ""; foreach (Widget w in widgets) { if ((w as CheckButton).Active) { libs = libs + " " + (w as CheckButton).Name; /*if((w as CheckButton).Name.ToLower() == "uix"){ * libs = libs +" ui"; * }*/ } } Gtk.TreePath[] selRow = ivSelectOrientation.SelectedItems; if (selRow.Length > 0) { Gtk.TreePath tp = selRow[0]; TreeIter ti = new TreeIter(); storeOrientation.GetIter(out ti, tp); if (!tp.Equals(TreeIter.Zero)) { orientation = storeOrientation.GetValue(ti, 3).ToString(); } } if (File.Exists(appPath)) { Project prj = ImportProject(appPath, projectName, libs, orientation.Trim()); MainClass.MainWindow.AddAndShowProject(prj, true, true); AddMessage(MainClass.Languages.Translate("wizzard_finish"), "", null); } } } }
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); }
void GetCorrectedPathAndPosition (int x, int y, out TreePath path, out IconViewDropPosition pos) { GetDestItemAtPos (x, y, out path, out pos); // Convert drop above/below/into into DropLeft or DropRight based on the x coordinate if (path != null && (pos == IconViewDropPosition.DropAbove || pos == IconViewDropPosition.DropBelow || pos == IconViewDropPosition.DropInto)) { if (!path.Equals (GetPathAtPos (x + ItemSize/2, y))) { pos = IconViewDropPosition.DropRight; } else { pos = IconViewDropPosition.DropLeft; } } }