# Path: sunflower/widgets/breadcrumbs.py
# class Breadcrumbs:
# 	"""Linked list of buttons navigating to different paths."""
# 
# 	def __init__(self, parent):
# 		self.container = Gtk.ScrolledWindow.new()
# 		self.container.set_overlay_scrolling(True)
# 		self.container.set_placement(Gtk.CornerType.TOP_RIGHT)
# 		self.container.get_hscrollbar().hide()
# 
# 		self.box = Gtk.HBox.new(False, 0)
# 		self.container.add_with_viewport(self.box)
# 
# 		# change the look of container
# 		self.container.set_focus_on_click(False)
# 		self.container.get_style_context().add_class('sunflower-breadcrumbs')
# 
# 		self._path = None
# 		self._parent = parent
# 		self._updating = False
# 		self._group = None
# 
# 		self.container.show_all()
# 
# 	def __fragment_click(self, widget, data=None):
# 		"""Handle clicking on path fragment."""
# 		if self._updating:
# 			return
# 
# 		# ignore non active buttons
# 		if not widget.props.active:
# 			return
# 
# 		# change path
# 		file_list = self._parent._parent
# 		if hasattr(file_list, 'change_path'):
# 			file_list.change_path(widget.path)
# 
# 	def _focus_fragment(self, fragment, is_new=True):
# 		"""Set fragment as active and present it to user."""
# 		allocation = fragment.get_allocation()
# 		adjustment = self.container.get_hadjustment()
# 		container_size = self.container.get_allocation().width
# 
# 		if is_new:
# 			position = adjustment.get_upper()
# 		elif allocation.x + allocation.width > container_size:
# 			position = allocation.x + allocation.width + 20
# 		else:
# 			position = 0
# 
# 		adjustment.set_value(position)
# 		fragment.set_active(True)
# 
# 	def set_state(self, state):
# 		"""Set widget state."""
# 		self._state = state
# 
# 	def refresh(self, path):
# 		"""Update buttons on directory change."""
# 		provider = self._parent._parent.get_provider()
# 
# 		# prevent signal dead-loops
# 		self._updating = True
# 
# 		if self._path is not None and self._path.startswith(path):
# 			# path is a subset, update highlight and exit
# 			for control in self.box.get_children():
# 				if control.path == path:
# 					self._focus_fragment(control, is_new=False)
# 					break
# 
# 		else:
# 			# prepare for parsing
# 			self._path = path
# 			self.box.foreach(self.box.remove)
# 
# 			# split root element from others
# 			root_element = provider.get_root_path(path)
# 			other_elements = path[len(root_element):]
# 
# 			# make sure our path doesn't begin with slash
# 			if other_elements.startswith(os.path.sep):
# 				other_elements = other_elements[1:]
# 
# 			# split elements
# 			elements = other_elements.split(os.path.sep)
# 			elements.insert(0, root_element)
# 
# 			# create controls
# 			control = None
# 			current_path = None
# 			for element in elements:
# 				current_path = os.path.join(current_path, element) if current_path is not None else element
# 				control = Fragment(decode_file_name(element), current_path, self.__fragment_click, control)
# 				self.box.pack_start(control, False, False, 0)
# 
# 			if control is not None:
# 				GObject.idle_add(self._focus_fragment, control, is_new=True)
# 
# 		# prevent signal dead-loops
# 		self._updating = False
# 
# Path: sunflower/widgets/context_menu.py
# class ContextMenu:
# 	"""Interface which shows options and information related to current path."""
# 
# 	def __init__(self, parent, relative_to):
# 		self._parent = parent
# 
# 		# create popover interface
# 		self._popover = Gtk.Popover.new()
# 		self._popover.set_relative_to(relative_to)
# 		self._popover.set_position(Gtk.PositionType.BOTTOM)
# 
# 		# create widget container
# 		self._container = Gtk.VBox.new(False, 10)
# 		self._container.set_border_width(10)
# 
# 		# show all widgets inside of container
# 		self._container.show_all()
# 
# 		# pack interface
# 		self._popover.add(self._container)
# 
# 	def add_control(self, control, fill=False, spacing=0):
# 		"""Add specified control to the context menu."""
# 		control.show_all()
# 		self._container.pack_start(control, fill, False, spacing)
# 
# 	def show(self):
# 		"""Show context menu for current directory."""
# 		self._popover.popup()
# 
# Path: sunflower/common.py
# 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))


import math
from gi.repository import Gtk, Pango, Gdk
from sunflower.widgets.breadcrumbs import Breadcrumbs
from sunflower.widgets.context_menu import ContextMenu
from sunflower.common import decode_file_name
from __future__ import absolute_import




class Mode:
	NORMAL = 0

