Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions | Variables
mozcontainer.c File Reference
#include "mozcontainer.h"
#include <gtk/gtkprivate.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  _MozContainerChild

Typedefs

typedef struct _MozContainerChild

Functions

static void moz_container_class_init (MozContainerClass *klass)
static void moz_container_init (MozContainer *container)
static void moz_container_map (GtkWidget *widget)
static void moz_container_unmap (GtkWidget *widget)
static void moz_container_realize (GtkWidget *widget)
static void moz_container_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
static void moz_container_remove (GtkContainer *container, GtkWidget *child_widget)
static void moz_container_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
static void moz_container_add (GtkContainer *container, GtkWidget *widget)
static void moz_container_allocate_child (MozContainer *container, MozContainerChild *child)
static MozContainerChild * moz_container_get_child (MozContainer *container, GtkWidget *child)
GtkType moz_container_get_type (void)
GtkWidget * moz_container_new (void)
void moz_container_put (MozContainer *container, GtkWidget *child_widget, gint x, gint y)
void moz_container_move (MozContainer *container, GtkWidget *child_widget, gint x, gint y, gint width, gint height)
void moz_container_scroll_update (MozContainer *container, GtkWidget *child_widget, gint x, gint y)

Variables

static GtkContainerClass * parent_class = NULL

Class Documentation

struct _MozContainerChild

Definition at line 66 of file mozcontainer.c.

Class Members
GtkWidget * widget
gint x
gint y

Typedef Documentation

typedef struct _MozContainerChild

Definition at line 64 of file mozcontainer.c.


Function Documentation

static void moz_container_add ( GtkContainer *  container,
GtkWidget *  widget 
) [static]

Definition at line 442 of file mozcontainer.c.

{
    moz_container_put(MOZ_CONTAINER(container), widget, 0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void moz_container_allocate_child ( MozContainer *  container,
MozContainerChild *  child 
) [static]

Definition at line 406 of file mozcontainer.c.

{
    GtkAllocation  allocation;
    GtkRequisition requisition;

    allocation.x = child->x;
    allocation.y = child->y;
    /* gtk_widget_get_child_requisition (child->widget, &requisition); */
    /* gtk_widget_size_request (child->widget, &requisition); */
    allocation.width = child->widget->allocation.width;
    allocation.height = child->widget->allocation.height;

    gtk_widget_size_allocate (child->widget, &allocation);
}

Here is the caller graph for this function:

void moz_container_class_init ( MozContainerClass *  klass) [static]

Definition at line 198 of file mozcontainer.c.

{
    /*GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
      GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); */
    GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

    parent_class = g_type_class_peek_parent (klass);

    widget_class->map = moz_container_map;
    widget_class->unmap = moz_container_unmap;
    widget_class->realize = moz_container_realize;
    widget_class->size_allocate = moz_container_size_allocate;

    container_class->remove = moz_container_remove;
    container_class->forall = moz_container_forall;
    container_class->add = moz_container_add;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void moz_container_forall ( GtkContainer *  container,
gboolean  include_internals,
GtkCallback  callback,
gpointer  callback_data 
) [static]

Definition at line 385 of file mozcontainer.c.

{
    MozContainer *moz_container;
    GList *tmp_list;
  
    g_return_if_fail (IS_MOZ_CONTAINER(container));
    g_return_if_fail (callback != NULL);

    moz_container = MOZ_CONTAINER(container);

    tmp_list = moz_container->children;
    while (tmp_list) {
        MozContainerChild *child;
        child = tmp_list->data;
        tmp_list = tmp_list->next;
        (* callback) (child->widget, callback_data);
    }
}

Here is the caller graph for this function:

MozContainerChild * moz_container_get_child ( MozContainer *  container,
GtkWidget *  child 
) [static]

Definition at line 423 of file mozcontainer.c.

{
    GList *tmp_list;

    tmp_list = container->children;
    while (tmp_list) {
        MozContainerChild *child;
    
        child = tmp_list->data;
        tmp_list = tmp_list->next;

        if (child->widget == child_widget)
            return child;
    }

    return NULL;
}

Here is the caller graph for this function:

Definition at line 82 of file mozcontainer.c.

{
    static GtkType moz_container_type = 0;

    if (!moz_container_type) {
        static GTypeInfo moz_container_info = {
            sizeof(MozContainerClass), /* class_size */
            NULL, /* base_init */
            NULL, /* base_finalize */
            (GClassInitFunc) moz_container_class_init, /* class_init */
            NULL, /* class_destroy */
            NULL, /* class_data */
            sizeof(MozContainer), /* instance_size */
            0, /* n_preallocs */
            (GInstanceInitFunc) moz_container_init, /* instance_init */
            NULL, /* value_table */
        };

        moz_container_type = g_type_register_static (GTK_TYPE_CONTAINER,
                                                     "MozContainer",
                                                     &moz_container_info, 0);
    }

    return moz_container_type;
}

Here is the call graph for this function:

void moz_container_init ( MozContainer *  container) [static]

Definition at line 218 of file mozcontainer.c.

{
    GTK_WIDGET_SET_FLAGS(container, GTK_CAN_FOCUS);
    container->container.resize_mode = GTK_RESIZE_IMMEDIATE;
    gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container),
                                      FALSE);

    /* Mozilla uses the the gdbrgb colormap and visual throughout the
       backend so for widgets we just use that colormap instead of the
       default one. */
    gtk_widget_set_colormap(GTK_WIDGET(container), gdk_rgb_get_colormap());
}

Here is the caller graph for this function:

void moz_container_map ( GtkWidget *  widget) [static]

Definition at line 232 of file mozcontainer.c.

{
    MozContainer *container;
    GList *tmp_list;
    GtkWidget *tmp_child;

    g_return_if_fail (IS_MOZ_CONTAINER(widget));
    container = MOZ_CONTAINER (widget);

    GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);

    tmp_list = container->children;
    while (tmp_list) {
        tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
    
        if (GTK_WIDGET_VISIBLE(tmp_child)) {
            if (!GTK_WIDGET_MAPPED(tmp_child))
                gtk_widget_map(tmp_child);
        }
        tmp_list = tmp_list->next;
    }

    gdk_window_show (widget->window);
}

