markdown.py 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. #####################################################################
  2. # #
  3. # THIS IS A SOURCE CODE FILE FROM A PROGRAM TO INTERACT WITH THE #
  4. # LBRY PROTOCOL ( lbry.com ). IT WILL USE THE LBRY SDK ( lbrynet ) #
  5. # FROM THEIR REPOSITORY ( https://github.com/lbryio/lbry-sdk ) #
  6. # WHICH I GONNA PRESENT TO YOU AS A BINARY. SINCE I DID NOT DEVELOP #
  7. # IT AND I'M LAZY TO INTEGRATE IN A MORE SMART WAY. THE SOURCE CODE #
  8. # OF THE SDK IS AVAILABLE IN THE REPOSITORY MENTIONED ABOVE. #
  9. # #
  10. # ALL THE CODE IN THIS REPOSITORY INCLUDING THIS FILE IS #
  11. # (C) J.Y.Amihud and Other Contributors 2021. EXCEPT THE LBRY SDK. #
  12. # YOU CAN USE THIS FILE AND ANY OTHER FILE IN THIS REPOSITORY UNDER #
  13. # THE TERMS OF GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER #
  14. # VERSION. TO FIND THE FULL TEXT OF THE LICENSE GO TO THE GNU.ORG #
  15. # WEBSITE AT ( https://www.gnu.org/licenses/gpl-3.0.html ). #
  16. # #
  17. # THE LBRY SDK IS UNFORTUNATELY UNDER THE MIT LICENSE. IF YOU ARE #
  18. # NOT INTENDING TO USE MY CODE AND JUST THE SDK. YOU CAN FIND IT ON #
  19. # THEIR OFFICIAL REPOSITORY ABOVE. THEIR LICENSE CHOICE DOES NOT #
  20. # SPREAD ONTO THIS PROJECT. DON'T GET A FALSE ASSUMPTION THAT SINCE #
  21. # THEY USE A PUSH-OVER LICENSE, I GONNA DO THE SAME. I'M NOT. #
  22. # #
  23. # THE LICENSE CHOSEN FOR THIS PROJECT WILL PROTECT THE 4 ESSENTIAL #
  24. # FREEDOMS OF THE USER FURTHER, BY NOT ALLOWING ANY WHO TO CHANGE #
  25. # THE LICENSE AT WILL. SO NO PROPRIETARY SOFTWARE DEVELOPER COULD #
  26. # TAKE THIS CODE AND MAKE THEIR USER-SUBJUGATING SOFTWARE FROM IT. #
  27. # #
  28. #####################################################################
  29. import os
  30. from subprocess import *
  31. from gi.repository import Gtk
  32. from gi.repository import Gdk
  33. from gi.repository import Pango
  34. from flbry import ui
  35. from flbry import parse
  36. from flbry import fetch
  37. ################################################################################
  38. # Markdown. Or .md file format is an easy way to give your simple text documents
  39. # a bit of flare. Stuff like links, images and quotes are supported. Also bold
  40. # an italic characters.
  41. EMOJIS ={ # SIZE | LINK
  42. ":alien:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Alien%402x.png)",
  43. ":angry_1:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/angry%402x.png)",
  44. ":angry_2:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/angry%202%402x.png)",
  45. ":angry_3:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/angry%203%402x.png)",
  46. ":angry_4:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/angry%204%402x.png)",
  47. ":blind:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/blind%402x.png)",
  48. ":block:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/block%402x.png)",
  49. ":bomb:" :"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/bomb%402x.png)",
  50. ":brain_chip:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Brain%20chip%402x.png)",
  51. ":confirm:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/CONFIRM%402x.png)",
  52. ":confused_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/confused%402x-1.png)",
  53. ":confused_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/confused%402x.png)",
  54. ":cooking_something_nice:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cooking%20something%20nice%402x.png)",
  55. ":cry_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cry%402x.png)",
  56. ":cry_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cry%202%402x.png)",
  57. ":cry_3:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cry%203%402x.png)",
  58. ":cry_4:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cry%204%402x.png)",
  59. ":cry_5:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/cry%205%402x.png)",
  60. ":donut:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/donut%402x.png)",
  61. ":eggplant_with_condom:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/eggplant%20with%20condom%402x.png)",
  62. ":eggplant:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/eggplant%402x.png)",
  63. ":fire_up:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/fire%20up%402x.png)",
  64. ":flat_earth:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Flat%20earth%402x.png)",
  65. ":flying_saucer:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Flying%20saucer%402x.png)",
  66. ":heart_chopper:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/heart%20chopper%402x.png)",
  67. ":hyper_troll:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/HyperTroll%402x.png)",
  68. ":ice_cream:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/ice%20cream%402x.png)",
  69. ":idk:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/IDK%402x.png)",
  70. ":illuminati_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Illuminati%402x-1.png)",
  71. ":illuminati_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Illuminati%402x.png)",
  72. ":kiss_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/kiss%402x.png)",
  73. ":kiss_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/kiss%202%402x.png)",
  74. ":laser_gun:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/laser%20gun%402x.png)",
  75. ":laughing_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Laughing%402x.png)",
  76. ":laughing_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Laughing%202%402x.png)",
  77. ":lollipop:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Lollipop%402x.png)",
  78. ":love_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Love%402x.png)",
  79. ":love_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Love%202%402x.png)",
  80. ":monster:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Monster%402x.png)",
  81. ":mushroom:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/mushroom%402x.png)",
  82. ":nail_it:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Nail%20It%402x.png)",
  83. ":no:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/NO%402x.png)",
  84. ":ouch:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/ouch%402x.png)",
  85. ":peace:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/peace%402x.png)",
  86. ":pizza:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/pizza%402x.png)",
  87. ":rabbit_hole:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/rabbit%20hole%402x.png)",
  88. ":rainbow_puke_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/rainbow%20puke%402x-1.png)",
  89. ":rainbow_puke_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/rainbow%20puke%402x.png)",
  90. ":rock:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/ROCK%402x.png)",
  91. ":sad:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/sad%402x.png)",
  92. ":salty:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/salty%402x.png)",
  93. ":scary:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/scary%402x.png)",
  94. ":sleep:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Sleep%402x.png)",
  95. ":slime_down:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/slime%20down%402x.png)",
  96. ":smelly_socks:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/smelly%20socks%402x.png)",
  97. ":smile_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/smile%402x.png)",
  98. ":smile_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/smile%202%402x.png)",
  99. ":space_chad:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/space%20chad%402x.png)",
  100. ":space_doge:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/doge%402x.png)",
  101. ":space_green_wojak:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/space%20wojak%402x-1.png)",
  102. ":space_julian:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Space%20Julian%402x.png)",
  103. ":space_red_wojak:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/space%20wojak%402x.png)",
  104. ":space_resitas:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/resitas%402x.png)",
  105. ":space_tom:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/space%20Tom%402x.png)",
  106. ":spock:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/SPOCK%402x.png)",
  107. ":star:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Star%402x.png)",
  108. ":sunny_day:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/sunny%20day%402x.png)",
  109. ":surprised:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/surprised%402x.png)",
  110. ":sweet:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/sweet%402x.png)",
  111. ":thinking_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/thinking%402x-1.png)",
  112. ":thinking_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/thinking%402x.png)",
  113. ":thumb_down:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/thumb%20down%402x.png)",
  114. ":thumb_up_1:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/thumb%20up%402x-1.png)",
  115. ":thumb_up_2:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/thumb%20up%402x.png)",
  116. ":tinfoil_hat:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/tin%20hat%402x.png)",
  117. ":troll_king:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/Troll%20king%402x.png)",
  118. ":ufo:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/ufo%402x.png)",
  119. ":waiting:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/waiting%402x.png)",
  120. ":what:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/what_%402x.png)",
  121. ":woodoo_doll:":"![20](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/emoticons/48%20px/woodo%20doll%402x.png)"
  122. }
  123. STICKERS = {
  124. # TOTALLY GRATIS
  125. "<stkr>:CAT:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/CAT/PNG/cat_with_border.png)",
  126. "<stkr>:FAIL:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/FAIL/PNG/fail_with_border.png)",
  127. "<stkr>:HYPE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/HYPE/PNG/hype_with_border.png)",
  128. "<stkr>:PANTS_1:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/PANTS/PNG/PANTS_1_with_frame.png)",
  129. "<stkr>:FIRE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/fire.png)",
  130. "<stkr>:SLIME:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/SLIME/PNG/slime_with_frame.png)",
  131. "<stkr>:PISS:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/PISS/PNG/piss_with_frame.png)",
  132. "<stkr>:BULL_RIDE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/BULL/PNG/bull-ride.png)",
  133. "<stkr>:ELIMINATED:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/ELIMINATED/PNG/eliminated.png)",
  134. "<stkr>:EGG_CARTON:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/egg_carton.png)",
  135. "<stkr>:BAN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/BAN/PNG/ban.png)",
  136. "<stkr>:MONEY_PRINTER:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/money_printer.png)",
  137. "<stkr>:MOUNT_RUSHMORE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/mount_rushmore.png)",
  138. "<stkr>:EGIRL:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/EGIRL/PNG/e-girl.png)",
  139. "<stkr>:KANYE_WEST:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/kanye_west.png)",
  140. "<stkr>:TAYLOR_SWIFT:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/taylor_swift.png)",
  141. "<stkr>:DONALD_TRUMP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/donald_trump.png)",
  142. "<stkr>:BILL_CLINTON:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/bill_clinton.png)",
  143. "<stkr>:EPSTEIN_ISLAND:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/epstein_island.png)",
  144. "<stkr>:KURT_COBAIN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/kurt_cobain.png)",
  145. "<stkr>:BILL_COSBY:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/bill_cosby.png)",
  146. "<stkr>:CHE_GUEVARA:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/che_guevara.png)",
  147. "<stkr>:CHRIS_CHAN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/MISC/PNG/chris_chan.png)",
  148. "<stkr>:PREGNANT_MAN_BLONDE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/pregnant%20man/png/Pregnant%20man_white%20border_blondie.png)",
  149. "<stkr>:PREGNANT_WOMAN_BROWN_HAIR:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/pregnant%20woman/png/Pregnant%20woman_white_border_brown%20hair.png)",
  150. "<stkr>:ROCKET_SPACEMAN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/ROCKET%20SPACEMAN/PNG/rocket-spaceman_with-border.png)",
  151. "<stkr>:SALTY:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/SALTY/PNG/salty.png)",
  152. "<stkr>:SICK_FLAME:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/SICK/PNG/sick2_with_border.png)",
  153. "<stkr>:SICK_SKULL:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/SICK/PNG/with%20borderdark%20with%20frame.png)",
  154. "<stkr>:SPHAGETTI_BATH:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/SPHAGETTI%20BATH/PNG/sphagetti%20bath_with_frame.png)",
  155. "<stkr>:THUG_LIFE:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/THUG%20LIFE/PNG/thug_life_with_border_clean.png)",
  156. "<stkr>:TRAP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TRAP/PNG/trap.png)",
  157. "<stkr>:TRASH:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TRASH/PNG/trash.png)",
  158. "<stkr>:WHUUT:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/WHUUT/PNG/whuut_with-frame.png)",
  159. # TECHNICALLY PAID ( FROM ODYSEE )
  160. "<stkr>:TIP_HAND_FLIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/tip_hand_flip_$%20_with_border.png)",
  161. "<stkr>:TIP_HAND_FLIP_COIN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/tip_hand_flip_coin_with_border.png)",
  162. "<stkr>:TIP_HAND_FILP_LBC:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/tip_hand_flip_lbc_with_border.png)",
  163. "<stkr>:COMET_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/$%20comet%20tip%20with%20border.png)",
  164. "<stkr>:SILVER_ODYSEE_COIN:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20bordersilver_odysee_coinv.png)",
  165. "<stkr>:LBC_COMET_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/LBC%20comet%20tip%20with%20border.png)",
  166. "<stkr>:SMALL_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20bordersmall$_tip.png)",
  167. "<stkr>:SMALL_LBC_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20bordersmall_LBC_tip%20.png)",
  168. "<stkr>:BITE_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/bite_$tip_with%20border.png)",
  169. "<stkr>:BITE_TIP_CLOSEUP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/bite_$tip_closeup.png)",
  170. "<stkr>:BITE_LBC_CLOSEUP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/LBC%20bite.png)",
  171. "<stkr>:MEDIUM_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20bordermedium$_%20tip.png)",
  172. "<stkr>:MEDIUM_LBC_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20bordermedium_LBC_tip%20%20%20%20%20%20%20%20%20%20.png)",
  173. "<stkr>:LARGE_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20borderlarge$tip.png)",
  174. "<stkr>:LARGE_LBC_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20borderlarge_LBC_tip%20.png)",
  175. "<stkr>:BIG_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20borderbig$tip.png)",
  176. "<stkr>:BIG_LBC_TIP:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/big_LBC_TIPV.png)",
  177. "<stkr>:FORTUNE_CHEST:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20borderfortunechest$_tip.png)",
  178. "<stkr>:FORTUNE_CHEST_LBC:<stkr>":"![100](https://thumbnails.odycdn.com/optimize/s:0:0/quality:85/plain/https://static.odycdn.com/stickers/TIPS/png/with%20borderfortunechest_LBC_tip.png)",
  179. }
  180. def Open(md):
  181. # Spliting it for the read.
  182. # EMOJIES CAN BE MORE THEN ONE IN THE TEXT
  183. for emoji in EMOJIS:
  184. md = md.replace(emoji, EMOJIS[emoji])
  185. # STICKERS ONLY ONE PER TEXT ( To make publishing from FastLBRY be compatible with
  186. # ODYSEE.COM )
  187. for sticker in STICKERS:
  188. if md == sticker:
  189. md = STICKERS[sticker]
  190. break
  191. md = "\n\n"+md
  192. md = md.split("\n")
  193. # First thing is I was to read the headings and convert it into a tree.
  194. tree = []
  195. indent = 1
  196. c = []
  197. skip = 0
  198. for n,line in enumerate(md):
  199. if skip > n:
  200. continue
  201. ty = "text"
  202. te = line
  203. # Here I want to simply get a type of each line. Later we going to parse
  204. # the links and other things. But first. Let's parse stuff based on
  205. # lines.
  206. if line.startswith("```"):
  207. # THREE ``` aka code block
  208. # This tag will block any other tags
  209. # untill it's untagged
  210. code = ""
  211. for l in md[n+1:]:
  212. if not l.startswith("```"):
  213. code = code + l + "\n"
  214. else:
  215. skip = n + code.count("\n") + 2
  216. break
  217. tree.append(["text_cm", code+"\n"])
  218. te = ""
  219. elif line.startswith("#"):
  220. # The titles of the chapter. The Headers are usually written similar
  221. # to how here in python you write comments. It's a # , space, and the
  222. # text.
  223. # The amount of hashes. ## or ### gives different sized text. Officialy
  224. # it should support up to 6 hashes. ######. But why not make it more
  225. # just in case.
  226. ty = line.count("#") # This might give bugs
  227. elif line.startswith(">"):
  228. # The > sign in the Markdown language is used for quatations.
  229. ty = "text_q"
  230. te = te[1:]
  231. tree.append([ty, te+"\n"])
  232. # Now the stage 0 is over and we parsed the basic things. Now is the hard
  233. # part to parse out all the images and stuff inside them. It's going to be
  234. # done per part. And we are going to use the same technique I used for the
  235. # conversion of the legacy projects. See : studio/story.py ( in VCStudio )
  236. # We are going to itterate over each letter. And decide what to do by that
  237. newtree = []
  238. for block in tree:
  239. if block[0] == "text_cm":
  240. newtree.append(block)
  241. continue
  242. part = ""
  243. skip = 0
  244. for n, l in enumerate(block[-1]):
  245. if skip > n:
  246. continue
  247. part = part + l
  248. # Here we are going to do something if a give condition is met.
  249. # Usually I gonna do something if [part] ends with a given markdown
  250. # thing. I don't have a manual of markdown on me. So please make it
  251. # more supported. I guess. I might forget things I rarely use.
  252. # Links are made with [stuff you click on](https://example.com)
  253. # but similar to it. Images are done ![Tooltip](Image.png)
  254. # and even weirder you can put one into the other. Like
  255. # [![Tooltip](Image.png)](https://example.com)
  256. # Which going to give you a clickable image.
  257. # For this version what we are going to do is next.
  258. # If we got [![ then it's a clickable image
  259. # If we got ![ then it's just image
  260. # and if we got [ then it's a link.
  261. if part.endswith("[!["):
  262. # IMAGE LINK
  263. newtree.append([block[0], part[:-3]])
  264. tooltip = ""
  265. imageurl = ""
  266. url = ""
  267. t = False
  268. iu = False
  269. skip = n
  270. for le in block[-1][n:]: # For letters in the rest of text
  271. skip = skip + 1
  272. if le == "]":
  273. t = True
  274. elif le == ")" and t and not iu:
  275. iu = True
  276. elif le == ")" and t and iu:
  277. break
  278. elif not t:
  279. tooltip = tooltip +le
  280. elif t and not iu:
  281. imageurl = imageurl + le
  282. else:
  283. url = url+le
  284. tooltip = tooltip[tooltip.find("[")+1:]
  285. imageurl = imageurl[imageurl.find("(")+1:]
  286. url = url[url.find("(")+1:]
  287. apnd = ["image_link", imageurl, url]
  288. newtree.append(apnd)
  289. part = ""
  290. elif part.endswith("!["):
  291. # IMAGE
  292. newtree.append([block[0], part[:-2]])
  293. tooltip = ""
  294. url = ""
  295. t = False
  296. skip = n
  297. for le in block[-1][n:]: # For letters in the rest of text
  298. skip = skip + 1
  299. if le == "]":
  300. t = True
  301. elif le == ")" and t:
  302. break
  303. elif not t:
  304. tooltip = tooltip +le
  305. else:
  306. url = url+le
  307. tooltip = tooltip[tooltip.find("[")+1:]
  308. url = url[url.find("(")+1:]
  309. apnd = ["image", tooltip, url]
  310. newtree.append(apnd)
  311. part = ""
  312. elif part.endswith("[") and not block[-1][n:].startswith('[!['):
  313. # LINK
  314. newtree.append([block[0], part[:-1]])
  315. tooltip = ""
  316. url = ""
  317. t = False
  318. skip = n
  319. for le in block[-1][n:]: # For letters in the rest of text
  320. skip = skip + 1
  321. if le == "]":
  322. t = True
  323. elif le == ")" and t:
  324. break
  325. elif not t:
  326. tooltip = tooltip +le
  327. else:
  328. url = url+le
  329. tooltip = tooltip[tooltip.find("[")+1:]
  330. url = url[url.find("(")+1:]
  331. apnd = ["link", tooltip, url]
  332. newtree.append(apnd)
  333. part = ""
  334. # Now I want to deal with `, *, ** and ***. If you want to help me you
  335. # can implement other types. Such as _, __, ___ and so on. Markdown is
  336. # a very rich language. I'm going to use the cut down version I see other
  337. # people use.
  338. # BTW this is the time. Feb 28. When I switched from Gedit to GNU Emacs.
  339. # Interesting feeling using this programm. I kind a love it even tho
  340. # so many stuff in not intuitive. Like saving is not Ctrl - S but
  341. # Ctrl - X -> Ctrl - S.
  342. # Things like Alt-; to comment multiple lines at ones is HUGE. Also it
  343. # was built by programmers for programmers. So it's a very good tool.
  344. elif part.endswith("**") and not block[-1][n+2:].startswith('*'):
  345. # DOUBLE **
  346. newtree.append([block[0], part[:-2]])
  347. if block[0] == "text":
  348. block[0] = "text_b"
  349. else:
  350. block[0] = "text"
  351. part = ""
  352. elif part.endswith("*") and not block[-1][n+1:].startswith('*'):
  353. # SINGLE *
  354. newtree.append([block[0], part[:-1]])
  355. if block[0] == "text":
  356. block[0] = "text_i"
  357. else:
  358. block[0] = "text"
  359. part = ""
  360. elif part.endswith("`"):
  361. # SINGLE `
  362. newtree.append([block[0], part[:-1]])
  363. tmpart = block[-1][n+1:]
  364. tmpart = tmpart[:tmpart.find("`")]
  365. newtree.append(["text_c", tmpart])
  366. skip = n+len(tmpart)+2
  367. block[0] = "text"
  368. part = ""
  369. newtree.append([block[0], part])
  370. #newtree.append(["text", "\n"*20+" [END OF DOCUMENT] "])
  371. tree = newtree
  372. return(tree)
  373. def search_convert(s):
  374. # This function convers a chapter name into a link
  375. # such links are use in notabug.org to link to chapters
  376. # for example example.com/file.md#chapter-name
  377. # With this url it will load the example.com/file.md and
  378. # then skip to the "Chapter Name" chapter.
  379. # This function transforms "Chapter Name" into "chapter-name"
  380. l = " ./\|[]{}()?!@#$%^&*`~:;'\"=,<>"
  381. s = s.lower().replace(" ","-")
  382. r = ""
  383. for i in s:
  384. if i not in l:
  385. r = r + i
  386. return r
  387. def convert(win, text_view, imwidth=800):
  388. text_buffer = text_view.get_buffer()
  389. st = text_buffer.get_start_iter()
  390. en = text_buffer.get_end_iter()
  391. text = text_buffer.get_text(st, en, True)
  392. text_buffer.set_text("")
  393. try:
  394. text_buffer.create_tag("text", justification=Gtk.Justification.FILL, left_margin=64, right_margin=64)
  395. text_buffer.create_tag("text_c", background="#eeeeee", foreground="#000000", font="Monospace", left_margin=64, right_margin=64, justification=Gtk.Justification.LEFT)
  396. text_buffer.create_tag("text_b", font="Bold", justification=Gtk.Justification.FILL, left_margin=64, right_margin=64)
  397. text_buffer.create_tag("text_i", font="Italic", justification=Gtk.Justification.FILL, left_margin=64, right_margin=64)
  398. text_buffer.create_tag("text_q", justification=Gtk.Justification.FILL, left_margin=200, right_margin=200)
  399. text_buffer.create_tag("header", size_points=30, justification=Gtk.Justification.CENTER, left_margin=64, right_margin=64)
  400. except:
  401. pass
  402. text_view.set_justification(Gtk.Justification.CENTER)
  403. md = Open(text)
  404. markup = ""
  405. for i in md:
  406. en = text_buffer.get_end_iter()
  407. if type(i[0]) == str and i[0].startswith("text") and not i[0] == "text_cm":
  408. if i[-1].startswith("___") or i[-1].startswith("---"):
  409. # Inspired by ( and partially copied from ) LBRY-GTK by MorsMortium
  410. text_buffer.insert(en, "\n---")
  411. anchor = Gtk.TextChildAnchor()
  412. text_buffer.insert_child_anchor(en, anchor)
  413. def Expand(Widget, Discard):
  414. Width = text_view.get_allocated_width()
  415. Widget.set_size_request(Width, -1)
  416. B = Gtk.Box()
  417. Separator = Gtk.HSeparator()
  418. B.pack_start(Separator, 1,1,1)
  419. B.connect("draw", Expand)
  420. text_view.add_child_at_anchor(B , anchor)
  421. text_buffer.insert(en, "\n\n")
  422. continue
  423. elif (i[-1].startswith("lbry://") or i[-1].startswith("https://") or i[-1].startswith("http://")) and "youtu" not in i[-1] and i[0] != "text_c":
  424. # I will try to resolve it as a publication
  425. def try_resolve(url):
  426. out = fetch.lbrynet("resolve", {"urls":parse.bar(url)})
  427. try:
  428. out = out[parse.bar(url)]
  429. is_channel = "value_type" in out and out["value_type"] == "channel"
  430. return ["lbry", url, out]
  431. except:
  432. return ["text", url, out]
  433. def render_resolved(data):
  434. t, url, out = data
  435. if t == "text":
  436. return Gtk.Label(url)
  437. elif t == "lbry":
  438. try:
  439. return ui.search_item(win, out, True)
  440. except:
  441. return Gtk.Label(url)
  442. w = ui.load(win, try_resolve, render_resolved, i[-1])
  443. anchor = Gtk.TextChildAnchor()
  444. text_buffer.insert_child_anchor(en, anchor)
  445. text_view.add_child_at_anchor(w , anchor)
  446. continue
  447. try:
  448. text_buffer.insert_with_tags_by_name(en, i[-1], i[0])
  449. except:
  450. text_buffer.insert(en, i[-1])
  451. elif i[0] == "text_cm":
  452. codeview = Gtk.TextView()
  453. #codeview.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(0.2,0.2,0.2, 1))
  454. #codeview.override_color(Gtk.StateType.NORMAL, Gdk.RGBA(0.9,0.9,0.9, 1))
  455. codeview.override_font(Pango.FontDescription("Monospace"))
  456. codescrl = Gtk.ScrolledWindow()
  457. codeframe = Gtk.Frame()
  458. codeframe.add(codescrl)
  459. codescrl.set_size_request(imwidth, min(i[-1].count("\n")*20, 500 ))
  460. codeview.set_editable(True)
  461. codescrl.add(codeview)
  462. codebuffer = codeview.get_buffer()
  463. codebuffer.set_text(i[-1])
  464. anchor = Gtk.TextChildAnchor()
  465. text_buffer.insert_child_anchor(en, anchor)
  466. text_view.add_child_at_anchor(codeframe , anchor)
  467. elif type(i[0]) == int:
  468. text_buffer.insert_with_tags_by_name(en, i[-1].replace("#", ""), "header")
  469. elif i[0] == "image_link":
  470. image = ui.load(win, ui.net_image_calculation, ui.net_image_render, i[1], imwidth, imwidth, "", True)
  471. def link_launch(w, link):
  472. os.system("xdg-open "+link)
  473. def link_resolve(w, link):
  474. win.url.set_text(link)
  475. win.url.activate()
  476. optionsthing = Gtk.Popover()
  477. optbox = Gtk.VBox()
  478. optionsthing.add(optbox)
  479. optbox.pack_start(Gtk.Label("Link"), False, False, 5)
  480. opt_link = Gtk.Entry()
  481. opt_link.set_editable(False)
  482. opt_link.set_text(i[-1])
  483. optbox.pack_start(opt_link, False, False, False)
  484. opt_launch = Gtk.Button("Launch")
  485. optbox.pack_start(opt_launch, False, False, False)
  486. opt_resolve = Gtk.Button("Resolve")
  487. optbox.pack_start(opt_resolve, False, False, False)
  488. opt_launch.connect("clicked", link_launch, i[-1])
  489. opt_resolve.connect("clicked", link_resolve, i[-1])
  490. optbox.pack_start(Gtk.HSeparator(), False, False, 5)
  491. optbox.pack_start(Gtk.Label("Image"), False, False, 5)
  492. opt_link = Gtk.Entry()
  493. opt_link.set_editable(False)
  494. opt_link.set_text(i[1])
  495. optbox.pack_start(opt_link, False, False, False)
  496. opt2_open = Gtk.Button("Open")
  497. optbox.pack_start(opt2_open, False, False, False)
  498. opt2_launch = Gtk.Button("Launch")
  499. optbox.pack_start(opt2_launch, False, False, False)
  500. opt2_resolve = Gtk.Button("Resolve")
  501. optbox.pack_start(opt2_resolve, False, False, False)
  502. opt2_open.connect("clicked", link_launch, ui.image_save_name(i[1]))
  503. opt2_launch.connect("clicked", link_launch, i[1])
  504. opt2_resolve.connect("clicked", link_resolve, i[1])
  505. optbox.show_all()
  506. link = Gtk.MenuButton(popover=optionsthing)
  507. link.add(image)
  508. anchor = Gtk.TextChildAnchor()
  509. text_buffer.insert_child_anchor(en, anchor)
  510. text_view.add_child_at_anchor(link, anchor)
  511. elif i[0] == "image":
  512. try:
  513. loadw = int(i[1])
  514. except:
  515. loadw = imwidth
  516. image = ui.load(win, ui.net_image_calculation, ui.net_image_render, i[-1], loadw, loadw, "", True)
  517. def link_launch(w, link):
  518. os.system("xdg-open "+link)
  519. def link_resolve(w, link):
  520. win.url.set_text(link)
  521. win.url.activate()
  522. optionsthing = Gtk.Popover()
  523. optbox = Gtk.VBox()
  524. optionsthing.add(optbox)
  525. opt_link = Gtk.Entry()
  526. opt_link.set_editable(False)
  527. opt_link.set_text(i[-1])
  528. optbox.pack_start(opt_link, False, False, False)
  529. opt_open = Gtk.Button("Open")
  530. optbox.pack_start(opt_open, False, False, False)
  531. opt_launch = Gtk.Button("Launch")
  532. optbox.pack_start(opt_launch, False, False, False)
  533. opt_resolve = Gtk.Button("Resolve")
  534. optbox.pack_start(opt_resolve, False, False, False)
  535. opt_open.connect("clicked", link_launch, ui.image_save_name(i[-1]))
  536. opt_launch.connect("clicked", link_launch, i[-1])
  537. opt_resolve.connect("clicked", link_resolve, i[-1])
  538. optbox.show_all()
  539. link = Gtk.MenuButton(popover=optionsthing)
  540. link.set_relief(Gtk.ReliefStyle.NONE)
  541. link.add(image)
  542. anchor = Gtk.TextChildAnchor()
  543. text_buffer.insert_child_anchor(en, anchor)
  544. text_view.add_child_at_anchor(link, anchor)
  545. elif i[0] == "link":
  546. # link = Gtk.LinkButton.new_with_label(
  547. # uri=i[-1],
  548. # label=i[1])
  549. def link_launch(w, link):
  550. os.system("xdg-open "+link)
  551. def link_resolve(w, link):
  552. win.url.set_text(link)
  553. win.url.activate()
  554. optionsthing = Gtk.Popover()
  555. optbox = Gtk.VBox()
  556. optionsthing.add(optbox)
  557. opt_link = Gtk.Entry()
  558. opt_link.set_editable(False)
  559. opt_link.set_text(i[-1])
  560. optbox.pack_start(opt_link, False, False, False)
  561. opt_launch = Gtk.Button("Launch")
  562. optbox.pack_start(opt_launch, False, False, False)
  563. opt_resolve = Gtk.Button("Resolve")
  564. optbox.pack_start(opt_resolve, False, False, False)
  565. opt_launch.connect("clicked", link_launch, i[-1])
  566. opt_resolve.connect("clicked", link_resolve, i[-1])
  567. optbox.show_all()
  568. link = Gtk.MenuButton(label=i[1], popover=optionsthing)
  569. link.set_tooltip_text(i[-1])
  570. anchor = Gtk.TextChildAnchor()
  571. text_buffer.insert_child_anchor(en, anchor)
  572. text_view.add_child_at_anchor(link, anchor)