aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/gossip-profile-chooser.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2007-04-26 05:59:20 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-04-26 05:59:20 +0800
commit40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6 (patch)
treec1426dc8388fc711bf4a5e8de42fd3a4b76e6842 /libempathy-gtk/gossip-profile-chooser.c
downloadgsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar.gz
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar.bz2
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar.lz
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar.xz
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.tar.zst
gsoc2013-empathy-40c0d1ba5434b5c5d4f8b7ff6fedd1add5c03ce6.zip
[darcs-to-svn @ initial import]
svn path=/trunk/; revision=2
Diffstat (limited to 'libempathy-gtk/gossip-profile-chooser.c')
-rw-r--r--libempathy-gtk/gossip-profile-chooser.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/libempathy-gtk/gossip-profile-chooser.c b/libempathy-gtk/gossip-profile-chooser.c
new file mode 100644
index 000000000..15f2fbb34
--- /dev/null
+++ b/libempathy-gtk/gossip-profile-chooser.c
@@ -0,0 +1,102 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Xavier Claessens <xclaesse@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+#include <libmissioncontrol/mc-profile.h>
+
+#include <libempathy-gtk/gossip-ui-utils.h>
+
+#include "gossip-profile-chooser.h"
+
+enum {
+ COL_ICON,
+ COL_LABEL,
+ COL_PROFILE,
+ COL_COUNT
+};
+
+McProfile*
+gossip_profile_chooser_get_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;
+}
+
+GtkWidget *
+gossip_profile_chooser_new (void)
+{
+ GList *profiles, *l;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkWidget *combo_box;
+ GtkTreeIter iter;
+
+ /* set up combo box with new store */
+ store = gtk_list_store_new (COL_COUNT,
+ GDK_TYPE_PIXBUF, /* Icon */
+ 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,
+ "pixbuf", COL_ICON,
+ 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);
+
+ profiles = mc_profiles_list ();
+ for (l = profiles; l; l = l->next) {
+ McProfile *profile;
+
+ profile = l->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_ICON, gossip_pixbuf_from_profile (profile, GTK_ICON_SIZE_BUTTON),
+ COL_LABEL, mc_profile_get_display_name (profile),
+ COL_PROFILE, profile,
+ -1);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
+ }
+
+ mc_profiles_free_list (profiles);
+ g_object_unref (store);
+
+ return combo_box;
+}
+