@@ -36,19 +36,20 @@ class Dialogs(GObject.GObject):
3636
3737 __gsignals__ = {
3838 'play_sound' : (GObject .SignalFlags .RUN_FIRST , GObject .TYPE_NONE , (GObject .TYPE_STRING ,)),
39- 'system-dialog-result' : (GObject .SignalFlags .RUN_FIRST , GObject .TYPE_NONE , (GObject .TYPE_INT ,))
39+ 'system-dialog-result' : (GObject .SignalFlags .RUN_FIRST , GObject .TYPE_NONE , (GObject .TYPE_INT ,)),
40+ 'warning-dialog-result' : (GObject .SignalFlags .RUN_FIRST , GObject .TYPE_NONE , (GObject .TYPE_INT , GObject .TYPE_STRING ))
4041 }
4142
4243 def __init__ (self , caller ):
4344 GObject .GObject .__init__ (self )
4445 self .sys_dialog = self .system_dialog (caller )
46+ self .warn_dialog = self .warning_dialog (caller )
4547
4648 def dialog_ext_control (self , answer ):
4749 if self .sys_dialog .get_visible ():
48- if answer :
49- self .sys_dialog .response (Gtk .ResponseType .ACCEPT )
50- else :
51- self .sys_dialog .response (Gtk .ResponseType .CANCEL )
50+ self .sys_dialog .response (answer )
51+ elif self .warn_dialog .get_visible ():
52+ self .warn_dialog .response (answer )
5253
5354 # This dialog is for unlocking the system tab
5455 # The unlock code number is defined at the top of the page
@@ -134,7 +135,7 @@ def entry_dialog(self, caller, data = None, header = _("Enter value") , label =
134135 return "CANCEL"
135136
136137 # display warning dialog
137- def warning_dialog (self , caller , message , secondary = None , title = _ ("Operator Message" ),\
138+ def warning_dialog (self , caller , message = '' , secondary = None , title = _ ("Operator Message" ),\
138139 sound = True , confirm_pin = 'warning-confirm' , active_pin = None ):
139140 dialog = Gtk .MessageDialog (caller .widgets .window1 ,
140141 Gtk .DialogFlags .DESTROY_WITH_PARENT ,
@@ -149,11 +150,10 @@ def warning_dialog(self, caller, message, secondary = None, title = _("Operator
149150 box .add (ok_button )
150151 dialog .action_area .add (box )
151152 dialog .set_border_width (5 )
152- dialog .show_all ()
153153 if sound :
154154 self .emit ("play_sound" , "alert" )
155155 dialog .set_title (title )
156-
156+ dialog . context = []
157157 def periodic ():
158158 if caller .halcomp [confirm_pin ]:
159159 dialog .response (Gtk .ResponseType .OK )
@@ -164,10 +164,26 @@ def periodic():
164164 return False
165165 return True
166166 GLib .timeout_add (100 , periodic )
167+ dialog .connect ("response" , self .on_warning_response )
168+ return dialog
167169
168- response = dialog .run ()
169- dialog .destroy ()
170- return response == Gtk .ResponseType .OK
170+ def show_warning_dialog (self , title , message , context = None , sound = True ,\
171+ confirm_pin = 'warning-confirm' , active_pin = None ):
172+ print (message ,context )
173+ self .warn_dialog .context .append (context )
174+ self .warn_dialog .set_title (title )
175+ self .warn_dialog .format_secondary_text (message )
176+ self .warn_dialog .set_markup (message )
177+ self .warn_dialog .show_all ()
178+ if sound :
179+ self .emit ("play_sound" , "alert" )
180+ print (self .warn_dialog .context )
181+
182+ def on_warning_response (self , dialog , rtn ):
183+ context = dialog .context .pop ()
184+ print (context )
185+ self .emit ('warning-dialog-result' , rtn , context )
186+ dialog .hide ()
171187
172188 def yesno_dialog (self , caller , message , title = _ ("Operator Message" )):
173189 dialog = Gtk .MessageDialog (caller .widgets .window1 ,
0 commit comments