[Xfce4-commits] <midori:master> Change MidoriView into a subclass of GtkVBox
Christian Dywan
noreply at xfce.org
Wed Mar 31 00:18:03 CEST 2010
Updating branch refs/heads/master
to c3238d7c12b3d565be41e14e5c9d6e116ed8b82b (commit)
from dc90c7f093b810c16bad5430e24b70d1b2939b78 (commit)
commit c3238d7c12b3d565be41e14e5c9d6e116ed8b82b
Author: Arno Renevier <arno at renevier.net>
Date: Tue Mar 30 22:45:49 2010 +0200
Change MidoriView into a subclass of GtkVBox
This change makes it possible to pack widgets, notably info bars,
into a MidoriView.
midori/midori-browser.c | 32 +++++++++++++++++---------------
midori/midori-view.c | 35 ++++++++++++++++++++---------------
2 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index cf83bb8..371d838 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -1270,9 +1270,9 @@ midori_browser_view_copy_history (GtkWidget* view_to,
guint length_from;
gint i;
- copy_from = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_from)));
+ copy_from = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_from)));
list_from = webkit_web_view_get_back_forward_list (copy_from);
- copy_to = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view_to)));
+ copy_to = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view_to)));
list_to = webkit_web_view_get_back_forward_list (copy_to);
length_from = webkit_web_back_forward_list_get_back_length (list_from);
@@ -1672,8 +1672,6 @@ _midori_browser_add_tab (MidoriBrowser* browser,
guint n;
GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view),
- GTK_SHADOW_ETCHED_IN);
tab_label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
@@ -2626,8 +2624,8 @@ _midori_browser_find_done (MidoriBrowser* browser)
gtk_widget_hide (browser->find);
browser->find_typing = FALSE;
gtk_window_set_focus (GTK_WINDOW (browser),
- gtk_bin_get_child (GTK_BIN (view)) ?
- gtk_bin_get_child (GTK_BIN (view)) : view);
+ midori_view_get_web_view (MIDORI_VIEW (view)) ?
+ midori_view_get_web_view (MIDORI_VIEW (view)) : view);
}
static void
@@ -3476,7 +3474,7 @@ _action_view_encoding_activate (GtkAction* action,
GtkWidget* web_view;
name = gtk_action_get_name (current);
- web_view = gtk_bin_get_child (GTK_BIN (view));
+ web_view = midori_view_get_web_view (MIDORI_VIEW (view));
if (!strcmp (name, "EncodingAutomatic"))
g_object_set (web_view, "custom-encoding", NULL, NULL);
else
@@ -3610,7 +3608,7 @@ _action_source_view_activate (GtkAction* action,
source = midori_view_new (browser->net);
midori_view_set_settings (MIDORI_VIEW (source), browser->settings);
midori_view_set_uri (MIDORI_VIEW (source), "");
- web_view = gtk_bin_get_child (GTK_BIN (source));
+ web_view = midori_view_get_web_view (MIDORI_VIEW (source));
webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), TRUE);
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri);
gtk_widget_show (source);
@@ -3675,7 +3673,7 @@ _action_scroll_somewhere_activate (GtkAction* action,
view = midori_browser_get_current_tab (browser);
if (!view)
return;
- web_view = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view)));
+ web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
name = gtk_action_get_name (action);
if (g_str_equal (name, "ScrollLeft"))
@@ -4355,12 +4353,14 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser,
else if (g_str_equal (name, "Back"))
{
GtkWidget* view;
+ GtkWidget* page;
WebKitWebBackForwardList* back_forward_list;
WebKitWebHistoryItem* back_item;
const gchar* back_uri;
gint n;
- view = gtk_bin_get_child (GTK_BIN (midori_browser_get_current_tab (browser)));
+ page = midori_browser_get_current_tab (browser);
+ view = midori_view_get_web_view (MIDORI_VIEW (page));
back_forward_list =
webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
@@ -4378,12 +4378,14 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser,
else if (g_str_equal (name, "Forward"))
{
GtkWidget *view;
+ GtkWidget *page;
WebKitWebBackForwardList *back_forward_list;
WebKitWebHistoryItem *forward_item;
const gchar *forward_uri;
gint n;
- view = gtk_bin_get_child (GTK_BIN (midori_browser_get_current_tab (browser)));
+ page = midori_browser_get_current_tab (browser);
+ view = midori_view_get_web_view (MIDORI_VIEW (page));
back_forward_list =
webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (view));
@@ -4928,7 +4930,7 @@ _action_inspect_page_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* view = midori_browser_get_current_tab (browser);
- WebKitWebView* web_view = WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (view)));
+ WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (MIDORI_VIEW (view)));
WebKitWebInspector* inspector = webkit_web_view_get_inspector (web_view);
webkit_web_inspector_show (inspector);
}
@@ -4958,7 +4960,7 @@ _action_tab_current_activate (GtkAction* action,
MidoriBrowser* browser)
{
GtkWidget* view = midori_browser_get_current_tab (browser);
- GtkWidget* child = gtk_bin_get_child (GTK_BIN (view));
+ GtkWidget* child = midori_view_get_web_view (MIDORI_VIEW (view));
gtk_widget_grab_focus (child ? child : view);
}
@@ -7496,7 +7498,7 @@ midori_browser_set_current_page (MidoriBrowser* browser,
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
gtk_action_activate (_action_by_name (browser, "Location"));
- else if ((web_view = gtk_bin_get_child (GTK_BIN (view))))
+ else if ((web_view = midori_view_get_web_view (MIDORI_VIEW (view))))
gtk_widget_grab_focus (web_view);
else
gtk_widget_grab_focus (view);
@@ -7565,7 +7567,7 @@ midori_browser_set_current_tab (MidoriBrowser* browser,
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
if (view && midori_view_is_blank (MIDORI_VIEW (view)))
gtk_action_activate (_action_by_name (browser, "Location"));
- else if ((web_view = gtk_bin_get_child (GTK_BIN (view))))
+ else if ((web_view = midori_view_get_web_view (MIDORI_VIEW (view))))
gtk_widget_grab_focus (web_view);
else
gtk_widget_grab_focus (view);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 4a4475e..7a90c4d 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -61,7 +61,7 @@ midori_view_item_meta_data_changed (KatzeItem* item,
struct _MidoriView
{
- KatzeScrolled parent_instance;
+ GtkVBox parent_instance;
gchar* uri;
gboolean special;
@@ -106,14 +106,16 @@ struct _MidoriView
KatzeNet* net;
GHashTable* memory;
+
+ GtkWidget* scrolled_window;
};
struct _MidoriViewClass
{
- KatzeScrolledClass parent_class;
+ GtkVBoxClass parent_class;
};
-G_DEFINE_TYPE (MidoriView, midori_view, KATZE_TYPE_SCROLLED);
+G_DEFINE_TYPE (MidoriView, midori_view, GTK_TYPE_VBOX);
GType
midori_load_status_get_type (void)
@@ -1203,7 +1205,7 @@ midori_view_apply_scroll_position (MidoriView* view)
{
if (view->scrollh > 0)
{
- GtkAdjustment* adjustment = katze_object_get_object (view, "hadjustment");
+ GtkAdjustment* adjustment = katze_object_get_object (view->scrolled_window, "hadjustment");
gtk_adjustment_set_value (adjustment, view->scrollh);
g_object_unref (adjustment);
}
@@ -1213,7 +1215,7 @@ midori_view_apply_scroll_position (MidoriView* view)
{
if (view->scrollv > 0)
{
- GtkAdjustment* adjustment = katze_object_get_object (view, "vadjustment");
+ GtkAdjustment* adjustment = katze_object_get_object (view->scrolled_window, "vadjustment");
gtk_adjustment_set_value (adjustment, view->scrollv);
g_object_unref (adjustment);
}
@@ -2700,7 +2702,7 @@ midori_view_notify_hadjustment_cb (MidoriView* view,
GParamSpec* pspec,
gpointer data)
{
- GtkAdjustment* hadjustment = katze_object_get_object (view, "hadjustment");
+ GtkAdjustment* hadjustment = katze_object_get_object (view->scrolled_window, "hadjustment");
g_signal_connect (hadjustment, "notify::value",
G_CALLBACK (midori_view_hadjustment_notify_value_cb), view);
g_object_unref (hadjustment);
@@ -2721,7 +2723,7 @@ midori_view_notify_vadjustment_cb (MidoriView* view,
GParamSpec* pspec,
gpointer data)
{
- GtkAdjustment* vadjustment = katze_object_get_object (view, "vadjustment");
+ GtkAdjustment* vadjustment = katze_object_get_object (view->scrolled_window, "vadjustment");
g_signal_connect (vadjustment, "notify::value",
G_CALLBACK (midori_view_vadjustment_notify_value_cb), view);
g_object_unref (vadjustment);
@@ -2762,12 +2764,15 @@ midori_view_init (MidoriView* view)
view->download_manager = NULL;
view->news_aggregator = NULL;
view->web_view = NULL;
-
/* Adjustments are not created initially, but overwritten later */
- g_object_set (view, "hadjustment", NULL, "vadjustment", NULL, NULL);
- g_signal_connect (view, "notify::hadjustment",
+ view->scrolled_window = katze_scrolled_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window),
+ GTK_SHADOW_ETCHED_OUT);
+ gtk_container_add (GTK_CONTAINER (view), view->scrolled_window);
+
+ g_signal_connect (view->scrolled_window, "notify::hadjustment",
G_CALLBACK (midori_view_notify_hadjustment_cb), view);
- g_signal_connect (view, "notify::vadjustment",
+ g_signal_connect (view->scrolled_window, "notify::vadjustment",
G_CALLBACK (midori_view_notify_vadjustment_cb), view);
}
@@ -2949,7 +2954,7 @@ _midori_view_update_settings (MidoriView* view)
if (view->web_view)
g_object_set (view->web_view,
"full-content-zoom", zoom_text_and_images, NULL);
- g_object_set (view, "kinetic-scrolling", kinetic_scrolling, NULL);
+ g_object_set (view->scrolled_window, "kinetic-scrolling", kinetic_scrolling, NULL);
}
static void
@@ -3273,8 +3278,8 @@ midori_view_construct_web_view (MidoriView* view)
"zoom-text-and-images"), NULL);
}
- gtk_widget_show (view->web_view);
- gtk_container_add (GTK_CONTAINER (view), view->web_view);
+ gtk_container_add (GTK_CONTAINER (view->scrolled_window), view->web_view);
+ gtk_widget_show_all (view->scrolled_window);
inspector = katze_object_get_object (view->web_view, "web-inspector");
g_object_connect (inspector,
@@ -4797,7 +4802,7 @@ midori_view_get_snapshot (MidoriView* view,
GdkPixbuf* pixbuf;
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
- web_view = gtk_bin_get_child (GTK_BIN (view));
+ web_view = view->web_view;
g_return_val_if_fail (web_view->window, NULL);
x = web_view->allocation.x;
More information about the Xfce4-commits
mailing list