Example #1
0
    def __init__(self, controller):
        super(MainWindow, self).__init__()
        self.controller = controller

        # TODO: replace this with a signal
        self.controller.coherence_started_cb = self._coherence_started

        self.set_title("Mirabeau")
        self.set_app_menu(self._create_menu())
        self.connect('delete-event', self._exit_cb)

        self.devices_view = DevicesView()
        self.devices_view.connect('row-activated', self._row_activated_cb)

        area = hildon.PannableArea()
        area.add(self.devices_view)
        area.show_all()
        self.add(area)

        self.status_changed_cb(CONNECTION_STATUS_DISCONNECTED, "")

        self.controller.load_config()
        self.controller.start_coherence()

        if self.controller.first_run:
            # first run, a wizard might fit better here, probably.
            text = _("""\
Welcome to Mirabeau! It is currently bound to your local network,
if you want to browse remote MediaServers please edit the Settings.
A valid GTalk/Jabber account is needed.""")
            note = hildon.hildon_note_new_information(self, text)
            response = note.run()
            note.destroy()
Example #2
0
    def __init__(self, controller):
        super(MainWindow, self).__init__()
        self.controller = controller

        # TODO: replace this with a signal
        self.controller.coherence_started_cb = self._coherence_started

        self.set_title("Mirabeau")
        self.set_app_menu(self._create_menu())
        self.connect('delete-event', self._exit_cb)

        self.devices_view = DevicesView()
        self.devices_view.connect('row-activated', self._row_activated_cb)

        area = hildon.PannableArea()
        area.add(self.devices_view)
        area.show_all()
        self.add(area)

        self.status_changed_cb(CONNECTION_STATUS_DISCONNECTED, "")

        self.controller.load_config()
        self.controller.start_coherence()

        if self.controller.first_run:
            # first run, a wizard might fit better here, probably.
            text = _("""\
Welcome to Mirabeau! It is currently bound to your local network,
if you want to browse remote MediaServers please edit the Settings.
A valid GTalk/Jabber account is needed.""")
            note = hildon.hildon_note_new_information(self, text)
            response = note.run()
            note.destroy()
Example #3
0
    def save(self, button):
        """Saves Nagios server settings to gconf
        """
        gconf.client_get_default().set_string('/apps/maegios/url',\
        self.entryUrl.get_text())
        gconf.client_get_default().set_string('/apps/maegios/username',\
        base64.b64encode(self.entryUsername.get_text()))
        gconf.client_get_default().set_string('/apps/maegios/password',\
        base64.b64encode(self.entryPassword.get_text()))
        
        previous_is_configured_value = int(gconf.client_get_default().get_string('/apps/maegios/is_configured'))

        gconf.client_get_default().set_string('/apps/maegios/is_configured', '1')

        # notify desktop widget that configuration has been changed
        self.toplevel.reload_widget()

        # refresh treeview
        self.toplevel.refresh()
        
        # display pannable area if we haven't yet
        if previous_is_configured_value == 0:
            if len(self.toplevel.window.get_children()) > 0:
                self.toplevel.window.remove(self.toplevel.window.get_children()[0])  
            self.toplevel.window.add(self.toplevel.parea)
            self.toplevel.window.show_all()

        button.get_toplevel().get_stack().pop(1)

        # configuration note, todo: localization
        note = hildon.hildon_note_new_information(button.get_toplevel(), \
           _(u"Your Nagios configuration has been saved, and will now be used \
to pull information from your Nagios instance."))
        response = gtk.Dialog.run(note)
	def stop_backend(self):
		"""kills backend"""
		(exitstatus, outtext) = commands.getstatusoutput("""/etc/init.d/switch_backend stop""")
		if exitstatus <> 0:
			print "DEBUG: backend start exit code " + str(status) + ", output: \n"
			note = hildon.hildon_note_new_information(self.mainwindow, 'switchProfByMeeting failed to start')
			response = gtk.Dialog.run(note)
			note.destroy()
			return
		self.backend_started = False
Example #5
0
def update_google_profile(username, password, id, win):
    if (username == "" or password == ""):
        note = hildon.hildon_note_new_information(win, \
          "You must provide both the Google username "\
          "and password!")
        note.connect("delete-event", lambda w, d: w.destroy())
        gtk.Dialog.run(note)
        return False

    google_accounts.update_account(username, password, id)
    return True
Example #6
0
def store_google_profile(username, password, win):
    if (username == "" or password == ""):
        note = hildon.hildon_note_new_information(win, \
          "You must provide both the Google username "\
          "and password!")
        note.connect("delete-event", lambda w, d: w.destroy())
        gtk.Dialog.run(note)
        return False

    if (check_username_existence(username)):
        note = hildon.hildon_note_new_information(win, "The username"\
          " \"%s\" is already defined in Erminig." \
          " It will not be added a second time." \
          % (username))
        note.connect("delete-event", lambda w, d: w.destroy())
        gtk.Dialog.run(note)
        return False

    google_accounts.register_new_account(username, password)
    return True
