コード例 #1
0
ファイル: mozcontainer.c プロジェクト: LyeSS/mozilla-central
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));
}
コード例 #2
0
ファイル: mozcontainer.c プロジェクト: LyeSS/mozilla-central
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
}
コード例 #3
0
ファイル: test_container.c プロジェクト: fortunto2/celtx
int main(int argc, char **argv)
{
  gtk_init(&argc, &argv);

  //  gdk_window_set_debug_updates(TRUE);

  toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  printf("toplevel window is %p\n", toplevel_window);

  moz_container = moz_container_new();
  printf("moz_container is %p\n", moz_container);
  gtk_signal_connect(GTK_OBJECT(moz_container), "expose_event",
                     GTK_SIGNAL_FUNC(expose_handler), NULL);
  gtk_signal_connect(GTK_OBJECT(moz_container), "size_allocate",
                     GTK_SIGNAL_FUNC(size_allocate_handler), NULL);

  gtk_container_add(GTK_CONTAINER(toplevel_window),
                    moz_container);

  gtk_widget_realize(moz_container);

  drawingarea1 = moz_drawingarea_new (NULL, MOZ_CONTAINER(moz_container));
  moz_drawingarea_set_visibility (drawingarea1, TRUE);
  moz_drawingarea_move(drawingarea1, 10, 10);

  button = gtk_button_new_with_label("foo");
  scrollbar = gtk_vscrollbar_new(NULL);

  gtk_widget_set_parent_window(button, drawingarea1->inner_window);
  gtk_widget_set_parent_window(scrollbar, drawingarea1->inner_window);

  moz_container_put(MOZ_CONTAINER(moz_container), button, 0, 0);
  moz_container_put(MOZ_CONTAINER(moz_container), scrollbar, 0, 50);

  gtk_widget_show(button); 
  gtk_widget_show(scrollbar);
  gtk_widget_show(toplevel_window);
  gtk_widget_show(moz_container);

  gtk_main();

  return 0;
}
コード例 #4
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
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);
    }
}
コード例 #5
0
ファイル: mozcontainer.c プロジェクト: LyeSS/mozilla-central
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);
}
コード例 #6
0
ファイル: mozcontainer.c プロジェクト: LyeSS/mozilla-central
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);
    }
}
コード例 #7
0
ファイル: nsFilePicker.cpp プロジェクト: fortunto2/celtx
// XXXdholbert -- this function is duplicated in nsPrintDialogGTK.cpp
// and needs to be unified in some generic utility class.
static GtkWindow *
get_gtk_window_for_nsiwidget(nsIWidget *widget)
{
  // Get native GdkWindow
  GdkWindow *gdk_win = GDK_WINDOW(widget->GetNativeData(NS_NATIVE_WIDGET));
  if (!gdk_win)
    return NULL;

  // Get the container
  gpointer user_data = NULL;
  gdk_window_get_user_data(gdk_win, &user_data);
  if (!user_data)
    return NULL;

  // Make sure its really a container
  MozContainer *parent_container = MOZ_CONTAINER(user_data);
  if (!parent_container)
    return NULL;

  // Get its toplevel
  return GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(parent_container)));
}
コード例 #8
0
ファイル: mozcontainer.c プロジェクト: LyeSS/mozilla-central
static void 
moz_container_add(GtkContainer *container, GtkWidget *widget)
{
    moz_container_put(MOZ_CONTAINER(container), widget, 0, 0);
}