aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2004-10-14 02:37:28 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-10-14 02:37:28 +0800
commit597b1d90fb83ce367f260f8c4553f76348d8d976 (patch)
tree5b9c92b037cfe87a7af0525adf3a1215e6c28dcd /widgets/misc
parent6637268444f29f397df8f90086696500febfa17f (diff)
downloadgsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar.gz
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar.bz2
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar.lz
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar.xz
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.tar.zst
gsoc2013-evolution-597b1d90fb83ce367f260f8c4553f76348d8d976.zip
don't build source selector or source option menu or test programs any
2004-10-13 JP Rosevear <jpr@novell.com> * Makefile.am: don't build source selector or source option menu or test programs any more svn path=/trunk/; revision=27570
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/.cvsignore2
-rw-r--r--widgets/misc/ChangeLog5
-rw-r--r--widgets/misc/Makefile.am31
-rw-r--r--widgets/misc/e-source-option-menu.c307
-rw-r--r--widgets/misc/e-source-option-menu.h64
-rw-r--r--widgets/misc/e-source-selector.c1122
-rw-r--r--widgets/misc/e-source-selector.h82
-rw-r--r--widgets/misc/test-source-option-menu.c88
-rw-r--r--widgets/misc/test-source-selector.c131
9 files changed, 7 insertions, 1825 deletions
diff --git a/widgets/misc/.cvsignore b/widgets/misc/.cvsignore
index 4bc7214f51..8f7925a69c 100644
--- a/widgets/misc/.cvsignore
+++ b/widgets/misc/.cvsignore
@@ -12,6 +12,4 @@ test-dateedit
test-dropdown-button
test-error
test-multi-config-dialog
-test-source-option-menu
-test-source-selector
test-title-bar
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index ac6b0f6165..d996335373 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-13 JP Rosevear <jpr@novell.com>
+
+ * Makefile.am: don't build source selector or source option menu
+ or test programs any more
+
2004-10-08 Harry Lu <harry.lu@sun.com>
* e-source-selector.c: (e_source_selector_popup_menu),
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 6e1814b88d..fa4c167963 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -4,7 +4,7 @@ INCLUDES = \
-DMAP_DIR=\""$(imagesdir)"\" \
-DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
-DG_LOG_DOMAIN=__FILE__ \
- $(SOURCE_SEL_CFLAGS)
+ $(GNOME_FULL_CFLAGS)
privlib_LTLIBRARIES = \
libemiscwidgets.la
@@ -41,8 +41,6 @@ widgetsinclude_HEADERS = \
e-map.h \
e-multi-config-dialog.h \
e-search-bar.h \
- e-source-option-menu.h \
- e-source-selector.h \
e-task-bar.h \
e-task-widget.h \
e-title-bar.h \
@@ -72,8 +70,6 @@ libemiscwidgets_la_SOURCES = \
e-map.c \
e-multi-config-dialog.c \
e-search-bar.c \
- e-source-option-menu.c \
- e-source-selector.c \
e-task-bar.c \
e-task-widget.c \
e-title-bar.c \
@@ -90,7 +86,7 @@ errordir = $(privdatadir)/errors
libemiscwidgets_la_LIBADD = $(top_builddir)/e-util/libeutil.la \
$(top_builddir)/a11y/widgets/libevolution-widgets-a11y.la \
- $(SOURCE_SEL_LIBS)
+ $(GNOME_FULL_LIBS)
noinst_LTLIBRARIES = libefilterbar.la
@@ -104,8 +100,6 @@ noinst_PROGRAMS = \
test-dropdown-button \
test-error \
test-multi-config-dialog \
- test-source-option-menu \
- test-source-selector \
test-title-bar
# test-calendar
@@ -158,27 +152,6 @@ test_title_bar_LDADD = \
$(top_builddir)/e-util/libeutil.la \
$(GNOME_FULL_LIBS)
-# test-source-selector
-
-test_source_selector_SOURCES = \
- test-source-selector.c
-
-test_source_selector_LDADD = \
- $(top_builddir)/e-util/libeutil.la \
- ./libemiscwidgets.la \
- $(SOURCE_SEL_LIBS)
-
-
-# test-source-option-menu
-
-test_source_option_menu_SOURCES = \
- test-source-option-menu.c
-
-test_source_option_menu_LDADD = \
- $(top_builddir)/e-util/libeutil.la \
- ./libemiscwidgets.la \
- $(SOURCE_SEL_LIBS)
-
test_error_SOURCES = \
test-error.c
diff --git a/widgets/misc/e-source-option-menu.c b/widgets/misc/e-source-option-menu.c
deleted file mode 100644
index fd1fd3de1f..0000000000
--- a/widgets/misc/e-source-option-menu.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-option-menu.c
- *
- * Copyright (C) 2003 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#include <config.h>
-
-#include "e-source-option-menu.h"
-
-#include "e-util-marshal.h"
-
-#include <gal/util/e-util.h>
-
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-
-
-#define PARENT_TYPE gtk_option_menu_get_type ()
-static GtkOptionMenuClass *parent_class = NULL;
-
-
-/* We set data on each menu item specifying the corresponding ESource using this key. */
-#define MENU_ITEM_SOURCE_DATA_ID "ESourceOptionMenu:Source"
-
-
-struct _ESourceOptionMenuPrivate {
- ESourceList *source_list;
-
- ESource *selected_source;
-};
-
-
-enum {
- SOURCE_SELECTED,
- NUM_SIGNALS
-};
-
-static uint signals[NUM_SIGNALS] = { 0 };
-
-
-/* Selecting a source. */
-
-typedef struct {
- ESourceOptionMenu *option_menu;
- ESource *source;
- ESource *found_source;
- int i;
-} ForeachMenuItemData;
-
-static void
-select_source_foreach_menu_item (GtkWidget *menu_item,
- ForeachMenuItemData *data)
-{
- ESource *source = gtk_object_get_data (GTK_OBJECT (menu_item), MENU_ITEM_SOURCE_DATA_ID);
-
- if (data->found_source)
- return;
-
- if (source && e_source_equal (source, data->source)) {
- data->found_source = source;
- gtk_option_menu_set_history (GTK_OPTION_MENU (data->option_menu), data->i);
- }
-
- data->i ++;
-}
-
-static void
-select_source (ESourceOptionMenu *menu,
- ESource *source)
-{
- ForeachMenuItemData *foreach_data;
-
- foreach_data = g_new0 (ForeachMenuItemData, 1);
- foreach_data->option_menu = menu;
- foreach_data->source = source;
-
- gtk_container_foreach (GTK_CONTAINER (GTK_OPTION_MENU (menu)->menu),
- (GtkCallback) select_source_foreach_menu_item, foreach_data);
-
- if (foreach_data->found_source) {
- menu->priv->selected_source = foreach_data->found_source;
- g_signal_emit (menu, signals[SOURCE_SELECTED], 0, foreach_data->found_source);
- }
-
- g_free (foreach_data);
-}
-
-
-/* Menu callback. */
-
-static void
-menu_item_activate_callback (GtkMenuItem *menu_item,
- ESourceOptionMenu *option_menu)
-{
- ESource *source = gtk_object_get_data (GTK_OBJECT (menu_item), MENU_ITEM_SOURCE_DATA_ID);
-
- if (source != NULL)
- select_source (option_menu, source);
-}
-
-
-/* Functions to keep the menu in sync with the ESourceList. */
-
-static void
-populate (ESourceOptionMenu *option_menu)
-{
- GtkWidget *menu = gtk_menu_new ();
- GSList *groups = e_source_list_peek_groups (option_menu->priv->source_list);
- GSList *p;
- ESource *first_source = NULL;
- int first_source_item = -1;
- int selected_item = -1;
- int i;
-
- i = 0;
- for (p = groups; p != NULL; p = p->next) {
- ESourceGroup *group = E_SOURCE_GROUP (p->data);
- GtkWidget *item = gtk_menu_item_new_with_label (e_source_group_peek_name (group));
- GSList *q;
-
- gtk_widget_set_sensitive (item, FALSE);
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
-
- i ++;
-
- for (q = e_source_group_peek_sources (group); q != NULL; q = q->next) {
- ESource *source = E_SOURCE (q->data);
- char *label = g_strconcat (" ", e_source_peek_name (source), NULL);
- GtkWidget *item = gtk_menu_item_new_with_label (label);
-
- gtk_object_set_data_full (GTK_OBJECT (item), MENU_ITEM_SOURCE_DATA_ID, source,
- (GtkDestroyNotify) g_object_unref);
- g_object_ref (source);
-
- g_signal_connect (item, "activate", G_CALLBACK (menu_item_activate_callback), option_menu);
-
- gtk_widget_show (item);
- gtk_menu_append (GTK_MENU (menu), item);
-
- if (first_source_item == -1) {
- first_source_item = i;
- first_source = source;
- }
-
- if (source == option_menu->priv->selected_source)
- selected_item = i;
-
- i ++;
- }
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
-
- if (selected_item != -1) {
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), selected_item);
- } else {
- if (option_menu->priv->selected_source != NULL)
- g_object_unref (option_menu->priv->selected_source);
- option_menu->priv->selected_source = first_source;
- if (option_menu->priv->selected_source != NULL)
- g_object_ref (option_menu->priv->selected_source);
-
- gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), first_source_item);
- }
-}
-
-
-static void
-source_list_changed_callback (ESourceList *list,
- ESourceOptionMenu *menu)
-{
- populate (menu);
-}
-
-static void
-connect_signals (ESourceOptionMenu *menu)
-{
- g_signal_connect_object (menu->priv->source_list, "changed",
- G_CALLBACK (source_list_changed_callback), G_OBJECT (menu), 0);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- ESourceOptionMenuPrivate *priv = E_SOURCE_OPTION_MENU (object)->priv;
-
- if (priv->source_list != NULL) {
- g_object_unref (priv->source_list);
- priv->source_list = NULL;
- }
-
- if (priv->selected_source != NULL) {
- g_object_unref (priv->selected_source);
- priv->selected_source = NULL;
- }
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- ESourceOptionMenuPrivate *priv = E_SOURCE_OPTION_MENU (object)->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-/* Initialization. */
-
-static void
-class_init (ESourceOptionMenuClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- parent_class = g_type_class_peek_parent (class);
-
- signals[SOURCE_SELECTED] =
- g_signal_new ("source_selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceOptionMenuClass, source_selected),
- NULL, NULL,
- e_util_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-}
-
-static void
-init (ESourceOptionMenu *source_option_menu)
-{
- ESourceOptionMenuPrivate *priv;
-
- priv = g_new0 (ESourceOptionMenuPrivate, 1);
-
- source_option_menu->priv = priv;
-}
-
-
-/* Public methods. */
-
-GtkWidget *
-e_source_option_menu_new (ESourceList *source_list)
-{
- ESourceOptionMenu *menu;
-
- g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
-
- menu = g_object_new (e_source_option_menu_get_type (), NULL);
-
- menu->priv->source_list = source_list;
- g_object_ref (source_list);
-
- connect_signals (menu);
- populate (menu);
-
- return GTK_WIDGET (menu);
-}
-
-
-ESource *
-e_source_option_menu_peek_selected (ESourceOptionMenu *menu)
-{
- g_return_val_if_fail (E_IS_SOURCE_OPTION_MENU (menu), NULL);
-
- return menu->priv->selected_source;
-}
-
-
-void
-e_source_option_menu_select (ESourceOptionMenu *menu,
- ESource *source)
-{
- g_return_if_fail (E_IS_SOURCE_OPTION_MENU (menu));
- g_return_if_fail (E_IS_SOURCE (source));
-
- select_source (menu, source);
-}
-
-
-E_MAKE_TYPE (e_source_option_menu, "ESourceOptionMenu", ESourceOptionMenu, class_init, init, PARENT_TYPE)
diff --git a/widgets/misc/e-source-option-menu.h b/widgets/misc/e-source-option-menu.h
deleted file mode 100644
index 74a85d629e..0000000000
--- a/widgets/misc/e-source-option-menu.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-option-menu.h
- *
- * Copyright (C) 2003 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifndef _E_SOURCE_OPTION_MENU_H_
-#define _E_SOURCE_OPTION_MENU_H_
-
-#include <libedataserver/e-source-list.h>
-
-#include <gtk/gtkoptionmenu.h>
-
-#define E_TYPE_SOURCE_OPTION_MENU (e_source_option_menu_get_type ())
-#define E_SOURCE_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_OPTION_MENU, ESourceOptionMenu))
-#define E_SOURCE_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_OPTION_MENU, ESourceOptionMenuClass))
-#define E_IS_SOURCE_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_OPTION_MENU))
-#define E_IS_SOURCE_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_OPTION_MENU))
-
-
-typedef struct _ESourceOptionMenu ESourceOptionMenu;
-typedef struct _ESourceOptionMenuPrivate ESourceOptionMenuPrivate;
-typedef struct _ESourceOptionMenuClass ESourceOptionMenuClass;
-
-struct _ESourceOptionMenu {
- GtkOptionMenu parent;
-
- ESourceOptionMenuPrivate *priv;
-};
-
-struct _ESourceOptionMenuClass {
- GtkOptionMenuClass parent_class;
-
- void (* source_selected) (ESourceOptionMenu *menu,
- ESource *selected_source);
-};
-
-
-GType e_source_option_menu_get_type (void);
-
-GtkWidget *e_source_option_menu_new (ESourceList *list);
-
-ESource *e_source_option_menu_peek_selected (ESourceOptionMenu *menu);
-void e_source_option_menu_select (ESourceOptionMenu *menu,
- ESource *source);
-
-
-#endif /* _E_SOURCE_OPTION_MENU_H_ */
diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c
deleted file mode 100644
index 60d4fc9a0f..0000000000
--- a/widgets/misc/e-source-selector.c
+++ /dev/null
@@ -1,1122 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-selector.c
- *
- * Copyright (C) 2003 Ximian, Inc.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#include <config.h>
-
-#include "e-source-selector.h"
-
-#include "e-util-marshal.h"
-
-#include <gal/util/e-util.h>
-
-#include <gtk/gtkmenu.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtktreestore.h>
-#include <gtk/gtkcellrenderertoggle.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-
-#define PARENT_TYPE gtk_tree_view_get_type ()
-static GtkTreeViewClass *parent_class = NULL;
-
-
-struct _ESourceSelectorPrivate {
- ESourceList *list;
-
- GtkTreeStore *tree_store;
-
- GHashTable *selected_sources;
- GtkTreeRowReference *saved_primary_selection;
-
- int rebuild_model_idle_id;
-
- gboolean toggled_last;
- gboolean checkboxes_shown;
- gboolean select_new;
-};
-
-typedef struct {
- ESourceSelector *selector;
-
- GHashTable *remaining_uids;
- GSList *deleted_uids;
-
- gboolean selection_changed;
-} ESourceSelectorRebuildData;
-
-enum {
- SELECTION_CHANGED,
- PRIMARY_SELECTION_CHANGED,
- POPUP_EVENT,
- NUM_SIGNALS
-};
-static unsigned int signals[NUM_SIGNALS] = { 0 };
-
-
-/* Selection management. */
-
-static GHashTable *
-create_selected_sources_hash (void)
-{
- return g_hash_table_new_full (g_direct_hash, g_direct_equal,
- (GDestroyNotify) g_object_unref, NULL);
-}
-
-static ESourceSelectorRebuildData *
-create_rebuild_data (ESourceSelector *selector)
-{
- ESourceSelectorRebuildData *rebuild_data;
-
- rebuild_data = g_new0 (ESourceSelectorRebuildData, 1);
-
- rebuild_data->selector = selector;
- rebuild_data->remaining_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
- (GDestroyNotify) gtk_tree_row_reference_free);
- rebuild_data->deleted_uids = NULL;
-
- return rebuild_data;
-}
-
-
-static void
-free_rebuild_data (ESourceSelectorRebuildData *rebuild_data)
-{
- GSList *p;
-
- g_hash_table_destroy (rebuild_data->remaining_uids);
- for (p = rebuild_data->deleted_uids; p; p = p->next)
- gtk_tree_row_reference_free (p->data);
- g_slist_free (rebuild_data->deleted_uids);
-
- g_free (rebuild_data);
-}
-
-static void
-clear_saved_primary_selection (ESourceSelector *selector)
-{
- if (selector->priv->saved_primary_selection != NULL) {
- gtk_tree_row_reference_free (selector->priv->saved_primary_selection);
- selector->priv->saved_primary_selection = NULL;
- }
-}
-
-static gboolean
-source_is_selected (ESourceSelector *selector,
- ESource *source)
-{
- if (g_hash_table_lookup (selector->priv->selected_sources, source) == NULL)
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-select_source (ESourceSelector *selector,
- ESource *source)
-{
- if (g_hash_table_lookup (selector->priv->selected_sources, source) != NULL)
- return;
-
- g_hash_table_insert (selector->priv->selected_sources, source, source);
- g_object_ref (source);
-}
-
-static void
-unselect_source (ESourceSelector *selector,
- ESource *source)
-{
- if (g_hash_table_lookup (selector->priv->selected_sources, source) == NULL)
- return;
-
- /* (This will unref the source.) */
- g_hash_table_remove (selector->priv->selected_sources, source);
-}
-
-static gboolean
-find_source_iter (ESourceSelector *selector, ESource *source, GtkTreeIter *parent_iter, GtkTreeIter *source_iter)
-{
- GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
-
- if (gtk_tree_model_get_iter_first (model, parent_iter)) {
- do {
- if (gtk_tree_model_iter_children (model, source_iter, parent_iter)) {
- do {
- void *data;
-
- gtk_tree_model_get (model, source_iter, 0, &data, -1);
- g_assert (E_IS_SOURCE (data));
-
- if (E_SOURCE (data) == source) {
- g_object_unref (data);
-
- return TRUE;
- }
-
- g_object_unref (data);
- } while (gtk_tree_model_iter_next (model, source_iter));
- }
- } while (gtk_tree_model_iter_next (model, parent_iter));
- }
-
- return FALSE;
-}
-
-/* Setting up the model. */
-static gboolean
-rebuild_existing_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
-{
- ESourceSelectorRebuildData *rebuild_data = data;
- void *node;
- const char *uid;
-
- gtk_tree_model_get (model, iter, 0, &node, -1);
-
- if (E_IS_SOURCE_GROUP (node)) {
- uid = e_source_group_peek_uid (E_SOURCE_GROUP (node));
-
- if (e_source_list_peek_group_by_uid (rebuild_data->selector->priv->list, uid)) {
- g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
- gtk_tree_row_reference_new (model, path));
- } else {
- rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
- gtk_tree_row_reference_new (model, path));
- }
- } else {
- uid = e_source_peek_uid (E_SOURCE (node));
- if (e_source_list_peek_source_by_uid (rebuild_data->selector->priv->list, uid)) {
- g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid),
- gtk_tree_row_reference_new (model, path));
- } else {
- rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids,
- gtk_tree_row_reference_new (model, path));
-
- if (g_hash_table_remove (rebuild_data->selector->priv->selected_sources, node))
- rebuild_data->selection_changed = TRUE;
- }
- }
-
- g_object_unref (node);
-
- return FALSE;
-}
-
-static void
-rebuild_model (ESourceSelector *selector)
-{
- ESourceSelectorRebuildData *rebuild_data;
- GtkTreeStore *tree_store;
- GtkTreeIter iter;
- GSList *groups, *p;
- gboolean set_primary;
-
- tree_store = selector->priv->tree_store;
-
- rebuild_data = create_rebuild_data (selector);
- set_primary = e_source_selector_peek_primary_selection (selector) != NULL;
-
- /* Remove any delete sources or groups */
- gtk_tree_model_foreach (GTK_TREE_MODEL (tree_store), rebuild_existing_cb, rebuild_data);
- for (p = rebuild_data->deleted_uids; p; p = p->next) {
- GtkTreeRowReference *row_ref = p->data;
- GtkTreePath *path;
-
- path = gtk_tree_row_reference_get_path (row_ref);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path);
- gtk_tree_store_remove (tree_store, &iter);
-
- gtk_tree_path_free (path);
- }
-
- /* Add new sources/groups or call row_changed in case they were renamed */
- groups = e_source_list_peek_groups (selector->priv->list);
- for (p = groups; p != NULL; p = p->next) {
- ESourceGroup *group = E_SOURCE_GROUP (p->data);
- GSList *sources, *q;
- GtkTreeRowReference *row_ref;
-
- row_ref = g_hash_table_lookup (rebuild_data->remaining_uids, e_source_group_peek_uid (group));
- if (!row_ref) {
- gtk_tree_store_append (GTK_TREE_STORE (tree_store), &iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (tree_store), &iter, 0, group, -1);
- } else {
- GtkTreePath *path;
-
- path = gtk_tree_row_reference_get_path (row_ref);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path);
-
- gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, &iter);
-
- gtk_tree_path_free (path);
- }
-
- sources = e_source_group_peek_sources (group);
- for (q = sources; q != NULL; q = q->next) {
- ESource *source = E_SOURCE (q->data);
- GtkTreeIter child_iter;
-
- row_ref = g_hash_table_lookup (rebuild_data->remaining_uids, e_source_peek_uid (source));
- if (!row_ref) {
- if (selector->priv->select_new) {
- select_source (selector, source);
- rebuild_data->selection_changed = TRUE;
- }
- gtk_tree_store_append (GTK_TREE_STORE (tree_store), &child_iter, &iter);
- gtk_tree_store_set (GTK_TREE_STORE (tree_store), &child_iter, 0, source, -1);
-
- } else {
- GtkTreePath *path;
-
- path = gtk_tree_row_reference_get_path (row_ref);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &child_iter, path);
-
- gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, &child_iter);
-
- gtk_tree_path_free (path);
- }
- }
- }
-
- if (rebuild_data->selection_changed)
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
-
- if (set_primary && !e_source_selector_peek_primary_selection (selector))
- e_source_selector_set_primary_selection (selector, e_source_list_peek_source_any (selector->priv->list));
-
- free_rebuild_data (rebuild_data);
-}
-
-static int
-on_idle_rebuild_model_callback (ESourceSelector *selector)
-{
- rebuild_model (selector);
- selector->priv->rebuild_model_idle_id = 0;
-
- return FALSE;
-}
-
-static void
-list_changed_callback (ESourceList *list,
- ESourceSelector *selector)
-{
- ESourceSelectorPrivate *priv = selector->priv;
-
- if (priv->rebuild_model_idle_id == 0)
- priv->rebuild_model_idle_id = g_idle_add ((GSourceFunc) on_idle_rebuild_model_callback,
- selector);
-}
-
-static void
-setup_model (ESourceSelector *selector)
-{
- rebuild_model (selector);
-
- g_signal_connect_object (selector->priv->list, "changed", G_CALLBACK (list_changed_callback), G_OBJECT (selector), 0);
-}
-
-
-/* Data functions for rendering the model. */
-
-static void
-toggle_cell_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- ESourceSelector *selector)
-{
- void *data;
-
- gtk_tree_model_get (model, iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_set (renderer, "visible", FALSE, NULL);
- } else {
- g_assert (E_IS_SOURCE (data));
-
- g_object_set (renderer, "visible", selector->priv->checkboxes_shown, NULL);
- if (source_is_selected (selector, E_SOURCE (data)))
- g_object_set (renderer, "active", TRUE, NULL);
- else
- g_object_set (renderer, "active", FALSE, NULL);
- }
-
- g_object_unref (data);
-}
-
-static void
-text_cell_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- ESourceSelector *selector)
-{
- void *data;
-
- gtk_tree_model_get (model, iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_set (renderer,
- "text", e_source_group_peek_name (E_SOURCE_GROUP (data)),
- "weight", PANGO_WEIGHT_BOLD,
- "foreground_set", FALSE,
- NULL);
- } else {
- ESource *source;
-
- g_assert (E_IS_SOURCE (data));
- source = E_SOURCE (data);
-
- g_object_set (renderer,
- "text", e_source_peek_name (source),
- "weight", PANGO_WEIGHT_NORMAL,
- "foreground_set", FALSE,
- NULL);
- }
-
- g_object_unref (data);
-}
-
-static void
-pixbuf_cell_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- ESourceSelector *selector)
-{
- void *data;
-
- gtk_tree_model_get (model, iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_set (renderer,
- "visible", FALSE,
- NULL);
- } else {
- ESource *source;
- guint32 color;
- GdkPixbuf *pixbuf = NULL;
-
- g_assert (E_IS_SOURCE (data));
- source = E_SOURCE (data);
-
- if (e_source_get_color (source, &color)) {
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16);
- gdk_pixbuf_fill (pixbuf, color << 8);
- }
-
- g_object_set (renderer,
- "visible", pixbuf != NULL,
- "pixbuf", pixbuf,
- NULL);
-
- if (pixbuf)
- g_object_unref (pixbuf);
- }
-
- g_object_unref (data);
-}
-
-/* Custom selection function to make groups non selectable. */
-static gboolean
-selection_func (GtkTreeSelection *selection,
- GtkTreeModel *model,
- GtkTreePath *path,
- gboolean path_currently_selected,
- ESourceSelector *selector)
-{
- GtkTreeIter iter;
- void *data;
-
- if (selector->priv->toggled_last) {
- selector->priv->toggled_last = FALSE;
-
- return FALSE;
- }
-
- if (path_currently_selected)
- return TRUE;
-
- if (! gtk_tree_model_get_iter (model, &iter, path))
- return FALSE;
-
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
-
- return FALSE;
- }
-
- clear_saved_primary_selection (selector);
- g_object_unref (data);
-
- return TRUE;
-}
-
-
-/* Callbacks. */
-
-static void
-cell_toggled_callback (GtkCellRendererToggle *renderer,
- const char *path_string,
- ESourceSelector *selector)
-{
- GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- ESource *source;
- void *data;
-
- if (! gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_path_free (path);
- return;
- }
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
- if (!E_IS_SOURCE_GROUP (data)) {
- source = E_SOURCE (data);
-
- if (source_is_selected (selector, source))
- unselect_source (selector, source);
- else
- select_source (selector, source);
-
- selector->priv->toggled_last = TRUE;
-
- gtk_tree_model_row_changed (model, path, &iter);
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
- }
-
- gtk_tree_path_free (path);
-
- g_object_unref (data);
-}
-
-static void
-selection_changed_callback (GtkTreeSelection *selection,
- ESourceSelector *selector)
-{
- g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0);
-}
-
-static gboolean
-test_collapse_row_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
-{
- ESourceSelector *selector = data;
- ESourceSelectorPrivate *priv;
- GtkTreeIter child_iter;
-
- priv = selector->priv;
-
- /* Clear this because something else has been clicked on now */
- priv->toggled_last = FALSE;
-
- if (priv->saved_primary_selection)
- return FALSE;
-
- if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &child_iter))
- return FALSE;
-
- if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) {
- GtkTreePath *child_path;
-
- child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &child_iter);
- priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path);
- gtk_tree_path_free (child_path);
- }
-
- return FALSE;
-}
-
-static gboolean
-row_expanded_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
-{
- ESourceSelector *selector = data;
- ESourceSelectorPrivate *priv;
- GtkTreePath *child_path;
- GtkTreeIter child_iter;
-
- priv = selector->priv;
-
- if (!priv->saved_primary_selection)
- return FALSE;
-
- child_path = gtk_tree_row_reference_get_path (priv->saved_primary_selection);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &child_iter, child_path);
-
- if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
-
- gtk_tree_selection_select_iter (selection, &child_iter);
- clear_saved_primary_selection (selector);
- }
-
- gtk_tree_path_free (child_path);
-
- return FALSE;
-}
-
-static gboolean
-selector_button_press_event (GtkWidget *widget, GdkEventButton *event, ESourceSelector *selector)
-{
- ESourceSelectorPrivate *priv = selector->priv;
- GtkTreePath *path;
- ESource *source = NULL;
- gboolean res = FALSE;
-
- priv->toggled_last = FALSE;
-
- /* only process right-clicks */
- if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
- return FALSE;
-
- /* Get the source/group */
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), event->x, event->y, &path, NULL, NULL, NULL)) {
- GtkTreeIter iter;
- gpointer data;
-
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &iter, path)) {
- gtk_tree_model_get (GTK_TREE_MODEL (priv->tree_store), &iter, 0, &data, -1);
-
- /* TODO: we could still emit a popup event for this and let the callee decide? */
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
-
- return FALSE;
- }
-
- source = E_SOURCE (data);
- }
- }
-
- if (source)
- e_source_selector_set_primary_selection (selector, source);
-
- g_signal_emit(selector, signals[POPUP_EVENT], 0, source, event, &res);
-
- if (source)
- g_object_unref (source);
-
- return res;
-}
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- ESourceSelectorPrivate *priv = E_SOURCE_SELECTOR (object)->priv;
-
- if (priv->selected_sources != NULL) {
- g_hash_table_destroy (priv->selected_sources);
- priv->selected_sources = NULL;
- }
-
- if (priv->rebuild_model_idle_id != 0) {
- g_source_remove (priv->rebuild_model_idle_id);
- priv->rebuild_model_idle_id = 0;
- }
-
- if (priv->list != NULL) {
- g_object_unref (priv->list);
- priv->list = NULL;
- }
-
- if (priv->tree_store != NULL) {
- g_object_unref (priv->tree_store);
- priv->tree_store = NULL;
- }
-
- clear_saved_primary_selection (E_SOURCE_SELECTOR (object));
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- ESourceSelectorPrivate *priv = E_SOURCE_SELECTOR (object)->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static gboolean
-e_source_selector_popup_menu (GtkWidget *widget)
-{
- ESourceSelector *selector = E_SOURCE_SELECTOR (widget);
- ESource *source = e_source_selector_peek_primary_selection (selector);
- gboolean res = FALSE;
-
- if (source) {
- g_object_ref (source);
- g_signal_emit (selector, signals[POPUP_EVENT], 0, source, NULL, &res);
- g_object_unref (source);
- }
-
- return res;
-}
-
-/* Initialization. */
-static gboolean
-ess_bool_accumulator(GSignalInvocationHint *ihint, GValue *out, const GValue *in, void *data)
-{
- gboolean val = g_value_get_boolean(in);
-
- g_value_set_boolean(out, val);
-
- return !val;
-}
-
-static void
-class_init (ESourceSelectorClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- widget_class->popup_menu = e_source_selector_popup_menu;
-
- parent_class = g_type_class_peek_parent (class);
-
- signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceSelectorClass, selection_changed),
- NULL, NULL,
- e_util_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[PRIMARY_SELECTION_CHANGED] =
- g_signal_new ("primary_selection_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceSelectorClass, primary_selection_changed),
- NULL, NULL,
- e_util_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals[POPUP_EVENT] =
- g_signal_new ("popup_event",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESourceSelectorClass, popup_event),
- ess_bool_accumulator, NULL,
- e_util_marshal_BOOLEAN__OBJECT_BOXED,
- G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT,
- GDK_TYPE_EVENT|G_SIGNAL_TYPE_STATIC_SCOPE);
-}
-
-static void
-init (ESourceSelector *selector)
-{
- ESourceSelectorPrivate *priv;
- GtkTreeViewColumn *column;
- GtkCellRenderer *cell_renderer;
- GtkTreeSelection *selection;
-
- priv = g_new0 (ESourceSelectorPrivate, 1);
- selector->priv = priv;
-
- g_signal_connect (G_OBJECT (selector), "button_press_event",
- G_CALLBACK (selector_button_press_event), selector);
-
- priv->toggled_last = FALSE;
- priv->checkboxes_shown = TRUE;
- priv->select_new = FALSE;
-
- priv->selected_sources = create_selected_sources_hash ();
-
- priv->tree_store = gtk_tree_store_new (1, G_TYPE_OBJECT);
- gtk_tree_view_set_model (GTK_TREE_VIEW (selector), GTK_TREE_MODEL (priv->tree_store));
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_append_column (GTK_TREE_VIEW (selector), column);
-
- cell_renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (G_OBJECT (cell_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
- gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) pixbuf_cell_data_func, selector, NULL);
- cell_renderer = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) toggle_cell_data_func, selector, NULL);
- g_signal_connect (cell_renderer, "toggled", G_CALLBACK (cell_toggled_callback), selector);
-
- cell_renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (cell_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
- gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
- gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) text_cell_data_func, selector, NULL);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
- gtk_tree_selection_set_select_function (selection, (GtkTreeSelectionFunc) selection_func, selector, NULL);
- g_signal_connect_object (selection, "changed", G_CALLBACK (selection_changed_callback), G_OBJECT (selector), 0);
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (selector), FALSE);
-
- g_signal_connect (G_OBJECT (selector), "test-collapse-row", G_CALLBACK (test_collapse_row_callback), selector);
- g_signal_connect (G_OBJECT (selector), "row-expanded", G_CALLBACK (row_expanded_callback), selector);
-}
-
-
-/* Public API. */
-
-/**
- * e_source_selector_new:
- * @list: A source list.
- *
- * Create a new view for @list. The view will update automatically when @list
- * changes.
- *
- * Return value: The newly created widget.
- **/
-GtkWidget *
-e_source_selector_new (ESourceList *list)
-{
- ESourceSelector *selector;
-
- g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-
- selector = g_object_new (e_source_selector_get_type (), NULL);
-
- selector->priv->list = list;
- g_object_ref (list);
-
- setup_model (selector);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (selector));
-
- return GTK_WIDGET (selector);
-}
-
-
-/**
- * e_source_selector_get_selection:
- * @selector:
- *
- * Get the list of selected sources, i.e. those that were enabled through the
- * corresponding checkboxes in the tree.
- *
- * Return value: A list of the ESources currently selected. The sources will
- * be in the same order as they appear on the screen, and the list should be
- * freed using e_source_selector_free_selection().
- **/
-GSList *
-e_source_selector_get_selection (ESourceSelector *selector)
-{
- GSList *selection_list;
- GSList *groups;
- GSList *p;
-
- g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL);
-
- selection_list = NULL;
-
- groups = e_source_list_peek_groups (selector->priv->list);
- for (p = groups; p != NULL; p = p->next) {
- ESourceGroup *group = E_SOURCE_GROUP (p->data);
- GSList *sources;
- GSList *q;
-
- sources = e_source_group_peek_sources (group);
- for (q = sources; q != NULL; q = q->next) {
- ESource *source = E_SOURCE (q->data);
-
- if (source_is_selected (selector, source)) {
- selection_list = g_slist_prepend (selection_list, source);
- g_object_ref (source);
- }
- }
- }
-
- return g_slist_reverse (selection_list);
-}
-
-/**
- * e_source_list_free_selection:
- * @list: A selection list returned by e_source_selector_get_selection().
- *
- * Free the selection list.
- **/
-void
-e_source_selector_free_selection (GSList *list)
-{
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
-}
-
-
-/**
- * e_source_selector_show_selection:
- * @selector: An ESourceSelector widget
- *
- * Specify whether the checkboxes in the ESourceSelector should be shown or
- * not.
- **/
-void
-e_source_selector_show_selection (ESourceSelector *selector,
- gboolean show)
-{
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
-
- show = !! show;
- if (show == selector->priv->checkboxes_shown)
- return;
-
- selector->priv->checkboxes_shown = show;
-
- gtk_tree_model_foreach (GTK_TREE_MODEL (selector->priv->tree_store),
- (GtkTreeModelForeachFunc) gtk_tree_model_row_changed,
- NULL);
-}
-
-/**
- * e_source_selector_selection_shown:
- * @selector:
- *
- * Check whether the checkboxes in the ESourceSelector are being shown or not.
- *
- * Return value: %TRUE if the checkboxes are shown, %FALSE otherwise.
- **/
-gboolean
-e_source_selector_selection_shown (ESourceSelector *selector)
-{
- g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE);
-
- return selector->priv->checkboxes_shown;
-}
-
-/**
- * e_source_selector_set_select_new:
- * @selector: An ESourceSelector widget
- * @state: A gboolean
- *
- * Set whether or not to select new sources added to @selector.
- **/
-void
-e_source_selector_set_select_new (ESourceSelector *selector, gboolean state)
-{
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
-
- selector->priv->select_new = state;
-}
-
-/**
- * e_source_selector_select_source:
- * @selector: An ESourceSelector widget
- * @source: An ESource.
- *
- * Select @source in @selector.
- **/
-void
-e_source_selector_select_source (ESourceSelector *selector,
- ESource *source)
-{
- GtkTreeIter parent_iter, source_iter;
-
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
- g_return_if_fail (E_IS_SOURCE (source));
-
- if (source_is_selected (selector, source))
- return;
-
- select_source (selector, source);
-
- if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
- GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (model, &source_iter);
- gtk_tree_model_row_changed (model, path, &source_iter);
- gtk_tree_path_free (path);
-
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
- }
-}
-
-/**
- * e_source_selector_unselect_source:
- * @selector: An ESourceSelector widget
- * @source: An ESource.
- *
- * Unselect @source in @selector.
- **/
-void
-e_source_selector_unselect_source (ESourceSelector *selector,
- ESource *source)
-{
- GtkTreeIter parent_iter, source_iter;
-
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
- g_return_if_fail (E_IS_SOURCE (source));
-
- if (! source_is_selected (selector, source))
- return;
-
- unselect_source (selector, source);
-
- if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
- GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store);
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (model, &source_iter);
- gtk_tree_model_row_changed (model, path, &source_iter);
- gtk_tree_path_free (path);
-
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
- }
-}
-
-/**
- * e_source_selector_source_is_selected:
- * @selector: An ESourceSelector widget
- * @source: An ESource.
- *
- * Check whether @source is selected in @selector.
- *
- * Return value: %TRUE if @source is currently selected, %FALSE otherwise.
- **/
-gboolean
-e_source_selector_source_is_selected (ESourceSelector *selector,
- ESource *source)
-{
- g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE);
- g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
- return source_is_selected (selector, source);
-}
-
-/**
- * e_source_selector_peek_primary_selection:
- * @selector: An ESourceSelector widget
- *
- * Get the primary selected source. The primary selection is the one that is
- * highlighted through the normal GtkTreeView selection mechanism (as opposed
- * to the "normal" selection, which is the set of source whose checkboxes are
- * checked).
- *
- * Return value: The selected source.
- **/
-ESource *
-e_source_selector_peek_primary_selection (ESourceSelector *selector)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean have_iter = FALSE;
- void *data = NULL;
-
- g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL);
-
- model = GTK_TREE_MODEL (selector->priv->tree_store);
-
- if (selector->priv->saved_primary_selection) {
- GtkTreePath *child_path;
-
- child_path = gtk_tree_row_reference_get_path (selector->priv->saved_primary_selection);
- if (child_path) {
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->priv->tree_store), &iter, child_path))
- have_iter = TRUE;
- gtk_tree_path_free (child_path);
- }
- }
-
- if (!have_iter && ! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &iter))
- return NULL;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
- if (!data)
- return NULL;
-
- if (! E_IS_SOURCE (data)) {
- g_object_unref (data);
-
- return NULL;
- }
-
- g_object_unref (data);
-
- return E_SOURCE (data);
-}
-
-/**
- * e_source_selector_set_primary_selection:
- * @selector: An ESourceSelector widget
- * @source: Source to select
- *
- * Set the primary selected source.
- **/
-void
-e_source_selector_set_primary_selection (ESourceSelector *selector, ESource *source)
-{
- ESourceSelectorPrivate *priv;
- GtkTreeIter parent_iter, source_iter;
-
- g_return_if_fail (selector != NULL);
- g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
- g_return_if_fail (source != NULL);
- g_return_if_fail (E_IS_SOURCE (source));
-
- priv = selector->priv;
-
- if (find_source_iter (selector, source, &parent_iter, &source_iter)) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector));
- GtkTreePath *path;
-
- /* We block the signal because this all needs to be atomic */
- g_signal_handlers_block_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL);
- gtk_tree_selection_unselect_all (selection);
- g_signal_handlers_unblock_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL);
-
- clear_saved_primary_selection (selector);
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &parent_iter);
-
- if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (selector), path)) {
- gtk_tree_selection_select_iter (selection, &source_iter);
- } else {
- GtkTreePath *child_path;
-
- child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &source_iter);
- priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path);
- gtk_tree_path_free (child_path);
-
- /* We do this by hand because we aren't changing the tree selection */
- if (!source_is_selected (selector, source)) {
- select_source (selector, source);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->tree_store), path, &source_iter);
- g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
- }
-
- g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0);
- }
-
- gtk_tree_path_free (path);
- } else {
- g_warning (G_STRLOC ": Cannot find source %p (%s) in selector %p",
- source, e_source_peek_name (source), selector);
- }
-}
-
-
-E_MAKE_TYPE (e_source_selector, "ESourceSelector", ESourceSelector, class_init, init, PARENT_TYPE)
diff --git a/widgets/misc/e-source-selector.h b/widgets/misc/e-source-selector.h
deleted file mode 100644
index 1c24261a18..0000000000
--- a/widgets/misc/e-source-selector.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-selector.h
- *
- * Copyright (C) 2003 Ximian, Inc.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifndef _E_SOURCE_SELECTOR_H_
-#define _E_SOURCE_SELECTOR_H_
-
-#include <gtk/gtkmenu.h>
-#include <gtk/gtktreeview.h>
-#include <libedataserver/e-source-list.h>
-
-#define E_TYPE_SOURCE_SELECTOR (e_source_selector_get_type ())
-#define E_SOURCE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_SELECTOR, ESourceSelector))
-#define E_SOURCE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_SELECTOR, ESourceSelectorClass))
-#define E_IS_SOURCE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_SELECTOR))
-#define E_IS_SOURCE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_SELECTOR))
-
-
-typedef struct _ESourceSelector ESourceSelector;
-typedef struct _ESourceSelectorPrivate ESourceSelectorPrivate;
-typedef struct _ESourceSelectorClass ESourceSelectorClass;
-
-struct _ESourceSelector {
- GtkTreeView parent;
-
- ESourceSelectorPrivate *priv;
-};
-
-struct _ESourceSelectorClass {
- GtkTreeViewClass parent_class;
-
- void (* selection_changed) (ESourceSelector *selector);
- void (* primary_selection_changed) (ESourceSelector *selector);
- gboolean (*popup_event)(ESourceSelector *selector, ESource *primary, GdkEventButton *event);
-};
-
-
-GType e_source_selector_get_type (void);
-
-GtkWidget *e_source_selector_new (ESourceList *list);
-
-void e_source_selector_select_source (ESourceSelector *selector,
- ESource *source);
-void e_source_selector_unselect_source (ESourceSelector *selector,
- ESource *source);
-gboolean e_source_selector_source_is_selected (ESourceSelector *selector,
- ESource *source);
-
-GSList *e_source_selector_get_selection (ESourceSelector *selector);
-void e_source_selector_free_selection (GSList *list);
-
-void e_source_selector_show_selection (ESourceSelector *selector,
- gboolean show);
-gboolean e_source_selector_selection_shown (ESourceSelector *selector);
-
-void e_source_selector_set_select_new (ESourceSelector *selector, gboolean state);
-
-ESource *e_source_selector_peek_primary_selection (ESourceSelector *selector);
-void e_source_selector_set_primary_selection (ESourceSelector *selector,
- ESource *source);
-
-
-#endif /* _E_SOURCE_SELECTOR_H_ */
diff --git a/widgets/misc/test-source-option-menu.c b/widgets/misc/test-source-option-menu.c
deleted file mode 100644
index a473c0f972..0000000000
--- a/widgets/misc/test-source-option-menu.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* test-source-option-menu.c - Test for ESourceOptionMenu.
- *
- * Copyright (C) 2003 Novell, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include "e-source-option-menu.h"
-
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkmain.h>
-
-#include <libgnomeui/gnome-ui-init.h>
-
-
-static void
-source_selected_callback (ESourceOptionMenu *menu,
- ESource *source,
- void *unused_data)
-{
- g_print ("source selected: \"%s\"\n", e_source_peek_name (source));
-}
-
-
-static int
-on_idle_create_widget (const char *gconf_path)
-{
- GtkWidget *window;
- GtkWidget *option_menu;
- ESourceList *source_list;
- GConfClient *gconf_client;
-
- gconf_client = gconf_client_get_default ();
- source_list = e_source_list_new_for_gconf (gconf_client, gconf_path);
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- option_menu = e_source_option_menu_new (source_list);
- g_signal_connect (option_menu, "source_selected", G_CALLBACK (source_selected_callback), NULL);
-
- gtk_container_add (GTK_CONTAINER (window), option_menu);
- gtk_widget_show_all (window);
-
- g_object_unref (gconf_client);
- g_object_unref (source_list);
-
- return FALSE;
-}
-
-
-int
-main (int argc, char **argv)
-{
- GnomeProgram *program;
- const char *gconf_path;
-
- program = gnome_program_init ("test-source-list", "0.0", LIBGNOMEUI_MODULE, argc, argv, NULL);
-
- if (argc < 2)
- gconf_path = "/apps/evolution/calendar/sources";
- else
- gconf_path = argv [1];
-
- g_idle_add ((GSourceFunc) on_idle_create_widget, (void *) gconf_path);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/widgets/misc/test-source-selector.c b/widgets/misc/test-source-selector.c
deleted file mode 100644
index 3120f0c948..0000000000
--- a/widgets/misc/test-source-selector.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* test-source-list-selector.c - Test program for the ESourceListSelector
- * widget.
- *
- * Copyright (C) 2002 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-source-selector.h"
-
-#include <gtk/gtkmain.h>
-#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkwindow.h>
-
-#include <libgnomeui/gnome-ui-init.h>
-
-
-static void
-dump_selection (ESourceSelector *selector)
-{
- GSList *selection = e_source_selector_get_selection (selector);
-
- g_print ("Current selection:\n");
- if (selection == NULL) {
- g_print ("\t(None)\n");
- } else {
- GSList *p;
-
- for (p = selection; p != NULL; p = p->next) {
- ESource *source = E_SOURCE (p->data);
-
- g_print ("\tSource %s (group %s)\n",
- e_source_peek_name (source),
- e_source_group_peek_name (e_source_peek_group (source)));
- }
- }
-
- e_source_selector_free_selection (selection);
-}
-
-static void
-selection_changed_callback (ESourceSelector *selector,
- void *unused_data)
-{
- g_print ("Selection changed!\n");
- dump_selection (selector);
-}
-
-static void
-check_toggled_callback (GtkToggleButton *button,
- ESourceSelector *selector)
-{
- e_source_selector_show_selection (selector, gtk_toggle_button_get_active (button));
-}
-
-static int
-on_idle_create_widget (void *unused_data)
-{
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *selector;
- GtkWidget *scrolled_window;
- GtkWidget *check;
- ESourceList *list;
- GConfClient *gconf_client;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (GTK_WINDOW (window), 200, 300);
-
- vbox = gtk_vbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- gconf_client = gconf_client_get_default ();
- list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/test/source_list");
- selector = e_source_selector_new (list);
- g_signal_connect (selector, "selection_changed", G_CALLBACK (selection_changed_callback), NULL);
-
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (scrolled_window), selector);
- gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 3);
-
- check = gtk_check_button_new_with_label ("Show checkboxes");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
- e_source_selector_selection_shown (E_SOURCE_SELECTOR (selector)));
- g_signal_connect (check, "toggled", G_CALLBACK (check_toggled_callback), selector);
- gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 3);
-
- gtk_widget_show_all (window);
-
- g_object_unref (gconf_client);
- return FALSE;
-}
-
-
-int
-main (int argc, char **argv)
-{
- GnomeProgram *program;
-
- program = gnome_program_init ("test-source-list", "0.0",
- LIBGNOMEUI_MODULE, argc, argv,
- NULL);
-
- g_idle_add (on_idle_create_widget, NULL);
- gtk_main ();
-
- return 0;
-}