Example #1
0
    def __init__(self, obj):
        gtk.ScrolledWindow.__init__(self)

        self.treeview = gtk.TreeView()

        self.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)

        self.listmodel = FieldListModel(obj)

        self.column = gtk.TreeViewColumn()
        self.column.set_title(_('Field'))
        render_text = gtk.CellRendererText()
        self.column.pack_start(render_text, expand=True)
        self.column.add_attribute(render_text, 'text', 0)
        self.treeview.append_column(self.column)

        self.column1 = gtk.TreeViewColumn()
        self.column1.set_title(_('Value'))
        render_text = gtk.CellRendererText()
        self.column1.pack_start(render_text, expand=True)
        self.column1.add_attribute(render_text, 'text', 1)
        self.treeview.append_column(self.column1)

        self.add(self.treeview)

        self.treeview.set_model(self.listmodel)
        self.treeview.set_rules_hint(True)
        self.show_all()
        self.treeview.expand_all()
Example #2
0
	def __init__(self, obj):
		gtk.ScrolledWindow.__init__(self)

		self.treeview = gtk.TreeView()

		self.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)

		self.listmodel = FieldListModel(obj)

		self.column = gtk.TreeViewColumn()
		self.column.set_title(_('Field'))
		render_text = gtk.CellRendererText()
		self.column.pack_start(render_text, expand=True)
		self.column.add_attribute(render_text, 'text', 0)
		self.treeview.append_column(self.column)

		self.column1 = gtk.TreeViewColumn()
		self.column1.set_title(_('Value'))
		render_text = gtk.CellRendererText()
		self.column1.pack_start(render_text, expand=True)
		self.column1.add_attribute(render_text, 'text', 1)
		self.treeview.append_column(self.column1)

		self.add(self.treeview)

		self.treeview.set_model(self.listmodel)
		self.treeview.set_rules_hint(True)
		self.show_all()
		self.treeview.expand_all()
Example #3
0
    def open(self, doc_file=''):
        if not doc_file:
            doc_file = dialogs.get_open_file_name(self.mw, self,
                                                  config.open_dir)

        if os.path.lexists(doc_file) and os.path.isfile(doc_file):
            try:
                msg = _('Model creation for') + ' "%s" ' % (doc_file)
                uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

                doc = SW_Presenter(self, doc_file)
            except:
                details = sys.exc_info()[1].__str__(
                ) + '\n' + traceback.format_tb(sys.exc_info()[2])[0]
                msg = _('Cannot open file')
                msg = "%s '%s'" % (msg, doc_file)
                sec = _('The file may be corrupted or not supported format')

                uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

                dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                                   details)
                return
            self.docs.append(doc)
            self.set_current_doc(doc)
            config.open_dir = os.path.dirname(doc_file)
            events.emit(events.APP_STATUS, _('Document opened'))
Example #4
0
    def __init__(self):
        gtk.Frame.__init__(self, self.caption)

        self.set_border_width(5)

        tab = gtk.Table(2, 2, False)
        tab.set_border_width(5)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)
        self.add(tab)

        label = gtk.Label(_('Hex:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK)

        self.hex_value = gtk.Entry()
        self.hex_value.set_width_chars(15)
        self.hex_value.set_text('0')
        tab.attach(self.hex_value, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND,
                   gtk.SHRINK)
        self.hex_value.connect('key-release-event', self.hex_changed)

        label = gtk.Label(_('Dec:'))
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK)

        self.dec_value = gtk.Entry()
        self.dec_value.set_width_chars(15)
        self.dec_value.set_text('0')
        tab.attach(self.dec_value, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND,
                   gtk.SHRINK)
        self.dec_value.connect('key-release-event', self.dec_changed)
Example #5
0
	def save(self, doc=''):
		if not doc:
			doc = self.current_doc
		if not doc.doc_file:
			return self.save_as()
		ext = os.path.splitext(self.current_doc.doc_file)[1]
		if not ext[1:]:
			return self.save_as()
		if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
			return self.save_as()

		try:
			msg = _('Model saving for') + ' "%s" ' % (doc.doc_file)
			uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

			doc.save()
			events.emit(events.DOC_SAVED, doc)
		except:
			details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
			msg = _('Cannot save file')
			msg = "%s '%s'" % (msg, self.current_doc.doc_file)
			sec = _('Please check file write permissions')

			uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

			dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)
			return False
		events.emit(events.APP_STATUS, _('Document saved'))
		return True
Example #6
0
	def save_as(self):
		doc_file = '' + self.current_doc.doc_file
		if not doc_file:
			doc_file = '' + self.current_doc.doc_name
		if not os.path.lexists(os.path.dirname(doc_file)):
			doc_file = os.path.join(config.save_dir,
								os.path.basename(doc_file))
		doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
		if doc_file:
			old_file = self.current_doc.doc_file
			old_name = self.current_doc.doc_name
			self.current_doc.set_doc_file(doc_file)
			try:
				msg = _('Model saving for') + ' "%s" ' % (doc_file)
				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

				self.current_doc.save()
			except IOError:
				self.current_doc.set_doc_file(old_file, old_name)
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				first = _('Cannot save document')
				sec = _('Please check file name and write permissions')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)

				return False
			config.save_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document saved'))
			return True
		else:
			return False
Example #7
0
	def save_as(self):
		doc_file = self.current_doc.doc_file
		if not doc_file:
			doc_file = self.current_doc.doc_name
		if not os.path.lexists(os.path.dirname(doc_file)):
			doc_file = os.path.join(config.save_dir,
								os.path.basename(doc_file))
		doc_file = dialogs.get_save_file_name(self.mw, self, doc_file)
		if doc_file:
			old_file = self.current_doc.doc_file
			old_name = self.current_doc.doc_name
			self.current_doc.set_doc_file(doc_file)
			try:
				msg = _('Model saving for') + ' "%s" ' % (doc_file)
				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

				self.current_doc.save()
			except IOError:
				self.current_doc.set_doc_file(old_file, old_name)
				details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
				first = _('Cannot save document')
				sec = _('Please check file name and write permissions')
				msg = ("%s '%s'.") % (first, self.current_doc.doc_name)

				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)

				return False
			config.save_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document saved'))
			return True
		else:
			return False
Example #8
0
	def open(self, doc_file=''):
		if not doc_file:
			doc_file = dialogs.get_open_file_name(self.mw, self,
												config.open_dir)


		if os.path.lexists(doc_file) and os.path.isfile(doc_file):
			try:
				msg = _('Model creation for') + ' "%s" ' % (doc_file)
				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

				doc = SW_Presenter(self, doc_file)
			except:
				details = sys.exc_info()[1].__str__() + '\n' + traceback.format_tb(sys.exc_info()[2])[0]
				msg = _('Cannot open file')
				msg = "%s '%s'" % (msg, doc_file)
				sec = _('The file may be corrupted or not supported format')

				uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

				dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec, details)
				return
			self.docs.append(doc)
			self.set_current_doc(doc)
			config.open_dir = os.path.dirname(doc_file)
			events.emit(events.APP_STATUS, _('Document opened'))
Example #9
0
def _get_open_fiters():
    result = []
    descr = uc2const.FORMAT_DESCRIPTION
    ext = uc2const.FORMAT_EXTENSION
    items = [] + uc2const.LOADER_FORMATS + uc2const.EXPERIMENTAL_LOADERS

    for item in items:
        filter = gtk.FileFilter()
        filter.set_name(descr[item])
        for extension in ext[item]:
            filter.add_pattern('*.' + extension)
            filter.add_pattern('*.' + extension.upper())
        result.append(filter)

    filter = gtk.FileFilter()
    filter.set_name(_('All files'))
    filter.add_pattern('*')
    result = [filter] + result

    filter = gtk.FileFilter()
    filter.set_name(_('All supported formats'))
    for item in items:
        for extension in ext[item]:
            filter.add_pattern('*.' + extension)
            filter.add_pattern('*.' + extension.upper())
    result = [filter] + result

    return result
