ó
dòôdc           @` sá   d  Z  d d l m Z m Z m Z m Z d d l Td d l Z d d l Z e j	 d ƒ d d l
 Z
 d d l m Z d d l m Z d e
 j e d e d „ Z d d e d	 „ Z d d
 „ Z d d „ Z d d „ Z d „  Z d S(   u%   Functions to display message dialogs.i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   *Nu   2.0(   t	   pygimplib(   t
   exceptionsc         C` s=   t  j j |  | d t  j j d | d | d | d | d | ƒS(   Nt   titlet   parentt   buttonst   message_in_text_viewt   button_response_id_to_focust   message_markup(   t   pgt   guit   display_messaget   configt   PLUGIN_TITLE(   t   messaget   message_typeR   R	   R
   R   R   (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyR      s    	c         C` sƒ   | d  k r t d ƒ } n  t j j d t j j d t j j d | d t j d |  d | d | d	 | d
 t j j	 d | d t
 ƒ d  S(   NuŽ   If you believe this is an error in the plug-in, you can help fix it by sending a report with the text in the details to one of the sites belowR   t   app_nameR   R   R   t   message_secondary_markupt   detailst   display_details_initiallyt   report_uri_listt   report_descriptiont   focus_on_button(   t   Nonet   _R   R   t   display_alert_messageR   R   t   gtkt   MESSAGE_WARNINGt   BUG_REPORT_URL_LISTt   True(   t   main_messaget   failure_messageR   R   R   R   (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt   display_failure_message&   s    	c         C` s2   t  t d ƒ d t |  ƒ d t j ƒ  d | ƒd  S(   Nu&   There was a problem during processing:R#   R   R   (   R$   R   t   strt	   tracebackt
   format_exc(   t	   exceptionR   (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt"   display_processing_failure_message<   s
    c         C` s,   t  t d ƒ d d d t j ƒ  d |  ƒd  S(   NuŒ   There was a problem during processing. Do not close the image during processing, keep it open until the processing is finished successfully.R#   u    R   R   (   R$   R   R&   R'   (   R   (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt%   display_invalid_image_failure_messageD   s
    c         C` s,   t  |  d d d | d | d t d ƒ ƒd  S(   NR#   u    R   R   R   u›   If you believe this is an error in the plug-in, you can help fix it by sending a report with the file and the text in the details to one of the sites below(   R$   R   (   R"   R   R   (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt.   display_import_export_settings_failure_messageN   s    c         C` s  t  |  t j ƒ r( |  j |  j } } n |  \ } } d | j k ra d | j k ra t d ƒ ‚ n  | d  k	 rÃ d | j k r‹ t d ƒ } n d | j k r© t d ƒ } n  | j	 | d j
 | j ƒ Sd | j k rá t d ƒ } n d | j k rÿ t d ƒ } n  | j	 | d j
 ƒ Sd  S(	   Nu	   procedureu
   constraintu7   an action must have the "procedure" or "constraint" tagu/   Failed to apply procedure "{}" on "{}" because:u0   Failed to apply constraint "{}" on "{}" because:u   display_nameu'   Failed to apply procedure "{}" because:u(   Failed to apply constraint "{}" because:(   t
   isinstanceR   t   ActionErrort   actiont   itemt   tagst
   ValueErrorR   R   t   formatt   valuet	   orig_name(   t   action_and_item_or_action_errorR.   R/   t   message_template(    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt   get_failing_action_messageY   s     (   t   __doc__t
   __future__R    R   R   R   t   future.builtinsR&   t   pygtkt   requireR   t   export_layersR   R   R   R   t
   BUTTONS_OKt   FalseR   R$   R)   R*   R+   R7   (    (    (    sD   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/gui/messages.pyt   <module>   s&   "

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 # -*- coding: utf-8 -*-

"""Widget for placeholder GIMP objects (images, layers) such as "Current layer".

During processing, these placeholders are replaced with real objects.
"""

from __future__ import absolute_import, division, print_function, unicode_literals
from future.builtins import *

import gimpui

from export_layers import pygimplib as pg


class GimpObjectPlaceholdersComboBoxPresenter(pg.setting.GtkPresenter):
  """
  This class is a `setting.presenter.Presenter` subclass for
  `gimpui.IntComboBox` elements used for `placeholders.PlaceholderSetting`.
  
  Value: `placeholders.PlaceholderSetting` instance selected in the combo box.
  """
  
  _VALUE_CHANGED_SIGNAL = 'changed'
  
  def _create_gui_element(self, setting):
    placeholder_names_and_values = []
    
    for index, placeholder in enumerate(setting.get_allowed_placeholders()):
      placeholder_names_and_values.extend(
        (pg.utils.safe_encode_gtk(placeholder.display_name), index))
    
    return gimpui.IntComboBox(tuple(placeholder_names_and_values))
  
  def _get_value(self):
    return self._setting.get_allowed_placeholder_names()[self._element.get_active()]
  
  def _set_value(self, value):
    self._element.set_active(self._setting.get_allowed_placeholder_names().index(value))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        