summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/bookmark_bar_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 18:23:58 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 18:23:58 +0000
commit9f040e43fec71f77dd9c201aa5397e314de4c07a (patch)
tree951f4bde2e7f6dc1d9c3a1dc1923890aa1c80b5d /chrome/browser/gtk/bookmark_bar_gtk.cc
parent0e161112cc06b7d77d8c9b73b334b209d79e12d1 (diff)
downloadchromium_src-9f040e43fec71f77dd9c201aa5397e314de4c07a.zip
chromium_src-9f040e43fec71f77dd9c201aa5397e314de4c07a.tar.gz
chromium_src-9f040e43fec71f77dd9c201aa5397e314de4c07a.tar.bz2
A little bit of bookmark bar cleanup, a little bit of padding improvement.
The spacing between the toolbar buttons now matches windows pixel for pixel (tested empirically). The bookmark bar item spacing is now a little better, but we need some hackery to improve it to the state of windows (we need to annex about 5 pixels from the toolbar when the bookmark bar is open). The code for packing bookmark bar buttons is now all in one place. Functional change: There will be no other bookmarks button until the model is loaded. If you care I can fix this, it just doesn't seem like a very important matter since it's unusable anyway when the model isn't loaded.o I also removed a log warning from chrome_dll_main because with this change it started spamming a lot. We're already living with this warning, and have a bug filed for it (they fixed the root problem in newer versions of gtk so I think this bug will just never get resolved), so I don't think this is a big deal. BUG=15870 TEST=things look marginally better, theming still works properly Review URL: http://codereview.chromium.org/155342 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/bookmark_bar_gtk.cc')
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc61
1 files changed, 17 insertions, 44 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 8ac21df..2d98d34 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -85,8 +85,6 @@ void BookmarkBarGtk::SetProfile(Profile* profile) {
if (model_)
model_->RemoveObserver(this);
- gtk_widget_set_sensitive(other_bookmarks_button_, false);
-
// TODO(erg): Handle extensions
model_ = profile_->GetBookmarkModel();
@@ -103,10 +101,6 @@ void BookmarkBarGtk::SetPageNavigator(PageNavigator* navigator) {
}
void BookmarkBarGtk::Init(Profile* profile) {
- // Load the default images from the resource bundle.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- static GdkPixbuf* folder_icon = rb.GetPixbufNamed(IDR_BOOKMARK_BAR_FOLDER);
-
bookmark_hbox_.Own(gtk_hbox_new(FALSE, 0));
instructions_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -155,21 +149,6 @@ void BookmarkBarGtk::Init(Profile* profile) {
// we can have finer control over its label.
other_bookmarks_button_ = gtk_chrome_button_new();
ConnectFolderButtonEvents(other_bookmarks_button_);
- gtk_chrome_button_set_use_gtk_rendering(
- GTK_CHROME_BUTTON(other_bookmarks_button_),
- GtkThemeProvider::UseSystemThemeGraphics(profile));
-
- GtkWidget* image = gtk_image_new_from_pixbuf(folder_icon);
- other_bookmarks_label_ = gtk_label_new(
- l10n_util::GetStringUTF8(IDS_BOOMARK_BAR_OTHER_BOOKMARKED).c_str());
- GtkThemeProperties properties(profile);
- bookmark_utils::SetButtonTextColors(other_bookmarks_label_, &properties);
-
- GtkWidget* box = gtk_hbox_new(FALSE, bookmark_utils::kBarButtonPadding);
- gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), other_bookmarks_label_, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(other_bookmarks_button_), box);
-
gtk_box_pack_start(GTK_BOX(bookmark_hbox_.get()), other_bookmarks_button_,
FALSE, FALSE, 0);
@@ -230,13 +209,9 @@ void BookmarkBarGtk::Loaded(BookmarkModel* model) {
// shutdown. Do nothing.
if (!instructions_)
return;
- RemoveAllBookmarkButtons();
-
- const BookmarkNode* node = model_->GetBookmarkBarNode();
- DCHECK(node && model_->other_node());
- CreateAllBookmarkButtons(node);
- gtk_widget_set_sensitive(other_bookmarks_button_, true);
+ RemoveAllBookmarkButtons();
+ CreateAllBookmarkButtons();
}
void BookmarkBarGtk::BookmarkModelBeingDeleted(BookmarkModel* model) {
@@ -271,7 +246,7 @@ void BookmarkBarGtk::BookmarkNodeAdded(BookmarkModel* model,
gtk_toolbar_insert(GTK_TOOLBAR(bookmark_toolbar_.get()),
item, index);
- SetInstructionState(parent);
+ SetInstructionState();
}
void BookmarkBarGtk::BookmarkNodeRemoved(BookmarkModel* model,
@@ -288,7 +263,7 @@ void BookmarkBarGtk::BookmarkNodeRemoved(BookmarkModel* model,
gtk_container_remove(GTK_CONTAINER(bookmark_toolbar_.get()),
to_remove);
- SetInstructionState(parent);
+ SetInstructionState();
}
void BookmarkBarGtk::BookmarkNodeChanged(BookmarkModel* model,
@@ -319,22 +294,28 @@ void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model,
// Purge and rebuild the bar.
RemoveAllBookmarkButtons();
- CreateAllBookmarkButtons(node);
+ CreateAllBookmarkButtons();
}
-void BookmarkBarGtk::CreateAllBookmarkButtons(const BookmarkNode* node) {
+void BookmarkBarGtk::CreateAllBookmarkButtons() {
+ const BookmarkNode* node = model_->GetBookmarkBarNode();
+ DCHECK(node && model_->other_node());
+
// Create a button for each of the children on the bookmark bar.
for (int i = 0; i < node->GetChildCount(); ++i) {
GtkToolItem* item = CreateBookmarkToolItem(node->GetChild(i));
gtk_toolbar_insert(GTK_TOOLBAR(bookmark_toolbar_.get()), item, -1);
}
- SetInstructionState(node);
+ GtkThemeProperties properties(profile_);
+ bookmark_utils::ConfigureButtonForNode(model_->other_node(),
+ model_, other_bookmarks_button_, &properties);
+
+ SetInstructionState();
}
-void BookmarkBarGtk::SetInstructionState(
- const BookmarkNode* boomarks_bar_node) {
- show_instructions_ = (boomarks_bar_node->GetChildCount() == 0);
+void BookmarkBarGtk::SetInstructionState() {
+ show_instructions_ = (model_->GetBookmarkBarNode()->GetChildCount() == 0);
if (show_instructions_) {
gtk_widget_show_all(instructions_);
} else {
@@ -359,19 +340,11 @@ bool BookmarkBarGtk::IsAlwaysShown() {
}
void BookmarkBarGtk::UserChangedTheme(GtkThemeProperties* properties) {
- gtk_chrome_button_set_use_gtk_rendering(
- GTK_CHROME_BUTTON(other_bookmarks_button_),
- properties->use_gtk_rendering);
- bookmark_utils::SetButtonTextColors(other_bookmarks_label_, properties);
-
if (model_) {
// Regenerate the bookmark bar with all new objects with their theme
// properties set correctly for the new theme.
RemoveAllBookmarkButtons();
-
- const BookmarkNode* node = model_->GetBookmarkBarNode();
- DCHECK(node && model_->other_node());
- CreateAllBookmarkButtons(node);
+ CreateAllBookmarkButtons();
} else {
DLOG(ERROR) << "Received a theme change notification while we don't have a "
<< "BookmarkModel. Taking no action.";