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

Side by Side Diff: base/gfx/gtk_util.cc

Issue 67179: Have ResourceBundle own GdkPixbufs. (Closed)
Patch Set: null Created 11 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/gfx/gtk_util.h" 5 #include "base/gfx/gtk_util.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/gfx/rect.h" 10 #include "base/gfx/rect.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // This pixbuf takes ownership of our malloc()ed data and will 71 // This pixbuf takes ownership of our malloc()ed data and will
72 // free it for us when it is destroyed. 72 // free it for us when it is destroyed.
73 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( 73 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(
74 data, 74 data,
75 GDK_COLORSPACE_RGB, // The only colorspace gtk supports. 75 GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
76 true, // There is an alpha channel. 76 true, // There is an alpha channel.
77 8, 77 8,
78 width, height, stride, &FreePixels, data); 78 width, height, stride, &FreePixels, data);
79 79
80 // Assume ownership of pixbuf.
81 g_object_ref_sink(pixbuf);
82 bitmap->unlockPixels(); 80 bitmap->unlockPixels();
83 return pixbuf; 81 return pixbuf;
84 } 82 }
85 83
86 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, 84 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
87 int top, int bottom, int left, int right) { 85 int top, int bottom, int left, int right) {
88 // Use a GtkEventBox to get the background painted. However, we can't just 86 // Use a GtkEventBox to get the background painted. However, we can't just
89 // use a container border, since it won't paint there. Use an alignment 87 // use a container border, since it won't paint there. Use an alignment
90 // inside to get the sizes exactly of how we want the border painted. 88 // inside to get the sizes exactly of how we want the border painted.
91 GtkWidget* ebox = gtk_event_box_new(); 89 GtkWidget* ebox = gtk_event_box_new();
92 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, color); 90 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, color);
93 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 91 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
94 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right); 92 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right);
95 gtk_container_add(GTK_CONTAINER(alignment), child); 93 gtk_container_add(GTK_CONTAINER(alignment), child);
96 gtk_container_add(GTK_CONTAINER(ebox), alignment); 94 gtk_container_add(GTK_CONTAINER(ebox), alignment);
97 return ebox; 95 return ebox;
98 } 96 }
99 97
100 void RemoveAllChildren(GtkWidget* container) { 98 void RemoveAllChildren(GtkWidget* container) {
101 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); 99 gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container);
102 } 100 }
103 101
104 } // namespace gfx 102 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc » ('j') | chrome/common/resource_bundle_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698