Skip to content

Commit 2a573b6

Browse files
authored
One Pastebin upload dialog (#1683)
Fix #949. Block creation of multiple Pastebin dialogs at the same time. If one dialog is already open and the user press "Upload to Pastebin", the already open dialog gets focused.
1 parent 9122f8b commit 2a573b6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/pastebin/pastebin.vala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Scratch.Plugins.Pastebin : Peas.ExtensionBase, Scratch.Services.Act
7979
GLib.MenuItem? menuitem = null;
8080
GLib.Menu? share_menu = null;
8181
public Object object { owned get; set construct; }
82+
Dialogs.PasteBinDialog? pastebin_dialog = null;
8283

8384
Scratch.Services.Document? doc = null;
8485
Scratch.Services.Interface plugins;
@@ -142,8 +143,15 @@ public class Scratch.Plugins.Pastebin : Peas.ExtensionBase, Scratch.Services.Act
142143
}
143144

144145
void show_paste_bin_upload_dialog () {
145-
MainWindow window = plugins.manager.window;
146-
new Dialogs.PasteBinDialog (window, doc);
146+
if (pastebin_dialog != null) {
147+
pastebin_dialog.present ();
148+
} else {
149+
MainWindow window = plugins.manager.window;
150+
pastebin_dialog = new Dialogs.PasteBinDialog (window, doc);
151+
pastebin_dialog.destroy.connect (() => {
152+
pastebin_dialog = null;
153+
});
154+
}
147155
}
148156

149157
public void deactivate () {

0 commit comments

Comments
 (0)