Пример #1
0
    def open_project(self, window, filename):
        if not self.close_project(False):
            return

        f = open(filename)
        file = File(f.read())
        f.close()

        if file.version != mprj.project_version:
            moo.error_dialog(window, _("Could not open project '%s'") % (filename,),
                             _("Invalid project version %s") % (file.version,))
	    return

        file.path = filename
        project_type = self.project_types.get(file.project_type)
        config_type = getattr(project_type, '__config__')
        config = config_type(file)

        self.project = project_type(window, config, file)
        self.project.load()
        self.__set_title_prefix(self.project.name)
        self.recent_list.add_filename(filename)
        moo.prefs_set_string("Plugins/Project/last", filename)

        close = self.window.get_action("CloseProject")
        options = self.window.get_action("ProjectOptions")
        if close:
            close.set_property("sensitive", True)
        if options:
            options.set_property("visible", True)
Пример #2
0
    def open_project(self, window, filename):
        if not self.close_project(False):
            return

        f = open(filename)
        file = File(f.read())
        f.close()

        if file.version != mprj.project_version:
            moo.error_dialog(
                window,
                _("Could not open project '%s'") % (filename, ),
                _("Invalid project version %s") % (file.version, ))
            return

        file.path = filename
        project_type = self.project_types.get(file.project_type)
        config_type = getattr(project_type, '__config__')
        config = config_type(file)

        self.project = project_type(window, config, file)
        self.project.load()
        self.__set_title_prefix(self.project.name)
        self.recent_list.add_filename(filename)
        moo.prefs_set_string("Plugins/Project/last", filename)

        close = self.window.get_action("CloseProject")
        options = self.window.get_action("ProjectOptions")
        if close:
            close.set_property("sensitive", True)
        if options:
            options.set_property("visible", True)
Пример #3
0
 def save_config(self):
     content = self.config.format()
     try:
         mprj.utils.save_file(self.filename, content)
     except Exception, e:
         moo.error_dialog(self.window, 'Could not save project file',
                          'Could not save file %s: %s' % (self.filename, str(e)))
Пример #4
0
 def save_config(self):
     content = self.config.format()
     try:
         mprj.utils.save_file(self.filename, content)
     except Exception, e:
         moo.error_dialog(
             self.window, 'Could not save project file',
             'Could not save file %s: %s' % (self.filename, str(e)))
Пример #5
0
 def save_session(self):
     try:
         file = self.get_session_file()
         session = Session(self.window)
         session.set_file_selector_dir(self.__file_selector_dir)
         session.save(file)
     except Exception, e:
         moo.error_dialog(self.window, 'Could not save session',
                          'Could not save file %s: %s' % (file, str(e)))
Пример #6
0
 def run(self, factories, window):
     pi = self.ask(factories, window)
     if pi is None:
         return None
     try:
         pi.factory.create(pi)
     except Exception, e:
         moo.error_dialog(window, 'Could not create project', str(e))
         return None
Пример #7
0
 def save_session(self):
     try:
         file = self.get_session_file()
         session = Session(self.window)
         session.set_file_selector_dir(self.__file_selector_dir)
         session.save(file)
     except Exception, e:
         moo.error_dialog(self.window, 'Could not save session',
                          'Could not save file %s: %s' % (file, str(e)))
Пример #8
0
 def run(self, factories, window):
     pi = self.ask(factories, window)
     if pi is None:
         return None
     try:
         pi.factory.create(pi)
     except Exception, e:
         moo.error_dialog(window, 'Could not create project', str(e))
         return None
