private void RefreshTo(NoSccStatus status, SvnNodeKind nodeKind) { _cookie = NextCookie(); _statusDirty = XBool.False; GitItemState set = GitItemState.None; GitItemState unset = GitItemState.Modified | GitItemState.Added | GitItemState.Deleted | GitItemState.Conflicted | GitItemState.Ignored | GitItemState.Versioned | GitItemState.IsWCRoot | GitItemState.GitDirty | GitItemState.Ignored; switch (status) { case NoSccStatus.NotExisting: SetState(set, GitItemState.Exists | GitItemState.ReadOnly | GitItemState.IsDiskFile | GitItemState.IsDiskFolder | GitItemState.Versionable | unset); _status = GitStatusData.NotExisting; break; case NoSccStatus.NotVersionable: unset |= GitItemState.Versionable; goto case NoSccStatus.NotVersioned; // fall through case NoSccStatus.NotVersioned: SetState(GitItemState.Exists | set, GitItemState.None | unset); _status = GitStatusData.NotVersioned; break; case NoSccStatus.Unknown: default: SetDirty(set | unset); _statusDirty = XBool.True; break; } //InitializeFromKind(nodeKind); }
private void RefreshTo(GitStatusData status) { _cookie = NextCookie(); _statusDirty = XBool.False; _status = status; GitItemState set = GitItemState.None; GitItemState unset = GitItemState.None; if (status.IsConflicted) set |= GitItemState.Conflicted; else unset |= GitItemState.Conflicted; if (status.IsIgnored) { set |= GitItemState.Versionable | GitItemState.Exists; unset |= GitItemState.Added | GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty | GitItemState.Versioned; } else if (MaxModified(status.IndexStatus) && MaxModified(status.WorkingStatus)) { // We don't know if the node is a file or directory yet set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists; unset |= GitItemState.Added | GitItemState.Deleted | GitItemState.Ignored; if (status.Modified) set |= GitItemState.GitDirty | GitItemState.Modified; else unset |= GitItemState.GitDirty | GitItemState.Modified; } else if (status.IndexStatus == GitStatus.New || status.WorkingStatus == GitStatus.New) { set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists | GitItemState.Added; unset |= GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty; } else if (status.IndexStatus == GitStatus.Deleted || status.WorkingStatus == GitStatus.Deleted) { set |= GitItemState.Versioned | GitItemState.Versionable | GitItemState.Exists | GitItemState.Deleted; unset |= GitItemState.Deleted | GitItemState.Modified | GitItemState.Ignored | GitItemState.GitDirty; } else { throw new NotImplementedException(); } switch(status.NodeKind) { case SvnNodeKind.File: set |= GitItemState.IsDiskFile; unset |= GitItemState.IsDiskFolder; break; case SvnNodeKind.Directory: set |= GitItemState.IsDiskFolder; unset |= GitItemState.IsDiskFile; break; } SetState(set, unset); }
// Callback from "libICE" to process a message. private void ProcessMessage (IntPtr iceConn, IntPtr clientData, Xlib.Xint opcode, Xlib.Xulong length, XBool swap, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet) { bool haveReply; if (messageTransaction) { throw new XInvalidOperationException("Attempt to process message in the middle of sending another one"); // I always wondered, what will happen if we throw exception from callback? :) } this.messageTransaction = true; this.messageLength = (int)length; // Process the message. try { replyWait = replyWait; haveReply = true; replyReadyRet = ProcessMessage((int)opcode, replyWait.reply) ? XBool.True:XBool.False; // We omit `swap' here, can one need it? Even theoretrically?.. } catch (NullReferenceException) { haveReply = false; replyReadyRet = ProcessMessage((int)opcode) ? XBool.True:XBool.False; } this.messageTransaction = false; }
public void MarkDirty() { Debug.Assert(_statusDirty != XBool.None, "MarkDirty called while updating status"); _statusDirty = XBool.True; _validState = SvnItemState.None; _cookie = NextCookie(); _workingCopy = null; _modified = new DateTime(); _conflicts = null; }
void RefreshStatus() { _statusDirty = XBool.None; ISvnStatusCache statusCache = StatusCache; try { statusCache.RefreshItem(this, IsFile ? SvnNodeKind.File : SvnNodeKind.Directory); // We can check this less expensive than the statuscache! } finally { Debug.Assert(_statusDirty == XBool.False, "No longer dirty after refresh", string.Format("Path = {0}", FullPath)); _statusDirty = XBool.False; } }
// Clear a region to the background and optionally queue expose events. private bool ClearRegion(Region region, XBool exposures) { // Intersect the region with the widget boundaries. region.Intersect(0, 0, width, height); // Remove areas that are occupied by mapped child widgets. Widget child = TopChild; while (child != null) { if (child.mapped) { region.Subtract(child.x, child.y, child.width, child.height); } child = child.NextBelow; } // Bail out if the region is now empty. if (region.IsEmpty()) { return(false); } // Lock down the display and send the "XClearArea" requests. try { IntPtr display = dpy.Lock(); XWindow handle = GetWidgetHandle(); IntPtr xregion = region.GetRegion(); XRectangle xrect; int size, index; size = Xlib.XSharpGetRegionSize(xregion); for (index = 0; index < size; ++index) { Xlib.XSharpGetRegionRect(xregion, index, out xrect); Xlib.XClearArea(display, handle, xrect.x, xrect.y, xrect.width, xrect.height, exposures); } } finally { dpy.Unlock(); } return(true); }
void IGitItemUpdate.RefreshTo(GitItem lead) { if (lead == null) throw new ArgumentNullException("lead"); else if (lead._status == null) throw new InvalidOperationException("Lead status = null"); _status = lead._status; _statusDirty = lead._statusDirty; GitItemState current = lead._currentState; GitItemState valid = lead._validState; SetState(current & valid, (~current) & valid); _ticked = false; _modified = lead._modified; _cookie = NextCookie(); // Status 100% the same, but changed... Cookies are free ;) }
// Process incoming messages on the ICE iceConn. protected void ProcessResponces(Object replyStruct) { XBool readyRet = XBool.False; IceProcessMessagesStatus status; waitInfo.sequence_of_request = (uint)ICE.IceLastSentSequenceNumber(iceConn); waitInfo.major_opcode_of_request = 2; // FIXME: This is a terrible hack, see this::.ctor waitInfo.reply = replyStruct; do { status = (IceProcessMessagesStatus)ICE.IceProcessMessages(iceConn, ref waitInfo, ref readyRet); if (status != IceProcessMessagesStatus.IceProcessMessagesSuccess) { Close(); throw new XInvalidOperationException("I/O Error or server gone away?"); } }while(readyRet == XBool.False); }
public void XBooleanUsable() { // arrange XBool custTrueBool = new XBool(true); XBool custFalseBool = new XBool(false); // act bool trueResult = custTrueBool; bool falseResult = custFalseBool; // assert trueResult.Should().BeTrue(); falseResult.Should().BeFalse(); custTrueBool.Equals(true).Should().BeTrue(); custTrueBool.Equals(false).Should().BeFalse(); custTrueBool.Equals(null).Should().BeFalse(); }
void RefreshTo(NoSccStatus status, SvnNodeKind nodeKind) { _cookie = NextCookie(); _statusDirty = XBool.False; SvnItemState set = SvnItemState.None; SvnItemState unset = SvnItemState.Modified | SvnItemState.Added | SvnItemState.HasCopyOrigin | SvnItemState.Deleted | SvnItemState.ContentConflicted | SvnItemState.Ignored | SvnItemState.Obstructed | SvnItemState.Replaced | SvnItemState.Versioned | SvnItemState.SvnDirty | SvnItemState.PropertyModified | SvnItemState.PropertiesConflicted | SvnItemState.Conflicted | SvnItemState.Obstructed | SvnItemState.MustLock | SvnItemState.IsWCRoot | SvnItemState.HasProperties | SvnItemState.HasLockToken | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere; switch (status) { case NoSccStatus.NotExisting: SetState(set, SvnItemState.Exists | SvnItemState.ReadOnly | SvnItemState.IsDiskFile | SvnItemState.IsDiskFolder | SvnItemState.Versionable | unset); _status = SvnStatusData.NotExisting; break; case NoSccStatus.NotVersionable: unset |= SvnItemState.Versionable; goto case NoSccStatus.NotVersioned; // fall through case NoSccStatus.NotVersioned: SetState(SvnItemState.Exists | set, SvnItemState.None | unset); _status = SvnStatusData.NotVersioned; break; case NoSccStatus.Unknown: default: SetDirty(set | unset); _statusDirty = XBool.True; break; } InitializeFromKind(nodeKind); }
extern public static int XClearArea (IntPtr display, XWindow w, int x, int y, uint width, uint height, XBool exposures);
extern public static Xlib.Xint IceProcessMessages (IceConn *iceConn, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet);
extern public static IntPtr XSynchronize(IntPtr display, XBool onoff);
extern public static int XSync(IntPtr display, XBool discard);
extern public static XStatus XGetWindowProperty (IntPtr display, XWindow w, XAtom property, int long_offset, int long_length, XBool deleteProp, XAtom req_type, out XAtom actual_type_return, out Xlib.Xint actual_format_return, out Xlib.Xulong nitems_return, out Xlib.Xulong bytes_after_return, out IntPtr prop_return);
extern public static Xlib.Xint IceProtocolSetup (IceConn *iceConn, Xlib.Xint myOpcode, IntPtr clientData, XBool mustAuthenticate, out Xlib.Xint majorVersionRet, out Xlib.Xint minorVersionRet, out IntPtr vendorRet, out IntPtr releaseRet, Xlib.Xint errorLength, byte[] errorStringRet);
extern public static IceConn *IceOpenConnection (String networkIdsList, IntPtr context, XBool mustAuthenticate, Xlib.Xint majorOpcodeCheck, Xlib.Xint errorLength, byte[] errorStringRet);
extern public static void IceSetShutdownNegotiation (IceConn *iceConn, XBool negotiate);
extern public static Xlib.Xint _IcePaMagicCookie1Proc (IntPtr iceConn, IntPtr authStatePtr, XBool swap, Xlib.Xint authDataLen, IntPtr authData, ref Xlib.Xint replyDataLenRet, ref IntPtr replyDataRet, ref IntPtr errorStringRet);
// Callback from "libICE" to process a message. private void ProcessMessage (IntPtr iceConn, IntPtr clientData, Xlib.Xint opcode, Xlib.Xulong length, XBool swap, ref IceReplyWaitInfo replyWait, ref XBool replyReadyRet) { bool haveReply; if(messageTransaction) { throw new XInvalidOperationException("Attempt to process message in the middle of sending another one"); // I always wondered, what will happen if we throw exception from callback? :) } this.messageTransaction = true; this.messageLength = (int)length; // Process the message. try { replyWait = replyWait; haveReply = true; replyReadyRet = ProcessMessage((int)opcode, replyWait.reply) ? XBool.True:XBool.False; // We omit `swap' here, can one need it? Even theoretrically?.. } catch (NullReferenceException) { haveReply = false; replyReadyRet = ProcessMessage((int)opcode) ? XBool.True:XBool.False; } this.messageTransaction = false; }
void RefreshTo(SvnStatusData status) { if (status == null) { throw new ArgumentNullException("status"); } if (status.LocalNodeStatus == SvnStatus.External) { // When iterating the status of an external in it's parent directory // We get an external status and no really usefull information SetState(SvnItemState.Exists | SvnItemState.Versionable | SvnItemState.IsDiskFolder, SvnItemState.IsDiskFile | SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile); if (_statusDirty != XBool.False) { _statusDirty = XBool.True; // Walk the path itself to get the data you want } return; } else if (MightBeNestedWorkingCopy(status) && IsDirectory) { // A not versioned directory might be a working copy by itself! if (_statusDirty == XBool.False) { return; // No need to remove valid cache entries } if (SvnTools.IsManagedPath(FullPath)) { _statusDirty = XBool.True; // Walk the path itself to get the data // Extract useful information we got anyway SetState(SvnItemState.Exists | SvnItemState.Versionable | SvnItemState.Versioned | SvnItemState.IsWCRoot | SvnItemState.IsDiskFolder, SvnItemState.IsDiskFile | SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile); return; } else { SetState(SvnItemState.None, SvnItemState.IsWCRoot); } // Fall through } _cookie = NextCookie(); _statusDirty = XBool.False; _status = status; const SvnItemState unset = SvnItemState.Modified | SvnItemState.Added | SvnItemState.HasCopyOrigin | SvnItemState.Deleted | SvnItemState.ContentConflicted | SvnItemState.Ignored | SvnItemState.Obstructed | SvnItemState.Replaced | SvnItemState.MovedHere; const SvnItemState managed = SvnItemState.Versioned; // Let's assume status is more recent than our internal property cache // Set all caching properties we can bool svnDirty = true; bool exists = true; bool provideDiskInfo = true; switch (status.LocalNodeStatus) { case SvnStatus.None: SetState(SvnItemState.None, managed | unset); svnDirty = false; exists = false; provideDiskInfo = false; break; case SvnStatus.NotVersioned: // Node exists but is not managed by us in this directory // (Might be from an other location as in the nested case) SetState(SvnItemState.None, unset | managed); svnDirty = false; break; case SvnStatus.Ignored: // Node exists but is not managed by us in this directory // (Might be from an other location as in the nested case) SetState(SvnItemState.Ignored, unset | managed); svnDirty = false; break; case SvnStatus.Added: if (status.IsMoved && status.IsCopied) { SetState(managed | SvnItemState.Added | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere, unset); } else if (status.IsCopied) { SetState(managed | SvnItemState.Added | SvnItemState.HasCopyOrigin, unset); } else { SetState(managed | SvnItemState.Added, unset); } if (status.LocalTextStatus == SvnStatus.Modified) { SetState(SvnItemState.Modified, SvnItemState.None); } else if (status.LocalTextStatus == SvnStatus.Normal) { SetState(SvnItemState.None, SvnItemState.Modified); } break; case SvnStatus.Replaced: if (status.IsMoved && status.IsCopied) { SetState(managed | SvnItemState.Replaced | SvnItemState.HasCopyOrigin | SvnItemState.MovedHere, unset); } else if (status.IsCopied) { SetState(managed | SvnItemState.Replaced | SvnItemState.HasCopyOrigin, unset); } else { SetState(managed | SvnItemState.Replaced, unset); } if (status.LocalTextStatus == SvnStatus.Modified) { SetState(SvnItemState.Modified, SvnItemState.None); } else if (status.LocalTextStatus == SvnStatus.Normal) { SetState(SvnItemState.None, SvnItemState.Modified); } break; case SvnStatus.Modified: case SvnStatus.Conflicted: { bool done = false; switch (status.LocalTextStatus) { case SvnStatus.Modified: SetState(managed | SvnItemState.Modified, unset); done = true; break; case SvnStatus.Conflicted: SetState(managed | SvnItemState.ContentConflicted | SvnItemState.Conflicted, unset); done = true; break; } if (!done) { goto case SvnStatus.Normal; } break; } case SvnStatus.Obstructed: // node exists but is of the wrong type SetState(SvnItemState.None, managed | unset); provideDiskInfo = false; // Info is wrong break; case SvnStatus.Missing: exists = false; provideDiskInfo = false; // Info is wrong SetState(managed, unset); break; case SvnStatus.Deleted: SetState(managed | SvnItemState.Deleted, unset); if (status.LocalFileExists) { exists = provideDiskInfo = true; } else { exists = false; provideDiskInfo = false; // Folder might still exist } break; case SvnStatus.External: // Should be handled above throw new InvalidOperationException(); case SvnStatus.Incomplete: SetState(managed, unset); break; default: Trace.WriteLine(string.Format("Ignoring undefined status {0} in SvnItem.Refresh()", status.LocalNodeStatus)); provideDiskInfo = false; // Can't trust an unknown status goto case SvnStatus.Normal; case SvnStatus.Normal: SetState(managed | SvnItemState.Exists, unset); svnDirty = false; break; } if (exists) { SetState(SvnItemState.Versionable, SvnItemState.None); } else { SetState(SvnItemState.None, SvnItemState.Versionable); } if (status.Conflicted) { SetState(SvnItemState.Conflicted, SvnItemState.None); } else { SetState(SvnItemState.None, SvnItemState.Conflicted); } bool hasProperties = true; switch (status.LocalPropertyStatus) { case SvnStatus.None: hasProperties = false; SetState(SvnItemState.None, SvnItemState.PropertiesConflicted | SvnItemState.PropertyModified | SvnItemState.HasProperties); break; case SvnStatus.Modified: SetState(SvnItemState.PropertyModified | SvnItemState.HasProperties, SvnItemState.PropertiesConflicted); svnDirty = true; break; case SvnStatus.Conflicted: SetState(SvnItemState.PropertyModified | SvnItemState.PropertiesConflicted | SvnItemState.HasProperties, SvnItemState.None); svnDirty = true; break; case SvnStatus.Normal: default: SetState(SvnItemState.HasProperties, SvnItemState.PropertiesConflicted | SvnItemState.PropertyModified); break; } if (svnDirty) { SetState(SvnItemState.SvnDirty, SvnItemState.None); } else { SetState(SvnItemState.None, SvnItemState.SvnDirty); } if (!hasProperties) { SetState(SvnItemState.None, SvnItemState.MustLock); } if (provideDiskInfo) { if (exists) // Behaviour must match updating from UpdateAttributeInfo() { switch (status.NodeKind) { case SvnNodeKind.Directory: SetState(SvnItemState.IsDiskFolder | SvnItemState.Exists, SvnItemState.ReadOnly | SvnItemState.MustLock | SvnItemState.IsTextFile | SvnItemState.IsDiskFile); break; case SvnNodeKind.File: SetState(SvnItemState.IsDiskFile | SvnItemState.Exists, SvnItemState.IsDiskFolder); break; default: // Handle direct replacement without an additional stat if (status.LocalFileExists) { goto case SvnNodeKind.File; } break; } } else { SetState(SvnItemState.None, SvnItemState.Exists); } } if (status.IsLockedLocal) { SetState(SvnItemState.HasLockToken, SvnItemState.None); } else { SetState(SvnItemState.None, SvnItemState.HasLockToken); } }
extern public static int XGrabKeyboard (IntPtr display, XWindow grab_window, XBool owner_events, int pointer_mode, int keyboard_mode, XTime time);
extern public static int XGrabPointer (IntPtr display, XWindow grab_window, XBool owner_events, uint event_mask, int pointer_mode, int keyboard_mode, XWindow confine_to, XCursor cursor, XTime time);
extern public static int XGrabButton (IntPtr display, uint button, uint modifiers, XWindow grab_window, XBool owner_events, uint event_mask, int pointer_mode, int keyboard_mode, XWindow confine_to, XCursor cursor);
extern public static XStatus XSendEvent (IntPtr display, XWindow w, XBool propagate, int event_mask, ref XEvent event_send);
extern public static XAtom XInternAtom (IntPtr display, String name, XBool only_if_exists);
// Clear a region to the background and optionally queue expose events. private bool ClearRegion(Region region, XBool exposures) { // Intersect the region with the widget boundaries. region.Intersect(0, 0, width, height); // Remove areas that are occupied by mapped child widgets. Widget child = TopChild; while(child != null) { if(child.mapped) { region.Subtract(child.x, child.y, child.width, child.height); } child = child.NextBelow; } // Bail out if the region is now empty. if(region.IsEmpty()) { return false; } // Lock down the display and send the "XClearArea" requests. try { IntPtr display = dpy.Lock(); XWindow handle = GetWidgetHandle(); IntPtr xregion = region.GetRegion(); XRectangle xrect; int size, index; size = Xlib.XSharpGetRegionSize(xregion); for(index = 0; index < size; ++index) { Xlib.XSharpGetRegionRect(xregion, index, out xrect); Xlib.XClearArea(display, handle, xrect.x, xrect.y, xrect.width, xrect.height, exposures); } } finally { dpy.Unlock(); } return true; }