예제 #1
0
    def _show_tool_rot13(self, caller, data=None):
        dialog = gtk.Dialog("ROT13", self.window,
                            gtk.DIALOG_DESTROY_WITH_PARENT, ())
        dialog.set_size_request(800, 480)

        source = hildon.TextView()
        dialog.vbox.pack_start(source)
        destination = hildon.TextView()
        destination.set_editable(False)
        dialog.vbox.pack_start(destination)

        def do_rot(widget):
            try:
                text = HTMLManipulations._rot13(
                    unicode(source.get_buffer().get_text(
                        source.get_buffer().get_start_iter(),
                        source.get_buffer().get_end_iter())))
            except Exception:
                text = ''

            destination.get_buffer().set_text(text)

        source.get_buffer().connect('changed', do_rot)

        dialog.show_all()
        dialog.run()
        dialog.hide()
예제 #2
0
파일: logger.py 프로젝트: cas--/erminig-ng
def display(win):
    global text_area

    dialog = gtk.Dialog()
    dialog.set_title("Log")

    text_area = hildon.TextView()
    text_area.set_editable(False)
    text_area.set_cursor_visible(False)

    pannableArea = hildon.PannableArea()
    pannableArea.add(text_area)
    pannableArea.set_property("mov-mode", hildon.MOVEMENT_MODE_BOTH)
    pannableArea.set_size_request_policy(hildon.SIZE_REQUEST_CHILDREN)
    # WTF?
    pannableArea.set_size_request(300, 300)

    dialog.vbox.pack_start(pannableArea, True, True, 10)

    close_btn = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | \
      gtk.HILDON_SIZE_FINGER_HEIGHT, \
      hildon.BUTTON_ARRANGEMENT_VERTICAL)
    close_btn.connect("clicked", lambda w, d: d.destroy(), dialog)
    close_btn.set_text("Close", "")

    dialog.vbox.add(close_btn)

    dialog.connect("delete-event", lambda w, d: w.destroy())
    display_ring_buffer()
    dialog.show_all()
    dialog.run()
예제 #3
0
    def on_licence_clicked_event(self, widget, data):
        dialog = gtk.Dialog()
        dialog.set_transient_for(self)
        dialog.set_title("Copyright information")
        dialog.add_button("Ok", gtk.RESPONSE_OK)
        gpl = hildon.TextView()
        gpl_licence = """
Maegen is a genealogical application for N900. Use it
on the go to store genealogical data including
individuals and relational informations. Maegen can
be used to browse collected data on the device but
the main goal is its capabilitie to export the
database in a GEDCOM file which can be imported into
any desktop genealocial application.

Copyright (C) 2011  Thierry Bressure

This program is free software: you can redistribute
it and/or modify it under the terms of the GNU
General Public License as published by the Free
Software Foundation, either version 3 of the License,
or (at your option) any later version.

This program is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public
License for more details.

You should have received a copy of the GNU General
Public License along with this program. If not, see
<http://www.gnu.org/licenses/>
        """
        buffer = gtk.TextBuffer()
        buffer.set_text(gpl_licence)
        gpl.set_buffer(buffer)
        gpl.set_property('editable', False)

        pannable_area = hildon.PannableArea()
        pannable_area.set_property('mov_mode', hildon.MOVEMENT_MODE_BOTH)
        pannable_area.set_property('size-request-policy',
                                   hildon.SIZE_REQUEST_CHILDREN)
        pannable_area.add_with_viewport(gpl)
        dialog.vbox.add(pannable_area)
        dialog.show_all()
        dialog.run()
        dialog.destroy()
예제 #4
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)
예제 #5
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()
예제 #6
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()
예제 #7
0
파일: fmms_viewer.py 프로젝트: shubell/fmms
	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)
예제 #8
0
    def build_text_area(text):
        buffer = gtk.TextBuffer()

        tag = buffer.create_tag("bold", weight=pango.WEIGHT_BOLD)
        tag = buffer.create_tag("underline", underline=pango.UNDERLINE_SINGLE)
        tag = buffer.create_tag("wordwrap",
                                wrap_mode=gtk.WRAP_WORD,
                                wrap_mode_set=True)
        tag = buffer.create_tag("indent", left_margin=20, left_margin_set=True)

        # Split into paragraphs.
        paragraphs = re.split("(?:\n[ ]*){1,}\n", text)

        # Split lists into paragraphs.
        q = []
        for p in paragraphs:
            match = re.match("^[ ]+([0-9]+)[.][ ]", p)
            if match:
                # The start of the paragraph has the form " 1. "
                start = int(match.group(1))

                t = re.split("[ ]*\n[ ]+[0-9]+[.][ ]", p)
                if len(t) == 1:
                    q.append(p)
                else:
                    q.append(t[0])
                    for i in range(1, len(t)):
                        q.append(" " + str(start + i) + ". " + t[i])
            else:
                q.append(p)
        paragraphs = q

        for p in paragraphs:
            tags = ["wordwrap"]

            if p[0] == ' ':
                tags.append("indent")

            # Replace \n's with spaces
            p = p.replace("\n", " ")
            # Compress multiple spaces to a single space.
            p = re.sub(" +", " ", p)
            # Remove any leading spaces.
            p = re.sub("^ ", "", p)

            if re.match("^[0-9A-Z ]{5,60}:?[ ]*$", p):
                tags.append("bold")
                tags.append("underline")

            iter = buffer.get_iter_at_offset(-1)
            buffer.insert_with_tags_by_name(iter, p, *tags)
            buffer.insert(iter, "\n\n")

        textview = hildon.TextView()
        textview.set_editable(False)
        textview.set_cursor_visible(False)
        textview.set_buffer(buffer)
        textview.show()

        pannable = hildon.PannableArea()
        pannable.set_size_request(800, 500)
        pannable.add(textview)
        pannable.show()

        return pannable