Пример #9
0
    def ask(self, factories, window):
        glade_file = os.path.join(os.path.dirname(__file__), "factory.glade")
        xml = moo.glade_xml_new_from_file(glade_file,
                                          domain=moo.GETTEXT_PACKAGE)
        self.xml = xml

        self.__setup_type_list(factories, xml)

        xml.w_location.set_text(os.path.expanduser('~'))
        xml.w_location_button.connect('clicked',
                                      self.__location_button_clicked)
        xml.w_name.connect('changed', self.__name_changed)
        xml.w_location.connect('changed', self.__location_changed)

        dialog = xml.w_dialog
        dialog.set_response_sensitive(gtk.RESPONSE_OK, False)
        dialog.set_transient_for(window)

        try:
            while 1:
                if dialog.run() != gtk.RESPONSE_OK:
                    return None

                d, f = self.__get_project_file()

                if os.path.lexists(d) and not os.path.isdir(d):
                    moo.error_dialog(dialog, '%s is not a directory' % (d, ))
                    continue

                if os.path.exists(os.path.join(d, f)):
                    if not moo.overwrite_file_dialog(dialog, f, d):
                        continue

                if os.path.exists(d) and not os.access(d, os.W_OK):
                    moo.error_dialog(dialog, '%s is not writable' % (d, ))
                    continue
                if not os.path.exists(d):
                    try:
                        os.mkdir(d)
                    except Exception, e:
                        moo.error_dialog(
                            dialog, 'Could not create directory %s' % (d, ),
                            str(e))
                        continue

                model, iter = xml.w_type.get_selection().get_selected()
                factory = model.get_value(iter, _COLUMN_FACTORY)

                pi = ProjectInfo(factory, d, f, xml.w_name.get_text())

                return pi
        finally:
            dialog.destroy()
Пример #10
0
    def ask(self, factories, window):
        glade_file = os.path.join(os.path.dirname(__file__), "factory.glade")
        xml = moo.glade_xml_new_from_file(glade_file, domain=moo.GETTEXT_PACKAGE)
        self.xml = xml

        self.__setup_type_list(factories, xml)

        xml.w_location.set_text(os.path.expanduser('~'))
        xml.w_location_button.connect('clicked', self.__location_button_clicked)
        xml.w_name.connect('changed', self.__name_changed)
        xml.w_location.connect('changed', self.__location_changed)

        dialog = xml.w_dialog
        dialog.set_response_sensitive(gtk.RESPONSE_OK, False)
        dialog.set_transient_for(window)

        try:
            while 1:
                if dialog.run() != gtk.RESPONSE_OK:
                    return None

                d, f = self.__get_project_file()

                if os.path.lexists(d) and not os.path.isdir(d):
                    moo.error_dialog(dialog, '%s is not a directory' % (d,))
                    continue

                if os.path.exists(os.path.join(d, f)):
                    if not moo.overwrite_file_dialog(dialog, f, d):
                        continue

                if os.path.exists(d) and not os.access(d, os.W_OK):
                    moo.error_dialog(dialog, '%s is not writable' % (d,))
                    continue
                if not os.path.exists(d):
                    try:
                        os.mkdir(d)
                    except Exception, e:
                        moo.error_dialog(dialog, 'Could not create directory %s' % (d,), str(e))
                        continue

                model, iter = xml.w_type.get_selection().get_selected()
                factory = model.get_value(iter, _COLUMN_FACTORY)

                pi = ProjectInfo(factory, d, f, xml.w_name.get_text())

                return pi
        finally:
            dialog.destroy()
Пример #11
0
 def bad_project(self, parent, filename, error):
     moo.error_dialog(parent, _("Could not open project '%s'") % (filename,), str(error))
Пример #12
0
 def bad_project(self, parent, filename, error):
     moo.error_dialog(parent,
                      _("Could not open project '%s'") % (filename, ),
                      str(error))
Пример #13
0
def oops(window, error):
    moo.error_dialog(window, "OOPS", format_error(error))
Пример #14
0
def error_dialog(text, secondary_text=None, parent=None):
    moo.error_dialog(parent, text, secondary_text)
Пример #15
0
def oops(window, error):
    moo.error_dialog(window, "OOPS", format_error(error))
Пример #16
0
def error_dialog(text, secondary_text=None, parent=None):
    moo.error_dialog(parent, text, secondary_text)