Skip to content

Commit

Permalink
2006-10-21 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b22)
Browse files Browse the repository at this point in the history
	* Added warning dialog when quitting if some pictures haven't
	  been uploaded.
	* Added guidelines during crop (can be disabled by setting
	  previewDrawThirds=false in the user's properties).
  • Loading branch information
Pierre-Luc Paour committed Oct 21, 2006
1 parent eca938e commit 0f62a00
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 56 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2006-10-21 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b22)

* Added warning dialog when quitting if some pictures haven't
been uploaded.
* Added guidelines during crop (can be disabled by setting
previewDrawThirds=false in the user's properties).

2006-10-20 Pierre-Luc Paour <gallery@paour.com> (1.5.1-b21)

* The preview window is now tied to the main window: when
Expand Down
2 changes: 1 addition & 1 deletion com/gallery/GalleryRemote/DroppableTree.java
Expand Up @@ -144,7 +144,7 @@ public void dragOver(int y) {
Rectangle r = getVisibleRect();
boolean scrolled = false;

Log.log(Log.LEVEL_TRACE, MODULE, "row: " + row + " lastRow: " + lastRow + " rowHeight: " + rowHeight);
//Log.log(Log.LEVEL_TRACE, MODULE, "row: " + row + " lastRow: " + lastRow + " rowHeight: " + rowHeight);
if (y < r.getY() + getRowHeight() && row > 0) {
int tmpLastRow = lastRow;
//scrollRowToVisible(row - 1);
Expand Down
3 changes: 3 additions & 0 deletions com/gallery/GalleryRemote/GalleryComm2.java
Expand Up @@ -470,6 +470,7 @@ public void actionPerformed(ActionEvent e) {
}

((UploadProgress) su).setVisible(false);
((UploadProgress) su).dispose();
}
});
}
Expand Down Expand Up @@ -502,6 +503,8 @@ public void actionPerformed(ActionEvent e) {
}
}

g.setDirty(false);

