| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/gtk_tree.h" | 5 #include "chrome/browser/ui/gtk/gtk_tree.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "ui/base/models/table_model.h" | 11 #include "ui/base/models/table_model.h" |
| 12 #include "ui/gfx/gtk_util.h" | 12 #include "ui/gfx/gtk_util.h" |
| 13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
| 14 #include "ui/gfx/image/image_skia.h" |
| 14 | 15 |
| 15 namespace gtk_tree { | 16 namespace gtk_tree { |
| 16 | 17 |
| 17 gint GetRowNumForPath(GtkTreePath* path) { | 18 gint GetRowNumForPath(GtkTreePath* path) { |
| 18 gint* indices = gtk_tree_path_get_indices(path); | 19 gint* indices = gtk_tree_path_get_indices(path); |
| 19 if (!indices) { | 20 if (!indices) { |
| 20 NOTREACHED(); | 21 NOTREACHED(); |
| 21 return -1; | 22 return -1; |
| 22 } | 23 } |
| 23 return indices[0]; | 24 return indices[0]; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 345 |
| 345 TreeAdapter::TreeAdapter(Delegate* delegate, ui::TreeModel* tree_model) | 346 TreeAdapter::TreeAdapter(Delegate* delegate, ui::TreeModel* tree_model) |
| 346 : delegate_(delegate), | 347 : delegate_(delegate), |
| 347 tree_model_(tree_model) { | 348 tree_model_(tree_model) { |
| 348 tree_store_ = gtk_tree_store_new(COL_COUNT, | 349 tree_store_ = gtk_tree_store_new(COL_COUNT, |
| 349 GDK_TYPE_PIXBUF, | 350 GDK_TYPE_PIXBUF, |
| 350 G_TYPE_STRING, | 351 G_TYPE_STRING, |
| 351 G_TYPE_POINTER); | 352 G_TYPE_POINTER); |
| 352 tree_model->AddObserver(this); | 353 tree_model->AddObserver(this); |
| 353 | 354 |
| 354 std::vector<SkBitmap> icons; | 355 std::vector<gfx::ImageSkia> icons; |
| 355 tree_model->GetIcons(&icons); | 356 tree_model->GetIcons(&icons); |
| 356 for (size_t i = 0; i < icons.size(); ++i) { | 357 for (size_t i = 0; i < icons.size(); ++i) { |
| 357 pixbufs_.push_back(gfx::GdkPixbufFromSkBitmap(icons[i])); | 358 pixbufs_.push_back(gfx::GdkPixbufFromSkBitmap(*icons[i].bitmap())); |
| 358 } | 359 } |
| 359 } | 360 } |
| 360 | 361 |
| 361 TreeAdapter::~TreeAdapter() { | 362 TreeAdapter::~TreeAdapter() { |
| 362 g_object_unref(tree_store_); | 363 g_object_unref(tree_store_); |
| 363 for (size_t i = 0; i < pixbufs_.size(); ++i) | 364 for (size_t i = 0; i < pixbufs_.size(); ++i) |
| 364 g_object_unref(pixbufs_[i]); | 365 g_object_unref(pixbufs_[i]); |
| 365 } | 366 } |
| 366 | 367 |
| 367 void TreeAdapter::Init() { | 368 void TreeAdapter::Init() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 void TreeAdapter::TreeNodeChanged(ui::TreeModel* model, | 468 void TreeAdapter::TreeNodeChanged(ui::TreeModel* model, |
| 468 ui::TreeModelNode* node) { | 469 ui::TreeModelNode* node) { |
| 469 delegate_->OnAnyModelUpdateStart(); | 470 delegate_->OnAnyModelUpdateStart(); |
| 470 GtkTreeIter iter; | 471 GtkTreeIter iter; |
| 471 if (GetTreeIter(node, &iter)) | 472 if (GetTreeIter(node, &iter)) |
| 472 FillRow(&iter, node); | 473 FillRow(&iter, node); |
| 473 delegate_->OnAnyModelUpdate(); | 474 delegate_->OnAnyModelUpdate(); |
| 474 } | 475 } |
| 475 | 476 |
| 476 } // namespace gtk_tree | 477 } // namespace gtk_tree |
| OLD | NEW |