Exemplo n.º 1
0
    def on_new_template(self, action):
        dialog = Gtk.Dialog(_('Choose Template Name'))
        dialog.set_transient_for(self.main_window.main_frame)
        dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
        dialog.set_response_sensitive(Gtk.ResponseType.OK, False)

        # Let user finish by hitting ENTER.
        def respond(widget):
            dialog.response(Gtk.ResponseType.OK)

        def on_text_changed(entry):
            dialog.set_response_sensitive(Gtk.ResponseType.OK,
                                          bool(entry.get_text()))

        entry = Gtk.Entry()
        entry.connect('activate', respond)
        # Only allow closing dialog when text is entered.
        entry.connect('changed', on_text_changed)
        entry.set_size_request(300, -1)
        dialog.get_content_area().pack_start(entry, True, True, 0)
        dialog.show_all()
        response = dialog.run()
        dialog.hide()

        if response == Gtk.ResponseType.OK:
            title = entry.get_text()
            selection = self.main_window.day_text_field.get_selection_bounds()
            path = self.get_path(title)
            filesystem.make_file(path, example_text)
            self.enter_template_mode(title, selection)
Exemplo n.º 2
0
    def on_new_template(self, action):
        dialog = Gtk.Dialog(_('Choose Template Name'))
        dialog.set_transient_for(self.main_window.main_frame)
        dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
        dialog.set_response_sensitive(Gtk.ResponseType.OK, False)

        # Let user finish by hitting ENTER.
        def respond(widget):
            dialog.response(Gtk.ResponseType.OK)

        def on_text_changed(entry):
            dialog.set_response_sensitive(Gtk.ResponseType.OK, bool(entry.get_text()))

        entry = Gtk.Entry()
        entry.connect('activate', respond)
        # Only allow closing dialog when text is entered.
        entry.connect('changed', on_text_changed)
        entry.set_size_request(300, -1)
        dialog.get_content_area().pack_start(entry, True, True, 0)
        dialog.show_all()
        response = dialog.run()
        dialog.hide()

        if response == Gtk.ResponseType.OK:
            title = entry.get_text()
            parts = self.main_window.day_text_field.get_text_parts()
            path = self.get_path(title)
            filesystem.make_file(path, example_text)
            self.enter_template_mode(title, parts)
Exemplo n.º 3
0
	def on_new_template(self, action):
		dialog = gtk.Dialog(_('Choose Template Name'))
		dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
		dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
		
		entry = gtk.Entry()
		entry.set_size_request(300, -1)
		dialog.get_content_area().pack_start(entry)
		dialog.show_all()
		response = dialog.run()
		dialog.hide()		
		
		if response == gtk.RESPONSE_OK:
			title = entry.get_text()
			if not title.lower().endswith('.txt'):
				title += '.txt'
			filename = os.path.join(self.dirs.template_dir, title)
			
			filesystem.make_file(filename, example_text)
			
			filesystem.open_url(filename)
Exemplo n.º 4
0
    def on_new_template(self, action):
        dialog = gtk.Dialog(_('Choose Template Name'))
        dialog.set_transient_for(self.main_window.main_frame)
        dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)

        entry = gtk.Entry()
        entry.set_size_request(300, -1)
        dialog.get_content_area().pack_start(entry)
        dialog.show_all()
        response = dialog.run()
        dialog.hide()

        if response == gtk.RESPONSE_OK:
            title = entry.get_text()
            if not title.lower().endswith('.txt'):
                title += '.txt'
            filename = os.path.join(self.dirs.template_dir, title)

            filesystem.make_file(filename, example_text)

            filesystem.open_url(filename)