From 83697d21f914613d361350fa1c63cd44c1d1a0f5 Mon Sep 17 00:00:00 2001 From: James Cameron Date: Thu, 1 Jun 2017 12:50:29 +1000 Subject: [PATCH] Save As - add an optional Gtk.Entry to Alert An Alert may have a Gtk.Entry, which is placed between the title and the buttons. It is for when text is to be input during the alert. --- src/sugar3/graphics/alert.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sugar3/graphics/alert.py b/src/sugar3/graphics/alert.py index 1bc7bbd6..a561ef93 100644 --- a/src/sugar3/graphics/alert.py +++ b/src/sugar3/graphics/alert.py @@ -110,7 +110,7 @@ class Alert(Gtk.EventBox): self._buttons_box = Gtk.HButtonBox() self._buttons_box.set_layout(Gtk.ButtonBoxStyle.END) self._buttons_box.set_spacing(style.DEFAULT_SPACING) - self._hbox.pack_start(self._buttons_box, True, True, 0) + self._hbox.pack_end(self._buttons_box, True, True, 0) GObject.GObject.__init__(self, **kwargs) @@ -157,6 +157,22 @@ class Alert(Gtk.EventBox): elif pspec.name == 'msg': return self._msg + def add_entry(self): + """ + Add an entry, after the title and before the buttons. + + Returns: + Gtk.Entry: the entry added to the alert + """ + entry = Gtk.Entry() + self._hbox.pack_start(entry, True, True, 0) + entry.show() + + self._hbox.set_child_packing(self._buttons_box, False, False, 0, + Gtk.PackType.END) + + return entry + def add_button(self, response_id, label, icon=None, position=-1): """ Add a button to the alert