pidgin/gtk3compat.h

changeset 37989
018063ec9d2e
parent 36244
2a4179d0177d
child 37990
710f725725a8
equal deleted inserted replaced
37978:266009ac8af6 37989:018063ec9d2e
104 } 104 }
105 105
106 #endif /* 3.4.0 and gtk_color_chooser_ */ 106 #endif /* 3.4.0 and gtk_color_chooser_ */
107 107
108 108
109 #if GTK_CHECK_VERSION(3,0,0)
110
111 static inline GtkWidget *
112 gtk_grid_table_new(guint rows, guint columns)
113 {
114 return gtk_grid_new();
115 }
116
117 static inline void
118 gtk_grid_attach_defaults(GtkGrid *grid, GtkWidget *child, gint left, gint top,
119 gint width, gint height)
120 {
121 gtk_grid_attach(grid, child, left, top, width, height);
122 gtk_widget_set_hexpand(child, TRUE);
123 gtk_widget_set_vexpand(child, TRUE);
124 }
125
126 static inline void
127 gtk_grid_attach_full(GtkGrid *grid, GtkWidget *child, guint left, guint top,
128 guint width, guint height, GtkAttachOptions xoptions,
129 GtkAttachOptions yoptions, guint xpadding, guint ypadding)
130 {
131 gtk_grid_attach(grid, child, left, top, width, height);
132
133 if (xoptions & GTK_EXPAND)
134 gtk_widget_set_hexpand(child, TRUE);
135 if (!(xoptions & GTK_FILL))
136 gtk_widget_set_halign(child, GTK_ALIGN_CENTER);
137 gtk_widget_set_margin_left(child, xpadding);
138 gtk_widget_set_margin_right(child, xpadding);
139
140 if (yoptions & GTK_EXPAND)
141 gtk_widget_set_vexpand(child, TRUE);
142 if (!(yoptions & GTK_FILL))
143 gtk_widget_set_valign(child, GTK_ALIGN_CENTER);
144 gtk_widget_set_margin_top(child, ypadding);
145 gtk_widget_set_margin_bottom(child, ypadding);
146 }
147
148 #else /* 3.0.0 and gtk_grid_ */
149
150 #define GTK_GRID GTK_TABLE
151 #define GtkGrid GtkTable
152
153 static inline GtkWidget *
154 gtk_grid_table_new(guint rows, guint columns)
155 {
156 return gtk_table_new(rows, columns, FALSE);
157 }
158
159 static inline void
160 gtk_grid_set_row_spacing(GtkGrid *grid, guint spacing)
161 {
162 gtk_table_set_row_spacings(grid, spacing);
163 }
164
165 static inline void
166 gtk_grid_set_column_spacing(GtkGrid *grid, guint spacing)
167 {
168 gtk_table_set_col_spacings(grid, spacing);
169 }
170
171 static inline void
172 gtk_grid_attach_defaults(GtkGrid *grid, GtkWidget *child, gint left, gint top,
173 gint width, gint height)
174 {
175 gtk_table_attach_defaults(grid, child, left, left + width,
176 top, top + height);
177 }
178
179 static inline void
180 gtk_grid_attach_full(GtkGrid *grid, GtkWidget *child, guint left, guint top,
181 guint width, guint height, GtkAttachOptions xoptions,
182 GtkAttachOptions yoptions, guint xpadding, guint ypadding)
183 {
184 gtk_table_attach(grid, child, left, left + width, top, top + height,
185 xoptions, yoptions, xpadding, ypadding);
186 }
187
188 #endif /* 3.0.0 and gtk_grid_ */
189
190
191 #if !GTK_CHECK_VERSION(3,2,0) 109 #if !GTK_CHECK_VERSION(3,2,0)
192 110
193 #define GTK_FONT_CHOOSER GTK_FONT_SELECTION_DIALOG 111 #define GTK_FONT_CHOOSER GTK_FONT_SELECTION_DIALOG
194 #define gtk_font_chooser_get_font gtk_font_selection_dialog_get_font_name 112 #define gtk_font_chooser_get_font gtk_font_selection_dialog_get_font_name
195 #define gtk_font_chooser_set_font gtk_font_selection_dialog_set_font_name 113 #define gtk_font_chooser_set_font gtk_font_selection_dialog_set_font_name
198 GtkWindow *parent) 116 GtkWindow *parent)
199 { 117 {
200 return gtk_font_selection_dialog_new(title); 118 return gtk_font_selection_dialog_new(title);
201 } 119 }
202 120
203 #if !GTK_CHECK_VERSION(3,0,0)
204
205 #define gdk_x11_window_get_xid GDK_WINDOW_XWINDOW
206 #define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,z)
207
208 #ifdef GDK_WINDOWING_X11
209 #define GDK_IS_X11_WINDOW(window) TRUE
210 #endif
211 #ifdef GDK_WINDOWING_WIN32
212 #define GDK_IS_WIN32_WINDOW(window) TRUE
213 #endif
214 #ifdef GDK_WINDOWING_QUARTZ
215 #define GDK_IS_QUARTZ_WINDOW(window) TRUE
216 #endif
217
218 static inline GdkPixbuf *
219 gdk_pixbuf_get_from_surface(cairo_surface_t *surface, gint src_x, gint src_y,
220 gint width, gint height)
221 {
222 GdkPixmap *pixmap;
223 GdkPixbuf *pixbuf;
224 cairo_t *cr;
225
226 pixmap = gdk_pixmap_new(NULL, width, height, 24);
227
228 cr = gdk_cairo_create(pixmap);
229 cairo_set_source_surface(cr, surface, -src_x, -src_y);
230 cairo_paint(cr);
231 cairo_destroy(cr);
232
233 pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap,
234 gdk_drawable_get_colormap(pixmap), 0, 0, 0, 0, width, height);
235
236 g_object_unref(pixmap);
237
238 return pixbuf;
239 }
240
241 static inline GdkPixbuf *
242 gdk_pixbuf_get_from_window(GdkWindow *window, gint src_x, gint src_y,
243 gint width, gint height)
244 {
245 return gdk_pixbuf_get_from_drawable(NULL, window, NULL,
246 src_x, src_y, 0, 0, width, height);
247 }
248
249 static inline GtkWidget *
250 gtk_box_new(GtkOrientation orientation, gint spacing)
251 {
252 g_return_val_if_fail(orientation == GTK_ORIENTATION_HORIZONTAL ||
253 orientation == GTK_ORIENTATION_VERTICAL, NULL);
254
255 if (orientation == GTK_ORIENTATION_HORIZONTAL)
256 return gtk_hbox_new(FALSE, spacing);
257 else /* GTK_ORIENTATION_VERTICAL */
258 return gtk_vbox_new(FALSE, spacing);
259 }
260
261 static inline GtkWidget *
262 gtk_separator_new(GtkOrientation orientation)
263 {
264 g_return_val_if_fail(orientation == GTK_ORIENTATION_HORIZONTAL ||
265 orientation == GTK_ORIENTATION_VERTICAL, NULL);
266
267 if (orientation == GTK_ORIENTATION_HORIZONTAL)
268 return gtk_hseparator_new();
269 else /* GTK_ORIENTATION_VERTICAL */
270 return gtk_vseparator_new();
271 }
272
273 static inline GtkWidget *
274 gtk_button_box_new(GtkOrientation orientation)
275 {
276 g_return_val_if_fail(orientation == GTK_ORIENTATION_HORIZONTAL ||
277 orientation == GTK_ORIENTATION_VERTICAL, NULL);
278
279 if (orientation == GTK_ORIENTATION_HORIZONTAL)
280 return gtk_hbutton_box_new();
281 else /* GTK_ORIENTATION_VERTICAL */
282 return gtk_vbutton_box_new();
283 }
284
285 static inline GtkWidget *
286 gtk_paned_new(GtkOrientation orientation)
287 {
288 g_return_val_if_fail(orientation == GTK_ORIENTATION_HORIZONTAL ||
289 orientation == GTK_ORIENTATION_VERTICAL, NULL);
290
291 if (orientation == GTK_ORIENTATION_HORIZONTAL)
292 return gtk_hpaned_new();
293 else /* GTK_ORIENTATION_VERTICAL */
294 return gtk_vpaned_new();
295 }
296
297 static inline GtkWidget *
298 gtk_scale_new_with_range(GtkOrientation orientation, gdouble min, gdouble max,
299 gdouble step)
300 {
301 g_return_val_if_fail(orientation == GTK_ORIENTATION_HORIZONTAL ||
302 orientation == GTK_ORIENTATION_VERTICAL, NULL);
303
304 if (orientation == GTK_ORIENTATION_HORIZONTAL)
305 return gtk_hscale_new_with_range(min, max, step);
306 else /* GTK_ORIENTATION_VERTICAL */
307 return gtk_vscale_new_with_range(min, max, step);
308 }
309
310 #if !GTK_CHECK_VERSION(2,24,0)
311
312 #define gdk_x11_set_sm_client_id gdk_set_sm_client_id
313 #define gdk_window_get_display gdk_drawable_get_display
314 #define GtkComboBoxText GtkComboBox
315 #define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
316 #define gtk_combo_box_text_new gtk_combo_box_new_text
317 #define gtk_combo_box_text_new_with_entry gtk_combo_box_entry_new_text
318 #define gtk_combo_box_text_append_text gtk_combo_box_append_text
319 #define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
320 #define gtk_combo_box_text_remove gtk_combo_box_remove_text
321
322 static inline gint gdk_window_get_width(GdkWindow *x)
323 {
324 gint w;
325 gdk_drawable_get_size(GDK_DRAWABLE(x), &w, NULL);
326 return w;
327 }
328
329 static inline gint gdk_window_get_height(GdkWindow *x)
330 {
331 gint h;
332 gdk_drawable_get_size(GDK_DRAWABLE(x), NULL, &h);
333 return h;
334 }
335
336 #if !GTK_CHECK_VERSION(2,22,0)
337
338 #define gdk_drag_context_get_actions(x) (x)->action
339 #define gdk_drag_context_get_suggested_action(x) (x)->suggested_action
340 #define gtk_text_view_get_vadjustment(x) (x)->vadjustment
341 #define gtk_font_selection_dialog_get_font_selection(x) (x)->fontsel
342
343 #if !GTK_CHECK_VERSION(2,20,0)
344
345 #define gtk_widget_get_mapped GTK_WIDGET_MAPPED
346 #define gtk_widget_set_mapped(x,y) do { \
347 if (y) \
348 GTK_WIDGET_SET_FLAGS(x, GTK_MAPPED); \
349 else \
350 GTK_WIDGET_UNSET_FLAGS(x, GTK_MAPPED); \
351 } while(0)
352 #define gtk_widget_get_realized GTK_WIDGET_REALIZED
353 #define gtk_widget_set_realized(x,y) do { \
354 if (y) \
355 GTK_WIDGET_SET_FLAGS(x, GTK_REALIZED); \
356 else \
357 GTK_WIDGET_UNSET_FLAGS(x, GTK_REALIZED); \
358 } while(0)
359
360 #endif /* 2.20.0 */
361
362 #endif /* 2.22.0 */
363
364 #endif /* 2.24.0 */
365
366 #endif /* 3.0.0 */
367
368 #endif /* 3.2.0 */ 121 #endif /* 3.2.0 */
369 122
370 #endif /* _PIDGINGTK3COMPAT_H_ */ 123 #endif /* _PIDGINGTK3COMPAT_H_ */
371 124

mercurial