diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2001-01-22 13:30:07 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-01-22 13:30:07 +0800 |
commit | 6adb44b607e483357a6784ce75c26f411be143b0 (patch) | |
tree | 34565ec4022a8934b2a40414bcf207bdeb524b4e | |
parent | f43c14605c19d0ee0c2119dd68eefc41f561748b (diff) | |
download | gsoc2013-evolution-6adb44b607e483357a6784ce75c26f411be143b0.tar.gz gsoc2013-evolution-6adb44b607e483357a6784ce75c26f411be143b0.tar.zst gsoc2013-evolution-6adb44b607e483357a6784ce75c26f411be143b0.zip |
Initialize collection field to NULL. Set the collection on the model as
2001-01-22 Christopher James Lahey <clahey@helixcode.com>
* gal-define-views-dialog.c, gal-define-views-dialog.h
(gal_define_views_dialog_init): Initialize collection field to
NULL. Set the collection on the model as soon as we create it.
(gal_define_views_dialog_new): Add a GalViewCollection argument to
this function. This just makes this dialog a bit easier to use
through the API.
(gal_define_views_dialog_set_arg): When we set the collection, set
it on the dialog->model.
* gal-define-views-model.c, gal-define-views-model.h: Rewrote this
object to use a GalViewCollection to store the information instead
of an array of GalViews.
* gal-view-collection.c, gal-view-collection.h: Added
gal_view_collection_get_count, gal_view_collection_get_view,
gal_view_collection_append, gal_view_collection_delete_view, and
gal_view_collection_copy_view.
(view_changed, load_single_file): Connect to the "changed" signal
on the views.
(load_single_dir): Survive loading if there's no xml file.
* gal-view-etable.c: Implemented get_type_code method.
* gal-view-factory-etable.c: Implemented get_type_code method.
* gal-view.c, gal-view.h: Added gal_view_get_type_code and
"changed" signal.
svn path=/trunk/; revision=7699
-rw-r--r-- | widgets/menus/gal-define-views-dialog.c | 15 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-dialog.h | 2 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-model.c | 73 | ||||
-rw-r--r-- | widgets/menus/gal-define-views-model.h | 6 | ||||
-rw-r--r-- | widgets/menus/gal-view-collection.c | 168 | ||||
-rw-r--r-- | widgets/menus/gal-view-collection.h | 11 | ||||
-rw-r--r-- | widgets/menus/gal-view-etable.c | 29 | ||||
-rw-r--r-- | widgets/menus/gal-view-factory-etable.c | 17 | ||||
-rw-r--r-- | widgets/menus/gal-view.c | 56 | ||||
-rw-r--r-- | widgets/menus/gal-view.h | 48 |
10 files changed, 343 insertions, 82 deletions
diff --git a/widgets/menus/gal-define-views-dialog.c b/widgets/menus/gal-define-views-dialog.c index b1e5d6aba6..2c45b25a57 100644 --- a/widgets/menus/gal-define-views-dialog.c +++ b/widgets/menus/gal-define-views-dialog.c @@ -216,6 +216,8 @@ gal_define_views_dialog_init (GalDefineViewsDialog *dialog) GtkWidget *widget; GtkWidget *etable; + dialog->collection = NULL; + gui = glade_xml_new (GAL_GLADEDIR "/gal-define-views.glade", NULL); dialog->gui = gui; @@ -242,6 +244,9 @@ gal_define_views_dialog_init (GalDefineViewsDialog *dialog) 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); @@ -262,9 +267,12 @@ gal_define_views_dialog_destroy (GtkObject *object) { * Returns: The GalDefineViewsDialog. */ GtkWidget* -gal_define_views_dialog_new (void) +gal_define_views_dialog_new (GalViewCollection *collection) { GtkWidget *widget = GTK_WIDGET (gtk_type_new (gal_define_views_dialog_get_type ())); + gtk_object_set(GTK_OBJECT(widget), + "collection", collection, + NULL); return widget; } @@ -281,6 +289,11 @@ gal_define_views_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) dialog->collection = GAL_VIEW_COLLECTION(GTK_VALUE_OBJECT(*arg)); else dialog->collection = NULL; + if (dialog->model) { + gtk_object_set(GTK_OBJECT(dialog->model), + "collection", GTK_VALUE_OBJECT(*arg), + NULL); + } break; default: diff --git a/widgets/menus/gal-define-views-dialog.h b/widgets/menus/gal-define-views-dialog.h index b4ac80c492..e5ebd8feb3 100644 --- a/widgets/menus/gal-define-views-dialog.h +++ b/widgets/menus/gal-define-views-dialog.h @@ -64,7 +64,7 @@ struct _GalDefineViewsDialogClass GnomeDialogClass parent_class; }; -GtkWidget *gal_define_views_dialog_new (void); +GtkWidget *gal_define_views_dialog_new (GalViewCollection *collection); GtkType gal_define_views_dialog_get_type (void); #ifdef __cplusplus diff --git a/widgets/menus/gal-define-views-model.c b/widgets/menus/gal-define-views-model.c index ca365d662b..367ec65dc7 100644 --- a/widgets/menus/gal-define-views-model.c +++ b/widgets/menus/gal-define-views-model.c @@ -28,18 +28,15 @@ static void gal_define_views_model_get_arg (GtkObject *object, GtkArg *arg, guin enum { ARG_0, ARG_EDITABLE, + ARG_COLLECTION }; static void gdvm_destroy(GtkObject *object) { GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); - int i; - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); + gtk_object_unref(GTK_OBJECT(model->collection)); } /* This function returns the number of columns in our ETableModel. */ @@ -54,7 +51,10 @@ static int gdvm_row_count (ETableModel *etc) { GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); - return views->data_count; + 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. */ @@ -63,10 +63,8 @@ gdvm_value_at (ETableModel *etc, int col, int row) { GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); const char *value; - if (col != 0 || row < 0 || row > views->data_count) - return NULL; - value = gal_view_get_title (views->data[row]); + value = gal_view_get_title (gal_view_collection_get_view(views->collection, row)); return (void *)(value ? value : ""); } @@ -77,9 +75,7 @@ gdvm_set_value_at (ETableModel *etc, int col, int row, const void *val) { GalDefineViewsModel *views = GAL_DEFINE_VIEWS_MODEL(etc); if (views->editable) { - if (col != 0 || row < 0 || row > views->data_count) - return; - gal_view_set_title(views->data[row], val); + gal_view_set_title(gal_view_collection_get_view(views->collection, row), val); e_table_model_cell_changed(etc, col, row); } } @@ -142,11 +138,8 @@ gal_define_views_model_append (GalDefineViewsModel *model, ETableModel *etm = E_TABLE_MODEL(model); e_table_model_pre_change(etm); - model->data = g_renew(GalView *, model->data, model->data_count + 1); - model->data[model->data_count] = view; - model->data_count++; - gtk_object_ref(GTK_OBJECT(view)); - e_table_model_row_inserted(etm, model->data_count - 1); + gal_view_collection_append(model->collection, view); + e_table_model_row_inserted(etm, gal_view_collection_get_count(model->collection) - 1); } static void @@ -162,6 +155,8 @@ gal_define_views_model_class_init (GtkObjectClass *object_class) gtk_object_add_arg_type ("GalDefineViewsModel::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); + gtk_object_add_arg_type ("GalDefineViewsModel::collection", GTK_TYPE_OBJECT, + GTK_ARG_READWRITE, ARG_COLLECTION); model_class->column_count = gdvm_col_count; model_class->row_count = gdvm_row_count; @@ -181,9 +176,7 @@ gal_define_views_model_init (GtkObject *object) { GalDefineViewsModel *model = GAL_DEFINE_VIEWS_MODEL(object); - model->data = NULL; - model->data_count = 0; - model->editable = TRUE; + model->collection = NULL; } static void @@ -197,20 +190,36 @@ gal_define_views_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_EDITABLE: model->editable = GTK_VALUE_BOOL (*arg); break; + + case ARG_COLLECTION: + 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 *gal_define_views_model; + GalDefineViewsModel *model; - gal_define_views_model = GAL_DEFINE_VIEWS_MODEL (object); + model = GAL_DEFINE_VIEWS_MODEL (object); switch (arg_id) { case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = gal_define_views_model->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; @@ -271,7 +280,7 @@ GalView * gal_define_views_model_get_view (GalDefineViewsModel *model, int n) { - return model->data[n]; + return gal_view_collection_get_view(model->collection, n); } /** @@ -286,10 +295,7 @@ gal_define_views_model_delete_view (GalDefineViewsModel *model, int n) { e_table_model_pre_change(E_TABLE_MODEL(model)); - gtk_object_unref(GTK_OBJECT(model->data[n])); - model->data_count --; - memmove(model->data + n, model->data + n + 1, (model->data_count - n) * sizeof(*model->data)); - model->data = g_renew(GalView *, model->data, model->data_count); + gal_view_collection_delete_view(model->collection, n); e_table_model_row_deleted(E_TABLE_MODEL(model), n); } @@ -305,13 +311,6 @@ gal_define_views_model_copy_view (GalDefineViewsModel *model, int n) { ETableModel *etm = E_TABLE_MODEL(model); - GalView *view; - - view = gal_view_clone (model->data[n]); - - e_table_model_pre_change(etm); - model->data = g_renew(GalView *, model->data, model->data_count + 1); - model->data[model->data_count] = view; - model->data_count++; - e_table_model_row_inserted(etm, model->data_count - 1); + 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 index 4f1115d66a..ff05c497af 100644 --- a/widgets/menus/gal-define-views-model.h +++ b/widgets/menus/gal-define-views-model.h @@ -3,7 +3,8 @@ #define _GAL_DEFINE_VIEWS_MODEL_H_ #include <gal/e-table/e-table-model.h> -#include "gal-view.h" +#include <gal/menus/gal-view.h> +#include <gal/menus/gal-view-collection.h> #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)) @@ -22,8 +23,7 @@ typedef struct { ETableModel parent; /* item specific fields */ - GalView **data; - int data_count; + GalViewCollection *collection; guint editable : 1; } GalDefineViewsModel; diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c index 1ac4215f93..03882ed484 100644 --- a/widgets/menus/gal-view-collection.c +++ b/widgets/menus/gal-view-collection.c @@ -13,6 +13,7 @@ #include <gal/util/e-xml-utils.h> #include <gnome-xml/parser.h> #include "gal-view-collection.h" +#include <ctype.h> #define GVC_CLASS(e) ((GalViewCollectionClass *)((GtkObject *)e)->klass) @@ -201,6 +202,13 @@ gal_view_collection_add_factory (GalViewCollection *collection, collection->factory_list = g_list_prepend(collection->factory_list, factory); } +static void +view_changed (GalView *view, + GalViewCollectionItem *item) +{ + item->changed = TRUE; +} + static GalViewCollectionItem * load_single_file (GalViewCollection *collection, gchar *dir, @@ -235,6 +243,9 @@ load_single_file (GalViewCollection *collection, if (factory) { item->view = gal_view_factory_new_view (factory, item->filename); gal_view_load(item->view, item->filename); + gal_view_set_title (item->view, item->title); + gtk_signal_connect(GTK_OBJECT(item->view), "changed", + GTK_SIGNAL_FUNC(view_changed), item); } } return item; @@ -251,6 +262,8 @@ load_single_dir (GalViewCollection *collection, char *filename = g_concat_dir_and_file(dir, "galview.xml"); doc = xmlParseFile(filename); + if (!doc) + return; root = xmlDocGetRootElement(doc); for (child = root->xmlChildrenNode; child; child = child->next) { gchar *id = e_xml_get_string_prop_by_name(child, "id"); @@ -258,11 +271,12 @@ load_single_dir (GalViewCollection *collection, int i; for (i = 0; i < collection->view_count; i++) { - if (!strcmp(id, collection->view_data[i]->id)) + if (!strcmp(id, collection->view_data[i]->id)) { if (!local) collection->view_data[i]->built_in = TRUE; - found = TRUE; - break; + found = TRUE; + break; + } } if (!found) { for (i = 0; i < collection->removed_view_count; i++) { @@ -350,3 +364,151 @@ gal_view_collection_save (GalViewCollection *collection) 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) +{ + return collection->view_count; +} + +/** + * gal_view_collection_get_view + * @collection: The view collection to query + * @n: The view to get. + * + * Calculates the number of views in the given collection. + * + * Returns: The nth view in the collection + */ +GalView * +gal_view_collection_get_view (GalViewCollection *collection, + int n) +{ + g_return_val_if_fail(n < collection->view_count, NULL); + g_return_val_if_fail(n >= 0, NULL); + + return collection->view_data[n]->view; +} + +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; + + for (i = 0; i < collection->view_count; i++) { + if (!strcmp(string, collection->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); + } +} + +void +gal_view_collection_append (GalViewCollection *collection, + GalView *view) +{ + GalViewCollectionItem *item; + 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; + gtk_object_ref(GTK_OBJECT(view)); + + 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 ++; +} + +void +gal_view_collection_delete_view (GalViewCollection *collection, + int i) +{ + GalViewCollectionItem *item = collection->view_data[i]; + memmove(collection->view_data + i, collection->view_data + i + 1, (collection->view_count - i - 1) * sizeof(GalViewCollectionItem *)); + 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); + } +} + +void +gal_view_collection_copy_view (GalViewCollection *collection, + int i) +{ + GalViewCollectionItem *item; + GalView *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); + + 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 ++; +} diff --git a/widgets/menus/gal-view-collection.h b/widgets/menus/gal-view-collection.h index 0de5f9ff71..d93c9a12a5 100644 --- a/widgets/menus/gal-view-collection.h +++ b/widgets/menus/gal-view-collection.h @@ -52,9 +52,20 @@ void gal_view_collection_add_factory (GalViewCollecti void gal_view_collection_display_view (GalViewCollection *collection, GalView *view); +gint gal_view_collection_get_count (GalViewCollection *collection); +GalView *gal_view_collection_get_view (GalViewCollection *collection, + int n); + +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); + #endif /* _GAL_VIEW_COLLECTION_H_ */ diff --git a/widgets/menus/gal-view-etable.c b/widgets/menus/gal-view-etable.c index c25f3a62a8..220bf9ad24 100644 --- a/widgets/menus/gal-view-etable.c +++ b/widgets/menus/gal-view-etable.c @@ -52,6 +52,12 @@ gal_view_etable_set_title (GalView *view, 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) { @@ -83,17 +89,18 @@ gal_view_etable_destroy (GtkObject *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->clone = gal_view_etable_clone ; - - object_class->destroy = gal_view_etable_destroy ; + 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 diff --git a/widgets/menus/gal-view-factory-etable.c b/widgets/menus/gal-view-factory-etable.c index 0a013c71e6..80f5d39f92 100644 --- a/widgets/menus/gal-view-factory-etable.c +++ b/widgets/menus/gal-view-factory-etable.c @@ -32,6 +32,12 @@ gal_view_factory_etable_new_view (GalViewFactory *factory, 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) { @@ -45,12 +51,13 @@ 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; + 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; + object_class->destroy = gal_view_factory_etable_destroy; } static void diff --git a/widgets/menus/gal-view.c b/widgets/menus/gal-view.c index 484e1d5116..f48a6f0026 100644 --- a/widgets/menus/gal-view.c +++ b/widgets/menus/gal-view.c @@ -8,6 +8,7 @@ * (C) 2000 Helix Code, Inc. */ #include <config.h> +#include <gtk/gtksignal.h> #include "gal-view.h" #define GV_CLASS(e) ((GalViewClass *)((GtkObject *)e)->klass) @@ -21,6 +22,13 @@ 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 @@ -102,6 +110,24 @@ gal_view_set_title (GalView *view, } /** + * 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. * @@ -119,6 +145,20 @@ gal_view_clone (GalView *view) 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) { @@ -126,10 +166,22 @@ gal_view_class_init (GtkObjectClass *object_class) gal_view_parent_class = gtk_type_class (PARENT_TYPE); klass->edit = NULL; - klass->load = NULL; - klass->save = 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, + object_class->type, + GTK_SIGNAL_OFFSET (GalViewClass, changed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (object_class, gal_view_signals, LAST_SIGNAL); } GtkType diff --git a/widgets/menus/gal-view.h b/widgets/menus/gal-view.h index 70a410bd61..6302df2057 100644 --- a/widgets/menus/gal-view.h +++ b/widgets/menus/gal-view.h @@ -21,36 +21,46 @@ typedef struct { /* * 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); - GalView *(*clone) (GalView *view); + 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); +GtkType gal_view_get_type (void); /* Open an editor dialog for this view. */ -void gal_view_edit (GalView *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); +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); +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); +GalView *gal_view_clone (GalView *view); + +/* Changed signal */ +void gal_view_changed (GalView *view); #endif /* _GAL_VIEW_H_ */ |