diff --git a/ChangeLog b/ChangeLog index 3b0367cf1c..8bfec8fe26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-06-20 Dan Williams + + * libnm-glib/nm-vpn-plugin-ui-interface.c + libnm-glib/nm-vpn-plugin-ui-interface.h + - 'validity-changed' -> 'changed' to work better with the connection + editor. Plugin UI widgets should emit 'changed' whenever their + UI values change in a meaningful way. + - (nm_vpn_plugin_ui_widget_interface_update_connection): the + update_connection member now returns validity of the UI widget + 2008-06-20 Tambet Ingo * libnm-util/nm-connection.c (nm_connection_duplicate): Implement. diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.c b/libnm-glib/nm-vpn-plugin-ui-interface.c index 812d4197b9..b443da75d2 100644 --- a/libnm-glib/nm-vpn-plugin-ui-interface.c +++ b/libnm-glib/nm-vpn-plugin-ui-interface.c @@ -145,13 +145,13 @@ widget_interface_init (gpointer g_iface) return; /* Signals */ - g_signal_new ("validity-changed", + g_signal_new ("changed", iface_type, G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMVpnPluginUiWidgetInterface, validity_changed), + G_STRUCT_OFFSET (NMVpnPluginUiWidgetInterface, changed), NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); initialized = TRUE; } @@ -191,10 +191,14 @@ nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *ifac return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->get_widget (iface); } -void +gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface, - NMConnection *connection) + NMConnection *connection, + GError **error) { - return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->update_connection (iface, connection); + if (error) + g_return_val_if_fail (*error == NULL, FALSE); + + return NM_VPN_PLUGIN_UI_WIDGET_INTERFACE_GET_INTERFACE (iface)->update_connection (iface, connection, error); } diff --git a/libnm-glib/nm-vpn-plugin-ui-interface.h b/libnm-glib/nm-vpn-plugin-ui-interface.h index b1a5cfd091..8ee8365927 100644 --- a/libnm-glib/nm-vpn-plugin-ui-interface.h +++ b/libnm-glib/nm-vpn-plugin-ui-interface.h @@ -141,20 +141,29 @@ struct _NMVpnPluginUiWidgetInterface { /* Return the GtkWidget for the VPN's UI */ GObject * (*get_widget) (NMVpnPluginUiWidgetInterface *iface); - /* Called to save the user-entered options to the connection object */ - void (*update_connection) (NMVpnPluginUiWidgetInterface *iface, - NMConnection *connection); + /* Called to save the user-entered options to the connection object. Should + * return FALSE and set 'error' if the current options are invalid. 'error' + * should contain enough information for the plugin to determine which UI + * widget is invalid at a later point in time. For example, creating unique + * error codes for what error occurred and populating the message field + * of 'error' with the name of the invalid property. + */ + gboolean (*update_connection) (NMVpnPluginUiWidgetInterface *iface, + NMConnection *connection, + GError **error); - /* Emitted when the validity of the user-entered options changes */ - void (*validity_changed) (NMVpnPluginUiWidgetInterface *iface, gboolean valid); + /* Emitted when the value of a UI widget changes. May trigger a validity + * check via update_connection() to write values to the connection */ + void (*changed) (NMVpnPluginUiWidgetInterface *iface); }; GType nm_vpn_plugin_ui_widget_interface_get_type (void); GObject * nm_vpn_plugin_ui_widget_interface_get_widget (NMVpnPluginUiWidgetInterface *iface); -void nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface, - NMConnection *connection); +gboolean nm_vpn_plugin_ui_widget_interface_update_connection (NMVpnPluginUiWidgetInterface *iface, + NMConnection *connection, + GError **error); G_END_DECLS