diff options
author | Christopher James Lahey <clahey@ximian.com> | 2002-02-07 18:22:59 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2002-02-07 18:22:59 +0800 |
commit | 9f1ac34671b0446c8eb8855e0aca62d5b69840b0 (patch) | |
tree | ca6f4d720aa6642ddd43c348adb92cb1e5ba0327 /widgets/menus/gal-view-collection.c | |
parent | 6190f4f6879d8533bdb97a7baba33773a6d71d6c (diff) | |
download | gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.gz gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.bz2 gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.lz gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.xz gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.tar.zst gsoc2013-evolution-9f1ac34671b0446c8eb8855e0aca62d5b69840b0.zip |
Bumped the version number to 0.19.99.5.
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* configure.in: Bumped the version number to 0.19.99.5.
* gal/Makefile.am (libgal_la_LIBADD): Added
menus/gal-view-instance-save-as-dialog.lo.
* gal/e-text/e-text.c (next_word): Contains refactored code from
the E_TEP_FORWARD_WORD case of e_text_command.
(e_text_command): Implemented E_TEP_CAPS.
From gal/menus/ChangeLog:
2002-02-07 Christopher James Lahey <clahey@ximian.com>
* Makefile.am (glade_DATA): Added
gal-view-instance-save-as-dialog.glade.
(libgalmenus_la_SOURCES): Added
gal-view-instance-save-as-dialog.c.
(libgalmenusinclude_HEADERS): Added
gal-view-instance-save-as-dialog.h.
* gal-view-collection.c, gal-view-collection.h
(gal_view_collection_append_with_title): Added this new version of
the append function that sets the title and returns the new id as
well.
(gal_view_collection_set_nth_view): Added this function to save
over another view.
(gal_view_collection_get_default_view,
gal_view_collection_set_default_view): Added the concept of a
default view for GalViewCollections.
* gal-view-etable.c, gal-view-etable.h
(gal_view_etable_attach_table, gal_view_etable_attach_tree,
gal_view_etable_detach): Added functions to set the state of a
table or tree and then send GalView "changed" signals whenever
that state changes.
(gal_view_etable_set_state): New function to set the ETableState
of a GalViewETable.
* gal-view-instance-save-as-dialog.c,
gal-view-instance-save-as-dialog.glade,
gal-view-instance-save-as-dialog.h: New dialog to save the current
custom view as a named view.
* gal-view-instance.c, gal-view-instance.h
(gal_view_instance_set_custom_view): New function to set the state
of an instance to custom view and set the custom view to a
particular GalView.
(gal_view_instance_exists): New function to check if this
particular instance has ever been opened before. Use before
gal_view_instance_load.
(gal_view_instance_save_as): New function to open a save as
dialog.
(gal_view_instance_load): Added this function which used to be
part of _construct. This function can be called multiple times,
and those extra times will be ignored. This is so you can set a
default view before loading.
(gal_view_instance_get_default_view,
gal_view_instance_set_default_view): Set the default view for this
instance. If unset, this falls back to the default view for the
corresponding GalViewCollection.
svn path=/trunk/; revision=15590
Diffstat (limited to 'widgets/menus/gal-view-collection.c')
-rw-r--r-- | widgets/menus/gal-view-collection.c | 160 |
1 files changed, 140 insertions, 20 deletions
diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c index 89cd4deab7..9f56de9715 100644 --- a/widgets/menus/gal-view-collection.c +++ b/widgets/menus/gal-view-collection.c @@ -41,6 +41,8 @@ static GtkObjectClass *gal_view_collection_parent_class; +#define d(x) x + enum { DISPLAY_VIEW, CHANGED, @@ -83,8 +85,12 @@ static void gal_view_collection_item_free (GalViewCollectionItem *item) { g_free(item->id); - if (item->view) + 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); } @@ -163,6 +169,8 @@ gal_view_collection_destroy (GtkObject *object) 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); } @@ -200,17 +208,19 @@ gal_view_collection_class_init (GtkObjectClass *object_class) static void gal_view_collection_init (GalViewCollection *collection) { - collection->view_data = NULL; - collection->view_count = 0; - collection->factory_list = NULL; + collection->view_data = NULL; + collection->view_count = 0; + collection->factory_list = NULL; - collection->removed_view_data = NULL; - collection->removed_view_count = 0; + collection->removed_view_data = NULL; + collection->removed_view_count = 0; - collection->system_dir = NULL; - collection->local_dir = NULL; + collection->system_dir = NULL; + collection->local_dir = NULL; - collection->loaded = FALSE; + collection->loaded = FALSE; + collection->default_view = NULL; + collection->default_view_built_in = TRUE; } /** @@ -327,14 +337,11 @@ gal_view_collection_real_load_view_from_file (GalViewCollection *collection, con } } if (factory) { - char *fullpath; GalView *view; - fullpath = g_concat_dir_and_file(dir, filename); view = gal_view_factory_new_view (factory, title); gal_view_set_title (view, title); - gal_view_load(view, fullpath); - g_free(fullpath); + gal_view_load(view, filename); return view; } return NULL; @@ -362,12 +369,17 @@ load_single_file (GalViewCollection *collection, 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) { - item->view = gal_view_collection_real_load_view_from_file (collection, item->type, item->title, dir, 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) { - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); + item->view_changed_id = + gtk_signal_connect(GTK_OBJECT(item->view), "changed", + GTK_SIGNAL_FUNC(view_changed), item); } } return item; @@ -382,6 +394,7 @@ load_single_dir (GalViewCollection *collection, xmlNode *root; xmlNode *child; char *filename = g_concat_dir_and_file(dir, "galview.xml"); + char *default_view; doc = xmlParseFile(filename); if (!doc) { @@ -428,6 +441,16 @@ load_single_dir (GalViewCollection *collection, 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); } @@ -482,6 +505,10 @@ gal_view_collection_save (GalViewCollection *collection) 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; @@ -619,8 +646,9 @@ gal_view_collection_append (GalViewCollection *collection, item->collection = collection; gtk_object_ref(GTK_OBJECT(view)); - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); + 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; @@ -641,6 +669,7 @@ gal_view_collection_delete_view (GalViewCollection *collection, 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; @@ -679,8 +708,9 @@ gal_view_collection_copy_view (GalViewCollection *collection, item->view = gal_view_clone(view); item->collection = collection; - gtk_signal_connect(GTK_OBJECT(item->view), "changed", - GTK_SIGNAL_FUNC(view_changed), item); + 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; @@ -694,3 +724,93 @@ 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; +} |