Example #10
0
    def save(self, doc=''):
        if not doc:
            doc = self.current_doc
        if not doc.doc_file:
            return self.save_as()
        ext = os.path.splitext(self.current_doc.doc_file)[1]
        if not ext[1:]:
            return self.save_as()
        if not os.path.lexists(os.path.dirname(self.current_doc.doc_file)):
            return self.save_as()

        try:
            msg = _('Model saving for') + ' "%s" ' % (doc.doc_file)
            uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.JOB, msg)

            doc.save()
            events.emit(events.DOC_SAVED, doc)
        except:
            details = sys.exc_info()[1].__str__() + sys.exc_info()[2].__str__()
            msg = _('Cannot save file')
            msg = "%s '%s'" % (msg, self.current_doc.doc_file)
            sec = _('Please check file write permissions')

            uc2.events.emit(uc2.events.MESSAGES, uc2.msgconst.STOP, msg)

            dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                               details)
            return False
        events.emit(events.APP_STATUS, _('Document saved'))
        return True
Example #11
0
def _get_open_fiters():
	result = []
	descr = uc2const.FORMAT_DESCRIPTION
	ext = uc2const.FORMAT_EXTENSION
	items = [] + data.LOADER_FORMATS + data.EXPERIMENTAL_LOADERS

	for item in items:
		filter = gtk.FileFilter()
		filter.set_name(descr[item])
		for extension in ext[item]:
			filter.add_pattern('*.' + extension)
			filter.add_pattern('*.' + extension.upper())
		result.append(filter)

	filter = gtk.FileFilter()
	filter.set_name(_('All files'))
	filter.add_pattern('*')
	result = [filter] + result

	filter = gtk.FileFilter()
	filter.set_name(_('All supported formats'))
	for item in items:
		for extension in ext[item]:
			filter.add_pattern('*.' + extension)
			filter.add_pattern('*.' + extension.upper())
	result = [filter] + result

	return result
    def save(self):
        try:
            if config.make_backup:
                if os.path.lexists(self.doc_file):
                    if os.path.lexists(self.doc_file + '~'):
                        os.remove(self.doc_file + '~')
                    os.rename(self.doc_file, self.doc_file + '~')
            saver = get_saver(self.doc_file, True)
            if saver is None:
                raise IOError(
                    _('Unknown file format is requested for saving!'),
                    self.doc_file)

            pd = ProgressDialog(_('Saving file...'), self.app.mw)
            ret = pd.run(saver, [self.doc_presenter, self.doc_file, False])
            if ret == gtk.RESPONSE_OK:
                if not pd.error_info is None:
                    pd.destroy()
                    raise IOError(*pd.error_info)
                pd.destroy()
            else:
                pd.destroy()
                raise IOError(_('Error while saving'), self.doc_file)

        except IOError:
            raise IOError(*sys.exc_info())
        self.reflect_saving()
    def __init__(self, app, doc_file=''):
        self.app = app
        self.eventloop = EventLoop(self)
        self.doc_file = doc_file
        if doc_file:
            loader = get_loader(doc_file, True)
            if loader is None:
                raise IOError(_('Unknown file format'), doc_file)

            pd = ProgressDialog(_('Opening file...'), self.app.mw)
            ret = pd.run(loader, [app.appdata, doc_file, None, False])
            if ret == gtk.RESPONSE_OK:
                if pd.result is None:
                    pd.destroy()
                    raise IOError(*pd.error_info)

                self.doc_presenter = pd.result
                pd.destroy()
            else:
                pd.destroy()
                raise IOError(_('Error while opening'), doc_file)

            self.doc_file = self.doc_presenter.doc_file
            self.doc_name = os.path.basename(self.doc_file)
        else:
            #FIXME: Here should be new model creation
            self.doc_name = self.app.get_new_docname()

        self.doc_presenter.update(True)
        self.selection = ModelSelection(self)
        self.docarea = DocArea(self.app, self)
        self.app.mw.add_tab(self.docarea)
        self.selection.set_root()
Example #14
0
    def __init__(self, app):

        gtk.VBox.__init__(self)
        self.app = app
        self.logs = []
        self.icon_theme = gtk.icon_theme_get_default()
        self.caption_label = TabIconCaption(gtk.STOCK_MISSING_IMAGE,
                                            self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(0)

        self.rec_but = NavigationButton(gtk.STOCK_MEDIA_RECORD,
                                        _('Start recording'))
        nav_panel.pack_start(self.rec_but, False)
        self.rec_but.connect('clicked', self.start_rec)

        self.stop_but = NavigationButton(gtk.STOCK_MEDIA_STOP,
                                         _('Stop recording'))
        nav_panel.pack_start(self.stop_but, False)
        self.stop_but.connect('clicked', self.stop_rec)

        separator = gtk.VSeparator()
        nav_panel.pack_start(separator, False)

        self.clear_but = NavigationButton(gtk.STOCK_CLEAR, _('Clear logs'))
        nav_panel.pack_start(self.clear_but, False)
        self.clear_but.connect('clicked', self.clear_logs)

        spacer.pack_start(nav_panel, False)

        self.treeview = gtk.TreeView()

        self.scrolledwindow = gtk.ScrolledWindow()
        self.scrolledwindow.add(self.treeview)
        self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        spacer.pack_end(self.scrolledwindow, True)

        #-------TreeList--------------
        col = gtk.TreeViewColumn()
        col.set_title(_('Log Entries'))
        render_pixbuf = gtk.CellRendererPixbuf()
        col.pack_start(render_pixbuf, expand=False)
        col.add_attribute(render_pixbuf, 'pixbuf', 0)
        render_text = gtk.CellRendererText()
        col.pack_start(render_text, expand=True)
        col.add_attribute(render_text, 'text', 1)
        self.treeview.append_column(col)
        #-----------------------------
        self.treeview.set_rules_hint(True)

        self.show_all()
        self.update_view()
Example #15
0
    def __init__(self, mw):
        gtk.MenuBar.__init__(self)
        self.mw = mw
        self.app = mw.app
        self.actions = self.app.actions

        #----FILE MENU
        self.file_item, self.file_menu = self.create_menu(_("_File"))
        items = [
            'NEW', None, 'OPEN', 'SAVE', 'SAVE_AS', 'SAVE_ALL', None, 'CLOSE',
            'CLOSE_ALL', None, 'QUIT'
        ]
        self.add_items(self.file_menu, items)

        #----EDIT MENU
        self.edit_item, self.edit_menu = self.create_menu(_("_Edit"))
        items = ['CUT', 'COPY', 'PASTE', 'DELETE', None, 'PREFERENCES']
        self.add_items(self.edit_menu, items)

        #----VIEW MENU
        self.view_item, self.view_menu = self.create_menu(_("_View"))
        items = [
            'BACKWARD',
            'FORWARD',
            'ROOT',
            None,
            'CLEAR_HISTORY',
            None,
            'REFRESH_OBJ',
            'REFRESH_MODEL',
        ]
        self.add_items(self.view_menu, items)

        #----TOOLS MENU
        self.tools_item, self.tools_menu = self.create_menu(_("_Tools"))
        items = [
            'ABOUT',
        ]
        self.add_items(self.tools_menu, items)

        #----HELP MENU
        self.help_item, self.help_menu = self.create_menu(_("_Help"))
        items = [
            'REPORT_BUG',
            None,
            'PROJECT_WEBSITE',
            'PROJECT_FORUM',
            None,
            'ABOUT',
        ]
        self.add_items(self.help_menu, items)

        self.append(self.file_item)
        self.append(self.edit_item)
        self.append(self.view_item)
        #		self.append(self.tools_item)
        self.append(self.help_item)
Example #16
0
	def __init__(self, app):

		gtk.VBox.__init__(self)
		self.app = app
		self.logs = []
		self.icon_theme = gtk.icon_theme_get_default()
		self.caption_label = TabIconCaption(gtk.STOCK_MISSING_IMAGE, self.caption)

		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(5)

		nav_panel = gtk.HBox()
		nav_panel.set_border_width(0)

		self.rec_but = NavigationButton(gtk.STOCK_MEDIA_RECORD, _('Start recording'))
		nav_panel.pack_start(self.rec_but, False)
		self.rec_but.connect('clicked', self.start_rec)

		self.stop_but = NavigationButton(gtk.STOCK_MEDIA_STOP, _('Stop recording'))
		nav_panel.pack_start(self.stop_but, False)
		self.stop_but.connect('clicked', self.stop_rec)

		separator = gtk.VSeparator()
		nav_panel.pack_start(separator, False)

		self.clear_but = NavigationButton(gtk.STOCK_CLEAR, _('Clear logs'))
		nav_panel.pack_start(self.clear_but, False)
		self.clear_but.connect('clicked', self.clear_logs)

		spacer.pack_start(nav_panel, False)

		self.treeview = gtk.TreeView()

		self.scrolledwindow = gtk.ScrolledWindow()
		self.scrolledwindow.add(self.treeview)
		self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		spacer.pack_end(self.scrolledwindow, True)

		#-------TreeList--------------
		col = gtk.TreeViewColumn()
		col.set_title(_('Log Entries'))
		render_pixbuf = gtk.CellRendererPixbuf()
		col.pack_start(render_pixbuf, expand=False)
		col.add_attribute(render_pixbuf, 'pixbuf', 0)
		render_text = gtk.CellRendererText()
		col.pack_start(render_text, expand=True)
		col.add_attribute(render_text, 'text', 1)
		self.treeview.append_column(col)
		#-----------------------------
		self.treeview.set_rules_hint(True)

		self.show_all()
		self.update_view()
Example #17
0
def get_save_file_name(parent, app, path):
    result = ''
    dialog = gtk.FileChooserDialog(_('Save file As...'), parent,
                                   gtk.FILE_CHOOSER_ACTION_SAVE,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_OK))
    dialog.set_do_overwrite_confirmation(True)

    dialog.set_default_response(gtk.RESPONSE_OK)
    path = expanduser_unicode(path)

    doc_folder = os.path.dirname(path)
    dialog.set_current_folder(doc_folder)

    doc_name = os.path.basename(path)
    dialog.set_current_name(doc_name)

    for filter in _get_save_fiters():
        dialog.add_filter(filter)

    ret = dialog.run()
    if not ret == gtk.RESPONSE_CANCEL:
        result = dialog.get_filename()
    dialog.destroy()
    if result is None: result = ''
    return result
