# Path: sunflower/common.py
# def executable_exists(command):
# 	"""Check if specified command exists in search path"""
# 	default_paths = os.pathsep.join(('/bin', '/usr/bin', '/usr/local/bin'))
# 	search_paths = os.environ.get('PATH', default_paths).split(os.pathsep)
# 	found_commands = [path for path in search_paths if os.path.exists(os.path.join(path, command))]
# 
# 	return len(found_commands) > 0
# 
# def decode_file_name(file_name):
# 	"""Replace surrogate codepoints in a filename with a replacement character
# 	to display non-UTF-8 filenames."""
# 	if isinstance(file_name, bytes):
# 		return file_name.decode('utf-8', 'replace')
# 
# 	return decode_file_name(encode_file_name(file_name))
# 
# def get_monospace_font_string():
# 	"""Return monospace font name."""
# 	global MONOSPACE_FONT_STRING
# 
# 	if MONOSPACE_FONT_STRING is None:
# 		schema = Gio.SettingsSchemaSource.get_default()
# 		gnome_interface = schema.lookup('org.gnome.desktop.interface',True)
# 
# 		if gnome_interface is None:
# 			# not in gnome desktop environment, use 'monospace'
# 			MONOSPACE_FONT_STRING = 'monospace'
# 		else:
# 			settings = Gio.Settings.new('org.gnome.desktop.interface')
# 			MONOSPACE_FONT_STRING = settings.get_string('monospace-font-name')
# 
# 	return MONOSPACE_FONT_STRING
# 
# Path: sunflower/widgets/status_bar.py
# class StatusBar(Gtk.HBox):
# 	"""Plugin status bar"""
# 
# 	def __init__(self):
# 		GObject.GObject.__init__(self, homogeneous=False, spacing=15)
# 
# 		self.set_border_width(4)
# 		self.set_property('no-show-all', True)
# 
# 		self._icons = {}
# 		self._labels = {}
# 
# 		# create default label
# 		self._label = Gtk.Label()
# 		self._label.set_use_markup(True)
# 		self._label.set_alignment(0, 0.5)
# 		self._label.show()
# 
# 		# pack interface
# 		self.pack_end(self._label, True, True, 0)
# 
# 	def set_text(self, text, group=None):
# 		"""Set default label text"""
# 		if group is None:
# 			# set default label
# 			self._label.set_markup(text)
# 
# 		elif group in self._labels:
# 			# set specified group label
# 			self._labels[group].set_markup(text)
# 
# 	def add_group_with_icon(self, name, icon_name, value='', tooltip=None):
# 		"""Add status bar group with icon"""
# 		icon = Gtk.Image()
# 		icon.set_from_icon_name(icon_name, Gtk.IconSize.MENU)
# 		icon.show()
# 
# 		label = Gtk.Label(label=value)
# 		label.set_use_markup(True)
# 		label.set_alignment(0, 0.5)
# 		label.show()
# 
# 		# configure tooltip
# 		if tooltip is not None:
# 			label.set_tooltip_text(tooltip)
# 			icon.set_tooltip_text(tooltip)
# 
# 		# pack group
# 		hbox = Gtk.HBox(False, 3)
# 		hbox.show()
# 
# 		hbox.pack_start(icon, False, False, 0)
# 		hbox.pack_start(label, False, False, 0)
# 
# 		self.pack_start(hbox, False, False, 0)
# 
# 		# add group to local cache
# 		self._labels[name] = label
# 		self._icons[name] = icon
# 
# Path: sunflower/plugin_base/provider.py
# class Mode:
# 	READ = 0
# 	WRITE = 1
# 	APPEND = 2
# 	READ_APPEND = 3


import gi
import os
import chardet
import codecs
import subprocess
from gi.repository import Gio, Gtk, Gdk, Pango, GObject, GdkPixbuf
from sunflower.common import executable_exists, decode_file_name, get_monospace_font_string
from sunflower.widgets.status_bar import StatusBar
from sunflower.plugin_base.provider import Mode as FileMode
	from gi.repository import GtkSource

				code_buffer.place_cursor(code_buffer.get_start_iter())

				window = Gtk.ScrolledWindow.new()
				window.set_shadow_type(Gtk.ShadowType.NONE)
				window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
				window.add(viewer)

				# add page
				self.add_page(_('Code'), window)

		# create text page if needed
		if associations_manager.is_mime_type_subset(self._mime_type, 'text/plain'):
			# get data from the file
			raw_file = self._provider.get_file_handle(self.path, FileMode.READ)
			data = raw_file.read()
			raw_file.close()

			# create new page
			self._create_text_page(_('Text'), data)

		# create image page if needed
		if self._mime_type.startswith('image/'):
			container = Gtk.ScrolledWindow()
			container.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
			container.set_shadow_type(Gtk.ShadowType.NONE)
			viewport = Gtk.Viewport()
			image = Gtk.Image()

			# load raw data

