Re: Nathan msgbox problem

From: Date: Thu, 22 Jul 2004 08:57:17 +0000
Subject: Re: Nathan msgbox problem
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4834@lists.php.net to get a copy of this message
Silly me Silly Silly I'm sorry to bother you offcourse it doesn't work. I putted if($msg != 'ok') I should have beeen if($msg == 'ok') than it is ok Problem solved. Thx Wim Wim Stockman wrote: > Hello > > I tried the msgbox example you putted on the wiki and gave me the url to > it. But it seems I have the same problem than with my FileDialog. I > don't get the $msg returned it is also an empty string. > And I just copied and pasted your example so normally I cannot have done > something wrong. Maybe there is someting wrong with my configuration of > my PHP although I use the PHP version that came with tulip. So normally > that shouldn't be de problem. > Well Here is the program maybe I did still something wrong. > > > msgbox.class : > <?php > /** > @author <[http://wiki.gtk.php.net/index.php?page=nathan nathan] at > the-ring dot homelinux dot net> > @package GUI_OBJECTS > @license http://opensource.org/licenses/lgpl-license.php GNU > Lesser > General Public Licence > */ > class msgbox{ > var $gtkwindow; > var $gdkwindow; > var $mode; > var $buttons; > var $label; > var $actionbox; > var $box; > var $mainbox; > var $pixmap; > /** > create the message box > @param string $title the window title > @param mixed $icon (int iconid|string filename|array xpm_data) the > icon to display > defined icons are 0 for interrogation, 1 for exclamation > and 2 for X > @param string $label the message label > @param string $buttons is the button label separated by '|' (ie: > "OK|CANCEL") > @param int $mode define various window setting 0 is default add 1 for > a POPUP window and 2 for a modal one > (ie: 3 will be popup and modal window) > @param bool $forced_txt set it to true to force the message to be a > gtktext without regarding it's length > */ > function > msgbox($label,$icon=0,$buttons='cancel|ok',$title=null,$mode=2,$forced_txt=FALSE){ > $this->gtkwindow = &new > gtkwindow((($mode%2==1)?GTK_WINDOW_POPUP:GTK_WINDOW_DIALOG)); # set the > window as popup accordingly to $mode > $this->gtkwindow->set_title($title); > $this->gtkwindow->realize(); > $this->gdkwindow = $this->gtkwindow->window; > $this->frame = &new gtkframe(); > $this->mainbox = &new gtkvbox(0,5); > $this->box = &new gtkhbox(0,5); > $this->gtkwindow->add($this->frame); > $this->frame->add($this->mainbox); > > #THE ACTION BOX > $this->actionbox = &new gtkhbuttonbox(); > $this->actionbox->set_spacing(5); > $this->actionbox->set_layout(GTK_BUTTONBOX_END); > #CREATE BUTTONS > $buttons = explode('|',$buttons); > $bt_count= count($buttons); > foreach($buttons as $lb){ > $this->buttons[$lb] = &new gtkbutton($lb); > > > $this->buttons[$lb]->connect('clicked',array(&$this,'clicked'),$lb); > $this->actionbox->add($this->buttons[$lb]); > if(++$i == $bt_count) > $this->gtkwindow->set_focus($this->buttons[$lb]); > } > #ARRANGING WIDGETS > $this->mainbox->pack_start($this->box,1,1,0); > $separator = &new gtkhseparator(); > $this->mainbox->pack_end($this->actionbox,0,0,2); > $this->mainbox->pack_end($separator,0,0,0); > if($mode>=2)#set the window modal if needed > $this->gtkwindow->set_modal(TRUE); > #load the needed icons > $this->load_icon($icon); > if($this->pixmap) > $this->box->pack_start($this->pixmap,0,0,5); > if(strlen($label) < 250 && !$forced_txt){ > $this->label = &new gtklabel($label); > $this->label->set_justify(GTK_JUSTIFY_LEFT); > $this->box->pack_start($this->label,1,1,5); > }else{ > $this->txt = &new gtktext(); > $this->txt->set_word_wrap(FALSE); > $this->txt->insert(null,null,null,$label); > $this->scroll = &new gtkscrolledwindow(); > $this->scroll->add($this->txt); > > $this->scroll->set_policy(GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); > $this->scroll->set_usize(450,150); > $this->box->pack_start($this->scroll,1,1,5); > } > } > /** > known signal 'destroy','show',clicked > @param string $signal may be 'clicked','destroy','show' > @param mixed $callback (string function name or > array(object,methodname)) > */ > function connect($signal,$callback){ > $args[0] = &$this; > for($i=1;$i<func_num_args();$i++){ > $args[$i]=&func_get_arg($i); > } > $this->cbs[$signal] = array($callback,$args); > } > /** self explained */ > function show(){ > > $this->gtkwindow->connect('delete-event',array(&$this,'destroy')); > > $this->gtkwindow->connect('destroy-event',array(&$this,'destroy')); > $this->gtkwindow->set_position('center'); > $this->gtkwindow->show_all(); > if(is_array($this->cbs['show'])) > > call_user_func_array($this->cbs['show'][0],$this->cbs['show'][1]); > # this will block your script parsing until the gtk::main_quit() was > called > gtk::main(); > } > /** self explained */ > function destroy(){ > $this->gtkwindow->destroy(); > if(is_array($this->cbs['destroy'])) > > > call_user_func_array($this->cbs['destroy'][0],$this->cbs['destroy'][1]); > # this will quit the gtk loop we launched in the show method > # and then the script continue to be parsed where it stoped. > gtk::main_quit(); > } > /** self explained */ > function clicked($call_wdgt,$string){ > $this->clicked_button = $string; > if(is_array($this->cbs['clicked'])) > > > call_user_func_array($this->cbs['clicked'][0],$this->cbs['clicked'][1]); > $this->destroy(); > } > /** > load predefined icons by id > @internal > @private > @see msgbox constructor > @uses file2pixmap > */ > function load_icon($icon=0){ > if(! is_numeric($icon)) > return FALSE; > switch($icon){ > case 1: > $xpmd = array( > "31 31 32 1", > "` c #070319", > ". c #a59816", > "# c #f0cc08", > "a c #4f4424", > "b c None",//#d4d2cc", > "c c #faec09", > "d c #473729", > "e c #f9dc05", > "f c #6a612d", > "g c #baa521", > "h c #f0f352", > "i c #fcfb0f", > "j c #bcb2c4", > "k c #cabc18", > "l c #0e055a", > "m c #1e2983", > "n c #646dc9", > "o c #6c8cac", > "p c #2d4eac", > "q c #4461b5", > "r c #3f1581", > "s c #816f11", > "t c #35316e", > "u c #211734", > "v c #54467c", > "w c #9c9a5c", > "x c #cda704", > "y c #151a71", > "z c #767040", > "A c #e0b706", > "B c #37345a", > "C c #e4db3b", > "bbbbbbbbbbbbbhiioobbbbbbbbbbbbb", > "bbbbbbbbbbbbCiiicznbbbbbbbbbbbb", > "bbbbbbbbbbbCcciiikmnbbbbbbbbbbb", > "bbbbbbbbbbbCcihiiifpbbbbbbbbbbb", > "bbbbbbbbbbCCciihiikyqbbbbbbbbbb", > "bbbbbbbbbbCCciiiiiifpbbbbbbbbbb", > "bbbbbjbbb#Cciiiiiiikyqbbbjbbbbb", > "bbbbbbbbbCCcii#Ciiicftbbbbbbbjb", > "bbbbbbbb#eCiCa``fiiikmqbbbbbbbb", > "bbbbbbbbC#cif```u.iiczmbbbbbbbb", > "bbbbjbb##Ciif`l.iiikyqbbbbbbb", > "bbbbbbbC#ciis``lugiiccfmbbbbbbb", > "bbbbbb###cii.`lla#iicckyqbbbbbb", > "bbbbbb#CeiciCa`rsciiiccfmbbbbbb", > "bbbbbA##cicicayt.iccicckyqbbbbb", > "bbbbbk#Cccccismvgicciieefmbbbbb", > "bbbb###eiceci.ld#ieeiieckyqbjbb", > "bbbbk##cceceikuveiceciceezybbbb", > "bbbA##ecceeeiedfcceeecieekyqbbb", > "bbbk##cceeeeccffieeeeciceezmbbb", > "bb###eceeeeeecAAceeeeecieeAypbb", > "bbAA#cceeeeeccciceeeeeeiheezmbb", > "bA##eeee#eecea``sceee#eeie##ypb", > "bkA#eee#e#eis```uxi#e#eecc#ezyb", > "A#A#ee#e#e#if`ultgi#e##eec##Ayr", > "AA##eee#ee#isu`njAc#eee#eee##vr", > "kAA#########c.fzA############zl", > "wxAAAAAAAAAAA###AAAAAAAAAAAA#dy", > "bgxxxxxxxxxxxxxxxxxxxxxxxxxAfyy", > "bbqtttrBttttttttBtBtttrBttBrymb", > "bbbqppppppppptppppppppppppppppb"); > break; > case 2: > $xpmd = array( > "31 31 32 1", > "` c #1d100f", > ". c #ac8684", > "# c #980204", > "a c #9c5351", > "b c #d00506", > "c c #d33738", > "d c #f40e0e", > "e c #d74a49", > "f c #aecdcd", > "g c #b12d2d", > "h c #f66767", > "i c #d91717", > "j c #b80405", > "k c #665a58", > "l c #fa2f2f", > "m c None", > "n c #e00808", > "o c #570607", > "p c #f78b8b", > "q c #9cbebc", > "r c #967372", > "s c #342e2c", > "t c #f8fdfb", > "u c #c8e5e7", > "v c #7f0204", > "w c #fca1a1", > "x c #7c6161", > "y c #fc504f", > "z c #fc7979", > "A c #bf4f4f", > "B c #3c0204", > "C c #bc7274", > "mmmmmmmmmmmmhyyyyhzmmmmmmmmmmmm", > "mmmmmmmmmlyhzpzpzhyllhmmmmmmmmm", > "mmmmmmmlyhzpwwwwzzzhyll.mmmmmmm", > "mmmmmmlyhzpwwwwwpzzhyyllemmmmmm", > "mmmmmlyhzpwpwpzzzzhhyyyllimmmmm", > "mmmmdyyhzzzzhyyyyyyyyyllldgmmmm", > "mmmdyyyhhhyylddddlllyllllliammm", > "mmlllyyyrxldddddddddxalllidirmm", > "mmilyllrfurdddndndnkqqaddlii#mm", > "mlllllruttmrnnnndnkqttf.diiijkm", > "miilllhfttturndnnxqttttyndbibsm", > "miiddddyuttturnbrqttttennibji#m", > "hiildldneutttu..uttttybnnbijj#k", > "cibiddnnncutttttttttebbbbbjjjjs", > "ijiniinnbneutttttttebjbbbbbjjj`", > "jijinnbbbbbettttttcbbbbbbjjj#js", > "gjbbbbbnbbj.ttttttpjjbjjbjjj#j`", > "cjjjbbbbbjxfttttttu.jbjbjjj###`", > "h#jjjbbbjxftttttttturjjjjj##jvs", > "m#jjjjbjkqttttcetttturjjjj###vm", > "m#j#jbjkfttttejjAtttturj#j###Bm", > "mg#j#jrfttttAjjjjAutttt.#####`m", > "mmj#j#gftttejjjjj#Autttg##v#omm", > "mmg####gtte#j#j#jj#Attg##v#v`fm", > "mmmj####AA#j#j#j##j#Acvvvv#Bmmm", > "mmmm#########j##j####v#vv#Bmmmm", > "mmmmm##v############vvvv#ommmmm", > "mmmmmm##vv#######v#vvvvvBmmmmmm", > "mmmmmmmv#vvvvvvvvvvvv#vBmmmmmmm", > "mmmmmmmmmvv#vvvvvvvvvBmmmmmmmmm", > "mmmmmmmmmmmmovvvvoommmmmmmmmmmm"); > break; > default: > $xpmd = array( > "31 31 32 1", > "` c #040d62", > ". c #698ab6", > "# c #accded", > "a c #97989b", > "b c none",//#d4d2cc", > "c c #404f68", > "d c #c6e2fa", > "e c #a3b4c4", > "f c #4e5964", > "g c #86a9cd", > "h c #c2cdda", > "i c #bac0c6", > "j c #dceefb", > "k c #0b3188", > "l c #9dbcdd", > "m c #5a738c", > "n c #f5f9fa", > "o c #244ea4", > "p c #34436a", > "q c #4476d4", > "r c #7d99b3", > "s c #6b7a8e", > "t c #445e9c", > "u c #05227f", > "v c #89b4e1", > "w c #173d94", > "x c #a0a7ae", > "y c #5c6672", > "z c #5376b8", > "A c #7a9bcb", > "B c #dae5f2", > "C c #2c62c4", > "bbbbbbbbbbhjnBnjnBBBbbbbbbbbbbb", > "bbbbbbbhjnnnnnnnnnnnjBihbbbbbbb", > "bbbbbijnnnnnnnnnnnnnnnBbbbbbbbb", > "bbbbinnnnnnnnnnnnnnnnnnjbehbbbb", > "bbbinBnnnnnnBgzz.eBnnnnnBbhbbbb", > "bbiBBnnnnnnekkzw``phnnnnnBhihbb", > "bbBBnnnnnndw.nikuoBnnnnjBexhb", > "biBnnnnnnnx`ukhBcuuuljjnnnBhxxb", > "bbBnnnnjnnlukwljtuukgnjjnjj#eei", > "ibjnnjnjnndAzABdouukljjjjnj#ixy", > "hhjnjjjnjjnjjjnekkwzdnjjdjjdlxs", > "ihBjnjjjjjjjnnjzuCAdjdjdjjdh#xs", > "ihBjjjjjjjjjdnlwovdjjdjddjdh#xs", > "i#Bjjjjjjjjjjj.kAjjddddjddd##ay", > "eihjjjjjdjddjjqodjjddjdddjd#esy", > "gi#djdjdjdjddjlvdddddddddd#lrsx", > "eeihdjddddddjd##djddddddd##e.fb", > "bre#dddjdddddApwz#dddddd##vgyab", > "birelddddddjlk```Add#d###vescbb", > "bberelhdddddvkuku.ddd#d#vg.cabb", > "bbbirel##ddd#zkq.vd###lvg.cxbbb", > "bbbbe.ggll##dlv#####vlvrscxbbbb", > "bbbbbesrgggvvl##d#vvvg.ffxbbbbb", > "bbbbbbiefsrAAAgl#vvAmfpxibbbbbb", > "bbbbbbbbixfysgrv#v.fcxibbbbbbbb", > "bbbbbbbbbbibamgglvsxibbbbibbbbb", > "bbbbbbbbbbbbbamvlvmxbbbbbbbbbbb", > "bbbbibbbbbbbbbamvvmxbbbbbbbbbbb", > "bbbbbbbbbbbbbbbamvmxbbbbbbbbbbb", > "bbbbbbbbbbbbbbbiammxbbbbbbbbbbb", > "bbbbbbbbbbbbibbbbacxbbbbbbbibbb"); > } > # create pixmap > $pix = gdk::pixmap_create_from_xpm_d($this->gdkwindow,null,$xpmd); > $this->pixmap = &new gtkpixmap($pix[0],$pix[1]); > } > } > > ?> > > > > Here follows my example program > > <?php > if (!extension_loaded('gtk')) { > dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); > } > > include "msgbox.class"; > > /** > this will display a blocking msgbox waiting for user input. > it will return the clicked button string > see class message box for more details about params > @param string $title > @param mixed $icon_type > @param string $label > @param string $button_labels > @param int mode > */ > function gtkgui_msgbox($title='Confirmation.',$icon_type=0,$label='Do > you wish to continue ?',$button_labels='cancel|ok',$mode=0){ > $msg = &new msgbox($label,$icon_type,$button_labels,$title,$mode); > $msg->show(); > return $msg->clicked_button; > } > > > > $msg = gtkgui_msgbox('Quit',0,'Do you really want to > quit','cancel|ok',2); > if($msg != 'ok') > echo $msg; > exit; > #else continue to do what you want > else > echo 'failed'; > > ?> > > Thanks for all the help until now. > Hopefully you can help me out once more. > Just trying to use PHP-GTK > thx > > Wim Stockman

« previous php.gtk.general (#4834) next »