cvs: php-gtk-doc / liveGen.php /manual/en/reference/gtk gtklabel.xml

From: Date: Fri, 20 May 2005 04:01:11 +0000
Subject: cvs: php-gtk-doc / liveGen.php /manual/en/reference/gtk gtklabel.xml
Groups: php.gtk.doc 
Request: Send a blank email to php-gtk-doc+get-1436@lists.php.net to get a copy of this message
cweiske Fri May 20 00:01:11 2005 EDT Modified files: /php-gtk-doc liveGen.php /php-gtk-doc/manual/en/reference/gtk gtklabel.xml Log: - Fixed the problem that examples didn't contain any blank lines in test mode - Converted tabs to spaces to be more at the PEAR standards - First documentation: GtkLabel. The three signals and two functions are missing.

http://cvs.php.net/diff.php/php-gtk-doc/liveGen.php?r1=1.1&r2=1.2&ty=u Index: php-gtk-doc/liveGen.php diff -u php-gtk-doc/liveGen.php:1.1 php-gtk-doc/liveGen.php:1.2 --- php-gtk-doc/liveGen.php:1.1 Mon May 2 08:24:28 2005 +++ php-gtk-doc/liveGen.php Fri May 20 00:01:09 2005 @@ -1,428 +1,429 @@ <?php /** -* let's see if I can build my own livedocs :) +* let's see if I can build my own livedocs :) * -* @author Christian Weiske <cweiske@cweiske.de> +* @author Christian Weiske <cweiske@cweiske.de> * -* == What it does == -* The main problem with the php-gtk manual is the size. It has over 2400 functions, -* signals and properties. This leads to a build time of over 5 minutes, which is -* far too long to test the recently written function documentation +* == What it does == +* The main problem with the php-gtk manual is the size. It has over 2400 functions, +* signals and properties. This leads to a build time of over 5 minutes, which is +* far too long to test the recently written function documentation * -* So we've got to issues to solve: Keep the build size very short (one or two seconds) -* and make look the manual as realistic as possible, which means that the original -* xsl stylesheets should be used. -* As we use the original XSL files, we can't simply extract that -* one method/signal/property and let xsltproc run over it. We need a complete -* manual, but this has to be stripped down to the most necessary things: -* - the method/signal/property itself -* - predecessor and successor method/signal/property to the one as we -* want the navigation links to work -* - all the surrounding tags like <classet>, <book> and so +* So we've got to issues to solve: Keep the build size very short (one or two seconds) +* and make look the manual as realistic as possible, which means that the original +* xsl stylesheets should be used. +* As we use the original XSL files, we can't simply extract that +* one method/signal/property and let xsltproc run over it. We need a complete +* manual, but this has to be stripped down to the most necessary things: +* - the method/signal/property itself +* - predecessor and successor method/signal/property to the one as we +* want the navigation links to work +* - all the surrounding tags like <classet>, <book> and so * -* All this is done in this php script, and you can see that it works. +* All this is done in this php script, and you can see that it works. * * -* FIXME: -* - links to other functions/methods/enums/... need to be replaced / methods included -* - extend it to support tutorials and other sections as well -* - cache generated files, especially the large ones (gtk.functions, gtkwidget) +* FIXME: +* - links to other functions/methods/enums/... need to be replaced / methods included +* - extend it to support tutorials and other sections as well +* - cache generated files, especially the large ones (gtk.functions, gtkwidget) */ class PhpGtkLiveDocGenerator { - var $arReferencePrefixes = array('atk', 'gdk', 'gtk', 'pango'); - //relative to manual/en directory - var $arBookFiles = array('../reference.xml', '../tutorials.xml'); - var $arChapters = null; - - var $strLang = 'en'; - var $strTmpFile = 'test_manual.xml'; - - var $tpl_manual = null; - - - - function PhpGtkLiveDocGenerator() - { - global $tpl_manual; - - chdir(dirname(__FILE__)); - $this->tpl_manual = $tpl_manual; - $this->loadChapterents(); - }//function PhpGtkLiveDocGenerator() - - - - /** - * just returns the base path below which the manual files should be located - */ - function getBasePath() - { - return 'manual/' . $this->strLang . '/'; - }//function getBasePath() - - - - /** - * find the file in which $id should be described - * - * @param string $id The id for which the manual is built - * @return string The file in which the id should be. NULL if it doesn't exist - */ - function findFile($id) - { - foreach ($this->arReferencePrefixes as $prefix) { - $preflen = strlen($prefix); - $dotpos = strpos($id, '.', $preflen + 1); - if ($dotpos === false) { - $dotpos = strlen($id); - } - if (substr($id, 0, $preflen + 1) == $prefix . '.') { - //seems it's in the reference - $part = substr($id, $preflen + 1, $dotpos - $preflen - 1); - if ($part == 'method' || $part == 'functions') { - $part = $prefix . '-functions'; - } - $file = 'reference/' . $prefix . '/' . $part . '.xml'; - return $file; - } - } - - //not found yet... - foreach ($this->arBookFiles as $strBookFile) { - $strContent = file_get_contents($this->getBasePath() . $strBookFile); - if (strpos($strContent, ' id="' . $id . '"') !== false) { - return $strBookFile; - } - } - return null; - }//function findFile($id) - - - - /** - * checks if the given file is a special book file - */ - function isBookFile($strFile) - { - return in_array($strFile, $this->arBookFiles); - }//function isBookFile($strFile) - - - - /** - * find the neighbour files to the given one - */ - function findNeighbours($file) - { - if ($file === null) { - return null; - } - - if (substr($file, 0, 10) != 'reference/') { - return null; - } - - $fileid = $this->findChapterId($file); - $arLines = file('manual/reference.xml'); - $arFiles = array(); - $bFound = false; - $strPrevious = null; - $strNext = null; - foreach ($arLines as $nLine => $strLine) { - $strLine = trim($strLine); - if ($strLine[0] == '&') { - $strId = substr($strLine, 1, -1); - $strFile = $this->arChapters[$strId]; - $arFiles[] = $strFile; - if ($strFile == $file) { - $bFound = true; - $strPrevious = $arFiles[count($arFiles) - 2]; - continue; - } - } else if (substr($strLine, 0, 9) == '<classset') { - $arFiles[] = 'reference.xml'; - } else { - continue; - } - - if ($bFound) { - $strNext = $arFiles[count($arFiles) - 1]; - break; - } - } - - return array($strPrevious, $strNext); - }//function findNeighbours($file) - - - - /** - * parses the chapterents file and loads it into an array - */ - function loadChapterents() - { - if ($this->arChapters !== null) { - return; - } - $arLines = file($this->getBasePath() . '/chapters.ent'); - foreach ($arLines as $nLine => $strLine) { - if ($nLine == 0) { continue; } - $nSpacePos = strpos($strLine, ' ', 10); - $strId = substr($strLine, 9, $nSpacePos - 9); - $strFile = substr($strLine, $nSpacePos + 9, -4); - $this->arChapters[$strId] = $strFile; - } - }//function loadChapterents() - - - - /** - * finds the chapter id to the given filename - * e.g. "reference.gtk.gtkaboutdialog" for "reference/gtk/gtkaboutdialog.xml" - * uses chapters.ent for lookup - * - * @param string $file The filename to check - * @return string The chapterid used in chapters.ent - */ - function findChapterId($file) - { - $this->loadChapterents(); - foreach ($this->arChapters as $id => $strFile) { - if ($strFile == $file) { - return $id; - } - } - return null; - }//function findChapterId($file) - - - - /** - * Finds out if the given id in the file is the first or the last id in the given file. - * This is necessary as we may need to include the predecessor or - * successor file to have the real manual feeling. - * - * @param string $id The id for which the manual is built - * @param string $file The filename in which the id should be - * @return array Array with two boolean values: first one tells if $id is the first one, the second if $id is the last id in the file - */ - function getPositionInfo($id, $file) - { - $arLines = file($this->getBasePath() . $file); - $bFirst = false; - $bLast = false; - $nIds = 0; - $nMyPos = -1; - - foreach ($arLines as $strLine) { - if (preg_match('/id="[^"]+">/', $strLine)) { - if (strpos($strLine, 'id="' . $id . '">') !== false) { - if ($nIds == 0) { - $bFirst = true; - } - $nMyPos = $nIds + 1; - } - $nIds++; - } - } - - if ($nMyPos == $nIds) { - $bLast = true; - } - - return array($bFirst, $bLast); - }//function getPositionInfo($id, $file) - - - - /** - * builds the manual file with its contents stripped - * down to only have necessary sections for the given id - * - * @param string $id The id for which the test manual should be build - */ - function buildManualFile($id) - { - $manual = str_replace('&book;', $this->stripDownBook('reference.xml', $id), $this->tpl_manual); - - $strFile = $this->getBasePath() . $this->strTmpFile; - echo 'Generating test manual file ' . $strFile . ' '; - $hdl = fopen($strFile, 'w+'); - fwrite($hdl, $manual); - fclose($hdl); - echo 'done' . "\r\n"; - }//function buildManualFile($id) - - - - /** - * strips down the book file (reference.xml, tutorials.xml) - * and replaces the required entities - * - * @param string $bookfile The book file (like "reference.xml") - * @param string $id The function id to generate (e.g. "gtk.method.accel_map_load") - * @return string The book's contents - */ - function stripDownBook($bookfile, $id) - { - $file = $this->findFile($id); - - if ($this->isBookFile($file)) { - return $this->stripDownBookOverview($bookfile, $id); - } else { - return $this->stripDownBookNormal($bookfile, $id, $file); - } - }//function stripDownBook($bookfile, $id) - - - - /** - * implements stripping down of book files for *normal* ids, - * e.g. classes and class methods - * NOT class overviews - */ - function stripDownBookNormal($bookfile, $id, $file) - { - $chapid = $this->findChapterId($file); - list($bIsFirst, $bIsLast) = $this->getPositionInfo($id, $file); - $arNeighbours = $this->findNeighbours($file); - $arNeighbourIds = array( - $this->findChapterId($arNeighbours[0]), - $this->findChapterId($arNeighbours[1]) - ); - - $arLines = file('manual/' . $bookfile); - $strBookContent = ''; - foreach ($arLines as $nLine => $strLine) { - if (substr($strLine, 0, 3) != ' &') { - if ($nLine > 0) { - $strBookContent .= $strLine; - } - continue; - } - $strLine2 = trim($strLine); - $nFileType = 0; - //the $nFileType = <number> assignments in the if are intended - if ( ($strLine2 == '&' . $chapid . ';' && ($nFileType = 0) !== false) - || ($arNeighbourIds[0] !== null && $bIsFirst && $strLine2 == '&' . $arNeighbourIds[0] . ';' && ($nFileType = -1) !== false) - || ($arNeighbourIds[1] !== null && $bIsLast && $strLine2 == '&' . $arNeighbourIds[1] . ';' && ($nFileType = 1) !== false) - ) { - $strBookContent .= $this->getFileContents(substr($strLine2, 1, -1), $id, $nFileType); - } - } - - //Fixme: remove empty classsets and such unneeded things - - return $strBookContent; - }//function stripDownBookNormal($bookfile, $id, $file) - - - - /** - * strips down the book itself and includes all the (stripped down) classes below it - * especially reference.xml - * - * @return string The stripped & extendet book - */ - function stripDownBookOverview($bookfile, $id) - { - $arLines = file('manual/' . $bookfile); - $strBookContent = ''; - $bInIt = false; - foreach ($arLines as $nLine => $strLine) { - $strLine2 = trim($strLine); - if (substr($strLine, 0, 3) != ' &') { - if ($nLine > 0) { - if ($strLine2 == '<classset id="' . $id . '">') { - $bInIt = true; - } else if ($bInIt && $strLine2 == '</classset>') { - $bInIt = false; - } - $strBookContent .= $strLine; - } - continue; - } - if ($bInIt) { - $strBookContent .= $this->getFileContents(substr($strLine2, 1, -1), $id, 1); - } - } - - //Fixme: remove empty classsets and such unneeded things - - return $strBookContent; - }//function stripDownBookOverview($bookfile, $id) - - - - /** - * loads the file's contents, strips them down to contain only - * required ids (top id, function id itself, predecessor and successor functions of the id's function itself) - * - * @param string $refid The id which the file in the book (e.g. reference.xml) has - * @param string $id id of the function to be displayed in live - * @param int $nFileType 0 if its the file itself, -1 if the predecessor, 1 for the successor - */ - function getFileContents($refid, $id, $nFileType) - { - $arContents = file($this->getBasePath() . $this->arChapters[$refid]); - - $strStrippedContents = ''; - $bWaiting = false; - $strTag = ''; - $nIdNum = 0;//number of current id - $nIdPos = 0;//position of $id in id array - - if ($nFileType == 0) { - //we're in the main file of the given id and need the position of the id among all other ids - $arMatches = array(); - preg_match_all('/ id="([^"]+)"/', implode("\r\n", $arContents), $arMatches); - unset($arMatches[0]); - - $nMaxId = count($arMatches[1]); - //find the right position - foreach ($arMatches[1] as $nThisIdPos => $strThisId) { - if ($strThisId == $id) { - $nIdPos = $nThisIdPos + 1; - break; - } - } - } else { - $nMaxId = substr_count(implode("\r\n", $arContents), ' id="'); - } - - foreach ($arContents as $strLine) { - if (!$bWaiting) { - //find an id - $nPos = strpos($strLine, ' id='); - if ($nPos !== false) { - $nIdNum++; - if ($nIdNum == 1 - || $nIdPos == 1 - || ($nFileType == -1 && $nIdNum == $nMaxId) - || ($nFileType == 0 && abs($nIdPos - $nIdNum) <= 1) - ) { - $strStrippedContents .= $strLine; - } else { - $nPosOpen = strpos($strLine, '<') + 1; - $strTag = substr($strLine, $nPosOpen, $nPos - $nPosOpen); - $bWaiting = true; - } - } else { - if (trim($strLine) != '') { - $strStrippedContents .= $strLine; - } - } - } else { - //find closing tag - if (strpos($strLine, '</' . $strTag . '>') !== false) { - $bWaiting = false; - } - } - } - return $strStrippedContents; - }//function getFileContents($refid, $nFileType) - + var $arReferencePrefixes = array('atk', 'gdk', 'gtk', 'pango'); + //relative to manual/en directory + var $arBookFiles = array('../reference.xml', '../tutorials.xml'); + var $arChapters = null; + + var $strLang = 'en'; + var $strTmpFile = 'test_manual.xml'; + + var $tpl_manual = null; + + + + function PhpGtkLiveDocGenerator() + { + global $tpl_manual; + + chdir(dirname(__FILE__)); + $this->tpl_manual = $tpl_manual; + $this->loadChapterents(); + }//function PhpGtkLiveDocGenerator() + + + + /** + * just returns the base path below which the manual files should be located + */ + function getBasePath() + { + return 'manual/' . $this->strLang . '/'; + }//function getBasePath() + + + + /** + * find the file in which $id should be described + * + * @param string $id The id for which the manual is built + * @return string The file in which the id should be. NULL if it doesn't exist + */ + function findFile($id) + { + foreach ($this->arReferencePrefixes as $prefix) { + $preflen = strlen($prefix); + $dotpos = strpos($id, '.', $preflen + 1); + if ($dotpos === false) { + $dotpos = strlen($id); + } + if (substr($id, 0, $preflen + 1) == $prefix . '.') { + //seems it's in the reference + $part = substr($id, $preflen + 1, $dotpos - $preflen - 1); + if ($part == 'method' || $part == 'functions') { + $part = $prefix . '-functions'; + } + $file = 'reference/' . $prefix . '/' . $part . '.xml'; + return $file; + } + } + + //not found yet... + foreach ($this->arBookFiles as $strBookFile) { + $strContent = file_get_contents($this->getBasePath() . $strBookFile); + if (strpos($strContent, ' id="' . $id . '"') !== false) { + return $strBookFile; + } + } + return null; + }//function findFile($id) + + + + /** + * checks if the given file is a special book file + */ + function isBookFile($strFile) + { + return in_array($strFile, $this->arBookFiles); + }//function isBookFile($strFile) + + + + /** + * find the neighbour files to the given one + */ + function findNeighbours($file) + { + if ($file === null) { + return null; + } + + if (substr($file, 0, 10) != 'reference/') { + return null; + } + + $fileid = $this->findChapterId($file); + $arLines = file('manual/reference.xml'); + $arFiles = array(); + $bFound = false; + $strPrevious = null; + $strNext = null; + foreach ($arLines as $nLine => $strLine) { + $strLine = trim($strLine); + if ($strLine[0] == '&') { + $strId = substr($strLine, 1, -1); + $strFile = $this->arChapters[$strId]; + $arFiles[] = $strFile; + if ($strFile == $file) { + $bFound = true; + $strPrevious = $arFiles[count($arFiles) - 2]; + continue; + } + } else if (substr($strLine, 0, 9) == '<classset') { + $arFiles[] = 'reference.xml'; + } else { + continue; + } + + if ($bFound) { + $strNext = $arFiles[count($arFiles) - 1]; + break; + } + } + + return array($strPrevious, $strNext); + }//function findNeighbours($file) + + + + /** + * parses the chapterents file and loads it into an array + */ + function loadChapterents() + { + if ($this->arChapters !== null) { + return; + } + $arLines = file($this->getBasePath() . '/chapters.ent'); + foreach ($arLines as $nLine => $strLine) { + if ($nLine == 0) { continue; } + $nSpacePos = strpos($strLine, ' ', 10); + $strId = substr($strLine, 9, $nSpacePos - 9); + $strFile = substr($strLine, $nSpacePos + 9, -4); + $this->arChapters[$strId] = $strFile; + } + }//function loadChapterents() + + + + /** + * finds the chapter id to the given filename + * e.g. "reference.gtk.gtkaboutdialog" for "reference/gtk/gtkaboutdialog.xml" + * uses chapters.ent for lookup + * + * @param string $file The filename to check + * @return string The chapterid used in chapters.ent + */ + function findChapterId($file) + { + $this->loadChapterents(); + foreach ($this->arChapters as $id => $strFile) { + if ($strFile == $file) { + return $id; + } + } + return null; + }//function findChapterId($file) + + + + /** + * Finds out if the given id in the file is the first or the last id in the given file. + * This is necessary as we may need to include the predecessor or + * successor file to have the real manual feeling. + * + * @param string $id The id for which the manual is built + * @param string $file The filename in which the id should be + * @return array Array with two boolean values: first one tells if $id is the first one, the second if $id is the last id in the file + */ + function getPositionInfo($id, $file) + { + $arLines = file($this->getBasePath() . $file); + $bFirst = false; + $bLast = false; + $nIds = 0; + $nMyPos = -1; + + foreach ($arLines as $strLine) { + if (preg_match('/id="[^"]+">/', $strLine)) { + if (strpos($strLine, 'id="' . $id . '">') !== false) { + if ($nIds == 0) { + $bFirst = true; + } + $nMyPos = $nIds + 1; + } + $nIds++; + } + } + + if ($nMyPos == $nIds) { + $bLast = true; + } + + return array($bFirst, $bLast); + }//function getPositionInfo($id, $file) + + + + /** + * builds the manual file with its contents stripped + * down to only have necessary sections for the given id + * + * @param string $id The id for which the test manual should be build + */ + function buildManualFile($id) + { + $manual = str_replace('&book;', $this->stripDownBook('reference.xml', $id), $this->tpl_manual); + + $strFile = $this->getBasePath() . $this->strTmpFile; + echo 'Generating test manual file ' . $strFile . ' '; + $hdl = fopen($strFile, 'w+'); + fwrite($hdl, $manual); + fclose($hdl); + echo 'done' . "\r\n"; + }//function buildManualFile($id) + + + + /** + * strips down the book file (reference.xml, tutorials.xml) + * and replaces the required entities + * + * @param string $bookfile The book file (like "reference.xml") + * @param string $id The function id to generate (e.g. "gtk.method.accel_map_load") + * @return string The book's contents + */ + function stripDownBook($bookfile, $id) + { + $file = $this->findFile($id); + + if ($this->isBookFile($file)) { + return $this->stripDownBookOverview($bookfile, $id); + } else { + return $this->stripDownBookNormal($bookfile, $id, $file); + } + }//function stripDownBook($bookfile, $id) + + + + /** + * implements stripping down of book files for *normal* ids, + * e.g. classes and class methods + * NOT class overviews + */ + function stripDownBookNormal($bookfile, $id, $file) + { + $chapid = $this->findChapterId($file); + list($bIsFirst, $bIsLast) = $this->getPositionInfo($id, $file); + $arNeighbours = $this->findNeighbours($file); + $arNeighbourIds = array( + $this->findChapterId($arNeighbours[0]), + $this->findChapterId($arNeighbours[1]) + ); + + $arLines = file('manual/' . $bookfile); + $strBookContent = ''; + foreach ($arLines as $nLine => $strLine) { + if (substr($strLine, 0, 3) != ' &') { + if ($nLine > 0) { + $strBookContent .= $strLine; + } + continue; + } + $strLine2 = trim($strLine); + $nFileType = 0; + //the $nFileType = <number> assignments in the if are intended + if ( ($strLine2 == '&' . $chapid . ';' && ($nFileType = 0) !== false) + || ($arNeighbourIds[0] !== null && $bIsFirst && $strLine2 == '&' . $arNeighbourIds[0] . ';' && ($nFileType = -1) !== false) + || ($arNeighbourIds[1] !== null && $bIsLast && $strLine2 == '&' . $arNeighbourIds[1] . ';' && ($nFileType = 1) !== false) + ) { + $strBookContent .= $this->getFileContents(substr($strLine2, 1, -1), $id, $nFileType); + } + } + + //Fixme: remove empty classsets and such unneeded things + + return $strBookContent; + }//function stripDownBookNormal($bookfile, $id, $file) + + + + /** + * strips down the book itself and includes all the (stripped down) classes below it + * especially reference.xml + * + * @return string The stripped & extendet book + */ + function stripDownBookOverview($bookfile, $id) + { + $arLines = file('manual/' . $bookfile); + $strBookContent = ''; + $bInIt = false; + foreach ($arLines as $nLine => $strLine) { + $strLine2 = trim($strLine); + if (substr($strLine, 0, 3) != ' &') { + if ($nLine > 0) { + if ($strLine2 == '<classset id="' . $id . '">') { + $bInIt = true; + } else if ($bInIt && $strLine2 == '</classset>') { + $bInIt = false; + } + $strBookContent .= $strLine; + } + continue; + } + if ($bInIt) { + $strBookContent .= $this->getFileContents(substr($strLine2, 1, -1), $id, 1); + } + } + + //Fixme: remove empty classsets and such unneeded things + + return $strBookContent; + }//function stripDownBookOverview($bookfile, $id) + + + + /** + * loads the file's contents, strips them down to contain only + * required ids (top id, function id itself, predecessor and successor functions of the id's function itself) + * + * @param string $refid The id which the file in the book (e.g. reference.xml) has + * @param string $id id of the function to be displayed in live + * @param int $nFileType 0 if its the file itself, -1 if the predecessor, 1 for the successor + */ + function getFileContents($refid, $id, $nFileType) + { + $arContents = file($this->getBasePath() . $this->arChapters[$refid]); + + $strStrippedContents = ''; + $bWaiting = false;//if we are waiting for a closing tag + $strTag = '';//the tag we wait for + $nIdNum = 0;//number of current id + $nIdPos = 0;//position of $id in id array + + if ($nFileType == 0) { + //we're in the main file of the given id and need the position of the id among all other ids + $arMatches = array(); + preg_match_all('/ id="([^"]+)"/', implode("\r\n", $arContents), $arMatches); + unset($arMatches[0]); + + $nMaxId = count($arMatches[1]); + //find the right position + foreach ($arMatches[1] as $nThisIdPos => $strThisId) { + if ($strThisId == $id) { + $nIdPos = $nThisIdPos + 1; + break; + } + } + } else { + $nMaxId = substr_count(implode("\r\n", $arContents), ' id="'); + } + + foreach ($arContents as $strLine) { + if (!$bWaiting) { + //find an id + $nPos = strpos($strLine, ' id='); + if ($nPos !== false) { + $nIdNum++; + if ($nIdNum == 1 + || $nIdPos == 1 + || ($nFileType == -1 && $nIdNum == $nMaxId) + || ($nFileType == 0 && abs($nIdPos - $nIdNum) <= 1) + ) { + $strStrippedContents .= $strLine; + } else { + $nPosOpen = strpos($strLine, '<') + 1; + $strTag = substr($strLine, $nPosOpen, $nPos - $nPosOpen); + $bWaiting = true; + } + } else { + //I deactivated this if statement because the programlisting examples wouldn't have empty lines + //if (trim($strLine) != '') { + $strStrippedContents .= $strLine; + //} + } + } else { + //find closing tag + if (strpos($strLine, '</' . $strTag . '>') !== false) { + $bWaiting = false; + } + } + } + return $strStrippedContents; + }//function getFileContents($refid, $nFileType) + }//class PhpGtkLiveDocGenerator $tpl_manual = <<<EOD @@ -441,10 +442,10 @@ if (!isset($GLOBALS['liveUnitTest']) || !$GLOBALS['liveUnitTest']) { - $ld = new PhpGtkLiveDocGenerator(); - if (!isset($argv[1])) { - die('Pass the ID as parameter' . "\r\n"); - } - $ld->buildManualFile($argv[1]); + $ld = new PhpGtkLiveDocGenerator(); + if (!isset($argv[1])) { + die('Pass the ID as parameter' . "\r\n"); + } + $ld->buildManualFile($argv[1]); } ?> \ No newline at end of file http://cvs.php.net/diff.php/php-gtk-doc/manual/en/reference/gtk/gtklabel.xml?r1=1.4&r2=1.5&ty=u Index: php-gtk-doc/manual/en/reference/gtk/gtklabel.xml diff -u php-gtk-doc/manual/en/reference/gtk/gtklabel.xml:1.4 php-gtk-doc/manual/en/reference/gtk/gtklabel.xml:1.5 --- php-gtk-doc/manual/en/reference/gtk/gtklabel.xml:1.4 Thu Apr 28 14:10:27 2005 +++ php-gtk-doc/manual/en/reference/gtk/gtklabel.xml Fri May 20 00:01:11 2005 @@ -3,10 +3,16 @@ <classtitle>GtkLabel</classtitle> <classparent>GtkMisc</classparent> <shortdesc> - + A widget that displays a small to medium amount of text. </shortdesc> <desc> - + <para> + The GtkLabel widget displays a small amount of text. + As the name implies, most labels are used to label + another widget such as a <classname>GtkButton</classname>, + a <classname>GtkMenuItem</classname>, or a + <classname>GtkOptionMenu</classname>. + </para> </desc> </classmeta> @@ -17,28 +23,48 @@ <funcprototype> <funcdef> <function>GtkLabel</function></funcdef> <paramdef>string <parameter><optional>string = NULL</optional></parameter></paramdef> + <paramdef>boolean <parameter><optional>parse_mnemonic = FALSE</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Creates a new <classname>GtkLabel</classname>. </shortdesc> <desc> + <para> + Creates a new label with an (optional) text. If you set the <parameter>parse_mnemonic</parameter> to true, + the label will set the mnemonic key to the first letter right to the first underscore <literal>_</literal>. + </para> + <para> + <example> + <title>Creating a GtkLabel</title> + <programlisting role="php"> +<![CDATA[<?php +function rotate($label) { + $label->set_label($label->get_angle() . ' ' . 'label text - this <b>is</b> a' + . '<span foreground="#F00">very long label</span>' + . 'so we can see <span background="green" size="larger"' + . ' weight="bold">rotation</span> better'); + $label->set_angle($label->get_angle() + 1); + return true; +} - </desc> - </constructor> +$wnd = new GtkWindow(); +$wnd->set_default_size(500,500); +$wnd->set_title('GtkLabel::set_angle'); +$wnd->connect_object('destroy', array('gtk', 'main_quit')); - <constructor id="gtk.gtklabel.constructor.new_with_mnemonic"> - <funcsynopsis> - <funcprototype> - <funcdef> <function>GtkLabel::new_with_mnemonic</function></funcdef> - <paramdef>string <parameter><optional>string = NULL</optional></parameter></paramdef> - </funcprototype> - </funcsynopsis> - <shortdesc> +$label = new GtkLabel('t_est', true); +$label->set_use_markup(true); - </shortdesc> - <desc> +$wnd->add($label); +$wnd->show_all(); +Gtk::timeout_add(50, 'rotate', $label); +Gtk::main(); +?> +]]></programlisting> + </example> + </para> </desc> </constructor> @@ -54,10 +80,16 @@ </funcprototype> </funcsynopsis> <shortdesc> - + DEPRECATED. Gets the string of the label. </shortdesc> <desc> - + <para> + DEPRECATED. Gets the string of the label. + </para> + <para> + Use <function class="GtkLabel">get_text</function> or + <function class="GtkLabel">get_label</function> instead. + </para> </desc> </method> @@ -69,14 +101,16 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Gets the angle of rotation for the label. </shortdesc> <desc> <para> + Returns the angle of rotation in degrees (0-359). + </para> + <para> See also: <function class="GtkLabel">set_angle</function> </para> - </desc> </method> @@ -102,19 +136,21 @@ <method id="gtk.gtklabel.method.get_ellipsize"> <funcsynopsis> <funcprototype> - <funcdef> <function>get_ellipsize</function></funcdef> + <funcdef><classname>PangoEllipsizeMode</classname> <function>get_ellipsize</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Returns the ellipsization mode is used to shorten the text. </shortdesc> <desc> <para> + Returns the ellipsization mode is used to shorten the text. + </para> + <para> See also: <function class="GtkLabel">set_ellipsize</function> </para> - </desc> </method> @@ -126,9 +162,12 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the justification of the label. </shortdesc> <desc> + <simpara> + Returns the justification of the label. + </simpara> <para> See also: <function class="GtkLabel">set_justify</function> @@ -145,29 +184,35 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Fetches the text including any embedded underlines indicating mnemonics and Pango markup. </shortdesc> <desc> <para> + Fetches the text from a label widget including any embedded + underlines indicating mnemonics and Pango markup. + </para> + <para> See also: - <function class="GtkLabel">set_label</function> + <function class="GtkLabel">set_label</function>, + <function class="GtkLabel">set_text</function> </para> - </desc> </method> <method id="gtk.gtklabel.method.get_layout"> <funcsynopsis> <funcprototype> - <funcdef> <function>get_layout</function></funcdef> + <funcdef><classname>PangoLayout</classname> <function>get_layout</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Gets the <classname>PangoLayout</classname> used to display the label. </shortdesc> <desc> - + <para> + Gets the <classname>PangoLayout</classname> used to display the label + </para> </desc> </method> @@ -179,10 +224,21 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Obtains the coordinates where the label will draw the <classname>PangoLayout</classname>. </shortdesc> <desc> - + <para> + Obtains the coordinates where the label will draw the <classname>PangoLayout</classname> + representing the text in the label; + useful to convert mouse events into coordinates inside the <classname>PangoLayout</classname>, + e.g. to take some action if some part of the label is clicked. + </para> + <para> + Of course you will need to create a <classname>GtkEventBox</classname> to receive + the events, and pack the label inside it, since labels are a Gtk::NO_WINDOW widget. + Remember when using the <classname>PangoLayout</classname> functions you need to convert + to and from pixels using PANGO_PIXELS() or PANGO_SCALE. + </para> </desc> </method> @@ -194,10 +250,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns whether lines in the label are automatically wrapped. </shortdesc> <desc> <para> + Returns whether lines in the label are automatically wrapped. + </para> + <para> See also: <function class="GtkLabel">set_line_wrap</function> </para> @@ -213,10 +272,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the maximum width in characters. </shortdesc> <desc> <para> + Returns the maximum width in characters. + </para> + <para> See also: <function class="GtkLabel">set_max_width_chars</function> </para> @@ -232,29 +294,36 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the keyval of the mnemonic key if set. </shortdesc> <desc> - + <para> + If the label has been set so that it has an mnemonic key this + function returns the keyval used for the mnemonic accelerator. + If there is no mnemonic set up it returns + <literal>Gdk::VoidSymbol</literal>. + </para> </desc> </method> <method id="gtk.gtklabel.method.get_mnemonic_widget"> <funcsynopsis> <funcprototype> - <funcdef>GtkWidget <function>get_mnemonic_widget</function></funcdef> + <funcdef><classname>GtkWidget</classname> <function>get_mnemonic_widget</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Retrieves the target of the mnemonic (keyboard shortcut) of this label. </shortdesc> <desc> <para> + Retrieves the target of the mnemonic (keyboard shortcut) of this label. + </para> + <para> See also: <function class="GtkLabel">set_mnemonic_widget</function> </para> - </desc> </method> @@ -266,10 +335,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Checks it the user can select text in the label. </shortdesc> <desc> <para> + Checks it the user can select text in the label. + </para> + <para> See also: <function class="GtkLabel">set_selectable</function> </para> @@ -280,15 +352,26 @@ <method id="gtk.gtklabel.method.get_selection_bounds"> <funcsynopsis> <funcprototype> - <funcdef>bool <function>get_selection_bounds</function></funcdef> + <funcdef>array <function>get_selection_bounds</function></funcdef> <paramdef>void</paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Gets the selected range of characters in the label. </shortdesc> <desc> - + <para> + Gets the selected range of characters in the label. The first array value is the + start character offset, the second the end offset. + </para> + <para> + So a return array of <literal>array(1,2)</literal> would mean that 1 character + (from position 1 to position 2) is selected. + </para> + <para> + See also: + <function class="GtkLabel">select_region</function> + </para> </desc> </method> @@ -300,14 +383,16 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns if the label displays only one line. </shortdesc> <desc> <para> + Returns whether the label is in single line mode. + </para> + <para> See also: <function class="GtkLabel">set_single_line_mode</function> </para> - </desc> </method> @@ -319,11 +404,16 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Fetches the text from a label widget, as displayed on the screen. </shortdesc> <desc> + <simpara> + Fetches the text from a label widget, as displayed on the screen. + This does not include any embedded underlines indicating mnemonics or Pango markup. + </simpara> <para> See also: + <function class="GtkLabel">get_label</function>, <function class="GtkLabel">set_text</function> </para> @@ -338,10 +428,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns whether the label's text is interpreted as marked up with the Pango text markup language. </shortdesc> <desc> <para> + Returns whether the label's text is interpreted as marked up with the Pango text markup language. + </para> + <para> See also: <function class="GtkLabel">set_use_markup</function> </para> @@ -357,10 +450,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns whether an embedded underline in the label indicates a mnemonic. </shortdesc> <desc> <para> + Returns whether an embedded underline in the label indicates a mnemonic. + </para> + <para> See also: <function class="GtkLabel">set_use_underline</function> </para> @@ -376,14 +472,16 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Retrieves the desired width of the label, in characters. </shortdesc> <desc> <para> + Retrieves the desired width of the label, in characters. + </para> + <para> See also: <function class="GtkLabel">set_width_chars</function> </para> - </desc> </method> @@ -395,10 +493,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + DEPRECATED. Parses the given string for underscores and converts the next character to an underlined character. </shortdesc> <desc> - + <para> + Parses the given string for underscores and converts the next character to an underlined character. + The last character that was underlined will have its lower-cased accelerator keyval + returned (i.e. "_File" would return the keyval for "f". + This is probably only used within the Gtk+ library itself for menu items and such. + </para> </desc> </method> @@ -411,10 +514,19 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Selects a range of characters in the label, if the label is selectable. </shortdesc> <desc> - + <para> + Selects a range of characters in the label, if the label is selectable. + If the label is not selectable, this function has no effect. + If start_offset or end_offset are -1, then the end of the label will be substituted. + </para> + <para> + See also: + <function class="GtkLabel">get_selectable</function>, + <function class="GtkLabel">get_selection_bounds</function>, + </para> </desc> </method> @@ -426,10 +538,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + DEPRECATED. Alias for <function class="GtkLabel">set_text</function>. </shortdesc> <desc> - + <para> + DEPRECATED. Alias for <function class="GtkLabel">set_text</function>. + Only for backwards compatibility. + </para> </desc> </method> @@ -441,10 +556,15 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the angle of rotation for the label. </shortdesc> <desc> <para> + Sets the angle of rotation for the label (0-359). + An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom. + The angle setting for the label is ignored if the label is selectable, wrapped, or ellipsized. + </para> + <para> See also: <function class="GtkLabel">get_angle</function> </para> @@ -475,18 +595,31 @@ <funcsynopsis> <funcprototype> <funcdef>void <function>set_ellipsize</function></funcdef> - <paramdef>void</paramdef> + <paramdef><classname>PangoEllipsizeMode</classname> <parameter>ellipsizationmode</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Sets the ellipsization mode used to make the text fit the width. </shortdesc> <desc> <para> + Sets the ellipsization mode used to fit the text to a given width. + In the ellipsization process characters are removed from the text in + order to make it fit to a given width and replaced with an ellipsis. + </para> + <para> + If a window is 100px in width, and the text in the <classname>GtkLabel</classname> + would need 200px space to display, the window is resized to fit the label + (with <literal>Pango::ELLIPSIZE_NONE</literal>). The modes + <literal>Pango::ELLIPSIZE_START</literal>, <literal>Pango::ELLIPSIZE_MIDDLE</literal> and + <literal>Pango::ELLIPSIZE_END</literal> replace some text at the beginning, middle or end + with three dots (<literal>...</literal>) to make the needed width smaller and therefore keep the + original width of 100px. + </para> + <para> See also: <function class="GtkLabel">get_ellipsize</function> </para> - </desc> </method> @@ -494,14 +627,24 @@ <funcsynopsis> <funcprototype> <funcdef>void <function>set_justify</function></funcdef> - <paramdef>GtkJustification <parameter>jtype</parameter></paramdef> + <paramdef><classname>GtkJustification</classname> <parameter>jtype</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc> - + Sets the alignment of the lines in the text of the label relative to each other. </shortdesc> <desc> <para> + Sets the alignment of the lines in the text of the label relative to each other. + <literal>Gtk::JUSTIFY_LEFT</literal> is the default value when the widget is first + created. + </para> + <para> + If you instead want to set the alignment of the label as a whole, + use <function class="GtkMisc">set_alignment</function> instead. + It <emphasis>has no effect</emphasis> on labels containing only a <emphasis>single line</emphasis>. + </para> + <para> See also: <function class="GtkLabel">get_justify</function> </para> @@ -517,12 +660,23 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the text of the label incl. Pango markup. </shortdesc> <desc> <para> + Sets the text of the label. + The label is interpreted as including embedded underlines and/or + Pango markup depending on the values of <function class="GtkLabel">set_use_underline</function> + and <function class="GtkLabel">set_use_markup</function> + </para> + <para> + By default, <literal>use_markup</literal> is not activated - you've got to enable it before. + </para> + <para> See also: - <function class="GtkLabel">get_label</function> + <function class="GtkLabel">get_label</function>, + <function class="GtkLabel">set_text</function>, + <function class="GtkLabel">set_markup</function> </para> </desc> @@ -536,14 +690,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Toggles line wrapping within the GtkLabel widget. </shortdesc> <desc> <para> + Toggles line wrapping within the GtkLabel widget. + TRUE makes it break lines if text exceeds the widget's size. + FALSE lets the text get cut off by the edge of the widget if it exceeds the widget size. + </para> + <para> See also: <function class="GtkLabel">get_line_wrap</function> </para> - </desc> </method> @@ -555,10 +713,17 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Set the label text with a pango marked up string. </shortdesc> <desc> - + <para> + Parses str which is marked up with the Pango text markup language, + setting the label's text and attribute list based on the parse results. + <!-- FIXME + If the str is external data, you may need to escape it with + g_markup_escape_text() or g_markup_printf_escaped(): + --> + </para> </desc> </method> @@ -570,10 +735,21 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Set the label text and mnemonic with a pango marked up string. </shortdesc> <desc> - + <para> + Parses str which is marked up with the Pango text markup language, + setting the label's text and attribute list based on the parse results. + If characters in str are preceded by an underscore, + they are underlined indicating that they represent a keyboard + accelerator called a mnemonic. + </para> + <para> + The mnemonic key can be used to activate another widget, + chosen automatically, or explicitly using + <function class="GtkLabel">set_mnemonic_widget</function>. + </para> </desc> </method> @@ -585,10 +761,13 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the desired maximum width in characters. </shortdesc> <desc> <para> + Sets the desired maximum width in characters to <literal>n_chars</literal> chars. + </para> + <para> See also: <function class="GtkLabel">get_max_width_chars</function> </para> @@ -604,10 +783,29 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Returns the widget associated with the mnemonic key. </shortdesc> <desc> <para> + If the label has been set so that it has an mnemonic key (using + <function class="GtkLabel">set_markup_with_mnemonic</function>, + <function class="GtkLabel">set_text_with_mnemonic</function> or + the constructor) + the label can be associated with a widget that is the target of + the mnemonic. When the label is inside a widget + (like a <classname>GtkButton</classname> or a <classname>GtkNotebook</classname> + tab) it is automatically associated with the correct widget, but + sometimes (i.e. when the target is a <classname>GtkEntry</classname> + next to the label) you need to set it explicitly using this function. + </para> + <para> + <!-- FIXME: link the mnemonic_activate signal --> + The target widget will be accelerated by emitting "mnemonic_activate" + on it. The default handler for this signal will activate the + widget if there are no mnemonic collisions and toggle focus + between the colliding widgets otherwise. + </para> + <para> See also: <function class="GtkLabel">get_mnemonic_widget</function> </para> @@ -623,10 +821,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + The pattern of underlines you want under the existing text within the GtkLabel widget. </shortdesc> <desc> - + <para> + The pattern of underlines you want under the existing text + within the GtkLabel widget. + </para> + <para> + For example if the current text of the label says "FooBarBaz" + passing a pattern of "<literal><![CDATA[___ ___]]></literal>" + will underline "Foo" and "Baz" but not "Bar". + </para> </desc> </method> @@ -638,10 +844,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Selectable labels allow the user to select text from the label, for copy-and-paste. </shortdesc> <desc> <para> + Selectable labels allow the user to select text from the label, for copy-and-paste. + With this function you can enable and disable it. + </para> + <para> See also: <function class="GtkLabel">get_selectable</function> </para> @@ -657,10 +867,14 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets whether the label is in single line mode. </shortdesc> <desc> <para> + Sets whether the label is in single line mode. If it is in single line + mode, the text will not be broken onto several lines. + </para> + <para> See also: <function class="GtkLabel">get_single_line_mode</function> </para> @@ -676,14 +890,24 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the text within the label. </shortdesc> <desc> <para> + Sets the text within the label. It overwrites any text that was there before. + Pango markup will not be used; you have to use + <function class="GtkLabel">set_markup</function> for this. + </para> + <para> + This will also clear any previously set mnemonic accelerators. + </para> + <para> See also: - <function class="GtkLabel">get_text</function> + <function class="GtkLabel">get_text</function>, + <function class="GtkLabel">set_text_with_mnemonic</function>, + <function class="GtkLabel">set_label</function>, + <function class="GtkLabel">set_markup</function> </para> - </desc> </method> @@ -695,10 +919,24 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the label's text and parses underscores to a mnemonic. </shortdesc> <desc> - + <para> + Sets the label's text from the string str. + If characters in str are preceded by an underscore, + they are underlined indicating that they represent a keyboard + accelerator called a mnemonic. + </para> + <para> + The mnemonic key can be used to activate another widget, + chosen automatically, or explicitly using + <function class="GtkLabel">set_mnemonic_widget</function>. + </para> + <para> + See also: + <function class="GtkLabel">set_text</function> + </para> </desc> </method> @@ -710,14 +948,19 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets whether the text of the label contains markup in Pango's + text markup language. </shortdesc> <desc> <para> - See also: - <function class="GtkLabel">get_use_markup</function> + Sets whether the text of the label contains markup in Pango's + text markup language. + </para> + <para> + See also: + <function class="GtkLabel">get_use_markup</function>, + <function class="GtkLabel">set_markup</function> </para> - </desc> </method> @@ -729,14 +972,18 @@ </funcprototype> </funcsynopsis> <shortdesc> - + If an underline shall be used for the mnemonic accelerator key. </shortdesc> <desc> <para> + If true, an underline in the text indicates the next character + should be used for the mnemonic accelerator key. + </para> + <para> See also: - <function class="GtkLabel">get_use_underline</function> + <function class="GtkLabel">get_use_underline</function>, + <function class="GtkLabel">set_text_with_mnemonic</function> </para> - </desc> </method> @@ -748,14 +995,17 @@ </funcprototype> </funcsynopsis> <shortdesc> - + Sets the desired width of the label, in characters. </shortdesc> <desc> <para> + Sets the desired width of the label, in characters. + </para> + <para> See also: - <function class="GtkLabel">get_width_chars</function> + <function class="GtkLabel">get_width_chars</function>, + <function class="GtkLabel">set_max_width_chars</function> </para> - </desc> </method> @@ -768,7 +1018,7 @@ <funcsynopsis> <funcprototype> <funcdef>void <cbfunction>callback</cbfunction></funcdef> - <paramdef>GtkLabel <parameter>label</parameter></paramdef> + <paramdef><classname>GtkLabel</classname> <parameter>label</parameter></paramdef> </funcprototype> </funcsynopsis> <shortdesc>
« previous php.gtk.doc (#1436) next »