+ All Categories
Home > Technology > Lone Star PHP - PHP-GTK - Bob Majdak Jr

Lone Star PHP - PHP-GTK - Bob Majdak Jr

Date post: 28-May-2015
Category:
Upload: bobmajdakjr
View: 1,157 times
Download: 0 times
Share this document with a friend
Description:
The slides from the presentation I gave at Lone Star PHP in Dallas on June 11th 2011.
Popular Tags:
27
PHP, GTK, PHP-GTK look ma, no webserver. http://joind.in/2980
Transcript
Page 1: Lone Star PHP - PHP-GTK - Bob Majdak Jr

PHP, GTK, PHP-GTK

look ma, no webserver.

http://joind.in/2980

Page 2: Lone Star PHP - PHP-GTK - Bob Majdak Jr

WHAT IS PHP?For the sake of completeness

Page 3: Lone Star PHP - PHP-GTK - Bob Majdak Jr

WHAT IS GTK?Boxes, buttons, and sliders, oh my!

Page 4: Lone Star PHP - PHP-GTK - Bob Majdak Jr

GTK was... GTK is...

• Original UI toolkit for GIMP.– GIMP Tool Kit

• Now the basis of GNOME and lots of software.– GNOME Tool Kit. (sarcastic groan)

• C Library. Bindings in almost any language ever– C++, D, ...– Java, Python, Perl, ...– Oh, and PHP

Page 5: Lone Star PHP - PHP-GTK - Bob Majdak Jr

GTK Applications

• GIMP• GNOME anything.• Transmission• Banshee• Pidgin• Apps roll custom UI kits for GTK or QT purists– Firefox, The suite formerly known as OpenOffice.

Page 6: Lone Star PHP - PHP-GTK - Bob Majdak Jr

SO WHY NOT PHP AND GTK^_^

Page 7: Lone Star PHP - PHP-GTK - Bob Majdak Jr

PHP-GTK is...

• A client side application library.– Will not run in a

webserver. In fact your webserver will catch fire.

– I have seen it happen twice.

• NOT for building webpages. Remember: fire.

Page 8: Lone Star PHP - PHP-GTK - Bob Majdak Jr

PHP-GTK Pros

• PHP is easy fun.• PHP Object Orientation fits well with a widget

toolkit mindset.• Linux systems probably already have PHP CLI

accessible.• Multiplatform.– Download unzip and go on Windows.– Package manager + some compiling on Linux.– MacOS is not fun to setup. But it can happen.

Page 9: Lone Star PHP - PHP-GTK - Bob Majdak Jr

PHP-GTK Cons

• PHP is “slow”• PHP is kind of single thread mostly.• Windows users are like “lolwut?”

– The concept of an exe binary does not exist.• Actually it does, but it is the official position of the devs to not even

attempt to support blendering.

– Perfectly reasonable way around this• MacOS is a pain to setup.

– 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?

– 4:39:34 PM Bob: yeah :D

Page 10: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Quick peek at some PHP-GTKs

<?php

//. FAR from a proper app,//. but will “work”.

$window = new GtkWindow;$window->add(new GtkLabel( ‘Hello World’));$window->set_title(‘Hurr Durr’);$window->show_all();Gtk::main();

?>

Page 11: Lone Star PHP - PHP-GTK - Bob Majdak Jr

WHAT CAN WE DO WITH PHP-GTK?The right answer is almost anything.

Page 12: Lone Star PHP - PHP-GTK - Bob Majdak Jr

PGID3, An MP3 Tag Editor

Page 13: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Ambst, Ambient Star Trek >_>

Page 14: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Prana, Removable Media Launcher

Page 15: Lone Star PHP - PHP-GTK - Bob Majdak Jr

HOW ABOUT SOME HEAVY LIFTINGNice tiny apps but...

Page 16: Lone Star PHP - PHP-GTK - Bob Majdak Jr

LiveCD Installer?

Page 17: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Package Management?

Page 18: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Repository Management?

Page 19: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Network Configuration?

Page 20: Lone Star PHP - PHP-GTK - Bob Majdak Jr

QUICK PRE-DEMO POINTERSlets see some code already.

Page 21: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Desktop App Requirements

• Applications must know how to initialize themselves.– Loading, caching, building UI, handling input.

• Applications must know how to terminate themselves cleanly.– SEGFAULT is not a valid choice, though humorous.– Clean up files, swaps, connections, last second

saves, etc.

Page 22: Lone Star PHP - PHP-GTK - Bob Majdak Jr

How it works...

• Execute PHP application• PHP app loads whatever config, init whatever

UI, and exposes itself to you• PHP app hits the main loop– Gtk::main();– This keeps your script alive in the GTK loop so that

it can answer to things like mouse clicks.• PHP app breaks the loop when done.– Gtk::main_quit();

Page 23: Lone Star PHP - PHP-GTK - Bob Majdak Jr

BOB GO SHOW THEM SOME CODESRSLY, CODE... NAO

Page 24: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Some Widgets

• Windows. GtkWindow, GtkDialog• Buttons. GtkButton• Text Labels. GtkLabel• Text Entry. GtkEntry, GtkTextView• Dropdown Menus: GtkComboBox• Radio Buttons: GtkRadioButton• Progress Bars: GtkProgressBar

Page 25: Lone Star PHP - PHP-GTK - Bob Majdak Jr

The power comes from EXTENDS

• GtkWindow is boring.• bobWindow extends GtkWindow– Sets default title, icon, builds internal UI.– This is how apps are made.

Page 26: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Resources

• PHP-GTK Manual, http://gtk.php.net• Bob’s PHP-GTK Archive– http://oops.opsat.net– http://squirrelshaterobots.com

• PHP-GTK Community Site– apps, tips, sort-of-not-active-forum– http://php-gtk.eu

Page 27: Lone Star PHP - PHP-GTK - Bob Majdak Jr

Contact and More Info

• Bob Majdak Jr• twitter: @bobmajdakjr• irc: #php-gtk, #dallasphp on Freenode• dev blog: http://squirrelshaterobots.com• this talk: http://joind.in/2980


Recommended