1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Xavier Claessens <xclaesse@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
24 #include <libmissioncontrol/mc-profile.h>
26 #include <libempathy-gtk/gossip-ui-utils.h>
28 #include "gossip-profile-chooser.h"
38 gossip_profile_chooser_get_selected (GtkWidget *widget)
42 McProfile *profile = NULL;
44 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
45 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
46 gtk_tree_model_get (model, &iter,
47 COL_PROFILE, &profile,
55 gossip_profile_chooser_new (void)
59 GtkCellRenderer *renderer;
63 /* set up combo box with new store */
64 store = gtk_list_store_new (COL_COUNT,
65 GDK_TYPE_PIXBUF, /* Icon */
66 G_TYPE_STRING, /* Label */
67 MC_TYPE_PROFILE); /* Profile */
68 combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
71 renderer = gtk_cell_renderer_pixbuf_new ();
72 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE);
73 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
76 renderer = gtk_cell_renderer_text_new ();
77 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
78 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
82 profiles = mc_profiles_list ();
83 for (l = profiles; l; l = l->next) {
88 gtk_list_store_append (store, &iter);
89 gtk_list_store_set (store, &iter,
90 COL_ICON, gossip_pixbuf_from_profile (profile, GTK_ICON_SIZE_BUTTON),
91 COL_LABEL, mc_profile_get_display_name (profile),
94 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
97 mc_profiles_free_list (profiles);
98 g_object_unref (store);