Gtk2_ExceptionDump
[ class tree: Gtk2_ExceptionDump ] [ index: Gtk2_ExceptionDump ] [ all elements ]

Source for file Stack.php

Documentation is available at Stack.php

  1. <?php
  2. require_once 'Gtk2/ExceptionDump/StackModel.php';
  3. require_once 'Gtk2/VarDump.php';
  4. require_once 'Gtk2/VarDump/ColTreeView.php';
  5.  
  6. /**
  7. * Stack trace list for an exception.
  8. * Tree with the trace lines in top level, and the parameters
  9. * in second level.
  10. * Double-click an entry, and Gtk2_VarDump will be started.
  11. * Drop an entry in your editor to open the file.
  12. *
  13. @category Gtk2
  14. @package  Gtk2_ExceptionDump
  15. @author   Christian Weiske <cweiske@php.net>
  16. @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  17. @version  CVS: $Id$
  18. @link     http://pear.php.net/package/Gtk2_ExceptionDump
  19. */
  20. class Gtk2_ExceptionDump_Stack extends Gtk2_VarDump_ColTreeView
  21. {
  22.     /**
  23.     * Creates the stack trace list.
  24.     *
  25.     * @param mixed $exception Exception or PEAR_Error
  26.     */
  27.     public function __construct($exception = null)
  28.     {
  29.         parent::__construct();
  30.  
  31.         $this->set_model(new Gtk2_ExceptionDump_StackModel());
  32.         $this->build();
  33.  
  34.         if ($exception !== null{
  35.             $this->setException($exception);
  36.         }
  37.     }
  38.  
  39.  
  40.  
  41.     /**
  42.     * Sets up the columns and DnD thingies.
  43.     */
  44.     protected function build()
  45.     {
  46.         $this->createColumns(array('#''Function''Location'));
  47.         $this->connect_after('event'array($this'clickedTree'));
  48.         $this->set_events(Gdk::_2BUTTON_PRESS);
  49.  
  50.         $this->drag_source_set(
  51.             Gdk::BUTTON1_MASK,
  52.             array(),
  53.             Gdk::ACTION_COPY | Gdk::ACTION_MOVE
  54.         );
  55.         $this->drag_source_add_uri_targets();
  56.         $this->connect('drag-begin'   array($this'onDragBegin'));
  57.         $this->connect('drag-data-get'array($this'onGetDragData'));
  58.     }
  59.  
  60.  
  61.  
  62.     /**
  63.     * Sets and displays the exception.
  64.     *
  65.     * @param mixed $exception  Exception or PEAR_Error
  66.     * @param int   $nOmitLines Number of stack lines to supress
  67.     */
  68.     public function setException($exception$nOmitLines = 0)
  69.     {
  70.         $this->get_model()->setException($exception$nOmitLines);
  71.     }//public function setException($exception, $nOmitLines = 0)
  72.  
  73.  
  74.  
  75.     /**
  76.     * The tree has been double-clicked. This causes Gtk2_VarDump
  77.     * to be opened with the selected stack trace entry.
  78.     *
  79.     * @param GtkTreeView $tree  The tree which has been clicked
  80.     * @param GdkEvent    $event The event data for the click event
  81.     */
  82.     public function clickedTree($tree$event)
  83.     {
  84.         if ($event->type !== Gdk::_2BUTTON_PRESS{
  85.             return;
  86.         }
  87.  
  88.         list($model$arSelected$tree->get_selection()->get_selected_rows();
  89.         if ($arSelected === null{
  90.             return;
  91.         }
  92.  
  93.         $path implode(':'$arSelected[0]);
  94.  
  95.         if ($event->button == 1{
  96.             //left mouse button
  97.             $iter $this->get_model()->get_iter($path);
  98.             $var  $this->get_model()->get_value($iter3);
  99.             Gtk2_VarDump::display($var$this->get_model()->get_value($iter1));
  100.         }
  101.     }//public function clickedTree($tree, $event)
  102.  
  103.  
  104.  
  105.     /**
  106.     * Returns the data at the end of a DnD operation
  107.     * that shall go into the target application.
  108.     * Sets the file to drop.
  109.     *
  110.     * @param GtkWidget    $widget    Widget the drag begin with
  111.     * @param mixed        $context   Drag context object
  112.     * @param GtkSelection $selection Selection object
  113.     * @param mixed        $info      Info object
  114.     * @param int          $time      Time the drag started
  115.     */
  116.     public function onGetDragData($widget$context$selection$info$time)
  117.     {
  118.         list($model$iter$widget->get_selection()->get_selected();
  119.         if (!$iter{
  120.             $context->drag_abort($time);
  121.             return;
  122.         }
  123.  
  124.         $step $model->get_value($iter3);
  125.         $file $step['file'"\r\n";
  126.  
  127.         $selection->set(
  128.             //GdkAtom type,
  129.             Gdk::atom_intern('text/uri-list'),
  130.             //gint format,    format (number of bits in a unit)
  131.             8,
  132.             //const guchar *data,pointer to the data (will be copied)
  133.             $file,
  134.             //gint length, length of the data
  135.             strlen($file)
  136.         );
  137.     }//function onGetDragData($widget, $context, $selection, $info, $time)
  138.  
  139.  
  140.  
  141.     /**
  142.     * When a drag begins, we want to set DnD icon to reflect
  143.     * the contents of the row being dragged.
  144.     *
  145.     * @param GtkWidget $widget  Widget the drag begin with
  146.     * @param mixed     $context Drag context object
  147.     */
  148.     public function onDragBegin($widget$context)
  149.     {
  150.         list($model$iter$this->get_selection()->get_selected();
  151.         if (!$iter{
  152.             $context->drag_abort($time);
  153.             return;
  154.         }
  155.         /*
  156.         $this->drag_source_set_icon(
  157.             GdkColormap::get_system(),
  158.             //FIXME: create pixmap with contents that really will be dropped
  159.             $this->create_row_drag_icon(
  160.                 $this->get_model()->get_path($iter)
  161.             )
  162.         );*/
  163.     }//public function onDragBegin($widget, $context)
  164.  
  165. }//class Gtk2_ExceptionDump_Stack extends Gtk2_VarDump_ColTreeView
  166. ?>

Documentation generated on Mon, 11 Mar 2019 15:55:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.