
    Vh                     v    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ  G d de
      Zd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functionaO  
module: gconftool2
author:
  - Kenneth D. Evensen (@kevensen)
short_description: Edit GNOME Configurations
description:
  - This module allows for the manipulation of GNOME 2 Configuration using C(gconftool-2). Please see the gconftool-2(1) man
    pages for more details.
seealso:
  - name: C(gconftool-2) command manual page
    description: Manual page for the command.
    link: https://help.gnome.org/admin//system-admin-guide/2.32/gconf-6.html.en

extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  key:
    type: str
    description:
      - A GConf preference key is an element in the GConf repository that corresponds to an application preference.
    required: true
  value:
    type: str
    description:
      - Preference keys typically have simple values such as strings, integers, or lists of strings and integers. This is
        ignored unless O(state=present).
  value_type:
    type: str
    description:
      - The type of value being set. This is ignored unless O(state=present).
    choices: [bool, float, int, string]
  state:
    type: str
    description:
      - The action to take upon the key/value.
    required: true
    choices: [absent, present]
  config_source:
    type: str
    description:
      - Specify a configuration source to use rather than the default path.
  direct:
    description:
      - Access the config database directly, bypassing server. If O(direct) is specified then the O(config_source) must be
        specified as well.
    type: bool
    default: false
z
- name: Change the widget font to "Serif 12"
  community.general.gconftool2:
    key: "/desktop/gnome/interface/font_name"
    value_type: "string"
    value: "Serif 12"
a  
key:
  description: The key specified in the module parameters.
  returned: success
  type: str
  sample: /desktop/gnome/interface/font_name
value_type:
  description: The type of the value that was changed.
  returned: success
  type: str
  sample: string
value:
  description:
    - The value of the preference key after executing the module or V(null) if key is removed.
    - From community.general 7.0.0 onwards it returns V(null) for a non-existent O(key), and returned V("") before that.
  returned: success
  type: str
  sample: "Serif 12"
previous_value:
  description:
    - The value of the preference key before executing the module.
    - From community.general 7.0.0 onwards it returns V(null) for a non-existent O(key), and returned V("") before that.
  returned: success
  type: str
  sample: "Serif 12"
version:
  description: Version of gconftool-2.
  type: str
  returned: always
  sample: "3.2.6"
  version_added: 10.0.0
)StateModuleHelper)gconftool2_runnerc                       e Zd ZdZdZdZdZ e e eddd       edg d	       ed
       eddddg       edd       ed
            ddddgfdddgfgd      ZdZ	d Z
d Zd Zd Zd Zy)	GConftool)value)key
value_type
gconftool2strTF)typerequiredno_log)boolfloatintstring)r   choices)r   absentpresent)r   r   r   r   )r   default)r   r   r
   statedirectconfig_sourcer   r
   r   r   r   )argument_specrequired_ifsupports_check_modec                 L   t        | j                  d      | _        | j                  j                  s'| j                  j
                  | j                  d       | j                  d      5 }|j                         \  }}}|j                         | j                  _	        d d d        | j                  j                  d| j                         d       | j                  j                  d| j                  j                         | j                  j                  d| j                  j                  d	d
       | j                  j                  d| j                  j                         | j                  j                  d| j                  j                  d       y # 1 sw Y   xY w)NT)check_rcz@If the "config_source" is specified then "direct" must be "true"versionprevious_valuefactr   _valueF)outputchanger
   )initial_valueplaybook_value)r   modulerunnervarsr   r   do_raiserunstripr"   set_getr   r#   set_metar
   )selfctxrcouterrs        p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/gconftool2.py__init_module__zGConftool.__init_module__   s    'dCyyDII$;$;$GMM\][[# 	,s779LBS #		DII	, 			&		$?		lDII$8$89		h		 8 8tT		7$))2J2JK		&		dC	, 	,s   +4FF#c                       fd}|S )Nc                     |r$r"j                  d|j                         z         |j                         }|dk(  rd n|j                  _        j                  j                  S )Nz!gconftool-2 failed with error:
%s )r.   r0   rstripr-   r
   )r6   r7   r8   fail_on_errr4   s      r9   processz(GConftool._make_process.<locals>.process   sL    {BSYY[PQ**,C&)RidSDIIO99??"     )r4   r?   r@   s   `` r9   _make_processzGConftool._make_process   s    	# rA   c                 f    | j                  d| j                  d            j                  d      S )N	state keyFoutput_processget)r   )r,   rC   r/   )r4   s    r9   r2   zGConftool._get   s/    {{;t7I7I%7P{QUU\aUbbrA   c                 @   | j                  d| j                  d            5 }|j                          | j                  j	                  d|j
                  d       d d d        | j                  j	                  dd d	       d | j                  _        y # 1 sw Y   9xY w)
NrE   FrF   run_info   	verbosity	new_valueTr$   )r,   rC   r/   r-   r1   rJ   r&   r4   r5   s     r9   state_absentzGConftool.state_absent   s    [[T5G5G5N[O 	ASVGGIIIMM*cllaM@	A 			k4d3				A 	As   9BBc                    | j                  d| j                  d            5 }|j                          | j                  j	                  d|j
                  d       d d d        | j                  j	                  d| j                         d       | j                  j                  | j                  _        y # 1 sw Y   [xY w)	Nz/direct config_source value_type state key valueTrF   rJ   rK   rL   rN   r$   )	r,   rC   r/   r-   r1   rJ   r2   rN   r&   rO   s     r9   state_presentzGConftool.state_present   s    [[J[_[m[mnr[s[t 	Ax{GGIIIMM*cllaM@	A 			k499;T:99..				A 	As   9B66B?N)__name__
__module____qualname__diff_paramsoutput_paramsfacts_params
facts_namedictr+   use_old_vardictr:   rC   r2   rP   rR   rB   rA   r9   r	   r	   o   s    K)M(LJ%$u=0RSE"ED8Y:OPVU3E*
 i'<!89to./
 !F ODc /rA   r	   c                  ,    t         j                          y )N)r	   executerB   rA   r9   mainr^      s    rA   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNHansible_collections.community.general.plugins.module_utils.module_helperr   Eansible_collections.community.general.plugins.module_utils.gconftool2r   r	   r^   rS   rB   rA   r9   <module>rg      sZ    A @4l
B g c=/! =/@ zF rA   