Bumped the required version of gal.

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* configure.in: Bumped the required version of gal.

From addressbook/ChangeLog:

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* gui/widgets/e-addressbook-view.c
	(e_addressbook_view_setup_menus): Changed this function to use the
	new GalViewMenus which takes a GalViewInstance, instead of a
	GalViewCollection.

From calendar/ChangeLog:

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* gui/e-tasks.c (e_tasks_setup_view_menus), gui/gnome-cal.c
	(gnome_calendar_setup_view_menus): Made these use the new
	GalViewMenus stuff.

From mail/ChangeLog:

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* folder-browser.c, folder-browser.h, folder-browser-ui.c,
	folder-browser-ui.h
	(folder_browser_ui_setup_view_menus,
	folder_browser_ui_discard_view_menus): Changed this to use the new
	GalViewMenus stuff.  Made these exported functions.

	* mail-callbacks.c, message-browser.c: Changed these to not pass
	the now removed row parameter to message_list_select.

	* mail-config.c, mail-config.h (mail_config_folder_to_safe_url):
	Refactored this out of mail_config_folder_to_cachename.

	* message-list.c, message-list.h (message_list_select): Removed
	the row argument.  Changed this to use the new function in ETree
	for finding the next cursor row that matches a test.
	(message_list_construct): Handle a failed construction of the
	ETree here.
	(message_list_setup_etree, save_tree_state): Don't load or save
	the header state.  folder-browser-ui.c deals with this now.

From views/ChangeLog:

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* addressbook/galview.xml, calendar/galview.xml, mail/galview.xml,
	tasks/galview.xml: Added default-view parameters.

	* mail/As_Sent_Folder.galview: New galview.

	* mail/Makefile.am, mail/galview.xml: Added As_Sent_Folder
	galview.

From widgets/ChangeLog:

2002-02-07  Christopher James Lahey  <clahey@ximian.com>

	* menus/gal-view-menus.c, menus/gal-view-menus.h
	(gal_view_menus_new): Made this take a GalViewInstance instead of
	a GalViewCollection.  Reworked most of this to utilize the
	interfaces provided by GalViewInstance.

svn path=/trunk/; revision=15592
This commit is contained in:
Christopher James Lahey 2002-02-07 11:24:08 +00:00 committed by Chris Lahey
parent 9f83d6d318
commit b7ac37f6b1
28 changed files with 856 additions and 533 deletions

View File

@ -1,3 +1,7 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* configure.in: Bumped the required version of gal.
2002-01-28 Radek Doulik <rodo@ximian.com>
* configure.in: added bonobo to filter flags to avoid compile

View File

@ -1,3 +1,10 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* gui/widgets/e-addressbook-view.c
(e_addressbook_view_setup_menus): Changed this function to use the
new GalViewMenus which takes a GalViewInstance, instead of a
GalViewCollection.
2002-02-04 JP Rosevear <jpr@ximian.com>
* gui/contact-editor/e-contact-editor.c (find_address_mailing): tidy

View File

