welcome1stboot.bac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. REM welcome window, first boot of Puppy.
  2. REM (c) Copyright Barry Kauler 2011, bkhome.org
  3. REM License GPL v3 (/usr/share/doc/legal)
  4. REM 110412 first release.
  5. REM 110414 tweak dimensions for non-English (thanks L18L and rodin.s).
  6. REM 120630 1st bootup in PUPMODE=2, removed section about saving session.
  7. REM 130204 include hug.bac, avoid needs recompiling when hug.so updated. (but much bigger!)
  8. REM 130209 go back to hug.so.
  9. REM 130710 Puppy default dpi has changed from 78 to 96.
  10. REM 131210 modified for quirky6.
  11. REM 140205 L18L modified for puppy and quirky and fatdog (anything in 1st word of /etc/issue)
  12. REM 140207 /usr/sbin/delayedrun now tests active network and internet connection.
  13. REM 140210 L18L choose from available languages, lang_names in new /usr/share/i18n/lang_names
  14. REM 140211 display lang_names, language code in tooltip
  15. REM 140212 bugfix
  16. REM 140215 01micko: disable button_ic if connected; add slacko method which also enables test runs after 1stboot
  17. REM compile and create pot file: bacon -x -d /tmp welcome1stboot.bac
  18. OPTION INTERNATIONAL TRUE
  19. REM .po/.mo files have 'charset=UTF-8', so either set UTF-8 on in LANG variable, or do this...
  20. SETENVIRON "OUTPUT_CHARSET", "UTF-8"
  21. REM Final exe size: incl hug.bac: 178K, func list: 134K, shared hug.so: 47K...
  22. REM INCLUDE "/usr/share/BaCon/hug.bac",ATTACH,BUTTON,CALLBACK,DISPLAY,FONT,HIDE,HUGOPTIONS,IMAGE,INIT,MARK,MSGDIALOG,PROPERTY,QUIT,SHOW,WINDOW
  23. INCLUDE "/usr/share/BaCon/hug_imports.bac"
  24. REM http://developer.gnome.org/gtk/stable/GtkWidget.html#gtk-widget-set-tooltip-text
  25. IMPORT "gtk_widget_set_tooltip_text(long,char*)" FROM "libgtk-x11-2.0.so" TYPE void
  26. ISSUE$=EXEC$("cat /etc/issue | head -n 1 | cut -d ' ' -f1")
  27. SETENVIRON "ISSUE", ISSUE$
  28. INIT
  29. SUB ic_func()
  30. SYSTEM "/usr/sbin/connectwizard & "
  31. END SUB
  32. SUB setup_func()
  33. SYSTEM "/usr/sbin/wizardwizard & "
  34. END SUB
  35. SUB close_dlg(NUMBER widget)
  36. HIDE(widget)
  37. END SUB
  38. REM ============================ <language> ======================140210
  39. FUNCTION available_languages$()
  40. GLOBAL langs$
  41. REM langs$=CONCAT$("en ", CHOP$(EXEC$("echo `find /usr/share/locale/*/LC_MESSAGES/welcome1stboot.mo | cut -d '/' -f 5`")))
  42. langs$="en"
  43. OPEN "/usr/share/locale/" FOR DIRECTORY AS textdomaindir
  44. REPEAT
  45. GETFILE oneLANG$ FROM textdomaindir
  46. IF FILEEXISTS(CONCAT$("/usr/share/locale/", oneLANG$, "/LC_MESSAGES/", ARGUMENT$, ".mo")) THEN langs$=CONCAT$(langs$, " ", oneLANG$)
  47. UNTIL ISFALSE(LEN(oneLANG$))
  48. CLOSE DIRECTORY textdomaindir
  49. RETURN langs$
  50. END FUNCTION
  51. SUB get_app_language
  52. OPTION BASE 1
  53. GLOBAL num_languages, language_win
  54. LOCAL num_cols
  55. no_LANG_NAME$ = "no name"
  56. GLOBAL language_checked[100]
  57. REM GLOBAL language_select[100]
  58. langs$=available_languages$ ()
  59. SPLIT langs$ BY " " TO language$ SIZE num_languages
  60. IF num_languages > 1 THEN
  61. num_cols = 2 : IF num_languages > 15 THEN num_cols = 3
  62. HUGOPTIONS("FONT DejaVu Sans 20")
  63. win_width=640
  64. win_height=480
  65. language_win = WINDOW("?", win_width, win_height)
  66. check_width = FLOOR((win_width - 10) / num_cols)
  67. check_height = win_height / (1 + FLOOR(num_languages / num_cols))
  68. padding_x = (win_width - (num_cols * check_width))
  69. padding_y = 0
  70. n = 1 : row = 1 : col = 1
  71. WHILE n < num_languages + 1
  72. IF n = 1 THEN LANG_NAME$="English"
  73. ELIF FILEEXISTS("/usr/share/i18n/lang_names") THEN
  74. 'get language name in language of language
  75. LANG_NAME$=CHOP$(EXEC$(CONCAT$("x=`grep ^", language$[n],": /usr/share/i18n/lang_names || echo ", no_LANG_NAME$, "`;echo ${x#*:}")))
  76. ELSE
  77. LANG_NAME$=CONCAT$("Code: ", language$[n], " ")
  78. END IF
  79. language_checked[n]=CHECK(LANG_NAME$, check_width, check_height)
  80. ATTACH(language_win, language_checked[n], padding_x + (col -1) * check_width , padding_y + (row - 1) * check_height )
  81. gtk_widget_set_tooltip_text(language_checked[n],CONCAT$(language$[n], " ⇌ ", LANG_NAME$))
  82. CALLBACKX(language_checked[n], use_language, n)
  83. INCR n : INCR col
  84. IF col > num_cols THEN
  85. INCR row : col = 1
  86. ENDIF
  87. WEND
  88. DISPLAY
  89. ENDIF
  90. END SUB
  91. ' restart this programm using LANGUAGE number n
  92. SUB use_language(NUMBER widget, NUMBER n)
  93. SPLIT langs$ BY " " TO language$ SIZE num_languages
  94. SYSTEM CONCAT$("echo -n `pidof ", ARGUMENT$, "`> /tmp/welcome")
  95. SYSTEM CONCAT$("LANGUAGE=", language$[n], " ", ARGUMENT$)
  96. SYSTEM CONCAT$("kill `pidof ", ARGUMENT$)
  97. END
  98. END SUB
  99. IF GETENVIRON$("LANGUAGE") = "" THEN
  100. get_app_language : REM language choice screen
  101. ELSE
  102. SYSTEM "kill `cat /tmp/welcome`; rm /tmp/welcome" : REM kill language choice screen
  103. END IF
  104. REM ============================ </language> ======================140210
  105. REM fix window font layout regardless of dpi...
  106. REM 78 is the Xft.dpi in /root/.Xresources when I designed the layout... now 96...
  107. HUGOPTIONS("BASEXFTDPI 96")
  108. REM User may have GTK theme font size too big/small. set to required size...
  109. HUGOPTIONS("FONT DejaVu Sans 10")
  110. REM hack for russian, ru...
  111. mycountry$=LEFT$(GETENVIRON$("LANG"),2)
  112. REM space required for the session-save section, if not PUPMODE=2...
  113. 'vert_space_save=0
  114. 'IF FILETYPE("/initrd") EQ 2 THEN vert_space_save=112
  115. vert_space_save=4
  116. REM to disable decorations, need to hide window first...
  117. HUGOPTIONS("WIDGET_SHOW 0")
  118. REM reduced height by 112 pixels...
  119. mainwin = WINDOW(INTL$("Welcome"),656,402+vert_space_save)
  120. PROPERTY(mainwin,"decorated",FALSE)
  121. HUGOPTIONS("WIDGET_SHOW 1")
  122. image_logo=IMAGE("/usr/share/doc/puppylogo96.png",96,96)
  123. ATTACH(mainwin,image_logo,68,5)
  124. label_welcome=MARK(INTL$("Welcome,"),350,24)
  125. REM left-align for single-line label...
  126. PROPERTY(label_welcome,"xalign",0.0)
  127. FONT(label_welcome,"DejaVu Sans Bold 20")
  128. ATTACH(mainwin,label_welcome,188,20)
  129. REM label_subhdr=MARK(INTL$("This is the first time you are running Quirky!"),462,24)
  130. pot_msg$=INTL$("This is the first time you are running ${ISSUE}!")
  131. label_subhdr=MARK(EXEC$("eval echo $(gettext 'welcome1stboot' 'This is the first time you are running ${ISSUE}!')"),462,24)
  132. PROPERTY(label_subhdr,"xalign",0.0)
  133. FONT(label_subhdr,"DejaVu Sans 14")
  134. ATTACH(mainwin,label_subhdr,188,50)
  135. button_x=BUTTON("",26,24)
  136. image_x=IMAGE("/usr/local/lib/X11/mini-icons/mini-cross.xpm",16,16)
  137. PROPERTY(button_x,"image",image_x)
  138. gtk_widget_set_tooltip_text(button_x,INTL$("Close window"))
  139. ATTACH(mainwin,button_x,622,6)
  140. CALLBACK(button_x,QUIT)
  141. button_ic=BUTTON("",58,56)
  142. image_ic=IMAGE("/usr/local/lib/X11/pixmaps/connect48.png",48,48)
  143. PROPERTY(button_ic,"image",image_ic)
  144. gtk_widget_set_tooltip_text(button_ic,INTL$("Connect to Internet"))
  145. ATTACH(mainwin,button_ic,584,116)
  146. label_ic=MARK(INTL$("Internet connection"),250,24)
  147. PROPERTY(label_ic,"xalign",0.0)
  148. FONT(label_ic,"DejaVu Sans Bold 14")
  149. ATTACH(mainwin,label_ic,60,108)
  150. label_ic=MARK(INTL$("Internet connection"),250,24)
  151. PROPERTY(label_ic,"xalign",0.0)
  152. FONT(label_ic,"DejaVu Sans Bold 14")
  153. ATTACH(mainwin,label_ic,60,108)
  154. REM 140215 add slacko method which also enables test runs after 1stboot
  155. '# check connection
  156. '#shinobar
  157. 'LANG=C route | grep -q 'default[ ].*[ ]0\.0\.0\.0[ ]' && \
  158. 'grep -wq nameserver /etc/resolv.conf && \
  159. 'ping -c1 sourceforge.net &>/dev/null && CONNECTED="yes" || CONNECTED=
  160. SYSTEM "echo -n no > /tmp/CONNECTED; LANG=C route | grep -q 'default[ ].*[ ]0.0.0.0[ ]' && grep -wq nameserver /etc/resolv.conf && ping -c1 sourceforge.net &>/dev/null && echo -n yes > /tmp/CONNECTED "
  161. CONNECTED$=EXEC$("cat /tmp/CONNECTED")
  162. IF FILEEXISTS("/tmp/delayedrun-internet-working") OR CONNECTED$ = "yes" THEN
  163. label_ic_body=MARK(INTL$("Congratulations, you are connected to the Internet. Experiment with mouse-over, left-click and right-click on the 'network' icon in the tray. Click on the 'connect' icon on the right (or on the desktop) if you need to reconfigure the Internet connection"),500,70)
  164. DISABLE(button_ic)
  165. ELIF FILEEXISTS("/tmp/delayedrun-active-interfaces") THEN
  166. label_ic_body=MARK(INTL$("There is a working network interface, but you are not connected to the Internet. Click on the 'connect' icon on the right, or on left-side of the desktop (do NOT double-click), to setup the Internet connection. Note the network status icon in the tray."),500,70)
  167. ELSE
  168. label_ic_body=MARK(INTL$("Click on the 'connect' button on the right, or icon at left of the screen (one click only -- do not double-click!). You will then see some buttons for choosing how you wish to connect to the Internet. It is easy..."),500,70)
  169. ENDIF
  170. PROPERTY(label_ic_body,"xalign",0.0)
  171. PROPERTY(label_ic_body,"yalign",0.0)
  172. PROPERTY(label_ic_body,"wrap",TRUE)
  173. ATTACH(mainwin,label_ic_body,60,130)
  174. CALLBACK(button_ic,ic_func)
  175. label_c=MARK(INTL$("connect"),82,16)
  176. FONT(label_c,"DejaVu Sans Bold 10")
  177. PROPERTY(label_c,"xalign",0.5)
  178. ATTACH(mainwin,label_c,571,172)
  179. REM bad hack for russian translation...
  180. IF mycountry$ = "ru" THEN
  181. vert1=186
  182. vert2=208
  183. ELSE
  184. vert1=202
  185. vert2=224
  186. END IF
  187. label_help=MARK(INTL$("I need help!"),280,24)
  188. PROPERTY(label_help,"xalign",0.0)
  189. FONT(label_help,"DejaVu Sans Bold 14")
  190. ATTACH(mainwin,label_help,20,vert1)
  191. REM label_help_body=MARK(INTL$("Explore the 'Menu' -- see bottom-left of screen. Lots of local help is available -- select 'Help' in the menu. The local Help page also has the Release Notes for this version of Quirky -- well worth checking out! When you get online, the web browser home page has many more links."),628,70)
  192. pot_msg$=INTL$("Explore the Menu -- see bottom-left of screen. Lots of local help is available -- select Help in the menu. The local Help page also has the Release Notes for this version of ${ISSUE}-- well worth checking out! When you get online, the web browser home page has many more links.")
  193. label_help_body=MARK(EXEC$("eval echo $(gettext 'welcome1stboot' 'Explore the Menu -- see bottom-left of screen. Lots of local help is available -- select Help in the menu. The local Help page also has the Release Notes for this version of ${ISSUE}-- well worth checking out! When you get online, the web browser home page has many more links.')"),628,70)
  194. PROPERTY(label_help_body,"xalign",0.0)
  195. PROPERTY(label_help_body,"yalign",0.0)
  196. PROPERTY(label_help_body,"wrap",TRUE)
  197. ATTACH(mainwin,label_help_body,20,vert2)
  198. image_tray=IMAGE("/usr/share/doc/tray.png",178,28)
  199. ATTACH(mainwin,image_tray,40,282)
  200. label_tray=MARK(INTL$("...mouse-over and click the tray applets, very helpful!"),431,16)
  201. PROPERTY(label_tray,"xalign",0.0)
  202. ATTACH(mainwin,label_tray,222,286)
  203. label_setup=MARK(INTL$("Setup"),280,24)
  204. PROPERTY(label_setup,"xalign",0.0)
  205. FONT(label_setup,"DejaVu Sans Bold 14")
  206. ATTACH(mainwin,label_setup,70,320+vert_space_save)
  207. label_setup_body=MARK(INTL$("Want to install an upgraded video driver? Country localization? Printing? Sound? Mouse? Keyboard? Click here (or 'setup' icon at top of screen):"),500,70)
  208. PROPERTY(label_setup_body,"xalign",0.0)
  209. PROPERTY(label_setup_body,"yalign",0.0)
  210. PROPERTY(label_setup_body,"wrap",TRUE)
  211. ATTACH(mainwin,label_setup_body,70,342+vert_space_save)
  212. button_setup=BUTTON("",58,56)
  213. image_setup=IMAGE("/usr/local/lib/X11/pixmaps/configuration48.png",48,48)
  214. PROPERTY(button_setup,"image",image_setup)
  215. REM gtk_widget_set_tooltip_text(button_setup,INTL$("Setup Quirky"))
  216. pot_msg$=INTL$("Setup ${ISSUE}")
  217. gtk_widget_set_tooltip_text(button_setup,EXEC$("eval echo -n $(gettext 'welcome1stboot' 'Setup ${ISSUE}')"))
  218. ATTACH(mainwin,button_setup,584,323+vert_space_save)
  219. CALLBACK(button_setup,setup_func)
  220. label_set=MARK(INTL$("setup"),87,16)
  221. FONT(label_set,"DejaVu Sans Bold 10")
  222. PROPERTY(label_set,"xalign",0.5)
  223. ATTACH(mainwin,label_set,568,379+vert_space_save)
  224. SHOW(mainwin)
  225. DISPLAY
  226. REM the end