~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/libgdl/gdl-dock-item.c

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                                          gboolean      include_internals,
80
80
                                          GtkCallback   callback,
81
81
                                          gpointer      callback_data);
82
 
static GtkType gdl_dock_item_child_type  (GtkContainer *container);
 
82
static GType gdl_dock_item_child_type  (GtkContainer *container);
83
83
 
84
84
static void  gdl_dock_item_set_focus_child (GtkContainer *container,
85
 
                                            GtkWidget    *widget,
86
 
                                            gpointer      callback_data);
 
85
                                            GtkWidget    *widget);
87
86
 
88
87
static void  gdl_dock_item_size_request  (GtkWidget *widget,
89
88
                                          GtkRequisition *requisition);
164
163
    DOCK_DRAG_BEGIN,
165
164
    DOCK_DRAG_MOTION,
166
165
    DOCK_DRAG_END,
 
166
    SELECTED,
167
167
    MOVE_FOCUS_CHILD,
168
168
    LAST_SIGNAL
169
169
};
282
282
 
283
283
    /* properties */
284
284
 
 
285
    /**
 
286
     * GdlDockItem:orientation:
 
287
     *
 
288
     * The orientation of the docking item. If the orientation is set to
 
289
     * #GTK_ORIENTATION_VERTICAL, the grip widget will be shown along
 
290
     * the top of the edge of item (if it is not hidden). If the
 
291
     * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip
 
292
     * widget will be shown down the left edge of the item (even if the
 
293
     * widget text direction is set to RTL).
 
294
     */
285
295
    g_object_class_install_property (
286
296
        g_object_class, PROP_ORIENTATION,
287
297
        g_param_spec_enum ("orientation", _("Orientation"),
302
312
        g_object_class, PROP_RESIZE,
303
313
        g_param_spec_boolean ("resize", _("Resizable"),
304
314
                              _("If set, the dock item can be resized when "
305
 
                                "docked in a panel"),
 
315
                                "docked in a GtkPanel widget"),
306
316
                              TRUE,
307
317
                              G_PARAM_READWRITE));
308
318
                                     
340
350
 
341
351
    /* signals */
342
352
    
 
353
    /**
 
354
     * GdlDockItem::dock-drag-begin:
 
355
     * @item: The dock item which is being dragged.
 
356
     * 
 
357
     * Signals that the dock item has begun to be dragged.
 
358
     **/
343
359
    gdl_dock_item_signals [DOCK_DRAG_BEGIN] = 
344
360
        g_signal_new ("dock-drag-begin",
345
361
                      G_TYPE_FROM_CLASS (klass),
350
366
                      gdl_marshal_VOID__VOID,
351
367
                      G_TYPE_NONE, 
352
368
                      0);
353
 
 
 
369
    
 
370
    /**
 
371
     * GdlDockItem::dock-drag-motion:
 
372
     * @item: The dock item which is being dragged.
 
373
     * @x: The x-position that the dock item has been dragged to.
 
374
     * @y: The y-position that the dock item has been dragged to.
 
375
     * 
 
376
     * Signals that a dock item dragging motion event has occured.
 
377
     **/
354
378
    gdl_dock_item_signals [DOCK_DRAG_MOTION] = 
355
379
        g_signal_new ("dock-drag-motion",
356
380
                      G_TYPE_FROM_CLASS (klass),
364
388
                      G_TYPE_INT,
365
389
                      G_TYPE_INT);
366
390
 
 
391
    /**
 
392
     * GdlDockItem::dock-drag-end:
 
393
     * @item: The dock item which is no longer being dragged.
 
394
     * @cancel: This value is set to TRUE if the drag was cancelled by
 
395
     * the user. #cancel is set to FALSE if the drag was accepted.
 
396
     * 
 
397
     * Signals that the dock item dragging has ended.
 
398
     **/
367
399
    gdl_dock_item_signals [DOCK_DRAG_END] = 
368
400
        g_signal_new ("dock_drag_end",
369
401
                      G_TYPE_FROM_CLASS (klass),
376
408
                      1,
377
409
                      G_TYPE_BOOLEAN);
378
410
 
 
411
    /**
 
412
     * GdlDockItem::selected:
 
413
     *
 
414
     * Signals that this dock has been selected from a switcher.
 
415
     */
 
416
    gdl_dock_item_signals [SELECTED] =
 