Here is the caller graph for this function:

void moz_container_move ( MozContainer *  container,
GtkWidget *  child_widget,
gint  x,
gint  y,
gint  width,
gint  height 
)

Definition at line 141 of file mozcontainer.c.

{
    MozContainerChild *child;
    GtkAllocation new_allocation;

    child = moz_container_get_child (container, child_widget);

    child->x = x;
    child->y = y;

    new_allocation.x = x;
    new_allocation.y = y;
    new_allocation.width = width;
    new_allocation.height = height;

    /* printf("moz_container_move %p %p will allocate to %d %d %d %d\n",
       (void *)container, (void *)child_widget,
       new_allocation.x, new_allocation.y,
       new_allocation.width, new_allocation.height); */

    gtk_widget_size_allocate(child_widget, &new_allocation);
}

Here is the call graph for this function:

GtkWidget* moz_container_new ( void  )

Definition at line 109 of file mozcontainer.c.

{
    MozContainer *container;

    container = gtk_type_new (MOZ_CONTAINER_TYPE);

    return GTK_WIDGET(container);
}

Here is the caller graph for this function:

void moz_container_put ( MozContainer *  container,
GtkWidget *  child_widget,
gint  x,
gint  y 
)

Definition at line 119 of file mozcontainer.c.

{
    MozContainerChild *child;

    child = g_new (MozContainerChild, 1);

    child->widget = child_widget;
    child->x = x;
    child->y = y;

    /*  printf("moz_container_put %p %p %d %d\n", (void *)container,
        (void *)child_widget, x, y); */

    container->children = g_list_append (container->children, child);

    /* we assume that the caller of this function will have already set
       the parent GdkWindow because we can have many anonymous children. */
    gtk_widget_set_parent(child_widget, GTK_WIDGET(container));
}

Here is the caller graph for this function:

void moz_container_realize ( GtkWidget *  widget) [static]

Definition at line 271 of file mozcontainer.c.

