public void OnAddPls()
 {
     Hyena.Log.Information ("add playlist");
     Gtk.Dialog dlg=new Gtk.Dialog();
     dlg.Title="Add Playlist";
     Gtk.Entry pls=new Gtk.Entry();
     pls.WidthChars=40;
     Gtk.Label lbl=new Gtk.Label("Playlist name:");
     Gtk.HBox hb=new Gtk.HBox();
     hb.PackStart (lbl,false,false,1);
     hb.PackEnd (pls);
     dlg.VBox.PackStart (hb);
     dlg.AddButton (Gtk.Stock.Cancel,0);
     dlg.AddButton (Gtk.Stock.Ok,1);
     dlg.VBox.ShowAll ();
     string plsname="";
     while (plsname=="") {
         int response=dlg.Run ();
         if (response==0) {
             dlg.Hide ();
             dlg.Destroy ();
             return;
         } else {
             plsname=pls.Text.Trim ();
         }
     }
     dlg.Hide ();
     dlg.Destroy ();
     _pls=_col.NewPlayList(plsname);
     _model.Reload ();
     _pls_model.SetPlayList (_pls);
 }
Пример #2
0
	/* Protected members */

	protected void Init (Gtk.Dialog dialog) {
		this.dialog = dialog;
		Util.SetBaseWindowFromUi(dialog);

		dialog.Response += OnResponse;
		dialog.DeleteEvent += OnDeleteEvent;
	}
Пример #3
0
		public TreeViewDemo ()
		{
			DateTime start = DateTime.Now;

			Application.Init ();
			
			PopulateStore ();

			Window win = new Window ("TreeView demo");
			win.DeleteEvent += new DeleteEventHandler (DeleteCB);
			win.SetDefaultSize (640,480);

			ScrolledWindow sw = new ScrolledWindow ();
			win.Add (sw);

			TreeView tv = new TreeView (store);
			tv.HeadersVisible = true;
			tv.EnableSearch = false;

			tv.AppendColumn ("Name", new CellRendererText (), "text", 0);
			tv.AppendColumn ("Type", new CellRendererText (), "text", 1);

			sw.Add (tv);
			
			dialog.Destroy ();
			dialog = null;

			win.ShowAll ();
			
			Console.WriteLine (count + " nodes added.");
			Console.WriteLine ("Startup time: " + DateTime.Now.Subtract (start));
			Application.Run ();
		}
Пример #4
0
		public static Gtk.Window Create ()
		{
			window = new Dialog ();
			window.Title = "Bi-directional flipping";
			window.SetDefaultSize (200, 100);

			label = new Label ("Label direction: <b>Left-to-right</b>");
			label.UseMarkup = true;
			label.SetPadding (3, 3);
			window.VBox.PackStart (label, true, true, 0);

			check_button = new CheckButton ("Toggle label direction");
			window.VBox.PackStart (check_button, true, true, 2);

			if (window.Direction == TextDirection.Ltr)
				check_button.Active = true;

			check_button.Toggled += new EventHandler (Toggle_Flip);
			check_button.BorderWidth = 10;

			button = new Button (Stock.Close);
			button.Clicked += new EventHandler (Close_Button);
			button.CanDefault = true;
			
			window.ActionArea.PackStart (button, true, true, 0);
			button.GrabDefault ();

			window.ShowAll ();
			return window;
		}
Пример #5
0
 public BookEditor()
 {
     Glade.XML gxml = new Glade.XML (Util.GladePath("contact-browser.glade"),
      "BookEditor", null);
        gxml.Autoconnect (this);
        beDlg = (Gtk.Dialog) gxml.GetWidget("BookEditor");
 }
Пример #6
0
        public static void Main(string[] args)
        {
            Application.Init ();

             			try {
                InfoManager.Init ();
            } catch (Exception e) {
                Dialog d = new Dialog ("Error", null, DialogFlags.Modal, new object [] {
                    "OK", ResponseType.Ok });
                d.VBox.Add (new Label ("There was a problem while trying to initialize the InfoManager\n\n" + e.ToString ()));
                d.VBox.ShowAll ();
                d.Run ();
                return;
            }

            string profile_path = null;
            if (args.Length != 0 && args[0].StartsWith ("--profile-path="))
                profile_path = args[0].Substring (15);

            MainWindow win = new MainWindow (profile_path);
            win.Show ();
            if (args.Length == 2 && File.Exists (args [0]) && File.Exists (args [1])){
                win.ComparePaths (args [0], args [1]);
            }
            Application.Run ();
        }
Пример #7
0
		public static Gtk.Window Create ()
		{
			window = new Dialog ();
			window.Response += new ResponseHandler (Print_Response);
			window.SetDefaultSize (200, 100);

			window.Title = "GtkDialog";
			Button button = new Button (Stock.Ok);
			button.Clicked += new EventHandler (Close_Button);
			button.CanDefault = true;
			window.ActionArea.PackStart (button, true, true, 0);
			button.GrabDefault ();

			ToggleButton toggle_button = new ToggleButton ("Toggle Label");
			toggle_button.Clicked += new EventHandler (Label_Toggle);
			window.ActionArea.PackStart (toggle_button, true, true, 0);

			toggle_button = new ToggleButton ("Toggle Separator");
			toggle_button.Clicked += new EventHandler (Separator_Toggle);
			window.ActionArea.PackStart (toggle_button, true, true, 0);

			window.ShowAll ();

			return window;
		}
Пример #8
0
        public override void EditPlayer(Text text)
        {
            playerText = text;
            if (playerDialog == null) {
                Gtk.Dialog d = new Gtk.Dialog (Catalog.GetString ("Select player"),
                                   this, DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                   Stock.Cancel, ResponseType.Cancel);
                d.WidthRequest = 600;
                d.HeightRequest = 400;

                DrawingArea da = new DrawingArea ();
                TeamTagger tagger = new TeamTagger (new WidgetWrapper (da));
                tagger.ShowSubstitutionButtons = false;
                tagger.LoadTeams ((ViewModel.Project as ProjectLongoMatch).LocalTeamTemplate, (ViewModel.Project as ProjectLongoMatch).VisitorTeamTemplate,
                                  (ViewModel.Project as ProjectLongoMatch).Dashboard.FieldBackground);
                tagger.PlayersSelectionChangedEvent += players => {
                    if (players.Count == 1) {
                        Player p = players [0];
                        playerText.Value = p.ToString ();
                        d.Respond (ResponseType.Ok);
                    }
                    tagger.ResetSelection ();
                };
                d.VBox.PackStart (da, true, true, 0);
                d.ShowAll ();
                playerDialog = d;
            }
            if (playerDialog.Run () != (int)ResponseType.Ok) {
                text.Value = null;
            }
            playerDialog.Hide ();
        }
Пример #9
0
 private void onClick(object Sender, EventArgs e)
 {
     Dialog d = new Dialog ("Test", this, DialogFlags.DestroyWithParent);
     d.Modal = true;
     d.AddButton ("Close", ResponseType.Close);
     d.Run ();
     d.Destroy ();
 }
Пример #10
0
        public PreferencesDialog(Settings set, Window parent,
				 string argsOver)
        {
            settings = set;
            argsOverride = argsOver;

            dialog = new Dialog("Preferences", parent,
            DialogFlags.Modal | DialogFlags.DestroyWithParent,
            new object[]{Gtk.Stock.Close, -1});

            var table = new Table(4, 3, false);

            sUseBundledDebugger = new CheckButton("Use bundled MSPDebug");
            sUseBundledDebugger.Clicked += OnBundledState;
            table.Attach(sUseBundledDebugger, 0, 3, 0, 1,
             AttachOptions.Expand | AttachOptions.Fill,
             0, 4, 4);

            Label lbl;

            lbl = new Label("MSPDebug path:");
            lbl.SetAlignment(0.0f, 0.5f);
            table.Attach(lbl, 0, 1, 1, 2, AttachOptions.Fill, 0, 4, 4);
            sMSPDebugPath = new Entry();
            table.Attach(sMSPDebugPath, 1, 2, 1, 2,
             AttachOptions.Expand | AttachOptions.Fill,
             0, 4, 4);
            chooseMSPDebug = new Button("Choose...");
            chooseMSPDebug.Clicked += OnChoose;
            table.Attach(chooseMSPDebug, 2, 3, 1, 2,
             AttachOptions.Fill, 0, 4, 4);

            lbl = new Label("MSPDebug arguments:");
            lbl.SetAlignment(0.0f, 0.5f);
            table.Attach(lbl, 0, 1, 2, 3, AttachOptions.Fill, 0, 4, 4);
            sMSPDebugArgs = new Entry();
            sMSPDebugArgs.Sensitive = (argsOverride == null);
            table.Attach(sMSPDebugArgs, 1, 3, 2, 3,
             AttachOptions.Expand | AttachOptions.Fill,
             0, 4, 4);

            lbl = new Label("Console font:");
            lbl.SetAlignment(0.0f, 0.5f);
            table.Attach(lbl, 0, 1, 3, 4, AttachOptions.Fill, 0, 4, 4);
            sConsoleFont = new FontButton();
            table.Attach(sConsoleFont, 1, 3, 3, 4,
             AttachOptions.Expand | AttachOptions.Fill,
             0, 4, 4);

            table.ShowAll();
            ((Container)dialog.Child).Add(table);

            chooseDialog = new FileChooserDialog("Choose MSPDebug binary",
            dialog, FileChooserAction.Open,
            new object[]{Stock.Cancel, ResponseType.Cancel,
                 Stock.Ok, ResponseType.Ok});
            chooseDialog.DefaultResponse = ResponseType.Ok;
        }
		public void Dispose ()
		{
			if (GotoLineDialog != null) {
				GotoLineDialog.Dispose ();
				GotoLineDialog = null;
				line_number_entry = null;
				IsVisible = false;
			}
		}
Пример #12
0
 static ErrorDialog()
 {
     XML gxml = new Glade.XML (null,
                   WorkbenchSingleton.GLADEFILE,
                   "ErrorDialog",
                   null);
     dialog = (Dialog) gxml["ErrorDialog"];
     Gtk.TextView errorTextView = (TextView) gxml["errorTextView"];
     errorBuffer = errorTextView.Buffer;
 }