417
        g_signal_new ("selected",
 
418
                      G_TYPE_FROM_CLASS (klass),
 
419
                      G_SIGNAL_RUN_FIRST,
 
420
                      0,
 
421
                      NULL,
 
422
                      NULL,
 
423
                      g_cclosure_marshal_VOID__VOID,
 
424
                      G_TYPE_NONE,
 
425
                      0);
 
426
    
379
427
    gdl_dock_item_signals [MOVE_FOCUS_CHILD] =
380
428
        g_signal_new ("move_focus_child",
381
429
                      G_TYPE_FROM_CLASS (klass),
426
474
static void
427
475
gdl_dock_item_instance_init (GdlDockItem *item)
428
476
{
429
 
    GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (item), GTK_NO_WINDOW);
430
 
    GTK_WIDGET_SET_FLAGS (GTK_WIDGET (item), GTK_CAN_FOCUS);
 
477
    gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
 
478
    gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE);
431
479
 
432
480
    item->child = NULL;
433
481
    
644
692
    
645
693
    item = GDL_DOCK_ITEM (container);
646
694
    if (item->_priv && widget == item->_priv->grip) {
647
 
        gboolean grip_was_visible = GTK_WIDGET_VISIBLE (widget);
 
695
        gboolean grip_was_visible = gtk_widget_get_visible (widget);
648
696
        gtk_widget_unparent (widget);
649
697
        item->_priv->grip = NULL;
650
698
        if (grip_was_visible)
658
706
    
659
707
    g_return_if_fail (item->child == widget);
660
708
    
661
 
    was_visible = GTK_WIDGET_VISIBLE (widget);
 
709
    was_visible = gtk_widget_get_visible (widget);
662
710
 
663
711
    gtk_widget_unparent (widget);
664
712
    item->child = NULL;
684
732
        (* callback) (item->child, callback_data);
685
733
}
686
734
 
687
 
static GtkType
 
735
static GType
688
736
gdl_dock_item_child_type (GtkContainer *container)
689
737
{
690
738
    g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE);
697
745
 
698
746
static void
699
747
gdl_dock_item_set_focus_child (GtkContainer *container,
700
 
                               GtkWidget    *child,
701
 
                               gpointer      callback_data)
 
748
                               GtkWidget    *child)
702
749
{
703
750
    g_return_if_fail (GDL_IS_DOCK_ITEM (container));
704
751
    
705
 
    if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child)
 
752
    if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child) {
706
753
        (* GTK_CONTAINER_CLASS (parent_class)->set_focus_child) (container, child);
 
754
    }
707
755
 
708
756
    gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container));
709
757
}
781
829
    item->_priv->preferred_height = -1;
782
830
    item->_priv->preferred_width = -1;
783
831
    
784
 
    if (GTK_WIDGET_REALIZED (widget))
 
832
    if (gtk_widget_get_realized (widget))
785
833
        gdk_window_move_resize (widget->window,
786
834
                                widget->allocation.x,
787
835
                                widget->allocation.y,
788
836
                                widget->allocation.width,
789
837
                                widget->allocation.height);
790
838
 
791
 
    if (item->child && GTK_WIDGET_VISIBLE (item->child)) {
 
839
    if (item->child && gtk_widget_get_visible (item->child)) {
792
840
        GtkAllocation  child_allocation;
793
841
        int            border_width;
794
842
 
836
884
    g_return_if_fail (widget != NULL);
837
885
    g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
838
886
 
839
 
    GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
 
887
    gtk_widget_set_mapped (widget, TRUE);
840
888
 
841
889
    item = GDL_DOCK_ITEM (widget);
842
890
 
843
891
    gdk_window_show (widget->window);
844
892
 
845
893
    if (item->child
846
 
        && GTK_WIDGET_VISIBLE (item->child)
847
 
        && !GTK_WIDGET_MAPPED (item->child))
 
894
        && gtk_widget_get_visible (item->child)
 
895
        && !gtk_widget_get_mapped (item->child))
848
896
        gtk_widget_map (item->child);
849
897
 
850
898
    if (item->_priv->grip
851
 
        && GTK_WIDGET_VISIBLE (item->_priv->grip)
852
 
        && !GTK_WIDGET_MAPPED (item->_priv->grip))
 
899
        && gtk_widget_get_visible (item->_priv->grip)
 
900
        && !gtk_widget_get_mapped (item->_priv->grip))
