From 0d2a6cd72f2297744be04ff4429ed4e693b2674d Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 20 Nov 2011 22:14:30 +0100 Subject: [PATCH] Sort out boxes and scrollables with GTK+ 3.2 There is only GtkBox, neither GtkHBox nor GtkVBox. Constructors and defaults have changed, we need to set "orientation" for vertical boxes. The panel takes care of its pages, and the view of itself. gtk_container_add on GtkBox is different to GtkVBox so we must use gtk_box_pack_start. GtkScrollable exists as a proper interface now. --- katze/gtk3-compat.h | 6 ++++++ midori/midori-panel.c | 14 ++++++++++++-- midori/midori-view.c | 6 +++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/katze/gtk3-compat.h b/katze/gtk3-compat.h index 70a811f7..c1a2dd5f 100644 --- a/katze/gtk3-compat.h +++ b/katze/gtk3-compat.h @@ -10,9 +10,15 @@ G_BEGIN_DECLS #define GTK_TYPE_VBOX GTK_TYPE_BOX #define GtkVBox GtkBox #define GtkVBoxClass GtkBoxClass + #define gtk_vbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \ + "homogeneous", hmg, "spacing", spc, \ + "orientation", GTK_ORIENTATION_VERTICAL, NULL) #define GTK_TYPE_HBOX GTK_TYPE_BOX #define GtkHBox GtkBox #define GtkHBoxClass GtkBoxClass + #define gtk_hbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \ + "homogeneous", hmg, "spacing", spc, \ + "orientation", GTK_ORIENTATION_HORIZONTAL, NULL) #endif #if !GLIB_CHECK_VERSION (2, 32, 0) diff --git a/midori/midori-panel.c b/midori/midori-panel.c index c1457790..ffe110e6 100644 --- a/midori/midori-panel.c +++ b/midori/midori-panel.c @@ -685,7 +685,9 @@ midori_panel_append_page (MidoriPanel* panel, MidoriViewable* viewable) { GtkWidget* scrolled; + #if !GTK_CHECK_VERSION (3, 0, 0) GObjectClass* gobject_class; + #endif GtkWidget* widget; GtkWidget* toolbar; GtkToolItem* toolitem; @@ -696,6 +698,12 @@ midori_panel_append_page (MidoriPanel* panel, g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1); g_return_val_if_fail (MIDORI_IS_VIEWABLE (viewable), -1); + #if GTK_CHECK_VERSION (3, 2, 0) + if (GTK_IS_ORIENTABLE (viewable)) + gtk_orientable_set_orientation (GTK_ORIENTABLE (viewable), + GTK_ORIENTATION_VERTICAL); + #endif + if (GTK_IS_SCROLLED_WINDOW (viewable)) scrolled = (GtkWidget*)viewable; else @@ -706,12 +714,14 @@ midori_panel_append_page (MidoriPanel* panel, GTK_POLICY_AUTOMATIC); gtk_widget_set_can_focus (scrolled, TRUE); gtk_widget_show (scrolled); + #if GTK_CHECK_VERSION (3, 0, 0) + if (GTK_IS_SCROLLABLE (viewable)) + #else gobject_class = G_OBJECT_GET_CLASS (viewable); -#if !GTK_CHECK_VERSION(3,0,0) /* TODO */ if (GTK_WIDGET_CLASS (gobject_class)->set_scroll_adjustments_signal) + #endif widget = (GtkWidget*)viewable; else -#endif { widget = gtk_viewport_new (NULL, NULL); gtk_widget_show (widget); diff --git a/midori/midori-view.c b/midori/midori-view.c index c4bae490..5cdeb4dd 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -3048,12 +3048,16 @@ midori_view_init (MidoriView* view) view->scrollh = view->scrollv = -2; view->back_forward_set = FALSE; + #if GTK_CHECK_VERSION (3, 2, 0) + gtk_orientable_set_orientation (GTK_ORIENTABLE (view), GTK_ORIENTATION_VERTICAL); + #endif + view->web_view = NULL; /* Adjustments are not created initially, but overwritten later */ view->scrolled_window = katze_scrolled_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window), GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (view), view->scrolled_window); + gtk_box_pack_start (GTK_BOX (view), view->scrolled_window, TRUE, TRUE, 0); g_signal_connect (view->item, "meta-data-changed", G_CALLBACK (midori_view_item_meta_data_changed), view); -- 2.39.5