diff options
Diffstat (limited to 'tp-account-widgets')
-rw-r--r-- | tp-account-widgets/tpaw-account-settings.c | 545 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-account-settings.h | 5 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-connection-managers.c | 70 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-connection-managers.h | 4 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-chooser-dialog.c | 217 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-chooser-dialog.h | 4 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-chooser.c | 135 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-chooser.h | 4 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-manager.c | 140 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-manager.h | 5 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network.c | 79 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-network.h | 3 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-server.c | 37 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-irc-server.h | 3 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-live-search.c | 119 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-live-search.h | 3 |
16 files changed, 597 insertions, 776 deletions
diff --git a/tp-account-widgets/tpaw-account-settings.c b/tp-account-widgets/tpaw-account-settings.c index bb6e092b4..e6b1a1213 100644 --- a/tp-account-widgets/tpaw-account-settings.c +++ b/tp-account-widgets/tpaw-account-settings.c @@ -29,8 +29,6 @@ #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT #include "empathy-debug.h" -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawAccountSettings) - G_DEFINE_TYPE(TpawAccountSettings, tpaw_account_settings, G_TYPE_OBJECT) enum { @@ -50,9 +48,6 @@ enum { static gulong signals[LAST_SIGNAL] = { 0, }; -/* private structure */ -typedef struct _TpawAccountSettingsPriv TpawAccountSettingsPriv; - struct _TpawAccountSettingsPriv { gboolean dispose_has_run; @@ -106,24 +101,22 @@ struct _TpawAccountSettingsPriv static void tpaw_account_settings_init (TpawAccountSettings *obj) { - TpawAccountSettingsPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), + obj->priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), TPAW_TYPE_ACCOUNT_SETTINGS, TpawAccountSettingsPriv); - obj->priv = priv; - /* allocate any data required by the object here */ - priv->managers = tpaw_connection_managers_dup_singleton (); - priv->account_manager = tp_account_manager_dup (); + obj->priv->managers = tpaw_connection_managers_dup_singleton (); + obj->priv->account_manager = tp_account_manager_dup (); - priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, + obj->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); - priv->param_regexps = g_hash_table_new_full (g_str_hash, g_str_equal, + obj->priv->param_regexps = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_regex_unref); - priv->unset_parameters = g_array_new (TRUE, FALSE, sizeof (gchar *)); + obj->priv->unset_parameters = g_array_new (TRUE, FALSE, sizeof (gchar *)); - priv->required_params = NULL; + obj->priv->required_params = NULL; } static void tpaw_account_settings_dispose (GObject *object); @@ -141,28 +134,27 @@ tpaw_account_settings_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (object); - TpawAccountSettingsPriv *priv = GET_PRIV (settings); + TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); switch (prop_id) { case PROP_ACCOUNT: - priv->account = g_value_dup_object (value); + self->priv->account = g_value_dup_object (value); break; case PROP_CM_NAME: - priv->cm_name = g_value_dup_string (value); + self->priv->cm_name = g_value_dup_string (value); break; case PROP_PROTOCOL: - priv->protocol = g_value_dup_string (value); + self->priv->protocol = g_value_dup_string (value); break; case PROP_SERVICE: - priv->service = g_value_dup_string (value); + self->priv->service = g_value_dup_string (value); break; case PROP_DISPLAY_NAME: - priv->display_name = g_value_dup_string (value); + self->priv->display_name = g_value_dup_string (value); break; case PROP_DISPLAY_NAME_OVERRIDDEN: - priv->display_name_overridden = g_value_get_boolean (value); + self->priv->display_name_overridden = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -176,31 +168,30 @@ tpaw_account_settings_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (object); - TpawAccountSettingsPriv *priv = GET_PRIV (settings); + TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); switch (prop_id) { case PROP_ACCOUNT: - g_value_set_object (value, priv->account); + g_value_set_object (value, self->priv->account); break; case PROP_CM_NAME: - g_value_set_string (value, priv->cm_name); + g_value_set_string (value, self->priv->cm_name); break; case PROP_PROTOCOL: - g_value_set_string (value, priv->protocol); + g_value_set_string (value, self->priv->protocol); break; case PROP_SERVICE: - g_value_set_string (value, priv->service); + g_value_set_string (value, self->priv->service); break; case PROP_DISPLAY_NAME: - g_value_set_string (value, priv->display_name); + g_value_set_string (value, self->priv->display_name); break; case PROP_DISPLAY_NAME_OVERRIDDEN: - g_value_set_boolean (value, priv->display_name_overridden); + g_value_set_boolean (value, self->priv->display_name_overridden); break; case PROP_READY: - g_value_set_boolean (value, priv->ready); + g_value_set_boolean (value, self->priv->ready); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -212,33 +203,32 @@ static void tpaw_account_settings_constructed (GObject *object) { TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - TpawAccountSettingsPriv *priv = GET_PRIV (self); - if (priv->account != NULL) + if (self->priv->account != NULL) { - g_free (priv->cm_name); - g_free (priv->protocol); - g_free (priv->service); - - priv->cm_name = - g_strdup (tp_account_get_cm_name (priv->account)); - priv->protocol = - g_strdup (tp_account_get_protocol_name (priv->account)); - priv->service = - g_strdup (tp_account_get_service (priv->account)); - priv->icon_name = g_strdup - (tp_account_get_icon_name (priv->account)); + g_free (self->priv->cm_name); + g_free (self->priv->protocol); + g_free (self->priv->service); + + self->priv->cm_name = + g_strdup (tp_account_get_cm_name (self->priv->account)); + self->priv->protocol = + g_strdup (tp_account_get_protocol_name (self->priv->account)); + self->priv->service = + g_strdup (tp_account_get_service (self->priv->account)); + self->priv->icon_name = g_strdup + (tp_account_get_icon_name (self->priv->account)); } else { - priv->icon_name = tpaw_protocol_icon_name (priv->protocol); + self->priv->icon_name = tpaw_protocol_icon_name (self->priv->protocol); } - g_assert (priv->cm_name != NULL && priv->protocol != NULL); + g_assert (self->priv->cm_name != NULL && self->priv->protocol != NULL); tpaw_account_settings_check_readyness (self); - if (!priv->ready) + if (!self->priv->ready) { GQuark features[] = { TP_ACCOUNT_FEATURE_CORE, @@ -246,13 +236,13 @@ tpaw_account_settings_constructed (GObject *object) TP_ACCOUNT_FEATURE_ADDRESSING, 0 }; - if (priv->account != NULL) + if (self->priv->account != NULL) { - tp_proxy_prepare_async (priv->account, features, + tp_proxy_prepare_async (self->priv->account, features, tpaw_account_settings_account_ready_cb, self); } - tp_g_signal_connect_object (priv->managers, "notify::ready", + tp_g_signal_connect_object (self->priv->managers, "notify::ready", G_CALLBACK (tpaw_account_settings_managers_ready_cb), object, 0); } @@ -340,22 +330,22 @@ static void tpaw_account_settings_dispose (GObject *object) { TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - TpawAccountSettingsPriv *priv = GET_PRIV (self); - if (priv->dispose_has_run) + if (self->priv->dispose_has_run) return; - priv->dispose_has_run = TRUE; + self->priv->dispose_has_run = TRUE; - if (priv->managers_ready_id != 0) - g_signal_handler_disconnect (priv->managers, priv->managers_ready_id); - priv->managers_ready_id = 0; + if (self->priv->managers_ready_id != 0) + g_signal_handler_disconnect (self->priv->managers, + self->priv->managers_ready_id); + self->priv->managers_ready_id = 0; - tp_clear_object (&priv->managers); - tp_clear_object (&priv->manager); - tp_clear_object (&priv->account_manager); - tp_clear_object (&priv->account); - tp_clear_object (&priv->protocol_obj); + tp_clear_object (&self->priv->managers); + tp_clear_object (&self->priv->manager); + tp_clear_object (&self->priv->account_manager); + tp_clear_object (&self->priv->account); + tp_clear_object (&self->priv->protocol_obj); /* release any references held by the object here */ if (G_OBJECT_CLASS (tpaw_account_settings_parent_class)->dispose) @@ -366,44 +356,42 @@ static void tpaw_account_settings_free_unset_parameters ( TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); guint i; - for (i = 0 ; i < priv->unset_parameters->len; i++) - g_free (g_array_index (priv->unset_parameters, gchar *, i)); + for (i = 0 ; i < settings->priv->unset_parameters->len; i++) + g_free (g_array_index (settings->priv->unset_parameters, gchar *, i)); - g_array_set_size (priv->unset_parameters, 0); + g_array_set_size (settings->priv->unset_parameters, 0); } static void tpaw_account_settings_finalize (GObject *object) { TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - TpawAccountSettingsPriv *priv = GET_PRIV (self); GList *l; /* free any data held directly by the object here */ - g_free (priv->cm_name); - g_free (priv->protocol); - g_free (priv->service); - g_free (priv->display_name); - g_free (priv->icon_name); - g_free (priv->password); - g_free (priv->password_original); - g_free (priv->storage_provider); - - if (priv->required_params != NULL) + g_free (self->priv->cm_name); + g_free (self->priv->protocol); + g_free (self->priv->service); + g_free (self->priv->display_name); + g_free (self->priv->icon_name); + g_free (self->priv->password); + g_free (self->priv->password_original); + g_free (self->priv->storage_provider); + + if (self->priv->required_params != NULL) { - for (l = priv->required_params; l; l = l->next) + for (l = self->priv->required_params; l; l = l->next) g_free (l->data); - g_list_free (priv->required_params); + g_list_free (self->priv->required_params); } - g_hash_table_unref (priv->parameters); - g_hash_table_unref (priv->param_regexps); + g_hash_table_unref (self->priv->parameters); + g_hash_table_unref (self->priv->param_regexps); tpaw_account_settings_free_unset_parameters (self); - g_array_unref (priv->unset_parameters); + g_array_unref (self->priv->unset_parameters); G_OBJECT_CLASS (tpaw_account_settings_parent_class)->finalize (object); } @@ -432,7 +420,6 @@ tpaw_account_settings_get_password_cb (GObject *source, gpointer user_data) { TpawAccountSettings *self = user_data; - TpawAccountSettingsPriv *priv = GET_PRIV (self); const gchar *password; GError *error = NULL; @@ -449,10 +436,10 @@ tpaw_account_settings_get_password_cb (GObject *source, * just means that it's not there, or let's act like that at * least. */ - g_assert (priv->password == NULL); + g_assert (self->priv->password == NULL); - priv->password = g_strdup (password); - priv->password_original = g_strdup (password); + self->priv->password = g_strdup (password); + self->priv->password_original = g_strdup (password); g_signal_emit (self, signals[PASSWORD_RETRIEVED], 0); } @@ -470,80 +457,83 @@ static GVariant * tpaw_account_settings_dup ( static void tpaw_account_settings_check_readyness (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); GQuark features[] = { TP_PROTOCOL_FEATURE_CORE, 0 }; - if (priv->ready) + if (self->priv->ready) return; - if (priv->account != NULL - && !tp_account_is_prepared (priv->account, TP_ACCOUNT_FEATURE_CORE)) + if (self->priv->account != NULL + && !tp_account_is_prepared (self->priv->account, + TP_ACCOUNT_FEATURE_CORE)) return; - if (!tpaw_connection_managers_is_ready (priv->managers)) + if (!tpaw_connection_managers_is_ready (self->priv->managers)) return; - if (priv->manager == NULL) + if (self->priv->manager == NULL) { - priv->manager = tpaw_connection_managers_get_cm ( - priv->managers, priv->cm_name); + self->priv->manager = tpaw_connection_managers_get_cm ( + self->priv->managers, self->priv->cm_name); } - if (priv->manager == NULL) + if (self->priv->manager == NULL) return; - g_object_ref (priv->manager); + g_object_ref (self->priv->manager); - if (priv->account != NULL) + if (self->priv->account != NULL) { - g_free (priv->display_name); - priv->display_name = - g_strdup (tp_account_get_display_name (priv->account)); + g_free (self->priv->display_name); + self->priv->display_name = + g_strdup (tp_account_get_display_name (self->priv->account)); - g_free (priv->icon_name); - priv->icon_name = - g_strdup (tp_account_get_icon_name (priv->account)); + g_free (self->priv->icon_name); + self->priv->icon_name = + g_strdup (tp_account_get_icon_name (self->priv->account)); - priv->uri_scheme_tel = account_has_uri_scheme_tel (priv->account); + self->priv->uri_scheme_tel = account_has_uri_scheme_tel ( + self->priv->account); } - if (priv->protocol_obj == NULL) + if (self->priv->protocol_obj == NULL) { - priv->protocol_obj = g_object_ref ( - tp_connection_manager_get_protocol_object (priv->manager, - priv->protocol)); + self->priv->protocol_obj = g_object_ref ( + tp_connection_manager_get_protocol_object (self->priv->manager, + self->priv->protocol)); } - if (!tp_proxy_is_prepared (priv->protocol_obj, TP_PROTOCOL_FEATURE_CORE) - && !priv->preparing_protocol) + if (!tp_proxy_is_prepared (self->priv->protocol_obj, + TP_PROTOCOL_FEATURE_CORE) + && !self->priv->preparing_protocol) { - priv->preparing_protocol = TRUE; - tp_proxy_prepare_async (priv->protocol_obj, features, + self->priv->preparing_protocol = TRUE; + tp_proxy_prepare_async (self->priv->protocol_obj, features, tpaw_account_settings_protocol_obj_prepared_cb, self); return; } else { if (tp_strv_contains (tp_protocol_get_authentication_types ( - priv->protocol_obj), + self->priv->protocol_obj), TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION)) { - priv->supports_sasl = TRUE; + self->priv->supports_sasl = TRUE; } } - if (priv->required_params == NULL) + if (self->priv->required_params == NULL) { GList *params, *l; - params = tp_protocol_dup_params (priv->protocol_obj); + params = tp_protocol_dup_params (self->priv->protocol_obj); for (l = params; l != NULL; l = g_list_next (l)) { TpConnectionManagerParam *cur = l->data; if (tp_connection_manager_param_is_required (cur)) { - priv->required_params = g_list_append (priv->required_params, + self->priv->required_params = g_list_append ( + self->priv->required_params, g_strdup (tp_connection_manager_param_get_name (cur))); } } @@ -552,20 +542,20 @@ tpaw_account_settings_check_readyness (TpawAccountSettings *self) (GDestroyNotify) tp_connection_manager_param_free); } - /* priv->account won't be a proper account if it's the account + /* self->priv->account won't be a proper account if it's the account * assistant showing this widget. */ - if (priv->supports_sasl && !priv->password_requested - && priv->account != NULL) + if (self->priv->supports_sasl && !self->priv->password_requested + && self->priv->account != NULL) { - priv->password_requested = TRUE; + self->priv->password_requested = TRUE; /* Make this call but don't block on its readiness. We'll signal * if it's updated later with ::password-retrieved. */ - tpaw_keyring_get_account_password_async (priv->account, + tpaw_keyring_get_account_password_async (self->priv->account, tpaw_account_settings_get_password_cb, self); } - priv->ready = TRUE; + self->priv->ready = TRUE; g_object_notify (G_OBJECT (self), "ready"); } @@ -623,93 +613,74 @@ tpaw_account_settings_new_for_account (TpAccount *account) GList * tpaw_account_settings_dup_tp_params (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - g_return_val_if_fail (priv->protocol_obj != NULL, NULL); + g_return_val_if_fail (settings->priv->protocol_obj != NULL, NULL); - return tp_protocol_dup_params (priv->protocol_obj); + return tp_protocol_dup_params (settings->priv->protocol_obj); } gboolean tpaw_account_settings_is_ready (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->ready; + return settings->priv->ready; } const gchar * tpaw_account_settings_get_cm (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->cm_name; + return settings->priv->cm_name; } const gchar * tpaw_account_settings_get_protocol (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->protocol; + return settings->priv->protocol; } const gchar * tpaw_account_settings_get_service (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->service; + return settings->priv->service; } void tpaw_account_settings_set_service (TpawAccountSettings *settings, const gchar *service) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - if (!tp_strdiff (priv->service, service)) + if (!tp_strdiff (settings->priv->service, service)) return; - g_free (priv->service); - priv->service = g_strdup (service); + g_free (settings->priv->service); + settings->priv->service = g_strdup (service); g_object_notify (G_OBJECT (settings), "service"); - priv->update_service = TRUE; + settings->priv->update_service = TRUE; } gchar * tpaw_account_settings_get_icon_name (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->icon_name; + return settings->priv->icon_name; } const gchar * tpaw_account_settings_get_display_name (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->display_name; + return settings->priv->display_name; } TpAccount * tpaw_account_settings_get_account (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return priv->account; + return settings->priv->account; } static gboolean tpaw_account_settings_is_unset (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GArray *a; guint i; - a = priv->unset_parameters; + a = settings->priv->unset_parameters; for (i = 0; i < a->len; i++) { @@ -724,9 +695,7 @@ static const TpConnectionManagerParam * tpaw_account_settings_get_tp_param (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - return tp_protocol_get_param (priv->protocol_obj, param); + return tp_protocol_get_param (settings->priv->protocol_obj, param); } gboolean @@ -740,18 +709,17 @@ static void account_settings_remove_from_unset (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); guint idx; gchar *val; - for (idx = 0; idx < priv->unset_parameters->len; idx++) + for (idx = 0; idx < settings->priv->unset_parameters->len; idx++) { - val = g_array_index (priv->unset_parameters, gchar *, idx); + val = g_array_index (settings->priv->unset_parameters, gchar *, idx); if (!tp_strdiff (val, param)) { - priv->unset_parameters = - g_array_remove_index (priv->unset_parameters, idx); + settings->priv->unset_parameters = + g_array_remove_index (settings->priv->unset_parameters, idx); g_free (val); break; @@ -790,21 +758,21 @@ static GVariant * tpaw_account_settings_dup (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GVariant *result; /* Lookup the update parameters we set */ - result = g_hash_table_lookup (priv->parameters, param); + result = g_hash_table_lookup (settings->priv->parameters, param); if (result != NULL) return g_variant_ref (result); /* If the parameters isn't unset use the accounts setting if any */ - if (priv->account != NULL + if (settings->priv->account != NULL && !tpaw_account_settings_is_unset (settings, param)) { GVariant *parameters; - parameters = tp_account_dup_parameters_vardict (priv->account); + parameters = tp_account_dup_parameters_vardict ( + settings->priv->account); result = g_variant_lookup_value (parameters, param, NULL); g_variant_unref (parameters); @@ -821,52 +789,49 @@ void tpaw_account_settings_unset (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); gchar *v; if (tpaw_account_settings_is_unset (settings, param)) return; - if (priv->supports_sasl && !tp_strdiff (param, "password")) + if (settings->priv->supports_sasl && !tp_strdiff (param, "password")) { - g_free (priv->password); - priv->password = NULL; + g_free (settings->priv->password); + settings->priv->password = NULL; return; } v = g_strdup (param); - g_array_append_val (priv->unset_parameters, v); - g_hash_table_remove (priv->parameters, param); + g_array_append_val (settings->priv->unset_parameters, v); + g_hash_table_remove (settings->priv->parameters, param); } void tpaw_account_settings_discard_changes (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - g_hash_table_remove_all (priv->parameters); + g_hash_table_remove_all (settings->priv->parameters); tpaw_account_settings_free_unset_parameters (settings); - g_free (priv->password); - priv->password = g_strdup (priv->password_original); + g_free (settings->priv->password); + settings->priv->password = g_strdup (settings->priv->password_original); - if (priv->account != NULL) - priv->uri_scheme_tel = account_has_uri_scheme_tel (priv->account); + if (settings->priv->account != NULL) + settings->priv->uri_scheme_tel = account_has_uri_scheme_tel ( + settings->priv->account); else - priv->uri_scheme_tel = FALSE; + settings->priv->uri_scheme_tel = FALSE; } gchar * tpaw_account_settings_dup_string (TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GVariant *v; gchar *result = NULL; - if (!tp_strdiff (param, "password") && priv->supports_sasl) + if (!tp_strdiff (param, "password") && settings->priv->supports_sasl) { - return g_strdup (priv->password); + return g_strdup (settings->priv->password); } v = tpaw_account_settings_dup (settings, param); @@ -1058,20 +1023,18 @@ tpaw_account_settings_set (TpawAccountSettings *settings, const gchar *param, GVariant *v) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - g_return_if_fail (param != NULL); g_return_if_fail (v != NULL); - if (!tp_strdiff (param, "password") && priv->supports_sasl && + if (!tp_strdiff (param, "password") && settings->priv->supports_sasl && g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) { - g_free (priv->password); - priv->password = g_variant_dup_string (v, NULL); + g_free (settings->priv->password); + settings->priv->password = g_variant_dup_string (v, NULL); } else { - g_hash_table_insert (priv->parameters, g_strdup (param), + g_hash_table_insert (settings->priv->parameters, g_strdup (param), g_variant_ref_sink (v)); } @@ -1106,7 +1069,6 @@ tpaw_account_settings_set_display_name_async ( GAsyncReadyCallback callback, gpointer user_data) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GSimpleAsyncResult *result; g_return_if_fail (name != NULL); @@ -1114,23 +1076,23 @@ tpaw_account_settings_set_display_name_async ( result = g_simple_async_result_new (G_OBJECT (settings), callback, user_data, tpaw_account_settings_set_display_name_finish); - if (!tp_strdiff (name, priv->display_name)) + if (!tp_strdiff (name, settings->priv->display_name)) { /* Nothing to do */ g_simple_async_result_complete_in_idle (result); return; } - g_free (priv->display_name); - priv->display_name = g_strdup (name); + g_free (settings->priv->display_name); + settings->priv->display_name = g_strdup (name); - if (priv->account == NULL) + if (settings->priv->account == NULL) { g_simple_async_result_complete_in_idle (result); return; } - tp_account_set_display_name_async (priv->account, name, + tp_account_set_display_name_async (settings->priv->account, name, account_settings_display_name_set_cb, result); } @@ -1179,7 +1141,6 @@ tpaw_account_settings_set_icon_name_async ( GAsyncReadyCallback callback, gpointer user_data) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GSimpleAsyncResult *result; g_return_if_fail (name != NULL); @@ -1187,19 +1148,19 @@ tpaw_account_settings_set_icon_name_async ( result = g_simple_async_result_new (G_OBJECT (settings), callback, user_data, tpaw_account_settings_set_icon_name_finish); - if (priv->account == NULL) + if (settings->priv->account == NULL) { - if (priv->icon_name != NULL) - g_free (priv->icon_name); + if (settings->priv->icon_name != NULL) + g_free (settings->priv->icon_name); - priv->icon_name = g_strdup (name); + settings->priv->icon_name = g_strdup (name); g_simple_async_result_complete_in_idle (result); return; } - tp_account_set_icon_name_async (priv->account, name, + tp_account_set_icon_name_async (settings->priv->account, name, account_settings_icon_name_set_cb, result); } @@ -1227,25 +1188,25 @@ tpaw_account_settings_processed_password (GObject *source, gpointer finish_func) { TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GSimpleAsyncResult *r; GError *error = NULL; gboolean (*func) (TpAccount *source, GAsyncResult *result, GError **error) = finish_func; - g_free (priv->password_original); - priv->password_original = g_strdup (priv->password); + g_free (settings->priv->password_original); + settings->priv->password_original = g_strdup (settings->priv->password); if (!func (TP_ACCOUNT (source), result, &error)) { - g_simple_async_result_set_from_error (priv->apply_result, error); + g_simple_async_result_set_from_error (settings->priv->apply_result, + error); g_error_free (error); } tpaw_account_settings_discard_changes (settings); - r = priv->apply_result; - priv->apply_result = NULL; + r = settings->priv->apply_result; + settings->priv->apply_result = NULL; g_simple_async_result_complete (r); g_object_unref (r); @@ -1272,14 +1233,12 @@ tpaw_account_settings_delete_password_cb (GObject *source, static void update_account_uri_schemes (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - if (priv->uri_scheme_tel == account_has_uri_scheme_tel ( - priv->account)) + if (self->priv->uri_scheme_tel == account_has_uri_scheme_tel ( + self->priv->account)) return; - tp_account_set_uri_scheme_association_async (priv->account, "tel", - priv->uri_scheme_tel, NULL, NULL); + tp_account_set_uri_scheme_association_async (self->priv->account, "tel", + self->priv->uri_scheme_tel, NULL, NULL); } static void @@ -1299,13 +1258,12 @@ set_service_cb (GObject *source, static void update_account_service (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - if (!priv->update_service) + if (!self->priv->update_service) return; - tp_account_set_service_async (priv->account, - priv->service != NULL ? priv->service : "", set_service_cb, self); + tp_account_set_service_async (self->priv->account, + self->priv->service != NULL ? self->priv->service : "", + set_service_cb, self); } static void @@ -1314,7 +1272,6 @@ tpaw_account_settings_account_updated (GObject *source, gpointer user_data) { TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GSimpleAsyncResult *r; GError *error = NULL; GStrv reconnect_required = NULL; @@ -1322,7 +1279,8 @@ tpaw_account_settings_account_updated (GObject *source, if (!tp_account_update_parameters_vardict_finish (TP_ACCOUNT (source), result, &reconnect_required, &error)) { - g_simple_async_result_set_from_error (priv->apply_result, error); + g_simple_async_result_set_from_error (settings->priv->apply_result, + error); g_error_free (error); goto out; } @@ -1330,24 +1288,25 @@ tpaw_account_settings_account_updated (GObject *source, update_account_uri_schemes (settings); update_account_service (settings); - g_simple_async_result_set_op_res_gboolean (priv->apply_result, + g_simple_async_result_set_op_res_gboolean (settings->priv->apply_result, g_strv_length (reconnect_required) > 0); /* Only set the password in the keyring if the CM supports SASL. */ - if (priv->supports_sasl) + if (settings->priv->supports_sasl) { - if (priv->password != NULL) + if (settings->priv->password != NULL) { /* FIXME: we shouldn't save the password if we * can't (MaySaveResponse=False) but we don't have API to check that * at this point (fdo #35382). */ - tpaw_keyring_set_account_password_async (priv->account, - priv->password, priv->remember_password, + tpaw_keyring_set_account_password_async (settings->priv->account, + settings->priv->password, settings->priv->remember_password, tpaw_account_settings_set_password_cb, settings); } else { - tpaw_keyring_delete_account_password_async (priv->account, + tpaw_keyring_delete_account_password_async ( + settings->priv->account, tpaw_account_settings_delete_password_cb, settings); } @@ -1357,8 +1316,8 @@ tpaw_account_settings_account_updated (GObject *source, out: tpaw_account_settings_discard_changes (settings); - r = priv->apply_result; - priv->apply_result = NULL; + r = settings->priv->apply_result; + settings->priv->apply_result = NULL; g_simple_async_result_complete (r); g_object_unref (r); @@ -1371,27 +1330,27 @@ tpaw_account_settings_created_cb (GObject *source, gpointer user_data) { TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GError *error = NULL; GSimpleAsyncResult *r; - priv->account = tp_account_request_create_account_finish ( + settings->priv->account = tp_account_request_create_account_finish ( TP_ACCOUNT_REQUEST (source), result, &error); - if (priv->account == NULL) + if (settings->priv->account == NULL) { - g_simple_async_result_set_from_error (priv->apply_result, error); + g_simple_async_result_set_from_error (settings->priv->apply_result, + error); } else { - if (priv->supports_sasl && priv->password != NULL) + if (settings->priv->supports_sasl && settings->priv->password != NULL) { /* Save the password before connecting */ /* FIXME: we shouldn't save the password if we * can't (MaySaveResponse=False) but we don't have API to check that * at this point (fdo #35382). */ - tpaw_keyring_set_account_password_async (priv->account, - priv->password, priv->remember_password, + tpaw_keyring_set_account_password_async (settings->priv->account, + settings->priv->password, settings->priv->remember_password, tpaw_account_settings_set_password_cb, settings); return; @@ -1402,8 +1361,8 @@ tpaw_account_settings_created_cb (GObject *source, tpaw_account_settings_discard_changes (settings); } - r = priv->apply_result; - priv->apply_result = NULL; + r = settings->priv->apply_result; + settings->priv->apply_result = NULL; g_simple_async_result_complete (r); g_object_unref (r); @@ -1412,22 +1371,22 @@ tpaw_account_settings_created_cb (GObject *source, static void tpaw_account_settings_do_create_account (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); TpAccountRequest *account_req; GHashTableIter iter; gpointer k, v; - account_req = tp_account_request_new (priv->account_manager, priv->cm_name, - priv->protocol, "New Account"); + account_req = tp_account_request_new (self->priv->account_manager, + self->priv->cm_name, self->priv->protocol, "New Account"); - tp_account_request_set_icon_name (account_req, priv->icon_name); + tp_account_request_set_icon_name (account_req, self->priv->icon_name); - tp_account_request_set_display_name (account_req, priv->display_name); + tp_account_request_set_display_name (account_req, + self->priv->display_name); - if (priv->service != NULL) - tp_account_request_set_service (account_req, priv->service); + if (self->priv->service != NULL) + tp_account_request_set_service (account_req, self->priv->service); - g_hash_table_iter_init (&iter, priv->parameters); + g_hash_table_iter_init (&iter, self->priv->parameters); while (g_hash_table_iter_next (&iter, &k, &v)) { const gchar *key = k; @@ -1436,10 +1395,10 @@ tpaw_account_settings_do_create_account (TpawAccountSettings *self) tp_account_request_set_parameter (account_req, key, value); } - if (priv->storage_provider != NULL) + if (self->priv->storage_provider != NULL) { tp_account_request_set_storage_provider (account_req, - priv->storage_provider); + self->priv->storage_provider); } tp_account_request_create_account_async (account_req, @@ -1449,14 +1408,13 @@ tpaw_account_settings_do_create_account (TpawAccountSettings *self) static GVariant * build_parameters_variant (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); GVariantBuilder *builder; GHashTableIter iter; gpointer k, v; builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); - g_hash_table_iter_init (&iter, priv->parameters); + g_hash_table_iter_init (&iter, self->priv->parameters); while (g_hash_table_iter_next (&iter, &k, &v)) { const gchar *key = k; @@ -1477,9 +1435,7 @@ tpaw_account_settings_apply_async (TpawAccountSettings *settings, GAsyncReadyCallback callback, gpointer user_data) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); - - if (priv->apply_result != NULL) + if (settings->priv->apply_result != NULL) { g_simple_async_report_error_in_idle (G_OBJECT (settings), callback, user_data, @@ -1487,24 +1443,27 @@ tpaw_account_settings_apply_async (TpawAccountSettings *settings, return; } - priv->apply_result = g_simple_async_result_new (G_OBJECT (settings), - callback, user_data, tpaw_account_settings_apply_finish); + settings->priv->apply_result = g_simple_async_result_new ( + G_OBJECT (settings), callback, user_data, + tpaw_account_settings_apply_finish); /* We'll have to reconnect only if we change none DBus_Property on an * existing account. */ - g_simple_async_result_set_op_res_gboolean (priv->apply_result, FALSE); + g_simple_async_result_set_op_res_gboolean (settings->priv->apply_result, + FALSE); - if (priv->account == NULL) + if (settings->priv->account == NULL) { - g_assert (priv->apply_result != NULL && priv->account == NULL); + g_assert (settings->priv->apply_result != NULL && + settings->priv->account == NULL); tpaw_account_settings_do_create_account (settings); } else { - tp_account_update_parameters_vardict_async (priv->account, + tp_account_update_parameters_vardict_async (settings->priv->account, build_parameters_variant (settings), - (const gchar **) priv->unset_parameters->data, + (const gchar **) settings->priv->unset_parameters->data, tpaw_account_settings_account_updated, settings); } } @@ -1533,20 +1492,18 @@ gboolean tpaw_account_settings_has_account (TpawAccountSettings *settings, TpAccount *account) { - TpawAccountSettingsPriv *priv; const gchar *account_path; const gchar *priv_account_path; g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE); - priv = GET_PRIV (settings); - - if (priv->account == NULL) + if (settings->priv->account == NULL) return FALSE; account_path = tp_proxy_get_object_path (TP_PROXY (account)); - priv_account_path = tp_proxy_get_object_path (TP_PROXY (priv->account)); + priv_account_path = tp_proxy_get_object_path ( + TP_PROXY (settings->priv->account)); return (!tp_strdiff (account_path, priv_account_path)); } @@ -1556,7 +1513,6 @@ tpaw_account_settings_set_regex (TpawAccountSettings *settings, const gchar *param, const gchar *pattern) { - TpawAccountSettingsPriv *priv = GET_PRIV (settings); GRegex *regex; GError *error = NULL; @@ -1568,7 +1524,8 @@ tpaw_account_settings_set_regex (TpawAccountSettings *settings, return; } - g_hash_table_insert (priv->param_regexps, g_strdup (param), regex); + g_hash_table_insert (settings->priv->param_regexps, g_strdup (param), + regex); } gboolean @@ -1576,26 +1533,25 @@ tpaw_account_settings_parameter_is_valid ( TpawAccountSettings *settings, const gchar *param) { - TpawAccountSettingsPriv *priv; const GRegex *regex; g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); - priv = GET_PRIV (settings); - - if (g_list_find_custom (priv->required_params, param, (GCompareFunc) strcmp)) + if (g_list_find_custom (settings->priv->required_params, param, + (GCompareFunc) strcmp)) { /* first, look if it's set in our own parameters */ - if (g_hash_table_lookup (priv->parameters, param) != NULL) + if (g_hash_table_lookup (settings->priv->parameters, param) != NULL) goto test_regex; /* if we did not unset the parameter, look if it's in the account */ - if (priv->account != NULL && + if (settings->priv->account != NULL && !tpaw_account_settings_is_unset (settings, param)) { const GHashTable *account_params; - account_params = tp_account_get_parameters (priv->account); + account_params = tp_account_get_parameters ( + settings->priv->account); if (tp_asv_lookup (account_params, param)) goto test_regex; } @@ -1605,7 +1561,7 @@ tpaw_account_settings_parameter_is_valid ( test_regex: /* test whether parameter value matches its regex */ - regex = g_hash_table_lookup (priv->param_regexps, param); + regex = g_hash_table_lookup (settings->priv->param_regexps, param); if (regex) { gchar *value; @@ -1627,22 +1583,19 @@ test_regex: gboolean tpaw_account_settings_is_valid (TpawAccountSettings *settings) { - TpawAccountSettingsPriv *priv; const gchar *param; GHashTableIter iter; GList *l; g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); - priv = GET_PRIV (settings); - - for (l = priv->required_params; l; l = l->next) + for (l = settings->priv->required_params; l; l = l->next) { if (!tpaw_account_settings_parameter_is_valid (settings, l->data)) return FALSE; } - g_hash_table_iter_init (&iter, priv->param_regexps); + g_hash_table_iter_init (&iter, settings->priv->param_regexps); while (g_hash_table_iter_next (&iter, (gpointer *) ¶m, NULL)) { if (!tpaw_account_settings_parameter_is_valid (settings, param)) @@ -1655,61 +1608,47 @@ tpaw_account_settings_is_valid (TpawAccountSettings *settings) TpProtocol * tpaw_account_settings_get_tp_protocol (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - return priv->protocol_obj; + return self->priv->protocol_obj; } gboolean tpaw_account_settings_supports_sasl (TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - return priv->supports_sasl; + return self->priv->supports_sasl; } gboolean tpaw_account_settings_param_is_supported (TpawAccountSettings *self, const gchar *param) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - return tp_protocol_has_param (priv->protocol_obj, param); + return tp_protocol_has_param (self->priv->protocol_obj, param); } void tpaw_account_settings_set_uri_scheme_tel (TpawAccountSettings *self, gboolean associate) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - priv->uri_scheme_tel = associate; + self->priv->uri_scheme_tel = associate; } gboolean tpaw_account_settings_has_uri_scheme_tel ( TpawAccountSettings *self) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - return priv->uri_scheme_tel; + return self->priv->uri_scheme_tel; } void tpaw_account_settings_set_storage_provider (TpawAccountSettings *self, const gchar *storage) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - g_free (priv->storage_provider); - priv->storage_provider = g_strdup (storage); + g_free (self->priv->storage_provider); + self->priv->storage_provider = g_strdup (storage); } void tpaw_account_settings_set_remember_password (TpawAccountSettings *self, gboolean remember) { - TpawAccountSettingsPriv *priv = GET_PRIV (self); - - priv->remember_password = remember; + self->priv->remember_password = remember; } diff --git a/tp-account-widgets/tpaw-account-settings.h b/tp-account-widgets/tpaw-account-settings.h index ad0c70aa5..d8e567fa3 100644 --- a/tp-account-widgets/tpaw-account-settings.h +++ b/tp-account-widgets/tpaw-account-settings.h @@ -28,6 +28,7 @@ G_BEGIN_DECLS typedef struct _TpawAccountSettings TpawAccountSettings; +typedef struct _TpawAccountSettingsPriv TpawAccountSettingsPriv; typedef struct _TpawAccountSettingsClass TpawAccountSettingsClass; struct _TpawAccountSettingsClass { @@ -36,7 +37,9 @@ struct _TpawAccountSettingsClass { struct _TpawAccountSettings { GObject parent; - gpointer priv; + + /*<private>*/ + TpawAccountSettingsPriv *priv; }; GType tpaw_account_settings_get_type (void); diff --git a/tp-account-widgets/tpaw-connection-managers.c b/tp-account-widgets/tpaw-connection-managers.c index f648340aa..fc0064796 100644 --- a/tp-account-widgets/tpaw-connection-managers.c +++ b/tp-account-widgets/tpaw-connection-managers.c @@ -22,6 +22,7 @@ #include "tpaw-connection-managers.h" #include "empathy-utils.h" +#include "tpaw-utils.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include "empathy-debug.h" @@ -45,13 +46,7 @@ enum { PROP_READY = 1 }; -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawConnectionManagers) - - /* private structure */ -typedef struct _TpawConnectionManagersPriv - TpawConnectionManagersPriv; - struct _TpawConnectionManagersPriv { gboolean dispose_has_run; @@ -65,14 +60,11 @@ struct _TpawConnectionManagersPriv static void tpaw_connection_managers_init (TpawConnectionManagers *obj) { - TpawConnectionManagersPriv *priv = - G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + obj->priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), TPAW_TYPE_CONNECTION_MANAGERS, TpawConnectionManagersPriv); - obj->priv = priv; - - priv->dbus = tp_dbus_daemon_dup (NULL); - g_assert (priv->dbus != NULL); + obj->priv->dbus = tp_dbus_daemon_dup (NULL); + g_assert (obj->priv->dbus != NULL); tpaw_connection_managers_update (obj); @@ -107,12 +99,11 @@ tpaw_connection_managers_get_property (GObject *object, GParamSpec *pspec) { TpawConnectionManagers *self = TPAW_CONNECTION_MANAGERS (object); - TpawConnectionManagersPriv *priv = GET_PRIV (self); switch (prop_id) { case PROP_READY: - g_value_set_boolean (value, priv->ready); + g_value_set_boolean (value, self->priv->ready); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -152,32 +143,30 @@ tpaw_connection_managers_class_init ( static void tpaw_connection_managers_free_cm_list (TpawConnectionManagers *self) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); GList *l; - for (l = priv->cms ; l != NULL ; l = g_list_next (l)) + for (l = self->priv->cms ; l != NULL ; l = g_list_next (l)) { g_object_unref (l->data); } - g_list_free (priv->cms); + g_list_free (self->priv->cms); - priv->cms = NULL; + self->priv->cms = NULL; } static void tpaw_connection_managers_dispose (GObject *object) { TpawConnectionManagers *self = TPAW_CONNECTION_MANAGERS (object); - TpawConnectionManagersPriv *priv = GET_PRIV (self); - if (priv->dispose_has_run) + if (self->priv->dispose_has_run) return; - priv->dispose_has_run = TRUE; + self->priv->dispose_has_run = TRUE; - if (priv->dbus != NULL) - g_object_unref (priv->dbus); - priv->dbus = NULL; + if (self->priv->dbus != NULL) + g_object_unref (self->priv->dbus); + self->priv->dbus = NULL; tpaw_connection_managers_free_cm_list (self); @@ -197,8 +186,7 @@ tpaw_connection_managers_dup_singleton (void) gboolean tpaw_connection_managers_is_ready (TpawConnectionManagers *self) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); - return priv->ready; + return self->priv->ready; } static void @@ -210,7 +198,6 @@ tpaw_connection_managers_listed_cb (GObject *source, GError *error = NULL; TpawConnectionManagers *self = tp_weak_ref_dup_object (wr); GList *cms, *l; - TpawConnectionManagersPriv *priv; if (self == NULL) { @@ -218,8 +205,6 @@ tpaw_connection_managers_listed_cb (GObject *source, return; } - priv = GET_PRIV (self); - tpaw_connection_managers_free_cm_list (self); cms = tp_list_connection_managers_finish (result, &error); @@ -236,13 +221,14 @@ tpaw_connection_managers_listed_cb (GObject *source, /* only list cms that didn't hit errors */ if (tp_proxy_is_prepared (cm, TP_CONNECTION_MANAGER_FEATURE_CORE)) - priv->cms = g_list_prepend (priv->cms, g_object_ref (cm)); + self->priv->cms = g_list_prepend (self->priv->cms, + g_object_ref (cm)); } out: - if (!priv->ready) + if (!self->priv->ready) { - priv->ready = TRUE; + self->priv->ready = TRUE; g_object_notify (G_OBJECT (self), "ready"); } @@ -254,9 +240,7 @@ out: void tpaw_connection_managers_update (TpawConnectionManagers *self) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); - - tp_list_connection_managers_async (priv->dbus, + tp_list_connection_managers_async (self->priv->dbus, tpaw_connection_managers_listed_cb, tp_weak_ref_new (self, NULL, NULL)); } @@ -264,19 +248,16 @@ tpaw_connection_managers_update (TpawConnectionManagers *self) GList * tpaw_connection_managers_get_cms (TpawConnectionManagers *self) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); - - return priv->cms; + return self->priv->cms; } TpConnectionManager * tpaw_connection_managers_get_cm (TpawConnectionManagers *self, const gchar *cm) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); GList *l; - for (l = priv->cms ; l != NULL; l = g_list_next (l)) + for (l = self->priv->cms ; l != NULL; l = g_list_next (l)) { TpConnectionManager *c = TP_CONNECTION_MANAGER (l->data); @@ -290,13 +271,9 @@ tpaw_connection_managers_get_cm (TpawConnectionManagers *self, guint tpaw_connection_managers_get_cms_num (TpawConnectionManagers *self) { - TpawConnectionManagersPriv *priv; - g_return_val_if_fail (TPAW_IS_CONNECTION_MANAGERS (self), 0); - priv = GET_PRIV (self); - - return g_list_length (priv->cms); + return g_list_length (self->priv->cms); } static void @@ -314,13 +291,12 @@ tpaw_connection_managers_prepare_async ( GAsyncReadyCallback callback, gpointer user_data) { - TpawConnectionManagersPriv *priv = GET_PRIV (self); GSimpleAsyncResult *result; result = g_simple_async_result_new (G_OBJECT (managers), callback, user_data, tpaw_connection_managers_prepare_finish); - if (priv->ready) + if (self->priv->ready) { g_simple_async_result_complete_in_idle (result); g_object_unref (result); diff --git a/tp-account-widgets/tpaw-connection-managers.h b/tp-account-widgets/tpaw-connection-managers.h index 33e5aa081..dba476b47 100644 --- a/tp-account-widgets/tpaw-connection-managers.h +++ b/tp-account-widgets/tpaw-connection-managers.h @@ -28,6 +28,7 @@ G_BEGIN_DECLS typedef struct _TpawConnectionManagers TpawConnectionManagers; +typedef struct _TpawConnectionManagersPriv TpawConnectionManagersPriv; typedef struct _TpawConnectionManagersClass TpawConnectionManagersClass; struct _TpawConnectionManagersClass { @@ -36,7 +37,8 @@ struct _TpawConnectionManagersClass { struct _TpawConnectionManagers { GObject parent; - gpointer priv; + /*<private>*/ + TpawConnectionManagersPriv *priv; }; GType tpaw_connection_managers_get_type (void); diff --git a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c b/tp-account-widgets/tpaw-irc-network-chooser-dialog.c index 123250254..d962dfb2f 100644 --- a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c +++ b/tp-account-widgets/tpaw-irc-network-chooser-dialog.c @@ -35,8 +35,6 @@ #include "tpaw-irc-network-chooser-dialog.h" -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcNetworkChooserDialog) - enum { PROP_SETTINGS = 1, PROP_NETWORK @@ -46,7 +44,7 @@ enum { RESPONSE_RESET = 0 }; -typedef struct { +struct _TpawIrcNetworkChooserDialogPriv { TpawAccountSettings *settings; TpawIrcNetwork *network; @@ -61,7 +59,7 @@ typedef struct { gulong search_sig; gulong activate_sig; -} TpawIrcNetworkChooserDialogPriv; +}; enum { COL_NETWORK_OBJ, @@ -77,15 +75,16 @@ tpaw_irc_network_chooser_dialog_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (object); + TpawIrcNetworkChooserDialog *self = + TPAW_IRC_NETWORK_CHOOSER_DIALOG (object); switch (prop_id) { case PROP_SETTINGS: - priv->settings = g_value_dup_object (value); + self->priv->settings = g_value_dup_object (value); break; case PROP_NETWORK: - priv->network = g_value_dup_object (value); + self->priv->network = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -99,15 +98,16 @@ tpaw_irc_network_chooser_dialog_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (object); + TpawIrcNetworkChooserDialog *self = + TPAW_IRC_NETWORK_CHOOSER_DIALOG (object); switch (prop_id) { case PROP_SETTINGS: - g_value_set_object (value, priv->settings); + g_value_set_object (value, self->priv->settings); break; case PROP_NETWORK: - g_value_set_object (value, priv->network); + g_value_set_object (value, self->priv->network); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -115,18 +115,18 @@ tpaw_irc_network_chooser_dialog_get_property (GObject *object, } } -/* The iter returned by *it is a priv->store iter (not a filter one) */ +/* The iter returned by *it is a self->priv->store iter (not a filter one) */ static TpawIrcNetwork * dup_selected_network (TpawIrcNetworkChooserDialog *self, GtkTreeIter *it) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; GtkTreeSelection *selection; GtkTreeIter iter; GtkTreeModel *model; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + selection = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (self->priv->treeview)); if (selection == NULL) return NULL; @@ -138,8 +138,8 @@ dup_selected_network (TpawIrcNetworkChooserDialog *self, if (it != NULL) { - gtk_tree_model_filter_convert_iter_to_child_iter (priv->filter, it, - &iter); + gtk_tree_model_filter_convert_iter_to_child_iter ( self->priv->filter, + it, &iter); } return network; @@ -149,21 +149,20 @@ static void treeview_changed_cb (GtkTreeView *treeview, TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; network = dup_selected_network (self, NULL); - if (network == priv->network) + if (network == self->priv->network) { g_clear_object (&network); return; } - tp_clear_object (&priv->network); + tp_clear_object (&self->priv->network); /* Transfer the reference */ - priv->network = network; + self->priv->network = network; - priv->changed = TRUE; + self->priv->changed = TRUE; } /* Take a filter iterator as argument */ @@ -171,14 +170,14 @@ static void scroll_to_iter (TpawIrcNetworkChooserDialog *self, GtkTreeIter *filter_iter) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GtkTreePath *path; - path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->filter), filter_iter); + path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->filter), + filter_iter); if (path != NULL) { - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->treeview), + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self->priv->treeview), path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); @@ -191,20 +190,20 @@ select_iter (TpawIrcNetworkChooserDialog *self, GtkTreeIter *filter_iter, gboolean emulate_changed) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GtkTreeSelection *selection; GtkTreePath *path; /* Select the network */ selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->treeview)); + GTK_TREE_VIEW (self->priv->treeview)); gtk_tree_selection_select_iter (selection, filter_iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->filter), filter_iter); + path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->filter), + filter_iter); if (path != NULL) { - gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->treeview), path, + gtk_tree_view_set_cursor (GTK_TREE_VIEW (self->priv->treeview), path, NULL, FALSE); gtk_tree_path_free (path); @@ -217,7 +216,7 @@ select_iter (TpawIrcNetworkChooserDialog *self, { /* gtk_tree_selection_select_iter doesn't fire the 'cursor-changed' signal * so we call the callback manually. */ - treeview_changed_cb (GTK_TREE_VIEW (priv->treeview), self); + treeview_changed_cb (GTK_TREE_VIEW (self->priv->treeview), self); } } @@ -225,10 +224,10 @@ static GtkTreeIter iter_to_filter_iter (TpawIrcNetworkChooserDialog *self, GtkTreeIter *iter) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GtkTreeIter filter_iter; - g_assert (gtk_tree_model_filter_convert_child_iter_to_iter (priv->filter, + g_assert ( + gtk_tree_model_filter_convert_child_iter_to_iter (self->priv->filter, &filter_iter, iter)); return filter_iter; @@ -237,23 +236,22 @@ iter_to_filter_iter (TpawIrcNetworkChooserDialog *self, static void fill_store (TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GSList *networks, *l; networks = tpaw_irc_network_manager_get_networks ( - priv->network_manager); + self->priv->network_manager); for (l = networks; l != NULL; l = g_slist_next (l)) { TpawIrcNetwork *network = l->data; GtkTreeIter iter; - gtk_list_store_insert_with_values (priv->store, &iter, -1, + gtk_list_store_insert_with_values (self->priv->store, &iter, -1, COL_NETWORK_OBJ, network, COL_NETWORK_NAME, tpaw_irc_network_get_name (network), -1); - if (network == priv->network) + if (network == self->priv->network) { GtkTreeIter filter_iter = iter_to_filter_iter (self, &iter); @@ -270,24 +268,23 @@ static void irc_network_dialog_destroy_cb (GtkWidget *widget, TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; GtkTreeIter iter, filter_iter; - priv->changed = TRUE; + self->priv->changed = TRUE; network = dup_selected_network (self, &iter); if (network == NULL) return; /* name could be changed */ - gtk_list_store_set (GTK_LIST_STORE (priv->store), &iter, + gtk_list_store_set (GTK_LIST_STORE (self->priv->store), &iter, COL_NETWORK_NAME, tpaw_irc_network_get_name (network), -1); filter_iter = iter_to_filter_iter (self, &iter); scroll_to_iter (self, &filter_iter); - gtk_widget_grab_focus (priv->treeview); + gtk_widget_grab_focus (self->priv->treeview); g_object_unref (network); } @@ -321,16 +318,15 @@ edit_network (TpawIrcNetworkChooserDialog *self) static void add_network (TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; GtkTreeIter iter, filter_iter; - gtk_widget_hide (priv->search); + gtk_widget_hide (self->priv->search); network = tpaw_irc_network_new (_("New Network")); - tpaw_irc_network_manager_add (priv->network_manager, network); + tpaw_irc_network_manager_add (self->priv->network_manager, network); - gtk_list_store_insert_with_values (priv->store, &iter, -1, + gtk_list_store_insert_with_values (self->priv->store, &iter, -1, COL_NETWORK_OBJ, network, COL_NETWORK_NAME, tpaw_irc_network_get_name (network), -1); @@ -346,7 +342,6 @@ add_network (TpawIrcNetworkChooserDialog *self) static void remove_network (TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; GtkTreeIter iter; @@ -355,12 +350,12 @@ remove_network (TpawIrcNetworkChooserDialog *self) return; /* Hide the search after picking the network to get the right one */ - gtk_widget_hide (priv->search); + gtk_widget_hide (self->priv->search); DEBUG ("Remove network %s", tpaw_irc_network_get_name (network)); /* Delete network and select next network */ - if (gtk_list_store_remove (priv->store, &iter)) + if (gtk_list_store_remove (self->priv->store, &iter)) { GtkTreeIter filter_iter = iter_to_filter_iter (self, &iter); @@ -372,21 +367,21 @@ remove_network (TpawIrcNetworkChooserDialog *self) GtkTreeIter last, filter_iter; gint n_elements; - n_elements = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), - NULL); + n_elements = gtk_tree_model_iter_n_children ( + GTK_TREE_MODEL (self->priv->store), NULL); if (n_elements > 0) { - gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (priv->store), &last, - NULL, (n_elements-1)); + gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->store), + &last, NULL, (n_elements-1)); filter_iter = iter_to_filter_iter (self, &last); select_iter (self, &filter_iter, TRUE); } } - tpaw_irc_network_manager_remove (priv->network_manager, network); - gtk_widget_grab_focus (priv->treeview); + tpaw_irc_network_manager_remove (self->priv->network_manager, network); + gtk_widget_grab_focus (self->priv->treeview); g_object_unref (network); } @@ -394,11 +389,10 @@ remove_network (TpawIrcNetworkChooserDialog *self) static void reset_networks (TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GSList *networks, *l; networks = tpaw_irc_network_manager_get_dropped_networks ( - priv->network_manager); + self->priv->network_manager); for (l = networks; l != NULL; l = g_slist_next (l)) { @@ -408,7 +402,7 @@ reset_networks (TpawIrcNetworkChooserDialog *self) network = TPAW_IRC_NETWORK (l->data); tpaw_irc_network_activate (network); - gtk_list_store_insert_with_values (priv->store, &iter, -1, + gtk_list_store_insert_with_values (self->priv->store, &iter, -1, COL_NETWORK_OBJ, network, COL_NETWORK_NAME, tpaw_irc_network_get_name (network), -1); @@ -431,13 +425,13 @@ filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (user_data); + TpawIrcNetworkChooserDialog *self = user_data; TpawIrcNetwork *network; gboolean visible; gtk_tree_model_get (model, iter, COL_NETWORK_OBJ, &network, -1); - visible = tpaw_live_search_match (TPAW_LIVE_SEARCH (priv->search), + visible = tpaw_live_search_match (TPAW_LIVE_SEARCH (self->priv->search), tpaw_irc_network_get_name (network)); g_object_unref (network); @@ -457,19 +451,19 @@ search_text_notify_cb (TpawLiveSearch *search, GParamSpec *pspec, TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GtkTreeIter filter_iter; gboolean sensitive = FALSE; - gtk_tree_model_filter_refilter (priv->filter); + gtk_tree_model_filter_refilter (self->priv->filter); /* Is there at least one network in the view ? */ - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->filter), + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->filter), &filter_iter)) { const gchar *text; - text = tpaw_live_search_get_text (TPAW_LIVE_SEARCH (priv->search)); + text = tpaw_live_search_get_text ( + TPAW_LIVE_SEARCH (self->priv->search)); if (!TPAW_STR_EMPTY (text)) { /* We are doing a search, select the first matching network */ @@ -481,16 +475,17 @@ search_text_notify_cb (TpawLiveSearch *search, GtkTreeSelection *selection; selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (priv->treeview)); + GTK_TREE_VIEW (self->priv->treeview)); - if (gtk_tree_selection_get_selected (selection, NULL, &filter_iter)) + if (gtk_tree_selection_get_selected (selection, NULL, + &filter_iter)) scroll_to_iter (self, &filter_iter); } sensitive = TRUE; } - gtk_widget_set_sensitive (priv->select_button, sensitive); + gtk_widget_set_sensitive (self->priv->select_button, sensitive); } static void @@ -518,7 +513,6 @@ static void tpaw_irc_network_chooser_dialog_constructed (GObject *object) { TpawIrcNetworkChooserDialog *self = (TpawIrcNetworkChooserDialog *) object; - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); GtkDialog *dialog = GTK_DIALOG (self); GtkCellRenderer *renderer; GtkWidget *vbox; @@ -528,23 +522,26 @@ tpaw_irc_network_chooser_dialog_constructed (GObject *object) GtkToolItem *item; GtkStyleContext *context; - g_assert (priv->settings != NULL); + g_assert (self->priv->settings != NULL); gtk_window_set_title (GTK_WINDOW (self), _("Choose an IRC network")); /* Create store and treeview */ - priv->store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING); + self->priv->store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->store), + gtk_tree_sortable_set_sort_column_id ( + GTK_TREE_SORTABLE (self->priv->store), COL_NETWORK_NAME, GTK_SORT_ASCENDING); - priv->treeview = gtk_tree_view_new (); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE); - gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->treeview), FALSE); + self->priv->treeview = gtk_tree_view_new (); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->priv->treeview), + FALSE); + gtk_tree_view_set_enable_search (GTK_TREE_VIEW (self->priv->treeview), + FALSE); column = gtk_tree_view_column_new (); - gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column); + gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->treeview), column); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE); @@ -560,7 +557,7 @@ tpaw_irc_network_chooser_dialog_constructed (GObject *object) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (scroll), priv->treeview); + gtk_container_add (GTK_CONTAINER (scroll), self->priv->treeview); gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 6); /* Treeview toolbar */ @@ -593,36 +590,36 @@ tpaw_irc_network_chooser_dialog_constructed (GObject *object) gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); /* Live search */ - priv->search = tpaw_live_search_new (priv->treeview); + self->priv->search = tpaw_live_search_new (self->priv->treeview); - gtk_box_pack_start (GTK_BOX (vbox), priv->search, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox), self->priv->search, FALSE, TRUE, 0); - priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new ( - GTK_TREE_MODEL (priv->store), NULL)); - gtk_tree_model_filter_set_visible_func (priv->filter, + self->priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new ( + GTK_TREE_MODEL (self->priv->store), NULL)); + gtk_tree_model_filter_set_visible_func (self->priv->filter, filter_visible_func, self, NULL); - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), - GTK_TREE_MODEL (priv->filter)); + gtk_tree_view_set_model (GTK_TREE_VIEW (self->priv->treeview), + GTK_TREE_MODEL (self->priv->filter)); - priv->search_sig = g_signal_connect (priv->search, "notify::text", - G_CALLBACK (search_text_notify_cb), self); + self->priv->search_sig = g_signal_connect (self->priv->search, + "notify::text", G_CALLBACK (search_text_notify_cb), self); - priv->activate_sig = g_signal_connect (priv->search, "activate", - G_CALLBACK (search_activate_cb), self); + self->priv->activate_sig = g_signal_connect (self->priv->search, + "activate", G_CALLBACK (search_activate_cb), self); /* Add buttons */ gtk_dialog_add_buttons (dialog, _("Reset _Networks List"), RESPONSE_RESET, NULL); - priv->select_button = gtk_dialog_add_button (dialog, + self->priv->select_button = gtk_dialog_add_button (dialog, C_("verb displayed on a button to select an IRC network", "Select"), GTK_RESPONSE_CLOSE); fill_store (self); - g_signal_connect (priv->treeview, "cursor-changed", + g_signal_connect (self->priv->treeview, "cursor-changed", G_CALLBACK (treeview_changed_cb), self); g_signal_connect (self, "response", @@ -637,34 +634,35 @@ tpaw_irc_network_chooser_dialog_constructed (GObject *object) static void tpaw_irc_network_chooser_dialog_dispose (GObject *object) { - TpawIrcNetworkManager *self = (TpawIrcNetworkManager *) object; - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); + TpawIrcNetworkChooserDialog *self = (TpawIrcNetworkChooserDialog *) object; - if (priv->search_sig != 0) + if (self->priv->search_sig != 0) { - g_signal_handler_disconnect (priv->search, priv->search_sig); - priv->search_sig = 0; + g_signal_handler_disconnect (self->priv->search, + self->priv->search_sig); + self->priv->search_sig = 0; } - if (priv->activate_sig != 0) + if (self->priv->activate_sig != 0) { - g_signal_handler_disconnect (priv->search, priv->activate_sig); - priv->activate_sig = 0; + g_signal_handler_disconnect (self->priv->search, + self->priv->activate_sig); + self->priv->activate_sig = 0; } - if (priv->search != NULL) + if (self->priv->search != NULL) { - tpaw_live_search_set_hook_widget (TPAW_LIVE_SEARCH (priv->search), - NULL); + tpaw_live_search_set_hook_widget ( + TPAW_LIVE_SEARCH (self->priv->search), NULL); - priv->search = NULL; + self->priv->search = NULL; } - tp_clear_object (&priv->settings); - tp_clear_object (&priv->network); - tp_clear_object (&priv->network_manager); - tp_clear_object (&priv->store); - tp_clear_object (&priv->filter); + tp_clear_object (&self->priv->settings); + tp_clear_object (&self->priv->network); + tp_clear_object (&self->priv->network_manager); + tp_clear_object (&self->priv->store); + tp_clear_object (&self->priv->filter); if (G_OBJECT_CLASS (tpaw_irc_network_chooser_dialog_parent_class)->dispose) G_OBJECT_CLASS (tpaw_irc_network_chooser_dialog_parent_class)->dispose (object); @@ -701,13 +699,10 @@ tpaw_irc_network_chooser_dialog_class_init (TpawIrcNetworkChooserDialogClass *kl static void tpaw_irc_network_chooser_dialog_init (TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv; - - priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, TpawIrcNetworkChooserDialogPriv); - self->priv = priv; - priv->network_manager = tpaw_irc_network_manager_dup_default (); + self->priv->network_manager = tpaw_irc_network_manager_dup_default (); } GtkWidget * @@ -726,16 +721,12 @@ TpawIrcNetwork * tpaw_irc_network_chooser_dialog_get_network ( TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); - - return priv->network; + return self->priv->network; } gboolean tpaw_irc_network_chooser_dialog_get_changed ( TpawIrcNetworkChooserDialog *self) { - TpawIrcNetworkChooserDialogPriv *priv = GET_PRIV (self); - - return priv->changed; + return self->priv->changed; } diff --git a/tp-account-widgets/tpaw-irc-network-chooser-dialog.h b/tp-account-widgets/tpaw-irc-network-chooser-dialog.h index 6549b7063..fb5edf1f8 100644 --- a/tp-account-widgets/tpaw-irc-network-chooser-dialog.h +++ b/tp-account-widgets/tpaw-irc-network-chooser-dialog.h @@ -42,11 +42,13 @@ G_BEGIN_DECLS G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, \ TpawIrcNetworkChooserDialogClass)) +typedef struct _TpawIrcNetworkChooserDialogPriv TpawIrcNetworkChooserDialogPriv; + typedef struct { GtkDialog parent; /*<private>*/ - gpointer priv; + TpawIrcNetworkChooserDialogPriv *priv; } TpawIrcNetworkChooserDialog; typedef struct { diff --git a/tp-account-widgets/tpaw-irc-network-chooser.c b/tp-account-widgets/tpaw-irc-network-chooser.c index 5339e1ba5..7181653ae 100644 --- a/tp-account-widgets/tpaw-irc-network-chooser.c +++ b/tp-account-widgets/tpaw-irc-network-chooser.c @@ -35,8 +35,6 @@ #define DEFAULT_IRC_PORT 6667 #define DEFAULT_IRC_SSL FALSE -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcNetworkChooser) - enum { PROP_SETTINGS = 1 }; @@ -48,14 +46,14 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -typedef struct { +struct _TpawIrcNetworkChooserPriv { TpawAccountSettings *settings; TpawIrcNetworkManager *network_manager; GtkWidget *dialog; /* Displayed network */ TpawIrcNetwork *network; -} TpawIrcNetworkChooserPriv; +}; G_DEFINE_TYPE (TpawIrcNetworkChooser, tpaw_irc_network_chooser, GTK_TYPE_BUTTON); @@ -66,12 +64,12 @@ tpaw_irc_network_chooser_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (object); + TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (object); switch (prop_id) { case PROP_SETTINGS: - priv->settings = g_value_dup_object (value); + self->priv->settings = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -85,12 +83,12 @@ tpaw_irc_network_chooser_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (object); + TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (object); switch (prop_id) { case PROP_SETTINGS: - g_value_set_object (value, priv->settings); + g_value_set_object (value, self->priv->settings); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -101,12 +99,10 @@ tpaw_irc_network_chooser_get_property (GObject *object, static void unset_server_params (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); - DEBUG ("Unset server, port and use-ssl"); - tpaw_account_settings_unset (priv->settings, "server"); - tpaw_account_settings_unset (priv->settings, "port"); - tpaw_account_settings_unset (priv->settings, "use-ssl"); + tpaw_account_settings_unset (self->priv->settings, "server"); + tpaw_account_settings_unset (self->priv->settings, "port"); + tpaw_account_settings_unset (self->priv->settings, "use-ssl"); } static gchar * @@ -146,18 +142,17 @@ dup_network_service (TpawIrcNetwork *network) static void update_server_params (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); GSList *servers; const gchar *charset; - g_assert (priv->network != NULL); + g_assert (self->priv->network != NULL); - charset = tpaw_irc_network_get_charset (priv->network); + charset = tpaw_irc_network_get_charset (self->priv->network); DEBUG ("Setting charset to %s", charset); - tpaw_account_settings_set (priv->settings, "charset", + tpaw_account_settings_set (self->priv->settings, "charset", g_variant_new_string (charset)); - servers = tpaw_irc_network_get_servers (priv->network); + servers = tpaw_irc_network_get_servers (self->priv->network); if (g_slist_length (servers) > 0) { /* set the first server as CM server */ @@ -174,19 +169,19 @@ update_server_params (TpawIrcNetworkChooser *self) NULL); DEBUG ("Setting server to %s", address); - tpaw_account_settings_set (priv->settings, "server", + tpaw_account_settings_set (self->priv->settings, "server", g_variant_new_string (address)); DEBUG ("Setting port to %u", port); - tpaw_account_settings_set (priv->settings, "port", + tpaw_account_settings_set (self->priv->settings, "port", g_variant_new_uint32 (port)); DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" ); - tpaw_account_settings_set (priv->settings, "use-ssl", + tpaw_account_settings_set (self->priv->settings, "use-ssl", g_variant_new_boolean (ssl)); /* Set Account.Service */ - service = dup_network_service (priv->network); + service = dup_network_service (self->priv->network); DEBUG ("Setting Service to %s", service); - tpaw_account_settings_set_service (priv->settings, service); + tpaw_account_settings_set_service (self->priv->settings, service); g_free (address); g_free (service); @@ -204,23 +199,20 @@ update_server_params (TpawIrcNetworkChooser *self) static void set_label (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); - - g_assert (priv->network != NULL); + g_assert (self->priv->network != NULL); gtk_button_set_label (GTK_BUTTON (self), - tpaw_irc_network_get_name (priv->network)); + tpaw_irc_network_get_name (self->priv->network)); } static void set_label_from_settings (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); gchar *server; - tp_clear_object (&priv->network); + tp_clear_object (&self->priv->network); - server = tpaw_account_settings_dup_string (priv->settings, "server"); + server = tpaw_account_settings_dup_string (self->priv->settings, "server"); if (server != NULL) { @@ -228,28 +220,30 @@ set_label_from_settings (TpawIrcNetworkChooser *self) gint port; gboolean ssl; - priv->network = tpaw_irc_network_manager_find_network_by_address ( - priv->network_manager, server); + self->priv->network = + tpaw_irc_network_manager_find_network_by_address ( + self->priv->network_manager, server); - if (priv->network != NULL) + if (self->priv->network != NULL) { /* The network is known */ - g_object_ref (priv->network); + g_object_ref (self->priv->network); set_label (self); return; } /* We don't have this network. Let's create it */ - port = tpaw_account_settings_get_uint32 (priv->settings, "port"); - ssl = tpaw_account_settings_get_boolean (priv->settings, + port = tpaw_account_settings_get_uint32 (self->priv->settings, "port"); + ssl = tpaw_account_settings_get_boolean (self->priv->settings, "use-ssl"); DEBUG ("Create a network %s", server); - priv->network = tpaw_irc_network_new (server); + self->priv->network = tpaw_irc_network_new (server); srv = tpaw_irc_server_new (server, port, ssl); - tpaw_irc_network_append_server (priv->network, srv); - tpaw_irc_network_manager_add (priv->network_manager, priv->network); + tpaw_irc_network_append_server (self->priv->network, srv); + tpaw_irc_network_manager_add (self->priv->network_manager, + self->priv->network); set_label (self); @@ -259,28 +253,29 @@ set_label_from_settings (TpawIrcNetworkChooser *self) } /* Set default network */ - priv->network = tpaw_irc_network_manager_find_network_by_address ( - priv->network_manager, DEFAULT_IRC_NETWORK); + self->priv->network = tpaw_irc_network_manager_find_network_by_address ( + self->priv->network_manager, DEFAULT_IRC_NETWORK); - if (priv->network == NULL) + if (self->priv->network == NULL) { /* Default network is not known, recreate it */ TpawIrcServer *srv; - priv->network = tpaw_irc_network_new (DEFAULT_IRC_NETWORK); + self->priv->network = tpaw_irc_network_new (DEFAULT_IRC_NETWORK); srv = tpaw_irc_server_new (DEFAULT_IRC_NETWORK, DEFAULT_IRC_PORT, DEFAULT_IRC_SSL); - tpaw_irc_network_append_server (priv->network, srv); - tpaw_irc_network_manager_add (priv->network_manager, priv->network); + tpaw_irc_network_append_server (self->priv->network, srv); + tpaw_irc_network_manager_add (self->priv->network_manager, + self->priv->network); g_object_unref (srv); } set_label (self); update_server_params (self); - g_object_ref (priv->network); + g_object_ref (self->priv->network); } static void @@ -288,9 +283,8 @@ dialog_response_cb (GtkDialog *dialog, gint response, TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); TpawIrcNetworkChooserDialog *chooser = - TPAW_IRC_NETWORK_CHOOSER_DIALOG (priv->dialog); + TPAW_IRC_NETWORK_CHOOSER_DIALOG (self->priv->dialog); if (response != GTK_RESPONSE_CLOSE && response != GTK_RESPONSE_DELETE_EVENT) @@ -298,9 +292,9 @@ dialog_response_cb (GtkDialog *dialog, if (tpaw_irc_network_chooser_dialog_get_changed (chooser)) { - tp_clear_object (&priv->network); + tp_clear_object (&self->priv->network); - priv->network = g_object_ref ( + self->priv->network = g_object_ref ( tpaw_irc_network_chooser_dialog_get_network (chooser)); update_server_params (self); @@ -309,40 +303,39 @@ dialog_response_cb (GtkDialog *dialog, g_signal_emit (self, signals[SIG_CHANGED], 0); } - gtk_widget_destroy (priv->dialog); - priv->dialog = NULL; + gtk_widget_destroy (self->priv->dialog); + self->priv->dialog = NULL; } static void clicked_cb (GtkButton *button, gpointer user_data) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (button); + TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (button); GtkWindow *window; - if (priv->dialog != NULL) + if (self->priv->dialog != NULL) goto out; window = tpaw_get_toplevel_window (GTK_WIDGET (button)); - priv->dialog = tpaw_irc_network_chooser_dialog_new (priv->settings, - priv->network, window); - gtk_widget_show_all (priv->dialog); + self->priv->dialog = tpaw_irc_network_chooser_dialog_new ( + self->priv->settings, self->priv->network, window); + gtk_widget_show_all (self->priv->dialog); - tp_g_signal_connect_object (priv->dialog, "response", + tp_g_signal_connect_object (self->priv->dialog, "response", G_CALLBACK (dialog_response_cb), button, 0); out: - tpaw_window_present (GTK_WINDOW (priv->dialog)); + tpaw_window_present (GTK_WINDOW (self->priv->dialog)); } static void tpaw_irc_network_chooser_constructed (GObject *object) { TpawIrcNetworkChooser *self = (TpawIrcNetworkChooser *) object; - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); - g_assert (priv->settings != NULL); + g_assert (self->priv->settings != NULL); set_label_from_settings (self); @@ -352,12 +345,11 @@ tpaw_irc_network_chooser_constructed (GObject *object) static void tpaw_irc_network_chooser_dispose (GObject *object) { - TpawIrcNetworkManager *self = (TpawIrcNetworkManager *) object; - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); + TpawIrcNetworkChooser *self = (TpawIrcNetworkChooser *) object; - tp_clear_object (&priv->settings); - tp_clear_object (&priv->network_manager); - tp_clear_object (&priv->network); + tp_clear_object (&self->priv->settings); + tp_clear_object (&self->priv->network_manager); + tp_clear_object (&self->priv->network); if (G_OBJECT_CLASS (tpaw_irc_network_chooser_parent_class)->dispose) G_OBJECT_CLASS (tpaw_irc_network_chooser_parent_class)->dispose (object); @@ -396,13 +388,10 @@ tpaw_irc_network_chooser_class_init (TpawIrcNetworkChooserClass *klass) static void tpaw_irc_network_chooser_init (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv; - - priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_NETWORK_CHOOSER, TpawIrcNetworkChooserPriv); - self->priv = priv; - priv->network_manager = tpaw_irc_network_manager_dup_default (); + self->priv->network_manager = tpaw_irc_network_manager_dup_default (); } GtkWidget * @@ -416,7 +405,5 @@ tpaw_irc_network_chooser_new (TpawAccountSettings *settings) TpawIrcNetwork * tpaw_irc_network_chooser_get_network (TpawIrcNetworkChooser *self) { - TpawIrcNetworkChooserPriv *priv = GET_PRIV (self); - - return priv->network; + return self->priv->network; } diff --git a/tp-account-widgets/tpaw-irc-network-chooser.h b/tp-account-widgets/tpaw-irc-network-chooser.h index cb664d09f..175679c37 100644 --- a/tp-account-widgets/tpaw-irc-network-chooser.h +++ b/tp-account-widgets/tpaw-irc-network-chooser.h @@ -42,11 +42,13 @@ G_BEGIN_DECLS G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK_CHOOSER, \ TpawIrcNetworkChooserClass)) +typedef struct _TpawIrcNetworkChooserPriv TpawIrcNetworkChooserPriv; + typedef struct { GtkButton parent; /*<private>*/ - gpointer priv; + TpawIrcNetworkChooserPriv *priv; } TpawIrcNetworkChooser; typedef struct { diff --git a/tp-account-widgets/tpaw-irc-network-manager.c b/tp-account-widgets/tpaw-irc-network-manager.c index 12c73d6d3..e7f873844 100644 --- a/tp-account-widgets/tpaw-irc-network-manager.c +++ b/tp-account-widgets/tpaw-irc-network-manager.c @@ -33,8 +33,7 @@ #define IRC_NETWORKS_FILENAME "irc-networks.xml" #define SAVE_TIMER 4 -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcNetworkManager) -typedef struct { +struct _TpawIrcNetworkManagerPriv { GHashTable *networks; gchar *global_file; @@ -47,7 +46,7 @@ typedef struct { gboolean loading; /* source id of the autosave timer */ gint save_timer_id; -} TpawIrcNetworkManagerPriv; +}; /* properties */ enum @@ -75,15 +74,14 @@ tpaw_irc_network_manager_get_property (GObject *object, GParamSpec *pspec) { TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_GLOBAL_FILE: - g_value_set_string (value, priv->global_file); + g_value_set_string (value, self->priv->global_file); break; case PROP_USER_FILE: - g_value_set_string (value, priv->user_file); + g_value_set_string (value, self->priv->user_file); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -98,17 +96,16 @@ tpaw_irc_network_manager_set_property (GObject *object, GParamSpec *pspec) { TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_GLOBAL_FILE: - g_free (priv->global_file); - priv->global_file = g_value_dup_string (value); + g_free (self->priv->global_file); + self->priv->global_file = g_value_dup_string (value); break; case PROP_USER_FILE: - g_free (priv->user_file); - priv->user_file = g_value_dup_string (value); + g_free (self->priv->user_file); + self->priv->user_file = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -138,22 +135,21 @@ static void tpaw_irc_network_manager_finalize (GObject *object) { TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - if (priv->save_timer_id > 0) + if (self->priv->save_timer_id > 0) { - g_source_remove (priv->save_timer_id); + g_source_remove (self->priv->save_timer_id); } - if (priv->have_to_save) + if (self->priv->have_to_save) { irc_network_manager_file_save (self); } - g_free (priv->global_file); - g_free (priv->user_file); + g_free (self->priv->global_file); + g_free (self->priv->user_file); - g_hash_table_unref (priv->networks); + g_hash_table_unref (self->priv->networks); G_OBJECT_CLASS (tpaw_irc_network_manager_parent_class)->finalize (object); } @@ -161,19 +157,17 @@ tpaw_irc_network_manager_finalize (GObject *object) static void tpaw_irc_network_manager_init (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_NETWORK_MANAGER, TpawIrcNetworkManagerPriv); - self->priv = priv; - - priv->networks = g_hash_table_new_full (g_str_hash, g_str_equal, + self->priv->networks = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); - priv->last_id = 0; + self->priv->last_id = 0; - priv->have_to_save = FALSE; - priv->loading = FALSE; - priv->save_timer_id = 0; + self->priv->have_to_save = FALSE; + self->priv->loading = FALSE; + self->priv->save_timer_id = 0; } static void @@ -243,9 +237,7 @@ tpaw_irc_network_manager_new (const gchar *global_file, static gboolean save_timeout (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - priv->save_timer_id = 0; + self->priv->save_timer_id = 0; irc_network_manager_file_save (self); return FALSE; @@ -254,14 +246,12 @@ save_timeout (TpawIrcNetworkManager *self) static void reset_save_timeout (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - if (priv->save_timer_id > 0) + if (self->priv->save_timer_id > 0) { - g_source_remove (priv->save_timer_id); + g_source_remove (self->priv->save_timer_id); } - priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER, + self->priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER, (GSourceFunc) save_timeout, self); } @@ -269,13 +259,11 @@ static void network_modified (TpawIrcNetwork *network, TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - network->user_defined = TRUE; - if (!priv->loading) + if (!self->priv->loading) { - priv->have_to_save = TRUE; + self->priv->have_to_save = TRUE; reset_save_timeout (self); } } @@ -285,9 +273,8 @@ add_network (TpawIrcNetworkManager *self, TpawIrcNetwork *network, const gchar *id) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - g_hash_table_insert (priv->networks, g_strdup (id), g_object_ref (network)); + g_hash_table_insert (self->priv->networks, g_strdup (id), + g_object_ref (network)); g_signal_connect (network, "modified", G_CALLBACK (network_modified), self); } @@ -304,23 +291,20 @@ void tpaw_irc_network_manager_add (TpawIrcNetworkManager *self, TpawIrcNetwork *network) { - TpawIrcNetworkManagerPriv *priv; gchar *id = NULL; g_return_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self)); g_return_if_fail (TPAW_IS_IRC_NETWORK (network)); - priv = GET_PRIV (self); - /* generate an id for this network */ do { g_free (id); - id = g_strdup_printf ("id%u", ++priv->last_id); - } while (g_hash_table_lookup (priv->networks, id) != NULL && - priv->last_id < G_MAXUINT); + id = g_strdup_printf ("id%u", ++self->priv->last_id); + } while (g_hash_table_lookup (self->priv->networks, id) != NULL && + self->priv->last_id < G_MAXUINT); - if (priv->last_id == G_MAXUINT) + if (self->priv->last_id == G_MAXUINT) { DEBUG ("Can't add network: too many networks using a similar ID"); return; @@ -331,7 +315,7 @@ tpaw_irc_network_manager_add (TpawIrcNetworkManager *self, network->user_defined = TRUE; add_network (self, network, id); - priv->have_to_save = TRUE; + self->priv->have_to_save = TRUE; reset_save_timeout (self); g_free (id); @@ -349,17 +333,13 @@ void tpaw_irc_network_manager_remove (TpawIrcNetworkManager *self, TpawIrcNetwork *network) { - TpawIrcNetworkManagerPriv *priv; - g_return_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self)); g_return_if_fail (TPAW_IS_IRC_NETWORK (network)); - priv = GET_PRIV (self); - network->user_defined = TRUE; network->dropped = TRUE; - priv->have_to_save = TRUE; + self->priv->have_to_save = TRUE; reset_save_timeout (self); } @@ -389,21 +369,18 @@ static GSList * get_network_list (TpawIrcNetworkManager *self, gboolean get_active) { - TpawIrcNetworkManagerPriv *priv; GSList *irc_networks = NULL; g_return_val_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self), NULL); - priv = GET_PRIV (self); - if (get_active) { - g_hash_table_foreach (priv->networks, + g_hash_table_foreach (self->priv->networks, (GHFunc) append_active_networks_to_list, &irc_networks); } else { - g_hash_table_foreach (priv->networks, + g_hash_table_foreach (self->priv->networks, (GHFunc) append_dropped_networks_to_list, &irc_networks); } @@ -447,49 +424,44 @@ tpaw_irc_network_manager_get_dropped_networks (TpawIrcNetworkManager *self) static void load_global_file (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - if (priv->global_file == NULL) + if (self->priv->global_file == NULL) return; - if (!g_file_test (priv->global_file, G_FILE_TEST_EXISTS)) + if (!g_file_test (self->priv->global_file, G_FILE_TEST_EXISTS)) { - DEBUG ("Global networks file %s doesn't exist", priv->global_file); + DEBUG ("Global networks file %s doesn't exist", + self->priv->global_file); return; } - irc_network_manager_file_parse (self, priv->global_file, FALSE); + irc_network_manager_file_parse (self, self->priv->global_file, FALSE); } static void load_user_file (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - if (priv->user_file == NULL) + if (self->priv->user_file == NULL) return; - if (!g_file_test (priv->user_file, G_FILE_TEST_EXISTS)) + if (!g_file_test (self->priv->user_file, G_FILE_TEST_EXISTS)) { - DEBUG ("User networks file %s doesn't exist", priv->global_file); + DEBUG ("User networks file %s doesn't exist", self->priv->global_file); return; } - irc_network_manager_file_parse (self, priv->user_file, TRUE); + irc_network_manager_file_parse (self, self->priv->user_file, TRUE); } static void irc_network_manager_load_servers (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); - - priv->loading = TRUE; + self->priv->loading = TRUE; load_global_file (self); load_user_file (self); - priv->loading = FALSE; - priv->have_to_save = FALSE; + self->priv->loading = FALSE; + self->priv->have_to_save = FALSE; } static void @@ -545,7 +517,6 @@ irc_network_manager_parse_irc_network (TpawIrcNetworkManager *self, xmlNodePtr node, gboolean user_defined) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; xmlNodePtr child; gchar *str; @@ -559,7 +530,7 @@ irc_network_manager_parse_irc_network (TpawIrcNetworkManager *self, DEBUG ("the 'dropped' attribute shouldn't be used in the global file"); } - network = g_hash_table_lookup (priv->networks, id); + network = g_hash_table_lookup (self->priv->networks, id); if (network != NULL) { network->dropped = TRUE; @@ -732,11 +703,10 @@ write_network_to_xml (const gchar *id, static gboolean irc_network_manager_file_save (TpawIrcNetworkManager *self) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); xmlDocPtr doc; xmlNodePtr root; - if (priv->user_file == NULL) + if (self->priv->user_file == NULL) { DEBUG ("can't save: no user file defined"); return FALSE; @@ -748,17 +718,18 @@ irc_network_manager_file_save (TpawIrcNetworkManager *self) root = xmlNewNode (NULL, (const xmlChar *) "networks"); xmlDocSetRootElement (doc, root); - g_hash_table_foreach (priv->networks, (GHFunc) write_network_to_xml, root); + g_hash_table_foreach (self->priv->networks, + (GHFunc) write_network_to_xml, root); /* Make sure the XML is indented properly */ xmlIndentTreeOutput = 1; - xmlSaveFormatFileEnc (priv->user_file, doc, "utf-8", 1); + xmlSaveFormatFileEnc (self->priv->user_file, doc, "utf-8", 1); xmlFreeDoc (doc); xmlMemoryDump (); - priv->have_to_save = FALSE; + self->priv->have_to_save = FALSE; return TRUE; } @@ -808,12 +779,11 @@ tpaw_irc_network_manager_find_network_by_address ( TpawIrcNetworkManager *self, const gchar *address) { - TpawIrcNetworkManagerPriv *priv = GET_PRIV (self); TpawIrcNetwork *network; g_return_val_if_fail (address != NULL, NULL); - network = g_hash_table_find (priv->networks, + network = g_hash_table_find (self->priv->networks, (GHRFunc) find_network_by_address, (gchar *) address); return network; diff --git a/tp-account-widgets/tpaw-irc-network-manager.h b/tp-account-widgets/tpaw-irc-network-manager.h index feb6e28ab..b44209a02 100644 --- a/tp-account-widgets/tpaw-irc-network-manager.h +++ b/tp-account-widgets/tpaw-irc-network-manager.h @@ -28,12 +28,15 @@ G_BEGIN_DECLS typedef struct _TpawIrcNetworkManager TpawIrcNetworkManager; +typedef struct _TpawIrcNetworkManagerPriv TpawIrcNetworkManagerPriv; typedef struct _TpawIrcNetworkManagerClass TpawIrcNetworkManagerClass; struct _TpawIrcNetworkManager { GObject parent; - gpointer priv; + + /*<private>*/ + TpawIrcNetworkManagerPriv *priv; }; struct _TpawIrcNetworkManagerClass diff --git a/tp-account-widgets/tpaw-irc-network.c b/tp-account-widgets/tpaw-irc-network.c index a46cbb69d..1aa63309f 100644 --- a/tp-account-widgets/tpaw-irc-network.c +++ b/tp-account-widgets/tpaw-irc-network.c @@ -22,14 +22,14 @@ #include "tpaw-irc-network.h" #include "empathy-utils.h" +#include "tpaw-utils.h" -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcNetwork) -typedef struct +struct _TpawIrcNetworkPriv { gchar *name; gchar *charset; GSList *servers; -} TpawIrcNetworkPriv; +}; /* properties */ enum @@ -64,15 +64,14 @@ tpaw_irc_network_get_property (GObject *object, GParamSpec *pspec) { TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - TpawIrcNetworkPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_NAME: - g_value_set_string (value, priv->name); + g_value_set_string (value, self->priv->name); break; case PROP_CHARSET: - g_value_set_string (value, priv->charset); + g_value_set_string (value, self->priv->charset); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -87,23 +86,22 @@ tpaw_irc_network_set_property (GObject *object, GParamSpec *pspec) { TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - TpawIrcNetworkPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_NAME: - if (tp_strdiff (priv->name, g_value_get_string (value))) + if (tp_strdiff (self->priv->name, g_value_get_string (value))) { - g_free (priv->name); - priv->name = g_value_dup_string (value); + g_free (self->priv->name); + self->priv->name = g_value_dup_string (value); g_signal_emit (object, signals[MODIFIED], 0); } break; case PROP_CHARSET: - if (tp_strdiff (priv->charset, g_value_get_string (value))) + if (tp_strdiff (self->priv->charset, g_value_get_string (value))) { - g_free (priv->charset); - priv->charset = g_value_dup_string (value); + g_free (self->priv->charset); + self->priv->charset = g_value_dup_string (value); g_signal_emit (object, signals[MODIFIED], 0); } break; @@ -117,10 +115,9 @@ static void tpaw_irc_network_dispose (GObject *object) { TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - TpawIrcNetworkPriv *priv = GET_PRIV (self); GSList *l; - for (l = priv->servers; l != NULL; l = g_slist_next (l)) + for (l = self->priv->servers; l != NULL; l = g_slist_next (l)) { g_signal_handlers_disconnect_by_func (l->data, G_CALLBACK (server_modified_cb), self); @@ -134,11 +131,10 @@ static void tpaw_irc_network_finalize (GObject *object) { TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - TpawIrcNetworkPriv *priv = GET_PRIV (self); - g_slist_free (priv->servers); - g_free (priv->name); - g_free (priv->charset); + g_slist_free (self->priv->servers); + g_free (self->priv->name); + g_free (self->priv->charset); G_OBJECT_CLASS (tpaw_irc_network_parent_class)->finalize (object); } @@ -146,12 +142,10 @@ tpaw_irc_network_finalize (GObject *object) static void tpaw_irc_network_init (TpawIrcNetwork *self) { - TpawIrcNetworkPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_IRC_NETWORK, TpawIrcNetworkPriv); - - self->priv = priv; + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_NETWORK, + TpawIrcNetworkPriv); - priv->servers = NULL; + self->priv->servers = NULL; self->user_defined = TRUE; self->dropped = FALSE; @@ -260,13 +254,11 @@ tpaw_irc_network_new (const gchar *name) GSList * tpaw_irc_network_get_servers (TpawIrcNetwork *self) { - TpawIrcNetworkPriv *priv; GSList *servers = NULL, *l; g_return_val_if_fail (TPAW_IS_IRC_NETWORK (self), NULL); - priv = GET_PRIV (self); - for (l = priv->servers; l != NULL; l = g_slist_next (l)) + for (l = self->priv->servers; l != NULL; l = g_slist_next (l)) { servers = g_slist_prepend (servers, g_object_ref (l->data)); } @@ -287,16 +279,11 @@ void tpaw_irc_network_append_server (TpawIrcNetwork *self, TpawIrcServer *server) { - TpawIrcNetworkPriv *priv; - g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); + g_return_if_fail (g_slist_find (self->priv->servers, server) == NULL); - priv = GET_PRIV (self); - - g_return_if_fail (g_slist_find (priv->servers, server) == NULL); - - priv->servers = g_slist_append (priv->servers, g_object_ref (server)); + self->priv->servers = g_slist_append (self->priv->servers, g_object_ref (server)); g_signal_connect (server, "modified", G_CALLBACK (server_modified_cb), self); @@ -316,20 +303,17 @@ void tpaw_irc_network_remove_server (TpawIrcNetwork *self, TpawIrcServer *server) { - TpawIrcNetworkPriv *priv; GSList *l; g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); - priv = GET_PRIV (self); - - l = g_slist_find (priv->servers, server); + l = g_slist_find (self->priv->servers, server); if (l == NULL) return; g_object_unref (l->data); - priv->servers = g_slist_delete_link (priv->servers, l); + self->priv->servers = g_slist_delete_link (self->priv->servers, l); g_signal_handlers_disconnect_by_func (server, G_CALLBACK (server_modified_cb), self); @@ -353,20 +337,17 @@ tpaw_irc_network_set_server_position (TpawIrcNetwork *self, TpawIrcServer *server, gint pos) { - TpawIrcNetworkPriv *priv; GSList *l; g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); - priv = GET_PRIV (self); - - l = g_slist_find (priv->servers, server); + l = g_slist_find (self->priv->servers, server); if (l == NULL) return; - priv->servers = g_slist_delete_link (priv->servers, l); - priv->servers = g_slist_insert (priv->servers, server, pos); + self->priv->servers = g_slist_delete_link (self->priv->servers, l); + self->priv->servers = g_slist_insert (self->priv->servers, server, pos); g_signal_emit (self, signals[MODIFIED], 0); } @@ -374,15 +355,11 @@ tpaw_irc_network_set_server_position (TpawIrcNetwork *self, const gchar * tpaw_irc_network_get_name (TpawIrcNetwork *self) { - TpawIrcNetworkPriv *priv = GET_PRIV (self); - - return priv->name; + return self->priv->name; } const gchar * tpaw_irc_network_get_charset (TpawIrcNetwork *self) { - TpawIrcNetworkPriv *priv = GET_PRIV (self); - - return priv->charset; + return self->priv->charset; } diff --git a/tp-account-widgets/tpaw-irc-network.h b/tp-account-widgets/tpaw-irc-network.h index 9fb414f32..d305319fc 100644 --- a/tp-account-widgets/tpaw-irc-network.h +++ b/tp-account-widgets/tpaw-irc-network.h @@ -28,12 +28,13 @@ G_BEGIN_DECLS typedef struct _TpawIrcNetwork TpawIrcNetwork; +typedef struct _TpawIrcNetworkPriv TpawIrcNetworkPriv; typedef struct _TpawIrcNetworkClass TpawIrcNetworkClass; struct _TpawIrcNetwork { GObject parent; - gpointer priv; + TpawIrcNetworkPriv *priv; gboolean user_defined; gboolean dropped; diff --git a/tp-account-widgets/tpaw-irc-server.c b/tp-account-widgets/tpaw-irc-server.c index aa9b5332a..f459448cb 100644 --- a/tp-account-widgets/tpaw-irc-server.c +++ b/tp-account-widgets/tpaw-irc-server.c @@ -22,14 +22,14 @@ #include "tpaw-irc-server.h" #include "empathy-utils.h" +#include "tpaw-utils.h" -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawIrcServer) -typedef struct +struct _TpawIrcServerPriv { gchar *address; guint port; gboolean ssl; -} TpawIrcServerPriv; +}; /* properties */ enum @@ -58,18 +58,17 @@ tpaw_irc_server_get_property (GObject *object, GParamSpec *pspec) { TpawIrcServer *self = TPAW_IRC_SERVER (object); - TpawIrcServerPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_ADDRESS: - g_value_set_string (value, priv->address); + g_value_set_string (value, self->priv->address); break; case PROP_PORT: - g_value_set_uint (value, priv->port); + g_value_set_uint (value, self->priv->port); break; case PROP_SSL: - g_value_set_boolean (value, priv->ssl); + g_value_set_boolean (value, self->priv->ssl); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -84,29 +83,28 @@ tpaw_irc_server_set_property (GObject *object, GParamSpec *pspec) { TpawIrcServer *self = TPAW_IRC_SERVER (object); - TpawIrcServerPriv *priv = GET_PRIV (self); switch (property_id) { case PROP_ADDRESS: - if (tp_strdiff (priv->address, g_value_get_string (value))) + if (tp_strdiff (self->priv->address, g_value_get_string (value))) { - g_free (priv->address); - priv->address = g_value_dup_string (value); + g_free (self->priv->address); + self->priv->address = g_value_dup_string (value); g_signal_emit (object, signals[MODIFIED], 0); } break; case PROP_PORT: - if (priv->port != g_value_get_uint (value)) + if (self->priv->port != g_value_get_uint (value)) { - priv->port = g_value_get_uint (value); + self->priv->port = g_value_get_uint (value); g_signal_emit (object, signals[MODIFIED], 0); } break; case PROP_SSL: - if (priv->ssl != g_value_get_boolean (value)) + if (self->priv->ssl != g_value_get_boolean (value)) { - priv->ssl = g_value_get_boolean (value); + self->priv->ssl = g_value_get_boolean (value); g_signal_emit (object, signals[MODIFIED], 0); } break; @@ -120,9 +118,8 @@ static void tpaw_irc_server_finalize (GObject *object) { TpawIrcServer *self = TPAW_IRC_SERVER (object); - TpawIrcServerPriv *priv = GET_PRIV (self); - g_free (priv->address); + g_free (self->priv->address); G_OBJECT_CLASS (tpaw_irc_server_parent_class)->finalize (object); } @@ -130,10 +127,8 @@ tpaw_irc_server_finalize (GObject *object) static void tpaw_irc_server_init (TpawIrcServer *self) { - TpawIrcServerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_IRC_SERVER, TpawIrcServerPriv); - - self->priv = priv; + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_SERVER, + TpawIrcServerPriv); } static void diff --git a/tp-account-widgets/tpaw-irc-server.h b/tp-account-widgets/tpaw-irc-server.h index ef9e0c872..046ae4775 100644 --- a/tp-account-widgets/tpaw-irc-server.h +++ b/tp-account-widgets/tpaw-irc-server.h @@ -26,12 +26,13 @@ G_BEGIN_DECLS typedef struct _TpawIrcServer TpawIrcServer; +typedef struct _TpawIrcServerPriv TpawIrcServerPriv; typedef struct _TpawIrcServerClass TpawIrcServerClass; struct _TpawIrcServer { GObject parent; - gpointer priv; + TpawIrcServerPriv *priv; }; struct _TpawIrcServerClass diff --git a/tp-account-widgets/tpaw-live-search.c b/tp-account-widgets/tpaw-live-search.c index 059eac39c..e86717e50 100644 --- a/tp-account-widgets/tpaw-live-search.c +++ b/tp-account-widgets/tpaw-live-search.c @@ -29,15 +29,13 @@ G_DEFINE_TYPE (TpawLiveSearch, tpaw_live_search, GTK_TYPE_HBOX) -#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawLiveSearch) - -typedef struct +struct _TpawLiveSearchPriv { GtkWidget *search_entry; GtkWidget *hook_widget; GPtrArray *stripped_words; -} TpawLiveSearchPriv; +}; enum { @@ -285,7 +283,6 @@ live_search_text_changed (GtkEntry *entry, gpointer user_data) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - TpawLiveSearchPriv *priv = GET_PRIV (self); const gchar *text; text = gtk_entry_get_text (entry); @@ -295,10 +292,10 @@ live_search_text_changed (GtkEntry *entry, else gtk_widget_show (GTK_WIDGET (self)); - if (priv->stripped_words != NULL) - g_ptr_array_unref (priv->stripped_words); + if (self->priv->stripped_words != NULL) + g_ptr_array_unref (self->priv->stripped_words); - priv->stripped_words = tpaw_live_search_strip_utf8_string (text); + self->priv->stripped_words = tpaw_live_search_strip_utf8_string (text); g_object_notify (G_OBJECT (self), "text"); } @@ -320,7 +317,6 @@ live_search_key_press_event_cb (GtkWidget *widget, gpointer user_data) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - TpawLiveSearchPriv *priv = GET_PRIV (self); GdkEvent *new_event; gboolean ret; @@ -364,16 +360,16 @@ live_search_key_press_event_cb (GtkWidget *widget, return FALSE; /* realize the widget if it is not realized yet */ - gtk_widget_realize (priv->search_entry); - if (!gtk_widget_has_focus (priv->search_entry)) + gtk_widget_realize (self->priv->search_entry); + if (!gtk_widget_has_focus (self->priv->search_entry)) { - gtk_widget_grab_focus (priv->search_entry); - gtk_editable_set_position (GTK_EDITABLE (priv->search_entry), -1); + gtk_widget_grab_focus (self->priv->search_entry); + gtk_editable_set_position (GTK_EDITABLE (self->priv->search_entry), -1); } /* forward the event to the search entry */ new_event = gdk_event_copy ((GdkEvent *) event); - ret = gtk_widget_event (priv->search_entry, new_event); + ret = gtk_widget_event (self->priv->search_entry, new_event); gdk_event_free (new_event); return ret; @@ -389,17 +385,15 @@ live_search_entry_activate_cb (GtkEntry *entry, static void live_search_release_hook_widget (TpawLiveSearch *self) { - TpawLiveSearchPriv *priv = GET_PRIV (self); - /* remove old handlers if old source was not null */ - if (priv->hook_widget != NULL) + if (self->priv->hook_widget != NULL) { - g_signal_handlers_disconnect_by_func (priv->hook_widget, + g_signal_handlers_disconnect_by_func (self->priv->hook_widget, live_search_key_press_event_cb, self); - g_signal_handlers_disconnect_by_func (priv->hook_widget, + g_signal_handlers_disconnect_by_func (self->priv->hook_widget, live_search_hook_widget_destroy_cb, self); - g_object_unref (priv->hook_widget); - priv->hook_widget = NULL; + g_object_unref (self->priv->hook_widget); + self->priv->hook_widget = NULL; } } @@ -429,10 +423,9 @@ static void live_search_finalize (GObject *obj) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (obj); - TpawLiveSearchPriv *priv = GET_PRIV (self); - if (priv->stripped_words != NULL) - g_ptr_array_unref (priv->stripped_words); + if (self->priv->stripped_words != NULL) + g_ptr_array_unref (self->priv->stripped_words); if (G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize != NULL) G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize (obj); @@ -485,7 +478,6 @@ static void live_search_unmap (GtkWidget *widget) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - TpawLiveSearchPriv *priv = GET_PRIV (self); GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->unmap (widget); @@ -494,20 +486,19 @@ live_search_unmap (GtkWidget *widget) * won't be shown. */ gtk_widget_hide (widget); - gtk_entry_set_text (GTK_ENTRY (priv->search_entry), ""); + gtk_entry_set_text (GTK_ENTRY (self->priv->search_entry), ""); - if (priv->hook_widget != NULL) - gtk_widget_grab_focus (priv->hook_widget); + if (self->priv->hook_widget != NULL) + gtk_widget_grab_focus (self->priv->hook_widget); } static void live_search_show (GtkWidget *widget) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - TpawLiveSearchPriv *priv = GET_PRIV (self); - if (!gtk_widget_has_focus (priv->search_entry)) - gtk_widget_grab_focus (priv->search_entry); + if (!gtk_widget_has_focus (self->priv->search_entry)) + gtk_widget_grab_focus (self->priv->search_entry); GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->show (widget); } @@ -516,12 +507,11 @@ static void live_search_grab_focus (GtkWidget *widget) { TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - TpawLiveSearchPriv *priv = GET_PRIV (self); - if (!gtk_widget_has_focus (priv->search_entry)) + if (!gtk_widget_has_focus (self->priv->search_entry)) { - gtk_widget_grab_focus (priv->search_entry); - gtk_editable_set_position (GTK_EDITABLE (priv->search_entry), -1); + gtk_widget_grab_focus (self->priv->search_entry); + gtk_editable_set_position (GTK_EDITABLE (self->priv->search_entry), -1); } } @@ -574,35 +564,32 @@ tpaw_live_search_class_init (TpawLiveSearchClass *klass) static void tpaw_live_search_init (TpawLiveSearch *self) { - TpawLiveSearchPriv *priv = - G_TYPE_INSTANCE_GET_PRIVATE ((self), TPAW_TYPE_LIVE_SEARCH, + self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), TPAW_TYPE_LIVE_SEARCH, TpawLiveSearchPriv); gtk_widget_set_no_show_all (GTK_WIDGET (self), TRUE); - priv->search_entry = gtk_entry_new (); - gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->search_entry), + self->priv->search_entry = gtk_entry_new (); + gtk_entry_set_icon_from_stock (GTK_ENTRY (self->priv->search_entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLOSE); - gtk_entry_set_icon_activatable (GTK_ENTRY (priv->search_entry), + gtk_entry_set_icon_activatable (GTK_ENTRY (self->priv->search_entry), GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->search_entry), + gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->search_entry), GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_widget_show (priv->search_entry); + gtk_widget_show (self->priv->search_entry); - gtk_box_pack_start (GTK_BOX (self), priv->search_entry, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (self), self->priv->search_entry, TRUE, TRUE, 0); - g_signal_connect (priv->search_entry, "icon_release", + g_signal_connect (self->priv->search_entry, "icon_release", G_CALLBACK (live_search_close_pressed), self); - g_signal_connect (priv->search_entry, "changed", + g_signal_connect (self->priv->search_entry, "changed", G_CALLBACK (live_search_text_changed), self); - g_signal_connect (priv->search_entry, "key-press-event", + g_signal_connect (self->priv->search_entry, "key-press-event", G_CALLBACK (live_search_entry_key_pressed_cb), self); - g_signal_connect (priv->search_entry, "activate", + g_signal_connect (self->priv->search_entry, "activate", G_CALLBACK (live_search_entry_activate_cb), self); - priv->hook_widget = NULL; - - self->priv = priv; + self->priv->hook_widget = NULL; } GtkWidget * @@ -620,35 +607,29 @@ tpaw_live_search_new (GtkWidget *hook) GtkWidget * tpaw_live_search_get_hook_widget (TpawLiveSearch *self) { - TpawLiveSearchPriv *priv = GET_PRIV (self); - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL); - return priv->hook_widget; + return self->priv->hook_widget; } void tpaw_live_search_set_hook_widget (TpawLiveSearch *self, GtkWidget *hook) { - TpawLiveSearchPriv *priv; - g_return_if_fail (TPAW_IS_LIVE_SEARCH (self)); g_return_if_fail (hook == NULL || GTK_IS_WIDGET (hook)); - priv = GET_PRIV (self); - /* release the actual widget */ live_search_release_hook_widget (self); /* connect handlers if new source is not null */ if (hook != NULL) { - priv->hook_widget = g_object_ref (hook); - g_signal_connect (priv->hook_widget, "key-press-event", + self->priv->hook_widget = g_object_ref (hook); + g_signal_connect (self->priv->hook_widget, "key-press-event", G_CALLBACK (live_search_key_press_event_cb), self); - g_signal_connect (priv->hook_widget, "destroy", + g_signal_connect (self->priv->hook_widget, "destroy", G_CALLBACK (live_search_hook_widget_destroy_cb), self); } @@ -657,23 +638,19 @@ tpaw_live_search_set_hook_widget (TpawLiveSearch *self, const gchar * tpaw_live_search_get_text (TpawLiveSearch *self) { - TpawLiveSearchPriv *priv = GET_PRIV (self); - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL); - return gtk_entry_get_text (GTK_ENTRY (priv->search_entry)); + return gtk_entry_get_text (GTK_ENTRY (self->priv->search_entry)); } void tpaw_live_search_set_text (TpawLiveSearch *self, const gchar *text) { - TpawLiveSearchPriv *priv = GET_PRIV (self); - g_return_if_fail (TPAW_IS_LIVE_SEARCH (self)); g_return_if_fail (text != NULL); - gtk_entry_set_text (GTK_ENTRY (priv->search_entry), text); + gtk_entry_set_text (GTK_ENTRY (self->priv->search_entry), text); } /** @@ -696,13 +673,9 @@ gboolean tpaw_live_search_match (TpawLiveSearch *self, const gchar *string) { - TpawLiveSearchPriv *priv; - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), FALSE); - priv = GET_PRIV (self); - - return tpaw_live_search_match_words (string, priv->stripped_words); + return tpaw_live_search_match_words (string, self->priv->stripped_words); } gboolean @@ -723,7 +696,5 @@ tpaw_live_search_match_string (const gchar *string, GPtrArray * tpaw_live_search_get_words (TpawLiveSearch *self) { - TpawLiveSearchPriv *priv = GET_PRIV (self); - - return priv->stripped_words; + return self->priv->stripped_words; } diff --git a/tp-account-widgets/tpaw-live-search.h b/tp-account-widgets/tpaw-live-search.h index 50aad9202..0772d9d91 100644 --- a/tp-account-widgets/tpaw-live-search.h +++ b/tp-account-widgets/tpaw-live-search.h @@ -36,13 +36,14 @@ G_BEGIN_DECLS #define TPAW_LIVE_SEARCH_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_LIVE_SEARCH, TpawLiveSearchClass)) typedef struct _TpawLiveSearch TpawLiveSearch; +typedef struct _TpawLiveSearchPriv TpawLiveSearchPriv; typedef struct _TpawLiveSearchClass TpawLiveSearchClass; struct _TpawLiveSearch { GtkHBox parent; /*<private>*/ - gpointer priv; + TpawLiveSearchPriv *priv; }; struct _TpawLiveSearchClass { |