1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/* virt-p2v
* Copyright (C) 2009-2019 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Backwards compatibility for some deprecated functions in Gtk 3. */
#if !GTK_CHECK_VERSION(3,2,0) /* gtk < 3.2 */
static gboolean
gdk_event_get_button (const GdkEvent *event, guint *button)
{
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
*button = ((const GdkEventButton *) event)->button;
return TRUE;
}
#endif
#if GTK_CHECK_VERSION(3,2,0) /* gtk >= 3.2 */
#define hbox_new(box, homogeneous, spacing) \
do { \
(box) = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, spacing); \
if (homogeneous) \
gtk_box_set_homogeneous (GTK_BOX (box), TRUE); \
} while (0)
#define vbox_new(box, homogeneous, spacing) \
do { \
(box) = gtk_box_new (GTK_ORIENTATION_VERTICAL, spacing); \
if (homogeneous) \
gtk_box_set_homogeneous (GTK_BOX (box), TRUE); \
} while (0)
#else /* gtk < 3.2 */
#define hbox_new(box, homogeneous, spacing) \
(box) = gtk_hbox_new ((homogeneous), (spacing))
#define vbox_new(box, homogeneous, spacing) \
(box) = gtk_vbox_new ((homogeneous), (spacing))
#endif
#if !GTK_CHECK_VERSION(3,4,0) /* gtk < 3.4 */
/* Gtk < 3.4 entirely lacked gtk_about_dialog_add_credit_section. */
#define gtk_about_dialog_add_credit_section(d,k,v) do {} while (0)
#endif
#if GTK_CHECK_VERSION(3,4,0) /* gtk >= 3.4 */
/* GtkGrid is sufficiently similar to GtkTable that we can just
* redefine these functions.
*/
#define table_new(grid, rows, columns) \
(grid) = gtk_grid_new ()
#define table_attach(grid, child, left, right, top, bottom, xoptions, yoptions, xpadding, ypadding) \
do { \
if (((xoptions) & GTK_EXPAND) != 0) \
gtk_widget_set_hexpand ((child), TRUE); \
if (((xoptions) & GTK_FILL) != 0) \
gtk_widget_set_halign ((child), GTK_ALIGN_FILL); \
if (((yoptions) & GTK_EXPAND) != 0) \
gtk_widget_set_vexpand ((child), TRUE); \
if (((yoptions) & GTK_FILL) != 0) \
gtk_widget_set_valign ((child), GTK_ALIGN_FILL); \
set_padding ((child), (xpadding), (ypadding)); \
gtk_grid_attach (GTK_GRID (grid), (child), \
(left), (top), (right)-(left), (bottom)-(top)); \
} while (0)
#else
#define table_new(table, rows, columns) \
(table) = gtk_table_new ((rows), (columns), FALSE)
#define table_attach(table, child, left, right,top, bottom, xoptions, yoptions, xpadding, ypadding) \
gtk_table_attach (GTK_TABLE (table), (child), \
(left), (right), (top), (bottom), \
(xoptions), (yoptions), (xpadding), (ypadding))
#endif
#if GTK_CHECK_VERSION(3,8,0) /* gtk >= 3.8 */
#define scrolled_window_add_with_viewport(container, child) \
gtk_container_add (GTK_CONTAINER (container), child)
#else
#define scrolled_window_add_with_viewport(container, child) \
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (container), child)
#endif
#if !GTK_CHECK_VERSION(3,10,0) /* gtk < 3.10 */
#define gdk_event_get_event_type(event) ((event)->type)
#endif
#if GTK_CHECK_VERSION(3,10,0) /* gtk >= 3.10 */
#undef GTK_STOCK_DIALOG_WARNING
#define GTK_STOCK_DIALOG_WARNING "dialog-warning"
#define gtk_image_new_from_stock gtk_image_new_from_icon_name
#endif
#if GTK_CHECK_VERSION(3,14,0) /* gtk >= 3.14 */
#define set_padding(widget, xpad, ypad) \
do { \
if ((xpad) != 0) { \
gtk_widget_set_margin_start ((widget), (xpad)); \
gtk_widget_set_margin_end ((widget), (xpad)); \
} \
if ((ypad) != 0) { \
gtk_widget_set_margin_top ((widget), (ypad)); \
gtk_widget_set_margin_bottom ((widget), (ypad)); \
} \
} while (0)
#define set_alignment(widget, xalign, yalign) \
do { \
if ((xalign) == 0.) \
gtk_widget_set_halign ((widget), GTK_ALIGN_START); \
else if ((xalign) == 1.) \
gtk_widget_set_halign ((widget), GTK_ALIGN_END); \
else \
gtk_widget_set_halign ((widget), GTK_ALIGN_CENTER); \
if ((yalign) == 0.) \
gtk_widget_set_valign ((widget), GTK_ALIGN_START); \
else if ((xalign) == 1.) \
gtk_widget_set_valign ((widget), GTK_ALIGN_END); \
else \
gtk_widget_set_valign ((widget), GTK_ALIGN_CENTER); \
} while (0)
#else /* gtk < 3.14 */
#define set_padding(widget, xpad, ypad) \
gtk_misc_set_padding(GTK_MISC(widget),(xpad),(ypad))
#define set_alignment(widget, xalign, yalign) \
gtk_misc_set_alignment(GTK_MISC(widget),(xalign),(yalign))
#endif
|