This source file includes following definitions.
- OnKeyPress
- CreateWebContentsModalDialogGtk
#include "chrome/browser/ui/gtk/constrained_window_gtk.h"
#include <gdk/gdkkeysyms.h>
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "ui/base/gtk/gtk_hig_constants.h"
namespace {
gboolean OnKeyPress(GtkWidget* sender, GdkEventKey* key, gpointer user_data) {
if (key->keyval == GDK_Escape) {
gtk_widget_destroy(sender);
return TRUE;
}
return FALSE;
}
}
GtkWidget* CreateWebContentsModalDialogGtk(
GtkWidget* contents,
GtkWidget* focus_widget) {
GtkWidget* border = gtk_event_box_new();
GtkWidget* frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
ui::kContentAreaBorder, ui::kContentAreaBorder,
ui::kContentAreaBorder, ui::kContentAreaBorder);
if (gtk_widget_get_parent(contents))
gtk_widget_reparent(contents, alignment);
else
gtk_container_add(GTK_CONTAINER(alignment), contents);
gtk_container_add(GTK_CONTAINER(frame), alignment);
gtk_container_add(GTK_CONTAINER(border), frame);
gtk_widget_add_events(border, GDK_KEY_PRESS_MASK);
g_signal_connect(border,
"key-press-event",
reinterpret_cast<GCallback>(&OnKeyPress),
NULL);
g_object_set_data(G_OBJECT(border), "focus_widget", focus_widget);
return border;
}