Example #18
0
    def __init__(self, app):

        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = TabIconCaption(gtk.STOCK_INDEX, self.caption)
        self.data = ''

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(0)
        spacer.pack_start(nav_panel, False, False)

        #---Panel internal content---

        self.dec_box = DecoderTab(app)
        spacer.pack_start(self.dec_box, False, False)

        self.be_check = gtk.CheckButton(label=_('Big Endian values'))
        self.be_check.set_active(False)
        self.be_check.connect('clicked', self.change_be_check)
        spacer.pack_start(self.be_check, False, False)

        calc_frame = HexDecCalc()
        spacer.pack_start(calc_frame, False, False)
        #----------------------------

        self.show_all()
        events.connect(events.BIN_SELECTION, self.get_selection)
Example #19
0
def get_save_file_name(parent, app, path):
	result = ''
	dialog = gtk.FileChooserDialog(_('Save file As...'),
				parent,
				gtk.FILE_CHOOSER_ACTION_SAVE,
				(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
					gtk.STOCK_SAVE, gtk.RESPONSE_OK))
	dialog.set_do_overwrite_confirmation(True)

	dialog.set_default_response(gtk.RESPONSE_OK)
	path = expanduser_unicode(path)

	doc_folder = os.path.dirname(path)
	dialog.set_current_folder(doc_folder)

	doc_name = os.path.basename(path)
	dialog.set_current_name(doc_name)

	for filter in _get_save_fiters():
		dialog.add_filter(filter)

	ret = dialog.run()
	if not ret == gtk.RESPONSE_CANCEL:
		result = dialog.get_filename()
	dialog.destroy()
	if result is None: result = ''
	return result
Example #20
0
def get_prefs_dialog(app):
    parent = app.mw
    title = _('%s Preferences') % (app.appdata.app_name)

    nb = PrefsNotebook(app)
    nb.set_property('scrollable', True)
    nb.set_tab_pos(gtk.POS_TOP)

    dialog = gtk.Dialog(title, parent,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                         gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT))
    dialog.vbox.pack_start(nb)

    about = gtk.Button(stock=gtk.STOCK_ABOUT)
    about.connect('clicked', app.proxy.about)
    bbox_start = gtk.VBox()
    bbox_start.pack_start(about, False, False, 3)
    bbox = gtk.HBox()
    bbox.pack_start(bbox_start, False, False, 3)
    dialog.vbox.remove(dialog.action_area)
    bbox.pack_end(dialog.action_area)
    dialog.vbox.pack_start(bbox, True, False, 0)
    dialog.show_all()

    ret = dialog.run()
    if ret == gtk.RESPONSE_ACCEPT:
        nb.run_apply()
    dialog.destroy()
Example #21
0
    def reflect_selection(self, *args):
        obj = args[0][0][0]
        self.tb.set_text('')
        self.iter = self.tb.get_iter_at_offset(0)

        self.show_header(_("Object "))
        self.show_header_bold(obj.resolve()[1] + "\n")
        self.show_subheader(str(obj) + '\n')
        if obj.__doc__:
            self.show_pydoc(obj.__doc__)

        self.new_line()
        self.show_subheader(_('Object fields table:') + "\n\n")

        anchor = self.tb.create_child_anchor(self.iter)
        self.add_child_at_anchor(ObjectFieldTab(obj), anchor)

        self.show_subheader(' \n')
Example #22
0
	def reflect_selection(self, *args):
		obj = args[0][0][0]
		self.tb.set_text('')
		self.iter = self.tb.get_iter_at_offset(0)

		self.show_header(_("Object "))
		self.show_header_bold(obj.resolve()[1] + "\n")
		self.show_subheader(str(obj) + '\n')
		if obj.__doc__:
			self.show_pydoc(obj.__doc__)

		self.new_line()
		self.show_subheader(_('Object fields table:') + "\n\n")

		anchor = self.tb.create_child_anchor(self.iter)
		self.add_child_at_anchor(ObjectFieldTab(obj), anchor)

		self.show_subheader(' \n')
Example #23
0
    def __init__(self, mw):
        gtk.MenuBar.__init__(self)
        self.mw = mw
        self.app = mw.app
        self.actions = self.app.actions

        # ----FILE MENU
        self.file_item, self.file_menu = self.create_menu(_("_File"))
        items = ["NEW", None, "OPEN", "SAVE", "SAVE_AS", "SAVE_ALL", None, "CLOSE", "CLOSE_ALL", None, "QUIT"]
        self.add_items(self.file_menu, items)

        # ----EDIT MENU
        self.edit_item, self.edit_menu = self.create_menu(_("_Edit"))
        items = ["CUT", "COPY", "PASTE", "DELETE", None, "PREFERENCES"]
        self.add_items(self.edit_menu, items)

        # ----VIEW MENU
        self.view_item, self.view_menu = self.create_menu(_("_View"))
        items = ["BACKWARD", "FORWARD", "ROOT", None, "CLEAR_HISTORY", None, "REFRESH_OBJ", "REFRESH_MODEL"]
        self.add_items(self.view_menu, items)

        # ----TOOLS MENU
        self.tools_item, self.tools_menu = self.create_menu(_("_Tools"))
        items = ["ABOUT"]
        self.add_items(self.tools_menu, items)

        # ----HELP MENU
        self.help_item, self.help_menu = self.create_menu(_("_Help"))
        items = ["REPORT_BUG", None, "PROJECT_WEBSITE", "PROJECT_FORUM", None, "ABOUT"]
        self.add_items(self.help_menu, items)

        self.append(self.file_item)
        self.append(self.edit_item)
        self.append(self.view_item)
        # 		self.append(self.tools_item)
        self.append(self.help_item)
Example #24
0
    def __init__(self, app, presenter):
        gtk.VBox.__init__(self, False, 0)
        self.mw = app.mw
        self.app = app
        self.presenter = presenter
        model_cid = self.presenter.doc_presenter.cid
        model_name = uc2const.FORMAT_EXTENSION[model_cid][0].upper()

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(0)

        self.listmodel = ObjectTreeModel(self.presenter.doc_presenter.model)

        self.treeview = gtk.TreeView()

        self.column = gtk.TreeViewColumn()
        self.column.set_title(model_name + ' ' + _('File Format Model'))
        render_pixbuf = gtk.CellRendererPixbuf()
        self.column.pack_start(render_pixbuf, expand=False)
        self.column.add_attribute(render_pixbuf, 'pixbuf', 0)
        render_text = gtk.CellRendererText()
        self.column.pack_start(render_text, expand=True)
        self.column.add_attribute(render_text, 'text', 1)
        self.treeview.append_column(self.column)

        self.column1 = gtk.TreeViewColumn()
        render_text = gtk.CellRendererText()
        self.column1.pack_start(render_text, expand=False)
        self.column1.add_attribute(render_text, 'text', 2)
        self.column1.add_attribute(render_text, 'foreground', 3)
        self.treeview.append_column(self.column1)

        self.treeview.connect('cursor-changed', self.view_object)

        self.scrolledwindow = gtk.ScrolledWindow()
        self.scrolledwindow.add(self.treeview)
        self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        spacer.pack_end(self.scrolledwindow, True)

        self.treeview.set_model(self.listmodel)
        self.treeview.set_rules_hint(True)
        self.treeview.set_enable_tree_lines(True)
        eventloop = self.presenter.eventloop
        eventloop.connect(eventloop.SELECTION_CHANGED, self.reflect_selection)
        self.update_view()
Example #25
0
	def set_path(self, pathname, undo=False):
		try:
			os.listdir(pathname)
		except:
			msg = _('Access error to')
			msg = "%s '%s'" % (msg, pathname)
			sec = sys.exc_info()[1].__str__()
			dialogs.msg_dialog(self.mw, self.app.appdata.app_name, msg,
							sec, gtk.MESSAGE_ERROR)
			return

		if undo:
			pass
		else:
			self.undo += [self.current_dir, ]
		self.current_dir = "" + pathname
		self.update_view()
Example #26
0
	def set_path(self, pathname, undo=False):
		try:
			os.listdir(pathname)
		except:
			msg = _('Access error to')
			msg = "%s '%s'" % (msg, pathname)
			sec = sys.exc_info()[1].__str__()
			dialogs.msg_dialog(self.mw, self.app.appdata.app_name, msg,
							sec, gtk.MESSAGE_ERROR)
			return

		if undo:
			pass
		else:
			self.undo += [self.current_dir, ]
		self.current_dir = "" + pathname
		self.update_view()
Example #27
0
class Clipboard(gtk.VBox):
    name = "Clipboard"
    caption = _("Clipboard")
    caption_label = None

    def __init__(self, app):
        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = TabIconCaption(gtk.STOCK_PASTE, self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(0)

        self.show_all()
Example #28
0
	def close(self, doc=None):
		if not self.docs:
			return
		if doc is None:
			doc = self.current_doc

		if not self.mw.nb.page_num(doc.docarea) == self.mw.nb.get_current_page():
			self.mw.set_active_tab(doc.docarea)
		if doc in self.docs:
			self.docs.remove(doc)
			doc.close()
			events.emit(events.DOC_CLOSED)
			if not len(self.docs):
				self.current_doc = None
				events.emit(events.NO_DOCS)
				msg = _('To start create new or open existing document')
				events.emit(events.APP_STATUS, msg)
		return True
Example #29
0
	def close(self, doc=None):
		if not self.docs:
			return
		if doc is None:
			doc = self.current_doc

		if not self.mw.nb.page_num(doc.docarea) == self.mw.nb.get_current_page():
			self.mw.set_active_tab(doc.docarea)
		if doc in self.docs:
			self.docs.remove(doc)
			doc.close()
			events.emit(events.DOC_CLOSED)
			if not len(self.docs):
				self.current_doc = None
				events.emit(events.NO_DOCS)
				msg = _('To start, create new document or open existing')
				events.emit(events.APP_STATUS, msg)
		return True
Example #30
0
class Decoder(gtk.VBox):
    name = "Decoder"
    caption = _("Decoder")
    caption_label = None
    data = ''

    def __init__(self, app):
        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = TabIconCaption(gtk.STOCK_SORT_ASCENDING,
                                            self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(0)
        spacer.pack_start(nav_panel, False, False)

        # ---Panel internal content---

        self.dec_box = DecoderTab(app)
        spacer.pack_start(self.dec_box, False, False)

        self.be_check = gtk.CheckButton(label=_('Big Endian values'))
        self.be_check.set_active(False)
        self.be_check.connect('clicked', self.change_be_check)
        spacer.pack_start(self.be_check, False, False)

        calc_frame = HexDecCalc()
        spacer.pack_start(calc_frame, False, False)
        # ----------------------------

        self.show_all()
        events.connect(events.BIN_SELECTION, self.get_selection)

    def get_selection(self, *args):
        self.data = args[0][0]
        self.change_be_check()

    def change_be_check(self, *args):
        self.dec_box.update_data(self.data, self.be_check.get_active())
Example #31
0
def get_prefs_dialog(app):

    parent = app.mw
    title = _('%s Preferences') % (app.appdata.app_name)

    nb = PrefsNotebook(app)
    nb.set_property('scrollable', True)
    nb.set_tab_pos(gtk.POS_TOP)

    dialog = gtk.Dialog(title, parent,
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                         gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT))
    dialog.vbox.pack_start(nb)
    nb.show()

    ret = dialog.run()
    if ret == gtk.RESPONSE_ACCEPT:
        nb.run_apply()
    dialog.destroy()
Example #32
0
def get_open_file_name(parent, app, start_dir):
    result = ''
    dialog = gtk.FileChooserDialog(_('Open file'), parent,
                                   gtk.FILE_CHOOSER_ACTION_OPEN,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_OPEN, gtk.RESPONSE_OK))

    dialog.set_default_response(gtk.RESPONSE_OK)
    start_dir = expanduser_unicode(start_dir)
    dialog.set_current_folder(start_dir)

    for filter in _get_open_fiters():
        dialog.add_filter(filter)

    ret = dialog.run()
    if not ret == gtk.RESPONSE_CANCEL:
        result = dialog.get_filename()
    dialog.destroy()
    if result is None: result = ''
    return result
Example #33
0
def get_prefs_dialog(app):

	parent = app.mw
	title = _('%s Preferences') % (app.appdata.app_name)

	nb = PrefsNotebook(app)
	nb.set_property('scrollable', True)
	nb.set_tab_pos(gtk.POS_TOP)

	dialog = gtk.Dialog(title, parent,
	                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
	                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
	                    gtk.STOCK_APPLY, gtk.RESPONSE_ACCEPT))
	dialog.vbox.pack_start(nb)
	nb.show()

	ret = dialog.run()
	if ret == gtk.RESPONSE_ACCEPT:
		nb.run_apply()
	dialog.destroy()
