~vcs-imports-ii/gnubg/trunk

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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
 * gtklocdefs.c
 *
 * by Michael Petch <mpetch@capp-sysware.com>, 2011.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 3 or later of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: gtklocdefs.c,v 1.12 2016/04/30 14:12:39 plm Exp $
 */


#include "config.h"
#include "gtkgame.h"
#include "gtklocdefs.h"

#if (USE_GTK)
#include <gtk/gtk.h>

#if ! GTK_CHECK_VERSION(2,22,0)
gint
gdk_visual_get_depth(GdkVisual * visual)
{
    return visual->depth;
}
#endif

#if ! GTK_CHECK_VERSION(2,18,0)
void
gtk_widget_get_allocation(GtkWidget * widget, GtkAllocation * allocation)
{
    *allocation = widget->allocation;
}

void
gtk_widget_set_allocation(GtkWidget * widget, const GtkAllocation * allocation)
{
    widget->allocation = *allocation;
}

void
gtk_cell_renderer_get_alignment(GtkCellRenderer * cell, gfloat * xalign, gfloat * yalign)
{
    *xalign = cell->xalign;
    *yalign = cell->yalign;
}

void
gtk_cell_renderer_set_padding(GtkCellRenderer * cell, gint xpad, gint ypad)
{
    cell->xpad = xpad;
    cell->ypad = ypad;
}
#endif

#if ! GTK_CHECK_VERSION(2,14,0)

GtkWidget *
gtk_dialog_get_action_area(GtkDialog * dialog)
{
    return (dialog->action_area);
}

GtkWidget *
gtk_dialog_get_content_area(GtkDialog * dialog)
{
    return (dialog->vbox);
}

GdkWindow *
gtk_widget_get_window(GtkWidget * widget)
{
    return (widget->window);
}

gdouble
gtk_adjustment_get_upper(GtkAdjustment * adjustment)
{
    return adjustment->upper;
}

void
gtk_adjustment_set_upper(GtkAdjustment * adjustment, gdouble upper)
{
    adjustment->upper = upper;
}

guchar *
gtk_selection_data_get_data(GtkSelectionData * data)
{
    return data->data;
}

#endif

#if ! GTK_CHECK_VERSION(2,12,0)
GtkTooltips *ptt;
#endif

extern GtkWidget *
get_statusbar_label(GtkStatusbar * statusbar)
{
#if GTK_CHECK_VERSION(2,20,0)
    return
        GTK_WIDGET(gtk_container_get_children
                   (GTK_CONTAINER(gtk_statusbar_get_message_area(GTK_STATUSBAR(statusbar))))->data);
#else
    return GTK_WIDGET(statusbar->label);
#endif
}


extern void
toolbar_set_orientation(GtkToolbar * toolbar, GtkOrientation orientation)
{
#if GTK_CHECK_VERSION(2,16,0)
    gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), orientation);
#else
    gtk_toolbar_set_orientation(toolbar, orientation);
#endif
}

#ifndef USE_GRESOURCE
#include <string.h>
#include "gnubg-stock-pixbufs.h"

static const struct {
    const char *resource_path;
    gconstpointer inline_data;
} resource_to_inline[] = {
    {"/org/gnubg/16x16/actions/ok_16.png", ok_16},
    {"/org/gnubg/24x24/actions/ok_24.png", ok_24},
    {"/org/gnubg/24x24/actions/anti_clockwise_24.png", anti_clockwise_24},
    {"/org/gnubg/24x24/actions/clockwise_24.png", clockwise_24},
    {"/org/gnubg/16x16/actions/double_16.png", double_16},
    {"/org/gnubg/24x24/actions/double_24.png", double_24},
    {"/org/gnubg/16x16/actions/runit_16.png", runit_16},
    {"/org/gnubg/24x24/actions/runit_24.png", runit_24},
    {"/org/gnubg/16x16/actions/go_next_cmarked_16.png", go_next_cmarked_16},
    {"/org/gnubg/24x24/actions/go_next_cmarked_24.png", go_next_cmarked_24},
    {"/org/gnubg/16x16/actions/go_next_game_16.png", go_next_game_16},
    {"/org/gnubg/24x24/actions/go_next_game_24.png", go_next_game_24},
    {"/org/gnubg/16x16/actions/go_next_16.png", go_next_16},
    {"/org/gnubg/24x24/actions/go_next_24.png", go_next_24},
    {"/org/gnubg/16x16/actions/go_next_marked_16.png", go_next_marked_16},
    {"/org/gnubg/24x24/actions/go_next_marked_24.png", go_next_marked_24},
    {"/org/gnubg/16x16/actions/go_prev_cmarked_16.png", go_prev_cmarked_16},
    {"/org/gnubg/24x24/actions/go_prev_cmarked_24.png", go_prev_cmarked_24},
    {"/org/gnubg/16x16/actions/go_prev_game_16.png", go_prev_game_16},
    {"/org/gnubg/24x24/actions/go_prev_game_24.png", go_prev_game_24},
    {"/org/gnubg/16x16/actions/go_prev_16.png", go_prev_16},
    {"/org/gnubg/24x24/actions/go_prev_24.png", go_prev_24},
    {"/org/gnubg/16x16/actions/go_prev_marked_16.png", go_prev_marked_16},
    {"/org/gnubg/24x24/actions/go_prev_marked_24.png", go_prev_marked_24},
    {"/org/gnubg/16x16/actions/hint_16.png", hint_16},
    {"/org/gnubg/24x24/actions/hint_24.png", hint_24},
    {"/org/gnubg/24x24/actions/new0_24.png", new0_24},
    {"/org/gnubg/24x24/actions/new11_24.png", new11_24},
    {"/org/gnubg/24x24/actions/new13_24.png", new13_24},
    {"/org/gnubg/24x24/actions/new15_24.png", new15_24},
    {"/org/gnubg/24x24/actions/new17_24.png", new17_24},
    {"/org/gnubg/24x24/actions/new1_24.png", new1_24},
    {"/org/gnubg/24x24/actions/new3_24.png", new3_24},
    {"/org/gnubg/24x24/actions/new5_24.png", new5_24},
    {"/org/gnubg/24x24/actions/new7_24.png", new7_24},
    {"/org/gnubg/24x24/actions/new9_24.png", new9_24},
    {"/org/gnubg/16x16/actions/cancel_16.png", cancel_16},
    {"/org/gnubg/24x24/actions/cancel_24.png", cancel_24},
    {"/org/gnubg/16x16/actions/resign_16.png", resign_16},
    {"/org/gnubg/24x24/actions/resign_24.png", resign_24},
    {"/org/gnubg/24x24/actions/resignsb_24.png", resignsb_24},
    {"/org/gnubg/24x24/actions/resignsg_24.png", resignsg_24},
    {"/org/gnubg/24x24/actions/resignsn_24.png", resignsn_24}
};

GdkPixbuf *
gdk_pixbuf_new_from_resource(const char *resource_path, GError **error)
{
    guint i;
    GdkPixbuf *pixbuf = NULL;

    for (i = 0; i < G_N_ELEMENTS(resource_to_inline) && !pixbuf; i++) {
        if (strcmp(resource_path, resource_to_inline[i].resource_path) == 0) {
            const guchar *inline_data = resource_to_inline[i].inline_data;
            pixbuf = gdk_pixbuf_new_from_inline(-1, inline_data, FALSE, error);
        }
    }

    return pixbuf;
}
#endif

#endif