{
    GdkWindowAttr attributes;
    gint attributes_mask = 0;
    MozContainer *container;

    g_return_if_fail(IS_MOZ_CONTAINER(widget));

    container = MOZ_CONTAINER(widget);

    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);

    /* create the shell window */

    attributes.event_mask = gtk_widget_get_events (widget);
    attributes.event_mask |=  (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);
    attributes.x = widget->allocation.x;
    attributes.y = widget->allocation.y;
    attributes.width = widget->allocation.width;
    attributes.height = widget->allocation.height;
    attributes.wclass = GDK_INPUT_OUTPUT;
    attributes.visual = gtk_widget_get_visual (widget);
    attributes.colormap = gtk_widget_get_colormap (widget);
    attributes.window_type = GDK_WINDOW_CHILD;

    attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
        GDK_WA_X | GDK_WA_Y;

    widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
                                     &attributes, attributes_mask);
    /*  printf("widget->window is %p\n", (void *)widget->window); */
    gdk_window_set_user_data (widget->window, container);

    widget->style = gtk_style_attach (widget->style, widget->window);

    /* set the back pixmap to None so that you don't end up with the gtk
       default which is BlackPixel */
    gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
}

Here is the caller graph for this function:

void moz_container_remove ( GtkContainer *  container,
GtkWidget *  child_widget 
) [static]

Definition at line 362 of file mozcontainer.c.

{
    MozContainerChild *child;
    MozContainer *moz_container;
    GList *tmp_list;

    g_return_if_fail (IS_MOZ_CONTAINER(container));
    g_return_if_fail (GTK_IS_WIDGET(child_widget));

    moz_container = MOZ_CONTAINER(container);

    child = moz_container_get_child (moz_container, child_widget);
    g_return_if_fail (child);

    if(child->widget == child_widget) {
        gtk_widget_unparent(child_widget);
    }

    moz_container->children = g_list_remove(moz_container->children, child);
    g_free(child);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void moz_container_scroll_update ( MozContainer *  container,
GtkWidget *  child_widget,
gint  x,
gint  y 
)

Definition at line 171 of file mozcontainer.c.

{
    MozContainerChild *child;
    GtkAllocation new_allocation;

    child = moz_container_get_child (container, child_widget);

    child->x = x;
    child->y = y;

    new_allocation.x = x;
    new_allocation.y = y;
    new_allocation.width = child_widget->allocation.width;
    new_allocation.height = child_widget->allocation.height;

    /* printf("moz_container_update %p %p will allocate to %d %d %d %d\n",
       (void *)container, (void *)child_widget,
       new_allocation.x, new_allocation.y,
       new_allocation.width, new_allocation.height); */

    gtk_widget_size_allocate(child_widget, &new_allocation);
}

Here is the call graph for this function:

void moz_container_size_allocate ( GtkWidget *  widget,
GtkAllocation *  allocation 
) [static]

Definition at line 312 of file mozcontainer.c.

{
    MozContainer   *container;
    GList          *tmp_list;
    GtkAllocation   tmp_allocation;
    GtkRequisition  tmp_requisition;
    GtkWidget      *tmp_child;

    g_return_if_fail (IS_MOZ_CONTAINER (widget));

    /*  printf("moz_container_size_allocate %p %d %d %d %d\n",
        (void *)widget,
        allocation->x,
        allocation->y,
        allocation->width,
        allocation->height); */

    /* short circuit if you can */
    container = MOZ_CONTAINER (widget);
    if (!container->children &&
        widget->allocation.x == allocation->x &&
        widget->allocation.y == allocation->y &&
        widget->allocation.width == allocation->width &&
        widget->allocation.height == allocation->height) {
        return;
    }

    widget->allocation = *allocation;

    tmp_list = container->children;

    while (tmp_list) {
        MozContainerChild *child = tmp_list->data;

        moz_container_allocate_child (container, child);

        tmp_list = tmp_list->next;
    }

    if (GTK_WIDGET_REALIZED (widget)) {
        gdk_window_move_resize(widget->window,
                               widget->allocation.x,
                               widget->allocation.y,
                               widget->allocation.width,
                               widget->allocation.height);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void moz_container_unmap ( GtkWidget *  widget) [static]

Definition at line 258 of file mozcontainer.c.

{
    MozContainer *container;

    g_return_if_fail (IS_MOZ_CONTAINER (widget));
    container = MOZ_CONTAINER (widget);
  
    GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);

    gdk_window_hide (widget->window);
}

Here is the caller graph for this function:


Variable Documentation

GtkContainerClass* parent_class = NULL [static]

Definition at line 77 of file mozcontainer.c.