>Ic.ddlmZddlmZmZmZddlZddlZdZGddejZ e dk(r`ejZ e e djZe j!ee j#ej$yy) )Pango)GtkGObjectGdkNc tjjdrd|g}nLtjjdrd|g}n(tjjdrd|g}nd|g}tjdk(r,d tjvrd d tjd g|z}nFtjdk(r/d tjvrd d d dtjd zg|z}t j |y)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_USERsudoz-u PKEXEC_UIDz-H#N)ospathexistsgetuidenviron subprocessPopen)urlcommands @/usr/lib/python3/dist-packages/DistUpgrade/ReleaseNotesViewer.pyopen_urlr!s ww~~)*s# + ,s# - .%"C( yy{aK2::54K!89GC  lbjj84L1135<=Wc6eZdZdZdZdZdZdZdZdZ y) ReleaseNotesViewercRtjj|d|_d|_|j dd|j d|j tjdtj|_ |j|j|jj||jd|j|jd|j |jd|j"|j%y) zInit the ReleaseNotesViewer as an Inheritance of the Gtk.TextView. Load the notes into the buffer and make links clickableFTeditable monospacezbutton-press-eventzmotion-notify-eventzvisibility-notify-eventN)r__init__hoveringfirst set_propertyset_cursor_visible modify_fontrFontDescriptionr TextBufferbuffer set_bufferset_textconnectbutton_press_eventmotion_notify_eventvisibility_notify_event search_links)selfnotess rrzReleaseNotesViewer.__init__6s   &   *e, & ..{;<nn&   $ U# )4+B+BC *D,D,DE .0L0LM rc|jjddtjj}||_|jj |||y)z@Apply the tag that marks links to the specified buffer selectionNblue) foreground underline)r% create_tagr UnderlineSINGLEr apply_tag)r-startendrtags rtag_linkzReleaseNotesViewer.tag_linkKsJkk$$Tf/4/E/E%G c5#.rc|jjd} |jdtjj d}|sy|\}}|j } |jr|j|}|dvrnn|j }8|j|}|j||||})zlSearch for http URLs in the buffer and call the tag_link method for each one to tag them as linksrzhttp://N) )]  ) r%get_iter_at_offsetforward_searchrTextSearchFlags VISIBLE_ONLYcopy forward_charget_textr:)r-iterret match_start match_end match_tmptextrs rr,zReleaseNotesViewer.search_linksRs{{--a0%%i&)&9&9&F&F&*,C'* $[)!(I))+$--i8D::%NN, &&y1C MM+y# 6D1rc|jdk7ry |jj\}}|j|jk7ry|j t jjt|jt|j\}}|j||}|j}|D]!} t| dd} | dk7st| yy#t$rYwxYw)zcallback for mouse click eventsFrN)buttonr%get_selection_bounds get_offset ValueErrorwindow_to_buffer_coordsrTextWindowTypeWIDGETintxyget_iter_at_locationget_tagsgetattrr) r- text_vieweventr7r8rYrZrHtagsr9rs rr)z%ReleaseNotesViewer.button_press_eventqs <<1  ;;;;=LUC!S^^%55--c.@.@.G.G.1%''lCLJA((A.}} C#ud+Cby      sC.. C:9C:c>|jtjjt |j t |j \}}|j|||jtjjjy)z{callback for the mouse movement event, that calls the check_hovering method with the mouse postition coordiantesF) rUrrVrWrXrYrZcheck_hovering get_windowTEXT get_pointer)r-r^r_rYrZs rr*z&ReleaseNotesViewer.motion_notify_eventsp001C1C1J1J14UWWs577|M1 Aq! **//0<<>rc|jtjj}|j \}}}}|j tjj ||\}} |j|| y)zcallback if the widgets gets visible (e.g. moves to the foreground) that calls the check_hovering method with the mouse position coordinatesF)rcrrVrdrerUrWrb) r-r^r_windowscreenwxwymodbxbys rr+z*ReleaseNotesViewer.visibility_notify_eventsq%%c&8&8&=&=> & 2 2 4R44    % %r2/R B#rcd}|j||}|j}|D]}t|dd}|dk7sd}n||jk7s |jrd|_||_|jrn|j t jjjtjjtjjy|j t jjjtjjtjjyy)zRCheck if the mouse is above a tagged link and if yes show a hand cursorFrNrPT)r[r\r]rrrcrrVrd set_cursorrCursornew CursorTypeHAND2LEFT_PTR)r-rYrZ _hoveringrHr`r9rs rrbz!ReleaseNotesViewer.check_hoverings ((A.}} C#ud+Cby     %DJ%DM}} 2 2 7 78CCJJNN3>>#7#78: 2 2 7 78CCJJNN3>>#:#:;=*4rN) __name__ __module__ __qualname__rr:r,r)r*r+rbrrrr5s%*/>6 =rr__main__z"../DistUpgrade/ReleaseAnnouncement) gi.repositoryrrrrr rrTextViewrrvWindowwinopenreadrvaddshow_allmainryrrrs6 ++ (D=D=N z #**,C D!EFKKM NBGGBKLLN CHHJ r