summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 22:19:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 22:19:41 +0000
commit3edd952ea05dfb5c950b63768fc9cc9ec807f6d8 (patch)
treea78e9bef8fe0efbff8b56fb6c6f8bc23e344c46e /chrome/browser/gtk
parentc0a2ee2bb8bfcc3ade688d43a95cc3404eea3748 (diff)
downloadchromium_src-3edd952ea05dfb5c950b63768fc9cc9ec807f6d8.zip
chromium_src-3edd952ea05dfb5c950b63768fc9cc9ec807f6d8.tar.gz
chromium_src-3edd952ea05dfb5c950b63768fc9cc9ec807f6d8.tar.bz2
Basic download shelf implementation on linux.
It shows and hides at appropriate times, and that's about it. TEST=navigate to a savable page and select "save page as" from the page menu. Click the x. Save the page again. The shelf should pop up, go away, pop up again. Review URL: http://codereview.chromium.org/38004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc91
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.h45
2 files changed, 136 insertions, 0 deletions
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
new file mode 100644
index 0000000..86a51b2
--- /dev/null
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -0,0 +1,91 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/download_shelf_gtk.h"
+
+#include "base/logging.h"
+#include "chrome/browser/download/download_item_model.h"
+#include "chrome/common/l10n_util.h"
+#include "chrome/common/resource_bundle.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
+// TODO(port): remove this after tab_contents.h is ported.
+#include "chrome/common/temp_scaffolding_stubs.h"
+
+namespace {
+
+// Total height of the shelf.
+const int kShelfHeight = 30;
+
+// Padding between the download widgets.
+const int kDownloadItemPadding = 10;
+
+// Padding between the top/bottom of the download widgets and the edge of the
+// shelf.
+const int kTopBottomPadding = 2;
+
+// Padding from right edge and close button/show downloads link.
+const int kRightPadding = 10;
+
+}
+
+// static
+DownloadShelf* DownloadShelf::Create(TabContents* tab_contents) {
+ return new DownloadShelfGtk(tab_contents);
+}
+
+DownloadShelfGtk::DownloadShelfGtk(TabContents* tab_contents)
+ : DownloadShelf(tab_contents),
+ is_showing_(false) {
+ shelf_ = gtk_hbox_new(FALSE, 0);
+ gtk_widget_set_size_request(shelf_, -1, kShelfHeight);
+
+ // Create and pack the close button.
+ close_button_.reset(new CustomDrawButton(IDR_CLOSE_BAR,
+ IDR_CLOSE_BAR_P, IDR_CLOSE_BAR_H, 0));
+ g_signal_connect(G_OBJECT(close_button_->widget()), "clicked",
+ G_CALLBACK(OnCloseButtonClick), this);
+ GTK_WIDGET_UNSET_FLAGS(close_button_->widget(), GTK_CAN_FOCUS);
+ GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), close_button_->widget(), TRUE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(shelf_), vbox, FALSE, FALSE, kRightPadding);
+
+ // Stick ourselves at the bottom of the parent tab contents.
+ GtkWidget* parent_contents = tab_contents->GetNativeView();
+ gtk_box_pack_end(GTK_BOX(parent_contents), shelf_, FALSE, FALSE, 0);
+ Show();
+}
+
+void DownloadShelfGtk::AddDownload(BaseDownloadItemModel* download_model_) {
+ NOTIMPLEMENTED();
+ Show();
+}
+
+bool DownloadShelfGtk::IsShowing() const {
+ return is_showing_;
+}
+
+void DownloadShelfGtk::Show() {
+ if (is_showing_)
+ return;
+
+ gtk_widget_show_all(shelf_);
+ is_showing_ = true;
+}
+
+void DownloadShelfGtk::Hide() {
+ if (!is_showing_)
+ return;
+
+ gtk_widget_hide_all(shelf_);
+ is_showing_ = false;
+}
+
+// static
+void DownloadShelfGtk::OnCloseButtonClick(GtkWidget* button,
+ DownloadShelfGtk* shelf) {
+ shelf->Hide();
+}
+
diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h
new file mode 100644
index 0000000..9cbf5bc
--- /dev/null
+++ b/chrome/browser/gtk/download_shelf_gtk.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_
+#define CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_
+
+#include <gtk/gtk.h>
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/gtk/custom_button.h"
+
+class BaseDownloadItemModel;
+
+class DownloadShelfGtk : public DownloadShelf {
+ public:
+ explicit DownloadShelfGtk(TabContents* tab_contents);
+
+ // DownloadShelf implementation.
+ virtual void AddDownload(BaseDownloadItemModel* download_model);
+ virtual bool IsShowing() const;
+
+ private:
+ // Show the shelf.
+ void Show();
+
+ // Hide the shelf.
+ void Hide();
+
+ static void OnCloseButtonClick(GtkWidget* button,
+ DownloadShelfGtk* toolbar);
+
+ // |bar_| is the highest level widget of the download shelf. It is an hbox.
+ GtkWidget* shelf_;
+
+ // The 'x' that the user can press to hide the download shelf.
+ scoped_ptr<CustomDrawButton> close_button_;
+
+ // Keeps track of our current hide/show state.
+ bool is_showing_;
+};
+
+#endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_
+