[Xfce4-commits] [apps/xfce4-panel-profiles] 01/01: Add error for invalid config (bug #15983)
noreply at xfce.org
noreply at xfce.org
Tue Nov 26 11:55:10 CET 2019
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-panel-profiles.
commit 7568fd10452ca27963cf72e1d1b9c74065e72e4f
Author: Emanuele Petriglia <inbox at emanuelepetriglia.com>
Date: Sun Sep 22 12:49:48 2019 +0200
Add error for invalid config (bug #15983)
Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
xfce4-panel-profiles/xfce4-panel-profiles.py | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/xfce4-panel-profiles/xfce4-panel-profiles.py b/xfce4-panel-profiles/xfce4-panel-profiles.py
index c3a7ca8..0fa5d61 100644
--- a/xfce4-panel-profiles/xfce4-panel-profiles.py
+++ b/xfce4-panel-profiles/xfce4-panel-profiles.py
@@ -16,6 +16,8 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
+import tarfile
+
import gettext
gettext.textdomain('xfce4-panel-profiles')
@@ -252,9 +254,24 @@ class XfcePanelProfiles:
if savedlg.run() == Gtk.ResponseType.ACCEPT:
name = savedlg.get_save_name()
dst = os.path.join(self.save_location, name + ".tar.bz2")
- self._copy(filename, dst)
- self.tree_model.append(
- [dst, name, int(datetime.datetime.now().strftime('%s'))])
+ try:
+ self._copy(filename, dst)
+ self.tree_model.append(
+ [dst, name, int(datetime.datetime.now().strftime('%s'))])
+ except tarfile.ReadError:
+ message = _("Invalid configuration file!\n"
+ "Please select a valid configuration file.")
+
+ errordlg = Gtk.MessageDialog(
+ transient_for=self.window, modal=True,
+ message_type=Gtk.MessageType.ERROR,
+ text=message)
+
+ errordlg.add_button(_("OK"), Gtk.ResponseType.OK)
+
+ errordlg.run()
+ errordlg.destroy()
+
savedlg.destroy()
dialog.destroy()
@@ -337,6 +354,7 @@ class PanelSaveDialog(Gtk.MessageDialog):
def set_save_name(self, name):
self.entry.set_text(name.strip())
+
if __name__ == "__main__":
import sys
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list