@ -34,6 +34,7 @@
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
#include <gal/util/e-unicode-i18n.h>
#include <gal/util/e-xml-utils.h>
#include <gal/unicode/gunicode.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-stock.h>
@ -62,6 +63,9 @@
#include <gdk/gdkkeysyms.h>
#include <ctype.h>
#include <gnome-xml/tree.h>
#include <gnome-xml/parser.h>
#define SHOW_ALL_SEARCH "(contains \"x-evolution-any-field\" \"\")"
static void e_addressbook_view_init (EAddressbookView *card);
@ -117,6 +121,8 @@ static guint e_addressbook_view_signals [LAST_SIGNAL] = {0, };
static GdkAtom clipboard_atom = GDK_NONE;
static GalViewCollection *collection = NULL;
GtkType
e_addressbook_view_get_type (void)
{
@ -235,8 +241,9 @@ e_addressbook_view_init (EAddressbookView *eav)
eav->object = NULL;
eav->widget = NULL;
eav->view_collection = NULL;
eav->view_instance = NULL;
eav->view_menus = NULL;
eav->uic = NULL;
eav->current_alphabet_widget = NULL;
eav->invisible = gtk_invisible_new ();
@ -278,9 +285,11 @@ e_addressbook_view_destroy (GtkObject *object)
g_free(eav->query);
eav->query = NULL;
if (eav->view_collection) {
gtk_object_unref (GTK_OBJECT (eav->view_collection));
eav->view_collection = NULL;
eav->uic = NULL;
if (eav->view_instance) {
gtk_object_unref (GTK_OBJECT (eav->view_instance));
eav->view_instance = NULL;
}
if (eav->view_menus) {
@ -320,6 +329,171 @@ book_writable_cb (EBook *book, gboolean writable, EAddressbookView *eav)
writable_status (GTK_OBJECT(book), writable, eav);
}
#ifdef JUST_FOR_TRANSLATORS
static char *list [] = {
N_("* Click here to add a contact *"),
N_("File As"),
N_("Full Name"),
N_("Email"),
N_("Primary Phone"),
N_("Assistant Phone"),
N_("Business Phone"),
N_("Callback Phone"),
N_("Company Phone"),
N_("Home Phone"),
N_("Organization"),
N_("Business Address"),
N_("Home Address"),
N_("Mobile Phone"),
N_("Car Phone"),
N_("Business Fax"),
N_("Home Fax"),
N_("Business Phone 2"),
N_("Home Phone 2"),
N_("ISDN"),
N_("Other Phone"),
N_("Other Fax"),
N_("Pager"),
N_("Radio"),
N_("Telex"),
N_("TTY"),
N_("Other Address"),
N_("Email 2"),
N_("Email 3"),
N_("Web Site"),
N_("Department"),
N_("Office"),
N_("Title"),
N_("Profession"),
N_("Manager"),
N_("Assistant"),
N_("Nickname"),
N_("Spouse"),
N_("Note"),
N_("Free-busy URL"),
};
#endif
#define SPEC "<?xml version=\"1.0\"?> \
<ETableSpecification click-to-add=\"true\" draw-grid=\"true\" _click-to-add-message=\"* Click here to add a contact *\"> \
<ETableColumn model_col= \"0\" _title=\"File As\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"1\" _title=\"Full Name\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"2\" _title=\"Email\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"3\" _title=\"Primary Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"4\" _title=\"Assistant Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"5\" _title=\"Business Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"6\" _title=\"Callback Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"7\" _title=\"Company Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"8\" _title=\"Home Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"9\" _title=\"Organization\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"10\" _title=\"Business Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"11\" _title=\"Home Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"12\" _title=\"Mobile Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"13\" _title=\"Car Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"14\" _title=\"Business Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"15\" _title=\"Home Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"16\" _title=\"Business Phone 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"17\" _title=\"Home Phone 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"18\" _title=\"ISDN\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"19\" _title=\"Other Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"20\" _title=\"Other Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"21\" _title=\"Pager\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"22\" _title=\"Radio\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"23\" _title=\"Telex\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"24\" _title=\"TTY\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"25\" _title=\"Other Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"26\" _title=\"Email 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"27\" _title=\"Email 3\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"28\" _title=\"Web Site\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"29\" _title=\"Department\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"30\" _title=\"Office\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"31\" _title=\"Title\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"32\" _title=\"Profession\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"33\" _title=\"Manager\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"34\" _title=\"Assistant\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"35\" _title=\"Nickname\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"36\" _title=\"Spouse\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"37\" _title=\"Note\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"38\" _title=\"Free-busy URL\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableState> \
<column source=\"0\"/> \
<column source=\"1\"/> \
<column source=\"5\"/> \
<column source=\"2\"/> \
<column source=\"3\"/> \
<grouping> \
<leaf column=\"0\" ascending=\"true\"/> \
</grouping> \
</ETableState> \
</ETableSpecification>"
static void
init_collection (void)
{
GalViewFactory *factory;
ETableSpecification *spec;
char *galview;
if (collection == NULL) {
collection = gal_view_collection_new();
galview = gnome_util_prepend_user_home("/evolution/views/addressbook/");
gal_view_collection_set_storage_directories
(collection,
EVOLUTION_DATADIR "/evolution/views/addressbook/",
galview);
g_free(galview);
spec = e_table_specification_new();
e_table_specification_load_from_string(spec, SPEC);
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
factory = gal_view_factory_minicard_new ();
gal_view_collection_add_factory (collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
gal_view_collection_load(collection);
}
}
static void
display_view(GalViewInstance *instance,
GalView *view,
gpointer data)
{
EAddressbookView *address_view = data;
if (GAL_IS_VIEW_ETABLE(view)) {
change_view_type (address_view, E_ADDRESSBOOK_VIEW_TABLE);
gal_view_etable_attach_table (GAL_VIEW_ETABLE(view), e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget)));
} else if (GAL_IS_VIEW_MINICARD(view)) {
change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD);
}
address_view->current_view = view;
}
static void
setup_menus (EAddressbookView *view)
{
if (view->book && view->view_instance == NULL) {
init_collection ();
view->view_instance = gal_view_instance_new (collection, e_book_get_uri (view->book));
}
if (view->view_instance && view->uic) {
view->view_menus = gal_view_menus_new(view->view_instance);
gal_view_menus_apply(view->view_menus, view->uic, NULL);
display_view (view->view_instance, gal_view_instance_get_current_view (view->view_instance), view);
gtk_signal_connect(GTK_OBJECT(view->view_instance), "display_view",
display_view, view);
}
}
static void
e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
@ -339,10 +513,17 @@ e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
else
eav->book = NULL;
if (eav->view_instance) {
gtk_object_unref (GTK_OBJECT (eav->view_instance));
eav->view_instance = NULL;
}
gtk_object_set(GTK_OBJECT(eav->model),
"book", eav->book,
NULL);
setup_menus (eav);
break;
case ARG_QUERY:
@ -954,104 +1135,6 @@ alphabet_state_change (EAddressbookView *eav, gunichar letter)
gtk_signal_emit (GTK_OBJECT (eav), e_addressbook_view_signals [ALPHABET_STATE_CHANGE], letter);
}
#ifdef JUST_FOR_TRANSLATORS
static char *list [] = {
N_("* Click here to add a contact *"),
N_("File As"),
N_("Full Name"),
N_("Email"),
N_("Primary Phone"),
N_("Assistant Phone"),
N_("Business Phone"),
N_("Callback Phone"),
N_("Company Phone"),
N_("Home Phone"),
N_("Organization"),
N_("Business Address"),
N_("Home Address"),
N_("Mobile Phone"),
N_("Car Phone"),
N_("Business Fax"),
N_("Home Fax"),
N_("Business Phone 2"),
N_("Home Phone 2"),
N_("ISDN"),
N_("Other Phone"),
N_("Other Fax"),
N_("Pager"),
N_("Radio"),
N_("Telex"),
N_("TTY"),
N_("Other Address"),
N_("Email 2"),
N_("Email 3"),
N_("Web Site"),
N_("Department"),
N_("Office"),
N_("Title"),
N_("Profession"),
N_("Manager"),
N_("Assistant"),
N_("Nickname"),
N_("Spouse"),
N_("Note"),
N_("Free-busy URL"),
};
#endif
#define SPEC "<?xml version=\"1.0\"?> \
<ETableSpecification click-to-add=\"true\" draw-grid=\"true\" _click-to-add-message=\"* Click here to add a contact *\"> \
<ETableColumn model_col= \"0\" _title=\"File As\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"1\" _title=\"Full Name\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"2\" _title=\"Email\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"3\" _title=\"Primary Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"4\" _title=\"Assistant Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"5\" _title=\"Business Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"6\" _title=\"Callback Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"7\" _title=\"Company Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"8\" _title=\"Home Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col= \"9\" _title=\"Organization\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"10\" _title=\"Business Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"11\" _title=\"Home Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"12\" _title=\"Mobile Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"13\" _title=\"Car Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"14\" _title=\"Business Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"15\" _title=\"Home Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"16\" _title=\"Business Phone 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"17\" _title=\"Home Phone 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"18\" _title=\"ISDN\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"19\" _title=\"Other Phone\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"20\" _title=\"Other Fax\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"21\" _title=\"Pager\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"22\" _title=\"Radio\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"23\" _title=\"Telex\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"24\" _title=\"TTY\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"25\" _title=\"Other Address\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"26\" _title=\"Email 2\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"27\" _title=\"Email 3\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"28\" _title=\"Web Site\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"29\" _title=\"Department\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"30\" _title=\"Office\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"31\" _title=\"Title\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"32\" _title=\"Profession\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"33\" _title=\"Manager\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"34\" _title=\"Assistant\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"35\" _title=\"Nickname\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"36\" _title=\"Spouse\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"37\" _title=\"Note\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableColumn model_col=\"38\" _title=\"Free-busy URL\" expansion=\"1.0\" minimum_width=\"75\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
<ETableState> \
<column source=\"0\"/> \
<column source=\"1\"/> \
<column source=\"5\"/> \
<column source=\"2\"/> \
<column source=\"3\"/> \
<grouping> \
<leaf column=\"0\" ascending=\"true\"/> \
</grouping> \
</ETableState> \
</ETableSpecification>"
static void
create_table_view (EAddressbookView *view)
{
@ -1199,70 +1282,28 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
}
}
static void
display_view(GalViewCollection *collection,
GalView *view,
gpointer data)
{
EAddressbookView *address_view = data;
if (GAL_IS_VIEW_ETABLE(view)) {
change_view_type (address_view, E_ADDRESSBOOK_VIEW_TABLE);
e_table_set_state_object(e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget)), GAL_VIEW_ETABLE(view)->state);
} else if (GAL_IS_VIEW_MINICARD(view)) {
change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD);
}
}
void
e_addressbook_view_setup_menus (EAddressbookView *view,
BonoboUIComponent *uic)
{
GalViewFactory *factory;
ETableSpecification *spec;
char *galview;
g_return_if_fail (view != NULL);
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
g_return_if_fail (uic != NULL);
g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
g_return_if_fail (view->view_collection == NULL);
g_assert (view->view_collection == NULL);
g_assert (view->view_menus == NULL);
init_collection ();
view->view_collection = gal_view_collection_new();
view->uic = uic;
galview = gnome_util_prepend_user_home("/evolution/views/addressbook/");
gal_view_collection_set_storage_directories(view->view_collection,
EVOLUTION_DATADIR "/evolution/views/addressbook/",
galview);
g_free(galview);
spec = e_table_specification_new();
e_table_specification_load_from_string(spec, SPEC);
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (view->view_collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
factory = gal_view_factory_minicard_new ();
gal_view_collection_add_factory (view->view_collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
gal_view_collection_load(view->view_collection);
view->view_menus = gal_view_menus_new(view->view_collection);
gal_view_menus_apply(view->view_menus, uic, NULL);
gtk_signal_connect(GTK_OBJECT(view->view_collection), "display_view",
display_view, view);
setup_menus (view);
}
/**
* e_addressbook_view_discard_menus:
* @view: An addressbook view.
*
* Makes an addressbook view discard its GAL view menus and its views collection
* Makes an addressbook view discard its GAL view menus and its views instance
* objects. This should be called when the corresponding Bonobo component is
* deactivated.
**/
@ -1271,16 +1312,19 @@ e_addressbook_view_discard_menus (EAddressbookView *view)
{
g_return_if_fail (view != NULL);
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
g_return_if_fail (view->view_collection);
g_return_if_fail (view->view_instance);
g_assert (view->view_collection != NULL);
g_assert (view->view_menus != NULL);
if (view->view_instance) {
gtk_object_unref (GTK_OBJECT (view->view_instance));
view->view_instance = NULL;
}
gtk_object_unref (GTK_OBJECT (view->view_collection));
view->view_collection = NULL;
if (view->view_menus) {
gtk_object_unref (GTK_OBJECT (view->view_menus));
view->view_menus = NULL;
}
gtk_object_unref (GTK_OBJECT (view->view_menus));
view->view_menus = NULL;
view->uic = NULL;
}
static ESelectionModel*
@ -1508,6 +1552,81 @@ get_selected_cards (EAddressbookView *view)
return list;
}
#if 0
void
e_addressbook_view_save_state (EAddressbookView *view, const char *filename)
{
xmlDoc *doc;
xmlNode *node;
doc = xmlNewDoc ("1.0");
node = xmlNewDocNode (doc, NULL, "addressbook-view", NULL);
xmlDocSetRootElement (doc, node);
switch (view->view_type) {
case E_ADDRESSBOOK_VIEW_MINICARD: {
int column_width;
e_xml_set_string_prop_by_name (node, "style", "minicard");
gtk_object_get (GTK_OBJECT (view->object),
"column_width", &column_width,
NULL);
e_xml_set_integer_prop_by_name (node, "column-width", column_width);
break;
}
case E_ADDRESSBOOK_VIEW_TABLE: {
ETableState *state;
state = e_table_get_state_object (E_TABLE (view->widget));
e_xml_set_string_prop_by_name (node, "style", "table");
e_table_state_save_to_node (state, node);
gtk_object_unref (GTK_OBJECT (state));
break;
}
default:
xmlFreeDoc(doc);
return;
}
xmlSaveFile (filename, doc);
xmlFreeDoc(doc);
}
void
e_addressbook_view_load_state (EAddressbookView *view, const char *filename)
{
xmlDoc *doc;
doc = xmlParseFile (filename);
if (doc) {
xmlNode *node;
char *type;
node = xmlDocGetRootElement (doc);
type = e_xml_get_string_prop_by_name (node, "style");
if (!strcmp (type, "minicard")) {
int column_width;
change_view_type (view, E_ADDRESSBOOK_VIEW_MINICARD);
column_width = e_xml_get_integer_prop_by_name (node, "column-width");
gtk_object_set (GTK_OBJECT (view->object),
"column_width", column_width,
NULL);
} else if (!strcmp (type, "table")) {
ETableState *state;
change_view_type (view, E_ADDRESSBOOK_VIEW_TABLE);
state = e_table_state_new();
e_table_state_load_from_node (state, node->xmlChildrenNode);
e_table_set_state_object (E_TABLE (view->widget), state);
gtk_object_unref (GTK_OBJECT (state));
}
xmlFreeDoc(doc);
}
}
#endif
void
e_addressbook_view_save_as (EAddressbookView *view)
{

View File

@ -1,3 +1,9 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* gui/e-tasks.c (e_tasks_setup_view_menus), gui/gnome-cal.c
(gnome_calendar_setup_view_menus): Made these use the new
GalViewMenus stuff.
2002-02-06 Damon Chaplin <damon@ximian.com>
* cal-util/cal-recur.c (cal_recur_from_icalproperty): convert months

View File

@ -26,7 +26,7 @@
#include <gnome.h>
#include <gal/util/e-util.h>
#include <gal/e-table/e-table-scrolled.h>
#include <gal/menus/gal-view-collection.h>
#include <gal/menus/gal-view-instance.h>
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
#include "widgets/menus/gal-view-menus.h"
@ -54,8 +54,8 @@ struct _ETasksPrivate {
/* Calendar search bar for tasks */
GtkWidget *search_bar;
/* View collection and the view menus handler */
GalViewCollection *view_collection;
/* View instance and the view menus handler */
GalViewInstance *view_instance;
GalViewMenus *view_menus;
};
@ -122,7 +122,7 @@ e_tasks_init (ETasks *tasks)
priv->client = NULL;
priv->query = NULL;
priv->view_collection = NULL;
priv->view_instance = NULL;
priv->view_menus = NULL;
setup_widgets (tasks);
@ -646,7 +646,7 @@ e_tasks_delete_completed (ETasks *tasks)
/* Callback used from the view collection when we need to display a new view */
static void
display_view_cb (GalViewCollection *collection, GalView *view, gpointer data)
display_view_cb (GalViewInstance *instance, GalView *view, gpointer data)
{
ETasks *tasks;
@ -674,6 +674,7 @@ e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic)
GalViewFactory *factory;
ETableSpecification *spec;
char *dir;
static GalViewCollection *collection = NULL;
g_return_if_fail (tasks != NULL);
g_return_if_fail (E_IS_TASKS (tasks));
@ -682,40 +683,45 @@ e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic)
priv = tasks->priv;
g_return_if_fail (priv->view_collection == NULL);
g_return_if_fail (priv->view_instance == NULL);
g_assert (priv->view_collection == NULL);
g_assert (priv->view_instance == NULL);
g_assert (priv->view_menus == NULL);
/* Create the view collection */
/* Create the view instance */
priv->view_collection = gal_view_collection_new ();
if (collection == NULL) {
collection = gal_view_collection_new ();
dir = gnome_util_prepend_user_home ("/evolution/views/tasks/");
gal_view_collection_set_storage_directories (priv->view_collection,
EVOLUTION_DATADIR "/evolution/views/tasks/",
dir);
g_free (dir);
dir = gnome_util_prepend_user_home ("/evolution/views/tasks/");
gal_view_collection_set_storage_directories (collection,
EVOLUTION_DATADIR "/evolution/views/tasks/",
dir);
g_free (dir);
/* Create the views */
/* Create the views */
spec = e_table_specification_new ();
e_table_specification_load_from_file (spec,
EVOLUTION_ETSPECDIR "/e-calendar-table.etspec");
spec = e_table_specification_new ();
e_table_specification_load_from_file (spec,
EVOLUTION_ETSPECDIR "/e-calendar-table.etspec");
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (priv->view_collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
/* Load the collection and create the menus */
/* Load the collection and create the menus */
gal_view_collection_load (priv->view_collection);
gal_view_collection_load (collection);
}
priv->view_menus = gal_view_menus_new (priv->view_collection);
priv->view_instance = gal_view_instance_new (collection, cal_client_get_uri (priv->client));
priv->view_menus = gal_view_menus_new (priv->view_instance);
gal_view_menus_apply (priv->view_menus, uic, NULL);
gtk_signal_connect (GTK_OBJECT (priv->view_collection), "display_view",
gtk_signal_connect (GTK_OBJECT (priv->view_instance), "display_view",
GTK_SIGNAL_FUNC (display_view_cb), tasks);
display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), tasks);
}
/**
@ -736,13 +742,13 @@ e_tasks_discard_view_menus (ETasks *tasks)
priv = tasks->priv;
g_return_if_fail (priv->view_collection != NULL);
g_return_if_fail (priv->view_instance != NULL);
g_assert (priv->view_collection != NULL);
g_assert (priv->view_instance != NULL);
g_assert (priv->view_menus != NULL);
gtk_object_unref (GTK_OBJECT (priv->view_collection));
priv->view_collection = NULL;
gtk_object_unref (GTK_OBJECT (priv->view_instance));
priv->view_instance = NULL;
gtk_object_unref (GTK_OBJECT (priv->view_menus));
priv->view_menus = NULL;

View File

@ -129,8 +129,8 @@ struct _GnomeCalendarPrivate {
/* The signal handler id for our GtkCalendar "day_selected" handler. */
guint day_selected_id;
/* View collection and menus for the control */
GalViewCollection *view_collection;
/* View instance and menus for the control */
GalViewInstance *view_instance;
GalViewMenus *view_menus;
/* Whether we are being destroyed and should not mess with the object
@ -917,7 +917,7 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->zone);
priv->selection_end_time = time_add_day_with_zone (priv->selection_start_time, 1, priv->zone);
priv->view_collection = NULL;
priv->view_instance = NULL;
priv->view_menus = NULL;
priv->visible_start = -1;
@ -999,9 +999,9 @@ gnome_calendar_destroy (GtkObject *object)
g_hash_table_destroy (priv->object_editor_hash);
priv->object_editor_hash = NULL;
if (priv->view_collection) {
gtk_object_unref (GTK_OBJECT (priv->view_collection));
priv->view_collection = NULL;
if (priv->view_instance) {
gtk_object_unref (GTK_OBJECT (priv->view_instance));
priv->view_instance = NULL;
}
if (priv->view_menus) {
@ -1325,7 +1325,7 @@ gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type,
/* Callback used when the view collection asks us to display a particular view */
static void
display_view_cb (GalViewCollection *view_collection, GalView *view, gpointer data)
display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
{
GnomeCalendar *gcal;
CalendarView *cal_view;
@ -1355,6 +1355,7 @@ gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic)
GnomeCalendarPrivate *priv;
char *path;
CalendarViewFactory *factory;
static GalViewCollection *collection = NULL;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
@ -1363,47 +1364,52 @@ gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic)
priv = gcal->priv;
g_return_if_fail (priv->view_collection == NULL);
g_return_if_fail (priv->view_instance == NULL);
g_assert (priv->view_collection == NULL);
g_assert (priv->view_instance == NULL);
g_assert (priv->view_menus == NULL);
/* Create the view collection */
/* Create the view instance */
priv->view_collection = gal_view_collection_new ();
if (collection == NULL) {
collection = gal_view_collection_new ();
path = gnome_util_prepend_user_home ("/evolution/views/calendar/");
gal_view_collection_set_storage_directories (priv->view_collection,
EVOLUTION_DATADIR "/evolution/views/calendar/",
path);
g_free (path);
path = gnome_util_prepend_user_home ("/evolution/views/calendar/");
gal_view_collection_set_storage_directories (collection,
EVOLUTION_DATADIR "/evolution/views/calendar/",
path);
g_free (path);
/* Create the views */
/* Create the views */
factory = calendar_view_factory_new (GNOME_CAL_DAY_VIEW);
gal_view_collection_add_factory (priv->view_collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_DAY_VIEW);
gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_WORK_WEEK_VIEW);
gal_view_collection_add_factory (priv->view_collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_WORK_WEEK_VIEW);
gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_WEEK_VIEW);
gal_view_collection_add_factory (priv->view_collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_WEEK_VIEW);
gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_MONTH_VIEW);
gal_view_collection_add_factory (priv->view_collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
factory = calendar_view_factory_new (GNOME_CAL_MONTH_VIEW);
gal_view_collection_add_factory (collection, GAL_VIEW_FACTORY (factory));
gtk_object_unref (GTK_OBJECT (factory));
/* Load the collection and create the menus */
/* Load the collection and create the menus */
gal_view_collection_load (priv->view_collection);
gal_view_collection_load (collection);
}
priv->view_menus = gal_view_menus_new (priv->view_collection);
priv->view_instance = gal_view_instance_new (collection, cal_client_get_uri (priv->client));
priv->view_menus = gal_view_menus_new (priv->view_instance);
gal_view_menus_apply (priv->view_menus, uic, NULL);
gtk_signal_connect (GTK_OBJECT (priv->view_collection), "display_view",
gtk_signal_connect (GTK_OBJECT (priv->view_instance), "display_view",
GTK_SIGNAL_FUNC (display_view_cb), gcal);
display_view_cb (priv->view_instance, gal_view_instance_get_current_view (priv->view_instance), gcal);
}
/**
@ -1423,13 +1429,13 @@ gnome_calendar_discard_view_menus (GnomeCalendar *gcal)
priv = gcal->priv;
g_return_if_fail (priv->view_collection != NULL);
g_return_if_fail (priv->view_instance != NULL);
g_assert (priv->view_collection != NULL);
g_assert (priv->view_instance != NULL);
g_assert (priv->view_menus != NULL);
gtk_object_unref (GTK_OBJECT (priv->view_collection));
priv->view_collection = NULL;
gtk_object_unref (GTK_OBJECT (priv->view_instance));
priv->view_instance = NULL;
gtk_object_unref (GTK_OBJECT (priv->view_menus));
priv->view_menus = NULL;

View File

@ -579,7 +579,7 @@ EVO_CHECK_LIB(GNOME-VFS, vfs, 1.0)
EVO_CHECK_LIB(libxml, xml, 1.8.10, 2.0)
EVO_CHECK_LIB(bonobo-conf, bonobo_conf, 0.11)
EVO_CHECK_LIB(GAL, gal, 0.19.99.1)
EVO_CHECK_LIB(GAL, gal, 0.19.99.5)
EVO_CHECK_LIB(GtkHTML, gtkhtml, 1.0)
EVO_CHECK_LIB(Libsoup, soup, 0.6)

View File

@ -1,3 +1,25 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* folder-browser.c, folder-browser.h, folder-browser-ui.c,
folder-browser-ui.h
(folder_browser_ui_setup_view_menus,
folder_browser_ui_discard_view_menus): Changed this to use the new
GalViewMenus stuff. Made these exported functions.
* mail-callbacks.c, message-browser.c: Changed these to not pass
the now removed row parameter to message_list_select.
* mail-config.c, mail-config.h (mail_config_folder_to_safe_url):
Refactored this out of mail_config_folder_to_cachename.
* message-list.c, message-list.h (message_list_select): Removed
the row argument. Changed this to use the new function in ETree
for finding the next cursor row that matches a test.
(message_list_construct): Handle a failed construction of the
ETree here.
(message_list_setup_etree, save_tree_state): Don't load or save
the header state. folder-browser-ui.c deals with this now.
2002-02-06 Jeffrey Stedfast <fejj@ximian.com>
* mail-account-gui.c (mail_account_gui_new): Rearranged the #if

View File

@ -194,61 +194,110 @@ static void ui_add (FolderBrowser *fb,
/* more complex stuff */
static void
display_view(GalViewCollection *collection,
display_view(GalViewInstance *instance,
GalView *view,
gpointer data)
{
FolderBrowser *fb = data;
if (GAL_IS_VIEW_ETABLE(view)) {
e_tree_set_state_object(fb->message_list->tree, GAL_VIEW_ETABLE(view)->state);
gal_view_etable_attach_tree (GAL_VIEW_ETABLE(view), fb->message_list->tree);
}
}
static void
folder_browser_setup_view_menus (FolderBrowser *fb,
BonoboUIComponent *uic)
void
folder_browser_ui_setup_view_menus (FolderBrowser *fb)
{
GalViewFactory *factory;
ETableSpecification *spec;
char *local_dir;
static GalViewCollection *collection = NULL;
char *id;
gboolean outgoing;
g_assert (fb->view_collection == NULL);
if (fb->uicomp == NULL || fb->folder == NULL)
return;
g_assert (fb->view_instance == NULL);
g_assert (fb->view_menus == NULL);
fb->view_collection = gal_view_collection_new();
outgoing = folder_browser_is_drafts (fb) ||
folder_browser_is_sent (fb) ||
folder_browser_is_outbox (fb);
local_dir = gnome_util_prepend_user_home ("/evolution/views/mail/");
gal_view_collection_set_storage_directories(
fb->view_collection,
EVOLUTION_DATADIR "/evolution/views/mail/",
local_dir);
g_free (local_dir);
if (collection == NULL) {
ETableSpecification *spec;
char *local_dir;
GalViewFactory *factory;
spec = e_table_specification_new();
e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
collection = gal_view_collection_new();
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (fb->view_collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
local_dir = gnome_util_prepend_user_home ("/evolution/views/mail/");
gal_view_collection_set_storage_directories
(collection,
EVOLUTION_DATADIR "/evolution/views/mail/",
local_dir);
g_free (local_dir);
gal_view_collection_load(fb->view_collection);
spec = e_table_specification_new();
e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
fb->view_menus = gal_view_menus_new(fb->view_collection);
gal_view_menus_apply(fb->view_menus, uic, NULL);
gtk_signal_connect(GTK_OBJECT(fb->view_collection), "display_view",
factory = gal_view_factory_etable_new (spec);
gtk_object_unref (GTK_OBJECT (spec));
gal_view_collection_add_factory (collection, factory);
gtk_object_unref (GTK_OBJECT (factory));
gal_view_collection_load(collection);
}
id = mail_config_folder_to_safe_url(fb->folder);
fb->view_instance = gal_view_instance_new (collection, id);
g_free (id);
if (outgoing)
gal_view_instance_set_default_view (fb->view_instance, "As_Sent_Folder");
if (!gal_view_instance_exists (fb->view_instance)) {
char *path;
struct stat st;
gal_view_instance_load (fb->view_instance);
path = mail_config_folder_to_cachename (fb->folder, "et-header-");
if (path && stat (path, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) {
ETableSpecification *spec;
ETableState *state;
GalView *view;
spec = e_table_specification_new();
e_table_specification_load_from_file(spec, EVOLUTION_ETSPECDIR "/message-list.etspec");
view = gal_view_etable_new(spec, "");
gtk_object_unref (GTK_OBJECT (spec));
state = e_table_state_new ();
e_table_state_load_from_file (state, path);
gal_view_etable_set_state (GAL_VIEW_ETABLE (view), state);
gtk_object_unref (GTK_OBJECT (state));
gal_view_instance_set_custom_view (fb->view_instance, view);
gtk_object_unref (GTK_OBJECT (view));
}
g_free (path);
}
fb->view_menus = gal_view_menus_new(fb->view_instance);
gal_view_menus_apply(fb->view_menus, fb->uicomp, NULL);
gtk_signal_connect(GTK_OBJECT(fb->view_instance), "display_view",
display_view, fb);
display_view (fb->view_instance, gal_view_instance_get_current_view (fb->view_instance), fb);
}
/* Gets rid of the view collection and view menus objects */
static void
folder_browser_discard_view_menus (FolderBrowser *fb)
/* Gets rid of the view instance and view menus objects */
void
folder_browser_ui_discard_view_menus (FolderBrowser *fb)
{
g_assert (fb->view_collection != NULL);
g_assert (fb->view_instance != NULL);
g_assert (fb->view_menus != NULL);
gtk_object_unref (GTK_OBJECT (fb->view_collection));
fb->view_collection = NULL;
gtk_object_unref (GTK_OBJECT (fb->view_instance));
fb->view_instance = NULL;
gtk_object_unref (GTK_OBJECT (fb->view_menus));
fb->view_menus = NULL;
@ -371,14 +420,16 @@ folder_browser_ui_add_list (FolderBrowser *fb)
folder_browser_setup_property_menu (fb, fb->uicomp);
/* View menu */
folder_browser_setup_view_menus (fb, fb->uicomp);
if (fb->view_instance == NULL)
folder_browser_ui_setup_view_menus (fb);
}
void
folder_browser_ui_rm_list (FolderBrowser *fb)
{
/* View menu */
folder_browser_discard_view_menus (fb);
if (fb->view_instance != NULL)
folder_browser_ui_discard_view_menus (fb);
}
void

View File

@ -24,6 +24,8 @@ void folder_browser_ui_rm_all (FolderBrowser *fb);
void folder_browser_ui_set_selection_state (FolderBrowser *fb, FolderBrowserSelectionState state);
void folder_browser_ui_message_loaded (FolderBrowser *fb);
void folder_browser_ui_discard_view_menus (FolderBrowser *fb);
void folder_browser_ui_setup_view_menus (FolderBrowser *fb);
/* Set the sensitivity of a single item */
void fbui_sensitise_item(FolderBrowser *fb, const char *item, int state);

View File

@ -155,9 +155,9 @@ folder_browser_finalise (GtkObject *object)
CORBA_exception_free (&ev);
if (folder_browser->view_collection) {
gtk_object_unref (GTK_OBJECT (folder_browser->view_collection));
folder_browser->view_collection = NULL;
if (folder_browser->view_instance) {
gtk_object_unref (GTK_OBJECT (folder_browser->view_instance));
folder_browser->view_instance = NULL;
}
if (folder_browser->view_menus) {
@ -850,6 +850,11 @@ got_folder(char *uri, CamelFolder *folder, void *data)
camel_object_hook_event(CAMEL_OBJECT(fb->folder), "message_changed",
folder_changed, fb);
if (fb->view_instance != NULL && fb->view_menus != NULL)
folder_browser_ui_discard_view_menus (fb);
folder_browser_ui_setup_view_menus (fb);
/* when loading a new folder, nothing is selected initially */
if (fb->uicomp)
@ -1993,7 +1998,7 @@ my_folder_browser_init (GtkObject *object)
FolderBrowser *fb = FOLDER_BROWSER (object);
int i;
fb->view_collection = NULL;
fb->view_instance = NULL;
fb->view_menus = NULL;
fb->pref_master = FALSE;

View File

@ -78,8 +78,8 @@ struct _FolderBrowser {
int sensitize_timeout_id;
int update_status_bar_idle_id;
/* View collection and the menu handler object */
GalViewCollection *view_collection;
/* View instance and the menu handler object */
GalViewInstance *view_instance;
GalViewMenus *view_menus;
GtkWidget *invisible;

View File

@ -861,7 +861,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char
const CamelInternetAddress *reply_to, *sender, *to_addrs, *cc_addrs;
const char *name = NULL, *address = NULL, *source = NULL;
const char *message_id, *references, *reply_addr = NULL;
char *text, *subject, date_str[100], *format;
char *text = NULL, *subject, date_str[100], *format;
const MailConfigAccount *me = NULL;
const GSList *accounts = NULL;
GList *to = NULL, *cc = NULL;
@ -1392,10 +1392,10 @@ transfer_msg_done (gboolean ok, void *data)
are hidden, select the previous */
if ((row + 1 == e_tree_row_count (fb->message_list->tree))
&& mail_config_get_hide_deleted ())
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, CAMEL_MESSAGE_DELETED, FALSE);
else
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT,
0, 0, FALSE);
}
@ -2145,10 +2145,10 @@ delete_msg (GtkWidget *button, gpointer user_data)
are hidden, select the previous */
if ((row+1 == e_tree_row_count (fb->message_list->tree))
&& mail_config_get_hide_deleted ())
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, CAMEL_MESSAGE_DELETED, FALSE);
else
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT,
0, 0, FALSE);
}
}
@ -2163,26 +2163,22 @@ void
next_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_NEXT, 0, 0, FALSE);
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT, 0, 0, FALSE);
}
void
next_unread_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT,
0, CAMEL_MESSAGE_SEEN, TRUE);
}
@ -2190,13 +2186,11 @@ void
next_flagged_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT,
CAMEL_MESSAGE_FLAGGED, CAMEL_MESSAGE_FLAGGED, FALSE);
}
@ -2204,13 +2198,11 @@ void
previous_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, 0, FALSE);
}
@ -2218,13 +2210,11 @@ void
previous_unread_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, CAMEL_MESSAGE_SEEN, TRUE);
}
@ -2232,13 +2222,11 @@ void
previous_flagged_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
int row;
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
row = e_tree_row_of_node (fb->message_list->tree, e_tree_get_cursor (fb->message_list->tree));
message_list_select (fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
CAMEL_MESSAGE_FLAGGED, CAMEL_MESSAGE_FLAGGED, TRUE);
}

