Fix preferences, don't destroy child widgets

This commit is contained in:
Christian Dywan 2009-10-26 23:43:17 +01:00
parent 9c2c62d37c
commit aff65928b3

View file

@ -25,6 +25,8 @@
struct _MidoriPreferences struct _MidoriPreferences
{ {
KatzePreferences parent_instance; KatzePreferences parent_instance;
gpointer settings;
}; };
G_DEFINE_TYPE (MidoriPreferences, midori_preferences, KATZE_TYPE_PREFERENCES); G_DEFINE_TYPE (MidoriPreferences, midori_preferences, KATZE_TYPE_PREFERENCES);
@ -63,8 +65,6 @@ midori_preferences_class_init (MidoriPreferencesClass* class)
* MidoriPreferences:settings: * MidoriPreferences:settings:
* *
* The settings to proxy properties from. * The settings to proxy properties from.
*
* Since 0.2.1 the property is only writable.
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SETTINGS, PROP_SETTINGS,
@ -73,13 +73,13 @@ midori_preferences_class_init (MidoriPreferencesClass* class)
"Settings", "Settings",
"Settings instance to provide properties", "Settings instance to provide properties",
MIDORI_TYPE_WEB_SETTINGS, MIDORI_TYPE_WEB_SETTINGS,
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
} }
static void static void
midori_preferences_init (MidoriPreferences* preferences) midori_preferences_init (MidoriPreferences* preferences)
{ {
/* Nothing to do */ preferences->settings = NULL;
} }
static void static void
@ -114,8 +114,13 @@ midori_preferences_get_property (GObject* object,
GValue* value, GValue* value,
GParamSpec* pspec) GParamSpec* pspec)
{ {
MidoriPreferences* preferences = MIDORI_PREFERENCES (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_SETTINGS:
g_value_set_object (value, preferences->settings);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -244,8 +249,6 @@ midori_preferences_add_toolbutton (GtkWidget* toolbar,
* Note: This must not be called more than once. * Note: This must not be called more than once.
* *
* Since 0.1.2 this is equal to setting #MidoriPreferences:settings:. * Since 0.1.2 this is equal to setting #MidoriPreferences:settings:.
*
* Since 0.2.1 this can be called multiple times.
**/ **/
void void
midori_preferences_set_settings (MidoriPreferences* preferences, midori_preferences_set_settings (MidoriPreferences* preferences,
@ -265,7 +268,9 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
g_return_if_fail (MIDORI_IS_PREFERENCES (preferences)); g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings)); g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
gtk_container_foreach (GTK_CONTAINER (GTK_DIALOG (preferences)->vbox), (GtkCallback)gtk_widget_destroy, NULL); g_return_if_fail (!preferences->settings);
preferences->settings = settings;
g_object_get (preferences, "transient-for", &parent, NULL); g_object_get (preferences, "transient-for", &parent, NULL);
icon_name = parent ? gtk_window_get_icon_name (parent) : NULL; icon_name = parent ? gtk_window_get_icon_name (parent) : NULL;