Browse Source

Added $glade member
Fixed constructor to assign proper $top member instead of $win
Added utility callback for striped lists

Frederic G. Marand 16 năm trước cách đây
mục cha
commit
bcbdde718e
1 tập tin đã thay đổi với 25 bổ sung5 xóa
  1. 25 5
      Glade_Window.php

+ 25 - 5
Glade_Window.php

@@ -13,10 +13,15 @@ class Glade_Window
    * a top-level object if this is loaded
    * within another UI
    *
-   * @var unknown_type
+   * @var GtkWidget
    */
   public $top; 
   
+  /**
+   * @var GladeXML
+   */
+  protected $glade;
+  
   /**
    * Load the fixed structure for the actual class invoking the constructor
    * 
@@ -28,9 +33,9 @@ class Glade_Window
     $uiDescriptionFileName = get_class($this) . '.glade';
     try
       {
-      $glade = new GladeXML($uiDescriptionFileName);
-      $glade->signal_autoconnect_instance($this);
-      $this->win = $glade->get_widget('winPgma');
+      $this->glade = new GladeXML($uiDescriptionFileName);
+      $this->glade->signal_autoconnect_instance($this);
+      $this->top = $this->glade->get_widget($topName);
       }
     catch (Exception $e)
       {
@@ -46,5 +51,20 @@ class Glade_Window
     {
     Gtk::main_quit();
     }
-
+   
+  /**
+   * A utility callback for views inherited from this class: it
+   * enables automatic alternate row colors
+   *
+   * @param GtkCellLayout $cell_layout
+   * @param GtkCellRenderer $cell
+   * @param GtkTreeModel $tree_model
+   * @param GtkTreeIter $iter
+   * @return void
+   */
+  static public function zebraTreeViewCallback(GtkCellLayout $cell_layout, GtkCellRenderer $cell, GtkTreeModel $tree_model, GtkTreeIter $iter /* [, user_data] */)
+    {
+    $path = $tree_model->get_path($iter);
+    $cell->set_property('cell-background', ($path[0] % 2) ?'#d0d0d0' : '#ffffff');
+    }
   }