예제 #1
0
def main():
    notebook = gtk.Notebook()
    label_1 = gtk.Label("Page 1")
    label_2 = gtk.Label("Page 2")

    entry_3 = hildon.Entry(gtk.HILDON_SIZE_AUTO)
    entry_3.set_placeholder("Write something to continue")

    label_4 = gtk.Label("Page 4")

    notebook.append_page(label_1, None)
    notebook.append_page(label_2, None)
    notebook.append_page(entry_3, None)
    notebook.append_page(label_4, None)

    dialog = hildon.WizardDialog(None, "Wizard", notebook)

    def on_page_switch(n, p, num, d):
        print >> sys.stderr, "Page %d" % num
        return True

    def some_page_func(n, current, userdata):
        if current == 2:
            entry = n.get_nth_page(current)
            return len(entry.get_text()) != 0
        return True

    notebook.connect("switch-page", on_page_switch, dialog)

    dialog.set_forward_page_func(some_page_func)

    dialog.show_all()
    dialog.run()
예제 #2
0
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])

    save_button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH |
                                gtk.HILDON_SIZE_FINGER_HEIGHT,
                                hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
    save_button.set_text("Save new settings", "")
    save_button.connect("clicked", save_settings, window, win, entry)

    uname_box = gtk.HBox(False, 0)
    uname_box.pack_start(label, False, False, 20)
    uname_box.pack_start(entry, True, True, 10)

    save_box = gtk.HBox(False, 0)
    save_box.pack_start(save_button, True, False, 0)

    vbox = gtk.VBox(False, 0)
    vbox.pack_start(uname_box, False, False, 20)
    vbox.pack_start(save_box, False, False, 0)

    window.add(vbox)
    window.show_all()
예제 #3
0
def new_remote_source(widget, hint):
	global current_google_account_selected
	global local_selector

	dialog = gtk.Dialog()
	dialog.set_title("New Google Calendar")

	dialog.connect("delete-event", lambda w,d: w.destroy())

	label = gtk.Label("Please enter the name of a new Google calendar")
	new_cal_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
	new_cal_entry.set_placeholder("Calendar name")
	hint = local_selector.get_current_text()
	if not hint:
		hint = ""
	new_cal_entry.set_text(hint)
	new_cal_entry.select_region(0, len(hint))

	dialog.vbox.add(label)
	dialog.vbox.add(new_cal_entry)

	dialog.add_button("Add", gtk.RESPONSE_OK)
	dialog.show_all()
	resp = dialog.run()

	if resp == gtk.RESPONSE_OK:
		cal_name = new_cal_entry.get_text().strip()
		if not cal_name == "":
			cal_id = google_api.create_new_calendar(cal_name)
			update_remote_data_source(consts.SYNC_TYPE_CAL,\
					current_google_account_selected)
			select_remote_source(cal_id)
		
	dialog.destroy()
예제 #4
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()
예제 #5
0
    def __init__(self):

        Widget.__init__(self)

        if (platforms.MAEMO5):
            self.__input = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        else:
            self.__input = gtk.Entry()
예제 #6
0
    def _show_tool_romans(self, caller, data=None):
        dialog = gtk.Dialog("Roman Numbers", self.window,
                            gtk.DIALOG_DESTROY_WITH_PARENT, ())
        #dialog.set_size_request(800, 480)

        source = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        source.set_property("hildon-input-mode",
                            gtk.HILDON_GTK_INPUT_MODE_NUMERIC)
        dialog.vbox.pack_start(hildon.Caption(None, "Arabic", source, None, 0))
        destination = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        dialog.vbox.pack_start(
            hildon.Caption(None, "Roman", destination, None, 0))

        inhibit = [False]

        def to_roman(widget):
            if inhibit[0] == True:
                return
            try:
                text = HildonToolsDialog._int_to_roman(int(source.get_text()))
            except ValueError:
                text = ''
            inhibit[0] = True
            destination.set_text(text)
            inhibit[0] = False

        def to_arabic(widget):
            if inhibit[0] == True:
                return
            try:
                text = str(
                    HildonToolsDialog._roman_to_int(destination.get_text()))
            except ValueError:
                text = ''
            inhibit[0] = True
            source.set_text(text)
            inhibit[0] = False

        source.connect('changed', to_roman)
        destination.connect('changed', to_arabic)

        dialog.show_all()
        dialog.run()
        dialog.hide()
