示例#1
0
 def save_file(self, filename, export=False, **options):
     thumbnail_pixbuf = self.save_doc_to_file(filename, self.doc, export=export, **options)
     if "multifile" in options:
         # Skip thumbnail generation and recentmanager stuff: filename
         # is not reflective of actual disk filenames in this case, and it
         # would be incorrect to save a combined thumb for each file.
         return
     if not export:
         self.filename = os.path.abspath(filename)
         recent_mgr = pygtkcompat.gtk.recent_manager_get_default()
         uri = helpers.filename2uri(self.filename)
         recent_data = dict(
             app_name="mypaint",
             app_exec=sys.argv_unicode[0].encode("utf-8"),
             # todo: get mime_type
             mime_type="application/octet-stream",
         )
         if pygtkcompat.USE_GTK3:
             # No Gtk.RecentData.new() as of 3.4.2-0ubuntu0.3,
             # nor can we set the fields of an empty one :(
             recent_mgr.add_item(uri)
         else:
             recent_mgr.add_full(uri, recent_data)
     if not thumbnail_pixbuf:
         thumbnail_pixbuf = self.doc.model.render_thumbnail()
     helpers.freedesktop_thumbnail(filename, thumbnail_pixbuf)
示例#2
0
 def save_file(self, filename, export=False, **options):
     thumbnail_pixbuf = self.save_doc_to_file(filename,
                                              self.doc,
                                              export=export,
                                              **options)
     if "multifile" in options or not os.path.isfile(filename):
         # Multifile save, or failed save (error dialog was already shown).
         # Skip thumbnail generation attempt and recentmanager stuff.
         return
     if not export:
         self.filename = os.path.abspath(filename)
         recent_mgr = gtk2compat.gtk.recent_manager_get_default()
         uri = helpers.filename2uri(self.filename)
         recent_data = dict(
             app_name='mypaint',
             app_exec=sys.argv_unicode[0].encode('utf-8'),
             # todo: get mime_type
             mime_type='application/octet-stream')
         if gtk2compat.USE_GTK3:
             # No Gtk.RecentData.new() as of 3.4.2-0ubuntu0.3,
             # nor can we set the fields of an empty one :(
             recent_mgr.add_item(uri)
         else:
             recent_mgr.add_full(uri, recent_data)
     if not thumbnail_pixbuf:
         options["background"] = not options.get("alpha", False)
         thumbnail_pixbuf = self.doc.model.render_thumbnail(**options)
     helpers.freedesktop_thumbnail(filename, thumbnail_pixbuf)
示例#3
0
    def save_file(self, filename, export=False, **options):
        thumbnail_pixbuf = self.save_doc_to_file(filename, self.doc, export=export, **options)
        if not export:
            self.filename = os.path.abspath(filename)
            gtk.recent_manager_get_default().add_full(helpers.filename2uri(self.filename),
                    {
                        'app_name': 'mypaint',
                        'app_exec': sys.argv_unicode[0].encode('utf-8'),
                        # todo: get mime_type
                        'mime_type': 'application/octet-stream'
                    }
            )

        if not thumbnail_pixbuf:
            thumbnail_pixbuf = self.doc.model.render_thumbnail()
        helpers.freedesktop_thumbnail(filename, thumbnail_pixbuf)
示例#4
0
 def save_file(self, filename, export=False, **options):
     thumbnail_pixbuf = self.save_doc_to_file(filename, self.doc, export=export, **options)
     if "multifile" in options or not os.path.isfile(filename):
         # Multifile save, or failed save (error dialog was already shown).
         # Skip thumbnail generation attempt and recentmanager stuff.
         return
     if not export:
         self.filename = os.path.abspath(filename)
         recent_mgr = gtk2compat.gtk.recent_manager_get_default()
         uri = helpers.filename2uri(self.filename)
         recent_data = dict(app_name='mypaint',
                            app_exec=sys.argv_unicode[0].encode('utf-8'),
                            # todo: get mime_type
                            mime_type='application/octet-stream')
         if gtk2compat.USE_GTK3:
             # No Gtk.RecentData.new() as of 3.4.2-0ubuntu0.3,
             # nor can we set the fields of an empty one :(
             recent_mgr.add_item(uri)
         else:
             recent_mgr.add_full(uri, recent_data)
     if not thumbnail_pixbuf:
         thumbnail_pixbuf = self.doc.model.render_thumbnail()
     helpers.freedesktop_thumbnail(filename, thumbnail_pixbuf)
示例#5
0
    @drawwindow.with_wait_cursor
    def save_file(self, filename, export=False, **options):
        try:
            x, y, w, h =  self.doc.model.get_bbox()
            if w == 0 and h == 0:
                raise document.SaveLoadError, _('Did not save, the canvas is empty.')
            thumbnail_pixbuf = self.doc.model.save(filename, feedback_cb=self.gtk_main_tick, **options)
        except document.SaveLoadError, e:
            self.app.message_dialog(str(e),type=gtk.MESSAGE_ERROR)
        else:
            file_location = None
            if not export:
                file_location = self.filename = os.path.abspath(filename)
                print 'Saved to', self.filename
                gtk.recent_manager_get_default().add_full(helpers.filename2uri(self.filename),
                        {
                            'app_name': 'mypaint',
                            'app_exec': sys.argv_unicode[0].encode('utf-8'),
                            # todo: get mime_type
                            'mime_type': 'application/octet-stream'
                        }
                )
            else:
                file_location = os.path.abspath(filename)
                print 'Exported to', os.path.abspath(file_location)

            if not thumbnail_pixbuf:
                thumbnail_pixbuf = self.doc.model.render_thumbnail()
            helpers.freedesktop_thumbnail(file_location, thumbnail_pixbuf)