diff options
Diffstat (limited to 'widgets/menus')
27 files changed, 0 insertions, 5699 deletions
diff --git a/widgets/menus/.cvsignore b/widgets/menus/.cvsignore deleted file mode 100644 index 7708c3d120..0000000000 --- a/widgets/menus/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -libmenus.la -Makefile.in -.deps -.libs -.pure -*.o -*.lo diff --git a/widgets/menus/Makefile.am b/widgets/menus/Makefile.am deleted file mode 100644 index 3a1ca3450b..0000000000 --- a/widgets/menus/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -noinst_LTLIBRARIES = libmenus.la - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets/menus \ - -DG_LOG_DOMAIN=\"menus\" \ - $(GNOME_FULL_CFLAGS) - -libmenus_la_SOURCES = \ - gal-view-menus.c \ - gal-view-menus.h diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c deleted file mode 100644 index 8d8c903de8..0000000000 --- a/widgets/menus/gal-define-views-dialog.c +++ /dev/null @@ -1,338 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-dialog.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> - -#include "gal-define-views-dialog.h" - -#include <libgnomeui/gnome-dialog.h> -#include <libgnomeui/gnome-stock.h> -#include "gal-define-views-model.h" -#include "gal-view-new-dialog.h" -#include <gal/e-table/e-table-scrolled.h> -#include <gal/util/e-i18n.h> - -static void gal_define_views_dialog_init (GalDefineViewsDialog *card); -static void gal_define_views_dialog_class_init (GalDefineViewsDialogClass *klass); -static void gal_define_views_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void gal_define_views_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void gal_define_views_dialog_destroy (GtkObject *object); - -static GnomeDialogClass *parent_class = NULL; -#define PARENT_TYPE gnome_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, - ARG_COLLECTION -}; - -typedef struct { - char *title; - ETableModel *model; - GalDefineViewsDialog *names; -} GalDefineViewsDialogChild; - -GtkType -gal_define_views_dialog_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "GalDefineViewsDialog", - sizeof (GalDefineViewsDialog), - sizeof (GalDefineViewsDialogClass), - (GtkClassInitFunc) gal_define_views_dialog_class_init, - (GtkObjectInitFunc) gal_define_views_dialog_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -gal_define_views_dialog_class_init (GalDefineViewsDialogClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = gal_define_views_dialog_set_arg; - object_class->get_arg = gal_define_views_dialog_get_arg; - object_class->destroy = gal_define_views_dialog_destroy; - - gtk_object_add_arg_type("GalDefineViewsDialog::collection", GAL_VIEW_COLLECTION_TYPE, - GTK_ARG_READWRITE, ARG_COLLECTION); -} - -/* ETable creation */ -#define SPEC "<ETableSpecification cursor-mode=\"line\" draw-grid=\"true\" selection-mode=\"single\" gettext-domain=\"" E_I18N_DOMAIN "\">" \ - "<ETableColumn model_col= \"0\" _title=\"Name\" expansion=\"1.0\" minimum_width=\"18\" resizable=\"true\" cell=\"string\" compare=\"string\"/>" \ - "<ETableState> <column source=\"0\"/> <grouping> </grouping> </ETableState>" \ - "</ETableSpecification>" - -/* For use from libglade. */ -GtkWidget *gal_define_views_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2); - -GtkWidget * -gal_define_views_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2) -{ - GtkWidget *table; - ETableModel *model; - model = gal_define_views_model_new(); - table = e_table_scrolled_new(model, NULL, SPEC, NULL); - gtk_object_set_data(GTK_OBJECT(table), "GalDefineViewsDialog::model", model); - return table; -} - -/* Button callbacks */ - -static void -gdvd_button_new_dialog_callback(GtkWidget *widget, int button, GalDefineViewsDialog *dialog) -{ - gchar *name; - GalView *view; - GalViewFactory *factory; - switch (button) { - case 0: - gtk_object_get(GTK_OBJECT(widget), - "name", &name, - "factory", &factory, - NULL); - if (name && factory) { - view = gal_view_factory_new_view(factory, - name); - gal_define_views_model_append(GAL_DEFINE_VIEWS_MODEL(dialog->model), view); - gtk_object_unref(GTK_OBJECT(view)); - } - break; - } - gnome_dialog_close(GNOME_DIALOG(widget)); -} - -static void -gdvd_button_new_callback(GtkWidget *widget, GalDefineViewsDialog *dialog) -{ - GtkWidget *view_new_dialog = gal_view_new_dialog_new(dialog->collection); - gtk_signal_connect(GTK_OBJECT(view_new_dialog), "clicked", - GTK_SIGNAL_FUNC(gdvd_button_new_dialog_callback), dialog); - gtk_widget_show(GTK_WIDGET(view_new_dialog)); -} - -static void -gdvd_button_modify_callback(GtkWidget *widget, GalDefineViewsDialog *dialog) -{ - int row; - GtkWidget *scrolled; - ETable *etable; - - scrolled = glade_xml_get_widget(dialog->gui, "custom-table"); - etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled)); - row = e_table_get_cursor_row (E_TABLE(etable)); - - if (row != -1) { - GalView *view; - view = gal_define_views_model_get_view(GAL_DEFINE_VIEWS_MODEL(dialog->model), - row); - gal_view_edit(view); - } - -} - -static void -gdvd_button_delete_callback(GtkWidget *widget, GalDefineViewsDialog *dialog) -{ - int row; - GtkWidget *scrolled; - ETable *etable; - - scrolled = glade_xml_get_widget(dialog->gui, "custom-table"); - etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled)); - row = e_table_get_cursor_row (E_TABLE(etable)); - - if (row != -1) { - gal_define_views_model_delete_view(GAL_DEFINE_VIEWS_MODEL(dialog->model), - row); - } - -} - -static void -gdvd_button_copy_callback(GtkWidget *widget, GalDefineViewsDialog *dialog) -{ - int row; - GtkWidget *scrolled; - ETable *etable; - - scrolled = glade_xml_get_widget(dialog->gui, "custom-table"); - etable = e_table_scrolled_get_table(E_TABLE_SCROLLED(scrolled)); - row = e_table_get_cursor_row (E_TABLE(etable)); - - if (row != -1) { - gal_define_views_model_copy_view(GAL_DEFINE_VIEWS_MODEL(dialog->model), - row); - } - -} - -static void -gdvd_connect_signal(GalDefineViewsDialog *dialog, char *widget_name, char *signal, GtkSignalFunc handler) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget(dialog->gui, widget_name); - - if (widget) - gtk_signal_connect(GTK_OBJECT(widget), signal, handler, dialog); -} - -static void -gal_define_views_dialog_init (GalDefineViewsDialog *dialog) -{ - GladeXML *gui; - GtkWidget *widget; - GtkWidget *etable; - - dialog->collection = NULL; - - gui = glade_xml_new_with_domain (GAL_GLADEDIR "/gal-define-views.glade", NULL, PACKAGE); - dialog->gui = gui; - - widget = glade_xml_get_widget(gui, "table-top"); - if (!widget) { - return; - } - gtk_widget_ref(widget); - gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gnome_dialog_append_buttons(GNOME_DIALOG(dialog), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gdvd_connect_signal(dialog, "button-new", "clicked", GTK_SIGNAL_FUNC(gdvd_button_new_callback)); - gdvd_connect_signal(dialog, "button-modify", "clicked", GTK_SIGNAL_FUNC(gdvd_button_modify_callback)); - gdvd_connect_signal(dialog, "button-delete", "clicked", GTK_SIGNAL_FUNC(gdvd_button_delete_callback)); - gdvd_connect_signal(dialog, "button-copy", "clicked", GTK_SIGNAL_FUNC(gdvd_button_copy_callback)); - - dialog->model = NULL; - etable = glade_xml_get_widget(dialog->gui, "custom-table"); - if (etable) { - dialog->model = gtk_object_get_data(GTK_OBJECT(etable), "GalDefineViewsDialog::model"); - gtk_object_set(GTK_OBJECT(dialog->model), - "collection", dialog->collection, - NULL); - } - - gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE); -} - -static void -gal_define_views_dialog_destroy (GtkObject *object) -{ - GalDefineViewsDialog *gal_define_views_dialog = GAL_DEFINE_VIEWS_DIALOG(object); - - gtk_object_unref(GTK_OBJECT(gal_define_views_dialog->gui)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -gal_define_views_dialog_set_collection(GalDefineViewsDialog *dialog, - GalViewCollection *collection) -{ - dialog->collection = collection; - if (dialog->model) { - gtk_object_set(GTK_OBJECT(dialog->model), - "collection", collection, - NULL); - } -} - -/** - * gal_define_views_dialog_new - * - * Returns a new dialog for defining views. - * - * Returns: The GalDefineViewsDialog. - */ -GtkWidget* -gal_define_views_dialog_new (GalViewCollection *collection) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (gal_define_views_dialog_get_type ())); - gal_define_views_dialog_set_collection(GAL_DEFINE_VIEWS_DIALOG (widget), collection); - return widget; -} - -static void -gal_define_views_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GalDefineViewsDialog *dialog; - - dialog = GAL_DEFINE_VIEWS_DIALOG (o); - - switch (arg_id){ - case ARG_COLLECTION: - if (GTK_VALUE_OBJECT(*arg)) - gal_define_views_dialog_set_collection(dialog, GAL_VIEW_COLLECTION(GTK_VALUE_OBJECT(*arg))); - else - gal_define_views_dialog_set_collection(dialog, NULL); - break; - - default: - return; - } -} - -static void -gal_define_views_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GalDefineViewsDialog *dialog; - - dialog = GAL_DEFINE_VIEWS_DIALOG (object); - - switch (arg_id) { - case ARG_COLLECTION: - if (dialog->collection) - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(dialog->collection); - else - GTK_VALUE_OBJECT(*arg) = NULL; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h deleted file mode 100644 index edd40ed7c5..0000000000 --- a/widgets/menus/gal-define-views-dialog.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-dialog.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __GAL_DEFINE_VIEWS_DIALOG_H__ -#define __GAL_DEFINE_VIEWS_DIALOG_H__ - -#include <libgnomeui/gnome-dialog.h> -#include <glade/glade.h> -#include <gal/e-table/e-table-model.h> -#include <gal/menus/gal-view-collection.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* GalDefineViewsDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_DEFINE_VIEWS_DIALOG_TYPE (gal_define_views_dialog_get_type ()) -#define GAL_DEFINE_VIEWS_DIALOG(obj) (GTK_CHECK_CAST ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE, GalDefineViewsDialog)) -#define GAL_DEFINE_VIEWS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GAL_DEFINE_VIEWS_DIALOG_TYPE, GalDefineViewsDialogClass)) -#define GAL_IS_DEFINE_VIEWS_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE)) -#define GAL_IS_DEFINE_VIEWS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GAL_DEFINE_VIEWS_DIALOG_TYPE)) - -typedef struct _GalDefineViewsDialog GalDefineViewsDialog; -typedef struct _GalDefineViewsDialogClass GalDefineViewsDialogClass; - -struct _GalDefineViewsDialog -{ - GnomeDialog parent; - - /* item specific fields */ - GladeXML *gui; - ETableModel *model; - - GalViewCollection *collection; -}; - -struct _GalDefineViewsDialogClass -{ - GnomeDialogClass parent_class; -}; - -GtkWidget *gal_define_views_dialog_new (GalViewCollection *collection); -GtkType gal_define_views_dialog_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GAL_DEFINE_VIEWS_DIALOG_H__ */ diff --git a/widgets/menus/gal-define-views-model.c b/widgets/menus/gal-define-views-model.c deleted file mode 100644 index ca54e19c8d..0000000000 --- a/widgets/menus/gal-define-views-model.c +++ /dev/null @@ -1,335 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-model.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> -#include "gal-define-views-model.h" - -#define PARENT_TYPE e_table_model_get_type() -static ETableModelClass *parent_class; - -/* - * GalDefineViewsModel callbacks - * These are the callbacks that define the behavior of our custom model. - */ -static void gal_define_views_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void gal_define_views_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - - -enum { - ARG_0, - ARG_EDITABLE, - ARG_COLLECTION -}; - -static void -gdvm_destroy(GtkObject *object) -{ - GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); - - gtk_object_unref(GTK_OBJECT(model->collection)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -gdvm_col_count (ETableModel *etc) -{ - return 1; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -gdvm_row_count (ETableModel *etc) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); - if (views->collection) - return gal_view_collection_get_count(views->collection); - else - return 0; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -gdvm_value_at (ETableModel *etc, int col, int row) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); - const char *value; - - value = gal_view_get_title (gal_view_collection_get_view(views->collection, row)); - - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -gdvm_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); - if (views->editable) { - e_table_model_pre_change(etc); - gal_view_set_title(gal_view_collection_get_view(views->collection, row), val); - e_table_model_cell_changed(etc, col, row); - } -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -gdvm_is_cell_editable (ETableModel *etc, int col, int row) -{ - return GAL_DEFINE_VIEWS_MODEL(etc)->editable; -} - -static void -gdvm_append_row (ETableModel *etm, ETableModel *source, gint row) -{ -} - -/* This function duplicates the value passed to it. */ -static void * -gdvm_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -gdvm_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -gdvm_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -gdvm_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -gdvm_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/** - * gal_define_views_model_append - * @model: The model to add to. - * @view: The view to add. - * - * Adds the given view to the gal define views model. - */ -void -gal_define_views_model_append (GalDefineViewsModel *model, - GalView *view) -{ - ETableModel *etm = E_TABLE_MODEL(model); - - e_table_model_pre_change(etm); - gal_view_collection_append(model->collection, view); - e_table_model_row_inserted(etm, gal_view_collection_get_count(model->collection) - 1); -} - -static void -gal_define_views_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = gdvm_destroy; - object_class->set_arg = gal_define_views_model_set_arg; - object_class->get_arg = gal_define_views_model_get_arg; - - gtk_object_add_arg_type ("GalDefineViewsModel::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - gtk_object_add_arg_type ("GalDefineViewsModel::collection", GAL_VIEW_COLLECTION_TYPE, - GTK_ARG_READWRITE, ARG_COLLECTION); - - model_class->column_count = gdvm_col_count; - model_class->row_count = gdvm_row_count; - model_class->value_at = gdvm_value_at; - model_class->set_value_at = gdvm_set_value_at; - model_class->is_cell_editable = gdvm_is_cell_editable; - model_class->append_row = gdvm_append_row; - model_class->duplicate_value = gdvm_duplicate_value; - model_class->free_value = gdvm_free_value; - model_class->initialize_value = gdvm_initialize_value; - model_class->value_is_empty = gdvm_value_is_empty; - model_class->value_to_string = gdvm_value_to_string; -} - -static void -gal_define_views_model_init (GtkObject *object) -{ - GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); - - model->collection = NULL; -} - -static void -gal_define_views_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GalDefineViewsModel *model; - - model = GAL_DEFINE_VIEWS_MODEL (o); - - switch (arg_id){ - case ARG_EDITABLE: - model->editable = GTK_VALUE_BOOL (*arg); - break; - - case ARG_COLLECTION: - e_table_model_pre_change(E_TABLE_MODEL(o)); - if (GTK_VALUE_OBJECT (*arg)) - model->collection = GAL_VIEW_COLLECTION(GTK_VALUE_OBJECT (*arg)); - else - model->collection = NULL; - e_table_model_changed(E_TABLE_MODEL(o)); - break; - } -} - -static void -gal_define_views_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GalDefineViewsModel *model; - - model = GAL_DEFINE_VIEWS_MODEL (object); - - switch (arg_id) { - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = model->editable; - break; - - case ARG_COLLECTION: - if (model->collection) - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(model->collection); - else - GTK_VALUE_OBJECT (*arg) = NULL; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GtkType -gal_define_views_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "GalDefineViewsModel", - sizeof (GalDefineViewsModel), - sizeof (GalDefineViewsModelClass), - (GtkClassInitFunc) gal_define_views_model_class_init, - (GtkObjectInitFunc) gal_define_views_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -/** - * gal_define_views_model_new - * - * Returns a new define views model. This is a list of views as an - * ETable for use in the GalDefineViewsDialog. - * - * Returns: The new GalDefineViewsModel. - */ -ETableModel * -gal_define_views_model_new (void) -{ - GalDefineViewsModel *et; - - et = gtk_type_new (gal_define_views_model_get_type ()); - - return E_TABLE_MODEL(et); -} - -/** - * gal_define_views_model_get_view: - * @model: The GalDefineViewsModel. - * @n: Which view to get. - * - * Gets the nth view. - * - * Returns: The view. - */ -GalView * -gal_define_views_model_get_view (GalDefineViewsModel *model, - int n) -{ - return gal_view_collection_get_view(model->collection, n); -} - -/** - * gal_define_views_model_delete_view: - * @model: The GalDefineViewsModel. - * @n: Which view to delete. - * - * Deletes the nth view. - */ -void -gal_define_views_model_delete_view (GalDefineViewsModel *model, - int n) -{ - e_table_model_pre_change(E_TABLE_MODEL(model)); - gal_view_collection_delete_view(model->collection, n); - e_table_model_row_deleted(E_TABLE_MODEL(model), n); -} - -/** - * gal_define_views_model_copy_view: - * @model: The GalDefineViewsModel. - * @n: Which view to copy. - * - * Copys the nth view. - */ -void -gal_define_views_model_copy_view (GalDefineViewsModel *model, - int n) -{ - ETableModel *etm = E_TABLE_MODEL(model); - e_table_model_pre_change(etm); - gal_view_collection_copy_view(model->collection, n); - e_table_model_row_inserted(etm, gal_view_collection_get_count(model->collection) - 1); -} diff --git a/widgets/menus/gal-define-views-model.h b/widgets/menus/gal-define-views-model.h deleted file mode 100644 index 2724216985..0000000000 --- a/widgets/menus/gal-define-views-model.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-model.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_DEFINE_VIEWS_MODEL_H_ -#define _GAL_DEFINE_VIEWS_MODEL_H_ - -#include <gal/e-table/e-table-model.h> -#include <gal/menus/gal-view.h> -#include <gal/menus/gal-view-collection.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_DEFINE_VIEWS_MODEL_TYPE (gal_define_views_model_get_type ()) -#define GAL_DEFINE_VIEWS_MODEL(o) (GTK_CHECK_CAST ((o), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModel)) -#define GAL_DEFINE_VIEWS_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_DEFINE_VIEWS_MODEL_TYPE, GalDefineViewsModelClass)) -#define GAL_IS_DEFINE_VIEWS_MODEL(o) (GTK_CHECK_TYPE ((o), GAL_DEFINE_VIEWS_MODEL_TYPE)) -#define GAL_IS_DEFINE_VIEWS_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_DEFINE_VIEWS_MODEL_TYPE)) - -typedef struct { - ETableModel parent; - - /* item specific fields */ - GalViewCollection *collection; - - guint editable : 1; -} GalDefineViewsModel; - - -typedef struct { - ETableModelClass parent_class; -} GalDefineViewsModelClass; - - -GtkType gal_define_views_model_get_type (void); -ETableModel *gal_define_views_model_new (void); - -void gal_define_views_model_append (GalDefineViewsModel *model, - GalView *view); -GalView *gal_define_views_model_get_view (GalDefineViewsModel *model, - int i); -void gal_define_views_model_delete_view (GalDefineViewsModel *model, - int i); -void gal_define_views_model_copy_view (GalDefineViewsModel *model, - int i); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _GAL_DEFINE_VIEWS_MODEL_H_ */ diff --git a/widgets/menus/gal-define-views.glade b/widgets/menus/gal-define-views.glade deleted file mode 100644 index b393d97d2e..0000000000 --- a/widgets/menus/gal-define-views.glade +++ /dev/null @@ -1,311 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>gal-define-views</name> - <program_name>gal-define-views</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>True</use_widget_names> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <gnome_help_support>True</gnome_help_support> -</project> - -<widget> - <class>GnomeDialog</class> - <name>dialog1</name> - <visible>False</visible> - <title>Define Views for "%s"</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>False</auto_close> - <hide_on_close>False</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button1</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button7</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> - - <widget> - <class>GtkTable</class> - <name>table-top</name> - <rows>5</rows> - <columns>1</columns> - <homogeneous>False</homogeneous> - <row_spacing>6</row_spacing> - <column_spacing>6</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkFrame</class> - <name>frame1</name> - <label>Description</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkTable</class> - <name>table-description</name> - <border_width>6</border_width> - <rows>1</rows> - <columns>2</columns> - <homogeneous>False</homogeneous> - <row_spacing>6</row_spacing> - <column_spacing>6</column_spacing> - </widget> - </widget> - - <widget> - <class>GtkHBox</class> - <name>hbox1</name> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>Custom</class> - <name>custom-table</name> - <creation_function>gal_define_views_dialog_create_etable</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Fri, 10 Nov 2000 16:37:39 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox1</name> - <homogeneous>False</homogeneous> - <spacing>6</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>button-new</name> - <can_focus>True</can_focus> - <label>_New...</label> - <relief>GTK_RELIEF_NORMAL</relief> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-copy</name> - <can_focus>True</can_focus> - <label>_Copy...</label> - <relief>GTK_RELIEF_NORMAL</relief> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-modify</name> - <can_focus>True</can_focus> - <label>_Edit...</label> - <relief>GTK_RELIEF_NORMAL</relief> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkButton</class> - <name>button-delete</name> - <can_focus>True</can_focus> - <label>_Delete...</label> - <relief>GTK_RELIEF_NORMAL</relief> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - </widget> - - <widget> - <class>GtkHButtonBox</class> - <name>hbuttonbox1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>6</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>4</top_attach> - <bottom_attach>5</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkAlignment</class> - <name>alignment3</name> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xscale>0</xscale> - <yscale>1</yscale> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkButton</class> - <name>button-reset</name> - <can_focus>True</can_focus> - <label>Re_set to Factory Defaults...</label> - <relief>GTK_RELIEF_NORMAL</relief> - </widget> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label-views</name> - <label>Views for "%s"</label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c deleted file mode 100644 index 290c28f688..0000000000 --- a/widgets/menus/gal-view-collection.c +++ /dev/null @@ -1,816 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-collection.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> - -#include <util/e-i18n.h> -#include <ctype.h> -#include <string.h> -#include <gtk/gtksignal.h> -#include <gnome-xml/parser.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-util.h> -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> -#include <gal/widgets/e-unicode.h> -#include "gal-view-collection.h" - -#define GVC_CLASS(e) ((GalViewCollectionClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gtk_object_get_type () - -static GtkObjectClass *gal_view_collection_parent_class; - -#define d(x) x - -enum { - DISPLAY_VIEW, - CHANGED, - LAST_SIGNAL -}; - -static guint gal_view_collection_signals [LAST_SIGNAL] = { 0, }; - -/** - * gal_view_collection_display_view: - * @collection: The GalViewCollection to send the signal on. - * @view: The view to display. - * - */ -void -gal_view_collection_display_view (GalViewCollection *collection, - GalView *view) -{ - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - gtk_signal_emit (GTK_OBJECT (collection), - gal_view_collection_signals [DISPLAY_VIEW], - view); -} - -static void -gal_view_collection_changed (GalViewCollection *collection) -{ - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - - gtk_signal_emit (GTK_OBJECT (collection), - gal_view_collection_signals [CHANGED]); -} - -static void -gal_view_collection_item_free (GalViewCollectionItem *item) -{ - g_free(item->id); - if (item->view) { - if (item->view_changed_id) - gtk_signal_disconnect (GTK_OBJECT (item->view), - item->view_changed_id); - gtk_object_unref(GTK_OBJECT(item->view)); - } - g_free(item); -} - -static char * -gal_view_generate_string (GalViewCollection *collection, - GalView *view, - int which) -{ - char *ret_val; - char *pointer; - - if (which == 1) - ret_val = g_strdup(gal_view_get_title(view)); - else - ret_val = g_strdup_printf("%s_%d", gal_view_get_title(view), which); - for (pointer = ret_val; *pointer; pointer++) { - if (!isalnum((guint) *pointer)) { - *pointer = '_'; - } - } - return ret_val; -} - -static gint -gal_view_check_string (GalViewCollection *collection, - char *string) -{ - int i; - - if (!strcmp (string, "current_view")) - return FALSE; - - for (i = 0; i < collection->view_count; i++) { - if (!strcmp(string, collection->view_data[i]->id)) - return FALSE; - } - for (i = 0; i < collection->removed_view_count; i++) { - if (!strcmp(string, collection->removed_view_data[i]->id)) - return FALSE; - } - return TRUE; -} - -static char * -gal_view_generate_id (GalViewCollection *collection, - GalView *view) -{ - int i; - for (i = 1; TRUE; i++) { - char *try; - - try = gal_view_generate_string(collection, view, i); - if (gal_view_check_string(collection, try)) - return try; - g_free(try); - } -} - -static void -gal_view_collection_destroy (GtkObject *object) -{ - GalViewCollection *collection = GAL_VIEW_COLLECTION(object); - int i; - - for (i = 0; i < collection->view_count; i++) { - gal_view_collection_item_free (collection->view_data[i]); - } - g_free(collection->view_data); - e_free_object_list(collection->factory_list); - - for (i = 0; i < collection->removed_view_count; i++) { - gal_view_collection_item_free (collection->removed_view_data[i]); - } - g_free(collection->removed_view_data); - - g_free(collection->system_dir); - g_free(collection->local_dir); - - g_free (collection->default_view); - - if (gal_view_collection_parent_class->destroy) - (*gal_view_collection_parent_class->destroy)(object); -} - -static void -gal_view_collection_class_init (GtkObjectClass *object_class) -{ - GalViewCollectionClass *klass = GAL_VIEW_COLLECTION_CLASS(object_class); - gal_view_collection_parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = gal_view_collection_destroy; - - gal_view_collection_signals [DISPLAY_VIEW] = - gtk_signal_new ("display_view", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GalViewCollectionClass, display_view), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, GAL_VIEW_TYPE); - - gal_view_collection_signals [CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GalViewCollectionClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - E_OBJECT_CLASS_ADD_SIGNALS (object_class, gal_view_collection_signals, LAST_SIGNAL); - - klass->display_view = NULL; - klass->changed = NULL; -} - -static void -gal_view_collection_init (GalViewCollection *collection) -{ - collection->view_data = NULL; - collection->view_count = 0; - collection->factory_list = NULL; - - collection->removed_view_data = NULL; - collection->removed_view_count = 0; - - collection->system_dir = NULL; - collection->local_dir = NULL; - - collection->loaded = FALSE; - collection->default_view = NULL; - collection->default_view_built_in = TRUE; -} - -/** - * gal_view_collection_get_type: - * - */ -guint -gal_view_collection_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewCollection", - sizeof (GalViewCollection), - sizeof (GalViewCollectionClass), - (GtkClassInitFunc) gal_view_collection_class_init, - (GtkObjectInitFunc) gal_view_collection_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -/** - * gal_view_collection_new: - * - * A collection of views and view factories. - */ -GalViewCollection * -gal_view_collection_new (void) -{ - return gtk_type_new(gal_view_collection_get_type()); -} - -/** - * gal_view_collection_set_storage_directories - * @collection: The view collection to initialize - * @system_dir: The location of the system built in views - * @local_dir: The location to store the users set up views - * - * Sets up the GalViewCollection. - */ -void -gal_view_collection_set_storage_directories (GalViewCollection *collection, - const char *system_dir, - const char *local_dir) -{ - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (system_dir != NULL); - g_return_if_fail (local_dir != NULL); - - g_free(collection->system_dir); - g_free(collection->local_dir); - - collection->system_dir = g_strdup(system_dir); - collection->local_dir = g_strdup(local_dir); -} - -/** - * gal_view_collection_add_factory - * @collection: The view collection to add a factory to - * @factory: The factory to add. The @collection will add a reference - * to the factory object, so you should unref it after calling this - * function if you no longer need it. - * - * Adds the given factory to this collection. This list is used both - * when loading views from their xml description as well as when the - * user tries to create a new view. - */ -void -gal_view_collection_add_factory (GalViewCollection *collection, - GalViewFactory *factory) -{ - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (factory != NULL); - g_return_if_fail (GAL_IS_VIEW_FACTORY (factory)); - - gtk_object_ref (GTK_OBJECT (factory)); - collection->factory_list = g_list_prepend (collection->factory_list, factory); -} - -static void -view_changed (GalView *view, - GalViewCollectionItem *item) -{ - item->changed = TRUE; - item->ever_changed = TRUE; - - gal_view_collection_changed(item->collection); -} - -/* Use factory list to load a GalView file. */ -static GalView * -gal_view_collection_real_load_view_from_file (GalViewCollection *collection, const char *type, const char *title, const char *dir, const char *filename) -{ - GalViewFactory *factory; - GList *factories; - - factory = NULL; - for (factories = collection->factory_list; factories; factories = factories->next) { - if (type && !strcmp(gal_view_factory_get_type_code(factories->data), type)) { - factory = factories->data; - break; - } - } - if (factory) { - GalView *view; - - view = gal_view_factory_new_view (factory, title); - gal_view_set_title (view, title); - gal_view_load(view, filename); - return view; - } - return NULL; -} - -GalView * -gal_view_collection_load_view_from_file (GalViewCollection *collection, const char *type, const char *filename) -{ - return gal_view_collection_real_load_view_from_file (collection, type, "", collection->local_dir, filename); -} - -static GalViewCollectionItem * -load_single_file (GalViewCollection *collection, - gchar *dir, - gboolean local, - xmlNode *node) -{ - GalViewCollectionItem *item; - item = g_new(GalViewCollectionItem, 1); - item->ever_changed = local; - item->changed = FALSE; - item->built_in = !local; - item->id = e_xml_get_string_prop_by_name(node, "id"); - item->filename = e_xml_get_string_prop_by_name(node, "filename"); - item->title = e_xml_get_translated_utf8_string_prop_by_name(node, "title"); - item->type = e_xml_get_string_prop_by_name(node, "type"); - item->collection = collection; - item->view_changed_id = 0; - - if (item->filename) { - char *fullpath; - fullpath = g_concat_dir_and_file(dir, item->filename); - item->view = gal_view_collection_real_load_view_from_file (collection, item->type, item->title, dir, fullpath); - g_free(fullpath); - if (item->view) { - item->view_changed_id = - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); - } - } - return item; -} - -static void -load_single_dir (GalViewCollection *collection, - char *dir, - gboolean local) -{ - xmlDoc *doc; - xmlNode *root; - xmlNode *child; - char *filename = g_concat_dir_and_file(dir, "galview.xml"); - char *default_view; - - doc = xmlParseFile(filename); - if (!doc) { - g_free (filename); - return; - } - root = xmlDocGetRootElement(doc); - for (child = root->xmlChildrenNode; child; child = child->next) { - gchar *id = e_xml_get_string_prop_by_name(child, "id"); - gboolean found = FALSE; - int i; - - for (i = 0; i < collection->view_count; i++) { - if (!strcmp(id, collection->view_data[i]->id)) { - if (!local) - collection->view_data[i]->built_in = TRUE; - found = TRUE; - break; - } - } - if (!found) { - for (i = 0; i < collection->removed_view_count; i++) { - if (!strcmp(id, collection->removed_view_data[i]->id)) { - if (!local) - collection->removed_view_data[i]->built_in = TRUE; - found = TRUE; - break; - } - } - } - - if (!found) { - GalViewCollectionItem *item = load_single_file (collection, dir, local, child); - if (item->filename && *item->filename) { - collection->view_data = g_renew(GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count ++; - } else { - collection->removed_view_data = g_renew(GalViewCollectionItem *, collection->removed_view_data, collection->removed_view_count + 1); - collection->removed_view_data[collection->removed_view_count] = item; - collection->removed_view_count ++; - } - } - g_free(id); - } - - default_view = e_xml_get_string_prop_by_name (root, "default-view"); - if (default_view) { - if (local) - collection->default_view_built_in = FALSE; - else - collection->default_view_built_in = TRUE; - g_free (collection->default_view); - collection->default_view = default_view; - } - - g_free(filename); - xmlFreeDoc(doc); -} - -/** - * gal_view_collection_load - * @collection: The view collection to load information for - * - * Loads the data from the system and user directories specified in - * set storage directories. This is primarily for internal use by - * other parts of gal_view. - */ -void -gal_view_collection_load (GalViewCollection *collection) -{ - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (collection->local_dir != NULL); - g_return_if_fail (collection->system_dir != NULL); - g_return_if_fail (!collection->loaded); - - e_create_directory(collection->local_dir); - - load_single_dir(collection, collection->local_dir, TRUE); - load_single_dir(collection, collection->system_dir, FALSE); - gal_view_collection_changed(collection); - - collection->loaded = TRUE; -} - -/** - * gal_view_collection_save - * @collection: The view collection to save information for - * - * Saves the data to the user directory specified in set storage - * directories. This is primarily for internal use by other parts of - * gal_view. - */ -void -gal_view_collection_save (GalViewCollection *collection) -{ - int i; - xmlDoc *doc; - xmlNode *root; - char *filename; - - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (collection->local_dir != NULL); - - doc = xmlNewDoc("1.0"); - root = xmlNewNode(NULL, "GalViewCollection"); - xmlDocSetRootElement(doc, root); - - if (collection->default_view && !collection->default_view_built_in) { - e_xml_set_string_prop_by_name(root, "default-view", collection->default_view); - } - - for (i = 0; i < collection->view_count; i++) { - xmlNode *child; - GalViewCollectionItem *item; - - item = collection->view_data[i]; - if (item->ever_changed) { - child = xmlNewChild(root, NULL, "GalView", NULL); - e_xml_set_string_prop_by_name(child, "id", item->id); - e_xml_set_string_prop_by_name(child, "title", item->title); - e_xml_set_string_prop_by_name(child, "filename", item->filename); - e_xml_set_string_prop_by_name(child, "type", item->type); - - if (item->changed) { - filename = g_concat_dir_and_file(collection->local_dir, item->filename); - gal_view_save(item->view, filename); - g_free(filename); - } - } - } - for (i = 0; i < collection->removed_view_count; i++) { - xmlNode *child; - GalViewCollectionItem *item; - - item = collection->removed_view_data[i]; - - child = xmlNewChild(root, NULL, "GalView", NULL); - e_xml_set_string_prop_by_name(child, "id", item->id); - e_xml_set_string_prop_by_name(child, "title", item->title); - e_xml_set_string_prop_by_name(child, "type", item->type); - } - filename = g_concat_dir_and_file(collection->local_dir, "galview.xml"); - xmlSaveFile(filename, doc); - xmlFreeDoc(doc); - g_free(filename); -} - -/** - * gal_view_collection_get_count - * @collection: The view collection to count - * - * Calculates the number of views in the given collection. - * - * Returns: The number of views in the collection. - */ -gint -gal_view_collection_get_count (GalViewCollection *collection) -{ - g_return_val_if_fail (collection != NULL, -1); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), -1); - - return collection->view_count; -} - -/** - * gal_view_collection_get_view - * @collection: The view collection to query - * @n: The view to get. - * - * Returns: The nth view in the collection - */ -GalView * -gal_view_collection_get_view (GalViewCollection *collection, - int n) -{ - g_return_val_if_fail (collection != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (n < collection->view_count, NULL); - g_return_val_if_fail (n >= 0, NULL); - - return collection->view_data[n]->view; -} - -/** - * gal_view_collection_get_view_item - * @collection: The view collection to query - * @n: The view item to get. - * - * Returns: The nth view item in the collection - */ -GalViewCollectionItem * -gal_view_collection_get_view_item (GalViewCollection *collection, - int n) -{ - g_return_val_if_fail (collection != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail(n < collection->view_count, NULL); - g_return_val_if_fail(n >= 0, NULL); - - return collection->view_data[n]; -} - -int -gal_view_collection_get_view_index_by_id (GalViewCollection *collection, const char *view_id) -{ - int i; - for (i = 0; i < collection->view_count; i++) { - if (!strcmp (collection->view_data[i]->id, view_id)) - return i; - } - return -1; -} - -char * -gal_view_collection_get_view_id_by_index (GalViewCollection *collection, int n) -{ - g_return_val_if_fail (collection != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail(n < collection->view_count, NULL); - g_return_val_if_fail(n >= 0, NULL); - - return g_strdup (collection->view_data[n]->id); -} - - -void -gal_view_collection_append (GalViewCollection *collection, - GalView *view) -{ - GalViewCollectionItem *item; - - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - item = g_new(GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = TRUE; - item->built_in = FALSE; - item->title = g_strdup(gal_view_get_title(view)); - item->type = g_strdup(gal_view_get_type_code(view)); - item->id = gal_view_generate_id(collection, view); - item->filename = g_strdup_printf("%s.galview", item->id); - item->view = view; - item->collection = collection; - gtk_object_ref(GTK_OBJECT(view)); - - item->view_changed_id = - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); - - collection->view_data = g_renew(GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count ++; - - gal_view_collection_changed(collection); -} - -void -gal_view_collection_delete_view (GalViewCollection *collection, - int i) -{ - GalViewCollectionItem *item; - - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (i >= 0 && i < collection->view_count); - - item = collection->view_data[i]; - memmove(collection->view_data + i, collection->view_data + i + 1, (collection->view_count - i - 1) * sizeof(GalViewCollectionItem *)); - collection->view_count --; - if (item->built_in) { - g_free(item->filename); - item->filename = NULL; - - collection->removed_view_data = g_renew(GalViewCollectionItem *, collection->removed_view_data, collection->removed_view_count + 1); - collection->removed_view_data[collection->removed_view_count] = item; - collection->removed_view_count ++; - } else { - gal_view_collection_item_free (item); - } - - gal_view_collection_changed(collection); -} - -void -gal_view_collection_copy_view (GalViewCollection *collection, - int i) -{ - GalViewCollectionItem *item; - GalView *view; - - g_return_if_fail (collection != NULL); - g_return_if_fail (GAL_IS_VIEW_COLLECTION (collection)); - g_return_if_fail (i >= 0 && i < collection->view_count); - - view = collection->view_data[i]->view; - - item = g_new(GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = FALSE; - item->built_in = FALSE; - item->title = g_strdup(gal_view_get_title(view)); - item->type = g_strdup(gal_view_get_type_code(view)); - item->id = gal_view_generate_id(collection, view); - item->filename = g_strdup_printf("%s.galview", item->id); - item->view = gal_view_clone(view); - item->collection = collection; - - item->view_changed_id = - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); - - collection->view_data = g_renew(GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count ++; - - gal_view_collection_changed(collection); -} - -gboolean -gal_view_collection_loaded (GalViewCollection *collection) -{ - return collection->loaded; -} - -const char * -gal_view_collection_append_with_title (GalViewCollection *collection, const char *title, GalView *view) -{ - GalViewCollectionItem *item; - - g_return_val_if_fail (collection != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (view != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - gal_view_set_title (view, title); - - d(g_print("%s: %p\n", __FUNCTION__, view)); - - item = g_new(GalViewCollectionItem, 1); - item->ever_changed = TRUE; - item->changed = TRUE; - item->built_in = FALSE; - item->title = g_strdup(gal_view_get_title(view)); - item->type = g_strdup(gal_view_get_type_code(view)); - item->id = gal_view_generate_id(collection, view); - item->filename = g_strdup_printf("%s.galview", item->id); - item->view = view; - item->collection = collection; - gtk_object_ref(GTK_OBJECT(view)); - - item->view_changed_id = - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); - - collection->view_data = g_renew(GalViewCollectionItem *, collection->view_data, collection->view_count + 1); - collection->view_data[collection->view_count] = item; - collection->view_count ++; - - gal_view_collection_changed(collection); - return item->id; -} - -const char * -gal_view_collection_set_nth_view (GalViewCollection *collection, int i, GalView *view) -{ - GalViewCollectionItem *item; - - g_return_val_if_fail (collection != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_COLLECTION (collection), NULL); - g_return_val_if_fail (view != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - g_return_val_if_fail (i >= 0, NULL); - g_return_val_if_fail (i < collection->view_count, NULL); - - d(g_print("%s: %p\n", __FUNCTION__, view)); - - item = collection->view_data[i]; - - gal_view_set_title (view, item->title); - gtk_object_ref (GTK_OBJECT (view)); - if (item->view) { - gtk_signal_disconnect (GTK_OBJECT (item->view), - item->view_changed_id); - gtk_object_unref (GTK_OBJECT (item->view)); - } - item->view = view; - - item->ever_changed = TRUE; - item->changed = TRUE; - item->type = g_strdup(gal_view_get_type_code(view)); - - item->view_changed_id = - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); - - gal_view_collection_changed (collection); - return item->id; -} - -const char * -gal_view_collection_get_default_view (GalViewCollection *collection) -{ - return collection->default_view; -} - -void -gal_view_collection_set_default_view (GalViewCollection *collection, const char *id) -{ - g_free (collection->default_view); - collection->default_view = g_strdup (id); - gal_view_collection_changed (collection); - collection->default_view_built_in = FALSE; -} diff --git a/widgets/menus/gal-view-collection.h b/widgets/menus/gal-view-collection.h deleted file mode 100644 index 89501cda4c..0000000000 --- a/widgets/menus/gal-view-collection.h +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-collection.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_SET_H_ -#define _GAL_VIEW_SET_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-factory.h> -#include <libgnome/gnome-defs.h> - -BEGIN_GNOME_DECLS - - -#define GAL_VIEW_COLLECTION_TYPE (gal_view_collection_get_type ()) -#define GAL_VIEW_COLLECTION(o) (GTK_CHECK_CAST ((o), GAL_VIEW_COLLECTION_TYPE, GalViewCollection)) -#define GAL_VIEW_COLLECTION_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_COLLECTION_TYPE, GalViewCollectionClass)) -#define GAL_IS_VIEW_COLLECTION(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_COLLECTION_TYPE)) -#define GAL_IS_VIEW_COLLECTION_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_COLLECTION_TYPE)) - -typedef struct GalViewCollectionItem GalViewCollectionItem; - -typedef struct { - GtkObject base; - - GalViewCollectionItem **view_data; - int view_count; - - GList *factory_list; - - GalViewCollectionItem **removed_view_data; - int removed_view_count; - - guint loaded : 1; - guint default_view_built_in : 1; - - char *system_dir; - char *local_dir; - - char *default_view; -} GalViewCollection; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Signals - */ - void (*display_view) (GalViewCollection *collection, - GalView *view); - void (*changed) (GalViewCollection *collection); -} GalViewCollectionClass; - -struct GalViewCollectionItem { - GalView *view; - char *id; - guint changed : 1; - guint ever_changed : 1; - guint built_in : 1; - char *filename; - char *title; - char *type; - GalViewCollection *collection; - guint view_changed_id; -}; - -/* Standard functions */ -GtkType gal_view_collection_get_type (void); -GalViewCollection *gal_view_collection_new (void); - -/* Set up the view collection. Call these three functions before ever doing load or save and never call them again. */ -void gal_view_collection_set_storage_directories (GalViewCollection *collection, - const char *system_dir, - const char *local_dir); -void gal_view_collection_add_factory (GalViewCollection *collection, - GalViewFactory *factory); - -/* Send the display view signal. This function is deprecated. */ -void gal_view_collection_display_view (GalViewCollection *collection, - GalView *view); - - -/* Query the view collection. */ -gint gal_view_collection_get_count (GalViewCollection *collection); -GalView *gal_view_collection_get_view (GalViewCollection *collection, - int n); -GalViewCollectionItem *gal_view_collection_get_view_item (GalViewCollection *collection, - int n); -int gal_view_collection_get_view_index_by_id (GalViewCollection *collection, - const char *view_id); -char *gal_view_collection_get_view_id_by_index (GalViewCollection *collection, - int n); - -/* Manipulate the view collection */ -void gal_view_collection_append (GalViewCollection *collection, - GalView *view); -void gal_view_collection_delete_view (GalViewCollection *collection, - int i); -void gal_view_collection_copy_view (GalViewCollection *collection, - int i); -/* Call set_storage_directories and add factories for anything that - * might be found there before doing either of these. */ -void gal_view_collection_load (GalViewCollection *collection); -void gal_view_collection_save (GalViewCollection *collection); -gboolean gal_view_collection_loaded (GalViewCollection *collection); - -/* Use factory list to load a GalView file. */ -GalView *gal_view_collection_load_view_from_file (GalViewCollection *collection, - const char *type, - const char *filename); - -/* Returns id of the new view. These functions are used for - GalViewInstanceSaveAsDialog. */ -const char *gal_view_collection_append_with_title (GalViewCollection *collection, - const char *title, - GalView *view); -const char *gal_view_collection_set_nth_view (GalViewCollection *collection, - int i, - GalView *view); - -const char *gal_view_collection_get_default_view (GalViewCollection *collection); -void gal_view_collection_set_default_view (GalViewCollection *collection, - const char *id); - - -END_GNOME_DECLS - - -#endif /* _GAL_VIEW_COLLECTION_H_ */ diff --git a/widgets/menus/gal-view-etable.c b/widgets/menus/gal-view-etable.c deleted file mode 100644 index f81482435d..0000000000 --- a/widgets/menus/gal-view-etable.c +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-etable.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include "gal-view-etable.h" -#include <gal/e-table/e-table-config.h> - -#define PARENT_TYPE gal_view_get_type () - -static GalViewClass *gal_view_etable_parent_class; - -static void -detach_table (GalViewEtable *view) -{ - if (view->table == NULL) - return; - if (view->table_state_changed_id) { - gtk_signal_disconnect (GTK_OBJECT (view->table), - view->table_state_changed_id); - view->table_state_changed_id = 0; - } - gtk_object_unref (GTK_OBJECT (view->table)); - view->table = NULL; -} - -static void -detach_tree (GalViewEtable *view) -{ - if (view->tree == NULL) - return; - if (view->tree_state_changed_id) { - gtk_signal_disconnect (GTK_OBJECT (view->tree), - view->tree_state_changed_id); - view->tree_state_changed_id = 0; - } - gtk_object_unref (GTK_OBJECT (view->tree)); - view->tree = NULL; -} - -static void -config_changed (ETableConfig *config, GalViewEtable *view) -{ - ETableState *state; - if (view->state) - gtk_object_unref(GTK_OBJECT(view->state)); - gtk_object_get (GTK_OBJECT (config), - "state", &state, - NULL); - view->state = e_table_state_duplicate(state); - gal_view_changed(GAL_VIEW(view)); -} - -static void -gal_view_etable_edit (GalView *view) -{ - GalViewEtable *etable_view = GAL_VIEW_ETABLE(view); - ETableConfig *config; - - config = e_table_config_new(etable_view->title, - etable_view->spec, - etable_view->state); - - gtk_signal_connect(GTK_OBJECT(config), "changed", - GTK_SIGNAL_FUNC(config_changed), view); -} - -static void -gal_view_etable_load (GalView *view, - const char *filename) -{ - e_table_state_load_from_file(GAL_VIEW_ETABLE(view)->state, filename); -} - -static void -gal_view_etable_save (GalView *view, - const char *filename) -{ - e_table_state_save_to_file(GAL_VIEW_ETABLE(view)->state, filename); -} - -static const char * -gal_view_etable_get_title (GalView *view) -{ - return GAL_VIEW_ETABLE(view)->title; -} - -static void -gal_view_etable_set_title (GalView *view, - const char *title) -{ - g_free(GAL_VIEW_ETABLE(view)->title); - GAL_VIEW_ETABLE(view)->title = g_strdup(title); -} - -static const char * -gal_view_etable_get_type_code (GalView *view) -{ - return "etable"; -} - -static GalView * -gal_view_etable_clone (GalView *view) -{ - GalViewEtable *gve, *new; - - gve = GAL_VIEW_ETABLE(view); - - new = gtk_type_new (gal_view_etable_get_type ()); - new->spec = gve->spec; - new->title = g_strdup (gve->title); - new->state = e_table_state_duplicate(gve->state); - - gtk_object_ref(GTK_OBJECT(new->spec)); - - return GAL_VIEW(new); -} - -static void -gal_view_etable_destroy (GtkObject *object) -{ - GalViewEtable *view = GAL_VIEW_ETABLE(object); - - gal_view_etable_detach (view); - - g_free(view->title); - if (view->spec) - gtk_object_unref(GTK_OBJECT(view->spec)); - if (view->state) - gtk_object_unref(GTK_OBJECT(view->state)); - - if (GTK_OBJECT_CLASS (gal_view_etable_parent_class)->destroy) - (* GTK_OBJECT_CLASS (gal_view_etable_parent_class)->destroy) (object); -} - -static void -gal_view_etable_class_init (GtkObjectClass *object_class) -{ - GalViewClass *gal_view_class = GAL_VIEW_CLASS(object_class); - gal_view_etable_parent_class = gtk_type_class (PARENT_TYPE); - - gal_view_class->edit = gal_view_etable_edit ; - gal_view_class->load = gal_view_etable_load ; - gal_view_class->save = gal_view_etable_save ; - gal_view_class->get_title = gal_view_etable_get_title ; - gal_view_class->set_title = gal_view_etable_set_title ; - gal_view_class->get_type_code = gal_view_etable_get_type_code; - gal_view_class->clone = gal_view_etable_clone ; - - object_class->destroy = gal_view_etable_destroy ; -} - -static void -gal_view_etable_init (GalViewEtable *gve) -{ - gve->spec = NULL; - gve->state = e_table_state_new(); - gve->title = NULL; -} - -GtkType -gal_view_etable_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewEtable", - sizeof (GalViewEtable), - sizeof (GalViewEtableClass), - (GtkClassInitFunc) gal_view_etable_class_init, - (GtkObjectInitFunc) gal_view_etable_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -/** - * gal_view_etable_new - * @spec: The ETableSpecification that this view will be based upon. - * @title: The name of the new view. - * - * Returns a new GalViewEtable. This is primarily for use by - * GalViewFactoryEtable. - * - * Returns: The new GalViewEtable. - */ -GalView * -gal_view_etable_new (ETableSpecification *spec, - const gchar *title) -{ - return gal_view_etable_construct (gtk_type_new (gal_view_etable_get_type ()), spec, title); -} - -/** - * gal_view_etable_construct - * @view: The view to construct. - * @spec: The ETableSpecification that this view will be based upon. - * @title: The name of the new view. - * - * constructs the GalViewEtable. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewEtable. - */ -GalView * -gal_view_etable_construct (GalViewEtable *view, - ETableSpecification *spec, - const gchar *title) -{ - if (spec) - gtk_object_ref(GTK_OBJECT(spec)); - view->spec = spec; - - if (view->state) - gtk_object_unref(GTK_OBJECT(view->state)); - view->state = e_table_state_duplicate(spec->state); - - view->title = g_strdup(title); - - return GAL_VIEW(view); -} - -void -gal_view_etable_set_state (GalViewEtable *view, ETableState *state) -{ - if (view->state) - gtk_object_unref(GTK_OBJECT(view->state)); - view->state = e_table_state_duplicate(state); - - gal_view_changed(GAL_VIEW(view)); -} - -static void -table_state_changed (ETable *table, GalViewEtable *view) -{ - ETableState *state; - - state = e_table_get_state_object (table); - gtk_object_unref (GTK_OBJECT (view->state)); - view->state = state; - - gal_view_changed(GAL_VIEW(view)); -} - -static void -tree_state_changed (ETree *tree, GalViewEtable *view) -{ - ETableState *state; - - state = e_tree_get_state_object (tree); - gtk_object_unref (GTK_OBJECT (view->state)); - view->state = state; - - gal_view_changed(GAL_VIEW(view)); -} - -void -gal_view_etable_attach_table (GalViewEtable *view, ETable *table) -{ - gal_view_etable_detach (view); - - view->table = table; - - e_table_set_state_object(view->table, view->state); - gtk_object_ref (GTK_OBJECT (view->table)); - view->table_state_changed_id = - gtk_signal_connect(GTK_OBJECT(view->table), "state_change", - GTK_SIGNAL_FUNC (table_state_changed), view); -} - -void -gal_view_etable_attach_tree (GalViewEtable *view, ETree *tree) -{ - gal_view_etable_detach (view); - - view->tree = tree; - - e_tree_set_state_object(view->tree, view->state); - gtk_object_ref (GTK_OBJECT (view->tree)); - view->tree_state_changed_id = - gtk_signal_connect(GTK_OBJECT(view->tree), "state_change", - GTK_SIGNAL_FUNC (tree_state_changed), view); -} - -void -gal_view_etable_detach (GalViewEtable *view) -{ - if (view->table != NULL) - detach_table (view); - if (view->tree != NULL) - detach_tree (view); -} diff --git a/widgets/menus/gal-view-etable.h b/widgets/menus/gal-view-etable.h deleted file mode 100644 index 2fd001e583..0000000000 --- a/widgets/menus/gal-view-etable.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-etable.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_ETABLE_H_ -#define _GAL_VIEW_ETABLE_H_ - -#include <libgnome/gnome-defs.h> -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view.h> -#include <gal/e-table/e-table-state.h> -#include <gal/e-table/e-table-specification.h> -#include <gal/e-table/e-table.h> -#include <gal/e-table/e-tree.h> - -BEGIN_GNOME_DECLS - -#define GAL_VIEW_ETABLE_TYPE (gal_view_etable_get_type ()) -#define GAL_VIEW_ETABLE(o) (GTK_CHECK_CAST ((o), GAL_VIEW_ETABLE_TYPE, GalViewEtable)) -#define GAL_VIEW_ETABLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_ETABLE_TYPE, GalViewEtableClass)) -#define GAL_IS_VIEW_ETABLE(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_ETABLE_TYPE)) -#define GAL_IS_VIEW_ETABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_ETABLE_TYPE)) - -typedef struct { - GalView base; - - ETableSpecification *spec; - ETableState *state; - char *title; - - ETable *table; - guint table_state_changed_id; - - ETree *tree; - guint tree_state_changed_id; -} GalViewEtable; - -typedef struct { - GalViewClass parent_class; -} GalViewEtableClass; - -/* Standard functions */ -GtkType gal_view_etable_get_type (void); -GalView *gal_view_etable_new (ETableSpecification *spec, - const gchar *title); -GalView *gal_view_etable_construct (GalViewEtable *view, - ETableSpecification *spec, - const gchar *title); -void gal_view_etable_set_state (GalViewEtable *view, - ETableState *state); -void gal_view_etable_attach_table (GalViewEtable *view, - ETable *table); -void gal_view_etable_attach_tree (GalViewEtable *view, - ETree *tree); -void gal_view_etable_detach (GalViewEtable *view); - -END_GNOME_DECLS - -#endif /* _GAL_VIEW_ETABLE_H_ */ diff --git a/widgets/menus/gal-view-factory-etable.c b/widgets/menus/gal-view-factory-etable.c deleted file mode 100644 index 026d085145..0000000000 --- a/widgets/menus/gal-view-factory-etable.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-etable.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include "gal/util/e-i18n.h" -#include "gal-view-factory-etable.h" -#include "gal-view-etable.h" - -#define GVFE_CLASS(e) ((GalViewFactoryEtableClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gal_view_factory_get_type () - -static GalViewFactoryClass *gal_view_factory_etable_parent_class; - -static const char * -gal_view_factory_etable_get_title (GalViewFactory *factory) -{ - return _("Table"); -} - -static GalView * -gal_view_factory_etable_new_view (GalViewFactory *factory, - const char *name) -{ - return gal_view_etable_new(GAL_VIEW_FACTORY_ETABLE(factory)->spec, name); -} - -static const char * -gal_view_factory_etable_get_type_code (GalViewFactory *factory) -{ - return "etable"; -} - -static void -gal_view_factory_etable_destroy (GtkObject *object) -{ - GalViewFactoryEtable *factory = GAL_VIEW_FACTORY_ETABLE(object); - - if (factory->spec) - gtk_object_unref(GTK_OBJECT(factory->spec)); - - if (GTK_OBJECT_CLASS (gal_view_factory_etable_parent_class)->destroy) - (* GTK_OBJECT_CLASS (gal_view_factory_etable_parent_class)->destroy) (object); -} - -static void -gal_view_factory_etable_class_init (GtkObjectClass *object_class) -{ - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS(object_class); - gal_view_factory_etable_parent_class = gtk_type_class (PARENT_TYPE); - - view_factory_class->get_title = gal_view_factory_etable_get_title; - view_factory_class->new_view = gal_view_factory_etable_new_view; - view_factory_class->get_type_code = gal_view_factory_etable_get_type_code; - - object_class->destroy = gal_view_factory_etable_destroy; -} - -static void -gal_view_factory_etable_init (GalViewFactoryEtable *factory) -{ - factory->spec = NULL; -} - -/** - * gal_view_etable_new - * @spec: The spec to create GalViewEtables based upon. - * - * A new GalViewFactory for creating ETable views. Create one of - * these and pass it to GalViewCollection for use. - * - * Returns: The new GalViewFactoryEtable. - */ -GalViewFactory * -gal_view_factory_etable_new (ETableSpecification *spec) -{ - return gal_view_factory_etable_construct (gtk_type_new (gal_view_factory_etable_get_type ()), spec); -} - -/** - * gal_view_etable_construct - * @factory: The factory to construct - * @spec: The spec to create GalViewEtables based upon. - * - * constructs the GalViewFactoryEtable. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryEtable. - */ -GalViewFactory * -gal_view_factory_etable_construct (GalViewFactoryEtable *factory, - ETableSpecification *spec) -{ - if (spec) - gtk_object_ref(GTK_OBJECT(spec)); - factory->spec = spec; - return GAL_VIEW_FACTORY(factory); -} - -GtkType -gal_view_factory_etable_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewFactoryEtable", - sizeof (GalViewFactoryEtable), - sizeof (GalViewFactoryEtableClass), - (GtkClassInitFunc) gal_view_factory_etable_class_init, - (GtkObjectInitFunc) gal_view_factory_etable_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} diff --git a/widgets/menus/gal-view-factory-etable.h b/widgets/menus/gal-view-factory-etable.h deleted file mode 100644 index 502f39b5f6..0000000000 --- a/widgets/menus/gal-view-factory-etable.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-etable.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_FACTORY_ETABLE_H_ -#define _GAL_VIEW_FACTORY_ETABLE_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-factory.h> -#include <gal/e-table/e-table-specification.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_VIEW_FACTORY_ETABLE_TYPE (gal_view_factory_etable_get_type ()) -#define GAL_VIEW_FACTORY_ETABLE(o) (GTK_CHECK_CAST ((o), GAL_VIEW_FACTORY_ETABLE_TYPE, GalViewFactoryEtable)) -#define GAL_VIEW_FACTORY_ETABLE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_FACTORY_ETABLE_TYPE, GalViewFactoryEtableClass)) -#define GAL_IS_VIEW_FACTORY_ETABLE(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_FACTORY_ETABLE_TYPE)) -#define GAL_IS_VIEW_FACTORY_ETABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_FACTORY_ETABLE_TYPE)) - -typedef struct { - GalViewFactory base; - - ETableSpecification *spec; -} GalViewFactoryEtable; - -typedef struct { - GalViewFactoryClass parent_class; -} GalViewFactoryEtableClass; - -/* Standard functions */ -GtkType gal_view_factory_etable_get_type (void); -GalViewFactory *gal_view_factory_etable_new (ETableSpecification *spec); -GalViewFactory *gal_view_factory_etable_construct (GalViewFactoryEtable *factory, - ETableSpecification *spec); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _GAL_VIEW_FACTORY_ETABLE_H_ */ diff --git a/widgets/menus/gal-view-factory.c b/widgets/menus/gal-view-factory.c deleted file mode 100644 index 0f0d274b06..0000000000 --- a/widgets/menus/gal-view-factory.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include "gal-view-factory.h" - -#define GVF_CLASS(e) ((GalViewFactoryClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gtk_object_get_type () - -#define d(x) - -d(static gint depth = 0;) - -static GtkObjectClass *gal_view_factory_parent_class; - -/** - * gal_view_factory_get_title: - * @factory: The factory to query. - * - * Returns: The title of the factory. - */ -const char * -gal_view_factory_get_title (GalViewFactory *factory) -{ - g_return_val_if_fail (factory != NULL, 0); - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), 0); - - if (GVF_CLASS (factory)->get_title) - return GVF_CLASS (factory)->get_title (factory); - else - return NULL; -} - -/** - * gal_view_factory_new_view: - * @factory: The factory to use - * @name: the name for the view. - * - * Returns: The new view - */ -GalView * -gal_view_factory_new_view (GalViewFactory *factory, - const char *name) -{ - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - if (GVF_CLASS (factory)->new_view) - return GVF_CLASS (factory)->new_view (factory, name); - else - return NULL; -} - -/** - * gal_view_factory_get_type_code: - * @factory: The factory to use - * - * Returns: The type code - */ -const char * -gal_view_factory_get_type_code (GalViewFactory *factory) -{ - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_FACTORY (factory), NULL); - - if (GVF_CLASS (factory)->get_type_code) - return GVF_CLASS (factory)->get_type_code (factory); - else - return NULL; -} - -static void -gal_view_factory_class_init (GtkObjectClass *object_class) -{ - GalViewFactoryClass *klass = GAL_VIEW_FACTORY_CLASS(object_class); - gal_view_factory_parent_class = gtk_type_class (PARENT_TYPE); - - klass->get_title = NULL; - klass->new_view = NULL; -} - -GtkType -gal_view_factory_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewFactory", - sizeof (GalViewFactory), - sizeof (GalViewFactoryClass), - (GtkClassInitFunc) gal_view_factory_class_init, - NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} diff --git a/widgets/menus/gal-view-factory.h b/widgets/menus/gal-view-factory.h deleted file mode 100644 index b02c728517..0000000000 --- a/widgets/menus/gal-view-factory.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_FACTORY_H_ -#define _GAL_VIEW_FACTORY_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_VIEW_FACTORY_TYPE (gal_view_factory_get_type ()) -#define GAL_VIEW_FACTORY(o) (GTK_CHECK_CAST ((o), GAL_VIEW_FACTORY_TYPE, GalViewFactory)) -#define GAL_VIEW_FACTORY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_FACTORY_TYPE, GalViewFactoryClass)) -#define GAL_IS_VIEW_FACTORY(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_FACTORY_TYPE)) -#define GAL_IS_VIEW_FACTORY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_FACTORY_TYPE)) - -typedef struct { - GtkObject base; -} GalViewFactory; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - const char *(*get_title) (GalViewFactory *factory); - const char *(*get_type_code) (GalViewFactory *factory); - GalView *(*new_view) (GalViewFactory *factory, - const char *name); -} GalViewFactoryClass; - -/* Standard functions */ -GtkType gal_view_factory_get_type (void); - -/* Query functions */ -/* Returns already translated title. */ -const char *gal_view_factory_get_title (GalViewFactory *factory); - -/* Returns the code for use in identifying this type of object in the - * view list. This identifier should identify this as being the - * unique factory for xml files which were written out with this - * identifier. Thus each factory should have a unique type code. */ -const char *gal_view_factory_get_type_code (GalViewFactory *factory); - -/* Create a new view */ -GalView *gal_view_factory_new_view (GalViewFactory *factory, - const char *name); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* _GAL_VIEW_FACTORY_H_ */ diff --git a/widgets/menus/gal-view-instance-save-as-dialog.c b/widgets/menus/gal-view-instance-save-as-dialog.c deleted file mode 100644 index c00937b46f..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-dialog.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> - -#include "gal-view-instance-save-as-dialog.h" - -#include <libgnomeui/gnome-dialog.h> -#include <libgnomeui/gnome-stock.h> -#include "gal-define-views-model.h" -#include "gal-view-new-dialog.h" -#include <gal/e-table/e-table-scrolled.h> -#include <gal/util/e-i18n.h> - -static GnomeDialogClass *parent_class = NULL; -#define PARENT_TYPE gnome_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, - ARG_INSTANCE, -}; - -typedef struct { - char *title; - ETableModel *model; - GalViewInstanceSaveAsDialog *names; -} GalViewInstanceSaveAsDialogChild; - - -/* Static functions */ -static void -gal_view_instance_save_as_dialog_set_instance(GalViewInstanceSaveAsDialog *dialog, - GalViewInstance *instance) -{ - dialog->instance = instance; - if (dialog->model) { - gtk_object_set(GTK_OBJECT(dialog->model), - "collection", instance ? instance->collection : NULL, - NULL); - } -} - -static void -gvisad_setup_radio_buttons (GalViewInstanceSaveAsDialog *dialog) -{ - GtkWidget *radio_replace = glade_xml_get_widget (dialog->gui, "radiobutton-replace"); - GtkWidget *radio_create = glade_xml_get_widget (dialog->gui, "radiobutton-create" ); - GtkWidget *widget; - GtkNotebook *notebook = GTK_NOTEBOOK (glade_xml_get_widget (dialog->gui, "notebook-help")); - - widget = glade_xml_get_widget (dialog->gui, "custom-replace"); - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_replace))) { - gtk_widget_set_sensitive (widget, TRUE); - gtk_notebook_set_page (notebook, 0); - dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE; - } else { - gtk_widget_set_sensitive (widget, FALSE); - } - - widget = glade_xml_get_widget (dialog->gui, "entry-create"); - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_create))) { - gtk_widget_set_sensitive (widget, TRUE); - gtk_notebook_set_page (notebook, 1); - dialog->toggle = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE; - } else { - gtk_widget_set_sensitive (widget, FALSE); - } -} - -static void -gvisad_radio_toggled (GtkWidget *widget, GalViewInstanceSaveAsDialog *dialog) -{ - gvisad_setup_radio_buttons (dialog); -} - -static void -gvisad_connect_signal(GalViewInstanceSaveAsDialog *dialog, char *widget_name, char *signal, GtkSignalFunc handler) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget(dialog->gui, widget_name); - - if (widget) - gtk_signal_connect(GTK_OBJECT(widget), signal, handler, dialog); -} - -/* Method override implementations */ -static void -gal_view_instance_save_as_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GalViewInstanceSaveAsDialog *dialog; - - dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (o); - - switch (arg_id){ - case ARG_INSTANCE: - if (GTK_VALUE_OBJECT(*arg)) - gal_view_instance_save_as_dialog_set_instance(dialog, GAL_VIEW_INSTANCE(GTK_VALUE_OBJECT(*arg))); - else - gal_view_instance_save_as_dialog_set_instance(dialog, NULL); - break; - - default: - return; - } -} - -static void -gal_view_instance_save_as_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GalViewInstanceSaveAsDialog *dialog; - - dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (object); - - switch (arg_id) { - case ARG_INSTANCE: - if (dialog->instance) - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(dialog->instance); - else - GTK_VALUE_OBJECT(*arg) = NULL; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -gal_view_instance_save_as_dialog_destroy (GtkObject *object) -{ - GalViewInstanceSaveAsDialog *gal_view_instance_save_as_dialog = GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(object); - - gtk_object_unref(GTK_OBJECT(gal_view_instance_save_as_dialog->gui)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Init functions */ -static void -gal_view_instance_save_as_dialog_class_init (GalViewInstanceSaveAsDialogClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = gal_view_instance_save_as_dialog_set_arg; - object_class->get_arg = gal_view_instance_save_as_dialog_get_arg; - object_class->destroy = gal_view_instance_save_as_dialog_destroy; - - gtk_object_add_arg_type("GalViewInstanceSaveAsDialog::instance", GAL_VIEW_INSTANCE_TYPE, - GTK_ARG_READWRITE, ARG_INSTANCE); -} - -static void -gal_view_instance_save_as_dialog_init (GalViewInstanceSaveAsDialog *dialog) -{ - GladeXML *gui; - GtkWidget *widget; - GtkWidget *etable; - - dialog->instance = NULL; - - gui = glade_xml_new_with_domain (GAL_GLADEDIR "/gal-view-instance-save-as-dialog.glade", NULL, PACKAGE); - dialog->gui = gui; - - widget = glade_xml_get_widget(gui, "table-top"); - if (!widget) { - return; - } - gtk_widget_ref(widget); - gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gnome_dialog_append_buttons(GNOME_DIALOG(dialog), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gvisad_connect_signal(dialog, "radiobutton-replace", "toggled", GTK_SIGNAL_FUNC(gvisad_radio_toggled)); - gvisad_connect_signal(dialog, "radiobutton-create", "toggled", GTK_SIGNAL_FUNC(gvisad_radio_toggled)); - - dialog->model = NULL; - etable = glade_xml_get_widget(dialog->gui, "custom-replace"); - if (etable) { - dialog->model = gtk_object_get_data(GTK_OBJECT(etable), "GalViewInstanceSaveAsDialog::model"); - gtk_object_set(GTK_OBJECT(dialog->model), - "collection", dialog->instance ? dialog->instance->collection : NULL, - NULL); - } - - gvisad_setup_radio_buttons (dialog); - gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE); -} - - -/* For use from libglade. */ -/* ETable creation */ -#define SPEC "<ETableSpecification no-header=\"true\" cursor-mode=\"line\" draw-grid=\"false\" selection-mode=\"single\" gettext-domain=\"" E_I18N_DOMAIN "\">" \ - "<ETableColumn model_col= \"0\" _title=\"Name\" expansion=\"1.0\" minimum_width=\"18\" resizable=\"true\" cell=\"string\" compare=\"string\"/>" \ - "<ETableState> <column source=\"0\"/> <grouping> </grouping> </ETableState>" \ - "</ETableSpecification>" - -GtkWidget *gal_view_instance_save_as_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2); - -GtkWidget * -gal_view_instance_save_as_dialog_create_etable(char *name, char *string1, char *string2, int int1, int int2) -{ - GtkWidget *table; - ETableModel *model; - model = gal_define_views_model_new(); - table = e_table_scrolled_new(model, NULL, SPEC, NULL); - gtk_object_set_data(GTK_OBJECT(table), "GalViewInstanceSaveAsDialog::model", model); - return table; -} - -/* External methods */ -/** - * gal_view_instance_save_as_dialog_new - * - * Returns a new dialog for defining views. - * - * Returns: The GalViewInstanceSaveAsDialog. - */ -GtkWidget* -gal_view_instance_save_as_dialog_new (GalViewInstance *instance) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (gal_view_instance_save_as_dialog_get_type ())); - gal_view_instance_save_as_dialog_set_instance(GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (widget), instance); - return widget; -} - -GtkType -gal_view_instance_save_as_dialog_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "GalViewInstanceSaveAsDialog", - sizeof (GalViewInstanceSaveAsDialog), - sizeof (GalViewInstanceSaveAsDialogClass), - (GtkClassInitFunc) gal_view_instance_save_as_dialog_class_init, - (GtkObjectInitFunc) gal_view_instance_save_as_dialog_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -void -gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog) -{ - GalView *view = gal_view_instance_get_current_view (dialog->instance); - GtkWidget *widget; - char *title; - int n; - const char *id = NULL; - switch (dialog->toggle) { - case GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE: - widget = glade_xml_get_widget(dialog->gui, "custom-replace"); - if (widget && E_IS_TABLE_SCROLLED (widget)) { - n = e_table_get_cursor_row (e_table_scrolled_get_table (E_TABLE_SCROLLED (widget))); - id = gal_view_collection_set_nth_view (dialog->instance->collection, n, view); - gal_view_collection_save (dialog->instance->collection); - } - break; - case GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE: - widget = glade_xml_get_widget(dialog->gui, "entry-create"); - if (widget && GTK_IS_ENTRY (widget)) { - title = gtk_entry_get_text (GTK_ENTRY (widget)); - id = gal_view_collection_append_with_title (dialog->instance->collection, title, view); - gal_view_collection_save (dialog->instance->collection); - } - break; - } - - if (id) { - gal_view_instance_set_current_view_id (dialog->instance, id); - } -} diff --git a/widgets/menus/gal-view-instance-save-as-dialog.glade b/widgets/menus/gal-view-instance-save-as-dialog.glade deleted file mode 100644 index bc5d99dd58..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.glade +++ /dev/null @@ -1,269 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>gal-view-instance-save-as-dialog</name> - <program_name>gal-view-instance-save-as-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>True</use_widget_names> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <gnome_help_support>True</gnome_help_support> -</project> - -<widget> - <class>GnomeDialog</class> - <name>dialog1</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>False</auto_close> - <hide_on_close>False</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button1</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> - - <widget> - <class>GtkTable</class> - <name>table-top</name> - <rows>5</rows> - <columns>1</columns> - <homogeneous>False</homogeneous> - <row_spacing>0</row_spacing> - <column_spacing>0</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkNotebook</class> - <name>notebook-help</name> - <show_tabs>False</show_tabs> - <show_border>False</show_border> - <tab_pos>GTK_POS_TOP</tab_pos> - <scrollable>False</scrollable> - <tab_hborder>2</tab_hborder> - <tab_vborder>2</tab_vborder> - <popup_enable>False</popup_enable> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>4</top_attach> - <bottom_attach>5</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label6</name> - <label>The current view will replace the given view. Any folders -set to this view wil be replaced with the current view.</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label4</name> - <label>label4</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label7</name> - <label>This will create a new View.</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - - <widget> - <class>GtkLabel</class> - <child_name>Notebook:tab</child_name> - <name>label5</name> - <label>label5</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - - <widget> - <class>Custom</class> - <name>custom-replace</name> - <creation_function>gal_view_instance_save_as_dialog_create_etable</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Fri, 01 Feb 2002 20:18:32 GMT</last_modification_time> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry-create</name> - <sensitive>False</sensitive> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>radiobutton-replace</name> - <can_focus>True</can_focus> - <label>Replace Existing View</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <group>choice-group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkRadioButton</class> - <name>radiobutton-create</name> - <can_focus>True</can_focus> - <label>Create New View Named</label> - <active>True</active> - <draw_indicator>True</draw_indicator> - <group>choice-group</group> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/widgets/menus/gal-view-instance-save-as-dialog.h b/widgets/menus/gal-view-instance-save-as-dialog.h deleted file mode 100644 index 567e00d7b0..0000000000 --- a/widgets/menus/gal-view-instance-save-as-dialog.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-define-views-dialog.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ -#define __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ - -#include <libgnomeui/gnome-dialog.h> -#include <glade/glade.h> -#include <gal/e-table/e-table-model.h> -#include <gal/menus/gal-view-collection.h> -#include <gal/menus/gal-view-instance.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* GalViewInstanceSaveAsDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE (gal_view_instance_save_as_dialog_get_type ()) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) (GTK_CHECK_CAST ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE, GalViewInstanceSaveAsDialog)) -#define GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE, GalViewInstanceSaveAsDialogClass)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE)) -#define GAL_IS_VIEW_INSTANCE_SAVE_AS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TYPE)) - -typedef struct _GalViewInstanceSaveAsDialog GalViewInstanceSaveAsDialog; -typedef struct _GalViewInstanceSaveAsDialogClass GalViewInstanceSaveAsDialogClass; - -typedef enum { - GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_REPLACE, - GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_TOGGLE_CREATE -} GalViewInstanceSaveAsDialogToggle; - -struct _GalViewInstanceSaveAsDialog -{ - GnomeDialog parent; - - /* item specific fields */ - GladeXML *gui; - ETableModel *model; - - GalViewInstance *instance; - GalViewCollection *collection; - - GalViewInstanceSaveAsDialogToggle toggle; -}; - -struct _GalViewInstanceSaveAsDialogClass -{ - GnomeDialogClass parent_class; -}; - -GtkWidget *gal_view_instance_save_as_dialog_new (GalViewInstance *instance); -GtkType gal_view_instance_save_as_dialog_get_type (void); - -void gal_view_instance_save_as_dialog_save (GalViewInstanceSaveAsDialog *dialog); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GAL_VIEW_INSTANCE_SAVE_AS_DIALOG_H__ */ diff --git a/widgets/menus/gal-view-instance.c b/widgets/menus/gal-view-instance.c deleted file mode 100644 index 1cc0389f47..0000000000 --- a/widgets/menus/gal-view-instance.c +++ /dev/null @@ -1,620 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-instance.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> - -#include <util/e-i18n.h> -#include <ctype.h> -#include <string.h> -#include <gtk/gtksignal.h> -#include <gnome-xml/parser.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-util.h> -#include <libgnomeui/gnome-dialog.h> -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> -#include <gal/widgets/e-unicode.h> -#include "gal-view-instance.h" -#include "gal-view-instance-save-as-dialog.h" -#include "gal-define-views-dialog.h" -#include <sys/stat.h> -#include <unistd.h> -#include <gtk/gtkcheckmenuitem.h> - -#define GVI_CLASS(e) ((GalViewInstanceClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gtk_object_get_type () - -static GtkObjectClass *gal_view_instance_parent_class; - -static const EPopupMenu separator = E_POPUP_SEPARATOR; -static const EPopupMenu terminator = E_POPUP_TERMINATOR; - - -#define d(x) x - -enum { - DISPLAY_VIEW, - CHANGED, - LAST_SIGNAL -}; - -static guint gal_view_instance_signals [LAST_SIGNAL] = { 0, }; - -static void -gal_view_instance_changed (GalViewInstance *instance) -{ - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - gtk_signal_emit (GTK_OBJECT (instance), - gal_view_instance_signals [CHANGED]); -} - -static void -gal_view_instance_display_view (GalViewInstance *instance, GalView *view) -{ - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - gtk_signal_emit (GTK_OBJECT (instance), - gal_view_instance_signals [DISPLAY_VIEW], - view); -} - -static void -save_current_view (GalViewInstance *instance) -{ - xmlDoc *doc; - xmlNode *root; - - doc = xmlNewDoc("1.0"); - root = xmlNewNode (NULL, "GalViewCurrentView"); - xmlDocSetRootElement(doc, root); - - if (instance->current_id) - e_xml_set_string_prop_by_name (root, "current_view", instance->current_id); - if (instance->current_type) - e_xml_set_string_prop_by_name (root, "current_view_type", instance->current_type); - - xmlSaveFile(instance->current_view_filename, doc); - xmlFreeDoc(doc); -} - -static void -view_changed (GalView *view, GalViewInstance *instance) -{ - if (instance->current_id != NULL) { - g_free (instance->current_id); - instance->current_id = NULL; - save_current_view (instance); - gal_view_instance_changed(instance); - } - - gal_view_save (view, instance->custom_filename); -} - -static void -disconnect_view (GalViewInstance *instance) -{ - if (instance->current_view) { - if (instance->view_changed_id) { - gtk_signal_disconnect (GTK_OBJECT (instance->current_view), - instance->view_changed_id); - } - - gtk_object_unref (GTK_OBJECT (instance->current_view)); - } - g_free (instance->current_type); - g_free (instance->current_title); - instance->current_title = NULL; - instance->current_type = NULL; - instance->view_changed_id = 0; - instance->current_view = NULL; -} - -static void -connect_view (GalViewInstance *instance, GalView *view) -{ - if (instance->current_view) - disconnect_view (instance); - instance->current_view = view; - - instance->current_title = g_strdup (gal_view_get_title(view)); - instance->current_type = g_strdup (gal_view_get_type_code(view)); - instance->view_changed_id = - gtk_signal_connect(GTK_OBJECT(instance->current_view), "changed", - GTK_SIGNAL_FUNC(view_changed), instance); - - gal_view_instance_display_view (instance, instance->current_view); -} - -static void -gal_view_instance_destroy (GtkObject *object) -{ - GalViewInstance *instance = GAL_VIEW_INSTANCE(object); - - if (instance->collection) { - if (instance->collection_changed_id) { - gtk_signal_disconnect (GTK_OBJECT (instance->collection), - instance->collection_changed_id); - } - gtk_object_unref (GTK_OBJECT (instance->collection)); - } - - g_free (instance->instance_id); - g_free (instance->custom_filename); - g_free (instance->current_view_filename); - - g_free (instance->current_id); - disconnect_view (instance); - - g_free (instance->default_view); - - if (gal_view_instance_parent_class->destroy) - (*gal_view_instance_parent_class->destroy)(object); -} - -static void -gal_view_instance_class_init (GtkObjectClass *object_class) -{ - GalViewInstanceClass *klass = GAL_VIEW_INSTANCE_CLASS(object_class); - gal_view_instance_parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = gal_view_instance_destroy; - - gal_view_instance_signals [DISPLAY_VIEW] = - gtk_signal_new ("display_view", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GalViewInstanceClass, display_view), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, GAL_VIEW_TYPE); - - gal_view_instance_signals [CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GalViewInstanceClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - E_OBJECT_CLASS_ADD_SIGNALS (object_class, gal_view_instance_signals, LAST_SIGNAL); - - klass->display_view = NULL; - klass->changed = NULL; -} - -static void -gal_view_instance_init (GalViewInstance *instance) -{ - instance->collection = NULL; - - instance->instance_id = NULL; - instance->custom_filename = NULL; - instance->current_view_filename = NULL; - - instance->current_title = NULL; - instance->current_type = NULL; - instance->current_id = NULL; - instance->current_view = NULL; - - instance->view_changed_id = 0; - instance->collection_changed_id = 0; - - instance->loaded = FALSE; - instance->default_view = NULL; -} - -/** - * gal_view_instance_get_type: - * - */ -guint -gal_view_instance_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalViewInstance", - sizeof (GalViewInstance), - sizeof (GalViewInstanceClass), - (GtkClassInitFunc) gal_view_instance_class_init, - (GtkObjectInitFunc) gal_view_instance_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -collection_changed (GalView *view, GalViewInstance *instance) -{ - if (instance->current_id) { - char *view_id = instance->current_id; - instance->current_id = NULL; - gal_view_instance_set_current_view_id (instance, view_id); - g_free (view_id); - } -} - -static void -load_current_view (GalViewInstance *instance) -{ - xmlDoc *doc; - xmlNode *root; - GalView *view = NULL; - - doc = xmlParseFile(instance->current_view_filename); - - if (doc == NULL) { - instance->current_id = g_strdup (gal_view_instance_get_default_view (instance)); - - if (instance->current_id) { - int index = gal_view_collection_get_view_index_by_id (instance->collection, - instance->current_id); - - if (index != -1) { - view = gal_view_collection_get_view (instance->collection, - index); - view = gal_view_clone(view); - connect_view (instance, view); - } - } - return; - } - - root = xmlDocGetRootElement(doc); - instance->current_id = e_xml_get_string_prop_by_name_with_default (root, "current_view", NULL); - - if (instance->current_id != NULL) { - int index = gal_view_collection_get_view_index_by_id (instance->collection, - instance->current_id); - - if (index != -1) { - view = gal_view_collection_get_view (instance->collection, - index); - view = gal_view_clone(view); - } - } - if (view == NULL) { - char *type; - type = e_xml_get_string_prop_by_name_with_default (root, "current_view_type", NULL); - view = gal_view_collection_load_view_from_file (instance->collection, - type, - instance->custom_filename); - g_free (type); - } - - connect_view (instance, view); - - xmlFreeDoc(doc); -} - -/** - * gal_view_instance_new: - * @collection: This %GalViewCollection should be loaded before being passed to this function. - * @instance_id: Which instance of this type of object is this (for most of evo, this is the folder id.) - * - * Create a new %GalViewInstance. - * - * Return value: The new %GalViewInstance. - **/ -GalViewInstance * -gal_view_instance_new (GalViewCollection *collection, const char *instance_id) -{ - GalViewInstance *instance = gtk_type_new(gal_view_instance_get_type()); - if (gal_view_instance_construct (instance, collection, instance_id)) - return instance; - else { - gtk_object_unref (GTK_OBJECT (instance)); - return NULL; - } -} - -GalViewInstance * -gal_view_instance_construct (GalViewInstance *instance, GalViewCollection *collection, const char *instance_id) -{ - char *filename; - char *safe_id; - - g_return_val_if_fail (gal_view_collection_loaded (collection), NULL); - - instance->collection = collection; - if (collection) - gtk_object_ref (GTK_OBJECT (collection)); - instance->collection_changed_id = - gtk_signal_connect (GTK_OBJECT (collection), "changed", - GTK_SIGNAL_FUNC (collection_changed), instance); - instance->instance_id = g_strdup (instance_id); - - safe_id = g_strdup (instance->instance_id); - e_filename_make_safe (safe_id); - - filename = g_strdup_printf ("custom_view-%s.xml", safe_id); - instance->custom_filename = g_concat_dir_and_file (instance->collection->local_dir, filename); - g_free (filename); - - filename = g_strdup_printf ("current_view-%s.xml", safe_id); - instance->current_view_filename = g_concat_dir_and_file (instance->collection->local_dir, filename); - g_free (filename); - - g_free (safe_id); - - return instance; -} - -/* Manipulate the current view. */ -char * -gal_view_instance_get_current_view_id (GalViewInstance *instance) -{ - if (instance->current_id && gal_view_collection_get_view_index_by_id (instance->collection, instance->current_id) != -1) - return g_strdup (instance->current_id); - else - return NULL; -} - -void -gal_view_instance_set_current_view_id (GalViewInstance *instance, const char *view_id) -{ - GalView *view; - int index; - - g_return_if_fail (instance != NULL); - g_return_if_fail (GAL_IS_VIEW_INSTANCE (instance)); - - d(g_print("%s: view_id set to %s\n", __FUNCTION__, view_id)); - - if (instance->current_id && !strcmp (instance->current_id, view_id)) - return; - - g_free (instance->current_id); - instance->current_id = g_strdup (view_id); - - index = gal_view_collection_get_view_index_by_id (instance->collection, view_id); - if (index != -1) { - view = gal_view_collection_get_view (instance->collection, index); - connect_view (instance, gal_view_clone (view)); - } - - save_current_view (instance); - gal_view_instance_changed(instance); - gal_view_instance_display_view (instance, instance->current_view); -} - -GalView * -gal_view_instance_get_current_view (GalViewInstance *instance) -{ - return instance->current_view; -} - -void -gal_view_instance_set_custom_view (GalViewInstance *instance, GalView *view) -{ - g_free (instance->current_id); - instance->current_id = NULL; - - view = gal_view_clone (view); - connect_view (instance, view); - gal_view_save (view, instance->custom_filename); - save_current_view (instance); - gal_view_instance_changed(instance); -} - -static void -dialog_clicked(GtkWidget *dialog, int button, GalViewInstance *instance) -{ - if (button == 0) { - gal_view_instance_save_as_dialog_save (GAL_VIEW_INSTANCE_SAVE_AS_DIALOG (dialog)); - } - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -void -gal_view_instance_save_as (GalViewInstance *instance) -{ - GtkWidget *dialog = gal_view_instance_save_as_dialog_new(instance); - gtk_signal_connect(GTK_OBJECT(dialog), "clicked", - GTK_SIGNAL_FUNC(dialog_clicked), instance); - gtk_widget_show(dialog); -} - -/* This is idempotent. Once it's been called once, the rest of the calls are ignored. */ -void -gal_view_instance_load (GalViewInstance *instance) -{ - if (!instance->loaded) { - load_current_view (instance); - instance->loaded = TRUE; - } -} - -/* These only mean anything before gal_view_instance_load is called the first time. */ -const char * -gal_view_instance_get_default_view (GalViewInstance *instance) -{ - if (instance->default_view) - return instance->default_view; - else - return gal_view_collection_get_default_view (instance->collection); -} - -void -gal_view_instance_set_default_view (GalViewInstance *instance, const char *id) -{ - g_free (instance->default_view); - instance->default_view = g_strdup (id); -} - -gboolean -gal_view_instance_exists (GalViewInstance *instance) -{ - struct stat st; - - if (instance->current_view_filename && stat (instance->current_view_filename, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) - return TRUE; - else - return FALSE; - -} - -typedef struct { - GalViewInstance *instance; - char *id; -} ListenerClosure; - -static void -view_item_cb (GtkWidget *widget, - gpointer user_data) -{ - ListenerClosure *closure = user_data; - - if (GTK_CHECK_MENU_ITEM (widget)->active) { - gal_view_instance_set_current_view_id (closure->instance, closure->id); - } -} - -static void -add_popup_radio_item (EPopupMenu *menu_item, - gchar *title, - void (*fn) (GtkWidget *widget, gpointer closure), - gpointer closure, - gboolean value) -{ - const EPopupMenu menu_item_struct = - E_POPUP_RADIO_ITEM_CC (title, - fn, - closure, - 0, - value); - - e_popup_menu_copy_1 (menu_item, &menu_item_struct); -} - -static void -add_popup_menu_item (EPopupMenu *menu_item, - gchar *title, - void (*fn) (GtkWidget *widget, gpointer closure), - gpointer closure) -{ - const EPopupMenu menu_item_struct = - E_POPUP_ITEM_CC (title, - fn, - closure, - 0); - - e_popup_menu_copy_1 (menu_item, &menu_item_struct); -} - -static void -define_views_dialog_clicked(GtkWidget *dialog, int button, GalViewInstance *instance) -{ - if (button == 0) { - gal_view_collection_save(instance->collection); - } - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static void -define_views_cb(GtkWidget *widget, - GalViewInstance *instance) -{ - GtkWidget *dialog = gal_define_views_dialog_new(instance->collection); - gtk_signal_connect(GTK_OBJECT(dialog), "clicked", - GTK_SIGNAL_FUNC(define_views_dialog_clicked), instance); - gtk_widget_show(dialog); -} - -static void -save_current_view_cb(GtkWidget *widget, - GalViewInstance *instance) -{ - gal_view_instance_save_as (instance); -} - -EPopupMenu * -gal_view_instance_get_popup_menu (GalViewInstance *instance) -{ - EPopupMenu *ret_val; - int length; - int i; - gboolean found = FALSE; - char *id; - - length = gal_view_collection_get_count(instance->collection); - id = gal_view_instance_get_current_view_id (instance); - - ret_val = g_new (EPopupMenu, length + 6); - - for (i = 0; i < length; i++) { - gboolean value = FALSE; - GalViewCollectionItem *item = gal_view_collection_get_view_item(instance->collection, i); - ListenerClosure *closure; - - closure = g_new (ListenerClosure, 1); - closure->instance = instance; - closure->id = item->id; - gtk_object_ref (GTK_OBJECT(closure->instance)); - - if (!found && id && !strcmp (id, item->id)) { - found = TRUE; - value = TRUE; - } - - add_popup_radio_item (ret_val + i, item->title, GTK_SIGNAL_FUNC (view_item_cb), closure, value); - } - - if (!found) { - e_popup_menu_copy_1 (ret_val + i++, &separator); - - add_popup_radio_item (ret_val + i++, N_("Custom View"), NULL, NULL, TRUE); - add_popup_menu_item (ret_val + i++, N_("Save Custom View"), GTK_SIGNAL_FUNC (save_current_view_cb), instance); - } - - e_popup_menu_copy_1 (ret_val + i++, &separator); - add_popup_menu_item (ret_val + i++, N_("Define Views"), GTK_SIGNAL_FUNC (define_views_cb), instance); - e_popup_menu_copy_1 (ret_val + i++, &terminator); - - return ret_val; -} - -void -gal_view_instance_free_popup_menu (GalViewInstance *instance, EPopupMenu *menu) -{ - int i; - /* This depends on the first non-custom closure to be a separator or a terminator. */ - for (i = 0; menu[i].name && *(menu[i].name); i++) { - gtk_object_unref (GTK_OBJECT ( ((ListenerClosure *)(menu[i].closure))->instance)); - g_free (menu[i].closure); - } - - e_popup_menu_free (menu); -} diff --git a/widgets/menus/gal-view-instance.h b/widgets/menus/gal-view-instance.h deleted file mode 100644 index 5e5ea6817e..0000000000 --- a/widgets/menus/gal-view-instance.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-instance.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_INSTANCE_H_ -#define _GAL_VIEW_INSTANCE_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-collection.h> -#include <gal/widgets/e-popup-menu.h> -#include <libgnome/gnome-defs.h> - -BEGIN_GNOME_DECLS - - -#define GAL_VIEW_INSTANCE_TYPE (gal_view_instance_get_type ()) -#define GAL_VIEW_INSTANCE(o) (GTK_CHECK_CAST ((o), GAL_VIEW_INSTANCE_TYPE, GalViewInstance)) -#define GAL_VIEW_INSTANCE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_INSTANCE_TYPE, GalViewInstanceClass)) -#define GAL_IS_VIEW_INSTANCE(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_INSTANCE_TYPE)) -#define GAL_IS_VIEW_INSTANCE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_INSTANCE_TYPE)) - -typedef struct { - GtkObject base; - - GalViewCollection *collection; - - char *instance_id; - char *current_view_filename; - char *custom_filename; - - char *current_title; - char *current_type; - char *current_id; - - GalView *current_view; - - guint view_changed_id; - guint collection_changed_id; - - guint loaded : 1; - char *default_view; -} GalViewInstance; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Signals - */ - void (*display_view) (GalViewInstance *instance, - GalView *view); - void (*changed) (GalViewInstance *instance); -} GalViewInstanceClass; - -/* Standard functions */ -GtkType gal_view_instance_get_type (void); - -/* */ -/*collection should be loaded when you call this. - instance_id: Which instance of this type of object is this (for most of evo, this is the folder id.) */ -GalViewInstance *gal_view_instance_new (GalViewCollection *collection, - const char *instance_id); -GalViewInstance *gal_view_instance_construct (GalViewInstance *instance, - GalViewCollection *collection, - const char *instance_id); - -/* Manipulate the current view. */ -char *gal_view_instance_get_current_view_id (GalViewInstance *instance); -void gal_view_instance_set_current_view_id (GalViewInstance *instance, - const char *view_id); -GalView *gal_view_instance_get_current_view (GalViewInstance *instance); - -/* Sets the current view to the given custom view. */ -void gal_view_instance_set_custom_view (GalViewInstance *instance, - GalView *view); - - -/* Returns true if this instance has ever been used before. */ -gboolean gal_view_instance_exists (GalViewInstance *instance); - -/* Manipulate the view collection */ -/* void gal_view_instance_set_as_default (GalViewInstance *instance); */ -void gal_view_instance_save_as (GalViewInstance *instance); - -/* This is idempotent. Once it's been called once, the rest of the calls are ignored. */ -void gal_view_instance_load (GalViewInstance *instance); - -/* These only mean anything before gal_view_instance_load is called the first time. */ -const char *gal_view_instance_get_default_view (GalViewInstance *instance); -void gal_view_instance_set_default_view (GalViewInstance *instance, - const char *id); - -EPopupMenu *gal_view_instance_get_popup_menu (GalViewInstance *instance); -void gal_view_instance_free_popup_menu (GalViewInstance *instance, - EPopupMenu *menu); - -END_GNOME_DECLS - - -#endif /* _GAL_VIEW_INSTANCE_H_ */ diff --git a/widgets/menus/gal-view-menus.c b/widgets/menus/gal-view-menus.c deleted file mode 100644 index 6c796dd6ee..0000000000 --- a/widgets/menus/gal-view-menus.c +++ /dev/null @@ -1,482 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-menus.c: Deploy a GalViewCollection in the menus. - * - * Author: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> - -#include "gal-view-menus.h" - -#include <stdlib.h> -#include <gtk/gtksignal.h> -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> -#include <libgnomeui/gnome-dialog.h> -#include <libgnome/gnome-i18n.h> -#include <bonobo/bonobo-ui-util.h> -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> -#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 { - GalViewInstance *instance; - int collection_changed_id; - 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) -#define CURRENT_VIEW_PATH "/menu/View/ViewBegin/CurrentView" - -static void -closure_free (void *data, void *user_data) -{ - ListenerClosure *closure = data; - GalViewMenus *gvm = user_data; - - closure->ref_count --; - if (closure->ref_count == 0) { - gtk_object_unref(GTK_OBJECT(closure->instance)); - - bonobo_ui_component_remove_listener (gvm->priv->component, closure->id); - g_free (closure); - } -} - -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 -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); - - remove_instance (gvm); - - gal_view_menus_unmerge (gvm, NULL); - - g_free(gvm->priv); - gvm->priv = NULL; - - GTK_OBJECT_CLASS (gvm_parent_class)->destroy (object); -} - -static void -gvm_class_init (GtkObjectClass *klass) -{ - gvm_parent_class = gtk_type_class (PARENT_TYPE); - - klass->destroy = gvm_destroy; -} - -static void -gvm_init (GalViewMenus *gvm) -{ - gvm->priv = g_new(GalViewMenusPrivate, 1); - gvm->priv->instance = NULL; - gvm->priv->collection_changed_id = 0; - 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 (GalViewInstance *instance) -{ - GalViewMenus *gvm; - - 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, instance); - - return gvm; -} - -GalViewMenus * -gal_view_menus_construct (GalViewMenus *gvm, - 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 (instance != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_INSTANCE (instance), NULL); - - add_instance (gvm, instance); - - return gvm; -} - -static void -dialog_clicked(GtkWidget *dialog, int button, GalViewMenus *menus) -{ - if (button == 0) { - gal_view_collection_save(menus->priv->instance->collection); - } - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static void -define_views(BonoboUIComponent *component, - GalViewMenus *menus, - char *cname) -{ - 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, *commands, *command; - char *xml; - xmlChar *string; - int length; - int i; - GalViewInstance *instance = menus->priv->instance; - GalViewCollection *collection = instance->collection; - char *id; - gboolean found = FALSE; - - 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"); - - place = bonobo_ui_node_new_child(submenu, "placeholder"); - bonobo_ui_node_set_attr(place, "name", "ViewBegin"); - - submenu = bonobo_ui_node_new_child(place, "submenu"); - 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; - 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); - - closure = g_new (ListenerClosure, 1); - closure->instance = instance; - closure->id = item->id; - closure->ref_count = 1; - - if (!found && id && !strcmp (item->id, id)) { - found = TRUE; - } - - 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 (!found) { - - menuitem = bonobo_ui_node_new_child(submenu, "separator"); - bonobo_ui_node_set_attr(menuitem, "name", "GalView:first_sep"); - bonobo_ui_node_set_attr(menuitem, "f", ""); - - - 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"); - } - - menuitem = bonobo_ui_node_new_child(submenu, "separator"); - bonobo_ui_node_set_attr(menuitem, "name", "GalView:second_sep"); - bonobo_ui_node_set_attr(menuitem, "f", ""); - - 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", ""); - - 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); - bonobo_ui_node_free_string(string); - - bonobo_ui_node_free(root); - - 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 -set_state (GalViewMenus *gvm, char *path, CORBA_Environment *ev) -{ - 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 void -set_radio (GalViewMenus *gvm, - CORBA_Environment *ev) -{ - char *id; - - id = gal_view_instance_get_current_view_id (gvm->priv->instance); - - if (id) { - set_state (gvm, id, ev); - } else { - set_state (gvm, "custom_view", ev); - } - g_free (id); -} - -static void -build_stuff (GalViewMenus *gvm, - CORBA_Environment *ev) -{ - char *xml; - - gal_view_menus_unmerge (gvm, ev); - - remove_listeners(gvm); - remove_xml(gvm); - xml = build_menus(gvm); - bonobo_ui_component_set_translate(gvm->priv->component, "/", xml, ev); - g_free(xml); - - bonobo_ui_component_add_verb_list_with_data(gvm->priv->component, verbs, gvm); - - set_radio (gvm, ev); -} - -void -gal_view_menus_apply (GalViewMenus *gvm, - BonoboUIComponent *component, - CORBA_Environment *opt_ev) -{ - if (gvm->priv == NULL) - return; - - 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)); - } - - gvm->priv->component = component; - - build_stuff (gvm, opt_ev); -} - -void -gal_view_menus_unmerge (GalViewMenus *gvm, - CORBA_Environment *opt_ev) -{ - d(g_print ("%s:\n", __FUNCTION__)); - if (bonobo_ui_component_path_exists (gvm->priv->component, CURRENT_VIEW_PATH, opt_ev)) { - d(g_print ("%s: Removing path\n", __FUNCTION__)); - bonobo_ui_component_rm (gvm->priv->component, CURRENT_VIEW_PATH, opt_ev); - } -} - -static void -collection_changed (GalViewCollection *collection, - GalViewMenus *gvm) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - build_stuff(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); - 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); -} diff --git a/widgets/menus/gal-view-menus.h b/widgets/menus/gal-view-menus.h deleted file mode 100644 index 208d49761c..0000000000 --- a/widgets/menus/gal-view-menus.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _GAL_VIEW_MENUS_H_ -#define _GAL_VIEW_MENUS_H_ - -#include <gtk/gtkobject.h> -#include <gnome-xml/tree.h> -#include <bonobo/bonobo-ui-component.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)) -#define GAL_VIEW_MENUS_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_MENUS_TYPE, GalViewMenusClass)) -#define GAL_IS_VIEW_MENUS(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_MENUS_TYPE)) -#define GAL_IS_VIEW_MENUS_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_MENUS_TYPE)) - -typedef struct _GalViewMenusPrivate GalViewMenusPrivate; - -typedef struct { - GtkObject base; - GalViewMenusPrivate *priv; -} GalViewMenus; - -typedef struct { - GtkObjectClass parent_class; -} GalViewMenusClass; - -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 *opt_ev); -void gal_view_menus_unmerge (GalViewMenus *gvm, - CORBA_Environment *opt_ev); -void gal_view_menus_set_instance (GalViewMenus *gvm, - GalViewInstance *instance); - -#endif /* _GAL_VIEW_MENUS_H_ */ diff --git a/widgets/menus/gal-view-new-dialog.c b/widgets/menus/gal-view-new-dialog.c deleted file mode 100644 index 41b4ea4c69..0000000000 --- a/widgets/menus/gal-view-new-dialog.c +++ /dev/null @@ -1,224 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-new-dialog.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include <libgnomeui/gnome-dialog.h> -#include <libgnomeui/gnome-stock.h> -#include "gal-view-new-dialog.h" -#include "gal-define-views-model.h" -#include <gal/widgets/e-unicode.h> -#include <gal/e-table/e-table-scrolled.h> - -static void gal_view_new_dialog_init (GalViewNewDialog *card); -static void gal_view_new_dialog_class_init (GalViewNewDialogClass *klass); -static void gal_view_new_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void gal_view_new_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void gal_view_new_dialog_destroy (GtkObject *object); - -static GnomeDialogClass *parent_class = NULL; -#define PARENT_TYPE gnome_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, - ARG_NAME, - ARG_FACTORY -}; - -GtkType -gal_view_new_dialog_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "GalViewNewDialog", - sizeof (GalViewNewDialog), - sizeof (GalViewNewDialogClass), - (GtkClassInitFunc) gal_view_new_dialog_class_init, - (GtkObjectInitFunc) gal_view_new_dialog_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -gal_view_new_dialog_class_init (GalViewNewDialogClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = gal_view_new_dialog_set_arg; - object_class->get_arg = gal_view_new_dialog_get_arg; - object_class->destroy = gal_view_new_dialog_destroy; - - gtk_object_add_arg_type ("GalViewNewDialog::name", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_NAME); - gtk_object_add_arg_type ("GalViewNewDialog::factory", GTK_TYPE_OBJECT, - GTK_ARG_READABLE, ARG_FACTORY); -} - -static void -gal_view_new_dialog_init (GalViewNewDialog *dialog) -{ - GladeXML *gui; - GtkWidget *widget; - - gui = glade_xml_new_with_domain (GAL_GLADEDIR "/gal-view-new-dialog.glade", NULL, PACKAGE); - dialog->gui = gui; - - widget = glade_xml_get_widget(gui, "table-top"); - if (!widget) { - return; - } - gtk_widget_ref(widget); - gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gnome_dialog_append_buttons(GNOME_DIALOG(dialog), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, FALSE); - - dialog->collection = NULL; - dialog->selected_factory = NULL; -} - -static void -gal_view_new_dialog_destroy (GtkObject *object) -{ - GalViewNewDialog *gal_view_new_dialog = GAL_VIEW_NEW_DIALOG(object); - - gtk_object_unref(GTK_OBJECT(gal_view_new_dialog->gui)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -GtkWidget* -gal_view_new_dialog_new (GalViewCollection *collection) -{ - GtkWidget *widget = - gal_view_new_dialog_construct(gtk_type_new (gal_view_new_dialog_get_type ()), - collection); - return widget; -} - - -static void -gal_view_new_dialog_select_row_callback(GtkCList *list, - gint row, - gint column, - GdkEventButton *event, - GalViewNewDialog *dialog) -{ - dialog->selected_factory = gtk_clist_get_row_data(list, - row); -} - -GtkWidget* -gal_view_new_dialog_construct (GalViewNewDialog *dialog, - GalViewCollection *collection) -{ - GtkWidget *list = glade_xml_get_widget(dialog->gui, - "clist-type-list"); - GList *iterator; - dialog->collection = collection; - - iterator = dialog->collection->factory_list; - - for ( ; iterator; iterator = g_list_next(iterator) ) { - GalViewFactory *factory = iterator->data; - char *text[1]; - int row; - - gtk_object_ref(GTK_OBJECT(factory)); - text[0] = (char *) gal_view_factory_get_title(factory); - row = gtk_clist_append(GTK_CLIST(list), text); - gtk_clist_set_row_data(GTK_CLIST(list), row, factory); - } - - gtk_signal_connect(GTK_OBJECT (list), - "select_row", - GTK_SIGNAL_FUNC(gal_view_new_dialog_select_row_callback), - dialog); - - return GTK_WIDGET(dialog); -} - -static void -gal_view_new_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GalViewNewDialog *dialog; - GtkWidget *entry; - - dialog = GAL_VIEW_NEW_DIALOG (o); - - switch (arg_id){ - case ARG_NAME: - entry = glade_xml_get_widget(dialog->gui, "entry-name"); - if (entry && GTK_IS_EDITABLE(entry)) { - e_utf8_gtk_editable_set_text(GTK_EDITABLE(entry), GTK_VALUE_STRING(*arg)); - } - break; - default: - return; - } -} - -static void -gal_view_new_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GalViewNewDialog *dialog; - GtkWidget *entry; - - dialog = GAL_VIEW_NEW_DIALOG (object); - - switch (arg_id) { - case ARG_NAME: - entry = glade_xml_get_widget(dialog->gui, "entry-name"); - if (entry && GTK_IS_EDITABLE(entry)) { - GTK_VALUE_STRING(*arg) = e_utf8_gtk_editable_get_text(GTK_EDITABLE(entry)); - } - break; - case ARG_FACTORY: - GTK_VALUE_OBJECT(*arg) = dialog->selected_factory ? GTK_OBJECT(dialog->selected_factory) : NULL; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} diff --git a/widgets/menus/gal-view-new-dialog.glade b/widgets/menus/gal-view-new-dialog.glade deleted file mode 100644 index 173fa6c3af..0000000000 --- a/widgets/menus/gal-view-new-dialog.glade +++ /dev/null @@ -1,220 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>gal-view-new-dialog</name> - <program_name>gal-view-new-dialog</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> - <use_widget_names>True</use_widget_names> - <output_main_file>False</output_main_file> - <output_support_files>False</output_support_files> - <output_build_files>False</output_build_files> - <gnome_help_support>True</gnome_help_support> -</project> - -<widget> - <class>GnomeDialog</class> - <name>dialog1</name> - <visible>False</visible> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <allow_shrink>False</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <auto_close>False</auto_close> - <hide_on_close>False</hide_on_close> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDialog:vbox</child_name> - <name>dialog-vbox1</name> - <homogeneous>False</homogeneous> - <spacing>8</spacing> - <child> - <padding>4</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>button1</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>button3</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> - </widget> - </widget> - - <widget> - <class>GtkTable</class> - <name>table-top</name> - <rows>4</rows> - <columns>1</columns> - <homogeneous>False</homogeneous> - <row_spacing>6</row_spacing> - <column_spacing>6</column_spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Name of new view:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <focus_target>entry-name</focus_target> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>entry-name</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>True</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - </widget> - - <widget> - <class>GtkLabel</class> - <name>label2</name> - <label>Type of view:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow1</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>True</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>True</yfill> - </child> - - <widget> - <class>GtkCList</class> - <name>clist-type-list</name> - <can_focus>True</can_focus> - <columns>1</columns> - <column_widths>80</column_widths> - <selection_mode>GTK_SELECTION_SINGLE</selection_mode> - <show_titles>False</show_titles> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>GtkLabel</class> - <child_name>CList:title</child_name> - <name>label5</name> - <label>label5</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - </widget> - </widget> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/widgets/menus/gal-view-new-dialog.h b/widgets/menus/gal-view-new-dialog.h deleted file mode 100644 index 623cb341d0..0000000000 --- a/widgets/menus/gal-view-new-dialog.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-new-dialog.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __GAL_VIEW_NEW_DIALOG_H__ -#define __GAL_VIEW_NEW_DIALOG_H__ - -#include <glade/glade.h> -#include <gal-view-collection.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* GalViewNewDialog - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define GAL_VIEW_NEW_DIALOG_TYPE (gal_view_new_dialog_get_type ()) -#define GAL_VIEW_NEW_DIALOG(obj) (GTK_CHECK_CAST ((obj), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialog)) -#define GAL_VIEW_NEW_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GAL_VIEW_NEW_DIALOG_TYPE, GalViewNewDialogClass)) -#define GAL_IS_VIEW_NEW_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) -#define GAL_IS_VIEW_NEW_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GAL_VIEW_NEW_DIALOG_TYPE)) - -typedef struct _GalViewNewDialog GalViewNewDialog; -typedef struct _GalViewNewDialogClass GalViewNewDialogClass; - -struct _GalViewNewDialog -{ - GnomeDialog parent; - - /* item specific fields */ - GladeXML *gui; - - GalViewCollection *collection; - GalViewFactory *selected_factory; -}; - -struct _GalViewNewDialogClass -{ - GnomeDialogClass parent_class; -}; - -GtkWidget *gal_view_new_dialog_new (GalViewCollection *collection); -GtkType gal_view_new_dialog_get_type (void); - -GtkWidget *gal_view_new_dialog_construct (GalViewNewDialog *dialog, - GalViewCollection *collection); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GAL_VIEW_NEW_DIALOG_H__ */ diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c deleted file mode 100644 index cfaf5dabaa..0000000000 --- a/widgets/menus/gal-view.c +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include "gal-view.h" -#include "gal/util/e-util.h" - -#define GV_CLASS(e) ((GalViewClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE gtk_object_get_type () - -#define d(x) - -d(static gint depth = 0;) - - -static GtkObjectClass *gal_view_parent_class; - -enum { - CHANGED, - LAST_SIGNAL -}; - -static guint gal_view_signals [LAST_SIGNAL] = { 0, }; - -/** - * gal_view_edit - * @view: The view to edit - */ -void -gal_view_edit (GalView *view) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - if (GV_CLASS (view)->edit) - GV_CLASS (view)->edit (view); -} - -/** - * gal_view_load - * @view: The view to load to - * @filename: The file to load from - */ -void -gal_view_load (GalView *view, - const char *filename) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - if (GV_CLASS (view)->load) - GV_CLASS (view)->load (view, filename); -} - -/** - * gal_view_save - * @view: The view to save - * @filename: The file to save to - */ -void -gal_view_save (GalView *view, - const char *filename) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - if (GV_CLASS (view)->save) - GV_CLASS (view)->save (view, filename); -} - -/** - * gal_view_get_title - * @view: The view to query. - * - * Returns: The title of the view. - */ -const char * -gal_view_get_title (GalView *view) -{ - g_return_val_if_fail (view != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - if (GV_CLASS (view)->get_title) - return GV_CLASS (view)->get_title (view); - else - return NULL; -} - -/** - * gal_view_set_title - * @view: The view to set. - * @title: The new title value. - */ -void -gal_view_set_title (GalView *view, - const char *title) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - if (GV_CLASS (view)->set_title) - GV_CLASS (view)->set_title (view, title); -} - -/** - * gal_view_get_type_code - * @view: The view to get. - * - * Returns: The type of the view. - */ -const char * -gal_view_get_type_code (GalView *view) -{ - g_return_val_if_fail (view != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - if (GV_CLASS (view)->get_type_code) - return GV_CLASS (view)->get_type_code (view); - else - return NULL; -} - -/** - * gal_view_clone - * @view: The view to clone. - * - * Returns: The clone. - */ -GalView * -gal_view_clone (GalView *view) -{ - g_return_val_if_fail (view != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW (view), NULL); - - if (GV_CLASS (view)->clone) - return GV_CLASS (view)->clone (view); - else - return NULL; -} - -/** - * gal_view_changed - * @view: The view that changed. - */ -void -gal_view_changed (GalView *view) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GAL_IS_VIEW (view)); - - gtk_signal_emit(GTK_OBJECT(view), - gal_view_signals [CHANGED]); -} - -static void -gal_view_class_init (GtkObjectClass *object_class) -{ - GalViewClass *klass = GAL_VIEW_CLASS(object_class); - gal_view_parent_class = gtk_type_class (PARENT_TYPE); - - klass->edit = NULL; - klass->load = NULL; - klass->save = NULL; - klass->get_title = NULL; - klass->clone = NULL; - - klass->changed = NULL; - - gal_view_signals [CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GalViewClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - E_OBJECT_CLASS_ADD_SIGNALS (object_class, gal_view_signals, LAST_SIGNAL); -} - -GtkType -gal_view_get_type (void) -{ - static guint type = 0; - - if (!type) - { - GtkTypeInfo info = - { - "GalView", - sizeof (GalView), - sizeof (GalViewClass), - (GtkClassInitFunc) gal_view_class_init, - NULL, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h deleted file mode 100644 index 3d617df25f..0000000000 --- a/widgets/menus/gal-view.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef _GAL_VIEW_H_ -#define _GAL_VIEW_H_ - -#include <gtk/gtkobject.h> -#include <gnome-xml/tree.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GAL_VIEW_TYPE (gal_view_get_type ()) -#define GAL_VIEW(o) (GTK_CHECK_CAST ((o), GAL_VIEW_TYPE, GalView)) -#define GAL_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_TYPE, GalViewClass)) -#define GAL_IS_VIEW(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_TYPE)) -#define GAL_IS_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_TYPE)) - -typedef struct { - GtkObject base; -} GalView; - -typedef struct { - GtkObjectClass parent_class; - - /* - * Virtual methods - */ - void (*edit) (GalView *view); - void (*load) (GalView *view, - const char *filename); - void (*save) (GalView *view, - const char *filename); - const char *(*get_title) (GalView *view); - void (*set_title) (GalView *view, - const char *title); - const char *(*get_type_code) (GalView *view); - GalView *(*clone) (GalView *view); - - /* Signals */ - void (*changed) (GalView *view); -} GalViewClass; - -/* Standard functions */ -GtkType gal_view_get_type (void); - -/* Open an editor dialog for this view. */ -void gal_view_edit (GalView *view); - -/* xml load and save functions */ -void gal_view_load (GalView *view, - const char *filename); -void gal_view_save (GalView *view, - const char *filename); - -/* Title functions */ -const char *gal_view_get_title (GalView *view); -void gal_view_set_title (GalView *view, - const char *title); - -/* View type. */ -const char *gal_view_get_type_code (GalView *view); - -/* Cloning the view */ -GalView *gal_view_clone (GalView *view); - -/* Changed signal */ -void gal_view_changed (GalView *view); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _GAL_VIEW_H_ */ |