diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 02:18:31 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 02:18:31 +0000 |
commit | 94d88ad381bbb235cde17c9a7c5849331945d9c9 (patch) | |
tree | 34f7025f687dc63618bf32659fe0c19b45c33f0f /chrome/browser | |
parent | f73eb0b562eb18036042c27a71fdff9fe6a33a13 (diff) | |
download | chromium_src-94d88ad381bbb235cde17c9a7c5849331945d9c9.zip chromium_src-94d88ad381bbb235cde17c9a7c5849331945d9c9.tar.gz chromium_src-94d88ad381bbb235cde17c9a7c5849331945d9c9.tar.bz2 |
GTK: Use stock icons for bookmark folder and default favicon.
In the main window, in the default theme, we still use the chrome icons.
There are still several more places that need updating: the tab strip, the task manager, etc. I will deal with that later.
BUG=13320
Review URL: http://codereview.chromium.org/165194
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/bookmark_editor_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_tree_model.cc | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_utils_gtk.cc | 54 | ||||
-rw-r--r-- | chrome/browser/gtk/bookmark_utils_gtk.h | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/list_store_favicon_loader.cc | 12 | ||||
-rw-r--r-- | chrome/browser/gtk/list_store_favicon_loader.h | 5 |
7 files changed, 69 insertions, 31 deletions
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc index a6d46c3..3aee43b 100644 --- a/chrome/browser/gtk/bookmark_editor_gtk.cc +++ b/chrome/browser/gtk/bookmark_editor_gtk.cc @@ -313,7 +313,7 @@ void BookmarkEditorGtk::AddNewGroup(GtkTreeIter* parent, GtkTreeIter* child) { gtk_tree_store_set( tree_store_, child, bookmark_utils::FOLDER_ICON, - bookmark_utils::GetFolderIcon(), + bookmark_utils::GetFolderIcon(true), bookmark_utils::FOLDER_NAME, l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME).c_str(), bookmark_utils::ITEM_ID, static_cast<int64>(0), diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index 19fee77..a7a516d 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -611,6 +611,7 @@ void BookmarkManagerGtk::BuildLeftStore() { model_->GetBookmarkBarNode()->id(), left_store_, &select_iter); gtk_tree_selection_select_iter(left_selection(), &select_iter); + // TODO(estade): is there a decent stock icon we can use here? ResourceBundle& rb = ResourceBundle::GetSharedInstance(); gtk_tree_store_append(left_store_, &select_iter, NULL); gtk_tree_store_set(left_store_, &select_iter, @@ -622,15 +623,18 @@ void BookmarkManagerGtk::BuildLeftStore() { bookmark_utils::ITEM_ID, kRecentID, -1); + GdkPixbuf* search_icon = gtk_widget_render_icon( + window_, GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, NULL); gtk_tree_store_append(left_store_, &select_iter, NULL); gtk_tree_store_set(left_store_, &select_iter, bookmark_utils::FOLDER_ICON, - rb.GetPixbufNamed(IDR_BOOKMARK_MANAGER_SEARCH_ICON), + search_icon, bookmark_utils::FOLDER_NAME, l10n_util::GetStringUTF8( IDS_BOOKMARK_TREE_SEARCH_NODE_TITLE).c_str(), bookmark_utils::ITEM_ID, kSearchID, -1); + g_object_unref(search_icon); } void BookmarkManagerGtk::BuildRightStore() { @@ -735,7 +739,7 @@ void BookmarkManagerGtk::SetRightSideColumnValues(int row, GtkTreeIter* iter) { // TODO(estade): building the path could be optimized out when we aren't // showing the path column. const BookmarkNode* node = right_tree_model_->GetNodeForRow(row); - GdkPixbuf* pixbuf = bookmark_utils::GetPixbufForNode(node, model_); + GdkPixbuf* pixbuf = bookmark_utils::GetPixbufForNode(node, model_, true); std::wstring title = right_tree_model_->GetText(row, IDS_BOOKMARK_TABLE_TITLE); std::wstring url = right_tree_model_->GetText(row, IDS_BOOKMARK_TABLE_URL); diff --git a/chrome/browser/gtk/bookmark_tree_model.cc b/chrome/browser/gtk/bookmark_tree_model.cc index f78baf1..7682e9b 100644 --- a/chrome/browser/gtk/bookmark_tree_model.cc +++ b/chrome/browser/gtk/bookmark_tree_model.cc @@ -16,10 +16,14 @@ namespace { void AddSingleNodeToTreeStore(GtkTreeStore* store, const BookmarkNode* node, GtkTreeIter *iter, GtkTreeIter* parent) { gtk_tree_store_append(store, iter, parent); - // TODO(estade): we should show the folder open icon when it's expanded. + // It would be easy to show a different icon when the folder is open (as they + // do on Windows, for example), using pixbuf-expander-closed and + // pixbuf-expander-open. Unfortunately there is no GTK_STOCK_OPEN_DIRECTORY + // (and indeed, Nautilus does not render an expanded directory any + // differently). gtk_tree_store_set(store, iter, bookmark_utils::FOLDER_ICON, - bookmark_utils::GetFolderIcon(), + bookmark_utils::GetFolderIcon(true), bookmark_utils::FOLDER_NAME, WideToUTF8(node->GetTitle()).c_str(), bookmark_utils::ITEM_ID, node->id(), diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc index 937cb3a..3d73794 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/gtk/bookmark_utils_gtk.cc @@ -45,6 +45,10 @@ void* AsVoid(const BookmarkNode* node) { return const_cast<BookmarkNode*>(node); } +// This is a dummy widget that only exists so we have something to pass to +// gtk_widget_render_icon(). +GtkWidget* icon_widget = NULL; + } // namespace namespace bookmark_utils { @@ -54,32 +58,53 @@ const char kBookmarkNode[] = "bookmark-node"; // Spacing between the buttons on the bar. const int kBarButtonPadding = 4; -GdkPixbuf* GetFolderIcon() { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - static GdkPixbuf* default_folder_icon = rb.GetPixbufNamed( - IDR_BOOKMARK_BAR_FOLDER); - return default_folder_icon; +GdkPixbuf* GetFolderIcon(bool native) { + if (!native) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + static GdkPixbuf* default_folder_icon = rb.GetPixbufNamed( + IDR_BOOKMARK_BAR_FOLDER); + return default_folder_icon; + } else { + if (!icon_widget) + icon_widget = gtk_fixed_new(); + // We never release our ref, so we will leak this on program shutdown. + static GdkPixbuf* default_folder_icon = + gtk_widget_render_icon(icon_widget, GTK_STOCK_DIRECTORY, + GTK_ICON_SIZE_MENU, NULL); + return default_folder_icon; + } } -GdkPixbuf* GetDefaultFavicon() { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - static GdkPixbuf* default_bookmark_icon = rb.GetPixbufNamed( - IDR_DEFAULT_FAVICON); - return default_bookmark_icon; +GdkPixbuf* GetDefaultFavicon(bool native) { + if (!native) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + static GdkPixbuf* default_bookmark_icon = rb.GetPixbufNamed( + IDR_DEFAULT_FAVICON); + return default_bookmark_icon; + } else { + if (!icon_widget) + icon_widget = gtk_fixed_new(); + // We never release our ref, so we will leak this on program shutdown. + static GdkPixbuf* default_bookmark_icon = + gtk_widget_render_icon(icon_widget, GTK_STOCK_FILE, + GTK_ICON_SIZE_MENU, NULL); + return default_bookmark_icon; + } } -GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model) { +GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, + bool native) { GdkPixbuf* pixbuf; if (node->is_url()) { if (model->GetFavIcon(node).width() != 0) { pixbuf = gfx::GdkPixbufFromSkBitmap(&model->GetFavIcon(node)); } else { - pixbuf = GetDefaultFavicon(); + pixbuf = GetDefaultFavicon(native); g_object_ref(pixbuf); } } else { - pixbuf = GetFolderIcon(); + pixbuf = GetFolderIcon(native); g_object_ref(pixbuf); } @@ -124,7 +149,8 @@ void ConfigureButtonForNode(const BookmarkNode* node, BookmarkModel* model, // We pack the button manually (rather than using gtk_button_set_*) so that // we can have finer control over its label. - GdkPixbuf* pixbuf = bookmark_utils::GetPixbufForNode(node, model); + GdkPixbuf* pixbuf = bookmark_utils::GetPixbufForNode(node, model, + provider->UseGtkTheme()); GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); diff --git a/chrome/browser/gtk/bookmark_utils_gtk.h b/chrome/browser/gtk/bookmark_utils_gtk.h index 865a79e..3bab09d 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.h +++ b/chrome/browser/gtk/bookmark_utils_gtk.h @@ -23,12 +23,14 @@ extern const int kBarButtonPadding; // These functions do not add a ref to the returned pixbuf, and it should not be // unreffed. -GdkPixbuf* GetFolderIcon(); -GdkPixbuf* GetDefaultFavicon(); +// If |native| is true, get the GTK_STOCK version of the icon. +GdkPixbuf* GetFolderIcon(bool native); +GdkPixbuf* GetDefaultFavicon(bool native); // Get the image that is used to represent the node. This function adds a ref // to the returned pixbuf, so it requires a matching call to g_object_unref(). -GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model); +GdkPixbuf* GetPixbufForNode(const BookmarkNode* node, BookmarkModel* model, + bool native); // Returns a GtkWindow with a visual hierarchy for passing to // gtk_drag_set_icon_widget(). @@ -47,8 +49,7 @@ std::string BuildTooltipFor(const BookmarkNode* node); // Returns the "bookmark-node" property of |widget| casted to the correct type. const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget); -// This function is a temporary hack to fix fonts on dark system themes. -// TODO(estade): remove this function. +// Set the colors on |label| as per the theme. void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider); // Drag and drop. -------------------------------------------------------------- diff --git a/chrome/browser/gtk/list_store_favicon_loader.cc b/chrome/browser/gtk/list_store_favicon_loader.cc index 5a34dd0..feb0e8e 100644 --- a/chrome/browser/gtk/list_store_favicon_loader.cc +++ b/chrome/browser/gtk/list_store_favicon_loader.cc @@ -4,11 +4,10 @@ #include "chrome/browser/gtk/list_store_favicon_loader.h" -#include "app/resource_bundle.h" #include "base/gfx/gtk_util.h" #include "base/gfx/png_decoder.h" +#include "chrome/browser/gtk/bookmark_utils_gtk.h" #include "chrome/browser/profile.h" -#include "grit/app_resources.h" #include "third_party/skia/include/core/SkBitmap.h" ListStoreFavIconLoader::ListStoreFavIconLoader( @@ -16,9 +15,12 @@ ListStoreFavIconLoader::ListStoreFavIconLoader( Profile* profile, CancelableRequestConsumer* consumer) : list_store_(list_store), favicon_col_(favicon_col), favicon_handle_col_(favicon_handle_col), profile_(profile), - consumer_(consumer) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - default_favicon_ = rb.GetPixbufNamed(IDR_DEFAULT_FAVICON); + consumer_(consumer), + default_favicon_(bookmark_utils::GetDefaultFavicon(true)) { +} + +ListStoreFavIconLoader::~ListStoreFavIconLoader() { + g_object_unref(default_favicon_); } void ListStoreFavIconLoader::LoadFaviconForRow(const GURL& url, diff --git a/chrome/browser/gtk/list_store_favicon_loader.h b/chrome/browser/gtk/list_store_favicon_loader.h index 935c0f7..86bb7e0 100644 --- a/chrome/browser/gtk/list_store_favicon_loader.h +++ b/chrome/browser/gtk/list_store_favicon_loader.h @@ -25,6 +25,8 @@ class ListStoreFavIconLoader { Profile* profile, CancelableRequestConsumer* consumer); + ~ListStoreFavIconLoader(); + // Start loading the favicon for |url| into the row |iter|. void LoadFaviconForRow(const GURL& url, GtkTreeIter* iter); @@ -55,8 +57,7 @@ class ListStoreFavIconLoader { // Used in loading favicons. CancelableRequestConsumer* consumer_; - // Default icon to show when one can't be found for the URL. This is owned by - // the ResourceBundle and we do not need to free it. + // Default icon to show when one can't be found for the URL. GdkPixbuf* default_favicon_; DISALLOW_COPY_AND_ASSIGN(ListStoreFavIconLoader); |