From 90db0014096b7e9e83d5b4feddf97208e0b8c0a1 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Tue, 28 Oct 2008 23:42:22 +0100 Subject: [PATCH] WebCommitView: Add a state display This adds a div in the webview to display the current commit state. It allows us to notify the user of new commits by showing something in the webview, rather than a modal dialog. --- PBGitCommitController.h | 4 +++- PBGitCommitController.m | 6 +----- PBGitCommitView.xib | 12 +++++++++++- PBWebChangesController.h | 2 ++ PBWebChangesController.m | 9 ++++++++- html/views/commit/commit.css | 15 +++++++++++++++ html/views/commit/commit.js | 14 ++++++++++++++ html/views/commit/index.html | 9 +++++++-- 8 files changed, 61 insertions(+), 10 deletions(-) diff --git a/PBGitCommitController.h b/PBGitCommitController.h index 3a4b5d8..53768f6 100644 --- a/PBGitCommitController.h +++ b/PBGitCommitController.h @@ -18,7 +18,9 @@ IBOutlet NSArrayController *unstagedFilesController; IBOutlet NSArrayController *cachedFilesController; NSString *status; - + + IBOutlet id webController; + // We use busy as a count of active processes. // You can increase it when your process start // And decrease it after you have finished. diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 88f62c9..93c2b53 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -269,11 +269,7 @@ if (ret) return [self commitFailedBecause:@"Could not update HEAD"]; - [[NSAlert alertWithMessageText:@"Commit succesful" - defaultButton:nil - alternateButton:nil - otherButton:nil - informativeTextWithFormat:@"Successfully created commit %@", commit] runModal]; + [webController setStateMessage:[NSString stringWithFormat:@"Succesfully created commit %@", commit]]; repository.hasChanged = YES; self.busy--; diff --git a/PBGitCommitView.xib b/PBGitCommitView.xib index 64e3858..60c933c 100644 --- a/PBGitCommitView.xib +++ b/PBGitCommitView.xib @@ -1081,6 +1081,14 @@ 252 + + + webController + + + + 253 + @@ -1514,7 +1522,7 @@ - 252 + 253 @@ -1566,6 +1574,7 @@ unstagedButtonCell unstagedFilesController unstagedTable + webController YES @@ -1576,6 +1585,7 @@ PBIconAndTextCell NSArrayController NSTableView + id diff --git a/PBWebChangesController.h b/PBWebChangesController.h index 006621a..dd7af8d 100644 --- a/PBWebChangesController.h +++ b/PBWebChangesController.h @@ -21,4 +21,6 @@ } - (void) refresh; +- (void) setStateMessage:(NSString *)state; + @end diff --git a/PBWebChangesController.m b/PBWebChangesController.m index 461f710..e8a4994 100644 --- a/PBWebChangesController.m +++ b/PBWebChangesController.m @@ -54,7 +54,7 @@ - (void) refresh { - if (!finishedLoading) + if (!finishedLoading || !selectedFile) return; id script = [view windowScriptObject]; @@ -67,4 +67,11 @@ [controller stageHunk: hunk reverse:reverse]; [self refresh]; } + +- (void) setStateMessage:(NSString *)state +{ + id script = [view windowScriptObject]; + [script callWebScriptMethod:@"setState" withArguments: [NSArray arrayWithObject:state]]; +} + @end diff --git a/html/views/commit/commit.css b/html/views/commit/commit.css index 848776e..a366379 100644 --- a/html/views/commit/commit.css +++ b/html/views/commit/commit.css @@ -17,6 +17,21 @@ body { width: 100%; } +#state { + margin-left: 20px; + margin-right: 20px; + margin-top: 40px; + text-align: center; + font-size: 200%; + padding: 20px; + width: auto; + + background-color: #B4D7FF; + border: 2px solid #45A1FE; + + -webkit-border-radius: 10px; +} + .floatright { float: right; } diff --git a/html/views/commit/commit.js b/html/views/commit/commit.js index 6c07037..845620b 100644 --- a/html/views/commit/commit.js +++ b/html/views/commit/commit.js @@ -12,9 +12,23 @@ var showNewFile = function(file) diff.style.display = ''; } +var hideState = function() { + $("state").style.display = "none"; +} + +var setState = function(state) { + $("state").style.display = ""; + $("diff").style.display = "none"; + $("state").innerHTML = state.escapeHTML(); +} + var showFileChanges = function(file, cached) { + if (!file) + return; + $("diff").style.display = 'none'; hideNotification(); + hideState(); if (file.status == 0) // New file? return showNewFile(file); diff --git a/html/views/commit/index.html b/html/views/commit/index.html index ac627ab..b59ca1b 100644 --- a/html/views/commit/index.html +++ b/html/views/commit/index.html @@ -14,14 +14,19 @@

Nothing to commit

-