853
901
        gtk_widget_map (item->_priv->grip);
854
902
}
855
903
 
861
909
    g_return_if_fail (widget != NULL);
862
910
    g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
863
911
 
864
 
    GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
 
912
    gtk_widget_set_mapped (widget, FALSE);
865
913
    
866
914
    item = GDL_DOCK_ITEM (widget);
867
915
 
883
931
 
884
932
    item = GDL_DOCK_ITEM (widget);
885
933
 
886
 
    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
 
934
    gtk_widget_set_realized (widget, TRUE);
887
935
 
888
936
    /* widget window */
889
937
    attributes.x = widget->allocation.x;
906
954
  
907
955
    widget->style = gtk_style_attach (widget->style, widget->window);
908
956
    gtk_style_set_background (widget->style, widget->window, 
909
 
                              GTK_WIDGET_STATE (item));
 
957
                              gtk_widget_get_state (GTK_WIDGET(item)));
910
958
    gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
911
959
 
912
960
    if (item->child)
920
968
gdl_dock_item_style_set (GtkWidget *widget,
921
969
                         GtkStyle  *previous_style)
922
970
{
 
971
    (void)previous_style;
 
972
 
923
973
    g_return_if_fail (widget != NULL);
924
974
    g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
925
975
 
926
 
    if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) {
 
976
    if (gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget)) {
927
977
        gtk_style_set_background (widget->style, widget->window,
928
978
                                  widget->state);
929
 
        if (GTK_WIDGET_DRAWABLE (widget))
 
979
        if (gtk_widget_is_drawable (widget))
930
980
            gdk_window_clear (widget->window);
931
981
    }
932
982
}
935
985
gdl_dock_item_paint (GtkWidget      *widget,
936
986
                     GdkEventExpose *event)
937
987
{
938
 
    GdlDockItem  *item;
939
 
 
940
 
    item = GDL_DOCK_ITEM (widget);
941
 
 
942
988
    gtk_paint_box (widget->style,
943
989
                   widget->window,
944
 
                   GTK_WIDGET_STATE (widget),
 
990
                   gtk_widget_get_state (widget),
945
991
                   GTK_SHADOW_NONE,
946
992
                   &event->area, widget,
947
993
                   "dockitem",
956
1002
    g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
957
1003
    g_return_val_if_fail (event != NULL, FALSE);
958
1004
 
959
 
    if (GTK_WIDGET_DRAWABLE (widget) && event->window == widget->window) {
 
1005
    if (gtk_widget_is_drawable (widget) && event->window == widget->window) {
960
1006
        gdl_dock_item_paint (widget, event);
961
1007
        GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event));
962
1008
    }
1260
1306
                    GdlDockPlacement  position,
1261
1307
                    GValue           *other_data)
1262
1308
{
1263
 
    GdlDockObject *new_parent, *parent;
1264
 
    gboolean       add_ourselves_first;
 
1309
    GdlDockObject *new_parent = NULL;
 
1310
    GdlDockObject *parent, *requestor_parent;
 
1311
    gboolean       add_ourselves_first = FALSE;
1265
1312
 
1266
1313
    guint          available_space=0;
1267
1314
    gint           pref_size=-1;
1375
1422
            pref_size = req.width;
1376
1423
            break;
1377
1424
        case GDL_DOCK_CENTER:
1378
 
            new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
1379
 
                                       "preferred-width", object_req.width,
1380
 
                                       "preferred-height", object_req.height,
1381
 
                                       NULL);
1382
 
            add_ourselves_first = TRUE;
 
1425
            /* If the parent is already a DockNotebook, we don't need
 
1426
             to create a new one. */
 
1427
            if (!GDL_IS_DOCK_NOTEBOOK (parent))
 
1428
            {
 
1429
                new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
 
1430
                                           "preferred-width", object_req.width,
 
1431
                                           "preferred-height", object_req.height,
 
1432
                                           NULL);
 
1433
                add_ourselves_first = TRUE;
 
1434
            }
1383
1435
            break;
1384
1436
        default: 
