This source file includes following definitions.
- set_size
- CastChecked
- GetType
- ClassInit
- InstanceInit
- HandleSizeRequest
- gtk_plugin_container_new
- gtk_plugin_container_set_size
#include "content/browser/renderer_host/gtk_plugin_container.h"
#include <gtk/gtk.h>
#include "base/basictypes.h"
namespace content {
namespace {
class GtkPluginContainer : public GtkSocket {
public:
void set_size(int width, int height) {
width_ = width;
height_ = height;
}
template <class T>
static GtkPluginContainer *CastChecked(T *instance) {
return G_TYPE_CHECK_INSTANCE_CAST(instance, GetType(), GtkPluginContainer);
}
static GType GetType() {
static GType type = 0;
if (!type) {
static const GTypeInfo info = {
sizeof(GtkSocketClass),
NULL, NULL,
static_cast<GClassInitFunc>(&ClassInit),
NULL, NULL,
sizeof(GtkPluginContainer),
0, &InstanceInit,
};
type = g_type_register_static(GTK_TYPE_SOCKET,
"GtkPluginContainer",
&info,
static_cast<GTypeFlags>(0));
}
return type;
}
static void ClassInit(gpointer klass, gpointer class_data_unusued) {
GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass);
widget_class->size_request = &HandleSizeRequest;
}
static void InstanceInit(GTypeInstance *instance, gpointer klass) {
GtkPluginContainer *container = CastChecked(instance);
container->set_size(0, 0);
}
static void HandleSizeRequest(GtkWidget* widget,
GtkRequisition* requisition) {
GtkPluginContainer *container = CastChecked(widget);
requisition->width = container->width_;
requisition->height = container->height_;
}
int width_;
int height_;
DISALLOW_IMPLICIT_CONSTRUCTORS(GtkPluginContainer);
};
}
GtkWidget* gtk_plugin_container_new() {
return GTK_WIDGET(g_object_new(GtkPluginContainer::GetType(), NULL));
}
void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height) {
GtkPluginContainer::CastChecked(widget)->set_size(width, height);
gtk_widget_queue_resize_no_redraw(widget);
}
}