Lone Star PHP - PHP-GTK - Bob Majdak Jr


Published on

The slides from the presentation I gave at Lone Star PHP in Dallas on June 11th 2011.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lone Star PHP - PHP-GTK - Bob Majdak Jr

  1. 1. PHP, GTK, PHP-GTK<br />look ma, no webserver.<br />http://joind.in/2980<br />
  2. 2. What is php?<br />For the sake of completeness<br />
  3. 3. What is GTK?<br />Boxes, buttons, and sliders, oh my!<br />
  4. 4. GTK was... GTK is...<br />Original UI toolkit for GIMP.<br />GIMP Tool Kit<br />Now the basis of GNOME and lots of software.<br />GNOME Tool Kit. (sarcastic groan)<br />C Library. Bindings in almost any language ever<br />C++, D, ...<br />Java, Python, Perl, ...<br />Oh, and PHP<br />
  5. 5. GTK Applications<br />GIMP<br />GNOME anything.<br />Transmission<br />Banshee<br />Pidgin<br />Apps roll custom UI kits for GTK or QT purists<br />Firefox, The suite formerly known as OpenOffice.<br />
  6. 6. so why not php and gtk<br />^_^<br />
  7. 7. PHP-GTK is...<br />A client side application library.<br />Will not run in a webserver. In fact your webserver will catch fire.<br />I have seen it happen twice.<br />NOT for building webpages. Remember: fire.<br />
  8. 8. PHP-GTK Pros<br />PHP is easy fun.<br />PHP Object Orientation fits well with a widget toolkit mindset.<br />Linux systems probably already have PHP CLI accessible.<br />Multiplatform.<br />Download unzip and go on Windows.<br />Package manager + some compiling on Linux.<br />MacOS is not fun to setup. But it can happen.<br />
  9. 9. PHP-GTK Cons<br />PHP is “slow”<br />PHP is kind of single thread mostly.<br />Windows users are like “lolwut?”<br />The concept of an exe binary does not exist.<br />Actually it does, but it is the official position of the devs to not even attempt to support blendering.<br />Perfectly reasonable way around this<br />MacOS is a pain to setup.<br />4:39:15 PM Greg: So let me see, you used Linux software to run the Windows binaries of Linux libraries through a web programming language on Mac... so that you could use a text editor?<br />4:39:34 PM Bob: yeah :D<br />
  10. 10. Quick peek at some PHP-GTKs<br /><?php<br />//. FAR from a proper app,<br />//. but will “work”.<br />$window = new GtkWindow;<br />$window->add(new GtkLabel(<br /> ‘Hello World’<br />));<br />$window->set_title(‘Hurr Durr’);<br />$window->show_all();<br />Gtk::main();<br />?><br />
  11. 11. What can we do with php-gtk?<br />The right answer is almost anything.<br />
  12. 12. PGID3, An MP3 Tag Editor<br />
  13. 13. Ambst, Ambient Star Trek >_><br />
  14. 14. Prana, Removable Media Launcher<br />
  15. 15. how about some heavy lifting<br />Nice tiny apps but...<br />
  16. 16. LiveCD Installer?<br />
  17. 17. Package Management?<br />
  18. 18. Repository Management?<br />
  19. 19. Network Configuration?<br />
  20. 20. quick pre-demo pointers<br />lets see some code already.<br />
  21. 21. Desktop App Requirements<br />Applications must know how to initialize themselves.<br />Loading, caching, building UI, handling input.<br />Applications must know how to terminate themselves cleanly.<br />SEGFAULT is not a valid choice, though humorous.<br />Clean up files, swaps, connections, last second saves, etc.<br />
  22. 22. How it works...<br />Execute PHP application<br />PHP app loads whatever config, init whatever UI, and exposes itself to you<br />PHP app hits the main loop<br />Gtk::main();<br />This keeps your script alive in the GTK loop so that it can answer to things like mouse clicks.<br />PHP app breaks the loop when done.<br />Gtk::main_quit();<br />
  23. 23. bob GO show them some code<br />SRSLY, CODE... NAO<br />
  24. 24. Some Widgets<br />Windows. GtkWindow, GtkDialog<br />Buttons. GtkButton<br />Text Labels. GtkLabel<br />Text Entry. GtkEntry, GtkTextView<br />Dropdown Menus: GtkComboBox<br />Radio Buttons: GtkRadioButton<br />Progress Bars: GtkProgressBar<br />
  25. 25. The power comes from EXTENDS<br />GtkWindow is boring.<br />bobWindow extends GtkWindow<br />Sets default title, icon, builds internal UI.<br />This is how apps are made. <br />
  26. 26. Resources<br />PHP-GTK Manual, http://gtk.php.net<br />Bob’s PHP-GTK Archive<br />http://oops.opsat.net<br />http://squirrelshaterobots.com<br />PHP-GTK Community Site<br />apps, tips, sort-of-not-active-forum<br />http://php-gtk.eu<br />
  27. 27. Contact and More Info<br />Bob Majdak Jr<br />twitter: @bobmajdakjr<br />irc: #php-gtk, #dallasphp on Freenode<br />dev blog: http://squirrelshaterobots.com<br />this talk: http://joind.in/2980<br />