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

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