From 91522bd0b3cff351252ebbdbd23e1a2a02688394 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 13 Nov 2013 18:07:42 +0100 Subject: Fix GTK3 deprecated functions... --- examples/rcc-gtk-config.c | 16 +++++++++++++++- ui/gtk.c | 13 +++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/examples/rcc-gtk-config.c b/examples/rcc-gtk-config.c index 41c4a5c..aa5359c 100644 --- a/examples/rcc-gtk-config.c +++ b/examples/rcc-gtk-config.c @@ -115,10 +115,20 @@ int main (int argc, char *argv[]) box = rccUiGetPage(uictx, NULL); gtk_widget_show (box); -// gtk_container_add (GTK_CONTAINER (window1), box); + +#if ((GTK_MAJOR_VERSION < 3) || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 7) || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 7 && GTK_MICRO_VERSION < 8)) gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), box); +#else + gtk_container_add (GTK_CONTAINER (scroll), box); +#endif +#if GTK_MAJOR_VERSION > 2 + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE); +#else /* GTK_MAJOR_VERSION < 3 */ hbox = gtk_hbox_new (TRUE, 0); +#endif /* GTK_MAJOR_VERSION */ + gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0); @@ -142,7 +152,11 @@ int main (int argc, char *argv[]) #endif /* GTK_MAJOR_VERSION */ gtk_box_pack_start (GTK_BOX (hbox), save, FALSE, FALSE, 0); +#if GTK_MAJOR_VERSION > 2 + gtk_widget_get_preferred_size (box, NULL, &size); +#else /* GTK_MAJOR_VERSION < 3 */ gtk_widget_size_request(box, &size); +#endif /* GTK_MAJOR_VERSION */ hints.min_width = size.width; hints.min_height = size.height; diff --git a/ui/gtk.c b/ui/gtk.c index d35c513..5056510 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -366,7 +366,12 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) { GtkWidget *hbox, *label; +#if GTK_MAJOR_VERSION > 2 + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BOX_SPACING); +#else /* GTK_MAJOR_VERSION < 3 */ hbox = gtk_hbox_new(FALSE, BOX_SPACING); +#endif /* GTK_MAJOR_VERSION */ + gtk_container_border_width(GTK_CONTAINER(hbox), BOX_BORDER); if ((ctx->type != RCC_UI_MENU_OPTION)||(rccUiMenuGetRangeType(ctx) != RCC_OPTION_RANGE_TYPE_BOOLEAN)) { @@ -388,7 +393,11 @@ rcc_ui_frame rccUiFrameCreate(rcc_ui_frame_context ctx, const char *title) { frame = gtk_frame_new(title?title:""); gtk_container_border_width(GTK_CONTAINER(frame), FRAME_BORDER); +#if GTK_MAJOR_VERSION > 2 + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, FRAME_SPACING); +#else /* GTK_MAJOR_VERSION < 3 */ box = gtk_vbox_new(FALSE, FRAME_SPACING); +#endif /* GTK_MAJOR_VERSION */ gtk_widget_show(box); gtk_container_add(GTK_CONTAINER(frame), box); @@ -412,7 +421,11 @@ int rccUiFrameAdd(rcc_ui_frame_context ctx, rcc_ui_box box) { rcc_ui_page rccUiPageCreate(rcc_ui_context ctx, const char *title) { GtkWidget *vbox; +#if GTK_MAJOR_VERSION > 2 + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PAGE_SPACING); +#else /* GTK_MAJOR_VERSION < 3 */ vbox = gtk_vbox_new(FALSE, PAGE_SPACING); +#endif /* GTK_MAJOR_VERSION */ return (rcc_ui_page)vbox; } -- cgit v1.2.3