Skip to content

Commit f844100

Browse files
authored
Gtk4Prep: Replace dialog.run () and dialog.present () where simple (#1756)
1 parent 91e6d78 commit f844100

11 files changed

Lines changed: 49 additions & 33 deletions

plugins/spell/spell.vala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,21 @@ public class Scratch.Plugins.Spell: Peas.ExtensionBase, Scratch.Services.Activat
7272
}
7373

7474
if (language_list.length () == 0) {
75+
// This fallback to the LC used but might fail.
76+
spell.set_language (null);
77+
7578
var dialog = new Granite.MessageDialog (
7679
_("No Suitable Dictionaries Were Found"),
7780
_("Please install at least one [aspell] dictionary."),
7881
new ThemedIcon ("dialog-warning"),
7982
Gtk.ButtonsType.CLOSE
8083
);
81-
dialog.run ();
82-
dialog.destroy ();
83-
84-
// This fallback to the LC used but might fail.
85-
spell.set_language (null);
86-
84+
dialog.response.connect (() => {
85+
dialog.destroy ();
86+
});
87+
// The following code does not depend on the dialog response
88+
//so we can just show the dialog
89+
dialog.show ();
8790
} else if (!exist_language) {
8891
this.lang_dict = language_list.first ().data;
8992
spell.set_language (lang_dict);

src/Dialogs/BranchActions/BranchActionDialog.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public class Scratch.Dialogs.BranchActionDialog : Granite.MessageDialog {
4949

5050
public BranchActionDialog (FolderManager.ProjectFolderItem project) {
5151
Object (
52-
project: project
52+
project: project,
53+
modal: true
5354
);
5455
}
5556

src/Dialogs/CloneRepositoryDialog.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public class Scratch.Dialogs.CloneRepositoryDialog : Granite.MessageDialog {
4141
public CloneRepositoryDialog (string _suggested_local_folder, string _suggested_remote) {
4242
Object (
4343
suggested_local_folder: _suggested_local_folder,
44-
suggested_remote: _suggested_remote
44+
suggested_remote: _suggested_remote,
45+
modal: true
4546
);
4647
}
4748

4849
construct {
4950
transient_for = ((Gtk.Application)(GLib.Application.get_default ())).get_active_window ();
5051
image_icon = new ThemedIcon ("git");
5152
badge_icon = new ThemedIcon ("emblem-downloads");
52-
modal = true;
5353

5454
///TRANSLATORS "Git" is a proper name and must not be translated
5555
primary_text = _("Create a local clone of a Git repository");

src/Dialogs/CloseProjectsConfirmationDialog.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class Scratch.Dialogs.CloseProjectsConfirmationDialog : Granite.MessageDi
2626
buttons: Gtk.ButtonsType.NONE,
2727
transient_for: parent,
2828
n_parents: n_parents,
29-
n_children: n_children
29+
n_children: n_children,
30+
modal: true
3031
);
3132
}
3233

src/Dialogs/GlobalSearchDialog.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class Scratch.Dialogs.GlobalSearchDialog : Granite.MessageDialog {
4444
is_repo: is_repo,
4545
case_sensitive: case_sensitive,
4646
wholeword: wholeword,
47-
use_regex: use_regex
47+
use_regex: use_regex,
48+
modal: true
4849
);
4950
}
5051

src/Dialogs/OverwriteUncommittedConfirmationDialog.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public class Scratch.Dialogs.OverwriteUncommittedConfirmationDialog : Granite.Me
2727
Object (
2828
buttons: Gtk.ButtonsType.NONE,
2929
transient_for: parent,
30-
branch_name: new_branch_name
30+
branch_name: new_branch_name,
31+
modal: true
3132
);
3233

3334
show_error_details (details);
3435
}
3536

3637
construct {
37-
modal = true;
3838
image_icon = new ThemedIcon ("dialog-warning");
3939

4040
primary_text = _("There are uncommitted changes in the current branch");

src/Dialogs/RestoreConfirmationDialog.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class Scratch.Dialogs.RestoreConfirmationDialog : Granite.MessageDialog {
2121
public RestoreConfirmationDialog (MainWindow parent) {
2222
Object (
2323
buttons: Gtk.ButtonsType.NONE,
24-
transient_for: parent
24+
transient_for: parent,
25+
modal: true
2526
);
2627
}
2728

src/FolderManager/FileView.vala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,18 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane
511511
var dialog = new Gtk.AppChooserDialog (new Gtk.Window (), Gtk.DialogFlags.MODAL, file);
512512
dialog.deletable = false;
513513

514-
if (dialog.run () == Gtk.ResponseType.OK) {
515-
var app_info = dialog.get_app_info ();
516-
if (app_info != null) {
517-
Utils.launch_app_with_file (app_info.get_id (), path);
514+
dialog.response.connect ((res) => {
515+
if (res == Gtk.ResponseType.OK) {
516+
var app_info = dialog.get_app_info ();
517+
if (app_info != null) {
518+
Utils.launch_app_with_file (app_info.get_id (), path);
519+
}
518520
}
519-
}
520521

521-
dialog.destroy ();
522+
dialog.destroy ();
523+
});
524+
525+
dialog.show ();
522526
}
523527

524528
private void action_execute_contract_with_file_path (SimpleAction action, Variant? param) {

src/FolderManager/ProjectFolderItem.vala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,14 @@ namespace Scratch.FolderManager {
397397
new ThemedIcon ("git"),
398398
Gtk.ButtonsType.CLOSE
399399
) {
400-
badge_icon = new ThemedIcon ("dialog-error")
400+
badge_icon = new ThemedIcon ("dialog-error"),
401+
modal = true
401402
};
402403
dialog.transient_for = (Gtk.Window)(view.get_toplevel ());
403404
dialog.response.connect (() => {
404405
dialog.destroy ();
405406
});
406-
dialog.run ();
407+
dialog.show ();
407408
}
408409
}
409410

src/Services/Document.vala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,8 @@ namespace Scratch.Services {
10441044
Gtk.ButtonsType.NONE
10451045
) {
10461046
badge_icon = new ThemedIcon ("dialog-question"),
1047-
transient_for = app_instance.active_window
1047+
transient_for = app_instance.active_window,
1048+
modal = true
10481049
};
10491050

10501051
dialog.add_button (_("Ignore"), Gtk.ResponseType.REJECT);
@@ -1077,7 +1078,7 @@ namespace Scratch.Services {
10771078
});
10781079
});
10791080

1080-
dialog.present ();
1081+
dialog.show ();
10811082
}
10821083

10831084
private void ask_external_changes (
@@ -1094,8 +1095,8 @@ namespace Scratch.Services {
10941095
new ThemedIcon ("dialog-warning"),
10951096
Gtk.ButtonsType.NONE
10961097
) {
1097-
transient_for = app_instance.active_window
1098-
1098+
transient_for = app_instance.active_window,
1099+
modal = true
10991100
};
11001101

11011102
dialog.add_button (_("Continue"), Gtk.ResponseType.REJECT);
@@ -1153,7 +1154,7 @@ namespace Scratch.Services {
11531154
});
11541155
});
11551156

1156-
dialog.present ();
1157+
dialog.show ();
11571158
}
11581159
// Set Undo/Redo action sensitive property
11591160
public void check_undoable_actions () {

0 commit comments

Comments
 (0)