Started on db icon with type

This commit is contained in:
Timothy Warren 2012-02-22 19:52:39 -05:00
parent cf37a54553
commit c3ca31a916

View File

@ -217,8 +217,12 @@ class Main extends GtkWindow {
// Initialize the treeview with the data
$treeview = new GtkTreeView($model);
$cell_renderer = new GtkCellRendererPixbuf();
$treeview->insert_column_with_data_func(0, '', $cell_renderer, array(&$this, 'set_icon'));
$cell_renderer = new GtkCellRendererText();
$treeview->insert_column_with_data_func(-1, 'Database Connections', $cell_renderer, array(&$this, 'set_label'));
$treeview->insert_column_with_data_func(1, 'Database Connections', $cell_renderer, array(&$this, 'set_label'));
$selection = $treeview->get_selection();
$selection->set_mode(GTK::SELECTION_SINGLE);
@ -231,6 +235,26 @@ class Main extends GtkWindow {
return $conn_vbox;
}
/**
* Sets the icon for the current db type
*
* @param GtkTreeView Column $col
* @param GtkCellRenderer $cell
* @param GtkTreeModel $model
* @param GtkTreeIter $iter
*/
public function set_icon($col, $cell, $model, $iter)
{
$info = $model->get_value($iter, 0);
$db_type = strtolower($info->type);
$img_file = BASE_DIR."/images/{$type}-logo-32.png";
if(is_file($img_file))
{
$cell->set_property('pixbuf', GdkPixbuf::new_from_file($img_file));
}
}
/**
* Sets the label of the current db connection
*
@ -241,7 +265,7 @@ class Main extends GtkWindow {
*/
public function set_label($col, $cell, $model, $iter)
{
$info = $model->get_value($iter, 0);
$info = $model->get_value($iter, 1);
$cell->set_property('text', $info->name);
}