| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension_shelf_gtk.h" | 5 #include "chrome/browser/gtk/extension_shelf_gtk.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/gtk/browser_window_gtk.h" | 8 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 9 #include "chrome/browser/gtk/gtk_theme_provider.h" | 9 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 10 #include "chrome/browser/gtk/nine_box.h" | 10 #include "chrome/browser/gtk/nine_box.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class ExtensionShelfGtk::Toolstrip { | 22 class ExtensionShelfGtk::Toolstrip { |
| 23 public: | 23 public: |
| 24 explicit Toolstrip(ExtensionHost* host) | 24 explicit Toolstrip(ExtensionHost* host) |
| 25 : host_(host), | 25 : host_(host), |
| 26 extension_name_(host_->extension()->name()) { | 26 extension_name_(host_->extension()->name()) { |
| 27 DCHECK(host_->view()); | 27 DCHECK(host_->view()); |
| 28 Init(); | 28 Init(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ~Toolstrip() { | |
| 32 label_.Destroy(); | |
| 33 } | |
| 34 | |
| 35 void AddToolstripToBox(GtkWidget* box); | 31 void AddToolstripToBox(GtkWidget* box); |
| 36 void RemoveToolstripFromBox(GtkWidget* box); | 32 void RemoveToolstripFromBox(GtkWidget* box); |
| 37 | 33 |
| 38 private: | 34 private: |
| 39 void Init(); | 35 void Init(); |
| 40 | 36 |
| 37 gfx::NativeView native_view() { |
| 38 return host_->view()->native_view(); |
| 39 } |
| 40 |
| 41 ExtensionHost* host_; | 41 ExtensionHost* host_; |
| 42 | 42 |
| 43 const std::string extension_name_; | 43 const std::string extension_name_; |
| 44 | 44 |
| 45 // Placeholder label with extension's name. | |
| 46 // TODO(phajdan.jr): replace the label with rendered extension contents. | |
| 47 OwnedWidgetGtk label_; | |
| 48 | |
| 49 private: | 45 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(Toolstrip); | 46 DISALLOW_COPY_AND_ASSIGN(Toolstrip); |
| 51 }; | 47 }; |
| 52 | 48 |
| 53 void ExtensionShelfGtk::Toolstrip::AddToolstripToBox(GtkWidget* box) { | 49 void ExtensionShelfGtk::Toolstrip::AddToolstripToBox(GtkWidget* box) { |
| 54 gtk_box_pack_start(GTK_BOX(box), label_.get(), FALSE, FALSE, | 50 gtk_box_pack_start(GTK_BOX(box), native_view(), TRUE, TRUE, |
| 55 kToolstripPadding); | 51 kToolstripPadding); |
| 56 } | 52 } |
| 57 | 53 |
| 58 void ExtensionShelfGtk::Toolstrip::RemoveToolstripFromBox(GtkWidget* box) { | 54 void ExtensionShelfGtk::Toolstrip::RemoveToolstripFromBox(GtkWidget* box) { |
| 59 gtk_container_remove(GTK_CONTAINER(box), label_.get()); | 55 gtk_container_remove(GTK_CONTAINER(box), native_view()); |
| 60 } | 56 } |
| 61 | 57 |
| 62 void ExtensionShelfGtk::Toolstrip::Init() { | 58 void ExtensionShelfGtk::Toolstrip::Init() { |
| 63 label_.Own(gtk_label_new(extension_name_.c_str())); | 59 host_->view()->set_is_toolstrip(true); |
| 64 gtk_widget_show_all(label_.get()); | 60 gtk_widget_show_all(native_view()); |
| 65 } | 61 } |
| 66 | 62 |
| 67 ExtensionShelfGtk::ExtensionShelfGtk(Profile* profile, Browser* browser) | 63 ExtensionShelfGtk::ExtensionShelfGtk(Profile* profile, Browser* browser) |
| 68 : browser_(browser), | 64 : browser_(browser), |
| 69 theme_provider_(GtkThemeProvider::GetFrom(profile)), | 65 theme_provider_(GtkThemeProvider::GetFrom(profile)), |
| 70 model_(browser->extension_shelf_model()) { | 66 model_(browser->extension_shelf_model()) { |
| 71 Init(profile); | 67 Init(profile); |
| 72 | 68 |
| 73 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 69 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
| 74 NotificationService::AllSources()); | 70 NotificationService::AllSources()); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 event->area.width, event->area.height); | 214 event->area.width, event->area.height); |
| 219 cairo_clip(cr); | 215 cairo_clip(cr); |
| 220 bar->InitBackground(); | 216 bar->InitBackground(); |
| 221 bar->background_ninebox_->RenderTopCenterStrip( | 217 bar->background_ninebox_->RenderTopCenterStrip( |
| 222 cr, event->area.x, event->area.y, | 218 cr, event->area.x, event->area.y, |
| 223 event->area.x + event->area.width); | 219 event->area.x + event->area.width); |
| 224 cairo_destroy(cr); | 220 cairo_destroy(cr); |
| 225 | 221 |
| 226 return FALSE; // Propagate expose to children. | 222 return FALSE; // Propagate expose to children. |
| 227 } | 223 } |
| OLD | NEW |