Пример #13
0
 static ImportDialog()
 {
     gxml = new Glade.XML (null,
                   WorkbenchSingleton.GLADEFILE,
                   "ImportDialog",
                   null);
     importDialog = (Dialog) gxml["ImportDialog"];
     typeCombo = (Combo) gxml["typeCombo"];
     formatCombo = (Combo) gxml["formatCombo"];
     okButton = (Button) gxml["okButton"];
 }
		private bool RunDialog (Dialog dlg)
		{
			bool result = false;
			try {	
				if (dlg.Run () == (int)ResponseType.Ok)
					result = true;
			} finally {
				dlg.Destroy ();
			}
			return result;
Пример #15
0
 void Initialize(Window parent)
 {
     Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("LadderLogic.Presentation.OpenFileDialog.glade");
     Glade.XML glade = new Glade.XML(stream, "OpenFileDialog", null);
     stream.Close();
     glade.Autoconnect(this);
     thisDialog = ((Gtk.Dialog)(glade.GetWidget("OpenFileDialog")));
     thisDialog.Modal = true;
     thisDialog.TransientFor = parent;
     thisDialog.SetPosition (WindowPosition.Center);
 }
Пример #16
0
        public GladeDialog(string name)
            : base(name)
        {
            dialog = base.Window as Dialog;

            if (dialog != null) {
                dialog.Response += delegate (object o, ResponseArgs args) {
                    OnResponse (args.ResponseId);
                };
            }
        }
Пример #17
0
		public static Gtk.Window Create ()
		{
			window = new Dialog ();
			window.Title = "Sized groups";
			window.Resizable = false;
			
			VBox vbox = new VBox (false, 5);
			window.VBox.PackStart (vbox, true, true, 0);
			vbox.BorderWidth = 5;

			size_group = new SizeGroup (SizeGroupMode.Horizontal);

			Frame frame = new Frame ("Color Options");
			vbox.PackStart (frame, true, true, 0);

			Table table = new Table (2, 2, false);
			table.BorderWidth = 5;
			table.RowSpacing = 5;
			table.ColumnSpacing = 10;
			frame.Add (table);

			string [] colors = {"Red", "Green", "Blue", };
			string [] dashes = {"Solid", "Dashed", "Dotted", };
			string [] ends = {"Square", "Round", "Arrow", };

			Add_Row (table, 0, size_group, "_Foreground", colors);
			Add_Row (table, 1, size_group, "_Background", colors);

			frame = new Frame ("Line Options");
			vbox.PackStart (frame, false, false, 0);

			table = new Table (2, 2, false);
			table.BorderWidth = 5;
			table.RowSpacing = 5;
			table.ColumnSpacing = 10;
			frame.Add (table);

			Add_Row (table, 0, size_group, "_Dashing", dashes);
			Add_Row (table, 1, size_group, "_Line ends", ends);

			CheckButton check_button = new CheckButton ("_Enable grouping");
			vbox.PackStart (check_button, false, false, 0);
			check_button.Active = true;
			check_button.Toggled += new EventHandler (Button_Toggle_Cb);

			Button close_button = new Button (Stock.Close);
			close_button.Clicked += new EventHandler (Close_Button);
			window.ActionArea.PackStart (close_button, false, false, 0);
			
			window.ShowAll ();
			return window;
		}
Пример #18
0
 public int Run()
 {
     int rc = 0;
        if(beDlg != null)
        {
     rc = beDlg.Run();
     name = beName.Text;
     beDlg.Hide();
     beDlg.Destroy();
     beDlg = null;
        }
        return rc;
 }
Пример #19
0
 private static void HandleUnhandledException(UnhandledExceptionArgs e)
 {
     Exception ex = e.ExceptionObject as Exception;
     string message = ex == null ? e.ExceptionObject.ToString() : ex.ToString();
     string title = "Unhandled exception";
     DialogFlags flags = DialogFlags.Modal | DialogFlags.DestroyWithParent;
     Dialog dialog = new Dialog(title, MainWindow, flags);
     Label label = new Label(message);
     VBox vBox = (VBox)dialog.Child;
     vBox.Add(label);
     dialog.ShowAll();
     e.ExitApplication = false;
 }
Пример #20
0
 public int Run()
 {
     int rc = 0;
        if(NewSlogDialog != null)
        {
     rc = NewSlogDialog.Run();
     name = NameEntry.Text;
     NewSlogDialog.Hide();
     NewSlogDialog.Destroy();
     NewSlogDialog = null;
        }
        return rc;
 }
Пример #21
0
        private static Gtk.Dialog Alert(string primary, string secondary, Image aImage, Gtk.Window parent)
        {
            Gtk.Dialog retval = new Gtk.Dialog("", parent, Gtk.DialogFlags.DestroyWithParent);

              // graphic items
              Gtk.HBox hbox;
              		Gtk.VBox labelBox;
              		Gtk.Label labelPrimary;
              		Gtk.Label labelSecondary;

            // set-up dialog
            retval.Modal=true;
            retval.BorderWidth=6;
            retval.HasSeparator=false;
            retval.Resizable=false;

            retval.VBox.Spacing=12;

            hbox=new Gtk.HBox();
            hbox.Spacing=12;
            hbox.BorderWidth=6;
            retval.VBox.Add(hbox);

            // set-up image
            aImage.Yalign=0.0F;
            hbox.Add(aImage);

            // set-up labels
            labelPrimary=new Gtk.Label();
            labelPrimary.Yalign=0.0F;
            labelPrimary.Xalign=0.0F;
            labelPrimary.UseMarkup=true;
            labelPrimary.Wrap=true;

            labelSecondary=new Gtk.Label();
            labelSecondary.Yalign=0.0F;
            labelSecondary.Xalign=0.0F;
            labelSecondary.UseMarkup=true;
            labelSecondary.Wrap=true;

            labelPrimary.Markup="<span weight=\"bold\" size=\"larger\">"+primary+"</span>";
            labelSecondary.Markup="\n"+secondary;

            labelBox=new VBox();
            labelBox.Add(labelPrimary);
            labelBox.Add(labelSecondary);

            hbox.Add(labelBox);

            return retval;
        }
Пример #22
0
        protected void buttonOKClickedHandler (object sender, EventArgs e)
        {
           
            string fileName = tbx_fileName.Text.Trim ();
            string fileNameAndPath;
            if (!fileName.EndsWith (s_fileExtension)) {
                fileName += s_fileExtension;
            }
            fileNameAndPath = tbx_dirPath.Text + System.IO.Path.DirectorySeparatorChar + fileName;

            //warn the user if the file already exists
            if (System.IO.File.Exists (fileNameAndPath)) {
                //show message dialog
                Dialog dialog = null;
                ResponseType response = ResponseType.None;

                try {
                    dialog = new Dialog (
                        "Warning",
                        this,
                        DialogFlags.DestroyWithParent | DialogFlags.Modal,
                        "Ok", ResponseType.Yes,
                        "No", ResponseType.No
                    );
                    dialog.VBox.Add (new Label ("\n\n" + OVERWIRTE_WARNING_MESSAGE + "  \n"));
                    dialog.ShowAll ();

                    response = (ResponseType)dialog.Run ();
      
                    dialog.Destroy ();
                    if (response == ResponseType.No)
                        Results = false;
                    else 
                        Results = true;
                
                } catch (Exception ex) {
                    Console.WriteLine (ex.ToString ());
                }            
            } else {
                Results = true;
            } 

                _experiment.ExperimentInfo.Name = tbx_experimentName.Text;
                //_experiment.ExperimentInfo.FilePath= flw_choseFile.CurrentFolder +"/"+ fileName;
                _experiment.ExperimentInfo.FilePath = fileNameAndPath;//tbx_dirPath.Text +"/"+ fileName;
                _experiment.ExperimentInfo.Author = tbx_author.Text;
                _experiment.ExperimentInfo.Description = tbx_description.Buffer.Text;

                this.Destroy ();
      
        }
Пример #23
0
 static AboutDialog()
 {
     XML gxml = new Glade.XML (null,
                   WorkbenchSingleton.GLADEFILE,
                   "AboutDialog",
                   null);
     dialog = (Dialog) gxml["AboutDialog"];
     buildLabel = (Label) gxml["buildLabel"];
     Gtk.Image image = (Gtk.Image) gxml["image"];
     Gdk.Pixbuf icon = new Pixbuf (null,
                       "simetron-hicolor-48x48.png");
     image.Pixbuf = icon;
     gxml.Autoconnect (typeof (AboutDialog));
 }
Пример #24
0
		public void CreateGui() 
		{
			dialog = new Dialog ();
			dialog.Title = "Login";
			dialog.BorderWidth = 3;
			dialog.VBox.BorderWidth = 5;
			dialog.HasSeparator = false;

			Frame frame = new Frame ("Connection");
			string image = Stock.DialogInfo;
			
			HBox hbox = new HBox (false, 2);
			hbox.BorderWidth = 5;
			hbox.PackStart (new Gtk.Image (image, IconSize.Dialog), true, true, 0);
		
			Table table = new Table (2, 3, false);
			hbox.PackStart (table);
			table.ColumnSpacing = 4;
			table.RowSpacing = 4;
			Label label = null;

			label = Label.NewWithMnemonic ("_Provider");
			table.Attach (label, 0, 1, 0, 1);
			providerOptionMenu = CreateProviderOptionMenu();
			table.Attach (providerOptionMenu, 1, 2, 0, 1);
			
			label = Label.NewWithMnemonic ("_Connection String");
			table.Attach (label, 0, 1, 1, 2);
			connection_entry = new Entry ();
			table.Attach (connection_entry, 1, 2, 1, 2);

			frame.Add (hbox);

			dialog.VBox.PackStart (frame, true, true, 0);

			Button button = null;
			button = new Button(Stock.Ok);
			button.Clicked += new EventHandler (Connect_Action);
			button.CanDefault = true;
			dialog.ActionArea.PackStart (button, true, true, 0);
			button.GrabDefault ();

			button = new Button(Stock.Cancel);
			button.Clicked += new EventHandler (Dialog_Cancel);
			dialog.ActionArea.PackStart (button, true, true, 0);
			dialog.Modal = true;

			dialog.ShowAll ();
		}
Пример #25
0
        protected override void BuildUI()
        {
            base.BuildUI ();

            string title = Catalog.GetString ("Sharpen");
            dialog = new Gtk.Dialog (title, (Gtk.Window) this,
                         DialogFlags.DestroyWithParent, new object [0]);
            dialog.BorderWidth = 12;
            dialog.VBox.Spacing = 6;

            Gtk.Table table = new Gtk.Table (3, 2, false);
            table.ColumnSpacing = 6;
            table.RowSpacing = 6;

            table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Amount:"))), 0, 1, 0, 1);
            table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Radius:"))), 0, 1, 1, 2);
            table.Attach (SetFancyStyle (new Gtk.Label (Catalog.GetString ("Threshold:"))), 0, 1, 2, 3);

            SetFancyStyle (amount_spin = new Gtk.SpinButton (0.00, 100.0, .01));
            SetFancyStyle (radius_spin = new Gtk.SpinButton (1.0, 50.0, .01));
            SetFancyStyle (threshold_spin = new Gtk.SpinButton (0.0, 50.0, .01));
            amount_spin.Value = .5;
            radius_spin.Value = 5;
            threshold_spin.Value = 0.0;

            amount_spin.ValueChanged += HandleSettingsChanged;
            radius_spin.ValueChanged += HandleSettingsChanged;
            threshold_spin.ValueChanged += HandleSettingsChanged;

            table.Attach (amount_spin, 1, 2, 0, 1);
            table.Attach (radius_spin, 1, 2, 1, 2);
            table.Attach (threshold_spin, 1, 2, 2, 3);

            Gtk.Button cancel_button = new Gtk.Button (Gtk.Stock.Cancel);
            cancel_button.Clicked += HandleCancelClicked;
            dialog.AddActionWidget (cancel_button, Gtk.ResponseType.Cancel);

            Gtk.Button ok_button = new Gtk.Button (Gtk.Stock.Ok);
            ok_button.Clicked += HandleOkClicked;
            dialog.AddActionWidget (ok_button, Gtk.ResponseType.Cancel);

            Destroyed += HandleLoupeDestroyed;

            table.ShowAll ();
            dialog.VBox.PackStart (table);
            dialog.ShowAll ();
        }
Пример #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicCodeTests.UI.ProjectPreferencesDialog"/> class.
        /// </summary>
        public ProjectDialog(Window parent, Project project)
        {
            Project = project;

            XML gxml = new XML("CodeWindow.glade", "ProjectDialog", null);
            gxml.Autoconnect(this);
            GtkDialog = nbPreferences.Toplevel as Dialog;
            //			GtkDialog.Reparent(parent as Widget);
            GtkDialog.Modal = GtkDialog.DestroyWithParent = true;

            storeReferencePaths = new NodeStore(typeof(Project.ReferencePathTreeNode));
            nvReferencePaths = new NodeView(storeReferencePaths);
            swReferencePaths.Add(nvReferencePaths);
            nvReferencePaths.AppendColumn("Reference Path", new CellRendererText(), "text", 0);

            Update();
        }
Пример #27
0
        internal static string TakePwd (Window parentWindow, string challengePwd, string experimentPwd)
        {              
            var passwordPickerDialog = new InsertPassword ();       
            string passwordFromUser = null;
            if (passwordPickerDialog.Run () == (int)Gtk.ResponseType.Ok) {
                //check pwds here
                passwordFromUser = passwordPickerDialog.userEnteredPassword;
                if (string.IsNullOrEmpty (passwordFromUser)) {
                    //show alert dialog
                    Dialog dialog = new Dialog (
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add (new Label ("Please insert a valid password")); 
                    dialog.ShowAll ();
                    dialog.Run ();
                    dialog.Destroy ();

                    return null;

                } else if (!checkPasswords (passwordFromUser, challengePwd, experimentPwd)) {
                    //show alert
                    Dialog dialog = new Dialog (
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add (new Label ("Entered password is not valid")); 
                    dialog.ShowAll ();
                    dialog.Run ();
                    dialog.Destroy ();

                    return null;
                }

                return passwordFromUser;
            } 

            passwordPickerDialog.Destroy ();
            return null;  
        }
Пример #28
0
        private void Initialize(Window parent)
        {
            var stream = Assembly
                .GetExecutingAssembly()
                .GetManifestResourceStream("LadderLogic.Presentation.UpdateDialog.glade");

            var glade = new Glade.XML(stream, "dialog1", null);
            if (stream != null)
            {
                stream.Close();
            }

            //Glade.XML glade = Glade.XML.FromAssembly("UnhandledExceptionDialog.glade","UnhandledExceptionDialog", null);
            //stream.Close();
            glade.Autoconnect(this);
            _thisDialog = ((Dialog)(glade.GetWidget("dialog1")));
            _thisDialog.SetPosition(WindowPosition.Center);
        }
Пример #29
0
 /// <summary>
 /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
 /// </summary>
 public static int RunCustomDialog(Gtk.Dialog dialog, Gtk.Window parent)
 {
     if (parent == null)
     {
         if (dialog.TransientFor != null)
         {
             parent = dialog.TransientFor;
         }
         else
         {
             parent = GetDefaultParent(dialog);
         }
     }
     dialog.TransientFor      = parent;
     dialog.DestroyWithParent = true;
     PlaceDialog(dialog, parent);
     return(GtkWorkarounds.RunDialogWithNotification(dialog));
 }
Пример #30
0
        public override bool SelectMediaFiles(MediaFileSet fileSet)
        {
            bool ret = false;
            MediaFileSetSelection fileselector = new MediaFileSetSelection(false);

            Gtk.Dialog d = new Gtk.Dialog(Catalog.GetString("Select video files"),
                                          MainWindow.Toplevel as Gtk.Window,
                                          DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                          Gtk.Stock.Cancel, ResponseType.Cancel,
                                          Gtk.Stock.Ok, ResponseType.Ok);
            fileselector.Show();
            fileselector.FileSet = fileSet.Clone();
            d.VBox.Add(fileselector);
            App.Current.Dialogs.WarningMessage(Catalog.GetString("Some video files are missing for this project"));
            while (d.Run() == (int)ResponseType.Ok)
            {
                if (!fileselector.FileSet.CheckFiles())
                {
                    App.Current.Dialogs.WarningMessage(Catalog.GetString("Some video files are still missing for this project."), d);
                    continue;
                }
                if (fileselector.FileSet.Count == 0)
                {
                    App.Current.Dialogs.WarningMessage(Catalog.GetString("You need at least 1 video file for the main angle"));
                    continue;
                }
                ret = true;
                break;
            }
            if (ret)
            {
                // We need to update the fileset as it might have changed. Indeed if multi camera is not supported
                // widget will propose only one media file selector and will return a smaller fileset than the
                // one provided originally.
                fileSet.Clear();
                for (int i = 0; i < fileselector.FileSet.Count; i++)
                {
                    fileSet.Add(fileselector.FileSet [i]);
                }
            }
            d.Destroy();
            return(ret);
        }
Пример #31
0
        public GladeDialog(Window parentWindow, string dialogName)
            : base(dialogName)
        {
            dialog = (Dialog)base.Window;
            dialog.Modal = true;
            dialog.WindowPosition = WindowPosition.CenterOnParent;
            dialog.TransientFor = parentWindow;

            // Dialog button order is reversed on windows
            if (Environment.OSVersion.Platform != PlatformID.Unix) {
                if (dialog.ActionArea != null) {
                    HButtonBox box = dialog.ActionArea;
                    int count = 0;
                    foreach (Widget widget in box.AllChildren) {
                        box.ReorderChild (widget, ++count);
                    }
                }
            }
        }
Пример #32
0
        void Initialize(Window parent)
        {
            var gladeRes = AppController.Instance.Config.AboutDialog;
            var stream = Assembly
                .GetExecutingAssembly()
                .GetManifestResourceStream(gladeRes);

            var glade = new Glade.XML(stream, AppController.Instance.Config.AboutDialogName, null);
            if (stream != null)
            {
                stream.Close();
            }

            glade.Autoconnect(this);
            _thisDialog = ((Dialog)(glade.GetWidget(AppController.Instance.Config.AboutDialogName)));
            _thisDialog.Modal = true;
            _thisDialog.TransientFor = parent;
            _thisDialog.SetPosition (WindowPosition.Center);
        }
Пример #33
0
 /// <summary>
 /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
 /// </summary>
 public static int RunCustomDialog(Gtk.Dialog dialog, Window parent)
 {
     if (parent == null)
     {
         if (dialog.TransientFor != null)
         {
             parent = dialog.TransientFor;
         }
         else
         {
             parent = GetDefaultParent(dialog);
         }
     }
     dialog.TransientFor      = parent;
     dialog.DestroyWithParent = true;
     if (dialog.Title == null)
     {
         dialog.Title = BrandingService.ApplicationName;
     }
     PlaceDialog(dialog, parent);
     return(Mono.TextEditor.GtkWorkarounds.RunDialogWithNotification(dialog));
 }
Пример #34
0
        public void OnAddPls()
        {
            Hyena.Log.Information("add playlist");
            Gtk.Dialog dlg = new Gtk.Dialog();
            dlg.Title = "Add Playlist";
            Gtk.Entry pls = new Gtk.Entry();
            pls.WidthChars = 40;
            Gtk.Label lbl = new Gtk.Label("Playlist name:");
            Gtk.HBox  hb  = new Gtk.HBox();
            hb.PackStart(lbl, false, false, 1);
            hb.PackEnd(pls);
            dlg.VBox.PackStart(hb);
            dlg.AddButton(Gtk.Stock.Cancel, 0);
            dlg.AddButton(Gtk.Stock.Ok, 1);
            dlg.VBox.ShowAll();
            string plsname = "";

            while (plsname == "")
            {
                int response = dlg.Run();
                if (response == 0)
                {
                    dlg.Hide();
                    dlg.Destroy();
                    return;
                }
                else
                {
                    plsname = pls.Text.Trim();
                }
            }
            dlg.Hide();
            dlg.Destroy();
            _pls = _col.NewPlayList(plsname);
            _model.Reload();
            _pls_model.SetPlayList(_pls);
        }
Пример #35
0
        /// <summary>
        /// Запуск простого диалога редактирования справочника
        /// </summary>
        /// <returns>Возвращает экземпляр сохраненного объекта, загруженного в сессии диалога. То есть не переданный объект.
        /// Если пользователь отказался от сохранения возвращаем null.
        /// </returns>
        /// <param name="editObject">Объект для редактирования. Если null создаем новый объект.</param>
        public static object RunSimpleDialog(Window parent, System.Type objectType, object editObject)
        {
            string actionTitle = null;
            string dialogTitle = null;

            if (editObject == null)
            {
                var names = DomainHelper.GetSubjectNames(objectType);
                if (names != null && names.Gender != GrammaticalGender.Unknown)
                {
                    switch (names.Gender)
                    {
                    case GrammaticalGender.Feminine:
                        actionTitle = $"Простое редактирование новой {names.Genitive}";
                        dialogTitle = $"Новая {names.Nominative}";
                        break;

                    case GrammaticalGender.Masculine:
                        actionTitle = $"Простое редактирование нового {names.Genitive}";
                        dialogTitle = $"Новый {names.Nominative}";
                        break;

                    case GrammaticalGender.Neuter:
                        actionTitle = $"Простое редактирование нового {names.Genitive}";
                        dialogTitle = $"Новое {names.Nominative}";
                        break;
                    }
                }
                else
                {
                    actionTitle = "Диалог простого редактирования";
                }
            }
            else
            {
                actionTitle = $"Простое редактирование '{DomainHelper.GetObjectTilte(editObject)}'";
                var names = DomainHelper.GetSubjectNames(objectType);
                if (names != null && names.Genitive != null)
                {
                    dialogTitle = $"Редактирование {names.Genitive}";
                }
            }
            using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot(actionTitle))
            {
                //Создаем объект редактирования
                object tempObject;
                if (editObject == null)
                {
                    tempObject = Activator.CreateInstance(objectType);
                }
                else
                {
                    if (editObject is IDomainObject)
                    {
                        tempObject = uow.GetById(objectType, (editObject as IDomainObject).Id);
                    }
                    else
                    {
                        throw new InvalidCastException("У объекта переданного для запуска простого диалога, нет интерфейса IDomainObject, объект не может быть открыт.");
                    }
                }

                //Создаем диалог
                Gtk.Dialog editDialog = new Gtk.Dialog(dialogTitle ?? "Редактирование", parent, Gtk.DialogFlags.Modal);
                editDialog.AddButton("Отмена", ResponseType.Cancel);
                editDialog.AddButton("Сохранить", ResponseType.Ok);
                Gtk.Table editDialogTable = new Table(1, 2, false);
                Label     LableName       = new Label("Название:");
                LableName.Justify = Justification.Right;
                editDialogTable.Attach(LableName, 0, 1, 0, 1);
                yEntry inputNameEntry = new yEntry();
                inputNameEntry.WidthRequest = 300;
                inputNameEntry.Binding.AddBinding(tempObject, "Name", w => w.Text).InitializeFromSource();
                editDialogTable.Attach(inputNameEntry, 1, 2, 0, 1);
                editDialog.VBox.Add(editDialogTable);

                //Запускаем диалог
                editDialog.ShowAll();
                int result = editDialog.Run();
                if (result == (int)ResponseType.Ok)
                {
                    string name = (string)tempObject.GetPropertyValue("Name");
                    if (String.IsNullOrWhiteSpace(name))
                    {
                        var    att         = DomainHelper.GetSubjectNames(tempObject);
                        string subjectName = att != null ? att.Accusative : null;
                        string msg         = String.Format("Название {0} пустое и не будет сохранено.",
                                                           string.IsNullOrEmpty(subjectName) ? "элемента справочника" : subjectName
                                                           );
                        MessageDialogHelper.RunWarningDialog(msg);
                        logger.Warn(msg);
                        editDialog.Destroy();
                        return(null);
                    }
                    var list = uow.Session.CreateCriteria(objectType)
                               .Add(Restrictions.Eq("Name", name))
                               .Add(Restrictions.Not(Restrictions.IdEq(DomainHelper.GetId(tempObject))))
                               .List();
                    if (list.Count > 0)
                    {
                        var    att         = DomainHelper.GetSubjectNames(tempObject);
                        string subjectName = att != null?att.Nominative.StringToTitleCase() : null;

                        string msg = String.Format("{0} с таким названием уже существует.",
                                                   string.IsNullOrEmpty(subjectName) ? "Элемент справочника" : subjectName
                                                   );
                        MessageDialogHelper.RunWarningDialog(msg);
                        logger.Warn(msg);
                        editDialog.Destroy();
                        return(list [0]);
                    }
                    uow.TrySave(tempObject);
                    uow.Commit();
                }
                else
                {
                    tempObject = null;
                }

                editDialog.Destroy();
                return(tempObject);
            }
        }
Пример #36
0
        /* Private members */

        private Gtk.Dialog BuildDialog(Window parent)
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Character Encodings"), parent, DialogFlags.Modal | DialogFlagsUseHeaderBar);

            dialog.DefaultWidth  = WidgetStyles.DialogWidthMedium;
            dialog.DefaultHeight = WidgetStyles.DialogHeightMedium;

            Grid grid = new Grid();

            grid.RowSpacing        = WidgetStyles.RowSpacingMedium;
            grid.ColumnSpacing     = WidgetStyles.ColumnSpacingLarge;
            grid.BorderWidth       = WidgetStyles.BorderWidthMedium;
            grid.ColumnHomogeneous = true;

            /* Left part: Available VBox */

            Label availLabel = new Label("<b>" + Catalog.GetString("Available Encodings") + "</b>");

            availLabel.UseMarkup = true;
            availLabel.Halign    = Align.Start;
            grid.Attach(availLabel, 0, 0, 1, 1);

            ScrolledWindow availScrolledWindow = new ScrolledWindow();

            availScrolledWindow.ShadowType = ShadowType.EtchedIn;
            availScrolledWindow.Expand     = true;
            availableTreeView = new TreeView();
            availScrolledWindow.Add(availableTreeView);
            grid.Attach(availScrolledWindow, 0, 1, 1, 1);

            buttonAdd = new Button("gtk-add");
            grid.Attach(buttonAdd, 0, 2, 1, 1);

            /* Right part: Shown VBox */

            Label shownLabel = new Label("<b>" + Catalog.GetString("Chosen Encodings") + "</b>");

            shownLabel.UseMarkup = true;
            shownLabel.Halign    = Align.Start;
            grid.Attach(shownLabel, 1, 0, 1, 1);

            ScrolledWindow shownScrolledWindow = new ScrolledWindow();

            shownScrolledWindow.ShadowType = ShadowType.EtchedIn;
            shownScrolledWindow.Expand     = true;
            shownTreeView = new TreeView();
            shownScrolledWindow.Add(shownTreeView);
            grid.Attach(shownScrolledWindow, 1, 1, 1, 1);

            buttonRemove = new Button("gtk-remove");
            grid.Attach(buttonRemove, 1, 2, 1, 1);

            FillAvailableEncodings();
            FillShownEncodings();

            dialog.ContentArea.Add(grid);
            dialog.ContentArea.ShowAll();

            ConnectSignals();

            return(dialog);
        }
Пример #37
0
        /* Private methods */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Synchronize Timings"), Base.Ui.Window, DialogFlags.DestroyWithParent,
                                               Util.GetStockLabel("gtk-close"), ResponseType.Cancel, Catalog.GetString("_Apply"), ResponseType.Ok);

            dialog.DefaultResponse = ResponseType.Ok;
            dialog.DefaultWidth    = WidgetStyles.DialogWidthXSmall;
            dialog.DefaultHeight   = WidgetStyles.DialogHeightMedium;

            Box box = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);

            box.BorderWidth = WidgetStyles.BorderWidthMedium;

            //Sync Points frame

            Box syncVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);

            syncVBox.MarginLeft = WidgetStyles.FrameContentSpacingMedium;
            syncVBox.Spacing    = WidgetStyles.BoxSpacingMedium;

            ScrolledWindow syncWindow = new ScrolledWindow();

            syncWindow.ShadowType = ShadowType.EtchedIn;
            syncWindow.Expand     = true;
            syncPointsTree        = new TreeView();
            CreateColumns(syncPointsTree);
            syncPointsTree.Model              = syncPoints.Model;
            syncPointsTree.Selection.Changed += OnSelectionChanged;
            syncWindow.Add(syncPointsTree);
            syncVBox.Add(syncWindow);

            Box syncButtonsHBox = new Box(Orientation.Horizontal, WidgetStyles.BoxSpacingMedium);

            buttonAdd = new Button("gtk-add");
            UpdateAddButtonSensitivity();
            buttonAdd.Clicked += OnAdd;
            syncButtonsHBox.Add(buttonAdd);

            buttonRemove           = new Button("gtk-remove");
            buttonRemove.Sensitive = false;
            buttonRemove.Clicked  += OnRemove;
            syncButtonsHBox.Add(buttonRemove);

            syncVBox.Add(syncButtonsHBox);
            Frame syncFrame = Util.CreateFrameWithContent(Catalog.GetString("Sync Points"), syncVBox);

            box.Add(syncFrame);


            //Apply To frame

            Box applyToFrameVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);

            applyToFrameVBox.MarginLeft  = WidgetStyles.FrameContentSpacingMedium;
            applyToFrameVBox.Spacing     = WidgetStyles.BoxSpacingMedium;
            allSubtitlesRadioButton      = new RadioButton(DialogStrings.ApplyToAllSubtitles);
            selectedSubtitlesRadioButton = new RadioButton(allSubtitlesRadioButton, Catalog.GetString("Subtitles between sync points"));
            applyToFrameVBox.Add(allSubtitlesRadioButton);
            applyToFrameVBox.Add(selectedSubtitlesRadioButton);

            Frame applyToFrame = Util.CreateFrameWithContent(Catalog.GetString("Apply To"), applyToFrameVBox);

            box.Add(applyToFrame);


            //Status frame

            Box statusFrameVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);     //Used so we can have a border

            statusFrameVBox.MarginLeft = WidgetStyles.FrameContentSpacingMedium;
            statusFrameVBox.Spacing    = WidgetStyles.BoxSpacingMedium;
            statusMessageLabel         = new Label();
            statusMessageLabel.Wrap    = true;
            statusFrameVBox.Add(statusMessageLabel);

            Frame statusFrame = Util.CreateFrameWithContent(Catalog.GetString("Info"), statusFrameVBox);

            box.Add(statusFrame);

            dialog.ContentArea.Add(box);
            dialog.ContentArea.ShowAll();

            return(dialog);
        }
