OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/gtk/gtk_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 void RemoveWidget(GtkWidget* widget, gpointer container) { | 73 void RemoveWidget(GtkWidget* widget, gpointer container) { |
74 gtk_container_remove(GTK_CONTAINER(container), widget); | 74 gtk_container_remove(GTK_CONTAINER(container), widget); |
75 } | 75 } |
76 | 76 |
77 // These two functions are copped almost directly from gtk core. The only | 77 // These two functions are copped almost directly from gtk core. The only |
78 // difference is that they accept middle clicks. | 78 // difference is that they accept middle clicks. |
79 gboolean OnMouseButtonPressed(GtkWidget* widget, GdkEventButton* event, | 79 gboolean OnMouseButtonPressed(GtkWidget* widget, GdkEventButton* event, |
80 gpointer userdata) { | 80 gpointer userdata) { |
81 if (event->type == GDK_BUTTON_PRESS) { | 81 if (event->type == GDK_BUTTON_PRESS) { |
82 if (gtk_button_get_focus_on_click(GTK_BUTTON(widget)) && | 82 if (gtk_button_get_focus_on_click(GTK_BUTTON(widget)) && |
83 !GTK_WIDGET_HAS_FOCUS(widget)) { | 83 !gtk_widget_has_focus(widget)) { |
84 gtk_widget_grab_focus(widget); | 84 gtk_widget_grab_focus(widget); |
85 } | 85 } |
86 | 86 |
87 gint button_mask = GPOINTER_TO_INT(userdata); | 87 gint button_mask = GPOINTER_TO_INT(userdata); |
88 if (button_mask & (1 << event->button)) | 88 if (button_mask & (1 << event->button)) |
89 gtk_button_pressed(GTK_BUTTON(widget)); | 89 gtk_button_pressed(GTK_BUTTON(widget)); |
90 } | 90 } |
91 | 91 |
92 return TRUE; | 92 return TRUE; |
93 } | 93 } |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 } | 926 } |
927 | 927 |
928 guint state = event->button.state; | 928 guint state = event->button.state; |
929 gdk_event_free(event); | 929 gdk_event_free(event); |
930 return event_utils::DispositionFromEventFlags(state); | 930 return event_utils::DispositionFromEventFlags(state); |
931 } | 931 } |
932 | 932 |
933 bool GrabAllInput(GtkWidget* widget) { | 933 bool GrabAllInput(GtkWidget* widget) { |
934 guint time = gtk_get_current_event_time(); | 934 guint time = gtk_get_current_event_time(); |
935 | 935 |
936 if (!GTK_WIDGET_VISIBLE(widget)) | 936 if (!gtk_widget_get_visible(widget)) |
937 return false; | 937 return false; |
938 | 938 |
939 if (!gdk_pointer_grab(widget->window, TRUE, | 939 if (!gdk_pointer_grab(widget->window, TRUE, |
940 GdkEventMask(GDK_BUTTON_PRESS_MASK | | 940 GdkEventMask(GDK_BUTTON_PRESS_MASK | |
941 GDK_BUTTON_RELEASE_MASK | | 941 GDK_BUTTON_RELEASE_MASK | |
942 GDK_ENTER_NOTIFY_MASK | | 942 GDK_ENTER_NOTIFY_MASK | |
943 GDK_LEAVE_NOTIFY_MASK | | 943 GDK_LEAVE_NOTIFY_MASK | |
944 GDK_POINTER_MOTION_MASK), | 944 GDK_POINTER_MOTION_MASK), |
945 NULL, NULL, time) == 0) { | 945 NULL, NULL, time) == 0) { |
946 return false; | 946 return false; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 string16 preferences; | 1180 string16 preferences; |
1181 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { | 1181 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { |
1182 const char16 kUnderscore[] = { '_', 0 }; | 1182 const char16 kUnderscore[] = { '_', 0 }; |
1183 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); | 1183 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); |
1184 } | 1184 } |
1185 return preferences; | 1185 return preferences; |
1186 } | 1186 } |
1187 | 1187 |
1188 bool IsWidgetAncestryVisible(GtkWidget* widget) { | 1188 bool IsWidgetAncestryVisible(GtkWidget* widget) { |
1189 GtkWidget* parent = widget; | 1189 GtkWidget* parent = widget; |
1190 while (parent && GTK_WIDGET_VISIBLE(parent)) | 1190 while (parent && gtk_widget_get_visible(parent)) |
1191 parent = parent->parent; | 1191 parent = parent->parent; |
1192 return !parent; | 1192 return !parent; |
1193 } | 1193 } |
1194 | 1194 |
1195 void SetLabelWidth(GtkWidget* label, int pixel_width) { | 1195 void SetLabelWidth(GtkWidget* label, int pixel_width) { |
1196 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 1196 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
1197 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 1197 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
1198 | 1198 |
1199 // Do the simple thing in LTR because the bug only affects right-aligned | 1199 // Do the simple thing in LTR because the bug only affects right-aligned |
1200 // text. Also, when using the workaround, the label tries to maintain | 1200 // text. Also, when using the workaround, the label tries to maintain |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1281 |
1282 void DoCopy(BrowserWindow* window) { | 1282 void DoCopy(BrowserWindow* window) { |
1283 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1283 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); |
1284 } | 1284 } |
1285 | 1285 |
1286 void DoPaste(BrowserWindow* window) { | 1286 void DoPaste(BrowserWindow* window) { |
1287 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1287 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); |
1288 } | 1288 } |
1289 | 1289 |
1290 } // namespace gtk_util | 1290 } // namespace gtk_util |
OLD | NEW |