# Path: sunflower/widgets/breadcrumbs.py
# class Breadcrumbs:
# 	"""Linked list of buttons navigating to different paths."""
# 
# 	def __init__(self, parent):
# 		self.container = Gtk.ScrolledWindow.new()
# 		self.container.set_overlay_scrolling(True)
# 		self.container.set_placement(Gtk.CornerType.TOP_RIGHT)
# 		self.container.get_hscrollbar().hide()
# 
# 		self.box = Gtk.HBox.new(False, 0)
# 		self.container.add_with_viewport(self.box)
# 
# 		# change the look of container
# 		self.container.set_focus_on_click(False)
# 		self.container.get_style_context().add_class('sunflower-breadcrumbs')
# 
# 		self._path = None
# 		self._parent = parent
# 		self._updating = False
# 		self._group = None
# 
# 		self.container.show_all()
# 
# 	def __fragment_click(self, widget, data=None):
# 		"""Handle clicking on path fragment."""
# 		if self._updating:
# 			return
# 
# 		# ignore non active buttons
# 		if not widget.props.active:
# 			return
# 
# 		# change path
# 		file_list = self._parent._parent
# 		if hasattr(file_list, 'change_path'):
# 			file_list.change_path(widget.path)
# 
# 	def _focus_fragment(self, fragment, is_new=True):
# 		"""Set fragment as active and present it to user."""
# 		allocation = fragment.get_allocation()
# 		adjustment = self.container.get_hadjustment()
# 		container_size = self.container.get_allocation().width
# 
# 		if is_new:
# 			position = adjustment.get_upper()
# 		elif allocation.x + allocation.width > container_size:
# 			position = allocation.x + allocation.width + 20
# 		else:
# 			position = 0
# 
# 		adjustment.set_value(position)
# 		fragment.set_active(True)
# 
# 	def set_state(self, state):
# 		"""Set widget state."""
# 		self._state = state
# 
# 	def refresh(self, path):
# 		"""Update buttons on directory change."""
# 		provider = self._parent._parent.get_provider()
# 
# 		# prevent signal dead-loops
# 		self._updating = True
# 
# 		if self._path is not None and self._path.startswith(path):
# 			# path is a subset, update highlight and exit
# 			for control in self.box.get_children():
# 				if control.path == path:
# 					self._focus_fragment(control, is_new=False)
# 					break
# 
# 		else:
# 			# prepare for parsing
# 			self._path = path
# 			self.box.foreach(self.box.remove)
# 
# 			# split root element from others
# 			root_element = provider.get_root_path(path)
# 			other_elements = path[len(root_element):]
# 
# 			# make sure our path doesn't begin with slash
# 			if other_elements.startswith(os.path.sep):
# 				other_elements = other_elements[1:]
# 
# 			# split elements
# 			elements = other_elements.split(os.path.sep)
# 			elements.insert(0, root_element)
# 
# 			# create controls
# 			control = None
# 			current_path = None
# 			for element in elements:
# 				current_path = os.path.join(current_path, element) if current_path is not None else element
# 				control = Fragment(decode_file_name(element), current_path, self.__fragment_click, control)
# 				self.box.pack_start(control, False, False, 0)
# 
# 			if control is not None:
# 				GObject.idle_add(self._focus_fragment, control, is_new=True)
# 
# 		# prevent signal dead-loops
# 		self._updating = False
# 
# Path: sunflower/widgets/context_menu.py
# class ContextMenu:
# 	"""Interface which shows options and information related to current path."""
# 
# 	def __init__(self, parent, relative_to):
# 		self._parent = parent
# 
# 		# create popover interface
# 		self._popover = Gtk.Popover.new()
# 		self._popover.set_relative_to(relative_to)
# 		self._popover.set_position(Gtk.PositionType.BOTTOM)
# 
# 		# create widget container
# 		self._container = Gtk.VBox.new(False, 10)
# 		self._container.set_border_width(10)
# 
# 		# show all widgets inside of container
# 		self._container.show_all()
# 
# 		# pack interface
# 		self._popover.add(self._container)
# 
# 	def add_control(self, control, fill=False, spacing=0):
# 		"""Add specified control to the context menu."""
# 		control.show_all()
# 		self._container.pack_start(control, fill, False, spacing)
# 
# 	def show(self):
# 		"""Show context menu for current directory."""
# 		self._popover.popup()
# 
# Path: sunflower/common.py
# 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))


# Path: sunflower/widgets/title_bar.py
import math
from gi.repository import Gtk, Pango, Gdk
from sunflower.widgets.breadcrumbs import Breadcrumbs
from sunflower.widgets.context_menu import ContextMenu
from sunflower.common import decode_file_name

from __future__ import absolute_import




class Mode:
	NORMAL = 0

	SUPER_USER = 1