[shotwell/wip/gtk4] Fix developer question dialog
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/gtk4] Fix developer question dialog
- Date: Wed, 13 Apr 2022 21:07:52 +0000 (UTC)
commit 1b1d0dad936ea507a19ed8da149ae34ffec702a9
Author: Jens Georg <mail jensge org>
Date: Wed Apr 13 22:23:53 2022 +0200
Fix developer question dialog
src/Dialogs.vala | 16 ++++++++++------
src/MediaPage.vala | 21 +++++++++++++++------
src/PhotoPage.vala | 21 +++++++++++++++------
3 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index 3d42f11f..b3ea352e 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -29,7 +29,7 @@ public async bool confirm_delete_saved_search(SavedSearch search) {
Resources.DELETE_SAVED_SEARCH_DIALOG_TITLE);
}
-public bool confirm_warn_developer_changed(int number) {
+public async bool confirm_warn_developer_changed(int number) {
Gtk.MessageDialog dialog = new Gtk.MessageDialog.with_markup(AppWindow.get_instance(),
Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
"<span weight=\"bold\" size=\"larger\">%s</span>",
@@ -40,13 +40,17 @@ public bool confirm_warn_developer_changed(int number) {
dialog.add_buttons(_("_Switch Developer"), Gtk.ResponseType.YES);
dialog.show();
- // TODO
-
- int response = 0; //dialog.run();
-
+ int result = 0;
+ SourceFunc continue_cb = confirm_warn_developer_changed.callback;
+ dialog.response.connect((source, res) => {
+ dialog.hide();
+ result = res;
+ continue_cb();
+ });
+ yield;
dialog.destroy();
- return response == Gtk.ResponseType.YES;
+ return result == Gtk.ResponseType.YES;
}
#if ENABLE_FACES
diff --git a/src/MediaPage.vala b/src/MediaPage.vala
index c814fcad..ada8872a 100644
--- a/src/MediaPage.vala
+++ b/src/MediaPage.vala
@@ -809,6 +809,13 @@ public abstract class MediaPage : CheckerboardPage {
action.set_state (value);
}
+ void switch_developer(Gee.ArrayList<DataView> to_set, RawDeveloper rd) {
+ SetRawDeveloperCommand command = new SetRawDeveloperCommand(to_set, rd);
+ get_command_manager().execute(command);
+
+ update_development_menu_item_sensitivity();
+ }
+
protected virtual void developer_changed(RawDeveloper rd) {
if (get_view().get_selected_count() == 0)
return;
@@ -830,12 +837,14 @@ public abstract class MediaPage : CheckerboardPage {
}
}
}
-
- if (!need_warn || Dialogs.confirm_warn_developer_changed(to_set.size)) {
- SetRawDeveloperCommand command = new SetRawDeveloperCommand(to_set, rd);
- get_command_manager().execute(command);
-
- update_development_menu_item_sensitivity();
+ if (!need_warn) {
+ switch_developer(to_set, rd);
+ } else {
+ Dialogs.confirm_warn_developer_changed.begin(to_set.size, (source, res) => {
+ if (Dialogs.confirm_warn_developer_changed.end(res)) {
+ switch_developer(to_set, rd);
+ }
+ });
}
}
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 040392c9..2001f0bb 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -2628,6 +2628,13 @@ public class LibraryPhotoPage : EditingHostPage {
action.set_state (value);
}
+ void switch_developer(RawDeveloper rd) {
+ var command = new SetRawDeveloperCommand(get_view().get_selected(), rd);
+ get_command_manager().execute(command);
+
+ update_development_menu_item_sensitivity();
+ }
+
protected virtual void developer_changed(RawDeveloper rd) {
if (get_view().get_selected_count() != 1)
return;
@@ -2638,12 +2645,14 @@ public class LibraryPhotoPage : EditingHostPage {
// Check if any photo has edits
// Display warning only when edits could be destroyed
- if (!photo.has_transformations() || Dialogs.confirm_warn_developer_changed(1)) {
- SetRawDeveloperCommand command = new SetRawDeveloperCommand(get_view().get_selected(),
- rd);
- get_command_manager().execute(command);
-
- update_development_menu_item_sensitivity();
+ if (!photo.has_transformations()) {
+ switch_developer(rd);
+ } else {
+ Dialogs.confirm_warn_developer_changed.begin(1, (source, res) => {
+ if (Dialogs.confirm_warn_developer_changed.end(res)) {
+ switch_developer(rd);
+ }
+ });
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]