GalleryRemote._().getCore().flushMemory();
} else {
su.stopProgress(StatusUpdate.LEVEL_UPLOAD_PROGRESS, GRI18n.getString(MODULE, "upFailed"));
Expand Down
99 changes: 55 additions & 44 deletions com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -78,7 +78,7 @@ public class MainFrame extends JFrame
* will lose their changes. If we are clean then there is no possibility
* of losing changes.
*/
private boolean m_isDirty = false;
//private boolean m_isDirty = false;

public DefaultComboBoxModel galleries = null;
//private Gallery currentGallery = null;
Expand Down Expand Up @@ -298,7 +298,7 @@ private void setGalleries(DefaultComboBoxModel galleries) {
selectedGalleryChanged();

// We've been initalized, we are now clean.
setDirtyFlag(false);
//setDirtyFlag(false);
}


Expand All @@ -323,15 +323,15 @@ private void shutdown(boolean halt, boolean shutdownOs) {
// check that we don't have galleries with data
if (!shutdownOs) {
// todo: save
/*if (m_isDirty) {
if (isDirty()) {
if (JOptionPane.showConfirmDialog(
(JFrame) this,
GRI18n.getString(MODULE, "quitQuestion"),
"Warning",
JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
return;
}
}*/
}
}

if (running) {
Expand Down Expand Up @@ -390,15 +390,26 @@ public void setInProgress(boolean inProgress) {
resetUIState();
}

/**
/*
* <p>This method updates the dirty flag and also causes the UI
* to be updated to reflect the new state.
*
* @param newDirtyState the new state (true means the document is dirty).
*/
private void setDirtyFlag(boolean newDirtyState) {
/*private void setDirtyFlag(boolean newDirtyState) {
m_isDirty = newDirtyState;
resetUIState();
}*/

public boolean isDirty() {
for (int i = galleries.getSize() - 1; i >= 0; i--) {
Gallery g = (Gallery) galleries.getElementAt(i);
if (g.isDirty()) {
return true;
}
}

return false;
}

void resetUIState() {
Expand Down Expand Up @@ -619,7 +630,7 @@ public void addPictures(Album album, File[] files, int index, boolean select) {
}

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}

public void addPictures(Picture[] pictures, boolean select) {
Expand Down Expand Up @@ -650,7 +661,7 @@ public void addPictures(Album album, Picture[] pictures, int index, boolean sele
}

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}

private void selectAddedPictures(Object[] objects, int index) {
Expand Down Expand Up @@ -708,7 +719,7 @@ public void sortPictures() {
}

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}

public void setSortType(int sortType) {
Expand Down Expand Up @@ -789,7 +800,7 @@ public void newAlbum() {
//}.transitionStart();

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}

public void slideshow() {
Expand Down Expand Up @@ -884,7 +895,7 @@ public void doCut() {
deleteSelectedPictures();

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}

public void doCopy() {
Expand All @@ -899,7 +910,7 @@ public void doPaste() {
}

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}


Expand Down Expand Up @@ -1318,22 +1329,23 @@ public void actionPerformed(ActionEvent e) {
showAboutBox();
} else if (command.equals("Fetch")) {
if (getCurrentGallery().hasComm() && getCurrentGallery().getComm(jStatusBar).isLoggedIn()) {

// todo: save
// We're currently logged in, but we might be dirty
// so ask the user if it's OK to log out.
/*int response = saveOnPermission("logoutQuestion", getCurrentGallery());
if (JOptionPane.CANCEL_OPTION == response) {
return;
}*/
if (JOptionPane.showConfirmDialog(
(JFrame) this,
GRI18n.getString(MODULE, "logoutQuestion"),
"Warning",
JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
return;
}

getCurrentGallery().logOut();

lastOpenedFile = null;

// We've been logged out, we are now clean.
setDirtyFlag(false);
//setDirtyFlag(false);
} else {
// login may have failed and caused getComm to be null.
GalleryComm comm = getCurrentGallery().getComm(jStatusBar);
Expand Down Expand Up @@ -1425,11 +1437,11 @@ public String getDescription() {
updateAlbumCombo();
resetUIState();
}*/
}
// todo: save
/*private void saveAsState() {
private void saveAsState() {
JFileChooser fc = new JFileChooser();
fc.setAcceptAllFileFilterUsed(false);
fc.setFileFilter(galleryFileFilter);
Expand Down Expand Up @@ -1463,19 +1475,19 @@ private void saveState() {
}
saveState(lastOpenedFile);
}*/
}
/**
* This is an internal worker function to save the state to a file.
* Note that we specifically do *not* set m_isDirty = false in this
* method because we use this to temporarily backup the current state
* to the default file (and we want the user to remember that they should
* save the state to a "real" save file if they want to keep it).
*
* @param f the file to store the current dialog data.
*/
// todo: save
/*private void saveState(File f) {
private void saveState(File f) {
try {
Log.log(Log.LEVEL_INFO, MODULE,
"Saving state to file " + f.getPath());
Expand All @@ -1501,13 +1513,13 @@ private void saveState() {
} catch (NoClassDefFoundError e) {
Log.log(Log.LEVEL_ERROR, MODULE, "JSX not installed, can't save state...");
}
}*/
}
/**
* Reads the properties and constructs the current MRU menu list.
*/
// todo: save
/*private void updateMRUItemList() {
private void updateMRUItemList() {
// First, delete all of the existing MRU values
for (int i = 0; i < m_MRUFileList.size(); i++) {
Expand Down Expand Up @@ -1561,14 +1573,14 @@ private void saveState() {
jMenuFile.insert(nextMRUItem, nextInsertPoint++);
nextMRUItem.addActionListener(this);
}
}*/
}
/**
* Save the passed mruFile and then write the properties file so that
* we don't lose the changes. Then force the MRU menu to change.
*
* @param mruFile the file to add to the MRU list
*/
// todo: save
/*private void saveMRUItem(File mruFile) {
// Wait to here to see if we succeed in loading the file.
Expand All @@ -1579,9 +1591,8 @@ private void saveState() {
// Update the MRU list
updateMRUItemList();
}*/
}
/**
* OpenState opens a file and loads it into GR. If a file path is
* passed in, then that file is opened. If null is passed in then a
* File Open dialog is displayed to allow the user to choose a file to
Expand All @@ -1593,9 +1604,9 @@ private void saveState() {
*
* @param fileToOpen The file to open (FQPN) or null if a File Open dialog
* should be used.
*/
// todo: save
/*private void openState(String fileToOpen) {
private void openState(String fileToOpen) {
JFileChooser fc = null;
if (null == fileToOpen) {
fc = new JFileChooser();
Expand Down Expand Up @@ -1831,7 +1842,7 @@ public void jListKeyPressed(KeyEvent e) {
}

// We've been modified, we are now dirty.
setDirtyFlag(true);
//setDirtyFlag(true);
}
}

Expand Down Expand Up @@ -1889,26 +1900,26 @@ private void macOSXRegistration() {
* and mark the document as being dirty.
*/
public void deleteSelectedPictures() {
CoreUtils.deleteSelectedPictures();
setDirtyFlag(true);
CoreUtils.deleteSelectedPictures();
//setDirtyFlag(true);
}

/*
* Move the selected picture (using the core utilities)
* and mark the document as being dirty.
*/
public void movePicturesUp() {
CoreUtils.movePicturesUp();
setDirtyFlag(true);
CoreUtils.movePicturesUp();
//setDirtyFlag(true);
}

/*
* Move the selected picture (using the core utilities)
* and mark the document as being dirty.
*/
public void movePicturesDown() {
CoreUtils.movePicturesDown();
setDirtyFlag(true);
CoreUtils.movePicturesDown();
//setDirtyFlag(true);
}

public void flushMemory() {
Expand Down
34 changes: 34 additions & 0 deletions com/gallery/GalleryRemote/PreviewFrame.java
Expand Up @@ -195,6 +195,18 @@ public void paint(Graphics g) {
g.setColor(Color.black);
g.drawRect(cacheRect.x, cacheRect.y, cacheRect.width, cacheRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.setColor(background);
g.drawLine(cacheRect.x + cacheRect.width / 3, cacheRect.y,
cacheRect.x + cacheRect.width / 3, cacheRect.y + cacheRect.height);
g.drawLine(cacheRect.x + cacheRect.width *2 / 3, cacheRect.y,
cacheRect.x + cacheRect.width * 2 / 3, cacheRect.y + cacheRect.height);
g.drawLine(cacheRect.x, cacheRect.y + cacheRect.height / 3,
cacheRect.x + cacheRect.width, cacheRect.y + cacheRect.height / 3);
g.drawLine(cacheRect.x, cacheRect.y + cacheRect.height * 2 / 3,
cacheRect.x + cacheRect.width, cacheRect.y + cacheRect.height * 2 / 3);
}

g.setClip(null);
} catch (NoninvertibleTransformException e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
Expand Down Expand Up @@ -240,12 +252,34 @@ public void updateRect() {
if (oldRect != null) {
g.setXORMode(Color.cyan);
g.drawRect(oldRect.x, oldRect.y, oldRect.width, oldRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.drawLine(oldRect.x + oldRect.width / 3, oldRect.y,
oldRect.x + oldRect.width / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x + oldRect.width *2 / 3, oldRect.y,
oldRect.x + oldRect.width * 2 / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x, oldRect.y + oldRect.height / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height / 3);
g.drawLine(oldRect.x, oldRect.y + oldRect.height * 2 / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height * 2 / 3);
}
}

if (inDrag) {
g.setXORMode(Color.cyan);
oldRect = getRect(start, end);
g.drawRect(oldRect.x, oldRect.y, oldRect.width, oldRect.height);

if (GalleryRemote._().properties.getBooleanProperty(PREVIEW_DRAW_THIRDS, false)) {
g.drawLine(oldRect.x + oldRect.width / 3, oldRect.y,
oldRect.x + oldRect.width / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x + oldRect.width *2 / 3, oldRect.y,
oldRect.x + oldRect.width * 2 / 3, oldRect.y + oldRect.height);
g.drawLine(oldRect.x, oldRect.y + oldRect.height / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height / 3);
g.drawLine(oldRect.x, oldRect.y + oldRect.height * 2 / 3,
oldRect.x + oldRect.width, oldRect.y + oldRect.height * 2 / 3);
}
}
}

Expand Down

0 comments on commit 0f62a00

Please sign in to comment.