예제 #7
0
 def _on_show_search_place(self, widget):
     dialog = gtk.Dialog("Search Place", self.window,
                         gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     search = hildon.Entry(gtk.HILDON_SIZE_AUTO)
     search.set_text(self.last_searched_text)
     dialog.vbox.pack_start(search)
     dialog.show_all()
     result = dialog.run()
     dialog.hide()
     search_text = search.get_text().strip()
     self.last_searched_text = search_text
     if result != gtk.RESPONSE_ACCEPT or search_text == '':
         return
     try:
         results = self.core.search_place(search_text)
     except Exception, e:
         self.show_error(e)
         return
예제 #8
0
    def init_center_view(self, centerview):

        subjectLbl = gtk.Label("Subject")
        centerview.pack_start(self.justifyLeft(subjectLbl), False)
        self._subject = hildon.Entry(gtk.HILDON_SIZE_FULLSCREEN_WIDTH)
        self._subject.set_placeholder("enter a subject")
        self._subject.set_text(str(self.type) + " : " + str(self.value))
        centerview.pack_start(self._subject, False)
        contentLbl = gtk.Label("Content")
        centerview.pack_start(self.justifyLeft(contentLbl), False)
        self._body = hildon.TextView()
        self._body.set_placeholder("enter the message here")
        self._body.set_wrap_mode(gtk.WRAP_WORD)
        stacktrace = traceback.format_exception(self.type, self.value,
                                                self.traceback)
        buf = self._body.get_buffer()
        for line in stacktrace:
            end = buf.get_end_iter()
            buf.insert(end, line, len(line))
        centerview.add(self._body)
        return MaegenStackableWindow.init_center_view(self, centerview)
예제 #9
0
파일: roster.py 프로젝트: fruch/coherence
    def __init__(self, coherence, room_name, conf_server):
        super(InviteFriendsWindow, self).__init__()
        self.coherence = coherence
        self.set_title(_("Spread the word!"))
        self.contact_handles = []
        vbox = gtk.VBox()

        # To
        to_box = gtk.HBox()
        to_button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO_WIDTH
                                     | gtk.HILDON_SIZE_FINGER_HEIGHT)
        to_button.set_label(_("To:"))
        to_button.connect("clicked", self._select_contacts)
        to_box.pack_start(to_button, expand=False)
        self.to_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        self.to_entry.set_sensitive(False)
        to_box.pack_start(self.to_entry)
        vbox.pack_start(to_box, expand=False)

        # Message
        template = _("""\
Hi! Join me in the tubes of the interwebs! It is all explained there:
%(howto_url)s. I am in the %(room_name)s of the server %(conf_server)s.
        """)
        howto_url = "http://coherence.beebits.net/wiki/MirabeauHowTo"
        self.text_view = hildon.TextView()
        buf = gtk.TextBuffer()
        buf.set_text(template % locals())
        self.text_view.set_wrap_mode(gtk.WRAP_WORD)
        self.text_view.set_buffer(buf)
        vbox.pack_start(self.text_view)

        # Send
        send_button = hildon.GtkButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
        send_button.set_label(_("Send"))
        send_button.connect("clicked", self._send_message)
        vbox.pack_start(send_button, expand=False)

        self.add(vbox)
        vbox.show_all()
예제 #10
0
def new_local_source(widget, hint):
	global remote_selector

	dialog = gtk.Dialog()
	dialog.set_title("New Local Calendar")

	dialog.connect("delete-event", lambda w,d: w.destroy())

	label = gtk.Label("Please enter the name of a new local calendar")
	new_cal_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
	new_cal_entry.set_placeholder("Calendar name")
	hint = remote_selector.get_current_text()
	if not hint:
		hint = ""
	new_cal_entry.set_text(hint)
	new_cal_entry.select_region(0, len(hint))

	dialog.vbox.add(label)
	dialog.vbox.add(new_cal_entry)

	dialog.add_button("Add", gtk.RESPONSE_OK)
	dialog.show_all()
	resp = dialog.run()

	if resp == gtk.RESPONSE_OK:
		cal_name = new_cal_entry.get_text().strip()
		if not cal_name == "":
			last_id = fremantle.add_local_calendar(cal_name)
			if last_id == -1:
				display_add_cal_error(dialog)
			else:
				update_local_data_source(\
						consts.DATASOURCE_BUILTIN)
				select_local_source(last_id)
		
	dialog.destroy()
