Exemplo n.º 1
0
static void
gdl_dock_object_destroy (GtkWidget *dock_object)
{
    GdlDockObject *object;

    g_return_if_fail (GDL_IS_DOCK_OBJECT (dock_object));

    object = GDL_DOCK_OBJECT (dock_object);
    if (gdl_dock_object_is_compound (object)) {
        /* detach our dock object children if we have some, and even
           if we are not attached, so they can get notification */
        gdl_dock_object_freeze (object);
        gtk_container_foreach (GTK_CONTAINER (object),
                               (GtkCallback) gdl_dock_object_foreach_detach,
                               NULL);
        object->priv->reduce_pending = FALSE;
        gdl_dock_object_thaw (object);
    }
    /* detach ourselves */
    gdl_dock_object_detach (object, FALSE);

    /* finally unbind us */
    if (object->priv->master)
        gdl_dock_object_unbind (object);

    GTK_WIDGET_CLASS(gdl_dock_object_parent_class)->destroy (dock_object);
}
Exemplo n.º 2
0
/**
 * gdl_dock_object_dock:
 * @object: A #GdlDockObject
 * @requestor: The widget to dock
 * @position: The position for the child
 * @other_data: (allow-none): Optional data giving additional information
 * depending on the dock object.
 *
 * Dock a dock widget in @object at the defined position.
 */
void
gdl_dock_object_dock (GdlDockObject    *object,
                      GdlDockObject    *requestor,
                      GdlDockPlacement  position,
                      GValue           *other_data)
{
    GdlDockObject *parent;

    g_return_if_fail (object != NULL && requestor != NULL);

    if (object == requestor)
        return;

    if (!object->priv->master)
        g_warning (_("Dock operation requested in a non-bound object %p. "
                     "The application might crash"), object);

    if (!gdl_dock_object_is_bound (requestor))
        gdl_dock_object_bind (requestor, object->priv->master);

    if (requestor->priv->master != object->priv->master) {
        g_warning (_("Cannot dock %p to %p because they belong to different masters"),
                   requestor, object);
        return;
    }

    /* first, see if we can optimize things by reordering */
    if (position != GDL_DOCK_NONE) {
        parent = gdl_dock_object_get_parent_object (object);
        if (gdl_dock_object_reorder (object, requestor, position, other_data) ||
            (parent && gdl_dock_object_reorder (parent, requestor, position, other_data)))
            return;
    }

    /* freeze the object, since under some conditions it might be destroyed when
       detaching the requestor */
    gdl_dock_object_freeze (object);

    /* detach the requestor before docking */
    g_object_ref (requestor);
    gdl_dock_object_detach (requestor, FALSE);

    if (position != GDL_DOCK_NONE)
        g_signal_emit (object, gdl_dock_object_signals [DOCK], 0,
                       requestor, position, other_data);

    g_object_unref (requestor);
    gdl_dock_object_thaw (object);

    if (gtk_widget_get_visible (GTK_WIDGET (requestor))) {
        requestor->priv->attached = TRUE;
#ifndef GDL_DISABLE_DEPRECATED
        requestor->deprecated_flags |= GDL_DOCK_ATTACHED;
#endif
    }
    /* Update visibility of automatic parents */
    gdl_dock_object_update_parent_visibility (GDL_DOCK_OBJECT (requestor));
}
Exemplo n.º 3
0
Arquivo: gdl-dock.c Projeto: vldm/gdl
static void
gdl_dock_detach (GdlDockObject *object,
                 gboolean       recursive)
{
    GdlDock *dock = GDL_DOCK (object);

    /* detach children */
    if (recursive && dock->priv->root) {
        gdl_dock_object_detach (dock->priv->root, recursive);
    }
}
Exemplo n.º 4
0
void
gdl_dock_object_dock (GdlDockObject    *object,
                      GdlDockObject    *requestor,
                      GdlDockPlacement  position,
                      GValue           *other_data)
{
    GdlDockObject *parent;
    
    g_return_if_fail (object != NULL && requestor != NULL);
        
    if (object == requestor)
        return;
    
    if (!object->master)
        g_warning (_("Dock operation requested in a non-bound object %p. "
                     "The application might crash"), object);
        
	PF;

    if (!gdl_dock_object_is_bound (requestor))
        gdl_dock_object_bind (requestor, object->master);

    if (requestor->master != object->master) {
        g_warning (_("Cannot dock %p to %p because they belong to different masters"),
                   requestor, object);
        return;
    }

    /* first, see if we can optimize things by reordering */
    if (position != GDL_DOCK_NONE) {
        parent = gdl_dock_object_get_parent_object (object);
        if (gdl_dock_object_reorder (object, requestor, position, other_data) ||
            (parent && gdl_dock_object_reorder (parent, requestor, position, other_data)))
            return;
    }
    
    /* freeze the object, since under some conditions it might be destroyed when
       detaching the requestor */
    gdl_dock_object_freeze (object);

    /* detach the requestor before docking */
    g_object_ref (requestor);
    if (GDL_DOCK_OBJECT_ATTACHED (requestor))
        gdl_dock_object_detach (requestor, FALSE);

    if (position != GDL_DOCK_NONE)
        g_signal_emit (object, gdl_dock_object_signals [DOCK], 0,
                       requestor, position, other_data);
	dbg(1, "done");

    g_object_unref (requestor);
    gdl_dock_object_thaw (object);
}
Exemplo n.º 5
0
static void
gdl_dock_detach (GdlDockObject *object,
                 gboolean       recursive)
{
    GdlDock *dock = GDL_DOCK (object);
    
    /* detach children */
    if (recursive && dock->root) {
        gdl_dock_object_detach (dock->root, recursive);
    }
    GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED);
}
Exemplo n.º 6
0
void
gdl_dock_object_unbind (GdlDockObject *object)
{
    g_return_if_fail (object != NULL);

    g_object_ref (object);

    /* detach the object first */
    if (GDL_DOCK_OBJECT_ATTACHED (object))
        gdl_dock_object_detach (object, TRUE);
    
    if (object->master) {
        GObject *master = object->master;
        g_object_remove_weak_pointer (master, (gpointer *) &object->master);
        object->master = NULL;
        gdl_dock_master_remove (GDL_DOCK_MASTER (master), object);
        g_object_notify (G_OBJECT (object), "master");
    }
    g_object_unref (object);
}
Exemplo n.º 7
0
/**
 * gdl_dock_object_unbind:
 * @object: A #GdlDockObject
 *
 * This removes the link between an dock object and its master.
 */
