OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/table/native_table_gtk.h" | 5 #include "views/controls/table/native_table_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Focus the associated widget. | 58 // Focus the associated widget. |
59 OnFocus(); | 59 OnFocus(); |
60 } | 60 } |
61 | 61 |
62 gfx::NativeView NativeTableGtk::GetTestingHandle() const { | 62 gfx::NativeView NativeTableGtk::GetTestingHandle() const { |
63 // Note that we are returning the tree view, not the scrolled window as | 63 // Note that we are returning the tree view, not the scrolled window as |
64 // arguably the tests need to access the tree view. | 64 // arguably the tests need to access the tree view. |
65 return GTK_WIDGET(tree_view_); | 65 return GTK_WIDGET(tree_view_); |
66 } | 66 } |
67 | 67 |
68 void NativeTableGtk::InsertColumn(const TableColumn& column, int index) { | 68 void NativeTableGtk::InsertColumn(const ui::TableColumn& column, int index) { |
69 NOTIMPLEMENTED(); | 69 NOTIMPLEMENTED(); |
70 } | 70 } |
71 | 71 |
72 void NativeTableGtk::RemoveColumn(int column_index) { | 72 void NativeTableGtk::RemoveColumn(int column_index) { |
73 if (!native_view()) | 73 if (!native_view()) |
74 return; | 74 return; |
75 | 75 |
76 GtkTreeViewColumn* column = gtk_tree_view_get_column(tree_view_, | 76 GtkTreeViewColumn* column = gtk_tree_view_get_column(tree_view_, |
77 column_index); | 77 column_index); |
78 if (column) { | 78 if (column) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 gtk_tree_view_set_model(tree_view_, GTK_TREE_MODEL(gtk_model_)); | 285 gtk_tree_view_set_model(tree_view_, GTK_TREE_MODEL(gtk_model_)); |
286 g_object_unref(gtk_model_); // Now the tree owns the model. | 286 g_object_unref(gtk_model_); // Now the tree owns the model. |
287 | 287 |
288 // Updates the gtk model with the actual model. | 288 // Updates the gtk model with the actual model. |
289 if (table_->model()) | 289 if (table_->model()) |
290 OnRowsAdded(0, table_->model()->RowCount()); | 290 OnRowsAdded(0, table_->model()->RowCount()); |
291 | 291 |
292 gtk_widget_show_all(native_view()); | 292 gtk_widget_show_all(native_view()); |
293 } | 293 } |
294 | 294 |
295 void NativeTableGtk::InsertTextColumn(const TableColumn& column, int index) { | 295 void NativeTableGtk::InsertTextColumn(const ui::TableColumn& column, |
| 296 int index) { |
296 GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); | 297 GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); |
297 gtk_tree_view_insert_column_with_attributes(tree_view_, -1, | 298 gtk_tree_view_insert_column_with_attributes(tree_view_, -1, |
298 UTF16ToUTF8(column.title).c_str(), | 299 UTF16ToUTF8(column.title).c_str(), |
299 renderer, "text", index, NULL); | 300 renderer, "text", index, NULL); |
300 } | 301 } |
301 | 302 |
302 void NativeTableGtk::InsertIconAndTextColumn(const TableColumn& column, | 303 void NativeTableGtk::InsertIconAndTextColumn(const ui::TableColumn& column, |
303 int index) { | 304 int index) { |
304 // If necessary we could support more than 1 icon and text column and we could | 305 // If necessary we could support more than 1 icon and text column and we could |
305 // make it so it does not have to be the 1st column. | 306 // make it so it does not have to be the 1st column. |
306 DCHECK_EQ(0, index) << "The icon and text column can only be the first column" | 307 DCHECK_EQ(0, index) << "The icon and text column can only be the first column" |
307 " at this point."; | 308 " at this point."; |
308 | 309 |
309 GtkTreeViewColumn* gtk_column = gtk_tree_view_column_new(); | 310 GtkTreeViewColumn* gtk_column = gtk_tree_view_column_new(); |
310 gtk_tree_view_column_set_title(gtk_column, UTF16ToUTF8(column.title).c_str()); | 311 gtk_tree_view_column_set_title(gtk_column, UTF16ToUTF8(column.title).c_str()); |
311 GtkCellRenderer* renderer = gtk_cell_renderer_pixbuf_new(); | 312 GtkCellRenderer* renderer = gtk_cell_renderer_pixbuf_new(); |
312 gtk_tree_view_column_pack_start(gtk_column, renderer, FALSE); | 313 gtk_tree_view_column_pack_start(gtk_column, renderer, FALSE); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 SkBitmap icon = table_->model()->GetIcon(row); | 362 SkBitmap icon = table_->model()->GetIcon(row); |
362 return gfx::GdkPixbufFromSkBitmap(&icon); | 363 return gfx::GdkPixbufFromSkBitmap(&icon); |
363 } | 364 } |
364 | 365 |
365 // static | 366 // static |
366 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { | 367 NativeTableWrapper* NativeTableWrapper::CreateNativeWrapper(TableView2* table) { |
367 return new NativeTableGtk(table); | 368 return new NativeTableGtk(table); |
368 } | 369 } |
369 | 370 |
370 } // namespace views | 371 } // namespace views |
OLD | NEW |