1385
1437
        {
1398
1450
    if (parent)
1399
1451
        gdl_dock_object_freeze (parent);
1400
1452
 
1401
 
    /* ref ourselves since we could be destroyed when detached */
1402
 
    g_object_ref (object);
1403
 
    GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
1404
 
    gdl_dock_object_detach (object, FALSE);
1405
 
 
1406
 
    /* freeze the new parent, so reduce won't get called before it's
1407
 
       actually added to our parent */
1408
 
    gdl_dock_object_freeze (new_parent);
1409
 
    
1410
 
    /* bind the new parent to our master, so the following adds work */
1411
 
    gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
1412
 
    
1413
 
    /* add the objects */
1414
 
    if (add_ourselves_first) {
1415
 
        gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
1416
 
        gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
1417
 
        splitpos = available_space - pref_size;
1418
 
    } else {
1419
 
        gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
1420
 
        gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
1421
 
        splitpos = pref_size;
1422
 
    }
1423
 
 
1424
 
    /* add the new parent to the parent */
1425
 
    if (parent)
1426
 
        gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
1427
 
 
1428
 
    /* show automatic object */
1429
 
    if (GTK_WIDGET_VISIBLE (object))
1430
 
        gtk_widget_show (GTK_WIDGET (new_parent));
1431
 
    
1432
 
    /* use extra docking parameter */
1433
 
    if (position != GDL_DOCK_CENTER && other_data &&
1434
 
        G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
 
1453
    
 
1454
    if (new_parent)
 
1455
    {
 
1456
        /* ref ourselves since we could be destroyed when detached */ 
 
1457
        g_object_ref (object);
 
1458
        GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
 
1459
        gdl_dock_object_detach (object, FALSE);
 
1460
 
 
1461
        /* freeze the new parent, so reduce won't get called before it's
 
1462
           actually added to our parent */
 
1463
        gdl_dock_object_freeze (new_parent);
 
1464
    
 
1465
        /* bind the new parent to our master, so the following adds work */
 
1466
        gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
 
1467
    
 
1468
        /* add the objects */
 
1469
        if (add_ourselves_first) {
 
1470
            gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
 
1471
            gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
 
1472
            splitpos = available_space - pref_size;
 
1473
        } else {
 
1474
            gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
 
1475
            gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
 
1476
            splitpos = pref_size;
 
1477
        }
 
1478
 
 
1479
        /* add the new parent to the parent */
 
1480
        if (parent)
 
1481
            gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
 
1482
 
 
1483
        /* show automatic object */
 
1484
        if (gtk_widget_get_visible (GTK_WIDGET (object)))
 
1485
        {
 
1486
            gtk_widget_show (GTK_WIDGET (new_parent));
 
1487
            GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
 
1488
        }
 
1489
        gdl_dock_object_thaw (new_parent);
 
1490
 
 
1491
        /* use extra docking parameter */
 
1492
        if (position != GDL_DOCK_CENTER && other_data &&
 
1493
            G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
1435
1494
        
1436
 
        g_object_set (G_OBJECT (new_parent),
1437
 
                      "position", g_value_get_uint (other_data),
1438
 
                      NULL);
1439
 
    } else if (splitpos > 0 && splitpos < available_space) {
1440
 
        g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
1441
 
    }
1442
 
    
1443
 
    GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
1444
 
    g_object_unref (object);
1445
 
 
1446
 
    gdl_dock_object_thaw (new_parent);
 
1495
            g_object_set (G_OBJECT (new_parent),
 
1496
                          "position", g_value_get_uint (other_data),
 
1497
                          NULL);
 
1498
        } else if (splitpos > 0 && splitpos < available_space) {
 
1499
            g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
 
1500
        }
 
1501
    
 
1502
        g_object_unref (object);
 
1503
    }
 
1504
    else
 
1505
    {
 
1506
        /* If the parent is already a DockNotebook, we don't need
 
1507
         to create a new one. */
 
1508
        gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor));
 
1509
    }
 
1510
    
 
1511
    requestor_parent = gdl_dock_object_get_parent_object (requestor);
 
1512
    if (GDL_IS_DOCK_NOTEBOOK (requestor_parent))
 
1513
    {
 
1514
        /* Activate the page we just added */
 
1515
        GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor));
 
1516
        gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child), 
 
1517
                               gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor)));
 
1518
    }
 
1519
                               
1447
1520
    if (parent)
1448
1521
        gdl_dock_object_thaw (parent);
1449
1522
 
1454
1527
gdl_dock_item_detach_menu (GtkWidget *widget,
1455
1528
                           GtkMenu   *menu)
