Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1701)

Unified Diff: chrome/browser/gtk/bookmark_utils_gtk.cc

Issue 165194: GTK: Use stock icons for bookmark folder and default favicon.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/bookmark_utils_gtk.h ('k') | chrome/browser/gtk/list_store_favicon_loader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/bookmark_utils_gtk.cc
===================================================================
--- chrome/browser/gtk/bookmark_utils_gtk.cc (revision 22744)
+++ chrome/browser/gtk/bookmark_utils_gtk.cc (working copy)
@@ -45,6 +45,10 @@
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 @@
// 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 @@
// 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);
« no previous file with comments | « chrome/browser/gtk/bookmark_utils_gtk.h ('k') | chrome/browser/gtk/list_store_favicon_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698