View File

@ -2214,17 +2214,25 @@ mail_config_service_set_save_passwd (MailConfigService *service, gboolean save_p
}
char *
mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix)
mail_config_folder_to_safe_url (CamelFolder *folder)
{
CamelService *service = CAMEL_SERVICE (folder->parent_store);
char *service_url, *url, *filename;
char *service_url, *url;
service_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL);
url = g_strdup_printf ("%s/%s", service_url, folder->full_name);
g_free (service_url);
e_filename_make_safe (url);
return url;
}
char *
mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix)
{
char *url, *filename;
url = mail_config_folder_to_safe_url (folder);
filename = g_strdup_printf ("%s/config/%s%s", evolution_dir, prefix, url);
g_free (url);

View File

@ -225,6 +225,7 @@ GSList *mail_config_get_sources (void);
/* static utility functions */
char *mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix);
char *mail_config_folder_to_safe_url (CamelFolder *folder);
gboolean mail_config_check_service (const char *url, CamelProviderType type, GList **authtypes, GtkWindow *window);

View File

@ -101,10 +101,10 @@ transfer_msg_done (gboolean ok, void *data)
are hidden, select the previous */
if ((row + 1 == e_tree_row_count (mb->fb->message_list->tree))
&& mail_config_get_hide_deleted ())
message_list_select (mb->fb->message_list, row, MESSAGE_LIST_SELECT_PREVIOUS,
message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_PREVIOUS,
0, CAMEL_MESSAGE_DELETED, FALSE);
else
message_list_select (mb->fb->message_list, row, MESSAGE_LIST_SELECT_NEXT,
message_list_select (mb->fb->message_list, MESSAGE_LIST_SELECT_NEXT,
0, 0, FALSE);
}