1456
1529
{
1457
 
    GdlDockItem *item;
1458
 
   
1459
 
    item = GDL_DOCK_ITEM (widget);
 
1530
    GdlDockItem *item = GDL_DOCK_ITEM(widget);
 
1531
 
 
1532
    (void)menu;
 
1533
 
1460
1534
    item->_priv->menu = NULL;
1461
1535
}
1462
1536
 
1506
1580
{
1507
1581
    GdkCursor *fleur;
1508
1582
 
1509
 
    if (!GTK_WIDGET_REALIZED (item))
 
1583
    if (!gtk_widget_get_realized (GTK_WIDGET (item)))
1510
1584
        gtk_widget_realize (GTK_WIDGET (item));
1511
1585
    
1512
1586
    GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG);
1539
1613
                          GdkEventButton *event,
1540
1614
                          gpointer        data)
1541
1615
{
1542
 
    GdlDockItem *item;
1543
 
 
1544
 
    item = GDL_DOCK_ITEM (data);
1545
 
 
1546
 
    if (!GDL_DOCK_ITEM_NOT_LOCKED (item))
 
1616
    GdlDockItem *item = GDL_DOCK_ITEM(data);
 
1617
 
 
1618
    (void)widget;
 
1619
 
 
1620
    if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) {
1547
1621
        return;
 
1622
    }
1548
1623
 
1549
1624
    switch (event->button) {
1550
1625
    case 1:
1576
1651
gdl_dock_item_hide_cb (GtkWidget   *widget, 
1577
1652
                       GdlDockItem *item)
1578
1653
{
1579
 
    GdlDockMaster *master;
1580
 
    
 
1654
    (void)widget;
 
1655
 
1581
1656
    g_return_if_fail (item != NULL);
1582
1657
 
1583
 
    master = GDL_DOCK_OBJECT_GET_MASTER (item);
1584
1658
    gdl_dock_item_hide_item (item);
1585
1659
}
1586
1660
 
1590
1664
{
1591
1665
    g_return_if_fail (item != NULL);
1592
1666
 
 
1667
    (void)widget;
 
1668
 
1593
1669
    gdl_dock_item_lock (item);
1594
1670
}
1595
1671
 
1599
1675
{
1600
1676
    g_return_if_fail (item != NULL);
1601
1677
 
 
1678
    (void)widget;
 
1679
 
1602
1680
    gdl_dock_item_unlock (item);
1603
1681
}
1604
1682
 
1632
1710
{
1633
1711
    item->orientation = orientation;
1634
1712
    
1635
 
    if (GTK_WIDGET_DRAWABLE (item))
 
1713
    if (gtk_widget_is_drawable (GTK_WIDGET (item)))
1636
1714
        gtk_widget_queue_draw (GTK_WIDGET (item));
1637
1715
    gtk_widget_queue_resize (GTK_WIDGET (item));
1638
1716
}
1640
1718
 
1641
1719
/* ----- Public interface ----- */
1642
1720
 
 
1721
/**
 
1722
 * gdl_dock_item_new:
 
1723
 * @name: Unique name for identifying the dock object.
 
1724
 * @long_name: Human readable name for the dock object.
 
1725
 * @behavior: General behavior for the dock item (i.e. whether it can
 
1726
 *            float, if it's locked, etc.), as specified by
 
1727
 *            #GdlDockItemBehavior flags.
 
1728
 * 
 
1729
 * Creates a new dock item widget.
 
1730
 * Returns: The newly created dock item grip widget.
 
1731
 **/
1643
1732
GtkWidget *
1644
1733
gdl_dock_item_new (const gchar         *name,
1645
1734
                   const gchar         *long_name,
1657
1746
    return GTK_WIDGET (item);
1658
1747
}
1659
1748
 
 
1749
/**
 
1750
 * gdl_dock_item_new_with_stock:
 
1751
 * @name: Unique name for identifying the dock object.
 
1752
 * @long_name: Human readable name for the dock object.
 
1753
 * @stock_id: Stock icon for the dock object.
 
1754
 * @behavior: General behavior for the dock item (i.e. whether it can
 
1755
 *            float, if it's locked, etc.), as specified by
 
1756
 *            #GdlDockItemBehavior flags.
 
1757
 * 
 
1758
 * Creates a new dock item grip widget with a given stock id.
 
1759
 * Returns: The newly created dock item grip widget.
 
1760
 **/
1660
1761
GtkWidget *
1661
1762
gdl_dock_item_new_with_stock (const gchar         *name,
1662
1763
                              const gchar         *long_name,
1699
1800
}
1700
1801
 
1701
1802
/* convenient function (and to preserve source compat) */
 
1803
/**
 
1804
 * gdl_dock_item_dock_to:
 
1805
 * @item: The dock item that will be relocated to the dock position.
 
1806
 * @target: The dock item that will be used as the point of reference.
 
1807
 * @position: The position to dock #item, relative to #target.
 
1808
 * @docking_param: This value is unused, and will be ignored.
 
1809
 * 
 
1810
 * Relocates a dock item to a new location relative to another dock item.
 
1811
 **/
1702
1812
void
1703
1813
gdl_dock_item_dock_to (GdlDockItem      *item,
1704
1814
                       GdlDockItem      *target,
1705
1815
                       GdlDockPlacement  position,
1706
1816
                       gint              docking_param)
1707
1817
{
 
1818
    (void)docking_param;
 
1819
 
1708
1820
    g_return_if_fail (item != NULL);
1709
1821
    g_return_if_fail (item != target);
1710
1822
    g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING);
1734
1846
                              position, NULL);
