Ejemplo n.º 1
0
 void ButtonClicked(object s, EventArgs a)
 {
     using (TextEditorDialog dlg = new TextEditorDialog()) {
         dlg.TransientFor = this.Toplevel as Gtk.Window;
         dlg.Text         = entry.Text;
         if (dlg.Run() == (int)ResponseType.Ok)
         {
             entry.Text = dlg.Text;
             TextChanged(null, null);
         }
     }
 }
Ejemplo n.º 2
0
		void ButtonClicked (object s, EventArgs a)
		{
			using (TextEditorDialog dlg = new TextEditorDialog ()) {
				dlg.TransientFor = this.Toplevel as Gtk.Window;
				dlg.Text = entry.Text;
				if (dlg.Run () == (int) ResponseType.Ok) {
					entry.Text = dlg.Text;
					TextChanged (null, null);
				}
			}
		}
        void OnZoomCellClick(object sender, EventArgs e)
        {
            var cell = (CellRendererButton) sender;
            var entry = SelectedEntry;
            var path = SelectedPath;
            var columnID = (string) cell.Data ["columnID"];

            string oldStr, newStr;
            // turning hoverslection off temporarily so row remains highlighted behind popup
            entriesTV.HoverSelection = false;
            if (columnID == "Name")
                oldStr = entry.Name;
            else if (columnID == "BaseValue")
                oldStr = entry.GetBaseString ();
            else if (columnID == "Value")
                oldStr = entry.Value;
            else if (columnID == "Comment")
                oldStr = entry.Comment;
            else
                throw new Exception ("Not setup for this column");

            int response;

            using (var dialog = new TextEditorDialog ()) {
                dialog.Text = oldStr;
                dialog.TransientFor = this.Toplevel as Gtk.Window;
                response = dialog.Run ();
                newStr = dialog.Text;
            }

            bool editMode; // whether to put cell in edit mode when selecting row again

            if ((response == (int) ResponseType.Ok) && (oldStr != newStr)) {
                if (columnID == "Name") {
                    if (ValidateName (oldStr, newStr, (entry == Inserter)))
                        entry.Name = newStr;
                }
                else if (columnID == "Value")
                    entry.Value = newStr;
                else if (columnID == "Comment")
                    entry.Comment = newStr;
                editMode = true;
            } else
                editMode = false;

            var col = entriesTV.Columns.Single (c=> (string) c.Data ["columnID"] == columnID);
            // CorrectRowHeights may add a task to idle, if so it needs to run first or cell wont go to edit mode
            CorrectRowHeights ((CellRendererText) col.Cells [1], oldStr, newStr);
            // select row, optionally put cell in edit mode (putting basevalue in edit mode triggers
            // its EditingStarted handler which currently defers editing to the value column)
            GLib.Idle.Add ( delegate () {
                entriesTV.SetCursorOnCell (path, col, col.Cells [1], editMode);
                entriesTV.HoverSelection = true; // turn on at end to avoid selection jumping about
                return false;
            });
        }