Merge pull request #700 from andreasb242/master

Close handling for macOS
presentation
andreasb242 7 years ago committed by GitHub
commit 663f6fac19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/control/Control.cpp
  2. 4
      src/control/Control.h
  3. 3
      src/gui/MainWindow.cpp
  4. 10
      src/undo/UndoRedoHandler.cpp

@ -2495,12 +2495,20 @@ bool Control::saveAs()
return save();
}
void Control::quit()
void Control::quit(bool allowCancel)
{
XOJ_CHECK_TYPE(Control);
if (!this->close(true))
if (!this->close(true, allowCancel))
{
if (!allowCancel)
{
// Cancel is not allowed, and the user close or did not save
// This is probably called from macOS, where the Application
// now will be killed - therefore do an emergency save.
emergencySave();
}
return;
}
@ -2514,7 +2522,7 @@ void Control::quit()
gtk_main_quit();
}
bool Control::close(bool destroy)
bool Control::close(bool destroy, bool allowCancel)
{
XOJ_CHECK_TYPE(Control);
@ -2529,7 +2537,12 @@ bool Control::close(bool destroy)
gtk_dialog_add_button(GTK_DIALOG(dialog), _("Save"), 1);
gtk_dialog_add_button(GTK_DIALOG(dialog), _("Discard"), 2);
gtk_dialog_add_button(GTK_DIALOG(dialog), _("Cancel"), 3);
if (allowCancel)
{
gtk_dialog_add_button(GTK_DIALOG(dialog), _("Cancel"), 3);
}
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(this->getWindow()->getWindow()));
int resNotSaved = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

@ -75,8 +75,8 @@ public:
void exportBase(BaseExportJob* job);
bool save(bool synchron = false);
bool saveAs();
void quit();
bool close(bool destroy = false);
void quit(bool allowCancel = true);
bool close(bool destroy = false, bool allowCancel = true);
// Asks user to replace an existing file when saving / exporting, since we add the extension
// after the OK, we need to check manually

@ -144,7 +144,8 @@ MainWindow::MainWindow(GladeSearchpath* gladeSearchPath, Control* control)
+[](GtkosxApplication* osxApp, MainWindow* self)
{
XOJ_CHECK_TYPE_OBJ(self, MainWindow);
self->control->quit();
self->control->quit(false);
return true;
}), this);
gtkosx_application_ready(osxApp);

@ -327,7 +327,10 @@ bool UndoRedoHandler::isChanged()
{
XOJ_CHECK_TYPE(UndoRedoHandler);
if (!this->undoList) return this->savedUndo;
if (!this->undoList)
{
return this->savedUndo;
}
return this->savedUndo != g_list_last(this->undoList)->data;
}
@ -336,7 +339,10 @@ bool UndoRedoHandler::isChangedAutosave()
{
XOJ_CHECK_TYPE(UndoRedoHandler);
if (!this->undoList) return this->autosavedUndo;
if (!this->undoList)
{
return this->autosavedUndo;
}
return this->autosavedUndo != g_list_last(this->undoList)->data;
}

Loading…
Cancel
Save