Example #7
0
def store_google_profile(username, password, win):
	if (username == "" or password == ""):
		note = hildon.hildon_note_new_information(win, \
				"You must provide both the Google username "\
				"and password!")
		note.connect("delete-event", lambda w,d: w.destroy())
		gtk.Dialog.run(note)
		return False

	if (check_username_existence(username)):
		note = hildon.hildon_note_new_information(win, "The username"\
				" \"%s\" is already defined in Erminig." \
				" It will not be added a second time." \
				% (username))
		note.connect("delete-event", lambda w,d: w.destroy())
		gtk.Dialog.run(note)
		return False

	google_accounts.register_new_account(username, password)
	return True
Example #8
0
def update_google_profile(username, password, id, win):
	if (username == "" or password == ""):
		note = hildon.hildon_note_new_information(win, \
				"You must provide both the Google username "\
				"and password!")
		note.connect("delete-event", lambda w,d: w.destroy())
		gtk.Dialog.run(note)
		return False

	google_accounts.update_account(username, password, id)
	return True
Example #9
0
    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()
Example #10
0
 def _send_message(self, widget):
     buf = self.text_view.get_buffer()
     text = buf.get_text(buf.get_iter_at_offset(0), buf.get_iter_at_offset(-1))
     client = self.coherence.mirabeau.tube_publisher
     if self.contact_handles:
         for handle_id in self.contact_handles:
             client.send_message(handle_id, text)
         # TODO: display delivery notification
         self.destroy()
     else:
         text = _("Please select at least one contact")
         note = hildon.hildon_note_new_information(self, text)
         response = note.run()
         note.destroy()
Example #11
0
 def _send_message(self, widget):
     buf = self.text_view.get_buffer()
     text = buf.get_text(buf.get_iter_at_offset(0),
                         buf.get_iter_at_offset(-1))
     client = self.coherence.mirabeau.tube_publisher
     if self.contact_handles:
         for handle_id in self.contact_handles:
             client.send_message(handle_id, text)
         # TODO: display delivery notification
         self.destroy()
     else:
         text = _("Please select at least one contact")
         note = hildon.hildon_note_new_information(self, text)
         response = note.run()
         note.destroy()
Example #12
0
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)
Example #13
0
    def save(self, button):
        """Saves refresh settings to gconf
        """
        gconf.client_get_default().set_string('/apps/maegios/interval', self.entryInterval.get_text())
        gconf.client_get_default().set_string('/apps/maegios/attempts', self.entryAttempts.get_text())

        # notify desktop widget that configuration has been changed
        self.toplevel.reload_widget()

        # refresh treeview
        self.toplevel.refresh()

        button.get_toplevel().get_stack().pop(1)

        # configuration note
        note = hildon.hildon_note_new_information(button.get_toplevel(), \
           _(u"Your refresh settings have been saved, and will now be used \
to pull information from your Nagios instance."))
        response = gtk.Dialog.run(note)
Example #14
0
    def save(self, button):
        """Saves user notification settings to gconf
        """
        gconf.client_get_default().set_string('/apps/maegios/notify_banner', \
            str(int(self.checkBanner.get_active())))
        gconf.client_get_default().set_string('/apps/maegios/notify_sound', \
            str(int(self.checkSound.get_active())))
        gconf.client_get_default().set_string('/apps/maegios/notify_vibration', \
            str(int(self.checkVibration.get_active())))
        gconf.client_get_default().set_string('/apps/maegios/notify_light', \
            str(int(self.checkLight.get_active())))

        # notify desktop widget that configuration has been changed
        self.toplevel.reload_widget()

        # refresh treeview
        self.toplevel.refresh()

        button.get_toplevel().get_stack().pop(1)

        # configuration note
        note = hildon.hildon_note_new_information(button.get_toplevel(), \
           _(u"Your notification settings have been changed."))
        response = gtk.Dialog.run(note)
Example #15
0
 def note(self, text):
     banner = hildon.hildon_note_new_information(self.window, str(text))
     banner.connect('response', lambda s, ev: s.destroy())
     banner.show()
     return banner
Example #16
0
    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()
Example #17
0
    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)

                # Determine the topmost visible window and attach the
                # message to that window to avoid Maemo Bug 10030
                stack = hildon.WindowStack.get_default()
                visible_windows = stack.get_windows()
                if visible_windows:
                    parent_window = visible_windows[0]
                else:
                    parent_window = self.main_window

                dlg = hildon.hildon_note_new_information(parent_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)
                    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
                    else:
                        widget = self.main_window
                    notification = NotificationWindow(message, title, important=False, widget=widget)
                    notification.show_timeout()
Example #18
0
  def show_note_information(self, mess):
     parent = hildon.WindowStack.get_default().peek()
     note = hildon.hildon_note_new_information(parent,mess)                 
 
     response = gtk.Dialog.run(note)
Example #19
0
def display_add_cal_error(win):
	note = hildon.hildon_note_new_information(win, \
		"Could not create new local calendar. Does it already exist?")
	note.connect("delete-event", lambda w,d: w.destroy())
	gtk.Dialog.run(note)
Example #20
0
def show_note_information(mess):
    parent = hildon.WindowStack.get_default().peek()
    note = hildon.hildon_note_new_information(parent, mess)

    response = gtk.Dialog.run(note)
Example #21
0
def display_google_auth_error(win):
	note = hildon.hildon_note_new_information(win, \
		"Could not connect to your Google account. Check username "\
		"and password. (And do you have Internet connectivity?)")
	note.connect("delete-event", lambda w,d: w.destroy())
	gtk.Dialog.run(note)