aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/gal-view-minicard.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-02-13 21:19:36 +0800
committerChris Lahey <clahey@src.gnome.org>2002-02-13 21:19:36 +0800
commit0227e26f802bf0d7d019b2197f774867fb43ff70 (patch)
tree372826b995ff40863e929380705fc1020b517ad2 /addressbook/gui/widgets/gal-view-minicard.c
parent606e024e4346d7d3851d6449cddcca514ad88046 (diff)
downloadgsoc2013-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/widgets/gal-view-minicard.c')
-rw-r--r--addressbook/gui/widgets/gal-view-minicard.c87
1 files changed, 77 insertions, 10 deletions
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;
+}