Example #34
0
def get_open_file_name(parent, app, start_dir):
	result = ''
	dialog = gtk.FileChooserDialog(_('Open file'),
				parent,
				gtk.FILE_CHOOSER_ACTION_OPEN,
				(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
					gtk.STOCK_OPEN, gtk.RESPONSE_OK))

	dialog.set_default_response(gtk.RESPONSE_OK)
	start_dir = expanduser_unicode(start_dir)
	dialog.set_current_folder(start_dir)

	for filter in _get_open_fiters():
		dialog.add_filter(filter)

	ret = dialog.run()
	if not ret == gtk.RESPONSE_CANCEL:
		result = dialog.get_filename()
	dialog.destroy()
	if result is None: result = ''
	return result
Example #35
0
    def update_view(self):
        obj = self.current_obj
        self.tb.set_text('')
        self.iter = self.tb.get_iter_at_offset(0)

        items = obj.__dict__.items()
        fields = []
        for key, value in items:
            if not key in GENERIC_TAGS:
                if not key[:6] == 'cache_':
                    fields.append((key, value))

        if fields:
            self.show_tag('<' + obj.tag)
        else:
            if obj.childs:
                self.show_tag('<' + obj.tag)
            else:
                self.show_tag('<' + obj.tag + ' />\n')

        if fields:
            for key, value in fields:
                self.show_key('\n' + IDENT + str(key) + '=')
                value_str = str(value)
                if self.presenter.doc_presenter.cid == uc2const.PDXF:
                    if isinstance(value, str):
                        value_str = "'%s'" % (self.escape_quote(value_str))
                self.show_value('"' + value_str + '" ')

        if obj.childs:
            self.show_tag('>\n')
            self.show_comment(IDENT + _('...child content...') + '\n')
            self.show_tag('</' + obj.tag + '>\n')
        else:
            if fields:
                self.show_tag('/>\n')
Example #36
0
	def update_view(self):
		obj = self.current_obj
		self.tb.set_text('')
		self.iter = self.tb.get_iter_at_offset(0)

		items = obj.__dict__.items()
		fields = []
		for key, value in items:
			if not key in GENERIC_TAGS:
				if not key[:6] == 'cache_':
					fields.append((key, value))

		if fields:
			self.show_tag('<' + obj.tag)
		else:
			if obj.childs:
				self.show_tag('<' + obj.tag)
			else:
				self.show_tag('<' + obj.tag + ' />\n')

		if fields:
			for key, value in fields:
				self.show_key('\n' + IDENT + str(key) + '=')
				value_str = str(value)
				if self.presenter.doc_presenter.cid == uc2const.PDXF:
					if isinstance(value, str):
						value_str = "'%s'" % (self.escape_quote(value_str))
				self.show_value('"' + value_str + '" ')

		if obj.childs:
			self.show_tag('>\n')
			self.show_comment(IDENT + _('...child content...') + '\n')
			self.show_tag('</' + obj.tag + '>\n')
		else:
			if fields:
				self.show_tag('/>\n')
Example #37
0
 def run(self):
     events.emit(events.NO_DOCS)
     events.emit(events.APP_STATUS,
                 _('To start create new or open existing document'))
     gtk.main()
