diff --git a/gramps/gui/dialog.py b/gramps/gui/dialog.py index 587c01586..7bd0d2da8 100644 --- a/gramps/gui/dialog.py +++ b/gramps/gui/dialog.py @@ -215,6 +215,50 @@ class QuestionDialog3: return (-1 if response == Gtk.ResponseType.DELETE_EVENT else response == Gtk.ResponseType.ACCEPT) +class InputDialog: + def __init__(self, msg, default_input=None, parent=None): + self.xml = Glade(toplevel='inputdialog') + + self.top = self.xml.toplevel + self.top.set_icon(ICON) + self.top.set_title("%s - Gramps" % msg) + self.top.set_default_response(Gtk.ResponseType.OK) + + label = self.xml.get_object('qd_label') + label.set_text('%s' % + html.escape(msg)) + label.set_use_markup(True) + + self.xml.get_object('ok').set_use_underline(True) + self.xml.get_object('cancel').set_use_underline(True) + + self.entry_box = self.xml.get_object('entry_box') + if default_input is not None: + self.entry_box.set_text(default_input) + self.entry_box.set_placeholder_text(default_input) + + # dirty fix for default action not working by default - not sure why + self.entry_box.connect('activate', + lambda _: self.top.response(Gtk.ResponseType.OK)) + + self.parent = parent + if parent: + self.top.set_transient_for(parent) + self.parent_modal = parent.get_modal() + if self.parent_modal: + parent.set_modal(False) + self.top.show() + + def run(self): + response = self.top.run() + input_text = self.entry_box.get_text() + self.top.destroy() + if self.parent and self.parent_modal: + self.parent.set_modal(True) + if response == Gtk.ResponseType.OK: + return input_text + return None + class OptionDialog: def __init__(self, msg1, msg2, btnmsg1, task1, btnmsg2, task2, parent=None): self.xml = Glade(toplevel='optiondialog') diff --git a/gramps/gui/glade/dialog.glade b/gramps/gui/glade/dialog.glade index bb32b056c..9a17f389a 100644 --- a/gramps/gui/glade/dialog.glade +++ b/gramps/gui/glade/dialog.glade @@ -1,28 +1,28 @@ - + - False - dialog + False + dialog True - False + False vertical True - False - end + False + end _Close True - True - True - False - True + True + True + False + True False @@ -34,74 +34,75 @@ False True - end + end 0 + True - False - 12 - 6 - 6 + False + 12 + 6 + 6 True - False + False start - 48 - dialog-warning + 48 + dialog-warning 6 - 0 - 0 + 0 + 0 True - False + False start True - True + True True - 1 - 0 + 1 + 0 Do not show this dialog again True - True - False + True + False center - True - True + True + True - 1 - 2 + 1 + 2 True - False + False start - 12 - 12 + 12 + 12 True True - 80 + 80 - 1 - 1 + 1 + 1 @@ -110,6 +111,15 @@ + + + + + + + + + False @@ -124,26 +134,26 @@ - False - dialog + False + dialog True - False + False vertical True - False - end + False + end _Close True - True - True - False - True + True + True + False + True False @@ -155,73 +165,89 @@ False False - end + end 0 + True - False - 12 + False + 12 True - False + False start - 48 - dialog-information + 48 + dialog-information 6 - 0 - 0 + 0 + 0 True - False + False start - 6 - 6 - True + 6 + 6 + True True - 1 - 0 + 1 + 0 True - True - etched-in - 300 - 300 + True + etched-in + 300 + 300 - 308 - 210 + 308 + 210 True - True + True True True - natural - natural + natural + natural False - 1 - 1 + 1 + 1 + + + + + + + + + + + + + + + False @@ -235,63 +261,42 @@ button182 - - False - 600 - dialog + + 300 + False + True + True + dialog - + True - False + False vertical - + True - False - end + False + end - - _Remove Object + + Cancel True - True - True - False - Remove object and all references to it from the database - True + True + False - False - False + True + True 0 - - _Keep Reference + + Ok True - True - True - False - Keep reference to the missing file - True - - - False - False - 1 - - - - - _Select File - True - True - True - True - True - False - Select replacement for the missing file - True + True + False + True False @@ -303,78 +308,224 @@ False True - end + end 0 + + True + False + + + True + False + 48 + dialog-question + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + end + 16 + label + 80 + + + True + True + 0 + + + + + True + True + True + 16 + + + False + True + end + 1 + + + + + True + True + 1 + + + + + True + True + 0 + + + + + + cancel + ok + + + + False + 600 + dialog + + + True + False + vertical + + + True + False + end + + + _Remove Object + True + True + True + False + Remove object and all references to it from the database + True + + + False + False + 0 + + + + + _Keep Reference + True + True + True + False + Keep reference to the missing file + True + + + False + False + 1 + + + + + _Select File + True + True + True + True + True + False + Select replacement for the missing file + True + + + False + False + 2 + + + + + False + True + end + 0 + + + + True - False - 12 + False + 12 True - False + False start - 6 - 6 - 24 - 24 + 6 + 6 + 24 + 24 True - True + True True start - 1 - 1 + 1 + 1 True - False + False start - 48 - dialog-warning + 48 + dialog-warning 6 - 0 - 0 + 0 + 0 True - False + False start - 6 - 6 + 6 + 6 True - True + True True - 1 - 0 + 1 + 0 _Use this selection for all missing media files True - True - False - If you check this button, all the missing media files will be automatically treated according to the currently selected option. No further dialogs will be presented for any missing media files. + True + False + If you check this button, all the missing media files will be automatically treated according to the currently selected option. No further dialogs will be presented for any missing media files. center - True - True + True + True - 1 - 2 + 1 + 2 @@ -383,6 +534,15 @@ + + + + + + + + + False @@ -399,28 +559,28 @@ - False - 600 - dialog + False + 600 + dialog True - False + False vertical True - False - end + False + end _Cancel True - True - True - False - Cancel the rest of the operations - True + True + True + False + Cancel the rest of the operations + True False @@ -432,11 +592,11 @@ _No True - True - True - False - Do not apply the operation to this item - True + True + True + False + Do not apply the operation to this item + True False @@ -448,13 +608,13 @@ _Yes True - True - True - True - True - False - Apply the operation to this item - True + True + True + True + True + False + Apply the operation to this item + True False @@ -466,78 +626,79 @@ False True - end + end 0 + True - False - 12 + False + 12 True - False + False start - 6 - 6 - 24 - 24 + 6 + 6 + 24 + 24 True - True + True True start - 1 - 1 + 1 + 1 True - False + False start - 48 - dialog-warning + 48 + dialog-warning 6 - 0 - 0 + 0 + 0 True - False + False start - 6 - 6 + 6 + 6 True - True + True True - 1 - 0 + 1 + 0 _Use this answer for the rest of the items True - True - False - If you check this button, your next answer will apply to the rest of the selected items + True + False + If you check this button, your next answer will apply to the rest of the selected items center - True - True + True + True - 1 - 2 + 1 + 2 @@ -546,6 +707,15 @@ + + + + + + + + + False @@ -562,25 +732,25 @@ - False - dialog + False + dialog True - False + False vertical True - False - end + False + end True - True - True - False - True + True + True + False + True False @@ -591,10 +761,10 @@ True - True - True - False - True + True + True + False + True False @@ -606,66 +776,82 @@ False True - end + end 0 + True - False - 12 + False + 12 True - False + False start - 6 - 6 - 12 - 12 + 6 + 6 + 12 + 12 True - True + True True - 1 - 1 + 1 + 1 True - False + False start - 48 - dialog-warning + 48 + dialog-warning 6 - 0 - 0 + 0 + 0 True - False + False start - 6 - 6 + 6 + 6 True - True + True True - 1 - 0 + 1 + 0 + + + + + + + + + + + + + + + False @@ -681,27 +867,27 @@ - 300 - False + 300 + False True - True - dialog + True + dialog True - False + False vertical True - False - end + False + end Cancel - True - True - False + True + True + False True @@ -713,10 +899,10 @@ _Cancel True - True - True - False - True + True + True + False + True False @@ -727,10 +913,10 @@ True - True - True - False - True + True + True + False + True False @@ -742,20 +928,20 @@ False True - end + end 0 True - False + False True - False - 48 - dialog-question + False + 48 + dialog-question 6 @@ -767,14 +953,14 @@ True - False + False vertical True - False + False label - 80 + 80 False @@ -785,15 +971,15 @@ True - False - 6 - 6 - 6 - 6 + False + 6 + 6 + 6 + 6 label - True + True True - 80 + 80 False @@ -824,26 +1010,26 @@ - False - dialog + False + dialog True - False + False vertical True - False - end + False + end Close _without saving True - True - True - False - True + True + True + False + True False @@ -855,12 +1041,12 @@ _Cancel True - True - True - True - True - False - True + True + True + True + True + False + True False @@ -872,10 +1058,10 @@ _Save True - True - True - False - True + True + True + False + True False @@ -887,73 +1073,74 @@ False True - end + end 0 + True - False - 6 + False + 6 True - False + False start - 6 - 6 + 6 + 6 label - True + True True - 1 - 1 + 1 + 1 True - False + False start - 48 - dialog-warning + 48 + dialog-warning 6 - 0 - 0 + 0 + 0 True - False + False start - 6 - 6 - True + 6 + 6 + True True - 1 - 0 + 1 + 0 Do not ask again True - True - False + True + False center - True - True + True + True - 1 - 2 + 1 + 2 @@ -962,6 +1149,15 @@ + + + + + + + + + True