HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/DistUpgrade/__pycache__/ReleaseNotesViewer.cpython-38.pyc
U

B��]��@s�ddlmZddlmZmZmZddlZddlZdd�ZGdd�dej�Z	e
dkr�e��Ze	e
d	����Ze�e�e��e��dS)
�)�Pango)�Gtk�GObject�GdkNcCs�tj�d�rd|g}n4tj�d�r,d|g}ntj�d�rBd|g}nd|g}t��dkrvd	tjkrvd
dtjd	g|}n0t��dkr�dtjkr�d
d
ddtjdg|}t�|�dS)z#Open the specified URL in a browserz/usr/bin/xdg-openzxdg-openz/usr/bin/exo-openzexo-openz/usr/bin/gnome-openz
gnome-openz
x-www-browserrZ	SUDO_USERZsudoz-uZ
PKEXEC_UIDz-H�#N)�os�path�exists�getuid�environ�
subprocess�Popen)�urlZcommand�r�@/usr/lib/python3/dist-packages/DistUpgrade/ReleaseNotesViewer.py�open_url!s 


��rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ReleaseNotesViewercCs�tj�|�d|_d|_|�dd�|�d�|�t�d��t	�
�|_|�|j�|j�
|�|�d|j�|�d|j�|�d|j�|��dS)	z�Init the ReleaseNotesViewer as an Inheritance of the Gtk.TextView.
           Load the notes into the buffer and make links clickableFTZeditableZ	monospacezbutton-press-eventzmotion-notify-eventzvisibility-notify-eventN)r�__init__�hovering�firstZset_propertyZset_cursor_visibleZmodify_fontrZFontDescriptionrZ
TextBuffer�bufferZ
set_bufferZset_textZconnect�button_press_event�motion_notify_event�visibility_notify_event�search_links)�selfZnotesrrrr6s

zReleaseNotesViewer.__init__cCs0|jjddtjjd�}||_|j�|||�dS)z@Apply the tag that marks links to the specified buffer selectionNZblue)Z
foregroundZ	underline)rZ
create_tagrZ	UnderlineZSINGLErZ	apply_tag)r�start�endr�tagrrr�tag_linkKs

�zReleaseNotesViewer.tag_linkcCs�|j�d�}|�dtjjd�}|s$q||\}}|��}|��r^|�|�}|dkrTq^nq^|��}q4|�|�}|�	|||�|}qdS)zlSearch for http URLs in the buffer and call the tag_link method
           for each one to tag them as linksrzhttp://N)� �)�]�
�	)
rZget_iter_at_offsetZforward_searchrZTextSearchFlagsZVISIBLE_ONLY�copyZforward_charZget_textr)r�iterZretZmatch_startZ	match_endZ	match_tmp�textrrrrrRs$�


zReleaseNotesViewer.search_linkscCs�|jdkrdSz|j��\}}Wntk
r4YnX|��|��krJdS|�tjjt	|j
�t	|j��\}}|�||�}|�
�}|D]$}	t|	dd�}
|
dkr�t|
�q�q�dS)zcallback for mouse click events�FrN�)ZbuttonrZget_selection_bounds�
ValueErrorZ
get_offset�window_to_buffer_coordsr�TextWindowType�WIDGET�int�x�y�get_iter_at_location�get_tags�getattrr)r�	text_view�eventrrr/r0r&�tagsrrrrrrqs&

�z%ReleaseNotesViewer.button_press_eventcCsD|�tjjt|j�t|j��\}}|�||�|�tjj	��
�dS)z{callback for the mouse movement event, that calls the
           check_hovering method with the mouse postition coordiantesF)r+rr,r-r.r/r0�check_hovering�
get_window�TEXT�get_pointer)rr4r5r/r0rrrr�s
�z&ReleaseNotesViewer.motion_notify_eventc
CsD|�tjj�}|��\}}}}|�tjj||�\}}	|�||	�dS)z�callback if the widgets gets visible (e.g. moves to the foreground)
           that calls the check_hovering method with the mouse position
           coordinatesF)r8rr,r9r:r+r-r7)
rr4r5ZwindowZscreenZwxZwy�modZbxZbyrrrr�s�z*ReleaseNotesViewer.visibility_notify_eventcCs�d}|�||�}|��}|D] }t|dd�}|dkrd}q>q||jksN|jr�d|_||_|jr�|�tjj��	t
j�t
j
j��n |�tjj��	t
j�t
j
j��dS)zRCheck if the mouse is above a tagged link and if yes show
           a hand cursorFrNr)T)r1r2r3rrr8rr,r9Z
set_cursorrZCursor�newZ
CursorTypeZHAND2ZLEFT_PTR)rr/r0Z	_hoveringr&r6rrrrrr7�s$��z!ReleaseNotesViewer.check_hoveringN)
�__name__�
__module__�__qualname__rrrrrrr7rrrrr5s	r�__main__z"../DistUpgrade/ReleaseAnnouncement)Z
gi.repositoryrrrrrrrZTextViewrr=ZWindow�win�open�read�rv�addZshow_all�mainrrrr�<module>s