diff options
author | Christopher James Lahey <clahey@ximian.com> | 2002-02-13 21:19:36 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2002-02-13 21:19:36 +0800 |
commit | 0227e26f802bf0d7d019b2197f774867fb43ff70 (patch) | |
tree | 372826b995ff40863e929380705fc1020b517ad2 /addressbook/gui | |
parent | 606e024e4346d7d3851d6449cddcca514ad88046 (diff) | |
download | gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar.gz gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar.bz2 gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar.lz gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar.xz gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.tar.zst gsoc2013-evolution-0227e26f802bf0d7d019b2197f774867fb43ff70.zip |
Attach the GalViewMinicard to the EMinicardView here.
2002-02-13 Christopher James Lahey <clahey@ximian.com>
* gui/widgets/e-addressbook-view.c (display_view): Attach the
GalViewMinicard to the EMinicardView here.
* gui/widgets/gal-view-minicard.c, gui/widgets/gal-view-minicard.h
(gal_view_minicard_load, gal_view_minicard_save): Made these save
the column width of the view.
(gal_view_minicard_attach, gal_view_minicard_detach): Added these
functions to allow the GalViewMinicard to set the column width of
a EMinicardView and to monitor its changes.
svn path=/trunk/; revision=15707
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 1 | ||||
-rw-r--r-- | addressbook/gui/widgets/gal-view-minicard.c | 87 | ||||
-rw-r--r-- | addressbook/gui/widgets/gal-view-minicard.h | 18 |
3 files changed, 91 insertions, 15 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index a7e81d7c5b..1ed12066cc 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -468,6 +468,7 @@ display_view(GalViewInstance *instance, gal_view_etable_attach_table (GAL_VIEW_ETABLE(view), e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget))); } else if (GAL_IS_VIEW_MINICARD(view)) { change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD); + gal_view_minicard_attach (GAL_VIEW_MINICARD(view), E_MINICARD_VIEW (E_MINICARD_VIEW_WIDGET (address_view->object)->emv)); } address_view->current_view = view; } diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c index 4cfa71f470..e4ebff2019 100644 --- a/addressbook/gui/widgets/gal-view-minicard.c +++ b/addressbook/gui/widgets/gal-view-minicard.c @@ -9,8 +9,11 @@ */ #include <config.h> #include "gal-view-minicard.h" +#include <gnome-xml/parser.h> +#include <gal/util/e-xml-utils.h> #define PARENT_TYPE gal_view_get_type () +#define d(x) x static GalViewClass *gal_view_minicard_parent_class; @@ -21,15 +24,31 @@ gal_view_minicard_edit (GalView *view) } static void -gal_view_minicard_load (GalView *view, - const char *filename) +gal_view_minicard_load (GalView *view, + const char *filename) { + xmlDoc *doc; + doc = xmlParseFile (filename); + if (doc) { + xmlNode *root = xmlDocGetRootElement(doc); + GAL_VIEW_MINICARD (view)->column_width = e_xml_get_double_prop_by_name_with_default (root, "column_width", 150); + xmlFreeDoc(doc); + } } static void -gal_view_minicard_save (GalView *view, - const char *filename) +gal_view_minicard_save (GalView *view, + const char *filename) { + xmlDoc *doc; + xmlNode *root; + + doc = xmlNewDoc("1.0"); + root = xmlNewNode (NULL, "EMinicardViewState"); + e_xml_set_double_prop_by_name (root, "column_width", GAL_VIEW_MINICARD (view)->column_width); + xmlDocSetRootElement(doc, root); + xmlSaveFile(filename, doc); + xmlFreeDoc(doc); } static const char * @@ -55,12 +74,13 @@ gal_view_minicard_get_type_code (GalView *view) static GalView * gal_view_minicard_clone (GalView *view) { - GalViewMinicard *gve, *new; + GalViewMinicard *gvm, *new; - gve = GAL_VIEW_MINICARD(view); + gvm = GAL_VIEW_MINICARD(view); - new = gtk_type_new (gal_view_minicard_get_type ()); - new->title = g_strdup (gve->title); + new = gtk_type_new (gal_view_minicard_get_type ()); + new->title = g_strdup (gvm->title); + new->column_width = gvm->column_width; return GAL_VIEW(new); } @@ -69,6 +89,7 @@ static void gal_view_minicard_destroy (GtkObject *object) { GalViewMinicard *view = GAL_VIEW_MINICARD(object); + gal_view_minicard_detach (view); g_free(view->title); } @@ -90,9 +111,13 @@ gal_view_minicard_class_init (GtkObjectClass *object_class) } static void -gal_view_minicard_init (GalViewMinicard *gve) +gal_view_minicard_init (GalViewMinicard *gvm) { - gve->title = NULL; + gvm->title = NULL; + gvm->column_width = 150.0; + + gvm->emv = NULL; + gvm->emv_column_width_changed_id = 0; } /** @@ -152,3 +177,45 @@ gal_view_minicard_get_type (void) return type; } + +static void +column_width_changed (ETable *table, double width, GalViewMinicard *view) +{ + d(g_print("%s: Old width = %f, New width = %f\n", __FUNCTION__, view->column_width, width)); + if (view->column_width != width) { + view->column_width = width; + gal_view_changed(GAL_VIEW(view)); + } +} + +void +gal_view_minicard_attach (GalViewMinicard *view, EMinicardView *emv) +{ + gal_view_minicard_detach (view); + + view->emv = emv; + + gtk_object_ref (GTK_OBJECT (view->emv)); + + gtk_object_set (GTK_OBJECT (view->emv), + "column_width", (int) view->column_width, + NULL); + + view->emv_column_width_changed_id = + gtk_signal_connect(GTK_OBJECT(view->emv), "column_width_changed", + GTK_SIGNAL_FUNC (column_width_changed), view); +} + +void +gal_view_minicard_detach (GalViewMinicard *view) +{ + if (view->emv == NULL) + return; + if (view->emv_column_width_changed_id) { + gtk_signal_disconnect (GTK_OBJECT (view->emv), + view->emv_column_width_changed_id); + view->emv_column_width_changed_id = 0; + } + gtk_object_unref (GTK_OBJECT (view->emv)); + view->emv = NULL; +} diff --git a/addressbook/gui/widgets/gal-view-minicard.h b/addressbook/gui/widgets/gal-view-minicard.h index fef98141f3..1228a4af8c 100644 --- a/addressbook/gui/widgets/gal-view-minicard.h +++ b/addressbook/gui/widgets/gal-view-minicard.h @@ -12,6 +12,7 @@ #include <gtk/gtkobject.h> #include <gal/menus/gal-view.h> +#include <e-minicard-view.h> #define GAL_VIEW_MINICARD_TYPE (gal_view_minicard_get_type ()) #define GAL_VIEW_MINICARD(o) (GTK_CHECK_CAST ((o), GAL_VIEW_MINICARD_TYPE, GalViewMinicard)) @@ -20,9 +21,13 @@ #define GAL_IS_VIEW_MINICARD_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_MINICARD_TYPE)) typedef struct { - GalView base; + GalView base; - char *title; + char *title; + double column_width; + + EMinicardView *emv; + guint emv_column_width_changed_id; } GalViewMinicard; typedef struct { @@ -31,8 +36,11 @@ typedef struct { /* Standard functions */ GtkType gal_view_minicard_get_type (void); -GalView *gal_view_minicard_new (const gchar *title); -GalView *gal_view_minicard_construct (GalViewMinicard *view, - const gchar *title); +GalView *gal_view_minicard_new (const gchar *title); +GalView *gal_view_minicard_construct (GalViewMinicard *view, + const gchar *title); +void gal_view_minicard_attach (GalViewMinicard *view, + EMinicardView *emv); +void gal_view_minicard_detach (GalViewMinicard *view); #endif /* _GAL_VIEW_MINICARD_H_ */ |