comparison frontends/src/quick_frontend/quick_profile_manager.py @ 1613:1c5761cb1bdc

quick_frontend(profile manager): fixed alert messages
author Goffi <goffi@goffi.org>
date Tue, 17 Nov 2015 12:39:38 +0100
parents 039d96e131be
children d17772b0fe22
comparison
equal deleted inserted replaced
1612:48f324352c52 1613:1c5761cb1bdc
112 profile = self.host.bridge.getProfileName(profile_key) 112 profile = self.host.bridge.getProfileName(profile_key)
113 if not profile: 113 if not profile:
114 self._autoconnect = False # manual mode 114 self._autoconnect = False # manual mode
115 msg = _("Trying to plug an unknown profile key ({})".format(profile_key)) 115 msg = _("Trying to plug an unknown profile key ({})".format(profile_key))
116 log.warning(msg) 116 log.warning(msg)
117 self.alert(_("Profile plugging in error"), msg) 117 self.showDialog(_("Profile plugging in error"), msg, 'error')
118 break 118 break
119 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile) 119 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile)
120 120
121 121
122 def getParamError(self, dummy): 122 def getParamError(self, dummy):
123 self.alert(_(u"Error"), _("Can't get profile parameter")) 123 self.host.showDialog(_(u"Error"), _("Can't get profile parameter"), 'error')
124 124
125 ## Helping methods ## 125 ## Helping methods ##
126 126
127 def _getErrorMessage(self, reason): 127 def _getErrorMessage(self, reason):
128 """Return an error message corresponding to profile creation error 128 """Return an error message corresponding to profile creation error
151 # These methods must be called by the frontend at some point 151 # These methods must be called by the frontend at some point
152 152
153 def _onConnectProfiles(self): 153 def _onConnectProfiles(self):
154 """Connect the profiles and start the main widget""" 154 """Connect the profiles and start the main widget"""
155 if self._autoconnect: 155 if self._autoconnect:
156 self.alert(_('Internal error'), _("You can't connect manually and automatically at the same time")) 156 self.host.showDialog(_('Internal error'), _("You can't connect manually and automatically at the same time"), 'error')
157 return 157 return
158 self.updateConnectionParams() 158 self.updateConnectionParams()
159 profiles = self.getProfiles() 159 profiles = self.getProfiles()
160 if not profiles: 160 if not profiles:
161 self.alert(_('No profile selected'), _('You need to create and select at least one profile before connecting')) 161 self.host.showDialog(_('No profile selected'), _('You need to create and select at least one profile before connecting'), 'error')
162 else: 162 else:
163 # All profiles in the list are already validated, so we can plug them directly 163 # All profiles in the list are already validated, so we can plug them directly
164 self.host.plug_profiles(profiles) 164 self.host.plug_profiles(profiles)
165 165
166 def getConnectionParams(self, profile): 166 def getConnectionParams(self, profile):
247 """ 247 """
248 raise NotImplementedError 248 raise NotImplementedError
249 249
250 # dialogs 250 # dialogs
251 251
252 def alert(self, title, message):
253 """Show an alert message, must be implemented by frontends
254
255 @param title: title of the dialog/popup
256 @param message: error message
257 """
258 raise NotImplementedError
259
260 # Note: a method which check profiles change must be implemented too 252 # Note: a method which check profiles change must be implemented too