Ejemplo n.º 1
0
/**
 * gdl_dock_object_bind:
 * @object: A #GdlDockObject
 * @master: A #GdlDockMaster
 *
 * Add a link between a #GdlDockObject and a master. It is normally not used
 * directly because it is automatically called when a new object is docked.
 */
void
gdl_dock_object_bind (GdlDockObject *object,
                      GObject       *master)
{
    g_return_if_fail (object != NULL && master != NULL);
    g_return_if_fail (GDL_IS_DOCK_MASTER (master));

    if (object->priv->master == master)
        /* nothing to do here */
        return;

    if (object->priv->master) {
        g_warning (_("Attempt to bind to %p an already bound dock object %p "
                     "(current master: %p)"), master, object, object->priv->master);
        return;
    }

    gdl_dock_master_add (GDL_DOCK_MASTER (master), object);
    object->priv->master = master;
#ifndef GDL_DISABLE_DEPRECATED
    object->deprecated_master = master;
#endif
    g_object_add_weak_pointer (master, (gpointer *) &object->priv->master);

    g_object_notify (G_OBJECT (object), "master");
}
Ejemplo n.º 2
0
static void
gdl_dock_master_dispose (GObject *g_object)
{
    GdlDockMaster *master;
    
    g_return_if_fail (GDL_IS_DOCK_MASTER (g_object));

    master = GDL_DOCK_MASTER (g_object);

    if (master->toplevel_docks) {
        g_list_foreach (master->toplevel_docks,
                        (GFunc) gdl_dock_object_unbind, NULL);
        g_list_free (master->toplevel_docks);
        master->toplevel_docks = NULL;
    }
    
    if (master->dock_objects) {
        GSList *alive_docks = NULL;
        g_hash_table_foreach (master->dock_objects,
                              (GHFunc) ht_foreach_build_slist, &alive_docks);
        while (alive_docks) {
            gdl_dock_object_unbind (GDL_DOCK_OBJECT (alive_docks->data));
            alive_docks = g_slist_delete_link (alive_docks, alive_docks);
        }
        
        g_hash_table_destroy (master->dock_objects);
        master->dock_objects = NULL;
    }
    
    if (master->_priv) {
        if (master->_priv->idle_layout_changed_id)
            g_source_remove (master->_priv->idle_layout_changed_id);
        
        if (master->_priv->root_xor_gc) {
            g_object_unref (master->_priv->root_xor_gc);
            master->_priv->root_xor_gc = NULL;
        }
        if (master->_priv->drag_request) {
            if (G_IS_VALUE (&master->_priv->drag_request->extra))
                g_value_unset (&master->_priv->drag_request->extra);
            g_free (master->_priv->drag_request);
            master->_priv->drag_request = NULL;
        }
        g_free (master->_priv->default_title);
        master->_priv->default_title = NULL;

        g_hash_table_destroy (master->_priv->locked_items);
        master->_priv->locked_items = NULL;
        g_hash_table_destroy (master->_priv->unlocked_items);
        master->_priv->unlocked_items = NULL;
        
        g_free (master->_priv);
        master->_priv = NULL;
    }

    GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (g_object));
}
Ejemplo n.º 3
0
static gboolean
idle_emit_layout_changed (gpointer user_data)
{
    GdlDockMaster *master = user_data;

    g_return_val_if_fail (master && GDL_IS_DOCK_MASTER (master), FALSE);

    master->_priv->idle_layout_changed_id = 0;
    g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0);
    
    return FALSE;
}
Ejemplo n.º 4
0
static void
gdl_dock_master_layout_changed (GdlDockMaster *master)
{
    g_return_if_fail (GDL_IS_DOCK_MASTER (master));

    /* emit "layout-changed" on the controller to notify the user who
     * normally shouldn't have access to us */
    if (master->controller)
        g_signal_emit_by_name (master->controller, "layout-changed");

    /* remove the idle handler if there is one */
    if (master->_priv->idle_layout_changed_id) {
        g_source_remove (master->_priv->idle_layout_changed_id);
        master->_priv->idle_layout_changed_id = 0;
    }
}
Ejemplo n.º 5
0
static void 
item_detach_cb (GdlDockObject *object,
                gboolean       recursive,
                gpointer       user_data)
{
    GdlDockMaster *master = user_data;
    
    g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object));
    g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));

    if (!GDL_DOCK_OBJECT_IN_REFLOW (object) &&
        !GDL_DOCK_OBJECT_AUTOMATIC (object)) {
        if (!master->_priv->idle_layout_changed_id)
            master->_priv->idle_layout_changed_id =
                g_idle_add (idle_emit_layout_changed, master);
    }
}
Ejemplo n.º 6
0
static void
gdl_dock_master_set_switcher_style (GdlDockMaster *master,
                                    GdlSwitcherStyle switcher_style)
{
    GList *l;
    g_return_if_fail (GDL_IS_DOCK_MASTER (master));
    
    master->_priv->switcher_style = switcher_style;
    for (l = master->toplevel_docks; l; l = l->next) {
        GdlDock *dock = GDL_DOCK (l->data);
        if (dock->root)
            set_switcher_style_foreach (GTK_WIDGET (dock->root),
                                        GINT_TO_POINTER (switcher_style));
    }

    /* just to be sure hidden items are set too */
    gdl_dock_master_foreach (master, (GFunc) set_switcher_style_foreach,
                             GINT_TO_POINTER (switcher_style));
}
Ejemplo n.º 7
0
static void 
item_dock_cb (GdlDockObject    *object,
              GdlDockObject    *requestor,
              GdlDockPlacement  position,
              GValue           *other_data,
              gpointer          user_data)
{
    GdlDockMaster *master = user_data;
    
    g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor));
    g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));

    /* here we are in fact interested in the requestor, since it's
     * assumed that object will not change its visibility... for the
     * requestor, however, could mean that it's being shown */
    if (!GDL_DOCK_OBJECT_IN_REFLOW (requestor) &&
        !GDL_DOCK_OBJECT_AUTOMATIC (requestor)) {
        if (!master->_priv->idle_layout_changed_id)
            master->_priv->idle_layout_changed_id =
                g_idle_add (idle_emit_layout_changed, master);
    }
}