void moz_container_map (GtkWidget *widget) { MozContainer *container; GList *tmp_list; GtkWidget *tmp_child; g_return_if_fail (IS_MOZ_CONTAINER(widget)); container = MOZ_CONTAINER (widget); gtk_widget_set_mapped(widget, TRUE); tmp_list = container->children; while (tmp_list) { tmp_child = ((MozContainerChild *)tmp_list->data)->widget; if (gtk_widget_get_visible(tmp_child)) { if (!gtk_widget_get_mapped(tmp_child)) gtk_widget_map(tmp_child); } tmp_list = tmp_list->next; } gdk_window_show (gtk_widget_get_window(widget)); }
void moz_container_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask = 0; MozContainer *container; GtkAllocation allocation; g_return_if_fail(IS_MOZ_CONTAINER(widget)); container = MOZ_CONTAINER(widget); gtk_widget_set_realized(widget, TRUE); /* create the shell window */ attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | #ifdef MOZ_PLATFORM_MAEMO GDK_POINTER_MOTION_HINT_MASK | #endif GDK_POINTER_MOTION_MASK); gtk_widget_get_allocation(widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); #if defined(MOZ_WIDGET_GTK2) attributes.colormap = gtk_widget_get_colormap (widget); #endif attributes.window_type = GDK_WINDOW_CHILD; attributes_mask |= GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y; #if defined(MOZ_WIDGET_GTK2) attributes_mask |= GDK_WA_COLORMAP; #endif gtk_widget_set_window(widget, 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 (gtk_widget_get_window(widget), container); #if defined(MOZ_WIDGET_GTK2) widget->style = gtk_style_attach (widget->style, widget->window); #endif /* TODO GTK3? */ #if defined(MOZ_WIDGET_GTK2) /* 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); #endif }
void moz_container_unmap (GtkWidget *widget) { g_return_if_fail (IS_MOZ_CONTAINER (widget)); gtk_widget_set_mapped(widget, FALSE); gdk_window_hide (gtk_widget_get_window(widget)); }
void moz_container_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { 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); gtk_widget_get_allocation(widget, &tmp_allocation); if (!container->children && tmp_allocation.x == allocation->x && tmp_allocation.y == allocation->y && tmp_allocation.width == allocation->width && tmp_allocation.height == allocation->height) { return; } gtk_widget_set_allocation(widget, 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_get_has_window (widget) && gtk_widget_get_realized (widget)) { gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x, allocation->y, allocation->width, allocation->height); } }
void moz_container_remove (GtkContainer *container, GtkWidget *child_widget) { MozContainerChild *child; MozContainer *moz_container; GdkWindow* parent_window; 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); /* gtk_widget_unparent will remove the parent window (as well as the * parent widget), but, in Mozilla's window hierarchy, the parent window * may need to be kept because it may be part of a GdkWindow sub-hierarchy * that is being moved to another MozContainer. * * (In a conventional GtkWidget hierarchy, GdkWindows being reparented * would have their own GtkWidget and that widget would be the one being * reparented. In Mozilla's hierarchy, the parent_window needs to be * retained so that the GdkWindow sub-hierarchy is maintained.) */ parent_window = gtk_widget_get_parent_window(child_widget); if (parent_window) g_object_ref(parent_window); gtk_widget_unparent(child_widget); if (parent_window) { /* The child_widget will always still exist because g_signal_emit, * which invokes this function, holds a reference. * * If parent_window is the container's root window then it will not be * the parent_window if the child_widget is placed in another * container. */ if (parent_window != gtk_widget_get_window(GTK_WIDGET(container))) gtk_widget_set_parent_window(child_widget, parent_window); g_object_unref(parent_window); } moz_container->children = g_list_remove(moz_container->children, child); g_free(child); }
void moz_container_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data) { 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); } }