aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/ppm.gresources.xml1
-rw-r--r--data/ui/ppm-error-dialog.ui96
-rwxr-xr-xsrc/prepaid-manager-applet.py40
3 files changed, 119 insertions, 18 deletions
diff --git a/data/ppm.gresources.xml b/data/ppm.gresources.xml
index 36e93a1..2948c0d 100644
--- a/data/ppm.gresources.xml
+++ b/data/ppm.gresources.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/PrepaidManager">
<file>ui/ppm.ui</file>
+ <file>ui/ppm-error-dialog.ui</file>
<file>ui/ppm-provider-assistant.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/ppm-error-dialog.ui b/data/ui/ppm-error-dialog.ui
new file mode 100644
index 0000000..a0e1842
--- /dev/null
+++ b/data/ui/ppm-error-dialog.ui
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="PPMErrorDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="type_hint">dialog</property>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="error_origin">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">10</property>
+ <property name="margin_right">10</property>
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="error_detail">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">10</property>
+ <property name="margin_right">10</property>
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-5">button1</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/src/prepaid-manager-applet.py b/src/prepaid-manager-applet.py
index 60c15e1..60486cf 100755
--- a/src/prepaid-manager-applet.py
+++ b/src/prepaid-manager-applet.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# vim: set fileencoding=utf-8 :
#
-# (C) 2010,2011 Guido Guenther <agx@sigxcpu.org>
+# (C) 2010,2011,2020 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@@ -41,11 +41,11 @@ from gi.repository import Gdk # noqa: E402
_ = None
+
# Needs to happen early so we can use it to create classes based on templates
resource = Gio.Resource.load(os.path.join(ppm.data_dir, "ppm.gresource"))
resource._register()
-
# The controller receives input and initiates a response by making calls on model
# objects. A controller accepts input from the user and instructs the model and
# view to perform actions based on that input.
@@ -318,8 +318,21 @@ class PPMController(Gtk.Application):
self.view.update_account_balance_information(balance, timestamp)
+# Views
+@Gtk.Template.from_resource('/org/gnome/PrepaidManager/ui/ppm-error-dialog.ui')
+class PPMErrorDialog(Gtk.Dialog):
+ __gtype_name__ = "PPMErrorDialog"
+ error_origin = Gtk.Template.Child()
+ error_detail = Gtk.Template.Child()
+
+ def __init__(self, origin, detail):
+ Gtk.Dialog.__init__(self)
+
+ self.error_origin.set_text(origin)
+ self.error_detail.set_text(detail)
+ self.set_title(GLib.get_application_name())
+
-# View
@Gtk.Template.from_resource('/org/gnome/PrepaidManager/ui/ppm.ui')
class PPMDialog(Gtk.ApplicationWindow):
__gtype_name__ = "PPMDialog"
@@ -448,14 +461,10 @@ class PPMDialog(Gtk.ApplicationWindow):
self.provider_info_missing_dialog.provider_unknown(mcc, mnc)
def show_modem_error(self, msg):
- dialog = Gtk.MessageDialog(parent=self,
- modal=True,
- destroy_with_parent=True,
- message_type=Gtk.MessageType.ERROR,
- buttons=Gtk.ButtonsType.OK)
- dialog.set_markup("Modem error: %s" % msg)
+ logging.debug(msg)
+ dialog = PPMErrorDialog(_("Modem error"), msg)
dialog.run()
- dialog.hide()
+ dialog.destroy()
def show_modem_enable(self):
self.enable_modem_info_bar.show()
@@ -470,14 +479,9 @@ class PPMDialog(Gtk.ApplicationWindow):
def show_error(self, msg):
"""show generic error"""
logging.debug(msg)
- error = Gtk.MessageDialog(parent=self,
- modal=True,
- destroy_with_parent=True,
- message_type=Gtk.MessageType.ERROR,
- buttons=Gtk.ButtonsType.OK)
- error.set_markup(msg)
- error.run()
- error.hide()
+ dialog = PPMErrorDialog(_("Error"), msg)
+ dialog.run()
+ dialog.destroy()
def show_modem_response(self):
self.modem_response_info_bar.show()