1735
1847
}
1736
1848
 
 
1849
/**
 
1850
 * gdl_dock_item_set_orientation:
 
1851
 * @item: The dock item which will get it's orientation set.
 
1852
 * @orientation: The orientation to set the item to. If the orientation
 
1853
 * is set to #GTK_ORIENTATION_VERTICAL, the grip widget will be shown
 
1854
 * along the top of the edge of item (if it is not hidden). If the
 
1855
 * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip widget
 
1856
 * will be shown down the left edge of the item (even if the widget
 
1857
 * text direction is set to RTL).
 
1858
 * 
 
1859
 * This function sets the layout of the dock item.
 
1860
 **/
1737
1861
void
1738
1862
gdl_dock_item_set_orientation (GdlDockItem    *item,
1739
1863
                               GtkOrientation  orientation)
1758
1882
    }
1759
1883
}
1760
1884
 
 
1885
/**
 
1886
 * gdl_dock_item_get_tablabel:
 
1887
 * @item: The dock item from which to get the tab label widget.
 
1888
 * 
 
1889
 * Gets the current tab label widget. Note that this label widget is
 
1890
 * only visible when the "switcher-style" property of the #GdlDockMaster
 
1891
 * is set to #GDL_SWITCHER_STYLE_TABS
 
1892
 * 
 
1893
 * Returns: Returns the tab label widget.
 
1894
 **/
1761
1895
GtkWidget *
1762
1896
gdl_dock_item_get_tablabel (GdlDockItem *item)
1763
1897
{
1767
1901
    return item->_priv->tab_label;
1768
1902
}
1769
1903
 
 
1904
/**
 
1905
 * gdl_dock_item_set_tablabel:
 
1906
 * @item: The dock item which will get it's tab label widget set.
 
1907
 * @tablabel: The widget that will become the tab label.
 
1908
 * 
 
1909
 * Replaces the current tab label widget with another widget. Note that
 
1910
 * this label widget is only visible when the "switcher-style" property
 
1911
 * of the #GdlDockMaster is set to #GDL_SWITCHER_STYLE_TABS
 
1912
 **/
1770
1913
void
1771
1914
gdl_dock_item_set_tablabel (GdlDockItem *item,
1772
1915
                            GtkWidget   *tablabel)
1782
1925
                                                  NULL, item);
1783
1926
            g_object_set (item->_priv->tab_label, "item", NULL, NULL);
1784
1927
        }
1785
 
        gtk_widget_unref (item->_priv->tab_label);
 
1928
        g_object_unref (item->_priv->tab_label);
1786
1929
        item->_priv->tab_label = NULL;
1787
1930
    }
1788
1931
    
1789
1932
    if (tablabel) {
1790
 
        gtk_widget_ref (tablabel);
1791
 
        gtk_object_sink (GTK_OBJECT (tablabel));
 
1933
        g_object_ref_sink (G_OBJECT (tablabel));
1792
1934
        item->_priv->tab_label = tablabel;
1793
1935
        if (GDL_IS_DOCK_TABLABEL (tablabel)) {
1794
1936
            g_object_set (tablabel, "item", item, NULL);
1799
1941
    }
1800
1942
}
1801
1943
 
 
1944
/**
 
1945
 * gdl_dock_item_get_grip:
 
1946
 * @item: The dock item from which to to get the grip of.
 
1947
 * 
 
1948
 * This function returns the dock item's grip label widget.
 
1949
 * 
 
1950
 * Returns: Returns the current label widget.
 
1951
 **/
 