Пример #38
0
        /* Methods */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Shift Timings"), Base.Ui.Window, DialogFlags.DestroyWithParent,
                                               Util.GetStockLabel("gtk-close"), ResponseType.Cancel, Catalog.GetString("Apply"), ResponseType.Ok);

            dialog.DefaultResponse = ResponseType.Ok;
            dialog.DefaultWidth    = 1;  //Needed otherwise the tip label will be displayed in a single line making the dialog have a huge width

            Box box = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingLarge);

            box.BorderWidth = WidgetStyles.BorderWidthMedium;


            //Timing Mode frame

            spinButton            = new SpinButton(new Adjustment(0, 0, 0, 1, 10, 0), 0, 0);
            spinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
            spinButton.Alignment  = 0.5f;
            Button clearButton = new Button(Catalog.GetString("Reset"));

            clearButton.Clicked    += OnClear;
            videoButton             = new Button(Catalog.GetString("Set From Video"));
            videoButton.TooltipText = Catalog.GetString("Sets the shift amount in order for the selected subtitles to start at the current video position.");
            videoButton.Clicked    += OnSetFromVideo;

            Box timingModeHBox = new Box(Orientation.Horizontal, WidgetStyles.BoxSpacingMedium);

            timingModeHBox.MarginLeft = WidgetStyles.FrameContentSpacingMedium;
            timingModeHBox.Add(spinButton);
            timingModeHBox.Add(clearButton);
            timingModeHBox.Add(videoButton);

            Frame timingModeFrame = Util.CreateFrameWithContent(Catalog.GetString("Amount"), timingModeHBox);

            box.Add(timingModeFrame);


            //Apply To frame

            allSubtitlesRadioButton                 = new RadioButton(DialogStrings.ApplyToAllSubtitles);
            selectedSubtitlesRadioButton            = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToSelection);
            fromFirstSubtitleToSelectionRadioButton = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToFirstToSelection);
            fromSelectionToLastSubtitleRadioButton  = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToSelectionToLast);

            Box applyToFrameVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);

            applyToFrameVBox.MarginLeft = WidgetStyles.FrameContentSpacingMedium;
            applyToFrameVBox.Add(allSubtitlesRadioButton);
            applyToFrameVBox.Add(selectedSubtitlesRadioButton);
            applyToFrameVBox.Add(fromFirstSubtitleToSelectionRadioButton);
            applyToFrameVBox.Add(fromSelectionToLastSubtitleRadioButton);

            Frame applyToFrame = Util.CreateFrameWithContent(Catalog.GetString("Apply To"), applyToFrameVBox);

            box.Add(applyToFrame);


            //Tips label

            Label label = new Label("<small><i>" + Catalog.GetString("Tip: alternatively use Shift + Numpad Plus/Minus to shift timings directly from the main window.") + "</i></small>");

            label.UseMarkup = true;
            label.Wrap      = true;
            box.Add(label);

            dialog.ContentArea.Add(box);

            timingMode = Base.TimingMode;
            UpdateFromTimingMode();
            UpdateFromSelection();
            UpdateVideoButtonSensitivity();

            ConnectEventHandlers();

            dialog.ContentArea.ShowAll();

            return(dialog);
        }
