0x1949 Team - FAZEMRX - MANAGER
Edit File: ReleaseNotesViewer.cpython-310.pyc
o >I�c� � @ s� d dl mZ d dl mZmZmZ d dlZd dlZdd� ZG dd� dej�Z e dkrDe�� Ze e d ��� �Ze�e� e�� e�� dS dS ) � )�Pango)�Gtk�GObject�GdkNc C s� t j�d�rd| g}nt j�d�rd| g}nt j�d�r!d| g}nd| g}t �� dkr;d t jv r;d dt jd g| }nt �� dkrSdt jv rSd d ddt jd 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-browserr � SUDO_USER�sudoz-u� PKEXEC_UIDz-H�#N)�os�path�exists�getuid�environ� subprocess�Popen)�url�command� r �@/usr/lib/python3/dist-packages/DistUpgrade/ReleaseNotesViewer.py�open_url! s ��r c @ sD e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dS )�ReleaseNotesViewerc C s� t j �| � 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 clickableFT�editable� monospacezbutton-press-eventzmotion-notify-eventzvisibility-notify-eventN)r �__init__�hovering�first�set_property�set_cursor_visible�modify_fontr �FontDescriptionr � TextBuffer�buffer� set_buffer�set_text�connect�button_press_event�motion_notify_event�visibility_notify_event�search_links)�self�notesr r r r 6 s zReleaseNotesViewer.__init__c C s0 | j jddtjjd�}||_| j �|||� dS )z@Apply the tag that marks links to the specified buffer selectionN�blue)� foreground� underline)r! � create_tagr � Underline�SINGLEr � apply_tag)r) �start�endr �tagr r r �tag_linkK s �zReleaseNotesViewer.tag_linkc C s� | j �d�} |�dtjjd�}|sdS |\}}|�� } |�� r,|�|�}|dv r+nnn|�� }q|�|�}| � |||� |}q)zlSearch for http URLs in the buffer and call the tag_link method for each one to tag them as linksr � zhttp://N)� �)�]� � ) r! �get_iter_at_offset�forward_searchr �TextSearchFlags�VISIBLE_ONLY�copy�forward_char�get_textr5 )r) �iter�ret�match_start� match_end� match_tmp�textr r r r r( R s. � �� �zReleaseNotesViewer.search_linksc C s� |j dkrdS z | j�� \}}W n ty Y nw |�� |�� kr$dS | �tjjt |j �t |j��\}}| �||�}|� � }|D ]} t| dd�} | dkrTt| � dS qAdS )zcallback for mouse click eventsr6 Fr N� )�buttonr! �get_selection_bounds� ValueError� get_offset�window_to_buffer_coordsr �TextWindowType�WIDGET�int�x�y�get_iter_at_location�get_tags�getattrr )r) � text_view�eventr2 r3 rR rS rC �tagsr4 r r r r r% q s* � ���z%ReleaseNotesViewer.button_press_eventc C sD |� tjjt|j�t|j��\}}| �||� | �tjj �� � dS )z{callback for the mouse movement event, that calls the check_hovering method with the mouse postition coordiantesF)rN r rO rP rQ rR rS �check_hovering� get_window�TEXT�get_pointer)r) rW rX rR rS r r r r&