diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-06-05 06:04:46 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-06-05 20:04:10 +0800 |
commit | 326ec5c02e85f1a94580120f6ccd715245348209 (patch) | |
tree | 5eaec395c634123090540abb265c47eb61e548e9 | |
parent | d3dc61867d99d3f9fa50e204fba66943d955ecd1 (diff) | |
download | gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar.gz gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar.bz2 gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar.lz gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar.xz gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.tar.zst gsoc2013-empathy-326ec5c02e85f1a94580120f6ccd715245348209.zip |
Convert style to Telepathy coding style.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | libempathy-gtk/empathy-profile-chooser.c | 302 | ||||
-rw-r--r-- | libempathy-gtk/empathy-profile-chooser.h | 6 |
2 files changed, 155 insertions, 153 deletions
diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c index 14965741c..53cfa3b3e 100644 --- a/libempathy-gtk/empathy-profile-chooser.c +++ b/libempathy-gtk/empathy-profile-chooser.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ /* * Copyright (C) 2007-2008 Collabora Ltd. * @@ -41,10 +41,10 @@ */ enum { - COL_ICON, - COL_LABEL, - COL_PROFILE, - COL_COUNT + COL_ICON, + COL_LABEL, + COL_PROFILE, + COL_COUNT }; /** @@ -59,18 +59,19 @@ enum { McProfile * empathy_profile_chooser_dup_selected (GtkWidget *widget) { - GtkTreeModel *model; - GtkTreeIter iter; - McProfile *profile = NULL; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { - gtk_tree_model_get (model, &iter, - COL_PROFILE, &profile, - -1); - } - - return profile; + GtkTreeModel *model; + GtkTreeIter iter; + McProfile *profile = NULL; + + model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) + { + gtk_tree_model_get (model, &iter, + COL_PROFILE, &profile, + -1); + } + + return profile; } /** @@ -84,62 +85,65 @@ empathy_profile_chooser_dup_selected (GtkWidget *widget) gint empathy_profile_chooser_n_profiles (GtkWidget *widget) { - GtkTreeModel *model; + GtkTreeModel *model; - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - return gtk_tree_model_iter_n_children (model, NULL); + return gtk_tree_model_iter_n_children (model, NULL); } static gint profile_chooser_sort_profile_value (McProfile *profile) { - guint i; - const gchar *profile_name; - const gchar *names[] = {"jabber", - "salut", - "gtalk", - NULL}; - - profile_name = mc_profile_get_unique_name (profile); - - for (i = 0 ; names[i]; i++) { - if (strcmp (profile_name, names[i]) == 0) { - return i; - } - } - - return i; + guint i; + const gchar *profile_name; + const gchar *names[] = { + "jabber", + "salut", + "gtalk", + NULL + }; + + profile_name = mc_profile_get_unique_name (profile); + + for (i = 0 ; names[i]; i++) + { + if (strcmp (profile_name, names[i]) == 0) + return i; + } + + return i; } static gint profile_chooser_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data) + GtkTreeIter *iter_a, + GtkTreeIter *iter_b, + gpointer user_data) { - McProfile *profile_a; - McProfile *profile_b; - gint cmp; - - gtk_tree_model_get (model, iter_a, - COL_PROFILE, &profile_a, - -1); - gtk_tree_model_get (model, iter_b, - COL_PROFILE, &profile_b, - -1); - - cmp = profile_chooser_sort_profile_value (profile_a); - cmp -= profile_chooser_sort_profile_value (profile_b); - if (cmp == 0) { - cmp = strcmp (mc_profile_get_display_name (profile_a), - mc_profile_get_display_name (profile_b)); - } - - g_object_unref (profile_a); - g_object_unref (profile_b); - - return cmp; + McProfile *profile_a; + McProfile *profile_b; + gint cmp; + + gtk_tree_model_get (model, iter_a, + COL_PROFILE, &profile_a, + -1); + gtk_tree_model_get (model, iter_b, + COL_PROFILE, &profile_b, + -1); + + cmp = profile_chooser_sort_profile_value (profile_a); + cmp -= profile_chooser_sort_profile_value (profile_b); + if (cmp == 0) + { + cmp = strcmp (mc_profile_get_display_name (profile_a), + mc_profile_get_display_name (profile_b)); + } + + g_object_unref (profile_a); + g_object_unref (profile_b); + + return cmp; } /** @@ -152,94 +156,92 @@ profile_chooser_sort_func (GtkTreeModel *model, GtkWidget * empathy_profile_chooser_new (void) { - GList *profiles, *l, *seen; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkWidget *combo_box; - GtkTreeIter iter; - gboolean iter_set = FALSE; - McManager *btf_cm; - - /* set up combo box with new store */ - store = gtk_list_store_new (COL_COUNT, - G_TYPE_STRING, /* Icon name */ - G_TYPE_STRING, /* Label */ - MC_TYPE_PROFILE); /* Profile */ - combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "icon-name", COL_ICON, - NULL); - g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "text", COL_LABEL, - NULL); - - btf_cm = mc_manager_lookup ("butterfly"); - profiles = mc_profiles_list (); - seen = NULL; - for (l = profiles; l; l = l->next) { - McProfile *profile; - McProtocol *protocol; - const gchar *unique_name; - - profile = l->data; - - /* Check if the CM is installed, otherwise skip that profile. - * Workaround SF bug #1688779 */ - protocol = mc_profile_get_protocol (profile); - if (!protocol) { - continue; - } - g_object_unref (protocol); - - /* Skip MSN-Haze if we have butterfly */ - unique_name = mc_profile_get_unique_name (profile); - if (btf_cm && strcmp (unique_name, "msn-haze") == 0) { - continue; - } - - if (g_list_find_custom (seen, unique_name, (GCompareFunc) strcmp)) { - continue; - } - seen = g_list_append (seen, (char *) unique_name); - - gtk_list_store_insert_with_values (store, &iter, 0, - COL_ICON, mc_profile_get_icon_name (profile), - COL_LABEL, mc_profile_get_display_name (profile), - COL_PROFILE, profile, - -1); - iter_set = TRUE; - } - - g_list_free (seen); - - if (btf_cm) { - g_object_unref (btf_cm); - } - - /* Set the profile sort function */ - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), - COL_PROFILE, - profile_chooser_sort_func, - NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - COL_PROFILE, - GTK_SORT_ASCENDING); - - if (iter_set) { - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); - } - - mc_profiles_free_list (profiles); - g_object_unref (store); - - return combo_box; + GList *profiles, *l, *seen; + GtkListStore *store; + GtkCellRenderer *renderer; + GtkWidget *combo_box; + GtkTreeIter iter; + gboolean iter_set = FALSE; + McManager *btf_cm; + + /* set up combo box with new store */ + store = gtk_list_store_new (COL_COUNT, + G_TYPE_STRING, /* Icon name */ + G_TYPE_STRING, /* Label */ + MC_TYPE_PROFILE); /* Profile */ + combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, + "icon-name", COL_ICON, + NULL); + g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, + "text", COL_LABEL, + NULL); + + btf_cm = mc_manager_lookup ("butterfly"); + profiles = mc_profiles_list (); + seen = NULL; + for (l = profiles; l; l = l->next) + { + McProfile *profile; + McProtocol *protocol; + const gchar *unique_name; + + profile = l->data; + + /* Check if the CM is installed, otherwise skip that profile. + * Workaround SF bug #1688779 */ + protocol = mc_profile_get_protocol (profile); + if (!protocol) + continue; + + g_object_unref (protocol); + + /* Skip MSN-Haze if we have butterfly */ + unique_name = mc_profile_get_unique_name (profile); + if (btf_cm && strcmp (unique_name, "msn-haze") == 0) + continue; + + if (g_list_find_custom (seen, unique_name, (GCompareFunc) strcmp)) + continue; + + seen = g_list_append (seen, (char *) unique_name); + + gtk_list_store_insert_with_values (store, &iter, 0, + COL_ICON, mc_profile_get_icon_name (profile), + COL_LABEL, mc_profile_get_display_name (profile), + COL_PROFILE, profile, + -1); + iter_set = TRUE; + } + + g_list_free (seen); + + if (btf_cm) + g_object_unref (btf_cm); + + /* Set the profile sort function */ + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), + COL_PROFILE, + profile_chooser_sort_func, + NULL, NULL); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), + COL_PROFILE, + GTK_SORT_ASCENDING); + + if (iter_set) + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); + + mc_profiles_free_list (profiles); + g_object_unref (store); + + return combo_box; } diff --git a/libempathy-gtk/empathy-profile-chooser.h b/libempathy-gtk/empathy-profile-chooser.h index 74c761cc4..caea8b6f2 100644 --- a/libempathy-gtk/empathy-profile-chooser.h +++ b/libempathy-gtk/empathy-profile-chooser.h @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ /* * Copyright (C) 2007-2008 Collabora Ltd. * @@ -26,9 +26,9 @@ G_BEGIN_DECLS -GtkWidget * empathy_profile_chooser_new (void); +GtkWidget * empathy_profile_chooser_new (void); McProfile * empathy_profile_chooser_dup_selected (GtkWidget *widget); -gint empathy_profile_chooser_n_profiles (GtkWidget *widget); +gint empathy_profile_chooser_n_profiles (GtkWidget *widget); G_END_DECLS #endif /* __EMPATHY_PROTOCOL_CHOOSER_H__ */ |