void
gdl_dock_object_unbind (GdlDockObject *object)
{
    g_return_if_fail (object != NULL);

    g_object_ref (object);

    /* detach the object first */
    gdl_dock_object_detach (object, TRUE);

    if (object->priv->master) {
        GObject *master = object->priv->master;
        g_object_remove_weak_pointer (master, (gpointer *) &object->priv->master);
        object->priv->master = NULL;
#ifndef GDL_DISABLE_DEPRECATED
        object->deprecated_master = NULL;
#endif
        gdl_dock_master_remove (GDL_DOCK_MASTER (master), object);
        g_object_notify (G_OBJECT (object), "master");
    }
    g_object_unref (object);
}
Exemplo n.º 8
0
static void
gdl_dock_object_real_reduce (GdlDockObject *object)
{
    GdlDockObject *parent;
    GList         *children;

    g_return_if_fail (object != NULL);

    if (!gdl_dock_object_is_compound (object))
        return;

    parent = gdl_dock_object_get_parent_object (object);
    children = gtk_container_get_children (GTK_CONTAINER (object));
    if (g_list_length (children) <= 1) {
        GList *l;
        GList *dchildren = NULL;

        /* detach ourselves and then re-attach our children to our
           current parent.  if we are not currently attached, the
           children are detached */
        if (parent)
            gdl_dock_object_freeze (parent);
        gdl_dock_object_freeze (object);
        /* Detach the children before detaching this object, since in this
         * way the children can have access to the whole object hierarchy.
         * Set the InDetach flag now, so the children know that this object
         * is going to be detached. */


        for (l = children; l; l = l->next) {
            GdlDockObject *child;

            if (!GDL_IS_DOCK_OBJECT (l->data))
                continue;

            child = GDL_DOCK_OBJECT (l->data);

            g_object_ref (child);
            gdl_dock_object_detach (child, FALSE);
            if (parent)
                dchildren = g_list_append (dchildren, child);
        }
        /* Now it can be detached */
        gdl_dock_object_detach (object, FALSE);

        /* After detaching the reduced object, we can add the
        children (the only child in fact) to the new parent */
        for (l = dchildren; l; l = l->next) {
            gtk_container_add (GTK_CONTAINER (parent), l->data);
            g_object_unref (l->data);
        }
        g_list_free (dchildren);


        /* sink the widget, so any automatic floating widget is destroyed */
        g_object_ref_sink (object);
        /* don't reenter */
        object->priv->reduce_pending = FALSE;
        gdl_dock_object_thaw (object);
        if (parent)
            gdl_dock_object_thaw (parent);
    }
    g_list_free (children);
}
Exemplo n.º 9
0
static void
gdl_dock_object_foreach_detach (GdlDockObject *object,
                                gpointer       user_data)
{
    gdl_dock_object_detach (object, TRUE);
}