summaryrefslogtreecommitdiffstats
path: root/chrome/common/gtk_util.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 01:33:24 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 01:33:24 +0000
commit63302a8b9faec92f1b956737057205acc2b44907 (patch)
tree4ced0044147ef7e0d2e525c37b7922dfca195e9f /chrome/common/gtk_util.cc
parent21a00fd62cb2760b12912697e9af1fb95aaf613c (diff)
downloadchromium_src-63302a8b9faec92f1b956737057205acc2b44907.zip
chromium_src-63302a8b9faec92f1b956737057205acc2b44907.tar.gz
chromium_src-63302a8b9faec92f1b956737057205acc2b44907.tar.bz2
Linux: convert namespace gtk_util to class GtkUtil to meet style guidelines.
BUG=none TEST=none Review URL: http://codereview.chromium.org/160371 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gtk_util.cc')
-rw-r--r--chrome/common/gtk_util.cc53
1 files changed, 27 insertions, 26 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 19eb595b..29d63f2 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -138,10 +138,8 @@ guint32 GetGdkEventTime(GdkEvent* event) {
} // namespace event_utils
-namespace gtk_util {
-
-GtkWidget* CreateLabeledControlsGroup(std::vector<GtkWidget*>* labels,
- const char* text, ...) {
+GtkWidget* GtkUtil::CreateLabeledControlsGroup(std::vector<GtkWidget*>* labels,
+ const char* text, ...) {
va_list ap;
va_start(ap, text);
GtkWidget* table = gtk_table_new(0, 2, FALSE);
@@ -169,8 +167,9 @@ GtkWidget* CreateLabeledControlsGroup(std::vector<GtkWidget*>* labels,
return table;
}
-GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
- int top, int bottom, int left, int right) {
+GtkWidget* GtkUtil::CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
+ int top, int bottom,
+ int left, int right) {
// Use a GtkEventBox to get the background painted. However, we can't just
// use a container border, since it won't paint there. Use an alignment
// inside to get the sizes exactly of how we want the border painted.
@@ -184,8 +183,9 @@ GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color,
return ebox;
}
-bool GetWidgetSizeFromResources(GtkWidget* widget, int width_chars,
- int height_lines, int* width, int* height) {
+bool GtkUtil::GetWidgetSizeFromResources(GtkWidget* widget,
+ int width_chars, int height_lines,
+ int* width, int* height) {
PangoContext* context = gtk_widget_create_pango_context(widget);
PangoFontMetrics* metrics = pango_context_get_metrics(context,
widget->style->font_desc, pango_context_get_language(context));
@@ -205,11 +205,11 @@ bool GetWidgetSizeFromResources(GtkWidget* widget, int width_chars,
return true;
}
-void RemoveAllChildren(GtkWidget* container) {
+void GtkUtil::RemoveAllChildren(GtkWidget* container) {
gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container);
}
-void ForceFontSizePixels(GtkWidget* widget, double size_pixels) {
+void GtkUtil::ForceFontSizePixels(GtkWidget* widget, double size_pixels) {
GtkStyle* style = widget->style;
PangoFontDescription* font_desc = style->font_desc;
// pango_font_description_set_absolute_size sets the font size in device
@@ -219,7 +219,7 @@ void ForceFontSizePixels(GtkWidget* widget, double size_pixels) {
gtk_widget_modify_font(widget, font_desc);
}
-gfx::Point GetWidgetScreenPosition(GtkWidget* widget) {
+gfx::Point GtkUtil::GetWidgetScreenPosition(GtkWidget* widget) {
int x = 0, y = 0;
if (GTK_IS_WINDOW(widget)) {
@@ -252,13 +252,13 @@ gfx::Point GetWidgetScreenPosition(GtkWidget* widget) {
return gfx::Point(x, y);
}
-gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) {
+gfx::Rect GtkUtil::GetWidgetScreenBounds(GtkWidget* widget) {
gfx::Point position = GetWidgetScreenPosition(widget);
return gfx::Rect(position.x(), position.y(),
widget->allocation.width, widget->allocation.height);
}
-void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) {
+void GtkUtil::ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) {
DCHECK(widget);
DCHECK(p);
@@ -266,7 +266,7 @@ void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) {
p->SetPoint(p->x() + position.x(), p->y() + position.y());
}
-void InitRCStyles() {
+void GtkUtil::InitRCStyles() {
static const char kRCText[] =
// Make our dialogs styled like the GNOME HIG.
//
@@ -295,8 +295,8 @@ void InitRCStyles() {
gtk_rc_parse_string(kRCText);
}
-void CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget, bool pack_at_end,
- int padding) {
+void GtkUtil::CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget,
+ bool pack_at_end, int padding) {
GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0);
if (pack_at_end)
@@ -305,7 +305,8 @@ void CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget, bool pack_at_end,
gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding);
}
-std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
+std::string GtkUtil::ConvertAcceleratorsFromWindowsStyle(
+ const std::string& label) {
std::string ret;
ret.reserve(label.length());
for (size_t i = 0; i < label.length(); ++i) {
@@ -324,12 +325,13 @@ std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
return ret;
}
-bool IsScreenComposited() {
+bool GtkUtil::IsScreenComposited() {
GdkScreen* screen = gdk_screen_get_default();
return gdk_screen_is_composited(screen) == TRUE;
}
-void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) {
+void GtkUtil::EnumerateTopLevelWindows(
+ x11_util::EnumerateWindowsDelegate* delegate) {
GdkScreen* screen = gdk_screen_get_default();
GList* stack = gdk_screen_get_window_stack(screen);
if (!stack) {
@@ -356,7 +358,7 @@ void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) {
g_list_free(stack);
}
-void SetButtonTriggersNavigation(GtkWidget* button) {
+void GtkUtil::SetButtonTriggersNavigation(GtkWidget* button) {
// We handle button activation manually because we want to accept middle mouse
// clicks.
g_signal_connect(G_OBJECT(button), "button-press-event",
@@ -365,21 +367,22 @@ void SetButtonTriggersNavigation(GtkWidget* button) {
G_CALLBACK(OnMouseButtonReleased), NULL);
}
-int MirroredLeftPointForRect(GtkWidget* widget, const gfx::Rect& bounds) {
+int GtkUtil::MirroredLeftPointForRect(GtkWidget* widget,
+ const gfx::Rect& bounds) {
if (l10n_util::GetTextDirection() != l10n_util::RIGHT_TO_LEFT) {
return bounds.x();
}
return widget->allocation.width - bounds.x() - bounds.width();
}
-int MirroredXCoordinate(GtkWidget* widget, int x) {
+int GtkUtil::MirroredXCoordinate(GtkWidget* widget, int x) {
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
return widget->allocation.width - x;
}
return x;
}
-bool WidgetContainsCursor(GtkWidget* widget) {
+bool GtkUtil::WidgetContainsCursor(GtkWidget* widget) {
gint x = 0;
gint y = 0;
gtk_widget_get_pointer(widget, &x, &y);
@@ -397,7 +400,7 @@ bool WidgetContainsCursor(GtkWidget* widget) {
return widget_allocation.Contains(x, y);
}
-void SetWindowIcon(GtkWindow* window) {
+void GtkUtil::SetWindowIcon(GtkWindow* window) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
GList* icon_list = NULL;
icon_list = g_list_append(icon_list, rb.GetPixbufNamed(IDR_PRODUCT_ICON_32));
@@ -405,5 +408,3 @@ void SetWindowIcon(GtkWindow* window) {
gtk_window_set_icon_list(window, icon_list);
g_list_free(icon_list);
}
-
-} // namespace gtk_util