OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <gtk/gtk.h> |
| 10 |
| 11 #include "app/gtk_signal.h" |
| 12 #include "base/basictypes.h" |
| 13 #include "chrome/browser/gtk/owned_widget_gtk.h" |
| 14 #include "chrome/browser/gtk/view_id_util.h" |
| 15 #include "chrome/common/notification_observer.h" |
| 16 #include "chrome/common/notification_registrar.h" |
| 17 |
| 18 class RenderViewHost; |
| 19 class StatusBubbleGtk; |
| 20 class TabContents; |
| 21 |
| 22 typedef struct _GtkFloatingContainer GtkFloatingContainer; |
| 23 |
| 24 class TabContentsContainerGtk : public NotificationObserver, |
| 25 public ViewIDUtil::Delegate { |
| 26 public: |
| 27 explicit TabContentsContainerGtk(StatusBubbleGtk* status_bubble); |
| 28 ~TabContentsContainerGtk(); |
| 29 |
| 30 void Init(); |
| 31 |
| 32 // Make the specified tab visible. |
| 33 void SetTabContents(TabContents* tab_contents); |
| 34 TabContents* GetTabContents() const { return tab_contents_; } |
| 35 |
| 36 // Gets the tab contents currently being displayed (either |tab_contents_| or |
| 37 // |preview_contents_|). |
| 38 TabContents* GetVisibleTabContents(); |
| 39 |
| 40 void SetPreviewContents(TabContents* preview); |
| 41 void PopPreviewContents(); |
| 42 |
| 43 // Remove the tab from the hierarchy. |
| 44 void DetachTabContents(TabContents* tab_contents); |
| 45 |
| 46 // NotificationObserver implementation. |
| 47 virtual void Observe(NotificationType type, |
| 48 const NotificationSource& source, |
| 49 const NotificationDetails& details); |
| 50 |
| 51 GtkWidget* widget() { return floating_.get(); } |
| 52 |
| 53 // ViewIDUtil::Delegate implementation --------------------------------------- |
| 54 virtual GtkWidget* GetWidgetForViewID(ViewID id); |
| 55 |
| 56 private: |
| 57 // Called when a TabContents is destroyed. This gives us a chance to clean |
| 58 // up our internal state if the TabContents is somehow destroyed before we |
| 59 // get notified. |
| 60 void TabContentsDestroyed(TabContents* contents); |
| 61 |
| 62 // Handler for |floating_|'s "set-floating-position" signal. During this |
| 63 // callback, we manually set the position of the status bubble. |
| 64 static void OnSetFloatingPosition( |
| 65 GtkFloatingContainer* container, GtkAllocation* allocation, |
| 66 TabContentsContainerGtk* tab_contents_container); |
| 67 |
| 68 // Add |contents| to the container and start showing it. |
| 69 void PackTabContents(TabContents* contents); |
| 70 |
| 71 // Stop showing |contents|. |
| 72 void HideTabContents(TabContents* contents); |
| 73 |
| 74 // Removes |preview_contents_|. |
| 75 void RemovePreviewContents(); |
| 76 |
| 77 // Handle focus traversal on the tab contents container. Focus should not |
| 78 // traverse to the preview contents. |
| 79 CHROMEGTK_CALLBACK_1(TabContentsContainerGtk, gboolean, OnFocus, |
| 80 GtkDirectionType); |
| 81 |
| 82 NotificationRegistrar registrar_; |
| 83 |
| 84 // The TabContents for the currently selected tab. This will be showing unless |
| 85 // there is a preview contents. |
| 86 TabContents* tab_contents_; |
| 87 |
| 88 // The current preview contents (for instant). If non-NULL, it will be |
| 89 // visible. |
| 90 TabContents* preview_contents_; |
| 91 |
| 92 // The status bubble manager. Always non-NULL. |
| 93 StatusBubbleGtk* status_bubble_; |
| 94 |
| 95 // Top of the TabContentsContainerGtk widget hierarchy. A cross between a |
| 96 // GtkBin and a GtkFixed, |floating_| has |expanded_| as its one "real" child, |
| 97 // and the various things that hang off the bottom (status bubble, etc) have |
| 98 // their positions manually set in OnSetFloatingPosition. |
| 99 OwnedWidgetGtk floating_; |
| 100 |
| 101 // We insert and remove TabContents GtkWidgets into this expanded_. This |
| 102 // should not be a GtkVBox since there were errors with timing where the vbox |
| 103 // was horizontally split with the top half displaying the current TabContents |
| 104 // and bottom half displaying the loading page. |
| 105 GtkWidget* expanded_; |
| 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(TabContentsContainerGtk); |
| 108 }; |
| 109 |
| 110 #endif // CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CONTAINER_GTK_H_ |
OLD | NEW |