# Path: sunflower/common.py
# def executable_exists(command):
# 	"""Check if specified command exists in search path"""
# 	default_paths = os.pathsep.join(('/bin', '/usr/bin', '/usr/local/bin'))
# 	search_paths = os.environ.get('PATH', default_paths).split(os.pathsep)
# 	found_commands = [path for path in search_paths if os.path.exists(os.path.join(path, command))]
# 
# 	return len(found_commands) > 0
# 
# def decode_file_name(file_name):
# 	"""Replace surrogate codepoints in a filename with a replacement character
# 	to display non-UTF-8 filenames."""
# 	if isinstance(file_name, bytes):
# 		return file_name.decode('utf-8', 'replace')
# 
# 	return decode_file_name(encode_file_name(file_name))
# 
# def get_monospace_font_string():
# 	"""Return monospace font name."""
# 	global MONOSPACE_FONT_STRING
# 
# 	if MONOSPACE_FONT_STRING is None:
# 		schema = Gio.SettingsSchemaSource.get_default()
# 		gnome_interface = schema.lookup('org.gnome.desktop.interface',True)
# 
# 		if gnome_interface is None:
# 			# not in gnome desktop environment, use 'monospace'
# 			MONOSPACE_FONT_STRING = 'monospace'
# 		else:
# 			settings = Gio.Settings.new('org.gnome.desktop.interface')
# 			MONOSPACE_FONT_STRING = settings.get_string('monospace-font-name')
# 
# 	return MONOSPACE_FONT_STRING
# 
# Path: sunflower/widgets/status_bar.py
# class StatusBar(Gtk.HBox):
# 	"""Plugin status bar"""
# 
# 	def __init__(self):
# 		GObject.GObject.__init__(self, homogeneous=False, spacing=15)
# 
# 		self.set_border_width(4)
# 		self.set_property('no-show-all', True)
# 
# 		self._icons = {}
# 		self._labels = {}
# 
# 		# create default label
# 		self._label = Gtk.Label()
# 		self._label.set_use_markup(True)
# 		self._label.set_alignment(0, 0.5)
# 		self._label.show()
# 
# 		# pack interface
# 		self.pack_end(self._label, True, True, 0)
# 
# 	def set_text(self, text, group=None):
# 		"""Set default label text"""
# 		if group is None:
# 			# set default label
# 			self._label.set_markup(text)
# 
# 		elif group in self._labels:
# 			# set specified group label
# 			self._labels[group].set_markup(text)
# 
# 	def add_group_with_icon(self, name, icon_name, value='', tooltip=None):
# 		"""Add status bar group with icon"""
# 		icon = Gtk.Image()
# 		icon.set_from_icon_name(icon_name, Gtk.IconSize.MENU)
# 		icon.show()
# 
# 		label = Gtk.Label(label=value)
# 		label.set_use_markup(True)
# 		label.set_alignment(0, 0.5)
# 		label.show()
# 
# 		# configure tooltip
# 		if tooltip is not None:
# 			label.set_tooltip_text(tooltip)
# 			icon.set_tooltip_text(tooltip)
# 
# 		# pack group
# 		hbox = Gtk.HBox(False, 3)
# 		hbox.show()
# 
# 		hbox.pack_start(icon, False, False, 0)
# 		hbox.pack_start(label, False, False, 0)
# 
# 		self.pack_start(hbox, False, False, 0)
# 
# 		# add group to local cache
# 		self._labels[name] = label
# 		self._icons[name] = icon
# 
# Path: sunflower/plugin_base/provider.py
# class Mode:
# 	READ = 0
# 	WRITE = 1
# 	APPEND = 2
# 	READ_APPEND = 3


# Path: sunflower/tools/viewer.py
import gi
import os
import chardet
import codecs
import subprocess
from gi.repository import Gio, Gtk, Gdk, Pango, GObject, GdkPixbuf
from sunflower.common import executable_exists, decode_file_name, get_monospace_font_string
from sunflower.widgets.status_bar import StatusBar
from sunflower.plugin_base.provider import Mode as FileMode
	from gi.repository import GtkSource


				code_buffer.place_cursor(code_buffer.get_start_iter())

				window = Gtk.ScrolledWindow.new()
				window.set_shadow_type(Gtk.ShadowType.NONE)
				window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
				window.add(viewer)

				# add page
				self.add_page(_('Code'), window)

		# create text page if needed
		if associations_manager.is_mime_type_subset(self._mime_type, 'text/plain'):
			# get data from the file
			raw_file = self._provider.get_file_handle(self.path, FileMode.READ)
			data = raw_file.read()
			raw_file.close()

			# create new page
			self._create_text_page(_('Text'), data)

		# create image page if needed
		if self._mime_type.startswith('image/'):
			container = Gtk.ScrolledWindow()
			container.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
			container.set_shadow_type(Gtk.ShadowType.NONE)
			viewport = Gtk.Viewport()
			image = Gtk.Image()

			# load raw data

			raw_file = provider.get_file_handle(path, FileMode.READ)