Be sure not to crash if "homepage" is NULL and hide homepage button

This commit is contained in:
Christian Dywan 2009-07-19 18:28:50 +02:00
parent f4d19b68bf
commit 9ed58f553b

View file

@ -3070,21 +3070,31 @@ _action_location_focus_in (GtkAction* action,
{ {
GtkWidget* popup = gtk_window_new (GTK_WINDOW_POPUP); GtkWidget* popup = gtk_window_new (GTK_WINDOW_POPUP);
GtkWidget* box = gtk_toolbar_new (); GtkWidget* box = gtk_toolbar_new ();
GtkToolItem* homepage = gtk_tool_button_new_from_stock (STOCK_HOMEPAGE); gchar* homepage = NULL;
guint i; guint i;
KatzeItem* item; KatzeItem* item;
/* FIXME: Resize popup to avoid overflowing items */ /* FIXME: Resize popup to avoid overflowing items */
/* FIXME: Take care of added and removed items */ /* FIXME: Take care of added and removed items */
gtk_tool_item_set_is_important (homepage, TRUE); if (browser->settings)
gtk_widget_show (GTK_WIDGET (homepage)); g_object_get (browser->settings, "homepage", &homepage, NULL);
g_signal_connect (homepage, "clicked", if (homepage && homepage)
G_CALLBACK (midori_browser_bookmark_homepage_clicked_cb), browser); {
GtkToolItem* toolitem;
toolitem = gtk_tool_button_new_from_stock (STOCK_HOMEPAGE);
gtk_tool_item_set_is_important (toolitem, TRUE);
gtk_widget_show (GTK_WIDGET (toolitem));
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_browser_bookmark_homepage_clicked_cb),
browser);
gtk_toolbar_insert (GTK_TOOLBAR (box), toolitem, -1);
}
gtk_container_add (GTK_CONTAINER (popup), box); gtk_container_add (GTK_CONTAINER (popup), box);
gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (browser)); gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (browser));
gtk_toolbar_set_icon_size (GTK_TOOLBAR (box), GTK_ICON_SIZE_MENU); gtk_toolbar_set_icon_size (GTK_TOOLBAR (box), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (box), GTK_TOOLBAR_BOTH_HORIZ); gtk_toolbar_set_style (GTK_TOOLBAR (box), GTK_TOOLBAR_BOTH_HORIZ);
gtk_toolbar_insert (GTK_TOOLBAR (box), homepage, -1);
i = 0; i = 0;
if (browser->bookmarks) if (browser->bookmarks)
while ((item = katze_array_get_nth_item (browser->bookmarks, i++))) while ((item = katze_array_get_nth_item (browser->bookmarks, i++)))
@ -5403,7 +5413,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
#endif #endif
_action_set_active (browser, "Statusbar", browser->show_statusbar); _action_set_active (browser, "Statusbar", browser->show_statusbar);
sokoke_widget_set_visible (GTK_WIDGET (browser->homepage), *homepage); sokoke_widget_set_visible (GTK_WIDGET (browser->homepage),
homepage && *homepage);
g_free (homepage); g_free (homepage);
g_free (toolbar_items); g_free (toolbar_items);
@ -5440,7 +5451,7 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
browser->progress_in_location = g_value_get_boolean (&value); browser->progress_in_location = g_value_get_boolean (&value);
else if (name == g_intern_string ("homepage")) else if (name == g_intern_string ("homepage"))
sokoke_widget_set_visible (GTK_WIDGET (browser->homepage), sokoke_widget_set_visible (GTK_WIDGET (browser->homepage),
*g_value_get_string (&value)); g_value_get_string (&value) && *g_value_get_string (&value));
else if (name == g_intern_string ("search-engines-in-completion")) else if (name == g_intern_string ("search-engines-in-completion"))
{ {
if (g_value_get_boolean (&value)) if (g_value_get_boolean (&value))