Browse Source

Use the new Server_Controller class to fill the main navigation list
Fixed the top-level widget name to match Glade_Window.php
Improved comments

Frederic G. Marand 16 years ago
parent
commit
8140b57b6c
3 changed files with 63 additions and 6 deletions
  1. 8 2
      Pgma_Model.php
  2. 54 3
      Pgma_View.php
  3. 1 1
      pgma.phpg

+ 8 - 2
Pgma_Model.php

@@ -2,12 +2,18 @@
 /**
  * Php-Gtk MySQL administrator - Main application data storage
  * 
- * This is just a plain text file
+ * This is just an active wrapper around a plain INI file named the
+ * same as the main program. INI information is made available as
+ * a two-level array in the $properties member.
+ * 
+ * 
+ * Configuration is loaded upon construction, and saved if changed 
+ * upon destruction. Changes are detected by a hash.
  *
  * @license CeCILL 2.0
  * @copyright 2008 Ouest  Systemes Informatiques
  * @author Frederic G. MARAND
- * @version $Id: Pgma_Model.php,v 1.1 2008-05-23 09:42:27 cvs Exp $
+ * @version $Id: Pgma_Model.php,v 1.2 2008-05-25 20:31:40 cvs Exp $
  */
 
 class Pgma_Model

+ 54 - 3
Pgma_View.php

@@ -5,7 +5,7 @@
  * @license CeCILL 2.0
  * @copyright 2008 Ouest  Systemes Informatiques
  * @author Frederic G. MARAND
- * @version $Id: Pgma_View.php,v 1.1 2008-05-23 09:42:27 cvs Exp $
+ * @version $Id: Pgma_View.php,v 1.2 2008-05-25 20:31:40 cvs Exp $
  */
 
 /**
@@ -20,19 +20,70 @@ class Pgma_View extends Glade_Window
    */
   protected $model;
   
+  /**
+   * @var Server_Controller 
+   */
+  protected $serverController;
+  
   /**
    * @var GtkFrame
    */
   public $activeDetailView;
 
   /**
-   * Load the view fixed structure, then reload session info
+   * Prepare the view and its initial data
    * 
    * @return void
    */
   public function __construct()
     {
+    /**
+     * 1. Load the view fixed structure
+     */
     parent::__construct('winPgma'); // not the standard top-level name
+    $this->top->set_size_request(640, 480);
+    
+    /**
+     * 2. Restore session info 
+     */
     $this->model = new Pgma_Model(); // load configuration info
+    /**
+     * @todo Apply layout info restored at this point to the top-level window
+     */
+
+    /**
+     * 3. connect
+     */
+    $this->serverController = new Server_Controller($this->model->properties['Auth']);
+    try
+      {
+      $this->serverController->login();
+      }
+    catch (PDOException $e)
+      {
+      die('Failed login to the DB server: ' . PHP_EOL 
+        . $e->getMessage() . PHP_EOL);
+      }
+      
+    /**
+     * Populate the DB view
+     */
+    $dbStore = new GtkListStore(GObject::TYPE_STRING);
+    $arDatabases = $this->serverController->getDatabases();
+    foreach ($arDatabases as $dbName)
+      {
+      $dbStore->append(array($dbName));
+      }
+
+    $dbView = $this->glade->get_widget('tvNavigation');
+    $dbView->set_model($dbStore);
+    
+    $dbNameRenderer = new GtkCellRendererText();
+    $dbNameRenderer->set_property('width', -1);
+    $dbNameRenderer->set_property('text', $dbName);
+    $dbCol = new GtkTreeViewColumn('Database', $dbNameRenderer, 'text', 0);
+    $dbCol->set_cell_data_func($dbNameRenderer, array($this, 'zebraTreeViewCallback'));
+    $dbView->append_column($dbCol);
     }
-  }
+  }
+  

+ 1 - 1
pgma.phpg

@@ -19,5 +19,5 @@ if (version_compare(phpversion(), '5.2.4', '<='))
  }
  
 $pgmaView = new Pgma_View();
-$pgmaView->win->show_all();
+$pgmaView->top->show_all();
 Gtk::main();