View File

@ -359,6 +359,30 @@ get_message_info (MessageList *message_list, ETreePath node)
return info;
}
struct search_func_data {
MessageList *message_list;
guint32 flags;
guint32 mask;
};
static gboolean
search_func (ETreeModel *model, ETreePath path, struct search_func_data *data)
{
CamelMessageInfo *info;
if (e_tree_model_node_is_root (data->message_list->model, path))
return FALSE;
info = get_message_info (data->message_list, path);
if (info && (info->flags & data->mask) == data->flags) {
gtk_signal_emit (GTK_OBJECT (data->message_list), message_list_signals[MESSAGE_SELECTED],
camel_message_info_uid (info));
return TRUE;
}
return FALSE;
}
/**
* message_list_select:
* @message_list: a MessageList
@ -380,87 +404,30 @@ get_message_info (MessageList *message_list, ETreePath node)
**/
void
message_list_select (MessageList *message_list,
int base_row,
MessageListSelectDirection direction,
guint32 flags,
guint32 mask,
gboolean wraparound)
{
CamelMessageInfo *info;
int vrow, last;
struct search_func_data data;
ETreeFindNextParams params = 0;
if (!GTK_WIDGET_HAS_FOCUS (message_list))
gtk_widget_grab_focus (GTK_WIDGET (message_list));
switch (direction) {
case MESSAGE_LIST_SELECT_PREVIOUS:
last = -1;
break;
case MESSAGE_LIST_SELECT_NEXT:
last = e_tree_row_count (message_list->tree);
if (last <= base_row)
return;
break;
default:
g_warning("Invalid argument to message_list_select");
return;
}
/* If it's -1, we want the last view row, not the last model row. */
/* model_to_view_row etc simply doesn't work for sorted views. Sigh. */
if (base_row == -1)
vrow = e_tree_row_count (message_list->tree) - 1;
data.message_list = message_list;
data.flags = flags;
data.mask = mask;
if (direction == MESSAGE_LIST_SELECT_NEXT)
params |= E_TREE_FIND_NEXT_FORWARD;
else
vrow = e_tree_model_to_view_row (message_list->tree, base_row);
if (vrow <= -1)
return;
/* This means that we'll move at least one message in 'direction'. */
if (vrow != last)
vrow += direction;
/* We don't know whether to use < or > due to "direction" */
while (vrow != last) {
ETreePath node = e_tree_node_at_row (message_list->tree, vrow);
info = get_message_info (message_list, node);
if (info && (info->flags & mask) == flags) {
e_tree_set_cursor (message_list->tree, node);
gtk_signal_emit (GTK_OBJECT (message_list), message_list_signals[MESSAGE_SELECTED],
camel_message_info_uid (info));
return;
}
vrow += direction;
}
if (wraparound) {
ETreePath node;
if (direction == MESSAGE_LIST_SELECT_NEXT) {
base_row = 0;
vrow = 0;
} else {
base_row = -1;
vrow = e_tree_row_count (message_list->tree) - 1;
}
/* lets see if the first/last (depending on direction)
row matches our selection criteria */
node = e_tree_node_at_row (message_list->tree, vrow);
info = get_message_info (message_list, node);
if (info && (info->flags & mask) == flags) {
e_tree_set_cursor (message_list->tree, node);
gtk_signal_emit (GTK_OBJECT (message_list), message_list_signals[MESSAGE_SELECTED],
camel_message_info_uid (info));
return;
}
message_list_select (message_list, base_row, direction, flags, mask, FALSE);
}
params |= E_TREE_FIND_NEXT_BACKWARD;
if (wraparound)
params |= E_TREE_FIND_NEXT_WRAP;
e_tree_find_next (message_list->tree, params, (ETreePathFunc) search_func, &data);
}
@ -1050,26 +1017,14 @@ save_tree_state(MessageList *ml)
if (ml->folder == NULL || ml->tree == NULL)
return;
filename = mail_config_folder_to_cachename(ml->folder, "et-header-");
e_tree_save_state(ml->tree, filename);
g_free(filename);
filename = mail_config_folder_to_cachename(ml->folder, "et-expanded-");
e_tree_save_expanded_state(ml->tree, filename);
g_free(filename);
}
static void
sort_info_changed (GtkWidget *widget, MessageList *ml)
{
save_tree_state(ml);
}
static void
message_list_setup_etree (MessageList *message_list, gboolean outgoing)
{
ETableState *etstate;
/* build the spec based on the folder, and possibly from a saved file */
/* otherwise, leave default */
if (message_list->folder) {
@ -1084,21 +1039,6 @@ message_list_setup_etree (MessageList *message_list, gboolean outgoing)
name = camel_service_get_name (CAMEL_SERVICE (message_list->folder->parent_store), TRUE);
d(printf ("folder name is '%s'\n", name));
path = mail_config_folder_to_cachename (message_list->folder, "et-header-");
if (path && stat (path, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) {
/* build based on saved file */
e_tree_load_state (message_list->tree, path);
} else if (outgoing) {
/* Swap From/To for Drafts, Sent, Outbox */
char *state = "<ETableState>"
"<column source=\"0\"/> <column source=\"1\"/> "
"<column source=\"8\"/> <column source=\"5\"/> "
"<column source=\"6\"/> <grouping> </grouping> </ETableState>";
e_tree_set_state (message_list->tree, state);
}
g_free (path);
path = mail_config_folder_to_cachename (message_list->folder, "et-expanded-");
if (path && stat (path, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) {
/* build based on saved file */
@ -1107,18 +1047,6 @@ message_list_setup_etree (MessageList *message_list, gboolean outgoing)
g_free (path);
g_free (name);
etstate = e_tree_get_state_object (message_list->tree);
gtk_signal_connect (GTK_OBJECT (etstate->sort_info),
"sort_info_changed",
GTK_SIGNAL_FUNC (sort_info_changed),
message_list);
gtk_signal_connect (GTK_OBJECT (etstate->sort_info),
"group_info_changed",
GTK_SIGNAL_FUNC (sort_info_changed),
message_list);
gtk_object_unref (GTK_OBJECT (etstate));
}
}
@ -1227,6 +1155,7 @@ message_list_class_init (GtkObjectClass *object_class)
static void
message_list_construct (MessageList *message_list)
{
gboolean construct_failed;
message_list->model =
e_tree_memory_callbacks_new (ml_tree_icon_at,
@ -1258,14 +1187,16 @@ message_list_construct (MessageList *message_list)
* The etree
*/
message_list->extras = message_list_create_extras ();
e_tree_scrolled_construct_from_spec_file (E_TREE_SCROLLED (message_list),
message_list->model,
message_list->extras,
EVOLUTION_ETSPECDIR "/message-list.etspec",
NULL);
construct_failed = (e_tree_scrolled_construct_from_spec_file (E_TREE_SCROLLED (message_list),
message_list->model,
message_list->extras,
EVOLUTION_ETSPECDIR "/message-list.etspec",
NULL)
== NULL);
message_list->tree = e_tree_scrolled_get_tree(E_TREE_SCROLLED (message_list));
e_tree_root_node_set_visible (message_list->tree, FALSE);
if (!construct_failed)
e_tree_root_node_set_visible (message_list->tree, FALSE);
gtk_signal_connect (GTK_OBJECT (message_list->tree), "cursor_activated",
GTK_SIGNAL_FUNC (on_cursor_activated_cmd),
@ -2572,5 +2503,5 @@ mail_regen_list (MessageList *ml, const char *search, const char *hideexpr, Came
m->folder = ml->folder;
camel_object_ref (CAMEL_OBJECT (m->folder));
e_thread_put (mail_thread_new, (EMsg *)m);
e_thread_put (mail_thread_queued, (EMsg *)m);
}

View File

@ -116,7 +116,6 @@ void message_list_foreach (MessageList *message_list,
gpointer user_data);
void message_list_select (MessageList *message_list,
int base_row,
MessageListSelectDirection direction,
guint32 flags,
guint32 mask,

View File

@ -1,3 +1,13 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* addressbook/galview.xml, calendar/galview.xml, mail/galview.xml,
tasks/galview.xml: Added default-view parameters.
* mail/As_Sent_Folder.galview: New galview.
* mail/Makefile.am, mail/galview.xml: Added As_Sent_Folder
galview.
2001-10-21 Christopher James Lahey <clahey@ximian.com>
* addressbook/By_Company.galview: Group by the correct column.

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<GalViewCollection>
<GalViewCollection default-view="Address_Cards">
<GalView id="Address_Cards" _title="Address Cards" filename="Address_Cards.galview" type="minicard"/>
<GalView id="Phone_List" _title="Phone List" filename="Phone_List.galview" type="etable"/>
<GalView id="By_Company" _title="By Company" filename="By_Company.galview" type="etable"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<GalViewCollection>
<GalViewCollection default-view="Day_View">
<GalView id="Day_View" _title="Day View" filename="Day_View.galview"
type="day_view"/>
<GalView id="Work_Week_View" _title="Work Week View" filename="Work_Week_View.galview"

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<ETableState state-version="0.100000">
<column source="0"/>
<column source="3"/>
<column source="1"/>
<column source="8"/>
<column source="5"/>
<column source="6"/>
<grouping/>
</ETableState>

View File

@ -1,3 +1,3 @@
defaultmaildir = $(datadir)/evolution/views/mail
defaultmail_DATA = By_Sender.galview By_Status.galview By_Subject.galview Messages.galview galview.xml
defaultmail_DATA = As_Sent_Folder.galview By_Sender.galview By_Status.galview By_Subject.galview Messages.galview galview.xml
EXTRA_DIST = $(defaultmail_DATA)

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?>
<GalViewCollection>
<GalViewCollection default-view="Messages">
<GalView id="Messages" _title="Messages" filename="Messages.galview" type="etable"/>
<GalView id="As_Sent_Folder" _title="As Sent Folder" filename="As_Sent_Folder.galview" type="etable"/>
<GalView id="By_Subject" _title="By Subject" filename="By_Subject.galview" type="etable"/>
<GalView id="By_Sender" _title="By Sender" filename="By_Sender.galview" type="etable"/>
<GalView id="By_Status" _title="By Status" filename="By_Status.galview" type="etable"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<GalViewCollection>
<GalViewCollection default-view="Tasks">
<GalView id="Tasks" _title="Tasks" filename="Tasks.galview" type="etable"/>
<GalView id="With_Category" _title="With Category" filename="With_Category.galview" type="etable"/>
</GalViewCollection>

View File

@ -1,3 +1,10 @@
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* menus/gal-view-menus.c, menus/gal-view-menus.h
(gal_view_menus_new): Made this take a GalViewInstance instead of
a GalViewCollection. Reworked most of this to utilize the
interfaces provided by GalViewInstance.
2002-01-27 Ettore Perazzoli <ettore@ximian.com>
* menus/Makefile.am: Use `GNOME_FULL_CFLAGS'.

View File

@ -23,48 +23,63 @@
#include <gal/menus/gal-define-views-dialog.h>
#include <gal/widgets/e-unicode.h>
#include <bonobo/bonobo-ui-util.h>
#include <e-util/e-list.h>
struct _GalViewMenusPrivate {
GalViewCollection *collection;
GalViewInstance *instance;
int collection_changed_id;
BonoboUIVerb *verbs;
int instance_changed_id;
BonoboUIComponent *component;
EList *listenerClosures;
};
typedef struct {
GalViewInstance *instance;
char *id;
int ref_count;
} ListenerClosure;
#define PARENT_TYPE (gtk_object_get_type())
static GtkObjectClass *gvm_parent_class;
static void collection_changed (GalViewCollection *collection,
GalViewMenus *gvm);
static void instance_changed (GalViewInstance *instance,
GalViewMenus *gvm);
#define d(x)
typedef struct {
GalViewCollection *collection;
GalView *view;
} CollectionAndView;
#define d(x) x
static void
free_verbs (GalViewMenus *gvm)
closure_free (void *data, void *user_data)
{
BonoboUIVerb *verbs;
if (gvm->priv->verbs) {
for (verbs = gvm->priv->verbs + 1; verbs->cname; verbs++) {
CollectionAndView *cnv;
ListenerClosure *closure = data;
GalViewMenus *gvm = user_data;
if (gvm->priv->component)
bonobo_ui_component_remove_verb(gvm->priv->component, verbs->cname);
closure->ref_count --;
if (closure->ref_count == 0) {
gtk_object_unref(GTK_OBJECT(closure->instance));
cnv = verbs->user_data;
g_free(verbs->cname);
gtk_object_unref(GTK_OBJECT(cnv->collection));
gtk_object_unref(GTK_OBJECT(cnv->view));
g_free(cnv);
}
g_free(gvm->priv->verbs);
bonobo_ui_component_remove_listener (gvm->priv->component, closure->id);
g_free (closure);
}
gvm->priv->verbs = NULL;
}
static void *
closure_copy (const void *data, void *user_data)
{
ListenerClosure *closure = (void *) data;
closure->ref_count ++;
return closure;
}
static void
remove_listeners (GalViewMenus *gvm)
{
if (gvm->priv->listenerClosures) {
gtk_object_unref (GTK_OBJECT(gvm->priv->listenerClosures));
}
gvm->priv->listenerClosures = NULL;
}
static void
@ -72,21 +87,55 @@ remove_xml (GalViewMenus *gvm)
{
}
static void
remove_instance (GalViewMenus *gvm)
{
if (gvm->priv->instance) {
if (gvm->priv->instance_changed_id != 0)
gtk_signal_disconnect(GTK_OBJECT(gvm->priv->instance), gvm->priv->instance_changed_id);
if (gvm->priv->instance->collection && gvm->priv->collection_changed_id != 0)
gtk_signal_disconnect(GTK_OBJECT(gvm->priv->instance->collection), gvm->priv->collection_changed_id);
}
gvm->priv->instance_changed_id = 0;
gvm->priv->collection_changed_id = 0;
if (gvm->priv->instance)
gtk_object_unref(GTK_OBJECT(gvm->priv->instance));
remove_listeners(gvm);
remove_xml(gvm);
}
static void
add_instance (GalViewMenus *gvm,
GalViewInstance *instance)
{
gtk_object_ref(GTK_OBJECT(instance));
if (gvm->priv->instance != NULL)
remove_instance (gvm);
gvm->priv->instance = instance;
gal_view_instance_load (gvm->priv->instance);
gvm->priv->instance_changed_id = gtk_signal_connect
(GTK_OBJECT(instance), "changed",
GTK_SIGNAL_FUNC(instance_changed), gvm);
gvm->priv->collection_changed_id = gtk_signal_connect
(GTK_OBJECT(instance->collection), "changed",
GTK_SIGNAL_FUNC(collection_changed), gvm);
}
static void
gvm_destroy (GtkObject *object)
{
GalViewMenus *gvm = GAL_VIEW_MENUS (object);
if (gvm->priv->collection && gvm->priv->collection_changed_id != 0) {
gtk_signal_disconnect(GTK_OBJECT(gvm->priv->collection), gvm->priv->collection_changed_id);
gvm->priv->collection_changed_id = 0;
}
if (gvm->priv->collection)
gtk_object_unref(GTK_OBJECT(gvm->priv->collection));
free_verbs(gvm);
remove_xml(gvm);
remove_instance (gvm);
if (gvm->priv->component) {
bonobo_object_unref (BONOBO_OBJECT (gvm->priv->component));
@ -111,42 +160,39 @@ static void
gvm_init (GalViewMenus *gvm)
{
gvm->priv = g_new(GalViewMenusPrivate, 1);
gvm->priv->collection = NULL;
gvm->priv->instance = NULL;
gvm->priv->collection_changed_id = 0;
gvm->priv->verbs = NULL;
gvm->priv->instance_changed_id = 0;
gvm->priv->component = NULL;
gvm->priv->listenerClosures = NULL;
}
E_MAKE_TYPE(gal_view_menus, "GalViewMenus", GalViewMenus, gvm_class_init, gvm_init, PARENT_TYPE);
GalViewMenus *
gal_view_menus_new (GalViewCollection *collection)
gal_view_menus_new (GalViewInstance *instance)
{
GalViewMenus *gvm;
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL);
g_return_val_if_fail (instance != NULL, NULL);
g_return_val_if_fail (GAL_IS_VIEW_INSTANCE (instance), NULL);
gvm = gtk_type_new (GAL_VIEW_MENUS_TYPE);
gal_view_menus_construct(gvm, collection);
gal_view_menus_construct(gvm, instance);
return gvm;
}
GalViewMenus *
gal_view_menus_construct (GalViewMenus *gvm,
GalViewCollection *collection)
GalViewInstance *instance)
{
g_return_val_if_fail (gvm != NULL, NULL);
g_return_val_if_fail (GAL_IS_VIEW_MENUS (gvm), NULL);
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL);
g_return_val_if_fail (instance != NULL, NULL);
g_return_val_if_fail (GAL_IS_VIEW_INSTANCE (instance), NULL);
gtk_object_ref(GTK_OBJECT(collection));
gvm->priv->collection = collection;
gvm->priv->collection_changed_id = gtk_signal_connect (
GTK_OBJECT(collection), "changed",
GTK_SIGNAL_FUNC(collection_changed), gvm);
add_instance (gvm, instance);
return gvm;
}
@ -155,7 +201,7 @@ static void
dialog_clicked(GtkWidget *dialog, int button, GalViewMenus *menus)
{
if (button == 0) {
gal_view_collection_save(menus->priv->collection);
gal_view_collection_save(menus->priv->instance->collection);
}
gnome_dialog_close(GNOME_DIALOG(dialog));
}
@ -165,24 +211,53 @@ define_views(BonoboUIComponent *component,
GalViewMenus *menus,
char *cname)
{
GtkWidget *dialog = gal_define_views_dialog_new(menus->priv->collection);
GtkWidget *dialog = gal_define_views_dialog_new(menus->priv->instance->collection);
gtk_signal_connect(GTK_OBJECT(dialog), "clicked",
GTK_SIGNAL_FUNC(dialog_clicked), menus);
gtk_widget_show(dialog);
}
static void
save_current_view(BonoboUIComponent *component,
GalViewMenus *menus,
char *cname)
{
gal_view_instance_save_as (menus->priv->instance);
}
static void
toggled_cb (BonoboUIComponent *component,
const char *path,
Bonobo_UIComponent_EventType type,
const char *state,
gpointer user_data)
{
ListenerClosure *closure = user_data;
/* do nothing on state change to untoggled */
if (!strcmp (state, "0"))
return;
g_print ("%s\n", path);
gal_view_instance_set_current_view_id (closure->instance, closure->id);
}
static char *
build_menus(GalViewMenus *menus)
{
BonoboUINode *root, *menu, *submenu, *place, *menuitem;
BonoboUINode *root, *menu, *submenu, *place, *menuitem, *commands, *command;
char *xml;
xmlChar *string;
int length;
int i;
GalViewCollection *collection = menus->priv->collection;
GalViewInstance *instance = menus->priv->instance;
GalViewCollection *collection = instance->collection;
char *id;
root = bonobo_ui_node_new("Root");
menu = bonobo_ui_node_new_child(root, "menu");
commands = bonobo_ui_node_new_child (root, "commands");
submenu = bonobo_ui_node_new_child(menu, "submenu");
bonobo_ui_node_set_attr(submenu, "name", "View");
@ -194,34 +269,82 @@ build_menus(GalViewMenus *menus)
bonobo_ui_node_set_attr(submenu, "name", "CurrentView");
bonobo_ui_node_set_attr(submenu, "_label", N_("_Current View"));
id = gal_view_instance_get_current_view_id (instance);
length = gal_view_collection_get_count(collection);
menus->priv->listenerClosures = e_list_new (closure_copy, closure_free, menus);
for (i = 0; i < length; i++) {
char *label, *encoded_label;
char *verb;
GalViewCollectionItem *item = gal_view_collection_get_view_item(collection, i);
ListenerClosure *closure;
menuitem = bonobo_ui_node_new_child(submenu, "menuitem");
bonobo_ui_node_set_attr(menuitem, "name", item->id);
bonobo_ui_node_set_attr(menuitem, "id", item->id);
bonobo_ui_node_set_attr(menuitem, "group", "GalViewMenus");
bonobo_ui_node_set_attr(menuitem, "type", "radio");
command = bonobo_ui_node_new_child (commands, "cmd");
bonobo_ui_node_set_attr(command, "name", item->id);
bonobo_ui_node_set_attr(command, "group", "GalViewMenus");
/* bonobo displays this string so it must be in locale */
label = e_utf8_to_locale_string(item->title);
encoded_label = bonobo_ui_util_encode_str (label);
bonobo_ui_node_set_attr(menuitem, "label", encoded_label);
g_free (encoded_label);
g_free(label);
g_free (label);
verb = g_strdup_printf("DefineViews:%s", item->id);
bonobo_ui_node_set_attr(menuitem, "verb", verb);
g_free(verb);
closure = g_new (ListenerClosure, 1);
closure->instance = instance;
closure->id = item->id;
closure->ref_count = 1;
gtk_object_ref (GTK_OBJECT(closure->instance));
bonobo_ui_component_add_listener (menus->priv->component, item->id, toggled_cb, closure);
e_list_append (menus->priv->listenerClosures, closure);
closure_free (closure, menus);
}
if (id == NULL) {
menuitem = bonobo_ui_node_new_child(submenu, "separator");
menuitem = bonobo_ui_node_new_child(submenu, "menuitem");
bonobo_ui_node_set_attr(menuitem, "name", "custom_view");
bonobo_ui_node_set_attr(menuitem, "id", "custom_view");
bonobo_ui_node_set_attr(menuitem, "group", "GalViewMenus");
bonobo_ui_node_set_attr(menuitem, "type", "radio");
/* bonobo displays this string so it must be in locale */
bonobo_ui_node_set_attr(menuitem, "_label", N_("Custom View"));
command = bonobo_ui_node_new_child (commands, "cmd");
bonobo_ui_node_set_attr(command, "name", "custom_view");
bonobo_ui_node_set_attr(command, "group", "GalViewMenus");
menuitem = bonobo_ui_node_new_child(submenu, "menuitem");
bonobo_ui_node_set_attr(menuitem, "name", "SaveCurrentView");
bonobo_ui_node_set_attr(menuitem, "_label", N_("Save Custom View"));
bonobo_ui_node_set_attr(menuitem, "verb", "");
command = bonobo_ui_node_new_child(commands, "cmd");
bonobo_ui_node_set_attr(command, "name", "SaveCurrentView");
}
#if 0
menuitem = bonobo_ui_node_new_child(submenu, "separator");
menuitem = bonobo_ui_node_new_child(submenu, "menuitem");
bonobo_ui_node_set_attr(menuitem, "name", "DefineViews");
bonobo_ui_node_set_attr(menuitem, "_label", N_("Define Views"));
bonobo_ui_node_set_attr(menuitem, "verb", "DefineViews");
#endif
bonobo_ui_node_set_attr(menuitem, "verb", "");
command = bonobo_ui_node_new_child(commands, "cmd");
bonobo_ui_node_set_attr(command, "name", "DefineViews");
string = bonobo_ui_node_to_string(root, TRUE);
xml = g_strdup(string);
@ -229,76 +352,66 @@ build_menus(GalViewMenus *menus)
bonobo_ui_node_free(root);
d(g_print (xml));
g_free (id);
/* d(g_print (xml));*/
return xml;
}
static BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("DefineViews", define_views),
BONOBO_UI_UNSAFE_VERB ("SaveCurrentView", save_current_view),
BONOBO_UI_VERB_END
};
static void
show_view(BonoboUIComponent *component,
gpointer user_data,
const char *cname)
set_state (GalViewMenus *gvm, char *path, CORBA_Environment *ev)
{
CollectionAndView *cnv = user_data;
gal_view_collection_display_view(cnv->collection, cnv->view);
char *full_path = g_strdup_printf ("/commands/%s", path);
bonobo_ui_component_set_prop (gvm->priv->component, full_path, "state", "1", ev);
g_print ("set_prop path: %s\n", full_path);
g_free (full_path);
}
static BonoboUIVerb *
build_verbs (GalViewMenus *menus)
static void
set_radio (GalViewMenus *gvm,
CORBA_Environment *ev)
{
GalViewCollection *collection = menus->priv->collection;
int count = gal_view_collection_get_count(collection);
BonoboUIVerb *verbs = g_new(BonoboUIVerb, count + 2);
BonoboUIVerb *verb;
int i;
verb = verbs;
verb->cname = g_strdup("DefineViews");
verb->cb = (BonoboUIVerbFn) define_views;
verb->user_data = menus;
verb->dummy = NULL;
verb ++;
for (i = 0; i < count; i++) {
CollectionAndView *cnv;
GalViewCollectionItem *item = gal_view_collection_get_view_item(collection, i);
char *id;
cnv = g_new(CollectionAndView, 1);
cnv->view = item->view;
cnv->collection = collection;
id = gal_view_instance_get_current_view_id (gvm->priv->instance);
gtk_object_ref(GTK_OBJECT(cnv->view));
gtk_object_ref(GTK_OBJECT(cnv->collection));
verb->cname = g_strdup_printf("DefineViews:%s", item->id);
verb->cb = show_view;
verb->user_data = cnv;
verb->dummy = NULL;
verb++;
if (id) {
set_state (gvm, id, ev);
} else {
set_state (gvm, "custom_view", ev);
}
verb->cname = NULL;
verb->cb = NULL;
verb->user_data = NULL;
verb->dummy = NULL;
verb++;
return verbs;
g_free (id);
}
#define CURRENT_VIEW_PATH "/menu/View/ViewBegin/CurrentView"
static void
build_stuff (GalViewMenus *gvm,
CORBA_Environment *ev)
{
char *xml;
d(g_print ("%s:\n", __FUNCTION__));
if (bonobo_ui_component_path_exists (gvm->priv->component, CURRENT_VIEW_PATH, ev)) {
d(g_print ("%s: Removing path\n", __FUNCTION__));
bonobo_ui_component_rm (gvm->priv->component, CURRENT_VIEW_PATH, ev);
}
remove_listeners(gvm);
remove_xml(gvm);
xml = build_menus(gvm);
bonobo_ui_component_set_translate(gvm->priv->component, "/", xml, ev);
g_free(xml);
free_verbs(gvm);
gvm->priv->verbs = build_verbs(gvm);
bonobo_ui_component_add_verb_list(gvm->priv->component, gvm->priv->verbs);
bonobo_ui_component_add_verb_list_with_data(gvm->priv->component, verbs, gvm);
set_radio (gvm, ev);
}
void
@ -306,15 +419,18 @@ gal_view_menus_apply (GalViewMenus *gvm,
BonoboUIComponent *component,
CORBA_Environment *ev)
{
if (component)
bonobo_object_ref (BONOBO_OBJECT (component));
if (component != gvm->priv->component) {
if (component)
bonobo_object_ref (BONOBO_OBJECT (component));
if (gvm->priv->component)
bonobo_object_unref (BONOBO_OBJECT (gvm->priv->component));
if (gvm->priv->component)
bonobo_object_unref (BONOBO_OBJECT (gvm->priv->component));
}
gvm->priv->component = component;
build_stuff (gvm, ev);
set_radio (gvm, ev);
}
static void
@ -325,5 +441,27 @@ collection_changed (GalViewCollection *collection,
CORBA_exception_init (&ev);
build_stuff(gvm, &ev);
set_radio (gvm, &ev);
CORBA_exception_free (&ev);
}
static void
instance_changed (GalViewInstance *instance,
GalViewMenus *gvm)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
build_stuff(gvm, &ev);
set_radio (gvm, &ev);
CORBA_exception_free (&ev);
}
void
gal_view_menus_set_instance (GalViewMenus *gvm,
GalViewInstance *instance)
{
remove_instance (gvm);
add_instance (gvm, instance);
instance_changed (instance, gvm);
}

View File

@ -5,7 +5,7 @@
#include <gtk/gtkobject.h>
#include <gnome-xml/tree.h>
#include <bonobo/bonobo-ui-component.h>
#include <gal/menus/gal-view-collection.h>
#include <gal/menus/gal-view-instance.h>
#define GAL_VIEW_MENUS_TYPE (gal_view_menus_get_type ())
#define GAL_VIEW_MENUS(o) (GTK_CHECK_CAST ((o), GAL_VIEW_MENUS_TYPE, GalViewMenus))
@ -24,13 +24,15 @@ typedef struct {
GtkObjectClass parent_class;
} GalViewMenusClass;
GtkType gal_view_menus_get_type (void);
GalViewMenus *gal_view_menus_new (GalViewCollection *collection);
GalViewMenus *gal_view_menus_construct (GalViewMenus *menus,
GalViewCollection *collection);
GtkType gal_view_menus_get_type (void);
GalViewMenus *gal_view_menus_new (GalViewInstance *instance);
GalViewMenus *gal_view_menus_construct (GalViewMenus *menus,
GalViewInstance *instance);
void gal_view_menus_apply (GalViewMenus *menus,
BonoboUIComponent *component,
CORBA_Environment *ev);
void gal_view_menus_apply (GalViewMenus *menus,
BonoboUIComponent *component,
CORBA_Environment *ev);
void gal_view_menus_set_instance (GalViewMenus *gvm,
GalViewInstance *instance);
#endif /* _GAL_VIEW_MENUS_H_ */