def send_mms(self, widget): """ sends the message (no shit?) """ hildon.hildon_gtk_window_set_progress_indicator(self.window, 1) self.force_ui_update() to = self.eNumber.get_text() if not self.cont.validate_phonenumber_email(to) or to == "": self.show_system_note(gettext.ldgettext('rtcom-messaging-ui', "messaging_fi_smsc_invalid_chars")) return attachment = self.attachmentFile hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('modest', "mcen_li_outbox_sending")) self.force_ui_update() if attachment == "" or attachment == None: attachment = None self.attachmentIsResized = False else: filetype = gnomevfs.get_mime_type(attachment) self.attachmentIsResized = False if self.config.get_img_resize_width() != 0 and filetype.startswith("image"): try: attachment = self.resize_img(attachment) except Exception, e: log.exception("resize failed: %s %s", type(e), e) errmsg = str(e.args) errstr = gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed") self.show_system_note("%s\n%s" % (errstr, errmsg)) raise
def send_mms(self, widget): """ sends the message (no shit?) """ hildon.hildon_gtk_window_set_progress_indicator(self.window, 1) self.force_ui_update() to = self.eNumber.get_text() if not self.cont.validate_phonenumber_email(to) or to == "": self.show_system_note( gettext.ldgettext('rtcom-messaging-ui', "messaging_fi_smsc_invalid_chars")) return attachment = self.attachmentFile hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('modest', "mcen_li_outbox_sending")) self.force_ui_update() if attachment == "" or attachment == None: attachment = None self.attachmentIsResized = False else: filetype = gnomevfs.get_mime_type(attachment) self.attachmentIsResized = False if self.config.get_img_resize_width() != 0 and filetype.startswith( "image"): try: attachment = self.resize_img(attachment) except Exception, e: log.exception("resize failed: %s %s", type(e), e) errmsg = str(e.args) errstr = gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed") self.show_system_note("%s\n%s" % (errstr, errmsg)) raise
def save_settings(widget, window, parent, entry): user = entry.get_text() conn = sqlite3.connect(settings.db_path) c = conn.execute("select value from config where name=?", ('user',)) current_user = c.fetchone() if current_user is not None and current_user[0] == user: window.destroy() return try: uf = UserFetcher(user) user_id = uf.user_id sql = "delete from config where name=? or name=? or name=?" conn.execute(sql, ('user', 'user_id', 'since_id')) sql = "insert into config values (?, ?)" conn.execute(sql, ('user', user)) sql = "insert into config values (?, ?)" conn.execute(sql, ('user_id', user_id)) sql = "delete from notices" conn.execute(sql) conn.commit() conn.close() hildon.hildon_banner_show_information(parent, '', "Settings saved.") window.destroy() except NoSuchUserException, nse: message = "User does not exist." hildon.hildon_banner_show_information(parent, '', message)
def remove_read_notices(widget, timeline): sql = "delete from notices where read = 1 and highlighted = 0" conn = sqlite3.connect(settings.db_path) conn.execute(sql) conn.commit() conn.close() timeline.remove_read_notices() hildon.hildon_banner_show_information(widget, '', "Removed read notices")
def save(self, button): apikey = self.qapikey.get_text() if self.player.check_password(apikey): banneri= hildon.hildon_banner_show_information(button, "", "Qaiku api-key saved") stack = self.get_stack() stack.pop(1) else: banner= hildon.hildon_banner_show_information(button, "", "Incorrect qaiku api-key")
def delete_push_mms(self, fname): """ Deletes both the MMS and the PUSH message. """ try: self.cont.wipe_message(fname) except Exception, e: log.exception("failed to delete push mms") hildon.hildon_banner_show_information( self.window, "", gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed"))
def copy_file(self, src, dst): if not os.path.isfile(dst): log.info("copying %s -> %s" % (src, dst)) shutil.copy(src, dst) banner = hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('hildon-libs', "wdgt_bd_done")) else: log.info("copy failed: file exists (%s -> %s)" % (src, dst)) banner = hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed"))
def show_message(self, message, title=None, important=False, widget=None): if gpodder.ui.diablo: import hildon if important: dlg = hildon.Note('information', (self.main_window, message)) dlg.run() dlg.destroy() else: if title is None: title = 'gPodder' pango_markup = '<b>%s</b>\n<small>%s</small>' % (title, message) hildon.hildon_banner_show_information_with_markup(gtk.Label(''), None, pango_markup) elif gpodder.ui.fremantle: import hildon if important: if title is None: message = message else: message = '%s\n%s' % (title, message) dlg = hildon.hildon_note_new_information(self.main_window, \ message) dlg.run() dlg.destroy() else: hildon.hildon_banner_show_information(self.main_window, \ '', message) else: # XXX: Dirty hack to get access to the gPodder-specific config object config = getattr(self, '_config', getattr(self, 'config', None)) if important: dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK) if title: dlg.set_title(str(title)) dlg.set_markup('<span weight="bold" size="larger">%s</span>\n\n%s' % (title, message)) else: dlg.set_markup('<span weight="bold" size="larger">%s</span>' % (message)) dlg.run() dlg.destroy() elif config is not None and config.enable_notifications: if pynotify is not None: if title is None: title = 'gPodder' notification = pynotify.Notification(title, message,\ gpodder.icon_file) notification.show() elif widget and isinstance(widget, gtk.Widget): if not widget.window: widget = self.main_window else: widget = self.main_window notification = NotificationWindow(message, title, important=False, widget=widget) notification.show_timeout()
def show_information(self, button, data=None): icon_text = self.icon_entry.get_text() if icon_text == "": icon_text = None if not self.markup_check.get_active(): hildon.hildon_banner_show_information(self.window, icon_text, self.text_entry.get_text()) else: hildon.hildon_banner_show_information_with_markup( self.window, icon_text, self.text_entry.get_text())
def notify(self, message): """ Sends a notification using pynotify, returns message """ if platform.DESKTOP and have_pynotify: icon = util.find_data_file('panucci_64x64.png') notification = pynotify.Notification(self.main_window.get_title(), message, icon) notification.show() elif platform.FREMANTLE: hildon.hildon_banner_show_information(self.main_window, \ '', message) elif platform.MAEMO: # Note: This won't work if we're not in the gtk main loop markup = '<b>%s</b>\n<small>%s</small>' % (self.main_window.get_title(), message) hildon.hildon_banner_show_information_with_markup(self.main_window, None, markup)
def update(self): # Redraws automatically it seems :) if not self.hasSettings: hildon.hildon_banner_show_information(self, "", "No user info configured!") self.balance = DummyBalance("No info!") self.setDrawer(NoUserInfoDrawer()) self.showSettings(None) ### Shouldn't be necessary TODO return if not self.isConnected: self.updatePending = True self.setDrawer(CouldntGetDataDrawer()) self.connection.request_connection(conic.CONNECT_FLAG_NONE) return self.updatePending = False hildon.hildon_banner_show_information(self, "", "Getting Mobile Vikings info") try: dom = parseString(self.xml.requestXML('sim_balance')) self.balance = MVBalance(dom) self.setDrawer(self.regularinfo) hildon.hildon_banner_show_information(self, "", "Mobile Vikings info updated") except: self.balance = DummyBalance("Failed to get") self.setDrawer(CouldntGetDataDrawer()) hildon.hildon_banner_show_information(self, "", "Getting Mobile Vikings info went wrong!")
def notify(self, message): """ Sends a notification using pynotify, returns message """ if platform.DESKTOP and have_pynotify: icon = util.find_data_file('panucci_64x64.png') notification = pynotify.Notification(self.main_window.get_title(), message, icon) notification.show() elif platform.FREMANTLE: hildon.hildon_banner_show_information(self.main_window, \ '', message) elif platform.MAEMO: # Note: This won't work if we're not in the gtk main loop markup = '<b>%s</b>\n<small>%s</small>' % ( self.main_window.get_title(), message) hildon.hildon_banner_show_information_with_markup( self.main_window, None, markup)
def run(self): if (platforms.MAEMO4): import hildon hildon.hildon_banner_show_information( self.__parent._get_window_impl(), None, self.__message) elif (platforms.MAEMO5): import hildon hildon.hildon_banner_show_information( self.__parent._get_window_impl(), "", self.__message) else: print self.__message
def open_file_dialog(self, button, data=None): # this shouldnt issue a warning according to the pymaemo mailing list, but does # anyway, nfc why :( #fcd = gobject.new(hildon.FileChooserDialog, self.window, action=gtk.FILE_CHOOSER_ACTION_OPEN) fcd = hildon.FileChooserDialog(self.window, gtk.FILE_CHOOSER_ACTION_OPEN) fcd.set_default_response(gtk.RESPONSE_OK) fcd.set_transient_for(self.window) folder = self.config.get_last_ui_dir() if folder: if os.path.isdir(folder): fcd.set_current_folder(folder) ret = fcd.run() if ret == gtk.RESPONSE_OK: ### TODO: dont hardcode filesize check filesize = os.path.getsize(fcd.get_filename()) / 1024 if filesize > 10240: errhelp = _("Attachment is too large (limit is %s)." % "10 MB") banner = hildon.hildon_banner_show_information(self.window, "", errhelp) else: self.attachmentFile = fcd.get_filename() self.set_thumbnail(self.attachmentFile) folder = fcd.get_current_folder() self.config.set_last_ui_dir(folder) fcd.destroy() else: fcd.destroy() return True
def open_file_dialog(self, button, data=None): # this shouldnt issue a warning according to the pymaemo mailing list, but does # anyway, nfc why :( #fcd = gobject.new(hildon.FileChooserDialog, self.window, action=gtk.FILE_CHOOSER_ACTION_OPEN) fcd = hildon.FileChooserDialog(self.window, gtk.FILE_CHOOSER_ACTION_OPEN) fcd.set_default_response(gtk.RESPONSE_OK) fcd.set_transient_for(self.window) folder = self.config.get_last_ui_dir() if folder: if os.path.isdir(folder): fcd.set_current_folder(folder) ret = fcd.run() if ret == gtk.RESPONSE_OK: ### TODO: dont hardcode filesize check filesize = os.path.getsize(fcd.get_filename()) / 1024 if filesize > 10240: errhelp = _("Attachment is too large (limit is %s)." % "10 MB") banner = hildon.hildon_banner_show_information( self.window, "", errhelp) else: self.attachmentFile = fcd.get_filename() self.set_thumbnail(self.attachmentFile) folder = fcd.get_current_folder() self.config.set_last_ui_dir(folder) fcd.destroy() else: fcd.destroy() return True
def refresh(self): "update departures" banner = hildon.hildon_banner_show_information(self.main_window, "", "Chargement en cours") banner.set_timeout(10000) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 1) self.treestore.clear() try: source_text = self.combo_source.get_current_text() dest_text = self.combo_dest.get_current_text() except AttributeError: source_text = self.combo_source.child.get_text() dest_text = self.combo_dest.child.get_text() for backend in self.weboob.iter_backends(): for station in backend.iter_station_search(source_text): for arrival in \ backend.iter_station_search(dest_text): for departure in \ backend.iter_station_departures(station.id, arrival.id): self.treestore.append(None, [departure.type, departure.time, departure.arrival_station, departure.plateform, departure.information]) self.refresh_in_progress = False banner.set_timeout(1) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 0)
def on_feature_complete(self, wnd, error=None): if wnd is self: if error: banner = hildon.hildon_banner_show_information(self, '', "Unable to get list") banner.set_timeout(2000) self.fetcher.stop() self.fetcher = None
def refresh(self): "update departures" banner = hildon.hildon_banner_show_information(self.main_window, "", "Chargement en cours") banner.set_timeout(10000) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 1) self.treestore.clear() try: source_text = self.combo_source.get_current_text() dest_text = self.combo_dest.get_current_text() except AttributeError: source_text = self.combo_source.child.get_text() dest_text = self.combo_dest.child.get_text() for backend in self.weboob.iter_backends(): for station in backend.iter_station_search(source_text): for arrival in \ backend.iter_station_search(dest_text): for departure in \ backend.iter_station_departures(station.id, arrival.id): self.treestore.append(None, [ departure.type, departure.time, departure.arrival_station, departure.plateform, departure.information ]) self.refresh_in_progress = False banner.set_timeout(1) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 0)
def create_advanced_config(self, spawnedby): dialog = gtk.Dialog() dialog.set_title( gettext.ldgettext('osso-connectivity-ui', 'conn_set_iap_ti_adv')) allVBox = gtk.VBox() labelwidth = 20 inputs = [(gettext.ldgettext('osso-connectivity-ui', 'conn_set_iap_fi_adv_ip_ip'), 'ip'), \ (gettext.ldgettext('osso-connectivity-ui', 'conn_set_iap_fi_adv_ip_dns_prim'), 'pdns'), \ (gettext.ldgettext('osso-connectivity-ui', 'conn_set_iap_fi_adv_ip_dns_sec'), 'sdns')] entries = {} current = self.config.get_advanced_apn_settings() if not current: current = self.cont.get_apn_settings_automatically() self.config.set_advanced_apn_settings(current) log.info("Set Advanced APN settings: %s" % current) if current['ip'] == "" or not current['ip']: current = self.cont.get_apn_settings_automatically() self.config.set_advanced_apn_settings(current) log.info("Set Advanced APN settings: %s" % current) for labelname in inputs: (labelname, var) = labelname box = gtk.HBox() label = gtk.Label(labelname) label.set_width_chars(labelwidth) label.set_alignment(0, 0.5) #vars()[var] = gtk.Entry() vars()[var] = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT) if current: if current.get(var, None): vars()[var].set_text(str(current[var])) entries[var] = vars()[var] box.pack_start(label, False, True, 0) box.pack_start(vars()[var], True, True, 0) allVBox.pack_start(box, False, False, 2) allVBox.show_all() dialog.vbox.add(allVBox) dialog.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_APPLY) ret = dialog.run() settings = {} for val in entries: settings[val] = vars()[val].get_text() if ret == gtk.RESPONSE_APPLY: self.config.set_advanced_apn_settings(settings) log.info("Set Advanced APN settings: %s" % settings) banner = hildon.hildon_banner_show_information(self.parent, "", \ gettext.ldgettext('osso-connectivity-ui', "conn_ib_settings_saved")) dialog.destroy()
def log_button(self, button): self.current_adventure.log(self.player, self.player.location, self.qaiku_message.get_text(), '', True ) banneri= hildon.hildon_banner_show_information(button, "", "Log has been sent") stack = self.get_stack() stack.pop(1)
def main(): Setup() logging.basicConfig(filename=os.path.expanduser(settings.log_file), filemode='w', format=settings.log_format, level=logging.getLevelName(settings.log_level)) gtk.set_application_name(settings.app_name) program = hildon.Program.get_instance() win = hildon.StackableWindow() win.set_title(settings.app_name) win.connect("destroy", gtk.main_quit, None) hildon.hildon_gtk_window_set_progress_indicator(win, 1) win.show_all() pannable_area = hildon.PannableArea() conn = sqlite3.connect(settings.db_path) c = conn.execute("select value from config where name=?", ('user',)) user = c.fetchone() conn.close() if user is None: message = "No user set up in database." logging.error("%s" % message) message += " Please go to Settings and enter a username." info = hildon.hildon_note_new_information(win, message) response = gtk.Dialog.run(info) if response == gtk.RESPONSE_DELETE_EVENT: info.destroy() try: if user is not None: user = user[0] logging.info("Loading notices for %s" % user) nf = NoticeFetcher(user) nf.fetch() except Exception, e: message = "Problem loading notices. Is the network down?" logging.error("%s | %s" % (message, e)) hildon.hildon_banner_show_information(pannable_area, '', message)
def add_player_to_map(self, adventure, player): #print "Adding " + player.nick + " to map of " + adventure.name + " to " + player.location.describe() banner = hildon.hildon_banner_show_information(self, "", "%s has joined adventure %s" % (player.nick, adventure.name)) if player.piece is not None: # This player is already on the map #print " skipping add because player is already on map" return player.piece = gtk.gdk.pixbuf_new_from_file_at_size (os.path.dirname(__file__) + "/" + player.colour + ".png", 35,35) self.osm.add_image(player.location.lat, player.location.lon, player.piece) player.gameboard_listener = player.connect('location-changed', self.location_changed)
def on_tag_complete(self, wnd, error=None): if wnd is self: taglist = self.fetcher.taglist self.fetcher.stop() if not error: wnd = open_playerwindow() wnd.play_tracks(taglist) else: banner = hildon.hildon_banner_show_information(self, '', "Error getting tracks") banner.set_timeout(2000) self.fetcher = None
def delete_push_mms(self, fname): """ delete push & mms """ log.info("deleting message: %s", fname) try: self.cont.wipe_message(fname) #banner = hildon.hildon_banner_show_information(self.window, "", "Message deleted") self.force_ui_update() self.window.destroy() except Exception, e: log.exception("%s %s", type(e), e) banner = hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed"))
def start_tag_fetcher(self, item_id): if self.fetcher: self.fetcher.stop() self.fetcher = None self.fetcher = Fetcher(lambda: jamaendo.get_tag_tracks(item_id), self, on_item = self.on_tag_result, on_ok = self.on_tag_complete, on_fail = self.on_tag_complete) self.fetcher.taglist = [] self.fetcher.start() banner = hildon.hildon_banner_show_information(self, '', "Getting tracks for tag") banner.set_timeout(2000)
def show_mms(self, treeview, path): """ Shows the message at the current selection in the treeview. """ self.treeview.set_sensitive(False) # Show loading indicator hildon.hildon_gtk_window_set_progress_indicator(self.window, 1) self.force_ui_update() log.info("showing mms: %s", path) model = treeview.get_model() miter = model.get_iter(path) # the 4th value is the transactionid (start counting at 0) transactionid = model.get_value(miter, 3) switch = False if not self.cont.is_fetched_push_by_transid( transactionid) and self.config.get_connmode( ) == fMMSconf.CONNMODE_ICDSWITCH: if not self.cont.get_current_connection_iap_id( ) == self.config.get_apn(): switch = self.show_switch_conn_dialog() if switch: self.cont.disconnect_current_connection() #if not self.cont.is_mms_read(transactionid) and not self.cont.get_direction_mms(transactionid) == fMMSController.MSG_DIRECTION_OUT: #self.refreshlistview = True self.import_viewer() try: fMMSViewer.fMMS_Viewer(transactionid, spawner=self) except Exception, e: log.exception("Failed to open viewer with transaction id: %s" % transactionid) hildon.hildon_banner_show_information( self.window, "", gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed"))
def _add_or_update_cb(self, button): # don't allow clicking until everything is loaded if self._loaded: if not self._start: self._start = datetime.datetime.now() # if it's recurring, make sure due is set recurrence = self.get_recurrence() if recurrence: due = self.get_due() if not due: due = self._start + datetime.timedelta(seconds=recurrence) self._set_due(due) self.emit('done') else: banner = hildon.hildon_banner_show_information(self, 'warning', "Please wait until projects, contexts and statuses are loaded")
def config_menu_button_clicked(self, action): """ Checks if we should save the Configuration options. """ if action == 1: #self.config.set_phonenumber(self.number.get_text()) selectorlabel = self.imgwidth.get_selector().get_current_text() size = 0 for (label, val) in self.imgmodes: if label == selectorlabel: size = val self.config.set_img_resize_width(size) log.info("Set image width to %s" % size) self.config.set_connmode(self.connmode_option()) log.info("Set connection mode %s" % self.connmode_option()) self.config.set_roammode(self.roammode_option()) log.info("Set roaming mode %s" % self.roammode_option()) banner = hildon.hildon_banner_show_information(self.window, "", \ gettext.ldgettext('osso-connectivity-ui', "conn_ib_settings_saved")) return 0
def location_changed(self, adventurer, location, text, qaikuid, force_log): # FIXME: In newer OsmGpsMap versions we can just move the image if text == '': text = "New location %s, distance to destination %s" % (location.pretty_print(), location.distance_to(self.current_adventure.destination)) #print "%s: %s" % (adventurer.nick, text) if adventurer.piece is not None: self.osm.remove_image(adventurer.piece) self.osm.add_image(adventurer.location.lat, adventurer.location.lon, adventurer.piece) if adventurer.nick == self.player.nick: if (self.track_location): self.osm.set_mapcenter(location.lat, location.lon, self.osm.props.zoom) self.update_description('home') else: self.update_description('destination') else: banner= hildon.hildon_banner_show_information(self, "", "%s: %s" %(adventurer.nick, text)) #TODO: Send an infobubble saying the text of the new location pass
def added(self, button): if self.create_destination is None: banner= hildon.hildon_banner_show_information(button, "", "You have to choose a destination") date = datetime.datetime.today() mission = midgard.mgdschema.ttoa_mission() mission.type = 2 mission.text = self.create_adventure.get_text() mission.pubDate = date mission.validDate = date.replace(hour=23, minute=59, second=59) mission.latitude = self.create_destination.lat mission.longitude = self.create_destination.lon mission.author = self.player.user.id mission.create() adventure = self.blyton.adventure_from_mission(mission, self.player) self.blyton.adventures.append(adventure) self.add_adventure_to_selector(adventure) if self.player.apikey is not None: adventure.adventure_to_qaiku(adventure, self.player.apikey) # Close the "add" window stack = self.get_stack() stack.pop(1)
def show_message(self, message, title=None, important=False, widget=None): if gpodder.ui.diablo: import hildon if important: try: dlg = hildon.Note('information', (self.main_window, message)) except TypeError: if title is None: message = message else: message = '%s\n%s' % (title, message) dlg = hildon.hildon_note_new_information(self.main_window, \ message) dlg.run() dlg.destroy() else: if title is None: title = 'gPodder' pango_markup = '<b>%s</b>\n<small>%s</small>' % (title, message) try: hildon.hildon_banner_show_information_with_markup( gtk.Label(''), None, pango_markup) except TypeError: # We're probably running the Diablo UI on Maemo 5 :) hildon.hildon_banner_show_information(self.main_window, \ '', message) elif gpodder.ui.fremantle: import hildon if important: if title is None: message = message else: message = '%s\n%s' % (title, message) dlg = hildon.hildon_note_new_information( \ self.get_dialog_parent(), \ message) dlg.run() dlg.destroy() else: hildon.hildon_banner_show_information(self.get_dialog_parent(), \ '', message) else: # XXX: Dirty hack to get access to the gPodder-specific config object config = getattr(self, '_config', getattr(self, 'config', None)) if important: dlg = gtk.MessageDialog(self.main_window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK) if title: dlg.set_title(str(title)) dlg.set_markup( '<span weight="bold" size="larger">%s</span>\n\n%s' % (title, message)) else: dlg.set_markup( '<span weight="bold" size="larger">%s</span>' % (message)) dlg.run() dlg.destroy() elif config is not None and config.enable_notifications: if pynotify is not None: if title is None: title = 'gPodder' notification = pynotify.Notification(title, message,\ gpodder.icon_file) try: notification.show() except: # See http://gpodder.org/bug/966 pass elif widget and isinstance(widget, gtk.Widget): if not widget.window: widget = self.main_window elif not gpodder.win32: widget = self.main_window notification = NotificationWindow(message, title, important=False, widget=widget) notification.show_timeout()
def __init__(self, parent): dialog = gtk.Dialog() dialog.set_transient_for(parent) dialog.set_title( gettext.ldgettext('osso-connectivity-ui', "conn_fi_placeholder_iap_settings")) self.parent = parent self.cont = fMMSController.fMMS_controller() self.config = self.cont.config pan = hildon.PannableArea() pan.set_property("mov-mode", hildon.MOVEMENT_MODE_VERT) allVBox = gtk.VBox() labelwidth = 20 gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_username") inputs = [(gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_accessp_name"), 'apn') , \ ('MMSC', 'mmsc'), \ (gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_username"), 'user'), \ (gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_password"), 'pass'), \ (gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_adv_proxies_http"), 'proxy'), \ (gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_fi_adv_proxies_port"), 'proxyport')] entries = {} current = self.config.get_apn_settings() log.info("Current APN settings: %s" % current) if not current: current = self.cont.get_apn_settings_automatically() self.config.set_apn_settings(current) log.info("Set APN settings: %s" % current) if not current['apn'] or current['mmsc'] == "": current = self.cont.get_apn_settings_automatically() if current: self.config.set_apn_settings(current) log.info("Set APN settings: %s" % current) for labelname in inputs: (labelname, var) = labelname box = gtk.HBox() label = gtk.Label(labelname) label.set_width_chars(labelwidth) label.set_alignment(0, 0.5) #vars()[var] = gtk.Entry() vars()[var] = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT) if var == "proxyport": vars()[var].set_property('hildon-input-mode', gtk.HILDON_GTK_INPUT_MODE_NUMERIC) if current: if current.get(var, None): vars()[var].set_text(str(current[var])) entries[var] = vars()[var] box.pack_start(label, False, True, 0) box.pack_start(vars()[var], True, True, 0) allVBox.pack_start(box, False, False, 2) pan.add_with_viewport(allVBox) pan.set_size_request_policy(hildon.SIZE_REQUEST_CHILDREN) dialog.vbox.add(pan) dialog.show_all() dialog.add_button( gettext.ldgettext('osso-connectivity-ui', "conn_set_iap_bd_advanced"), 999) dialog.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_APPLY) while 1: ret = dialog.run() settings = {} for val in entries: settings[val] = vars()[val].get_text() if ret == 999: self.create_advanced_config(dialog) if ret == gtk.RESPONSE_APPLY: # We can hardcode the checks here since # the fields have to exist here if settings['apn'] == "": banner = hildon.hildon_banner_show_information( parent, "", "Invalid APN.") elif settings['mmsc'] == "": banner = hildon.hildon_banner_show_information( parent, "", "Invalid MMSC.") else: settings['proxy'] = self.cont.convert_to_real_ip( settings['proxy']) settings['mmsc'] = self.cont.clean_url(settings['mmsc']) self.config.set_apn_settings(settings) log.info("Set APN settings: %s" % settings) banner = hildon.hildon_banner_show_information(parent, "", \ gettext.ldgettext('osso-connectivity-ui', "conn_ib_settings_saved")) break elif ret == -4: break dialog.destroy()
def message(self, text, timeout=500): banner = hildon.hildon_banner_show_information(self.window, '', str(text)) banner.set_timeout(timeout) return banner
sql = "delete from notices" conn.execute(sql) conn.commit() conn.close() hildon.hildon_banner_show_information(parent, '', "Settings saved.") window.destroy() except NoSuchUserException, nse: message = "User does not exist." hildon.hildon_banner_show_information(parent, '', message) except Exception, e: logging.error("Error getting user info | %s %s" % (str(type(e)), e)) message = "Couldn't get user information." hildon.hildon_banner_show_information(parent, '', message) def configure(widget, win): window = hildon.StackableWindow() window.set_title(settings.app_name + " - Settings") conn = sqlite3.connect(settings.db_path) c = conn.execute("select value from config where name=?", ('user',)) user = c.fetchone() conn.close() label = gtk.Label("Username") entry = hildon.Entry(gtk.HILDON_SIZE_AUTO) entry.set_max_length(64) if user is not None: entry.set_text(user[0])
def on_message(self, bus, message): if message.type == gst.MESSAGE_ERROR: err, debug = message.parse_error() hildon.hildon_banner_show_information(self.w, '', "Error: %s" % err)
errstr = gettext.ldgettext('hildon-common-strings', "sfil_ni_operation_failed") self.show_system_note("%s\n%s" % (errstr, errmsg)) raise to = self.eNumber.get_text() sender = self.config.get_phonenumber() tb = self.tvMessage.get_buffer() message = tb.get_text(tb.get_start_iter(), tb.get_end_iter()) log.info("attachment: %s message: %s", attachment, message) (status, msg) = self.cont.send_mms(to, self.subject, message, attachment, sender) if status == 0: banner = hildon.hildon_banner_show_information(self.spawner, "", \ gettext.dngettext('modest', 'mcen_ib_message_sent', 'mcen_ib_messages_sent', 1)) if self.attachmentIsResized == True: log.info("Removing temporary image: %s", attachment) os.remove(attachment) self.quit("clean") return elif status == -1: self.show_system_note(msg) hildon.hildon_gtk_window_set_progress_indicator(self.window, 0) self.bSend.set_sensitive(True) def from_sharing_service(self): try: if self.fromSharingService:
def update_widget(self, softUpdate = False): self.image = gtk.Image() self.image.set_size_request(64, 64) hosts = self.get_nagios_data() self.hosts = hosts # notification patterns for N900 ledPatternWarning = 'PatternBatteryCharging' ledPatternCritical = 'PatternError' vibratePattern = 'PatternChatAndEmail' # connect to mce service try: bus = dbus.SystemBus() smsobject = bus.get_object('com.nokia.mce', '/com/nokia/mce/request') smsiface = dbus.Interface(smsobject, 'com.nokia.mce.request') dbusConn = True except: dbusConn = False # deactivate previous led patterns if dbusConn: smsiface.req_led_pattern_deactivate(dbus.String(ledPatternCritical)) smsiface.req_led_pattern_deactivate(dbus.String(ledPatternWarning)) if hosts == False: # display disconnected icon self.image.set_from_file(self.images['DISCONNECTED']) hostStatusString = _(u"Disco'd") infoString = "" else: criticalServices = 0 warningServices = 0 for host in hosts: for service in host['services']: if service['status'] == "WARNING": warningServices += 1 elif service['status'] == "CRITICAL": criticalServices += 1 ledPattern = str() hostStatusString = str() if criticalServices > 0: self.image.set_from_file(self.images['CRITICAL']) ledPattern = ledPatternCritical if criticalServices > 1: hostStatusString = str(criticalServices) + " " + _(u"Alerts") infoString = str(criticalServices) + " " + _(u"Critical Alerts") else: hostStatusString = str(criticalServices) + " " + _(u"Alert") infoString = str(criticalServices) + " " + _(u"Critical Alert") elif warningServices > 0: ledPattern = ledPatternWarning if warningServices > 1: hostStatusString = str(warningServices) + " " + _(u"Alerts") infoString = str(warningServices) + " " + _(u"Warning Alerts") else: hostStatusString = str(warningServices) + " " + _(u"Alert") infoString = str(warningServices) + " " + _(u"Warning Alert") self.image.set_from_file(self.images['WARNING']) else: self.image.set_from_file(self.images['OK']) hostStatusString = _(u"All Good!") infoString = "" self.label = gtk.Label(hostStatusString) self.label.set_justify(gtk.JUSTIFY_CENTER) self.label.modify_font(pango.FontDescription("11")) if len(infoString) > 0: # notify if int(gconf.client_get_default().get_string('/apps/maegios/notify_banner')) == 1 and softUpdate == False and dbusConn: banner = hildon.hildon_banner_show_information(self, '', \ "Nagios: %s!" % infoString) banner.set_timeout(5000) if int(gconf.client_get_default().get_string('/apps/maegios/notify_sound')) == 1 and softUpdate == False and dbusConn: player = gst.element_factory_make('playbin2', 'myplayer') player.set_property('uri', 'file:///usr/share/sounds/ui-new_email.wav') player.set_state(gst.STATE_PLAYING) if int(gconf.client_get_default().get_string('/apps/maegios/notify_vibration')) == 1 and softUpdate == False and dbusConn: smsiface.req_vibrator_pattern_activate(dbus.String(vibratePattern)) if int(gconf.client_get_default().get_string('/apps/maegios/notify_light')) == 1 and dbusConn: smsiface.req_led_pattern_activate(dbus.String(ledPattern)) self.image.show_all() self.label.show_all() self.vbox = gtk.VBox(False, 0) if len(self.event_box.get_children()) > 0: self.event_box.remove(self.event_box.get_children()[0]) self.vbox.set_border_width(12) self.vbox.pack_start(self.image, False, False, 0) self.vbox.pack_start(self.label, False, False, 5) self.vbox.show_all() self.event_box.add(self.vbox)
def report_error(self, error): hildon.hildon_banner_show_information(self.win, '', error)
def notify(self, title, string) : hildon.hildon_banner_show_information(self.app, title, string)
def show_banner_information(self, mess): parent = hildon.WindowStack.get_default().peek() banner= hildon.hildon_banner_show_information(parent,"", mess) banner.set_timeout(2000)
def testShowInformation(self): hildon.hildon_banner_show_information(self.parent, "", "Dummy text")
def notify_battery(self): hildon.hildon_banner_show_information(self.window, None, "Batterinivån är låg")
def show_banner_information(mess): parent = hildon.WindowStack.get_default().peek() banner = hildon.hildon_banner_show_information(parent, "", mess) banner.set_timeout(2000)
def report_error(self, error): hildon.hildon_banner_show_information(self.get_toplevel(), '', error)
def _parse_mms(self, filename, container): """ parse mms and push each part to the container fetches the mms if its not downloaded """ hildon.hildon_gtk_window_set_progress_indicator(self.window, 1) self.force_ui_update() if not self.cont.is_fetched_push_by_transid(filename): msgstr = gettext.ldgettext('hildon-application-manager', "ai_nw_downloading") % "MMS" banner = hildon.hildon_banner_show_information(self.window, "", msgstr) self.force_ui_update() self.cont.get_mms_from_push(filename) self.cont.mark_mms_read(filename) headerlist = self.cont.get_mms_headers(filename) topbox = gtk.HBox() if self._direction == fMMSController.MSG_DIRECTION_IN: label = gtk.Label('<span foreground="#666666">%s</span>' \ % gettext.ldgettext('modest', 'mail_va_from')) sender = headerlist.get('From', "0").replace("/TYPE=PLMN", "") else: label = gtk.Label('<span foreground="#666666">%s</span>' \ % gettext.ldgettext('rtcom-messaging-ui', 'messaging_fi_new_sms_to')) sender = headerlist['To'].replace("/TYPE=PLMN", "") label.set_use_markup(True) label.set_alignment(0, 0.5) senderuid = self.ch.get_uid_from_number(sender) sendername = self.ch.get_displayname_from_uid(senderuid) if sendername != None: sender = sendername self.window.set_title("MMS - " + str(sender)) namelabel = gtk.Label(sender) namelabel.set_alignment(0, 0.5) mtime = headerlist['Time'] mtime = self.cont.convert_timeformat(mtime, "%Y-%m-%d | %H:%M") timestring = '<span foreground="#666666">' + mtime + "</span>" timelabel = gtk.Label(timestring) timelabel.set_use_markup(True) timelabel.set_alignment(1, 0.5) topbox.pack_start(label, False, False, 0) topbox.pack_start(namelabel, True, True, 10) topbox.pack_end(timelabel, False, False, 0) container.pack_start(topbox, False, False, 5) sep = gtk.HSeparator() container.pack_start(sep, False, False, 0) # TODO: add correct padding to first item in next container self.textview = hildon.TextView() self.textview.set_property("name", "hildon-readonly-textview") self.textview.set_editable(False) self.textview.set_cursor_visible(False) self.textview.set_wrap_mode(gtk.WRAP_WORD) self.textview.set_justification(gtk.JUSTIFY_LEFT) textbuffer = gtk.TextBuffer() direction = self.cont.get_direction_mms(filename) if direction == fMMSController.MSG_DIRECTION_OUT: path = self._outdir + filename else: path = self.cont.get_filepath_for_mms_transid(filename) filelist = self.cont.get_mms_attachments(filename) log.info("filelist: %s", filelist) self.attachment = None for fname in filelist: (name, ext) = os.path.splitext(fname) fnpath = os.path.join(path, fname) isText = False isImage = False try: filetype = gnomevfs.get_mime_type(fnpath) log.info("filetype: %s", filetype) if filetype != None: if filetype.startswith("image") or filetype.startswith("sketch"): isImage = True if filetype.startswith("text") and not "x-vcard" in filetype: isText = True except Exception, e: filetype = None log.exception("%s %s", type(e), e) if isImage or ext == ".wbmp": """ insert the image in an eventbox so we can get signals """ ebox = gtk.EventBox() img = gtk.Image() #img.set_from_file(path + "/" + fname) fullpath = "%s/%s" % (path, fname) im = Image.open(fnpath) im.thumbnail((384, 384), Image.NEAREST) pixbuf = self.cont.image2pixbuf(im) img = gtk.Image() img.set_from_pixbuf(pixbuf) ebox.add(img) menu = self.mms_img_menu(fullpath) ebox.tap_and_hold_setup(menu) container.add(ebox) self.attachment = fnpath elif isText or ext.startswith(".txt"): try: fp = codecs.open(path + "/" + fname, 'r', 'utf-8') contents = fp.read() except: fp = codecs.open(path + "/" + fname, 'r', 'latin-1') contents = fp.read() fp.close() textbuffer.insert(textbuffer.get_end_iter(), contents) elif name != "message" and name != "headers" and not ext.startswith(".smil") and filetype != "application/smil": self.attachment = fnpath attachButton = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_HORIZONTAL, fname) attachButton.connect('clicked', self.mms_img_clicked, fnpath) container.pack_end(attachButton, False, False, 0)
def notify_connection(self, connected): if (connected == True): hildon.hildon_banner_show_information(self.window, None, "Nätverksanslutning återupprättad") elif (connected == False): hildon.hildon_banner_show_information(self.window, None, "Inget nätverk hittades")