Пример #39
0
 public static int RunCustomDialog(Gtk.Dialog dialog)
 {
     return(RunCustomDialog(dialog, rootWindow));
 }
Пример #40
0
        protected void OnButtonPickDatePeriodClicked(object sender, EventArgs e)
        {
            #region Widget creation
            Window parentWin  = (Window)Toplevel;
            var    selectDate = new Gtk.Dialog("Укажите период", parentWin, DialogFlags.DestroyWithParent);
            selectDate.Modal = true;
            selectDate.AddButton("Отмена", ResponseType.Cancel);
            selectDate.AddButton("Ok", ResponseType.Ok);

            periodSummary = new Label();
            selectDate.VBox.Add(periodSummary);

            HBox hbox      = new HBox(true, 6);
            var  startVbox = new VBox(false, 3);
            var  endVbox   = new VBox(false, 3);

            StartDateCalendar = new Calendar();
            StartDateCalendar.DisplayOptions = DisplayOptions;
            StartDateCalendar.DaySelected   += StartDateCalendar_DaySelected;
            StartDateCalendar.MonthChanged  += StartDateCalendar_MonthChanged;
            StartDateCalendar.Day            = 0;
            StartDateCalendar_MonthChanged(null, null);

            EndDateCalendar = new Calendar();
            EndDateCalendar.DisplayOptions = DisplayOptions;
            EndDateCalendar.DaySelected   += EndDateCalendar_DaySelected;
            EndDateCalendar.MonthChanged  += EndDateCalendar_MonthChanged;
            EndDateCalendar.Day            = 0;
            EndDateCalendar_MonthChanged(null, null);

            if (CalendarFontSize.HasValue)
            {
                var desc = new FontDescription {
                    AbsoluteSize = CalendarFontSize.Value * 1000
                };
                StartDateCalendar.ModifyFont(desc);
                EndDateCalendar.ModifyFont(desc);
            }

            StartDateEntry              = new DatePicker();
            StartDateEntry.DateChanged += StartDateEntry_DateChanged;

            EndDateEntry              = new DatePicker();
            EndDateEntry.DateChanged += EndDateEntry_DateChanged;

            startVbox.Add(StartDateCalendar);
            startVbox.Add(StartDateEntry);
            endVbox.Add(EndDateCalendar);
            endVbox.Add(EndDateEntry);

            hbox.Add(startVbox);
            hbox.Add(endVbox);

            selectDate.VBox.Add(hbox);
            selectDate.ShowAll();

            StartDateEntry.HideCalendarButton = true;
            EndDateEntry.HideCalendarButton   = true;

            if (SetCurrentDateByDefault && !StartDateOrNull.HasValue && !EndDateOrNull.HasValue)
            {
                StartDateEntry.DateOrNull = DateTime.Today.Date;
                EndDateEntry.DateOrNull   = DateTime.Today.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else
            {
                StartDateEntry.DateOrNull = StartDateOrNull;
                EndDateEntry.DateOrNull   = EndDateOrNull;
            }
            #endregion

            int response = selectDate.Run();
            if (response == (int)ResponseType.Ok)
            {
                startDate = StartDateEntry.DateOrNull;
                endDate   = EndDateEntry.DateOrNull;
                OnStartDateChanged();
                OnEndDateChanged();
                OnPeriodChanged();
                OnPeriodChangedByUser();
            }

            #region Destroy
            EndDateCalendar.Destroy();
            StartDateCalendar.Destroy();
            StartDateEntry.Destroy();
            EndDateEntry.Destroy();
            startVbox.Destroy();
            endVbox.Destroy();
            hbox.Destroy();
            selectDate.Destroy();
            #endregion
        }
Пример #41
0
        void doDialog()
        {
#if GTK_SHARP_2_6
            bool rename = combo.Active == values.Count + 1;
#else
            bool rename = combo.Active == values.Count;
#endif
            Gtk.Dialog dialog = new Gtk.Dialog(
                rename ? Catalog.GetString("Rename Group") : Catalog.GetString("New Group"),
                combo.Toplevel as Gtk.Window,
                Gtk.DialogFlags.Modal | Gtk.DialogFlags.NoSeparator,
                Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                Gtk.Stock.Ok, Gtk.ResponseType.Ok);
            dialog.DefaultResponse  = Gtk.ResponseType.Ok;
            dialog.HasSeparator     = false;
            dialog.BorderWidth      = 12;
            dialog.VBox.Spacing     = 18;
            dialog.VBox.BorderWidth = 0;

            Gtk.HBox  hbox  = new Gtk.HBox(false, 12);
            Gtk.Label label = new Gtk.Label(rename ? Catalog.GetString("_New name:") : Catalog.GetString("_Name:"));
            Gtk.Entry entry = new Gtk.Entry();
            label.MnemonicWidget = entry;
            hbox.PackStart(label, false, false, 0);
            entry.ActivatesDefault = true;
            if (rename)
            {
                entry.Text = group;
            }
            hbox.PackStart(entry, true, true, 0);
            dialog.VBox.PackStart(hbox, false, false, 0);

            dialog.ShowAll();
            // Have to set this *after* ShowAll
            dialog.ActionArea.BorderWidth = 0;
            dialog.TransientFor           = this.Toplevel as Gtk.Window;
            Gtk.ResponseType response = (Gtk.ResponseType)dialog.Run();
            if (response == Gtk.ResponseType.Cancel || entry.Text.Length == 0)
            {
                dialog.Destroy();
                Value = group;                 // reset combo.Active
                return;
            }

            string oldname = group;
            group = entry.Text;
            dialog.Destroy();

            // FIXME: check that the new name doesn't already exist

            // This will trigger a GroupsChanged, which will eventually
            // update combo.Active
            if (rename)
            {
                manager.Rename(oldname, group);
            }
            else
            {
                manager.Add(group);
            }
        }
Пример #42
0
 public static void AddContent(this Gtk.Dialog dialog, Gtk.Widget widget)
 {
     dialog.ContentArea.Add(widget);
 }
Пример #43
0
 public static int RunCustomDialog(Gtk.Dialog dialog)
 {
     return(RunCustomDialog(dialog, null));
 }
Пример #44
0
 /// <summary>
 /// Places, runs and destroys a transient dialog.
 /// </summary>
 public static int ShowCustomDialog(Gtk.Dialog dialog)
 {
     return(ShowCustomDialog(dialog, null));
 }
Пример #45
0
 public static void SetContentSpacing(this Gtk.Dialog dialog, int spacing)
 {
     dialog.ContentArea.Spacing = spacing;
 }
Пример #46
0
    protected void OnNewScoreCardActionActivated(object sender, EventArgs e)
    {
        Dialog popupNumRounds = new Gtk.Dialog("New ScoreCard", this, DialogFlags.Modal, Stock.Ok, 200, Stock.Cancel, 400);

        Label enterRounds = new Label("Number of Rounds");

        popupNumRounds.VBox.Add(enterRounds);

        int[] list = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
        #pragma warning disable CS0612 // Type or member is obsolete
        Combo comboNumRounds = new Combo();
        #pragma warning restore CS0612 // Type or member is obsolete
        comboNumRounds.PopdownStrings = Array.ConvertAll(list, ele => ele.ToString());
        comboNumRounds.DisableActivate();
        comboNumRounds.SetValueInList(true, false);

        popupNumRounds.VBox.Add(comboNumRounds);
        popupNumRounds.ShowAll();

        int response_value = popupNumRounds.Run();

        if (response_value == 200)
        {
            {
                Dialog popupFighters = new Gtk.Dialog("Enter Fighters", this, DialogFlags.Modal, Stock.Ok, 200, Stock.Cancel, 400);
                popupFighters.BorderWidth     = 4;
                popupFighters.DefaultResponse = (Gtk.ResponseType) 200;


                HBox hbox = new HBox(false, 8);
                hbox.BorderWidth = 8;
                popupFighters.VBox.PackStart(hbox, false, false, 0);

                Image stock = new Image(Stock.DialogQuestion, IconSize.Dialog);
                hbox.PackStart(stock, false, false, 0);

                Table table = new Table(2, 2, false);
                table.RowSpacing    = 4;
                table.ColumnSpacing = 4;
                hbox.PackStart(table, true, true, 0);

                Label label = new Label("Fighter 1");
                table.Attach(label, 0, 1, 0, 1);
                Entry entryFighter1 = new Entry();
                table.Attach(entryFighter1, 1, 2, 0, 1);

                label = new Label("Fighter 2");
                table.Attach(label, 0, 1, 1, 2);
                Entry entryFighter2 = new Entry();
                table.Attach(entryFighter2, 1, 2, 1, 2);
                entryFighter2.ActivatesDefault = true;

                entryFighter1.MaxLength = 40;
                entryFighter2.MaxLength = 40;

                hbox.ShowAll();

                int response_value2 = popupFighters.Run();
                if (response_value2 == 200)
                {
                    DePopulateUI();
                    DePopulateRDTable();

                    this.main_Card = new CombatSportsScore.ScoreCard(Convert.ToByte(comboNumRounds.Entry.Text), entryFighter1.Text.Trim(), entryFighter2.Text.Trim());
                    PopulateRDTable(Convert.ToByte(comboNumRounds.Entry.Text));
                    PopulateUI();
                    PopulateTotals();
                }

                popupFighters.Destroy();
            }
        }

        popupNumRounds.Destroy();
    }
Пример #47
0
        public void Run(object o, EventArgs e)
        {
            Console.WriteLine("EXECUTING ExiflowCreateVersion EXTENSION");

            Window win = new Window("window");

            dialog = new Dialog(dialog_name, win, Gtk.DialogFlags.DestroyWithParent);

            Frame frame_versions = new Frame("new version");
            HBox  hbox_versions  = new HBox();

            frame_versions.Child = hbox_versions;

            // RadioButtons left
            VBox vbox_versions_left = new VBox();

            hbox_versions.PackStart(vbox_versions_left, true, false, 0);
            // EntryBox right
            VBox vbox_versions_right = new VBox();

            hbox_versions.PackStart(vbox_versions_right, true, false, 0);
            vbox_versions_right.PackStart(new_version_entry, true, false, 0);
            vbox_versions_right.PackStart(overwrite_file_ok, true, false, 0);

            Frame frame_resulting_filename = new Frame("resulting filename");
            VBox  vbox_resulting_filename  = new VBox();

            frame_resulting_filename.Child = vbox_resulting_filename;
            vbox_resulting_filename.PackStart(new_filename_label, true, false, 0);
            vbox_resulting_filename.PackStart(overwrite_warning_label, true, false, 0);

            Frame frame_open_with = new Frame("open with");
            VBox  vbox_open_with  = new VBox();

            frame_open_with.Child = vbox_open_with;
            vbox_open_with.PackStart(new_filename_label, true, false, 0);


            new_version_entry.Changed += new EventHandler(on_new_version_entry_changed);
            overwrite_file_ok.Toggled += new EventHandler(on_overwrite_file_ok_toggled);

            gtk_cancel.UseStock = true;
            gtk_cancel.Clicked += CancelClicked;
            gtk_ok.UseStock     = true;
            gtk_ok.Clicked     += OkClicked;

            foreach (Photo p in App.Instance.Organizer.SelectedPhotos())
            {
                this.currentphoto = p;
                //Console.WriteLine ("MimeType: "+ Gnome.Vfs.MimeType.GetMimeTypeForUri (p.DefaultVersionUri.ToString ()));

                //uint default_id = p.DefaultVersionId;
                //Console.WriteLine ("DefaultVersionId: "+default_id);
                //string filename = GetNextIntelligentVersionFileNames (p)[0];

                string [] possiblefilenames = GetNextIntelligentVersionFileNames(p);
                new_version_entry.Text = GetVersionName(possiblefilenames[0].ToString());

                for (int i = 0; i < possiblefilenames.Length; i++)
                {
                    Gtk.RadioButton rb = new Gtk.RadioButton(versionrb, GetVersionName(possiblefilenames[i].ToString()));
                    rb.Clicked += new EventHandler(on_versionrb_changed);
                    vbox_versions_left.PackStart(rb, true, false, 0);
                }

                ComboBox owcb = GetComboBox();
                vbox_open_with.PackStart(owcb, false, true, 0);

                dialog.Modal        = false;
                dialog.TransientFor = null;
            }

            VBox vbox_main = new VBox();

            vbox_main.PackStart(frame_versions);
            vbox_main.PackStart(frame_resulting_filename);
            //vbox_main.PackStart (frame_open_with);

            HButtonBox hbb_ok_cancel = new HButtonBox();

            hbb_ok_cancel.PackStart(gtk_cancel, true, false, 0);
            hbb_ok_cancel.PackStart(gtk_ok, true, false, 0);

            dialog.VBox.PackStart(vbox_main, false, true, 0);
            dialog.ActionArea.PackStart(hbb_ok_cancel, false, true, 0);
            dialog.ShowAll();
        }
Пример #48
0
        /* Private members */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Headers"), Base.Ui.Window, DialogFlags.Modal | DialogFlagsUseHeaderBar,
                                               Util.GetStockLabel("gtk-cancel"), ResponseType.Cancel, Util.GetStockLabel("gtk-apply"), ResponseType.Ok);

            dialog.DefaultResponse = ResponseType.Ok;
            dialog.DefaultWidth    = WidgetStyles.DialogWidthMedium;
            dialog.DefaultHeight   = WidgetStyles.DialogHeightLarge;

            Notebook notebook = new Notebook();

            notebook.Expand      = true;
            notebook.TabPos      = PositionType.Left;
            notebook.BorderWidth = WidgetStyles.BorderWidthMedium;

            Grid grid;

            //Karaoke Lyrics LRC
            grid = CreatePageWithGrid(notebook, "Karaoke Lyrics LRC");
            grid.Attach(CreateLabel(Catalog.GetString("Title:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Title"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Author:")), 0, 1, 1, 1);
            grid.Attach(CreateEntry("Author"), 1, 1, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Artist:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("Artist"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Album:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("Album"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("By:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("FileCreator"), 1, 4, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Version:")), 0, 5, 1, 1);
            grid.Attach(CreateEntry("Version"), 1, 5, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Program:")), 0, 6, 1, 1);
            grid.Attach(CreateEntry("Program"), 1, 6, 1, 1);

            //Karaoke Lyrics VKT
            grid = CreatePageWithGrid(notebook, "Karaoke Lyrics VKT");
            grid.Attach(CreateLabel(Catalog.GetString("Author:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Author"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Source:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("Source"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Date:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("Date"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Frame Rate:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("FrameRate"), 1, 4, 1, 1);

            //MPSub
            grid = CreatePageWithGrid(notebook, "MPSub");
            grid.Attach(CreateLabel(Catalog.GetString("Title:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Title"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("File:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("MPSubFileProperties"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Author:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("Author"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Note:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("Comment"), 1, 4, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Media Type:")), 0, 5, 1, 1);
            ComboBoxText comboBoxMPSubMediaType = CreateComboBoxText("MPSubMediaType",
                                                                     SubtitleFormatMPSub.HeaderMediaTypeAudio, Catalog.GetString("Audio"),
                                                                     SubtitleFormatMPSub.HeaderMediaTypeVideo, Catalog.GetString("Video"));

            grid.Attach(comboBoxMPSubMediaType, 1, 5, 1, 1);

            //Sub Station Alpha / ASS
            grid = CreatePageWithGrid(notebook, "Sub Station Alpha / ASS");
            grid.Attach(CreateLabel(Catalog.GetString("Title:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Title"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Original Script:")), 0, 1, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaOriginalScript"), 1, 1, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Original Translation:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaOriginalTranslation"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Original Editing:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaOriginalEditing"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Original Timing:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaOriginalTiming"), 1, 4, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Original Script Checking:")), 0, 5, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaOriginalScriptChecking"), 1, 5, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Script Updated By:")), 0, 6, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaScriptUpdatedBy"), 1, 6, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Collisions:")), 0, 7, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaCollisions"), 1, 7, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Timer:")), 0, 8, 1, 1);
            grid.Attach(CreateEntry("SubStationAlphaTimer"), 1, 8, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Play Res X:")), 0, 9, 1, 1);
            grid.Attach(CreateSpinButton("SubStationAlphaPlayResX", 0, 10000, 1), 1, 9, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Play Res Y:")), 0, 10, 1, 1);
            grid.Attach(CreateSpinButton("SubStationAlphaPlayResY", 0, 10000, 1), 1, 10, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Play Depth:")), 0, 11, 1, 1);
            grid.Attach(CreateSpinButton("SubStationAlphaPlayDepth", 0, 10000, 1), 1, 11, 1, 1);

            //SubViewer 1
            grid = CreatePageWithGrid(notebook, "SubViewer 1");
            grid.Attach(CreateLabel(Catalog.GetString("Title:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Title"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Author:")), 0, 1, 1, 1);
            grid.Attach(CreateEntry("Author"), 1, 1, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Source:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("Source"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Program:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("Program"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("File Path:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("FilePath"), 1, 4, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Delay:")), 0, 5, 1, 1);
            grid.Attach(CreateSpinButton("Delay", 0, 1000000, 1), 1, 5, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("CD Track:")), 0, 6, 1, 1);
            grid.Attach(CreateSpinButton("CDTrack", 1, 1000, 1), 1, 6, 1, 1);

            //SubViewer 2
            grid = CreatePageWithGrid(notebook, "SubViewer 2");
            grid.Attach(CreateLabel(Catalog.GetString("Title:")), 0, 0, 1, 1);
            grid.Attach(CreateEntry("Title"), 1, 0, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Author:")), 0, 1, 1, 1);
            grid.Attach(CreateEntry("Author"), 1, 1, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Source:")), 0, 2, 1, 1);
            grid.Attach(CreateEntry("Source"), 1, 2, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Program:")), 0, 3, 1, 1);
            grid.Attach(CreateEntry("Program"), 1, 3, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("File Path:")), 0, 4, 1, 1);
            grid.Attach(CreateEntry("FilePath"), 1, 4, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Font Name:")), 0, 5, 1, 1);
            grid.Attach(CreateEntry("SubViewer2FontName"), 1, 5, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Font Color:")), 0, 6, 1, 1);
            grid.Attach(CreateEntry("SubViewer2FontColor"), 1, 6, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Font Style:")), 0, 7, 1, 1);
            grid.Attach(CreateEntry("SubViewer2FontStyle"), 1, 7, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Font Size:")), 0, 8, 1, 1);
            grid.Attach(CreateSpinButton("SubViewer2FontSize", 1, 1000, 1), 1, 8, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("Delay:")), 0, 9, 1, 1);
            grid.Attach(CreateSpinButton("Delay", 0, 1000000, 1), 1, 9, 1, 1);
            grid.Attach(CreateLabel(Catalog.GetString("CD Track:")), 0, 10, 1, 1);
            grid.Attach(CreateSpinButton("CDTrack", 1, 1000, 1), 1, 10, 1, 1);

            //Finalize
            dialog.ContentArea.Add(notebook);
            dialog.ContentArea.ShowAll();

            return(dialog);
        }
        private static Gtk.ResponseType showErrDialog(Exception e, bool canContinue)
        {
            Gtk.Table          pnlError;
            Gtk.Image          pctError;
            Gtk.Label          lblError;
            Gtk.ScrolledWindow scrError;
            Gtk.TextView       txtError;
            Gtk.Button         cmdReport;
            Gtk.Button         cmdIgnore;
            Gtk.Button         cmdExit;

            pnlError               = new Gtk.Table(2, 2, false);
            pnlError.Name          = "pnlError";
            pnlError.RowSpacing    = 6;
            pnlError.ColumnSpacing = 6;

            pctError      = new Gtk.Image();
            pctError.Name = "pctError";
            pctError.Xpad = 8;
            pctError.Ypad = 8;
            if (CurrentOS.IsMac)
            {
                pctError.Pixbuf = Gdk.Pixbuf.LoadFromResource("RestrictionTrackerGTK.Resources.config.os_x.advanced_nettest_error.png");
            }
            else
            {
                pctError.Pixbuf = Gdk.Pixbuf.LoadFromResource("RestrictionTrackerGTK.Resources.config.linux.advanced_nettest_error.png");
            }
            pnlError.Attach(pctError, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            lblError        = new Gtk.Label();
            lblError.Name   = "lblError";
            lblError.Xalign = 0F;
            lblError.Yalign = 0.5F;
            if (e.TargetSite == null)
            {
                lblError.LabelProp = "<span size=\"12000\" weight=\"bold\">" + modFunctions.ProductName + " has Encountered an Error</span>";
            }
            else
            {
                lblError.LabelProp = "<span size=\"12000\" weight=\"bold\">" + modFunctions.ProductName + " has Encountered an Error in " + e.TargetSite.Name + "</span>";
            }
            var signal = GLib.Signal.Lookup(lblError, "size-allocate", typeof(SizeAllocatedArgs));

            signal.AddDelegate(new EventHandler <SizeAllocatedArgs>(SizeAllocateLabel));
            lblError.LineWrap  = true;
            lblError.UseMarkup = true;
            pnlError.Attach(lblError, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0);

            scrError                  = new Gtk.ScrolledWindow();
            scrError.Name             = "scrError";
            scrError.VscrollbarPolicy = PolicyType.Automatic;
            scrError.HscrollbarPolicy = PolicyType.Never;
            scrError.ShadowType       = ShadowType.In;

            txtError            = new Gtk.TextView();
            txtError.CanFocus   = true;
            txtError.Name       = "txtError";
            txtError.Editable   = false;
            txtError.AcceptsTab = false;
            txtError.WrapMode   = WrapMode.Word;

            scrError.Add(txtError);
            pnlError.Attach(scrError, 1, 2, 1, 2, AttachOptions.Shrink | AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink | AttachOptions.Fill | AttachOptions.Expand, 0, 0);

            txtError.Buffer.Text = "Error: " + e.Message;
            if (!string.IsNullOrEmpty(e.StackTrace))
            {
                if (e.StackTrace.Contains("\n"))
                {
                    txtError.Buffer.Text += "\n" + e.StackTrace.Substring(0, e.StackTrace.IndexOf("\n"));
                }
                else
                {
                    txtError.Buffer.Text += "\n" + e.StackTrace;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(e.Source))
                {
                    txtError.Buffer.Text += "\n @ " + e.Source;
                    if (e.TargetSite != null)
                    {
                        txtError.Buffer.Text += "." + e.TargetSite.Name;
                    }
                }
                else
                {
                    if (e.TargetSite != null)
                    {
                        txtError.Buffer.Text += "\n @ " + e.TargetSite.Name;
                    }
                }
            }

            cmdReport              = new Gtk.Button();
            cmdReport.CanDefault   = true;
            cmdReport.CanFocus     = true;
            cmdReport.Name         = "cmdReport";
            cmdReport.UseUnderline = false;
            cmdReport.Label        = "Report Error";

            if (canContinue)
            {
                cmdIgnore              = new Gtk.Button();
                cmdIgnore.CanDefault   = true;
                cmdIgnore.CanFocus     = true;
                cmdIgnore.Name         = "cmdIgnore";
                cmdIgnore.UseUnderline = false;
                cmdIgnore.Label        = "Ignore and Continue";
            }
            else
            {
                cmdIgnore = null;
            }

            cmdExit              = new global::Gtk.Button();
            cmdExit.CanFocus     = true;
            cmdExit.Name         = "cmdExit";
            cmdExit.UseUnderline = true;
            cmdExit.Label        = global::Mono.Unix.Catalog.GetString("Exit Application");

            Gtk.Dialog dlgErr = new Gtk.Dialog("Error in " + modFunctions.ProductName, null, DialogFlags.Modal | DialogFlags.DestroyWithParent, cmdReport);

            dlgErr.TypeHint        = Gdk.WindowTypeHint.Dialog;
            dlgErr.WindowPosition  = WindowPosition.CenterAlways;
            dlgErr.SkipPagerHint   = true;
            dlgErr.SkipTaskbarHint = true;
            dlgErr.AllowShrink     = true;
            dlgErr.AllowGrow       = true;

            VBox pnlErrorDialog = dlgErr.VBox;

            pnlErrorDialog.Name        = "pnlErrorDialog";
            pnlErrorDialog.BorderWidth = 2;
            pnlErrorDialog.Add(pnlError);

            Box.BoxChild pnlError_BC = (Box.BoxChild)pnlErrorDialog[pnlError];
            pnlError_BC.Position = 0;

            Gtk.HButtonBox dlgErrorAction = dlgErr.ActionArea;
            dlgErrorAction.Name        = "dlgErrorAction";
            dlgErrorAction.Spacing     = 10;
            dlgErrorAction.BorderWidth = 5;
            dlgErrorAction.LayoutStyle = ButtonBoxStyle.End;

            dlgErr.AddActionWidget(cmdReport, ResponseType.Ok);
            if (canContinue)
            {
                dlgErr.AddActionWidget(cmdIgnore, ResponseType.No);
            }
            dlgErr.AddActionWidget(cmdExit, ResponseType.Reject);

            dlgErr.ShowAll();
            Gdk.Geometry minGeo = new Gdk.Geometry();
            minGeo.MinWidth  = dlgErr.Allocation.Width;
            minGeo.MinHeight = dlgErr.Allocation.Height;
            if (minGeo.MinWidth > 1 & minGeo.MinHeight > 1)
            {
                dlgErr.SetGeometryHints(null, minGeo, Gdk.WindowHints.MinSize);
            }

            Gtk.ResponseType dRet;
            do
            {
                dRet = (Gtk.ResponseType)dlgErr.Run();
            } while (dRet == ResponseType.None);
            dlgErr.Hide();
            dlgErr.Destroy();
            dlgErr = null;
            return(dRet);
        }
Пример #50
0
        /* Private members */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Adjust Timings Between 2 Points"), Base.Ui.Window, DialogFlags.DestroyWithParent,
                                               Util.GetStockLabel("gtk-close"), ResponseType.Cancel, Catalog.GetString("_Apply"), ResponseType.Ok);

            dialog.DefaultResponse = ResponseType.Ok;

            Grid grid = new Grid();

            grid.BorderWidth   = WidgetStyles.BorderWidthMedium;
            grid.RowSpacing    = WidgetStyles.RowSpacingLarge;
            grid.ColumnSpacing = WidgetStyles.ColumnSpacingLarge;


            //First Subtitle frame

            Grid firstSubtitleGrid = new Grid();

            firstSubtitleGrid.RowSpacing    = WidgetStyles.RowSpacingMedium;
            firstSubtitleGrid.ColumnSpacing = WidgetStyles.ColumnSpacingMedium;
            firstSubtitleGrid.MarginLeft    = WidgetStyles.FrameContentSpacingMedium;
            Label firstSubtitleNoLabel = CreateAlignedLabel(Catalog.GetString("Subtitle No.:"));

            firstSubtitleGrid.Attach(firstSubtitleNoLabel, 0, 0, 1, 1);
            firstSubtitleNoInputLabel = CreateAlignedLabel();
            firstSubtitleGrid.Attach(firstSubtitleNoInputLabel, 1, 0, 1, 1);
            Label firstSubtitleStartLabel = CreateAlignedLabel(Catalog.GetString("Start:"));

            firstSubtitleGrid.Attach(firstSubtitleStartLabel, 0, 1, 1, 1);
            firstSubtitleStartInputLabel = CreateAlignedLabel();
            firstSubtitleGrid.Attach(firstSubtitleStartInputLabel, 1, 1, 1, 1);
            Label firstSubtitleNewStartLabel = CreateAlignedLabel(Catalog.GetString("New Start:"));

            firstSubtitleNewStartLabel.SetAlignment(0, 0.5f);
            firstSubtitleGrid.Attach(firstSubtitleNewStartLabel, 0, 2, 1, 1);
            firstSubtitleNewStartSpinButton            = new SpinButton(new Adjustment(0, 0, 0, 1, 10, 0), 0, 0);
            firstSubtitleNewStartSpinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
            firstSubtitleNewStartSpinButton.Alignment  = 0.5f;
            firstSubtitleGrid.Attach(firstSubtitleNewStartSpinButton, 1, 2, 1, 1);

            Frame firstSubtitleFrame = Util.CreateFrameWithContent(Catalog.GetString("First Point"), firstSubtitleGrid);

            grid.Attach(firstSubtitleFrame, 0, 0, 1, 1);


            //Second Subtitle frame

            Grid lastSubtitleGrid = new Grid();

            lastSubtitleGrid.RowSpacing    = WidgetStyles.RowSpacingMedium;
            lastSubtitleGrid.ColumnSpacing = WidgetStyles.ColumnSpacingMedium;
            lastSubtitleGrid.MarginLeft    = WidgetStyles.FrameContentSpacingMedium;
            Label lastSubtitleNoLabel = CreateAlignedLabel(Catalog.GetString("Subtitle No.:"));

            lastSubtitleGrid.Attach(lastSubtitleNoLabel, 0, 0, 1, 1);
            lastSubtitleNoInputLabel = CreateAlignedLabel();
            lastSubtitleGrid.Attach(lastSubtitleNoInputLabel, 1, 0, 1, 1);
            Label lastSubtitleStartLabel = CreateAlignedLabel(Catalog.GetString("Start:"));

            lastSubtitleGrid.Attach(lastSubtitleStartLabel, 0, 1, 1, 1);
            lastSubtitleStartInputLabel = CreateAlignedLabel();
            lastSubtitleGrid.Attach(lastSubtitleStartInputLabel, 1, 1, 1, 1);
            Label lastSubtitleNewStartLabel = CreateAlignedLabel(Catalog.GetString("New Start:"));

            lastSubtitleGrid.Attach(lastSubtitleNewStartLabel, 0, 2, 1, 1);
            lastSubtitleNewStartSpinButton            = new SpinButton(new Adjustment(0, 0, 0, 1, 10, 0), 0, 0);
            lastSubtitleNewStartSpinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
            lastSubtitleNewStartSpinButton.Alignment  = 0.5f;
            lastSubtitleGrid.Attach(lastSubtitleNewStartSpinButton, 1, 2, 1, 1);

            Frame lastSubtitleFrame = Util.CreateFrameWithContent(Catalog.GetString("Second Point"), lastSubtitleGrid);

            grid.Attach(lastSubtitleFrame, 1, 0, 1, 1);


            //Apply To frame

            allSubtitlesRadioButton                 = new RadioButton(DialogStrings.ApplyToAllSubtitles);
            selectedSubtitlesRadioButton            = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToSelection);
            fromFirstSubtitleToSelectionRadioButton = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToFirstToSelection);
            fromSelectionToLastSubtitleRadioButton  = new RadioButton(allSubtitlesRadioButton, DialogStrings.ApplyToSelectionToLast);

            allSubtitlesRadioButton.Toggled                 += OnToggleRadioButton;
            selectedSubtitlesRadioButton.Toggled            += OnToggleRadioButton;
            fromFirstSubtitleToSelectionRadioButton.Toggled += OnToggleRadioButton;
            fromSelectionToLastSubtitleRadioButton.Toggled  += OnToggleRadioButton;

            Box applyToFrameVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);

            applyToFrameVBox.MarginLeft = WidgetStyles.FrameContentSpacingMedium;
            applyToFrameVBox.Add(allSubtitlesRadioButton);
            applyToFrameVBox.Add(selectedSubtitlesRadioButton);
            applyToFrameVBox.Add(fromFirstSubtitleToSelectionRadioButton);
            applyToFrameVBox.Add(fromSelectionToLastSubtitleRadioButton);

            Frame applyToFrame = Util.CreateFrameWithContent(Catalog.GetString("Apply To"), applyToFrameVBox);

            grid.Attach(applyToFrame, 0, 1, 2, 2);

            dialog.ContentArea.Add(grid);
            dialog.ContentArea.ShowAll();

            return(dialog);
        }
Пример #51
0
 public static void AddContent(this Gtk.Dialog dialog, Gtk.Widget widget, bool expand = true, bool fill = true, uint padding = 0)
 {
     dialog.ContentArea.PackStart(widget, expand, fill, padding);
 }
Пример #52
0
        /* Private methods */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog();
            dialog.Resizable = false;     //This way it automatically resizes according to its content in the 2 display modes: find / replace

            //Content area

            Grid grid = new Grid();

            grid.BorderWidth   = WidgetStyles.BorderWidthLarge;
            grid.ColumnSpacing = WidgetStyles.ColumnSpacingLarge;
            grid.RowSpacing    = WidgetStyles.RowSpacingLarge;

            Label findLabel = new Label(Catalog.GetString("F_ind"));

            findLabel.SetAlignment(1, 0.5f);
            grid.Attach(findLabel, 0, 0, 1, 1);

            findEntry                  = new Entry();
            findEntry.Changed         += OnFindTextChanged;
            findEntry.ActivatesDefault = true;
            grid.Attach(findEntry, 1, 0, 2, 1);

            replaceLabel = new Label(Catalog.GetString("Replace _with"));
            replaceLabel.SetAlignment(1, 0.5f);
            grid.Attach(replaceLabel, 0, 1, 1, 1);

            replaceEntry                  = new Entry();
            replaceEntry.Changed         += OnReplaceTextChanged;
            replaceEntry.ActivatesDefault = true;
            grid.Attach(replaceEntry, 1, 1, 2, 1);

            matchCaseCheckButton          = new CheckButton(Catalog.GetString("_Match case"));
            matchCaseCheckButton.Toggled += OnMatchCaseToggled;
            grid.Attach(matchCaseCheckButton, 1, 2, 1, 1);

            backwardsCheckButton          = new CheckButton(Catalog.GetString("Search _backwards"));
            backwardsCheckButton.Toggled += OnBackwardsToggled;
            grid.Attach(backwardsCheckButton, 2, 2, 1, 1);

            regexCheckButton          = new CheckButton(Catalog.GetString("Regular _expression"));
            regexCheckButton.Toggled += OnUseRegexToggled;
            grid.Attach(regexCheckButton, 1, 3, 1, 1);

            wrapCheckButton          = new CheckButton(Catalog.GetString("Wra_p around"));
            wrapCheckButton.Toggled += OnWrapToggled;
            grid.Attach(wrapCheckButton, 2, 3, 1, 1);

            dialog.ContentArea.Add(grid);
            dialog.ContentArea.ShowAll();

            //Action area

            buttonReplaceAll           = dialog.AddButton(Catalog.GetString("Replace _All"), (int)SearchDialogResponse.ReplaceAll) as Button;
            buttonReplaceAll.Sensitive = false;

            buttonReplace           = dialog.AddButton(Catalog.GetString("_Replace"), (int)SearchDialogResponse.Replace) as Button;
            buttonReplace.Sensitive = false;

            buttonFind           = dialog.AddButton(Util.GetStockLabel("gtk-find"), (int)SearchDialogResponse.Find) as Button;
            buttonFind.Sensitive = false;

            dialog.DefaultResponse = (ResponseType)SearchDialogResponse.Find;

            return(dialog);
        }
Пример #53
0
        public PreferencesDialog() : base(null, "PreferencesDialog")
        {
            dialog        = base.Dialog;
            dialog.Shown += delegate {
                if (settings.FirstRun)
                {
                    on_redetectConnectionButton_clicked(redetectConnectionButton, EventArgs.Empty);
                    base.Dialog.SkipPagerHint   = false;
                    base.Dialog.SkipTaskbarHint = false;
                }
            };

            settings = Gui.Settings;

            /* Configure gui */

            firewallImage.Pixbuf           = new Gdk.Pixbuf(null, "FileFind.Meshwork.GtkClient.firewall-small.png");
            internetConnectionImage.Pixbuf = new Gdk.Pixbuf(null, "FileFind.Meshwork.GtkClient.network1.png");
            folderImage = Gui.LoadIcon(24, "folder");

            sharedFoldersListStore  = new Gtk.ListStore(typeof(string));
            sharedFoldersList.Model = sharedFoldersListStore;
            var imageCell = new CellRendererPixbuf();
            var textCell  = new CellRendererText();
            var column    = new TreeViewColumn();

            column.PackStart(imageCell, false);
            column.PackStart(textCell, true);
            column.SetCellDataFunc(imageCell, new TreeCellDataFunc(showFolderIcon));
            column.SetCellDataFunc(textCell, new TreeCellDataFunc(showFolderText));
            sharedFoldersList.AppendColumn(column);
            sharedFoldersList.RulesHint = true;

            Gtk.Drag.DestSet(sharedFoldersList, Gtk.DestDefaults.All, new Gtk.TargetEntry [] { new Gtk.TargetEntry("text/uri-list", 0, 0) }, Gdk.DragAction.Copy);
            sharedFoldersList.DragDataReceived += OnSharedFoldersListDragDataReceived;

            advancedListStore  = new Gtk.ListStore(typeof(string), typeof(int));
            advancedList.Model = advancedListStore;
            advancedList.AppendColumn("Text", new CellRendererText(), "text", 0);

            advancedNotebook.ShowTabs = false;

            for (int x = 0; x < advancedNotebook.NPages; x++)
            {
                Widget widget = advancedNotebook.GetNthPage(x);
                advancedListStore.AppendValues(advancedNotebook.GetTabLabelText(widget), x);
            }

            TreeIter iter;

            advancedListStore.GetIterFirst(out iter);
            advancedList.Selection.SelectIter(iter);

            if (Gui.MainWindow != null)
            {
                dialog.TransientFor = Gui.MainWindow.Window;
            }
            else
            {
                // First run!
            }

            Gtk.Drag.DestSet(avatarButton, DestDefaults.All, target_table, Gdk.DragAction.Copy | Gdk.DragAction.Move);


            provider = new RSACryptoServiceProvider();
            provider.ImportParameters(settings.EncryptionParameters);
            nodeid = Common.SHA512Str(provider.ToXmlString(false));

            /**** Load options ****/

            // General Tab
            nicknameEntry.Text = settings.NickName;
            nameEntry.Text     = settings.RealName;
            nodeIdLabel.Markup = "<span font=\"monospace\">" + Common.FormatFingerprint(nodeid, 7) + "</span>";
            emailEntry.Text    = settings.Email;

            string avatarDirectory = Path.Combine(Settings.ConfigurationDirectory, "avatars");
            string myAvatarFile    = Path.Combine(avatarDirectory, String.Format("{0}.png", nodeid));

            if (File.Exists(myAvatarFile))
            {
                avatarImage.Pixbuf = new Gdk.Pixbuf(myAvatarFile);
            }
            else
            {
                avatarImage.Pixbuf    = new Gdk.Pixbuf(null, "FileFind.Meshwork.GtkClient.avatar-generic-large.png");
                avatarImage.Sensitive = false;
            }

            // Networks tab
            networksListStore = new ListStore(typeof(NetworkInfo));

            foreach (NetworkInfo networkInfo in settings.Networks)
            {
                networksListStore.AppendValues(networkInfo.Clone());
            }

            networksTreeView.AppendColumn("Network Name", new CellRendererText(), new TreeCellDataFunc(NetworkNameFunc));
            networksTreeView.Model = networksListStore;

            // File Sharing Tab

            foreach (string dir in settings.SharedDirectories)
            {
                sharedFoldersListStore.AppendValues(new object[] { dir });
            }
            downloadsChooser.SetCurrentFolder(settings.IncompleteDownloadDir);
            completedDownloadsChooser.SetCurrentFolder(settings.CompletedDownloadDir);

            // Connection Tab

            tcpPortLabel.Text = settings.TcpListenPort.ToString();

            firewallStatusLabel.Text = String.Empty;

            if (CheckForNat())
            {
                natStatusLabel.Markup = "You <b>are</b> behind a NAT router.";
                // XXX: Include UPnP Info!
            }
            else
            {
                natStatusLabel.Markup     = "You <b>are not</b> behind a NAT router.";
                natOptionsTable.Sensitive = false;
            }

            bool foundIPv6Internal = false;
            bool foundIPv6External = false;

            foreach (IDestination destination in Core.DestinationManager.Destinations)
            {
                if (destination is IPv6Destination)
                {
                    if (((IPv6Destination)destination).IsExternal)
                    {
                        foundIPv6External = true;
                    }
                    else
                    {
                        foundIPv6Internal = true;
                    }
                }
                else if (destination is IPv4Destination && destination.IsExternal)
                {
                    internetIPLabel.Text = ((IPDestination)destination).Address.ToString();
                }
            }
            if (foundIPv6External)
            {
                supportsIPv6Label.Text = "Yes";
            }
            else if (foundIPv6Internal)
            {
                supportsIPv6Label.Text = "LAN Only";
            }
            else
            {
                supportsIPv6Label.Text = "No";
            }

            // Plugins Tab

            pluginsListStore = new ListStore(typeof(PluginInfo));
            pluginsTreeView.AppendColumn("Plugin Info", new CellRendererText(), new TreeCellDataFunc(PluginInfoFunc));
            pluginsTreeView.Model = pluginsListStore;

            foreach (string fileName in settings.Plugins)
            {
                try {
                    PluginInfo info = new PluginInfo(fileName);
                    pluginsListStore.AppendValues(info);
                } catch (Exception ex) {
                    Core.LoggingService.LogError(ex);
                }
            }

            // Advanced -> Appearance

            startInTrayCheckButton.Active = settings.StartInTray;

            // Advanced -> Auto-connect Tab
            autoConnectTreeStore  = new Gtk.TreeStore(typeof(object));
            autoConnectList.Model = autoConnectTreeStore;

            CellRendererToggle autoConnectToggleCell = new CellRendererToggle();

            autoConnectToggleCell.Toggled += OnAutoConnectItemToggled;

            CellRendererText autoConnectTextCell = new CellRendererText();

            column = new TreeViewColumn();
            column.PackStart(autoConnectToggleCell, false);
            column.SetCellDataFunc(autoConnectToggleCell, new TreeCellDataFunc(ShowAutoConnectToggle));
            column.PackStart(autoConnectTextCell, true);
            column.SetCellDataFunc(autoConnectTextCell, new TreeCellDataFunc(ShowAutoConnectName));
            autoConnectList.AppendColumn(column);
            autoConnectList.AppendColumn("IP", new CellRendererText(), new Gtk.TreeCellDataFunc(ShowAutoConnectIP));
            PopulateAutoConnectList();
            autoConnectCountSpinButton.Value = settings.AutoConnectCount;

            // Advanced -> Connection
            nodePortSpinButton.Value       = settings.TcpListenPort;
            nodePortOpenCheckButton.Active = settings.TcpListenPortOpen;
            detectIPCheckButton.Active     = settings.DetectInternetIPOnStart;
            externalIPv4AddressEntry.Text  = internetIPLabel.Text;
            stunServerEntry.Text           = settings.StunServer;

            ipv6LocalInterfaceComboBox.Model = new ListStore(typeof(string), typeof(int));
            ((ListStore)ipv6LocalInterfaceComboBox.Model).AppendValues("Disabled", -1);
            var interfaces = new Dictionary <string, int>();

            foreach (InterfaceAddress addr in Core.OS.GetInterfaceAddresses())
            {
                if (addr.Address.AddressFamily == AddressFamily.InterNetworkV6 && (!IPAddress.IsLoopback(addr.Address)))
                {
                    if (!interfaces.ContainsKey(addr.Name))
                    {
                        interfaces[addr.Name] = addr.InterfaceIndex;
                    }
                }
            }
            foreach (string name in interfaces.Keys)
            {
                ((ListStore)ipv6LocalInterfaceComboBox.Model).AppendValues(name, interfaces[name]);
            }

            if (ipv6LocalInterfaceComboBox.Model.GetIterFirst(out iter))
            {
                do
                {
                    int index = (int)ipv6LocalInterfaceComboBox.Model.GetValue(iter, 1);
                    if (index == settings.IPv6LinkLocalInterfaceIndex)
                    {
                        ipv6LocalInterfaceComboBox.SetActiveIter(iter);
                        break;
                    }
                } while (ipv6LocalInterfaceComboBox.Model.IterNext(ref iter));
            }

            UpdateFirewallLabel();

            // Advanced -> File Transfer
            limitDownSpeedCheckButton.Active = settings.EnableGlobalDownloadSpeedLimit;
            limitDownSpeedSpinButton.Value   = settings.GlobalDownloadSpeedLimit;

            limitUpSpeedCheckButton.Active = settings.EnableGlobalUploadSpeedLimit;
            limitUpSpeedSpinButton.Value   = settings.GlobalUploadSpeedLimit;

            // I cant seem to make anything default with just the glade file.
            nicknameEntry.GrabFocus();
        }
Пример #54
0
        public override void LaunchDialogue()
        {
            //the Type in the collection
            IList  collection  = (IList)Value;
            string displayName = Property.DisplayName;

            //populate list with existing items
            ListStore itemStore = new ListStore(typeof(object), typeof(int), typeof(string));

            for (int i = 0; i < collection.Count; i++)
            {
                itemStore.AppendValues(collection [i], i, collection [i].ToString());
            }

            #region Building Dialogue

            TreeView     itemTree;
            PropertyGrid grid;
            TreeIter     previousIter = TreeIter.Zero;

            //dialogue and buttons
            var dialog = new Gtk.Dialog()
            {
                Title       = displayName + " Editor",
                Modal       = true,
                AllowGrow   = true,
                AllowShrink = true,
            };
            var toplevel = this.Container.GetNativeWidget <Gtk.Widget> ().Toplevel as Gtk.Window;
            if (toplevel != null)
            {
                dialog.TransientFor = toplevel;
            }

            dialog.AddActionWidget(new Button(Stock.Cancel), ResponseType.Cancel);
            dialog.AddActionWidget(new Button(Stock.Ok), ResponseType.Ok);

            //three columns for items, sorting, PropGrid
            HBox hBox = new HBox();
            dialog.VBox.PackStart(hBox, true, true, 5);

            //propGrid at end
            grid = new PropertyGrid(base.EditorManager)
            {
                CurrentObject = null,
                WidthRequest  = 200,
                ShowHelp      = false
            };
            hBox.PackEnd(grid, true, true, 5);

            //followed by a ButtonBox
            VBox buttonBox = new VBox();
            buttonBox.Spacing = 6;
            hBox.PackEnd(buttonBox, false, false, 5);

            //add/remove buttons
            Button addButton = new Button(new Image(Stock.Add, IconSize.Button));
            buttonBox.PackStart(addButton, false, false, 0);
            if (types [0].IsAbstract)
            {
                addButton.Sensitive = false;
            }
            Button removeButton = new Button(new Gtk.Image(Stock.Remove, IconSize.Button));
            buttonBox.PackStart(removeButton, false, false, 0);

            //sorting buttons
            Button upButton = new Button(new Image(Stock.GoUp, IconSize.Button));
            buttonBox.PackStart(upButton, false, false, 0);
            Button downButton = new Button(new Image(Stock.GoDown, IconSize.Button));
            buttonBox.PackStart(downButton, false, false, 0);

            //Third column has list (TreeView) in a ScrolledWindow
            ScrolledWindow listScroll = new ScrolledWindow();
            listScroll.WidthRequest  = 200;
            listScroll.HeightRequest = 320;
            hBox.PackStart(listScroll, false, false, 5);

            itemTree = new TreeView(itemStore);
            itemTree.Selection.Mode = SelectionMode.Single;
            itemTree.HeadersVisible = false;
            listScroll.AddWithViewport(itemTree);

            //renderers and attribs for TreeView
            CellRenderer rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Index", rdr, "text", 1));
            rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Object", rdr, "text", 2));

            #endregion

            #region Events

            addButton.Clicked += delegate {
                //create the object
                object instance = System.Activator.CreateInstance(types[0]);

                //get existing selection and insert after it
                TreeIter oldIter, newIter;
                if (itemTree.Selection.GetSelected(out oldIter))
                {
                    newIter = itemStore.InsertAfter(oldIter);
                }
                //or append if no previous selection
                else
                {
                    newIter = itemStore.Append();
                }
                itemStore.SetValue(newIter, 0, instance);

                //select, set name and update all the indices
                itemTree.Selection.SelectIter(newIter);
                UpdateName(itemStore, newIter);
                UpdateIndices(itemStore);
            };

            removeButton.Clicked += delegate {
                //get selected iter and the replacement selection
                TreeIter iter, newSelection;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                newSelection = iter;
                if (!IterPrev(itemStore, ref newSelection))
                {
                    newSelection = iter;
                    if (!itemStore.IterNext(ref newSelection))
                    {
                        newSelection = TreeIter.Zero;
                    }
                }

                //new selection. Zeroing previousIter prevents trying to update name of deleted iter.
                previousIter = TreeIter.Zero;
                if (itemStore.IterIsValid(newSelection))
                {
                    itemTree.Selection.SelectIter(newSelection);
                }

                //and the removal and index update
                itemStore.Remove(ref iter);
                UpdateIndices(itemStore);
            };

            upButton.Clicked += delegate {
                TreeIter iter, prev;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                //get previous iter
                prev = iter;
                if (!IterPrev(itemStore, ref prev))
                {
                    return;
                }

                //swap the two
                itemStore.Swap(iter, prev);

                //swap indices too
                object prevVal = itemStore.GetValue(prev, 1);
                object iterVal = itemStore.GetValue(iter, 1);
                itemStore.SetValue(prev, 1, iterVal);
                itemStore.SetValue(iter, 1, prevVal);
            };

            downButton.Clicked += delegate {
                TreeIter iter, next;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                //get next iter
                next = iter;
                if (!itemStore.IterNext(ref next))
                {
                    return;
                }

                //swap the two
                itemStore.Swap(iter, next);

                //swap indices too
                object nextVal = itemStore.GetValue(next, 1);
                object iterVal = itemStore.GetValue(iter, 1);
                itemStore.SetValue(next, 1, iterVal);
                itemStore.SetValue(iter, 1, nextVal);
            };

            itemTree.Selection.Changed += delegate {
                TreeIter iter;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    removeButton.Sensitive = false;
                    return;
                }
                removeButton.Sensitive = true;

                //update grid
                object obj = itemStore.GetValue(iter, 0);
                grid.CurrentObject = obj;

                //update previously selected iter's name
                UpdateName(itemStore, previousIter);

                //update current selection so we can update
                //name next selection change
                previousIter = iter;
            };

            grid.Changed += delegate {
                TreeIter iter;
                if (itemTree.Selection.GetSelected(out iter))
                {
                    UpdateName(itemStore, iter);
                }
            };

            TreeIter selectionIter;
            removeButton.Sensitive = itemTree.Selection.GetSelected(out selectionIter);

            dialog.ShowAll();
            grid.ShowToolbar = false;

            #endregion

            //if 'OK' put items back in collection
            using (dialog) {
                if (MonoDevelop.Ide.MessageService.ShowCustomDialog(dialog, toplevel) == (int)ResponseType.Ok)
                {
                    DesignerTransaction tran = CreateTransaction(Instance);
                    object old = collection;

                    try {
                        collection.Clear();
                        foreach (object[] o in itemStore)
                        {
                            collection.Add(o [0]);
                        }
                        EndTransaction(Instance, tran, old, collection, true);
                    } catch {
                        EndTransaction(Instance, tran, old, collection, false);
                        throw;
                    }
                }
            }
        }
Пример #55
0
 /// <summary>
 /// Places, runs and destroys a transient dialog.
 /// </summary>
 public static int ShowCustomDialog(Gtk.Dialog dialog)
 {
     return(ShowCustomDialog(dialog, rootWindow));
 }
Пример #56
0
        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Set Languages"), Base.Ui.Window, DialogFlags.Modal | DialogFlagsUseHeaderBar,
                                               Util.GetStockLabel("gtk-cancel"), ResponseType.Cancel, Util.GetStockLabel("gtk-apply"), ResponseType.Ok);

            dialog.DefaultResponse = ResponseType.Ok;
            dialog.DefaultWidth    = WidgetStyles.DialogWidthMedium;
            dialog.DefaultHeight   = WidgetStyles.DialogHeightMedium;

            Grid grid = new Grid();

            grid.RowSpacing        = WidgetStyles.RowSpacingMedium;
            grid.ColumnSpacing     = WidgetStyles.ColumnSpacingLarge;
            grid.BorderWidth       = WidgetStyles.BorderWidthMedium;
            grid.ColumnHomogeneous = true;

            /* Left part: Text Language */

            Label textLabel = new Label("<b>" + Catalog.GetString("Text Language") + "</b>");

            textLabel.UseMarkup = true;
            textLabel.Halign    = Align.Start;
            grid.Attach(textLabel, 0, 0, 1, 1);

            textTreeView = CreateTreeView();
            ScrolledWindow textScrolledWindow = CreateLanguagesScrolledWindow(textTreeView);

            SelectActiveLanguage(textTreeView, SubtitleTextType.Text);
            grid.Attach(textScrolledWindow, 0, 1, 1, 1);

            /* Right part: Translation Language */

            Label transLabel = new Label("<b>" + Catalog.GetString("Translation Language") + "</b>");

            transLabel.UseMarkup = true;
            transLabel.Halign    = Align.Start;
            grid.Attach(transLabel, 1, 0, 1, 1);

            transTreeView = CreateTreeView();
            ScrolledWindow transScrolledWindow = CreateLanguagesScrolledWindow(transTreeView);

            if (Base.Document.IsTranslationLoaded)
            {
                SelectActiveLanguage(transTreeView, SubtitleTextType.Translation);
            }
            else
            {
                transScrolledWindow.Sensitive = false;
            }
            grid.Attach(transScrolledWindow, 1, 1, 1, 1);


            /* Bottom: info message */

            Label bottomLabel = Util.CreateLabel("<i>" + Catalog.GetString("For additional languages please install the corresponding package.") + "</i>", 0, 0);

            bottomLabel.UseMarkup = true;
            grid.Attach(bottomLabel, 0, 2, 2, 1);

            dialog.ContentArea.Add(grid);
            dialog.ContentArea.ShowAll();

            ConnectSignals();

            return(dialog);
        }