예제 #11
0
파일: common.py 프로젝트: xerxes2/gpodder
    def show_login_dialog(self,
                          title,
                          message,
                          username=None,
                          password=None,
                          username_prompt=_('Username'),
                          register_callback=None):
        """ An authentication dialog based on
                http://ardoris.wordpress.com/2008/07/05/pygtk-text-entry-dialog/ """

        if gpodder.ui.fremantle:
            dialog = gtk.Dialog(
                title, self.main_window,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                (str(_('Login')), gtk.RESPONSE_OK))
            label = gtk.Label(message)
            label.set_alignment(0., .5)
            label.set_padding(0, 5)
            dialog.vbox.add(label)
        else:
            dialog = gtk.MessageDialog(
                self.main_window,
                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL)
            dialog.add_button(_('Login'), gtk.RESPONSE_OK)
            dialog.set_image(
                gtk.image_new_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION,
                                         gtk.ICON_SIZE_DIALOG))
            dialog.set_title(_('Authentication required'))
            dialog.set_markup('<span weight="bold" size="larger">' + title +
                              '</span>')
            dialog.format_secondary_markup(message)
        dialog.set_default_response(gtk.RESPONSE_OK)

        if register_callback is not None:
            dialog.add_button(_('New user'), gtk.RESPONSE_HELP)

        if gpodder.ui.fremantle:
            import hildon
            username_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
            password_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        else:
            username_entry = gtk.Entry()
            password_entry = gtk.Entry()

        # Disable input capitalization for the login fields
        if gpodder.ui.fremantle:
            username_entry.set_property('hildon-input-mode', \
                        gtk.HILDON_GTK_INPUT_MODE_FULL)
            password_entry.set_property('hildon-input-mode', \
                        gtk.HILDON_GTK_INPUT_MODE_FULL)
        elif gpodder.ui.diablo:
            username_entry.set_property('hildon-input-mode', \
                        'HILDON_GTK_INPUT_MODE_FULL')
            password_entry.set_property('hildon-input-mode', \
                        'HILDON_GTK_INPUT_MODE_FULL')

        username_entry.connect('activate',
                               lambda w: password_entry.grab_focus())
        password_entry.set_visibility(False)
        password_entry.set_activates_default(True)

        if username is not None:
            username_entry.set_text(username)
        if password is not None:
            password_entry.set_text(password)

        table = gtk.Table(2, 2)
        table.set_row_spacings(6)
        table.set_col_spacings(6)

        username_label = gtk.Label()
        username_label.set_markup('<b>' + username_prompt + ':</b>')
        username_label.set_alignment(0.0, 0.5)
        table.attach(username_label, 0, 1, 0, 1, gtk.FILL, 0)
        table.attach(username_entry, 1, 2, 0, 1)

        password_label = gtk.Label()
        password_label.set_markup('<b>' + _('Password') + ':</b>')
        password_label.set_alignment(0.0, 0.5)
        table.attach(password_label, 0, 1, 1, 2, gtk.FILL, 0)
        table.attach(password_entry, 1, 2, 1, 2)

        dialog.vbox.pack_end(table, True, True, 0)
        dialog.show_all()
        response = dialog.run()

        while response == gtk.RESPONSE_HELP:
            register_callback()
            response = dialog.run()

        password_entry.set_visibility(True)
        username = username_entry.get_text()
        password = password_entry.get_text()
        success = (response == gtk.RESPONSE_OK)

        dialog.destroy()

        return (success, (username, password))
예제 #12
0
파일: common.py 프로젝트: xerxes2/gpodder
    def show_text_edit_dialog(self, title, prompt, text=None, empty=False, \
            is_url=False, affirmative_text=gtk.STOCK_OK):
        dialog = gtk.Dialog(title, self.get_dialog_parent(), \
            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

        if not gpodder.ui.fremantle:
            dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)

        dialog.add_button(affirmative_text, gtk.RESPONSE_OK)

        dialog.set_has_separator(False)
        if gpodder.ui.desktop:
            dialog.set_default_size(300, -1)
        else:
            dialog.set_default_size(650, -1)
        dialog.set_default_response(gtk.RESPONSE_OK)

        if gpodder.ui.fremantle:
            import hildon
            text_entry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
            if is_url:
                # Disable word capitalization and word completion when
                # requesting an URL to be entered (see Maemo bug 5184)
                text_entry.set_property('hildon-input-mode', \
                        gtk.HILDON_GTK_INPUT_MODE_FULL)
        elif gpodder.ui.diablo:
            text_entry = gtk.Entry()
            text_entry.set_property('hildon-input-mode', \
                    'HILDON_GTK_INPUT_MODE_FULL')
        else:
            text_entry = gtk.Entry()
        text_entry.set_activates_default(True)
        if text is not None:
            text_entry.set_text(text)
            text_entry.select_region(0, -1)

        if not empty:

            def on_text_changed(editable):
                can_confirm = (editable.get_text() != '')
                dialog.set_response_sensitive(gtk.RESPONSE_OK, can_confirm)

            text_entry.connect('changed', on_text_changed)
            if text is None:
                dialog.set_response_sensitive(gtk.RESPONSE_OK, False)

        hbox = gtk.HBox()
        if not gpodder.ui.fremantle:
            hbox.set_border_width(10)
        hbox.set_spacing(10)
        hbox.pack_start(gtk.Label(prompt), False, False)
        hbox.pack_start(text_entry, True, True)
        dialog.vbox.pack_start(hbox, True, True)

        dialog.show_all()
        response = dialog.run()
        result = text_entry.get_text()
        dialog.destroy()

        if response == gtk.RESPONSE_OK:
            return result
        else:
            return None