1952
GtkWidget *
 
1953
gdl_dock_item_get_grip(GdlDockItem *item)
 
1954
{
 
1955
    g_return_val_if_fail (item != NULL, NULL);
 
1956
    g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
 
1957
 
 
1958
    return item->_priv->grip;
 
1959
}
 
1960
 
 
1961
/**
 
1962
 * gdl_dock_item_hide_grip:
 
1963
 * @item: The dock item to hide the grip of.
 
1964
 * 
 
1965
 * This function hides the dock item's grip widget.
 
1966
 **/
1802
1967
void 
1803
1968
gdl_dock_item_hide_grip (GdlDockItem *item)
1804
1969
{
1810
1975
    g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" );
1811
1976
}
1812
1977
 
 
1978
/**
 
1979
 * gdl_dock_item_show_grip:
 
1980
 * @item: The dock item to show the grip of.
 
1981
 * 
 
1982
 * This function shows the dock item's grip widget.
 
1983
 **/
1813
1984
void
1814
1985
gdl_dock_item_show_grip (GdlDockItem *item)
1815
1986
{
1820
1991
    };
1821
1992
}
1822
1993
 
 
1994
/**
 
1995
 * gdl_dock_item_notify_selected:
 
1996
 * @item: the dock item to emit a selected signal on.
 
1997
 *
 
1998
 * This function emits the selected signal. It is to be used by #GdlSwitcher 
 
1999
 * to let clients know that this item has been switched to.
 
2000
 **/
 
2001
void
 
2002
gdl_dock_item_notify_selected (GdlDockItem *item)
 
2003
{
 
2004
    g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
 
2005
}
 
2006
 
1823
2007
/* convenient function (and to preserve source compat) */
 
2008
/**
 
2009
 * gdl_dock_item_bind:
 
2010
 * @item: The item to bind.
 
2011
 * @dock: The #GdlDock widget to bind it to. Note that this widget must
 
2012
 * be a type of #GdlDock.
 
2013
 * 
 
2014
 * Binds this dock item to a new dock master.
 
2015
 **/
1824
2016
void
1825
2017
gdl_dock_item_bind (GdlDockItem *item,
1826
2018
                    GtkWidget   *dock)
1833
2025
}
1834
2026
 
1835
2027
/* convenient function (and to preserve source compat) */
 
2028
/**
 
2029
 * gdl_dock_item_unbind:
 
2030
 * @item: The item to unbind.
 
2031
 * 
 
2032
 * Unbinds this dock item from it's dock master.
 
2033
 **/
1836
2034
void
1837
2035
gdl_dock_item_unbind (GdlDockItem *item)
1838
2036
{
1841
2039
    gdl_dock_object_unbind (GDL_DOCK_OBJECT (item));
1842
2040
}
1843
2041
 
 
2042
/**
 
2043
 * gdl_dock_item_hide_item:
 
2044
 * @item: The dock item to hide.
 
2045
 * 
 
2046
 * This function hides the dock item. When dock items are hidden they
 
2047
 * are completely removed from the layout.
 
2048
 * 
 
2049
 * The dock item close button causes the panel to be hidden.
 
2050
 **/
1844
2051
void
1845
2052
gdl_dock_item_hide_item (GdlDockItem *item)
1846
2053
{
1883
2090
                          "floatx", x,
1884
2091
                          "floaty", y,
1885
2092
                          NULL));
1886
 
        g_object_ref (item->_priv->ph);
1887
 
        gtk_object_sink (GTK_OBJECT (item->_priv->ph));
 
2093
        g_object_ref_sink (item->_priv->ph);
1888
2094
    }
1889
2095
    
1890
2096
    gdl_dock_object_freeze (GDL_DOCK_OBJECT (item));
1903
2109
    gdl_dock_object_thaw (GDL_DOCK_OBJECT (item));