Example #38
0
class ExternalAppsTab(gtk.VBox):

    name = "External Applications"
    caption = _("External Applications")
    caption_label = None

    def __init__(self, app):

        gtk.VBox.__init__(self)
        self.app = app
        self.caption_label = gtk.Label(self.caption)

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(15)
        self.set_size_request(550, 300)

        tab = gtk.Table(6, 2, False)
        tab.set_row_spacings(10)
        tab.set_col_spacings(10)
        spacer.add(tab)

        #---------------------------

        label = gtk.Label('External image viewer:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK)

        self.entry1 = gtk.Entry()
        self.entry1.set_text(config.ext_image_view)
        tab.attach(self.entry1, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        #---------------------------

        label = gtk.Label('External text editor:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK)

        self.entry2 = gtk.Entry()
        self.entry2.set_text(config.ext_text_view)
        tab.attach(self.entry2, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        #---------------------------

        label = gtk.Label('External document viewer:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK)

        self.entry3 = gtk.Entry()
        self.entry3.set_text(config.ext_doc_view)
        tab.attach(self.entry3, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        #---------------------------

        label = gtk.Label('External HTML viewer:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK)

        self.entry4 = gtk.Entry()
        self.entry4.set_text(config.ext_html_view)
        tab.attach(self.entry4, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        #---------------------------

        label = gtk.Label('External binary editor:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 4, 5, gtk.FILL, gtk.SHRINK)

        self.entry5 = gtk.Entry()
        self.entry5.set_text(config.ext_binary_view)
        tab.attach(self.entry5, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        #---------------------------

        label = gtk.Label('External compare tool:')
        label.set_alignment(0, 0.5)
        tab.attach(label, 0, 1, 5, 6, gtk.FILL, gtk.SHRINK)

        self.entry6 = gtk.Entry()
        self.entry6.set_text(config.ext_compare_view)
        tab.attach(self.entry6, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.SHRINK)

        self.show_all()

    def do_apply(self):
        config.ext_image_view = self.entry1.get_text()
        config.ext_text_view = self.entry2.get_text()
        config.ext_doc_view = self.entry3.get_text()
        config.ext_html_view = self.entry4.get_text()
        config.ext_binary_view = self.entry5.get_text()
        config.ext_compare_view = self.entry6.get_text()
Example #39
0
    def __init__(self, app, root=''):
        gtk.VBox.__init__(self, False, 0)
        self.mw = app.mw
        self.app = app
        self.caption_label = TabIconCaption(gtk.STOCK_MEDIA_PLAY, self.caption)
        self.root = root

        self.current_dir = "" + config.scr_current_directory

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        label = gtk.Label(self.caption.upper())
        spacer.pack_start(label, False)

        separator = gtk.HSeparator()
        spacer.pack_start(separator, False)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(3)

        self.back_but = NavigationButton(gtk.STOCK_GO_BACK, _('Go Back'))
        nav_panel.pack_start(self.back_but, False)
        self.back_but.connect('clicked', self.action_back)

        self.up_but = NavigationButton(gtk.STOCK_GO_UP, _('Go Up'))
        nav_panel.pack_start(self.up_but, False)
        self.up_but.connect('clicked', self.action_up)

        self.forward_but = NavigationButton(gtk.STOCK_GO_FORWARD,
                                            _('Go Forward'))
        nav_panel.pack_start(self.forward_but, False)
        self.forward_but.connect('clicked', self.action_forward)

        self.home_but = NavigationButton(gtk.STOCK_HOME, _('Home directory'))
        nav_panel.pack_start(self.home_but, False)
        self.home_but.connect('clicked', self.action_home)

        separator = gtk.VSeparator()
        nav_panel.pack_start(separator, False, padding=2)

        self.refr_but = NavigationButton(gtk.STOCK_REFRESH, _('Refresh'))
        nav_panel.pack_start(self.refr_but, False)
        self.refr_but.connect('clicked', self.update_view)

        separator = gtk.VSeparator()
        nav_panel.pack_start(separator, False, padding=2)

        self.find_but = NavigationToggleButton(gtk.STOCK_FIND,
                                               _('Show all files'))
        nav_panel.pack_start(self.find_but, False)
        self.find_but.connect('clicked', self.update_view)

        spacer.pack_start(nav_panel, False)

        self.listmodel = FileListModel()

        self.treeview = gtk.TreeView()

        self.column = gtk.TreeViewColumn()
        self.column.set_title(_('Log Entries'))
        render_pixbuf = gtk.CellRendererPixbuf()
        self.column.pack_start(render_pixbuf, expand=False)
        self.column.add_attribute(render_pixbuf, 'pixbuf', 0)
        render_text = gtk.CellRendererText()
        self.column.pack_start(render_text, expand=True)
        self.column.add_attribute(render_text, 'text', 1)
        self.treeview.append_column(self.column)

        self.treeview.connect('row-activated', self.open_file)

        self.scrolledwindow = gtk.ScrolledWindow()
        self.scrolledwindow.add(self.treeview)
        self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        spacer.pack_end(self.scrolledwindow, True)

        self.treeview.set_model(self.listmodel)
        self.treeview.set_rules_hint(True)
        events.connect(events.CONFIG_MODIFIED, self.update_by_config)
        self.find_but.set_active(config.scr_show_all_files)
        self.update_view()
Example #40
0
class ScriptingTool(gtk.VBox):

    name = "Script Launcher"
    caption = _("Script Launcher")
    caption_label = None
    undo = []
    redo = []

    def __init__(self, app, root=''):
        gtk.VBox.__init__(self, False, 0)
        self.mw = app.mw
        self.app = app
        self.caption_label = TabIconCaption(gtk.STOCK_MEDIA_PLAY, self.caption)
        self.root = root

        self.current_dir = "" + config.scr_current_directory

        spacer = gtk.VBox()
        self.add(spacer)
        self.set_border_width(5)

        label = gtk.Label(self.caption.upper())
        spacer.pack_start(label, False)

        separator = gtk.HSeparator()
        spacer.pack_start(separator, False)

        nav_panel = gtk.HBox()
        nav_panel.set_border_width(3)

        self.back_but = NavigationButton(gtk.STOCK_GO_BACK, _('Go Back'))
        nav_panel.pack_start(self.back_but, False)
        self.back_but.connect('clicked', self.action_back)

        self.up_but = NavigationButton(gtk.STOCK_GO_UP, _('Go Up'))
        nav_panel.pack_start(self.up_but, False)
        self.up_but.connect('clicked', self.action_up)

        self.forward_but = NavigationButton(gtk.STOCK_GO_FORWARD,
                                            _('Go Forward'))
        nav_panel.pack_start(self.forward_but, False)
        self.forward_but.connect('clicked', self.action_forward)

        self.home_but = NavigationButton(gtk.STOCK_HOME, _('Home directory'))
        nav_panel.pack_start(self.home_but, False)
        self.home_but.connect('clicked', self.action_home)

        separator = gtk.VSeparator()
        nav_panel.pack_start(separator, False, padding=2)

        self.refr_but = NavigationButton(gtk.STOCK_REFRESH, _('Refresh'))
        nav_panel.pack_start(self.refr_but, False)
        self.refr_but.connect('clicked', self.update_view)

        separator = gtk.VSeparator()
        nav_panel.pack_start(separator, False, padding=2)

        self.find_but = NavigationToggleButton(gtk.STOCK_FIND,
                                               _('Show all files'))
        nav_panel.pack_start(self.find_but, False)
        self.find_but.connect('clicked', self.update_view)

        spacer.pack_start(nav_panel, False)

        self.listmodel = FileListModel()

        self.treeview = gtk.TreeView()

        self.column = gtk.TreeViewColumn()
        self.column.set_title(_('Log Entries'))
        render_pixbuf = gtk.CellRendererPixbuf()
        self.column.pack_start(render_pixbuf, expand=False)
        self.column.add_attribute(render_pixbuf, 'pixbuf', 0)
        render_text = gtk.CellRendererText()
        self.column.pack_start(render_text, expand=True)
        self.column.add_attribute(render_text, 'text', 1)
        self.treeview.append_column(self.column)

        self.treeview.connect('row-activated', self.open_file)

        self.scrolledwindow = gtk.ScrolledWindow()
        self.scrolledwindow.add(self.treeview)
        self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        spacer.pack_end(self.scrolledwindow, True)

        self.treeview.set_model(self.listmodel)
        self.treeview.set_rules_hint(True)
        events.connect(events.CONFIG_MODIFIED, self.update_by_config)
        self.find_but.set_active(config.scr_show_all_files)
        self.update_view()

    def open_file(self, treeview, path, column):
        model = treeview.get_model()
        pathname = os.path.abspath(model.get_pathname(path))
        if os.path.isdir(pathname):
            self.set_path(pathname)
        else:
            name = os.path.basename(pathname)[:-3]
            path = os.path.dirname(pathname)
            file, filename, desc = imp.find_module(name, [path])
            module = imp.load_module(name, file, filename, desc)
            module.run_script(self.app, self.mw)

    def set_path(self, pathname, undo=False):
        try:
            os.listdir(pathname)
        except:
            msg = _('Access error to')
            msg = "%s '%s'" % (msg, pathname)
            sec = sys.exc_info()[1].__str__()
            dialogs.msg_dialog(self.mw, self.app.appdata.app_name, msg, sec,
                               gtk.MESSAGE_ERROR)
            return

        if undo:
            pass
        else:
            self.undo += [
                self.current_dir,
            ]
        self.current_dir = "" + pathname
        config.scr_current_directory = "" + pathname
        self.update_view()

    def update_view(self, *args):
        path = '' + config.scr_current_directory
        if self.root:
            path = path.replace(self.root, '::')
        self.column.set_title(path)

        filters = [
            'py',
        ]
        config.scr_show_all_files = self.find_but.get_active()
        if self.find_but.get_active():
            filters = []

        new_model = FileListModel(config.scr_current_directory, filters,
                                  config.scr_show_hidden_files, self.root)
        self.treeview.set_model(new_model)

        if self.undo:
            self.back_but.set_sensitive(True)
        else:
            self.back_but.set_sensitive(False)

        if self.redo:
            self.forward_but.set_sensitive(True)
        else:
            self.forward_but.set_sensitive(False)

        self.home_but.set_sensitive(True)
        if self.current_dir == os.path.expanduser('~'):
            self.home_but.set_sensitive(False)
        if self.root and self.current_dir == self.root:
            self.home_but.set_sensitive(False)

        self.up_but.set_sensitive(True)
        if self.root:
            if self.current_dir == self.root:
                self.up_but.set_sensitive(False)
        else:
            if self.current_dir == os.path.abspath(
                    os.path.join(self.current_dir, '..')):
                self.up_but.set_sensitive(False)

    def update_by_config(self, *args):
        attr = args[0][0]
        value = args[0][1]
        if attr[0:3] == 'scr_':
            if attr == 'scr_current_directory' and value == self.current_dir:
                pass
            else:
                self.update_view()

    def action_home(self, *args):
        if self.root:
            self.set_path(self.root)
        else:
            self.set_path(os.path.expanduser('~'))

    def action_up(self, *args):
        path = os.path.abspath(os.path.join(self.current_dir, '..'))
        self.set_path(path)

    def action_back(self, *args):
        if self.undo:
            self.redo.insert(0, self.current_dir)
            path = self.undo[-1]
            self.undo = self.undo[:-1]
            self.set_path(path, True)

    def action_forward(self, *args):
        if self.redo:
            path = self.redo[0]
            self.redo = self.redo[1:]
            self.set_path(path)
Example #41
0
def create_actions(app):
	insp = app.inspector
	proxy = app.proxy
	accelgroup = app.accelgroup
	actiongroup = app.actiongroup
	actions = {}
	entries = [

	['NEW', _('_New'), _('New'), gtk.STOCK_NEW, '<Control>N',
	 proxy.new, None, None],
	['OPEN', _('_Open'), _('Open'), gtk.STOCK_OPEN, '<Control>O',
	 proxy.open, None, None],
	['SAVE', _('_Save'), _('Save'), gtk.STOCK_SAVE, '<Control>S',
	 proxy.save, [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
	 insp.is_doc_not_saved],
	['SAVE_AS', _('Save _As...'), _('Save As...'), gtk.STOCK_SAVE_AS, None,
	 proxy.save_as, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['SAVE_ALL', _('Save All'), _('Save All'), None, None,
	 proxy.save_all, [NO_DOCS, DOC_CHANGED, DOC_MODIFIED, DOC_SAVED],
	 insp.is_any_doc_not_saved],
	['CLOSE', _('_Close'), _('Close'), gtk.STOCK_CLOSE, '<Control>W',
	 proxy.close, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['CLOSE_ALL', _('_Close All'), _('Close All'), None, None,
	 proxy.close_all, [NO_DOCS, DOC_CHANGED], insp.is_doc],
	['QUIT', _('_Exit'), _('Exit'), gtk.STOCK_QUIT, '<Alt>F4',
	 proxy.exit, None, None],


	['CUT', _('Cu_t'), _('Cut'), gtk.STOCK_CUT, '<Control>X',
	 proxy.cut, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_cutcopy],
	['COPY', _('_Copy'), _('Copy'), gtk.STOCK_COPY, '<Control>C',
	 proxy.copy, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_cutcopy],
	['PASTE', _('_Paste'), _('Paste'), gtk.STOCK_PASTE, '<Control>V',
	 proxy.paste, [events.NO_DOCS, events.CLIPBOARD], insp.stub],
	['DELETE', _('_Delete'), _('Delete'), gtk.STOCK_DELETE, 'Delete',
	 proxy.delete, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_cutcopy],

	['BACKWARD', _('Go back'), _('Go back'), gtk.STOCK_GO_BACK,
	 '<Alt>Left', proxy.backward_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_backward_object],
	['FORWARD', _('Go forward'), _('Go forward'), gtk.STOCK_GO_FORWARD,
	 '<Alt>Right', proxy.forward_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_forward_object],
	['ROOT', _('Go to root'), _('Go to root'), gtk.STOCK_HOME, '<Alt>Home',
	 proxy.root_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_set_root],

	['CLEAR_HISTORY', _('Clear history'), _('Clear history'), gtk.STOCK_CLEAR,
	 None, proxy.clear_history, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_clear_history],

	['REFRESH_OBJ', _('Refresh object'), _('Refresh object'), gtk.STOCK_REFRESH,
	 '<Control>R', proxy.refresh_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_refresh_object],
	['EDIT_OBJ', _('Edit binary chunk'), _('Edit binary chunk'), gtk.STOCK_EDIT,
	 None, proxy.edit_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_edit_object],
	['UPDATE_OBJ', _('Update edited chunk'), _('Update edited chunk'), gtk.STOCK_REVERT_TO_SAVED,
	 None, proxy.update_object, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_update_object],

	['REFRESH_MODEL', _('Refresh model'), _('Refresh model'), gtk.STOCK_REFRESH,
	 '<Alt>R', proxy.refresh_model, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_refresh_model],

	['COPY_TO_COMPARE', _('_Copy to comparator'), _('Copy to comparator'),
	gtk.STOCK_GOTO_LAST, None, proxy.copy_to_compare, [events.NO_DOCS,
	events.DOC_CHANGED, events.SELECTION_CHANGED], insp.can_copy_to_compare],
	['COPY_TO_CLIP', _('_Copy to clip'), _('Copy to clip'), gtk.STOCK_MEDIA_NEXT,
	None, proxy.copy_to_clip, [events.NO_DOCS, events.DOC_CHANGED,
	events.SELECTION_CHANGED], insp.can_copy_to_clip],




	['PREFERENCES', _('Preferences...'), _('Preferences...'), gtk.STOCK_PREFERENCES, None,
	 proxy.prefs, None, None],


	['REPORT_BUG', _('_Report bug'), _('Report bug'), gtk.STOCK_DIALOG_WARNING, None,
	 proxy.report_bug, None, None],
	['PROJECT_WEBSITE', _('Project _web site'), _('Project web site'), None, None,
	 proxy.project_website, None, None],
	['PROJECT_FORUM', _('Project _forum'), _('Project forum'), None, None,
	 proxy.project_forum, None, None],
	['ABOUT', _('_About SWord'), _('About SWord'), gtk.STOCK_ABOUT, None,
	 proxy.about, None, None],
	]

	for entry in entries:
		action = AppAction(entry[0], entry[1], entry[2], entry[3],
						   entry[4], entry[5], entry[6], entry[7])

		actions[entry[0]] = action
		if not action.shortcut is None:
			actiongroup.add_action_with_accel(action, action.shortcut)
			action.set_accel_group(accelgroup)
		else:
			actiongroup.add_action(action)

	return actions
Example #42
0
	def run(self):
		events.emit(events.NO_DOCS)
		events.emit(events.APP_STATUS,
				_('To start create new or open existing document'))
		gtk.main()
Example #43
0
	def __init__(self, app, root=''):
		gtk.VBox.__init__(self, False, 0)
		self.mw = app.mw
		self.app = app
		self.caption_label = TabIconCaption(gtk.STOCK_HARDDISK, self.caption)
		self.root = root

		self.current_dir = "" + config.fb_current_directory

		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(5)

		nav_panel = gtk.HBox()
		nav_panel.set_border_width(3)

		self.back_but = NavigationButton(gtk.STOCK_GO_BACK, _('Go Back'))
		nav_panel.pack_start(self.back_but, False)
		self.back_but.connect('clicked', self.action_back)

		self.up_but = NavigationButton(gtk.STOCK_GO_UP, _('Go Up'))
		nav_panel.pack_start(self.up_but, False)
		self.up_but.connect('clicked', self.action_up)

		self.forward_but = NavigationButton(gtk.STOCK_GO_FORWARD, _('Go Forward'))
		nav_panel.pack_start(self.forward_but, False)
		self.forward_but.connect('clicked', self.action_forward)

		self.home_but = NavigationButton(gtk.STOCK_HOME, _('Home directory'))
		nav_panel.pack_start(self.home_but, False)
		self.home_but.connect('clicked', self.action_home)

		separator = gtk.VSeparator()
		nav_panel.pack_start(separator, False, padding=2)

		self.refr_but = NavigationButton(gtk.STOCK_REFRESH, _('Refresh'))
		nav_panel.pack_start(self.refr_but, False)
		self.refr_but.connect('clicked', self.update_view)

		separator = gtk.VSeparator()
		nav_panel.pack_start(separator, False, padding=2)

		self.find_but = NavigationToggleButton(gtk.STOCK_FIND, _('Show all files'))
		nav_panel.pack_start(self.find_but, False)
		self.find_but.connect('clicked', self.update_view)


		spacer.pack_start(nav_panel, False)

		self.listmodel = FileListModel()

		self.treeview = gtk.TreeView()

		self.column = gtk.TreeViewColumn()
		self.column.set_title(_('Log Entries'))
		render_pixbuf = gtk.CellRendererPixbuf()
		self.column.pack_start(render_pixbuf, expand=False)
		self.column.add_attribute(render_pixbuf, 'pixbuf', 0)
		render_text = gtk.CellRendererText()
		self.column.pack_start(render_text, expand=True)
		self.column.add_attribute(render_text, 'text', 1)
		self.treeview.append_column(self.column)

		self.treeview.connect('row-activated', self.open_file)

		self.scrolledwindow = gtk.ScrolledWindow()
		self.scrolledwindow.add(self.treeview)
		self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
		spacer.pack_end(self.scrolledwindow, True)

		self.treeview.set_model(self.listmodel)
		self.treeview.set_rules_hint(True)
		events.connect(events.CONFIG_MODIFIED, self.update_by_config)
		self.find_but.set_active(config.fb_show_all_files)
		self.update_view()
Example #44
0
	def get_new_docname(self):
		self.doc_counter += 1
		return _('Untitled') + ' ' + str(self.doc_counter)
Example #45
0
 def _edit_stub(self):
     msg = _('Model editor is not found for ')
     msg = "%s '%s'" % (msg, self.app.current_doc.doc_file)
     sec = _('Install model editor and try again.')
     dialogs.msg_dialog(self.mw, self.app.appdata.app_name, msg, sec)
Example #46
0
 def get_new_docname(self):
     self.doc_counter += 1
     return _('Untitled') + ' ' + str(self.doc_counter)
Example #47
0
	def __init__(self, app, presenter):
		gtk.VBox.__init__(self, False, 0)
		self.mw = app.mw
		self.app = app
		self.presenter = presenter
		model_cid = self.presenter.doc_presenter.cid
		model_name = uc2const.FORMAT_EXTENSION[model_cid][0].upper()


		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(5)

		nav_panel = gtk.HBox()
		nav_panel.set_border_width(0)


		self.back_but = ActionButton(self.app.actions['BACKWARD'])
		nav_panel.pack_start(self.back_but, False)

		self.forward_but = ActionButton(self.app.actions['FORWARD'])
		nav_panel.pack_start(self.forward_but, False)

		self.home_but = ActionButton(self.app.actions['ROOT'])
		nav_panel.pack_start(self.home_but, False)

		separator = gtk.VSeparator()
		nav_panel.pack_start(separator, False, padding=2)

		self.refr_but = ActionButton(self.app.actions['REFRESH_MODEL'])
		nav_panel.pack_start(self.refr_but, False)


		self.expand_but = ImageButton('expand.png', _('Expand All'))
		nav_panel.pack_end(self.expand_but, False)
		self.expand_but.connect('clicked', self.expand_all)

		self.collapse_but = ImageButton('collapse.png', _('Collapse All'))
		nav_panel.pack_end(self.collapse_but, False)
		self.collapse_but.connect('clicked', self.collapse_all)

		spacer.pack_start(nav_panel, False)

		self.listmodel = ObjectTreeModel(self.presenter.doc_presenter.model)

		self.treeview = gtk.TreeView()

		self.column = gtk.TreeViewColumn()
		self.column.set_title(model_name + ' ' + _('File Format Model'))
		render_pixbuf = gtk.CellRendererPixbuf()
		self.column.pack_start(render_pixbuf, expand=False)
		self.column.add_attribute(render_pixbuf, 'pixbuf', 0)
		render_text = gtk.CellRendererText()
		self.column.pack_start(render_text, expand=True)
		self.column.add_attribute(render_text, 'text', 1)
		self.treeview.append_column(self.column)

		self.column1 = gtk.TreeViewColumn()
		render_text = gtk.CellRendererText()
		self.column1.pack_start(render_text, expand=False)
		self.column1.add_attribute(render_text, 'text', 2)
		self.column1.add_attribute(render_text, 'foreground', 3)
		self.treeview.append_column(self.column1)

		self.treeview.connect('cursor-changed', self.view_object)

		self.scrolledwindow = gtk.ScrolledWindow()
		self.scrolledwindow.add(self.treeview)
		self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		self.scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
		spacer.pack_end(self.scrolledwindow, True)

		self.treeview.set_model(self.listmodel)
		self.treeview.set_rules_hint(True)
		self.treeview.set_enable_tree_lines(True)
		eventloop = self.presenter.eventloop
		eventloop.connect(eventloop.SELECTION_CHANGED, self.reflect_selection)
		self.update_view()
Example #48
0
class Logger(gtk.VBox):

	name = "Logger"
	caption = _("Logger")
	caption_label = None
	logs = []
	connected = False


	def __init__(self, app):

		gtk.VBox.__init__(self)
		self.app = app
		self.logs = []
		self.icon_theme = gtk.icon_theme_get_default()
		self.caption_label = TabIconCaption(gtk.STOCK_MISSING_IMAGE, self.caption)

		spacer = gtk.VBox()
		self.add(spacer)
		self.set_border_width(5)

		nav_panel = gtk.HBox()
		nav_panel.set_border_width(0)

		self.rec_but = NavigationButton(gtk.STOCK_MEDIA_RECORD, _('Start recording'))
		nav_panel.pack_start(self.rec_but, False)
		self.rec_but.connect('clicked', self.start_rec)

		self.stop_but = NavigationButton(gtk.STOCK_MEDIA_STOP, _('Stop recording'))
		nav_panel.pack_start(self.stop_but, False)
		self.stop_but.connect('clicked', self.stop_rec)

		separator = gtk.VSeparator()
		nav_panel.pack_start(separator, False)

		self.clear_but = NavigationButton(gtk.STOCK_CLEAR, _('Clear logs'))
		nav_panel.pack_start(self.clear_but, False)
		self.clear_but.connect('clicked', self.clear_logs)

		spacer.pack_start(nav_panel, False)

		self.treeview = gtk.TreeView()

		self.scrolledwindow = gtk.ScrolledWindow()
		self.scrolledwindow.add(self.treeview)
		self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
		self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		spacer.pack_end(self.scrolledwindow, True)

		#-------TreeList--------------
		col = gtk.TreeViewColumn()
		col.set_title(_('Log Entries'))
		render_pixbuf = gtk.CellRendererPixbuf()
		col.pack_start(render_pixbuf, expand=False)
		col.add_attribute(render_pixbuf, 'pixbuf', 0)
		render_text = gtk.CellRendererText()
		col.pack_start(render_text, expand=True)
		col.add_attribute(render_text, 'text', 1)
		self.treeview.append_column(col)
		#-----------------------------
		self.treeview.set_rules_hint(True)

		self.show_all()
		self.update_view()

	def update_view(self):
		if config.log_start_record:
			self.rec_but.set_sensitive(False)
			self.stop_but.set_sensitive(True)
			if not self.connected:
				self.set_listener(True)
		else:
			self.rec_but.set_sensitive(True)
			self.stop_but.set_sensitive(False)
			if self.connected:
				self.set_listener(False)

		store = gtk.ListStore(gtk.gdk.Pixbuf, str)
		for log in self.logs:
			log_type, log_text = log
			store.append((self.icon_theme.load_icon(log_icons[log_type], 16, 0), log_text))

		self.treeview.set_model(store)

	def stop_rec(self, *args):
		config.log_start_record = False
		self.update_view()

	def start_rec(self, *args):
		config.log_start_record = True
		self.update_view()

	def clear_logs(self, *args):
		self.logs = []
		self.update_view()

	def set_listener(self, start=True):
		if start:
			events.connect(events.MESSAGES, self.listener)
			self.connected = True
		else:
			events.disconnect(events.MESSAGES, self.listener)
			self.connected = False

	def listener(self, *args):
		args, = args
		self.logs.append(args)
		self.update_view()
Example #49
0
 def load(self, pathname):
     msg = _('Request to open file')
     msg = "%s '%s'" % (msg, pathname)
     sec = _('The open operation will be implemented soon.')
     dialogs.msg_dialog(self.mw, self.appdata.app_name, msg, sec,
                        gtk.MESSAGE_INFO)
Example #50
0
	def load(self, pathname):
		msg = _('Request to open file')
		msg = "%s '%s'" % (msg, pathname)
		sec = _('The open operation will be implemented soon.')
		dialogs.msg_dialog(self.mw, self.appdata.app_name, msg,
						sec, gtk.MESSAGE_INFO)
Example #51
0
	def _edit_stub(self):
		msg = _('Model editor is not found for ')
		msg = "%s '%s'" % (msg, self.app.current_doc.doc_file)
		sec = _('Install model editor and try again.')
		dialogs.msg_dialog(self.mw, self.app.appdata.app_name, msg, sec)