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/view_id_util.h" | 5 #include "chrome/browser/ui/gtk/view_id_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 case VIEW_ID_FIND_IN_PAGE: | 107 case VIEW_ID_FIND_IN_PAGE: |
108 return "chrome-find-in-page"; | 108 return "chrome-find-in-page"; |
109 | 109 |
110 case VIEW_ID_DEV_TOOLS_DOCKED: | 110 case VIEW_ID_DEV_TOOLS_DOCKED: |
111 return "chrome-dev-tools-docked"; | 111 return "chrome-dev-tools-docked"; |
112 | 112 |
113 // These are never hit because the tab container uses the delegate to | 113 // These are never hit because the tab container uses the delegate to |
114 // set its ID. | 114 // set its ID. |
115 case VIEW_ID_TAB_CONTAINER: | 115 case VIEW_ID_TAB_CONTAINER: |
116 case VIEW_ID_TAB_CONTAINER_FOCUS_VIEW: | |
117 default: | 116 default: |
118 NOTREACHED() << "If you added a new VIEW_ID, please provide " | 117 NOTREACHED() << "If you added a new VIEW_ID, please provide " |
119 "a name for the widget."; | 118 "a name for the widget."; |
120 return NULL; | 119 return NULL; |
121 } | 120 } |
122 } | 121 } |
123 | 122 |
124 } // namespace | 123 } // namespace |
125 | 124 |
126 void ViewIDUtil::SetID(GtkWidget* widget, ViewID id) { | 125 void ViewIDUtil::SetID(GtkWidget* widget, ViewID id) { |
127 const char* name = GetNameFromID(id); | 126 const char* name = GetNameFromID(id); |
128 if (name) | 127 if (name) |
129 gtk_widget_set_name(widget, name); | 128 gtk_widget_set_name(widget, name); |
130 g_object_set_data(G_OBJECT(widget), kViewIDString, | 129 g_object_set_data(G_OBJECT(widget), kViewIDString, |
131 reinterpret_cast<void*>(id)); | 130 reinterpret_cast<void*>(id)); |
132 } | 131 } |
133 | 132 |
134 GtkWidget* ViewIDUtil::GetWidget(GtkWidget* root, ViewID id) { | 133 GtkWidget* ViewIDUtil::GetWidget(GtkWidget* root, ViewID id) { |
135 ViewIDSearchStruct search_struct = { id, NULL }; | 134 ViewIDSearchStruct search_struct = { id, NULL }; |
136 SearchForWidgetWithViewID(root, &search_struct); | 135 SearchForWidgetWithViewID(root, &search_struct); |
137 return search_struct.widget; | 136 return search_struct.widget; |
138 } | 137 } |
139 | 138 |
140 void ViewIDUtil::SetDelegateForWidget(GtkWidget* widget, Delegate* delegate) { | 139 void ViewIDUtil::SetDelegateForWidget(GtkWidget* widget, Delegate* delegate) { |
141 g_object_set_data(G_OBJECT(widget), kViewIDOverrideString, delegate); | 140 g_object_set_data(G_OBJECT(widget), kViewIDOverrideString, delegate); |
142 } | 141 } |
OLD | NEW |