1904
2110
}
1905
2111
 
 
2112
/**
 
2113
 * gdl_dock_item_iconify_item:
 
2114
 * @item: The dock item to iconify.
 
2115
 * 
 
2116
 * This function iconifies the dock item. When dock items are iconified
 
2117
 * they are hidden, and appear only as icons in dock bars.
 
2118
 * 
 
2119
 * The dock item iconify button causes the panel to be iconified.
 
2120
 **/
1906
2121
void
1907
2122
gdl_dock_item_iconify_item (GdlDockItem *item)
1908
2123
{
1912
2127
    gdl_dock_item_hide_item (item);
1913
2128
}
1914
2129
 
 
2130
/**
 
2131
 * gdl_dock_item_show_item:
 
2132
 * @item: The dock item to show.
 
2133
 * 
 
2134
 * This function shows the dock item. When dock items are shown, they
 
2135
 * are displayed in their normal layout position.
 
2136
 **/
1915
2137
void
1916
2138
gdl_dock_item_show_item (GdlDockItem *item)
1917
2139
{
1963
2185
    gtk_widget_show (GTK_WIDGET (item));
1964
2186
}
1965
2187
 
 
2188
/**
 
2189
 * gdl_dock_item_lock:
 
2190
 * @item: The dock item to lock.
 
2191
 * 
 
2192
 * This function locks the dock item. When locked the dock item cannot
 
2193
 * be dragged around and it doesn't show a grip.
 
2194
 **/
1966
2195
void
1967
2196
gdl_dock_item_lock (GdlDockItem *item)
1968
2197
{
1969
2198
    g_object_set (item, "locked", TRUE, NULL);
1970
2199
}
1971
2200
 
 
2201
/**
 
2202
 * gdl_dock_item_unlock:
 
2203
 * @item: The dock item to unlock.
 
2204
 * 
 
2205
 * This function unlocks the dock item. When unlocked the dock item can
 
2206
 * be dragged around and can show a grip.
 
2207
 **/
1972
2208
void
1973
2209
gdl_dock_item_unlock (GdlDockItem *item)
1974
2210
{
1975
2211
    g_object_set (item, "locked", FALSE, NULL);
1976
2212
}
1977
2213
 
 
2214
/**
 
2215
 * gdl_dock_item_set_default_position:
 
2216
 * @item: The dock item
 
2217
 * @reference: The GdlDockObject which is the default dock for @item 
 
2218
 *
 
2219
 * This method has only an effect when you add you dock_item with
 
2220
 * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign
 
2221
 * it a default position.
 
2222
 **/
1978
2223
void 
1979
2224
gdl_dock_item_set_default_position (GdlDockItem   *item,
1980
2225
                                    GdlDockObject *reference)
1988
2233
 
1989
2234
    if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) {
1990
2235
        if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
1991
 
            g_object_ref (reference);
1992
 
            gtk_object_sink (GTK_OBJECT (reference));
 
2236
            g_object_ref_sink (reference);
1993
2237
            item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference);
1994
2238
        } else {
1995
2239
            item->_priv->ph = GDL_DOCK_PLACEHOLDER (
1997
2241
                              "sticky", TRUE,
1998
2242
                              "host", reference,
1999
2243
                              NULL));
2000
 
            g_object_ref (item->_priv->ph);
2001
 
            gtk_object_sink (GTK_OBJECT (item->_priv->ph));
 
2244
            g_object_ref_sink (item->_priv->ph);
2002
2245
        }
2003
2246
    }
2004
2247
}
2005
2248
 
 
2249
/**
 
2250
 * gdl_dock_item_preferred_size:
 
2251
 * @item: The dock item to get the preferred size of.
 
2252
 * @req: A pointer to a #GtkRequisition into which the preferred size
 
2253
 * will be written.
 
2254
 * 
 
2255
 * Gets the preferred size of the dock item in pixels.
 
2256
 **/
2006
2257
void 
2007
2258
gdl_dock_item_preferred_size (GdlDockItem    *item,
2008
2259
                              GtkRequisition *req)
2030
2281
         item_child = GTK_CONTAINER (item_child)->focus_child) ;
2031
2282
    
2032
2283
    item_or_child_has_focus =
2033
 
        (GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (item)) || 
2034
 
         (GTK_IS_WIDGET (item_child) && GTK_WIDGET_HAS_FOCUS (item_child)));
 
2284
        (gtk_widget_has_focus (GTK_WIDGET (item)) || 
 
2285
         (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child)));
2035
2286
    
2036
2287
    return item_or_child_has_focus;
2037
2288
}