OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/task_manager_gtk.h" | 5 #include "chrome/browser/gtk/task_manager_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 GTK_TREE_VIEW(treeview_)); | 479 GTK_TREE_VIEW(treeview_)); |
480 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); | 480 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); |
481 g_signal_connect(selection, "changed", | 481 g_signal_connect(selection, "changed", |
482 G_CALLBACK(OnSelectionChangedThunk), this); | 482 G_CALLBACK(OnSelectionChangedThunk), this); |
483 | 483 |
484 gtk_container_add(GTK_CONTAINER(scrolled), treeview_); | 484 gtk_container_add(GTK_CONTAINER(scrolled), treeview_); |
485 | 485 |
486 SetInitialDialogSize(); | 486 SetInitialDialogSize(); |
487 gtk_util::ShowDialog(dialog_); | 487 gtk_util::ShowDialog(dialog_); |
488 | 488 |
| 489 // If the model already has resources, we need to add them before we start |
| 490 // observing events. |
| 491 if (model_->ResourceCount() > 0) |
| 492 OnItemsAdded(0, model_->ResourceCount()); |
| 493 |
489 model_->AddObserver(this); | 494 model_->AddObserver(this); |
490 } | 495 } |
491 | 496 |
492 void TaskManagerGtk::SetInitialDialogSize() { | 497 void TaskManagerGtk::SetInitialDialogSize() { |
493 // Hook up to the realize event so we can size the page column to the | 498 // Hook up to the realize event so we can size the page column to the |
494 // size of the leftover space after packing the other columns. | 499 // size of the leftover space after packing the other columns. |
495 g_signal_connect(treeview_, "realize", | 500 g_signal_connect(treeview_, "realize", |
496 G_CALLBACK(OnTreeViewRealizeThunk), this); | 501 G_CALLBACK(OnTreeViewRealizeThunk), this); |
497 // If we previously saved the dialog's bounds, use them. | 502 // If we previously saved the dialog's bounds, use them. |
498 if (g_browser_process->local_state()) { | 503 if (g_browser_process->local_state()) { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 guint keyval, | 962 guint keyval, |
958 GdkModifierType modifier) { | 963 GdkModifierType modifier) { |
959 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { | 964 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { |
960 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget | 965 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget |
961 // is destroyed. The deleted object will receive gtk signals otherwise. | 966 // is destroyed. The deleted object will receive gtk signals otherwise. |
962 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); | 967 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); |
963 } | 968 } |
964 | 969 |
965 return TRUE; | 970 return TRUE; |
966 } | 971 } |
OLD | NEW |