~ubuntu-branches/ubuntu/vivid/xfdesktop4/vivid-proposed

« back to all changes in this revision

Viewing changes to src/xfdesktop-icon-view.c

  • Committer: Package Import Robot
  • Author(s): Sean Davis
  • Date: 2014-09-15 06:24:44 UTC
  • mfrom: (1.5.12)
  • Revision ID: package-import@ubuntu.com-20140915062444-bbwf7f2smpusfgfb
Tags: 4.11.8-0ubuntu1
* New upstream development release
* Bugs fixed:
  - Infobar in desktop settings for <2 desktops (LP: #1365382)
  - Background color resets when starting settings (LP: #1313728)
  - Wallpaper spans multiple screens on reload (LP #1312577)

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
                                                gint x,
234
234
                                                gint y,
235
235
                                                guint time_);
236
 
static void xfdesktop_icon_view_drag_leave(GtkWidget *widget,
237
 
                                           GdkDragContext *context,
238
 
                                           guint time_);
239
236
static gboolean xfdesktop_icon_view_drag_drop(GtkWidget *widget,
240
237
                                              GdkDragContext *context,
241
238
                                              gint x,
409
406
    widget_class->expose_event = xfdesktop_icon_view_expose;
410
407
    widget_class->drag_begin = xfdesktop_icon_view_drag_begin;
411
408
    widget_class->drag_motion = xfdesktop_icon_view_drag_motion;
412
 
    widget_class->drag_leave = xfdesktop_icon_view_drag_leave;
413
409
    widget_class->drag_drop = xfdesktop_icon_view_drag_drop;
414
410
    widget_class->drag_data_get = xfdesktop_icon_view_drag_data_get;
415
411
    widget_class->drag_data_received = xfdesktop_icon_view_drag_data_received;
1401
1397
    *col = (x - icon_view->priv->xorigin - SCREEN_MARGIN) / CELL_SIZE;
1402
1398
}
1403
1399
 
1404
 
static inline void
1405
 
xfdesktop_icon_view_clear_drag_highlight(XfdesktopIconView *icon_view,
1406
 
                                         GdkDragContext *context)
1407
 
{
1408
 
    GdkRectangle *cell_highlight;
1409
 
 
1410
 
    cell_highlight = g_object_get_qdata(G_OBJECT(context),
1411
 
                                        xfdesktop_cell_highlight_quark);
1412
 
    if(!cell_highlight)
1413
 
        return;
1414
 
    
1415
 
    if(0 == cell_highlight->width || 0 == cell_highlight->height)
1416
 
        return;
1417
 
 
1418
 
    /* When dragging an icon a box is drawn to indicate the cell where the
1419
 
     * icon could be moved to if dropped. We need to clear that box but make
1420
 
     * the length of the lines slightly longer to clear all the pixels */
1421
 
    /* Left vertical line */
1422
 
    gtk_widget_queue_draw_area(GTK_WIDGET(icon_view),
1423
 
                               cell_highlight->x - 1,
1424
 
                               cell_highlight->y - 1,
1425
 
                               2,
1426
 
                               cell_highlight->height + 2);
1427
 
    /* Right vertical line */
1428
 
    gtk_widget_queue_draw_area(GTK_WIDGET(icon_view),
1429
 
                               cell_highlight->x + cell_highlight->width - 1,
1430
 
                               cell_highlight->y,
1431
 
                               2,
1432
 
                               cell_highlight->height + 2);
1433
 
    /* Top horizontal line */
1434
 
    gtk_widget_queue_draw_area(GTK_WIDGET(icon_view),
1435
 
                               cell_highlight->x,
1436
 
                               cell_highlight->y - 1,
1437
 
                               cell_highlight->width + 2,
1438
 
                               2);
1439
 
    /* Bottom horizontal line */
1440
 
    gtk_widget_queue_draw_area(GTK_WIDGET(icon_view),
1441
 
                               cell_highlight->x,
1442
 
                               cell_highlight->y + cell_highlight->height - 1,
1443
 
                               cell_highlight->width + 2,
1444
 
                               2);
1445
 
    
1446
 
    cell_highlight->width = cell_highlight->height = 0;
1447
 
}
1448
 
 
1449
 
static inline void
1450
 
xfdesktop_icon_view_draw_drag_highlight(XfdesktopIconView *icon_view,
1451
 
                                        GdkDragContext *context,
1452
 
                                        guint16 row,
1453
 
                                        guint16 col)
1454
 
{
1455
 
    GtkWidget *widget = GTK_WIDGET(icon_view);
1456
 
    cairo_t *cr;
1457
 
    GdkRectangle *cell_highlight;
1458
 
    gint newx, newy;
1459
 
    
1460
 
    newx = SCREEN_MARGIN + icon_view->priv->xorigin + col * CELL_SIZE;
1461
 
    newy = SCREEN_MARGIN + icon_view->priv->yorigin + row * CELL_SIZE;
1462
 
    
1463
 
    cell_highlight = g_object_get_qdata(G_OBJECT(context),
1464
 
                                        xfdesktop_cell_highlight_quark);
1465
 
    
1466
 
    if(cell_highlight) {
1467
 
        if(newx != cell_highlight->x || newy != cell_highlight->y)
1468
 
            xfdesktop_icon_view_clear_drag_highlight(icon_view, context);
1469
 
    } else {
1470
 
        cell_highlight = g_new0(GdkRectangle, 1);
1471
 
        g_object_set_qdata_full(G_OBJECT(context),
1472
 
                               xfdesktop_cell_highlight_quark,
1473
 
                               cell_highlight, (GDestroyNotify)g_free);
1474
 
    }
1475
 
    
1476
 
    cell_highlight->x = newx;
1477
 
    cell_highlight->y = newy;
1478
 
    cell_highlight->width = cell_highlight->height = CELL_SIZE;
1479
 
 
1480
 
    cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
1481
 
    gdk_cairo_set_source_color(cr, &gtk_widget_get_style(widget)->bg[GTK_STATE_SELECTED]);
1482
 
    cairo_set_line_width(cr, 0.5);
1483
 
    cairo_rectangle(cr, newx, newy, CELL_SIZE, CELL_SIZE);
1484
 
    cairo_stroke(cr);
1485
 
    cairo_destroy(cr);
1486
 
}
1487
 
 
1488
1400
static gboolean
1489
1401
xfdesktop_icon_view_drag_motion(GtkWidget *widget,
1490
1402
                                GdkDragContext *context,
1548
1460
                if(xfdesktop_icon_get_position(sel_icon, &sel_row, &sel_col)
1549
1461
                   && sel_row == hover_row && sel_col == hover_col)
1550
1462
                {
1551
 
                    xfdesktop_icon_view_clear_drag_highlight(icon_view, context);
1552
1463
                    return FALSE;
1553
1464
                }
1554
1465
            }
1595
1506
    return TRUE;
1596
1507
}
1597
1508
 
1598
 
static void
1599
 
xfdesktop_icon_view_drag_leave(GtkWidget *widget,
1600
 
                               GdkDragContext *context,
1601
 
                               guint time_)
1602
 
{
1603
 
    xfdesktop_icon_view_clear_drag_highlight(XFDESKTOP_ICON_VIEW(widget),
1604
 
                                             context);
1605
 
}
1606
 
 
1607
 
 
1608
1509
static gboolean
1609
1510
xfdesktop_icon_view_drag_drop(GtkWidget *widget,
1610
1511
                              GdkDragContext *context,
1778
1679
                                                                 context, data,
1779
1680
                                                                 info);
1780
1681
 
1781
 
        if(action == 0)
1782
 
            xfdesktop_icon_view_clear_drag_highlight(icon_view, context);
1783
 
        else
1784
 
            xfdesktop_icon_view_draw_drag_highlight(icon_view, context,
1785
 
                                                    icon_view->priv->hover_row,
1786
 
                                                    icon_view->priv->hover_col);
1787
1682
        gdk_drag_status(context, action, time_);
1788
1683
    }
1789
1684
}