예제 #1
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()
예제 #2
0
파일: factory.py 프로젝트: cmotc/medit
    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()
예제 #3
0
파일: utils.py 프로젝트: cmotc/medit
def entry_dialog(parent=None, label=None, entry_content=None, title=None):
    glade_file = os.path.join(os.path.dirname(__file__), "utils.glade")
    xml = moo.glade_xml_new_from_file(glade_file, root='entry_dialog',
                                      domain=moo.GETTEXT_PACKAGE)
    xml.w_entry_dialog.set_title(title)
    if parent:
        parent = parent.get_toplevel()
        xml.w_entry_dialog.set_transient_for(parent)
    if label:
        xml.w_label.set_text(label)
    else:
        xml.w_label.hide()
    if entry_content:
        xml.w_entry.set_text(entry_content)

    retval = None
    if xml.w_entry_dialog.run() == gtk.RESPONSE_OK:
        retval = xml.w_entry.get_text()

    xml.w_entry_dialog.destroy()
    return retval
예제 #4
0
def entry_dialog(parent=None, label=None, entry_content=None, title=None):
    glade_file = os.path.join(os.path.dirname(__file__), "utils.glade")
    xml = moo.glade_xml_new_from_file(glade_file,
                                      root='entry_dialog',
                                      domain=moo.GETTEXT_PACKAGE)
    xml.w_entry_dialog.set_title(title)
    if parent:
        parent = parent.get_toplevel()
        xml.w_entry_dialog.set_transient_for(parent)
    if label:
        xml.w_label.set_text(label)
    else:
        xml.w_label.hide()
    if entry_content:
        xml.w_entry.set_text(entry_content)

    retval = None
    if xml.w_entry_dialog.run() == gtk.RESPONSE_OK:
        retval = xml.w_entry.get_text()

    xml.w_entry_dialog.destroy()
    return retval