예제 #13
0
    def __init__(self,
                 spawner=None,
                 tonumber=None,
                 withfile=None,
                 subject=None,
                 message=None,
                 forward=None):
        hildon.Program.__init__(self)
        program = hildon.Program.get_instance()

        self.ch = ContactH.ContactHandler()
        self.cont = fMMSController.fMMS_controllerGTK()
        self.config = self.cont.config
        self.subject = subject
        self.osso_c = osso.Context("fMMS", "1.0", False)

        self.window = hildon.StackableWindow()
        self.window.set_title(
            gettext.ldgettext('rtcom-messaging-ui', "messaging_ti_new_mms"))
        if subject:
            try:
                self.window.set_title(subject)
            except:
                pass
        program.add_window(self.window)

        self.window.connect("delete_event", self.quit)
        self.attachmentFile = ""

        draftfile = False
        # got spawner and not a forward and not a reply
        if spawner != None and forward == None and tonumber == None:
            self.spawner = spawner
            (tonumber, message, tmpfn) = self.cont.get_draft()
            if tmpfn != "" and tmpfn != "None" and os.path.isfile(tmpfn):
                withfile = tmpfn
                self.attachmentFile = tmpfn
                draftfile = True
        # forwarding/replying message
        elif spawner != None and (forward or tonumber != None):
            self.spawner = spawner
        else:
            self.spawner = self.window
        allBox = gtk.VBox()
        """ Begin top section """
        topHBox1 = gtk.HBox()

        bTo = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_HORIZONTAL, \
               gettext.ldgettext('rtcom-messaging-ui', "messaging_fi_new_sms_to"))
        bTo.connect('clicked', self.open_contacts_dialog)
        bTo.set_size_request(128, gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.eNumber = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
        if tonumber != None:
            self.eNumber.set_text(tonumber)

        self.bSend = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT,
                                   hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        self.bSend.connect('clicked', self.send_mms_clicked)
        icon_theme = gtk.icon_theme_get_default()
        sendPixbuf = icon_theme.load_icon("email_message_send", 48, 0)
        sendImage = gtk.Image()
        sendImage.set_from_pixbuf(sendPixbuf)
        #sendImage.set_alignment(1, 0.5)
        self.bSend.set_image(sendImage)
        self.bSend.set_size_request(128, gtk.HILDON_SIZE_FINGER_HEIGHT)

        topHBox1.pack_start(bTo, False, True, 0)
        topHBox1.pack_start(self.eNumber, True, True, 5)
        topHBox1.pack_start(self.bSend, False, True, 0)
        """ Begin midsection """
        pan = hildon.PannableArea()
        pan.set_property("mov-mode", hildon.MOVEMENT_MODE_BOTH)
        midBox = gtk.VBox()
        centerBox = gtk.HBox()
        self.imageBox = gtk.EventBox()
        self.imageBox.set_size_request(400, 200)

        self.imageBoxContent = gtk.Fixed()
        border = gtk.Image()
        border.set_from_file("/opt/fmms/dotted_border.png")
        addimglabel = gtk.Label(
            gettext.ldgettext('modest', "mcen_me_editor_attach_inlineimage"))
        addimglabel.set_justify(gtk.JUSTIFY_CENTER)
        addimglabel.set_size_request(300, 50)

        self.imageBoxContent.put(border, 0, 0)
        self.imageBoxContent.put(addimglabel, 50, 100)

        self.imageBox.add(self.imageBoxContent)
        self.imageBox.connect('button-press-event', self.open_file_dialog)

        centerBox.pack_start(self.imageBox, True, False, 0)

        self.tvMessage = hildon.TextView()
        self.tvMessage.set_property("name", "hildon-fullscreen-textview")
        self.tvMessage.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self.tvMessage.set_justification(gtk.JUSTIFY_LEFT)
        if message != None and message != '':
            tb = gtk.TextBuffer()
            tb.set_text(message)
            self.tvMessage.set_buffer(tb)

        midBox.pack_start(centerBox)
        midBox.pack_start(self.tvMessage)

        pan.add_with_viewport(midBox)

        # Copy the file to our tempdir in case sharing service removes it
        if withfile and not draftfile:
            filename = os.path.basename(withfile)
            dst = "%s/%s" % (self.config.get_imgdir(), filename)
            log.info("Copying file to: %s" % dst)
            copy(withfile, dst)
            self.attachmentFile = dst
            self.fromSharingService = True
            self.fromSharingFile = dst
        if withfile or draftfile:
            try:
                self.set_thumbnail(self.attachmentFile)
            except:
                log.exception("wtf: %s" % self.attachmentFile)
        """ Show it all! """
        allBox.pack_start(topHBox1, False, False)
        allBox.pack_start(pan, True, True)
        #allBox.pack_start(self.botHBox, False, False)

        align = gtk.Alignment(1, 1, 1, 1)
        align.set_padding(2, 2, 10, 10)
        align.add(allBox)

        self.window.add(align)
        self.window.show_all()

        self.menu = self.cont.create_menu(self.window)
        self.window.set_app_menu(self.menu)

        self.add_window(self.window)

        # so appearently throwing an exception here
        # makes osso-abook always load the contacts...
        self.this_doesnt_exist()
예제 #14
0
    def _on_show_search(self, widget, data):

        name = hildon.Entry(gtk.HILDON_SIZE_AUTO_WIDTH
                            | gtk.HILDON_SIZE_FINGER_HEIGHT)
        name.set_placeholder("search for name...")
        name_hbox = hildon.Caption(None, "Name", name, None,
                                   hildon.CAPTION_OPTIONAL)

        sel_dist_type = hildon.TouchSelector(text=True)
        sel_dist_type.append_text('anywhere')
        sel_dist_type.append_text('around my position')
        sel_dist_type.append_text('around the current map center')
        pick_dist_type = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_dist_type.set_selector(sel_dist_type)
        pick_dist_type.set_title("Search")
        sel_dist_type.select_iter(0,
                                  sel_dist_type.get_model(0).get_iter(1),
                                  False)

        list_dist_radius = (1, 5, 10, 20, 50, 100, 200)
        sel_dist_radius = hildon.TouchSelector(text=True)
        for x in list_dist_radius:
            sel_dist_radius.append_text('%d km' % x)
        pick_dist_radius = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_dist_radius.set_selector(sel_dist_radius)
        pick_dist_radius.set_title("Radius")
        pick_dist_type.connect(
            'value-changed', lambda caller: pick_dist_radius.set_sensitive(
                sel_dist_type.get_selected_rows(0)[0][0] != 0))
        sel_dist_radius.select_iter(0,
                                    sel_dist_radius.get_model(0).get_iter(1),
                                    False)

        sel_size = hildon.TouchSelector(text=True)
        sel_size.append_text('micro')
        sel_size.append_text('small')
        sel_size.append_text('regular')
        sel_size.append_text('huge')
        sel_size.append_text('other')
        sel_size.set_column_selection_mode(
            hildon.TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)
        pick_size = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_size.set_selector(sel_size)
        pick_size.set_title("Select Size(s)")
        for i in xrange(5):
            sel_size.select_iter(0, sel_size.get_model(0).get_iter(i), False)

        sel_type = hildon.TouchSelector(text=True)
        sel_type.append_text('traditional')
        sel_type.append_text('multi-stage')
        sel_type.append_text('virtual')
        sel_type.append_text('earth')
        sel_type.append_text('event')
        sel_type.append_text('mystery')
        sel_type.append_text('all')
        sel_type.set_column_selection_mode(
            hildon.TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)
        pick_type = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_type.set_selector(sel_type)
        pick_type.set_title("Select Type(s)")
        sel_type.unselect_all(0)
        sel_type.select_iter(0, sel_type.get_model(0).get_iter(6), False)

        sel_status = hildon.TouchSelector(text=True)
        sel_status.append_text('any')
        sel_status.append_text("Geocaches I haven't found")
        sel_status.append_text("Geocaches I have found")
        sel_status.append_text("Marked Geocaches")
        sel_status.append_text("Marked Geocaches I haven't found")
        pick_status = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_status.set_selector(sel_status)
        pick_status.set_title("Select Status")

        sel_status.unselect_all(0)
        sel_status.select_iter(0, sel_status.get_model(0).get_iter(0), False)

        sel_diff = hildon.TouchSelector(text=True)
        sel_diff.append_text('1..2.5')
        sel_diff.append_text('3..4')
        sel_diff.append_text('4.5..5')
        sel_diff.set_column_selection_mode(
            hildon.TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)
        pick_diff = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_diff.set_selector(sel_diff)
        pick_diff.set_title("Select Difficulty")
        for i in xrange(3):
            sel_diff.select_iter(0, sel_diff.get_model(0).get_iter(i), False)

        sel_terr = hildon.TouchSelector(text=True)
        sel_terr.append_text('1..2.5')
        sel_terr.append_text('3..4')
        sel_terr.append_text('4.5..5')
        sel_terr.set_column_selection_mode(
            hildon.TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)
        pick_terr = hildon.PickerButton(
            gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
            hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
        pick_terr.set_selector(sel_terr)
        pick_terr.set_title("Select Terrain")
        for i in xrange(3):
            sel_terr.select_iter(0, sel_terr.get_model(0).get_iter(i), False)

        RESPONSE_SHOW_LIST, RESPONSE_RESET, RESPONSE_LAST_RESULTS = range(3)
        dialog = gtk.Dialog("Search", self.window,
                            gtk.DIALOG_DESTROY_WITH_PARENT,
                            ("OK", RESPONSE_SHOW_LIST))
        dialog.add_button("Filter Map", gtk.RESPONSE_ACCEPT)
        if self.map_filter_active:
            dialog.add_button("Reset Filter", RESPONSE_RESET)
        if self.old_search_window != None:
            dialog.add_button("Last Results", RESPONSE_LAST_RESULTS)
        dialog.set_size_request(800, 800)
        pan = hildon.PannableArea()
        options = gtk.VBox()
        pan.add_with_viewport(options)
        dialog.vbox.pack_start(pan)

        options.pack_start(gtk.Label("Search Geocaches"))
        options.pack_start(name_hbox)
        options.pack_start(pick_dist_type)
        options.pack_start(pick_dist_radius)
        options.pack_start(pick_type)
        options.pack_start(pick_status)

        options.pack_start(gtk.Label("Details..."))
        w = gtk.Label(
            "If you select something here, only geocaches for which details were downloaded will be shown in the result."
        )
        w.set_line_wrap(True)
        w.set_alignment(0, 0.5)
        options.pack_start(w)

        options.pack_start(pick_size)
        options.pack_start(pick_diff)
        options.pack_start(pick_terr)

        while True:
            dialog.show_all()
            response = dialog.run()
            dialog.hide()

            if response == RESPONSE_RESET:
                self.core.reset_filter()
                self.map_filter_active = False
                self.show_success("Showing all geocaches.")
                return
            elif response == RESPONSE_LAST_RESULTS:
                if self.old_search_window == None:
                    return
                hildon.WindowStack.get_default().push_1(self.old_search_window)

                return

            name_search = name.get_text().strip().lower()

            sizes = [x + 1 for x, in sel_size.get_selected_rows(0)]
            if sizes == [1, 2, 3, 4, 5]:
                sizes = None

            typelist = [
                geocaching.GeocacheCoordinate.TYPE_REGULAR,
                geocaching.GeocacheCoordinate.TYPE_MULTI,
                geocaching.GeocacheCoordinate.TYPE_VIRTUAL,
                geocaching.GeocacheCoordinate.TYPE_EARTH,
                geocaching.GeocacheCoordinate.TYPE_EVENT,
                geocaching.GeocacheCoordinate.TYPE_MYSTERY,
                geocaching.GeocacheCoordinate.TYPE_UNKNOWN
            ]

            types = [typelist[x] for x, in sel_type.get_selected_rows(0)]
            if geocaching.GeocacheCoordinate.TYPE_UNKNOWN in types:
                types = None

            # found, marked
            statuslist = [
                (None, None),
                (False, None),
                (True, None),
                (None, True),
                (False, True),
            ]
            found, marked = statuslist[sel_status.get_selected_rows(0)[0][0]]

            numberlist = [[1, 1.5, 2, 2.5], [3, 3.5, 4], [4.5, 5]]

            difficulties = []
            count = 0
            for x, in sel_diff.get_selected_rows(0):
                difficulties += numberlist[x]
                count += 1
            if count == len(numberlist):
                difficulties = None

            terrains = []
            count = 0
            for x, in sel_terr.get_selected_rows(0):
                terrains += numberlist[x]
                count += 1
            if count == len(numberlist):
                terrains = None

            center = None
            dist_type = sel_dist_type.get_selected_rows(0)[0][0]
            if dist_type == 1:
                try:
                    center = self.gps_last_good_fix.position
                except AttributeError:
                    logger.debug("No current Fix.")
                    pass
            elif dist_type == 2:
                center = self.map.get_center()
            if center != None:
                radius = list_dist_radius[sel_dist_radius.get_selected_rows(0)
                                          [0][0]]
                sqrt_2 = 1.41421356
                c1 = center.transform(-45, radius * 1000 * sqrt_2)
                c2 = center.transform(-45 + 180, radius * 1000 * sqrt_2)
                location = (c1, c2)
            else:
                location = None

            if response == RESPONSE_SHOW_LIST:
                points, truncated = self.core.get_points_filter(
                    found=found,
                    name_search=name_search,
                    size=sizes,
                    terrain=terrains,
                    diff=difficulties,
                    ctype=types,
                    marked=marked,
                    location=location)
                if len(points) > 0:
                    self._display_results(points, truncated)
                    break
                else:
                    self.show_error(
                        "Search returned no geocaches. Please remember that search works only within the downloaded geocaches."
                    )

            elif response == gtk.RESPONSE_ACCEPT:
                self.core.set_filter(found=found,
                                     name_search=name_search,
                                     size=sizes,
                                     terrain=terrains,
                                     diff=difficulties,
                                     ctype=types,
                                     marked=marked)
                self.show_success(
                    "Filter for map activated, ignoring distance restrictions."
                )
                self.map_filter_active = True
                break
            else:
                break
예제 #15
0
    def _show_tool_heading(self, caller, data=None):
        RESULT_WPT, RESULT_TARGET = range(2)
        dialog = gtk.Dialog("Coordinate Projection", self.window,
                            gtk.DIALOG_DESTROY_WITH_PARENT,
                            ("as target", RESULT_TARGET))
        if self.current_cache != None:
            dialog.add_button("add waypoint", RESULT_WPT)
        #dialog.set_size_request(800, 480)

        def select_origin(widget, data=None):
            start = self._get_best_coordinate(
            ) if origin[0] == None else origin[0]
            new = self._show_target_input_list(start, show_current=True)
            if new != None:
                origin[0] = new
                text = new.get_latlon()
                button.set_value(text)
                recalc(None)

        button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT,
                               hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_title("Select Origin")
        button.set_value("current Target")
        button.connect("clicked", select_origin, None)
        dialog.vbox.pack_start(button)

        origin = [self.core.current_target]

        direction = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        direction.set_property("hildon-input-mode",
                               gtk.HILDON_GTK_INPUT_MODE_NUMERIC)

        dialog.vbox.pack_start(
            hildon.Caption(None, "Heading in Degrees", direction, None, 0))

        distance = hildon.Entry(gtk.HILDON_SIZE_AUTO)
        distance.set_property("hildon-input-mode",
                              gtk.HILDON_GTK_INPUT_MODE_NUMERIC)
        dialog.vbox.pack_start(
            hildon.Caption(None, "Distance in Meters", distance, None, 0))

        result = gtk.Label()
        dialog.vbox.pack_start(
            hildon.Caption(None, "Resulting Point", result, None, 0))

        resulting_coordinate = [None]

        def recalc(widget):
            try:
                res = origin[0].transform(-float(direction.get_text()),
                                          float(distance.get_text()))
                text = res.get_latlon()
            except Exception:
                res = None
                text = 'enter values...'
            resulting_coordinate[0] = res
            result.set_text(text)

        direction.connect('changed', recalc)
        distance.connect('changed', recalc)

        dialog.show_all()
        res = dialog.run()
        dialog.hide()
        if res == RESULT_WPT:
            if resulting_coordinate[0] == None:
                return
            distance = resulting_coordinate[0].format_distance(
                float(distance.get_text()))
            heading = int(direction.get_text())
            name = "hdg %s, %d deg from %s" % (distance, heading,
                                               origin[0].get_latlon())
            self.current_cache.get_user_coordinates(None)
            self.current_cache.set_user_coordinate(
                geocaching.GeocacheCoordinate.USER_TYPE_COORDINATE,
                (resulting_coordinate[0].lat, resulting_coordinate[0].lon),
                name)
            self.core.save_cache_attribute(self.current_cache,
                                           'user_coordinates')
            self._on_cache_changed(None, self.current_cache)

        elif res == RESULT_TARGET:
            if resulting_coordinate[0] == None:
                return
            self.set_target(resulting_coordinate[0])
예제 #16
0
    def __init__(self, parent, mirabeau_section, media_server_enabled):
        super(SettingsDialog,
              self).__init__(parent=parent,
                             buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
        self.set_title(_("Settings"))

        self.accounts = []
        bus = dbus.SessionBus()

        # account
        conf_account = mirabeau_section.get("account")
        index = -1
        accounts = connect.gabble_accounts()
        self.account_picker = hildon.PickerButton(
            gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
        selector = hildon.TouchSelectorEntry(text=True)
        self.account_picker.set_title(_('Account:'))
        for account_obj_path in accounts:
            account_obj = bus.get_object(ACCOUNT_MANAGER, account_obj_path)
            norm_name = account_obj.Get(ACCOUNT, 'NormalizedName')
            nick_name = account_obj.Get(ACCOUNT, 'Nickname')
            parameters = account_obj.Get(ACCOUNT, 'Parameters')
            if "" in (nick_name, norm_name):
                label = parameters["account"]
            else:
                label = "%s - %s" % (nick_name, norm_name)
            selector.append_text(label)
            self.accounts.append((account_obj_path, nick_name))
            if account_obj_path == conf_account:
                index = accounts.index(account_obj_path)

        self.account_picker.set_selector(selector)
        if index > -1:
            self.account_picker.set_active(index)

        self.vbox.pack_start(self.account_picker, expand=False)

        # conf server
        self.conf_server_label = gtk.Label(_("Conference Server"))
        self.conf_server_entry = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.conf_server_entry.set_text(
            mirabeau_section.get("conference-server", ""))
        self.conf_server_hbox = gtk.HBox()
        self.conf_server_hbox.pack_start(self.conf_server_label, expand=False)
        self.conf_server_hbox.pack_start(self.conf_server_entry, expand=True)
        self.vbox.pack_start(self.conf_server_hbox, expand=False)

        # chatroom name
        self.chatroom_label = gtk.Label(_("Chatroom"))
        self.chatroom_entry = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.chatroom_entry.set_text(mirabeau_section.get("chatroom", ""))
        self.chatroom_hbox = gtk.HBox()
        self.chatroom_hbox.pack_start(self.chatroom_label, expand=False)
        self.chatroom_hbox.pack_start(self.chatroom_entry, expand=True)
        self.vbox.pack_start(self.chatroom_hbox, expand=False)

        # MS toggle
        self.ms_toggle = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
        self.ms_toggle.set_label(_("Share the media files of this device"))
        self.ms_toggle.set_active(media_server_enabled)
        self.vbox.pack_start(self.ms_toggle, expand=False)

        self.vbox.show_all()
예제 #17
0
def add_google_acct_dialog(widget, data, oldData=None, external=False):
    dialog = gtk.Dialog()

    if not oldData:
        dialog.set_title("Add Google Account")
    else:
        dialog.set_title("Edit Google Account")

    dialog.connect("delete-event", lambda w, d: w.destroy())

    username_label = gtk.Label("Username: "******"Please enter your Google username")

    password_label = gtk.Label("Password: "******"Please enter your Google password")
    password_entry.set_input_mode(gtk.HILDON_GTK_INPUT_MODE_FULL | \
      (not gtk.HILDON_GTK_INPUT_MODE_AUTOCAP))
    password_entry.set_visibility(False)

    if oldData:
        username_entry.set_text(oldData[0])
        password_entry.set_text(oldData[1])

    ubox = gtk.HBox()
    ubox.pack_start(username_label)
    ubox.pack_start(username_entry)

    pbox = gtk.HBox()
    pbox.pack_start(password_label)
    pbox.pack_start(password_entry)

    dialog.vbox.add(ubox)
    dialog.vbox.add(pbox)

    if not oldData:
        dialog.add_button("Add", gtk.RESPONSE_OK)
    else:
        dialog.add_button("Save", gtk.RESPONSE_OK)

    while True:
        dialog.show_all()
        resp = dialog.run()

        if resp == gtk.RESPONSE_OK:
            username = username_entry.get_text()
            password = password_entry.get_text()
            if not oldData:
                if store_google_profile(username, password, \
                  dialog):
                    dialog.destroy()
                    if not external:
                        read_accounts_list()
                        update_gaccts_button()
                    break
            else:
                if update_google_profile(username, password, \
                  oldData[2], dialog):
                    dialog.destroy()
                    read_accounts_list()
                    update_gaccts_button()
                    break
        else:
            break
예제 #18
0
    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()