Commit b73b48a8 authored by Jonny Lamb's avatar Jonny Lamb Committed by Xavier Claessens

Small coding style and name changes.

Signed-off-by: 's avatarJonny Lamb <jonny.lamb@collabora.co.uk>

svn path=/trunk/; revision=2336
parent 385d4541
...@@ -46,8 +46,7 @@ typedef struct ...@@ -46,8 +46,7 @@ typedef struct
EmpathyContactListStore *store; EmpathyContactListStore *store;
} EmpathyContactSelectorPriv; } EmpathyContactSelectorPriv;
static void changed_cb (GtkComboBox *widget, gpointer data); static void contact_selector_changed_cb (GtkComboBox *widget, gpointer data);
EmpathyContact * EmpathyContact *
empathy_contact_selector_get_selected (EmpathyContactSelector *selector) empathy_contact_selector_get_selected (EmpathyContactSelector *selector)
...@@ -67,9 +66,8 @@ empathy_contact_selector_get_selected (EmpathyContactSelector *selector) ...@@ -67,9 +66,8 @@ empathy_contact_selector_get_selected (EmpathyContactSelector *selector)
return contact; return contact;
} }
static guint static guint
get_number_online_contacts (GtkTreeStore *store) contact_selector_get_number_online_contacts (GtkTreeStore *store)
{ {
GtkTreePath *path; GtkTreePath *path;
GtkTreeIter tmp_iter; GtkTreeIter tmp_iter;
...@@ -95,10 +93,9 @@ get_number_online_contacts (GtkTreeStore *store) ...@@ -95,10 +93,9 @@ get_number_online_contacts (GtkTreeStore *store)
return number_online_contacts; return number_online_contacts;
} }
static gboolean static gboolean
get_iter_for_blank_contact (GtkTreeStore *store, contact_selector_get_iter_for_blank_contact (GtkTreeStore *store,
GtkTreeIter *blank_iter) GtkTreeIter *blank_iter)
{ {
GtkTreePath *path; GtkTreePath *path;
GtkTreeIter tmp_iter; GtkTreeIter tmp_iter;
...@@ -128,9 +125,8 @@ get_iter_for_blank_contact (GtkTreeStore *store, ...@@ -128,9 +125,8 @@ get_iter_for_blank_contact (GtkTreeStore *store,
return is_present; return is_present;
} }
static void static void
add_blank_contact (EmpathyContactSelector *selector) contact_selector_add_blank_contact (EmpathyContactSelector *selector)
{ {
EmpathyContactSelectorPriv *priv = GET_PRIV (selector); EmpathyContactSelectorPriv *priv = GET_PRIV (selector);
GtkTreeIter blank_iter; GtkTreeIter blank_iter;
...@@ -140,27 +136,26 @@ add_blank_contact (EmpathyContactSelector *selector) ...@@ -140,27 +136,26 @@ add_blank_contact (EmpathyContactSelector *selector)
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, NULL, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, NULL,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, (_("Select a contact")), EMPATHY_CONTACT_LIST_STORE_COL_NAME, (_("Select a contact")),
EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, FALSE, -1); EMPATHY_CONTACT_LIST_STORE_COL_IS_ONLINE, FALSE, -1);
g_signal_handlers_block_by_func(selector, changed_cb, NULL); g_signal_handlers_block_by_func (selector,
contact_selector_changed_cb, NULL);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &blank_iter); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &blank_iter);
g_signal_handlers_unblock_by_func(selector, changed_cb, NULL); g_signal_handlers_unblock_by_func (selector,
contact_selector_changed_cb, NULL);
} }
static void static void
remove_blank_contact (EmpathyContactSelector *selector) contact_selector_remove_blank_contact (EmpathyContactSelector *selector)
{ {
EmpathyContactSelectorPriv *priv = GET_PRIV (selector); EmpathyContactSelectorPriv *priv = GET_PRIV (selector);
GtkTreeIter blank_iter; GtkTreeIter blank_iter;
if (get_iter_for_blank_contact (GTK_TREE_STORE (priv->store), &blank_iter)) if (contact_selector_get_iter_for_blank_contact (
{ GTK_TREE_STORE (priv->store), &blank_iter))
gtk_tree_store_remove (GTK_TREE_STORE (priv->store), &blank_iter); gtk_tree_store_remove (GTK_TREE_STORE (priv->store), &blank_iter);
}
} }
static void static void
manage_sensitivity (EmpathyContactSelector *selector) contact_selector_manage_sensitivity (EmpathyContactSelector *selector)
{ {
EmpathyContactSelectorPriv *priv = GET_PRIV (selector); EmpathyContactSelectorPriv *priv = GET_PRIV (selector);
...@@ -168,18 +163,17 @@ manage_sensitivity (EmpathyContactSelector *selector) ...@@ -168,18 +163,17 @@ manage_sensitivity (EmpathyContactSelector *selector)
* The following value needs to be the number of entries shown * The following value needs to be the number of entries shown
* excluding the blank entry (if present). * excluding the blank entry (if present).
*/ */
guint number_online_contacts = guint number_online_contacts = contact_selector_get_number_online_contacts (
get_number_online_contacts (GTK_TREE_STORE (priv->store)); GTK_TREE_STORE (priv->store));
if (number_online_contacts) if (number_online_contacts)
gtk_widget_set_sensitive (GTK_WIDGET (selector), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (selector), TRUE);
else else
gtk_widget_set_sensitive (GTK_WIDGET (selector), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (selector), FALSE);
} }
static void static void
manage_blank_contact (EmpathyContactSelector *selector) contact_selector_manage_blank_contact (EmpathyContactSelector *selector)
{ {
gboolean is_popup_shown; gboolean is_popup_shown;
...@@ -187,65 +181,62 @@ manage_blank_contact (EmpathyContactSelector *selector) ...@@ -187,65 +181,62 @@ manage_blank_contact (EmpathyContactSelector *selector)
if (is_popup_shown) if (is_popup_shown)
{ {
remove_blank_contact (selector); contact_selector_remove_blank_contact (selector);
} }
else else
{ {
if (gtk_combo_box_get_active (GTK_COMBO_BOX (selector)) == -1) if (gtk_combo_box_get_active (GTK_COMBO_BOX (selector)) == -1)
{ {
add_blank_contact (selector); contact_selector_add_blank_contact (selector);
} }
else else
{ {
remove_blank_contact (selector); contact_selector_remove_blank_contact (selector);
} }
} }
manage_sensitivity (selector); contact_selector_manage_sensitivity (selector);
} }
static void static void
notify_popup_shown_cb (GtkComboBox *widget, contact_selector_notify_popup_shown_cb (GtkComboBox *widget,
GParamSpec *property, GParamSpec *property,
gpointer data) gpointer data)
{ {
EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (widget); EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (widget);
manage_blank_contact (selector); contact_selector_manage_blank_contact (selector);
} }
static void static void
changed_cb (GtkComboBox *widget, contact_selector_changed_cb (GtkComboBox *widget,
gpointer data) gpointer data)
{ {
EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (widget); EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (widget);
manage_blank_contact (selector); contact_selector_manage_blank_contact (selector);
} }
static void static void
empathy_store_row_changed_cb (EmpathyContactListStore *empathy_store, contact_selector_store_row_changed_cb (EmpathyContactListStore *empathy_store,
GtkTreePath *empathy_path, GtkTreePath *empathy_path,
GtkTreeIter *empathy_iter, GtkTreeIter *empathy_iter,
gpointer data) gpointer data)
{ {
EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data); EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data);
manage_sensitivity (selector); contact_selector_manage_sensitivity (selector);
} }
static GObject * static GObject *
empathy_contact_selector_constructor (GType type, contact_selector_constructor (GType type,
guint n_construct_params, guint n_construct_params,
GObjectConstructParam *construct_params) GObjectConstructParam *construct_params)
{ {
GObject *object = GObject *object =
G_OBJECT_CLASS (empathy_contact_selector_parent_class)->constructor (type, G_OBJECT_CLASS (empathy_contact_selector_parent_class)->constructor (
n_construct_params, construct_params); type, n_construct_params, construct_params);
EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object); EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object);
EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector); EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector);
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
...@@ -255,11 +246,12 @@ empathy_contact_selector_constructor (GType type, ...@@ -255,11 +246,12 @@ empathy_contact_selector_constructor (GType type,
"sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME, NULL); "sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME, NULL);
g_signal_connect (priv->store, "row-changed", g_signal_connect (priv->store, "row-changed",
G_CALLBACK (empathy_store_row_changed_cb), (gpointer) contact_selector); G_CALLBACK (contact_selector_store_row_changed_cb),
(gpointer) contact_selector);
g_signal_connect (GTK_COMBO_BOX (contact_selector), "changed", g_signal_connect (GTK_COMBO_BOX (contact_selector), "changed",
G_CALLBACK (changed_cb), NULL); G_CALLBACK (contact_selector_changed_cb), NULL);
g_signal_connect (GTK_COMBO_BOX (contact_selector), "notify::popup-shown", g_signal_connect (GTK_COMBO_BOX (contact_selector), "notify::popup-shown",
G_CALLBACK (notify_popup_shown_cb), NULL); G_CALLBACK (contact_selector_notify_popup_shown_cb), NULL);
gtk_combo_box_set_model (GTK_COMBO_BOX (contact_selector), gtk_combo_box_set_model (GTK_COMBO_BOX (contact_selector),
GTK_TREE_MODEL (priv->store)); GTK_TREE_MODEL (priv->store));
...@@ -277,14 +269,13 @@ empathy_contact_selector_constructor (GType type, ...@@ -277,14 +269,13 @@ empathy_contact_selector_constructor (GType type,
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (contact_selector), renderer, gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (contact_selector), renderer,
"text", EMPATHY_CONTACT_LIST_STORE_COL_NAME, NULL); "text", EMPATHY_CONTACT_LIST_STORE_COL_NAME, NULL);
manage_blank_contact (contact_selector); contact_selector_manage_blank_contact (contact_selector);
manage_sensitivity (contact_selector); contact_selector_manage_sensitivity (contact_selector);
object = G_OBJECT (contact_selector); object = G_OBJECT (contact_selector);
return object; return object;
} }
static void static void
empathy_contact_selector_init (EmpathyContactSelector *empathy_contact_selector) empathy_contact_selector_init (EmpathyContactSelector *empathy_contact_selector)
{ {
...@@ -295,12 +286,11 @@ empathy_contact_selector_init (EmpathyContactSelector *empathy_contact_selector) ...@@ -295,12 +286,11 @@ empathy_contact_selector_init (EmpathyContactSelector *empathy_contact_selector)
empathy_contact_selector->priv = priv; empathy_contact_selector->priv = priv;
} }
static void static void
empathy_contact_selector_set_property (GObject *object, contact_selector_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object); EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object);
EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector); EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector);
...@@ -316,12 +306,11 @@ empathy_contact_selector_set_property (GObject *object, ...@@ -316,12 +306,11 @@ empathy_contact_selector_set_property (GObject *object,
} }
} }
static void static void
empathy_contact_selector_get_property (GObject *object, contact_selector_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object); EmpathyContactSelector *contact_selector = EMPATHY_CONTACT_SELECTOR (object);
EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector); EmpathyContactSelectorPriv *priv = GET_PRIV (contact_selector);
...@@ -337,9 +326,8 @@ empathy_contact_selector_get_property (GObject *object, ...@@ -337,9 +326,8 @@ empathy_contact_selector_get_property (GObject *object,
} }
} }
static void static void
empathy_contact_selector_dispose (GObject *object) contact_selector_dispose (GObject *object)
{ {
EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (object); EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (object);
EmpathyContactSelectorPriv *priv = GET_PRIV (selector); EmpathyContactSelectorPriv *priv = GET_PRIV (selector);
...@@ -353,15 +341,14 @@ empathy_contact_selector_dispose (GObject *object) ...@@ -353,15 +341,14 @@ empathy_contact_selector_dispose (GObject *object)
(G_OBJECT_CLASS (empathy_contact_selector_parent_class)->dispose) (object); (G_OBJECT_CLASS (empathy_contact_selector_parent_class)->dispose) (object);
} }
static void static void
empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass) empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = empathy_contact_selector_constructor; object_class->constructor = contact_selector_constructor;
object_class->dispose = empathy_contact_selector_dispose; object_class->dispose = contact_selector_dispose;
object_class->set_property = empathy_contact_selector_set_property; object_class->set_property = contact_selector_set_property;
object_class->get_property = empathy_contact_selector_get_property; object_class->get_property = contact_selector_get_property;
g_type_class_add_private (klass, sizeof (EmpathyContactSelectorPriv)); g_type_class_add_private (klass, sizeof (EmpathyContactSelectorPriv));
g_object_class_install_property (object_class, PROP_STORE, g_object_class_install_property (object_class, PROP_STORE,
...@@ -370,7 +357,6 @@ empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass) ...@@ -370,7 +357,6 @@ empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
} }
EmpathyContactSelector * EmpathyContactSelector *
empathy_contact_selector_new (EmpathyContactListStore *store) empathy_contact_selector_new (EmpathyContactListStore *store)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment