aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-01-17 00:29:21 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-01-17 00:29:21 +0800
commit9b9570bd65b6ff0b6015380beec2a40a4c486156 (patch)
treead9a9ac8801b54aae1517998b798c7d05f3c71e9 /calendar
parent3889b52931d894b52a0a734306b91ea60f693fb4 (diff)
downloadgsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar.gz
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar.bz2
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar.lz
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar.xz
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.tar.zst
gsoc2013-evolution-9b9570bd65b6ff0b6015380beec2a40a4c486156.zip
convert to GObject
2004-01-16 JP Rosevear <jpr@ximian.com> * gui/e-comp-editor-registry.h: convert to GObject * gui/e-comp-editor-registry.c (registry_data_free): routine to free the registry data (dispose): destroy the registry data (finalize): finalize it (class_init): setup above (init): create full hash table (e_comp_editor_registry_add): weak ref the editor and strdup the hash table key (editor_destroy_cb): we get the registry data now, just remove it * gui/dialogs/comp-editor.c (close_dialog): disconnect the signal handlers, its a bit of a hack but it is a simple fix svn path=/trunk/; revision=24277
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/dialogs/comp-editor.c7
-rw-r--r--calendar/gui/e-comp-editor-registry.c90
-rw-r--r--calendar/gui/e-comp-editor-registry.h29
3 files changed, 69 insertions, 57 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 805cf550a4..d204de56e8 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -522,6 +522,13 @@ close_dialog (CompEditor *editor)
priv = editor->priv;
+ /* FIXME Unfortunately we do this here because otherwise corba
+ calls happen during destruction and we might get a change
+ notification back when we are in an inconsistent state */
+ if (priv->view)
+ g_signal_handlers_disconnect_matched (G_OBJECT (priv->view),
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor);
+
gtk_widget_destroy (GTK_WIDGET (editor));
}
diff --git a/calendar/gui/e-comp-editor-registry.c b/calendar/gui/e-comp-editor-registry.c
index 9e2a63bd48..c576ea7465 100644
--- a/calendar/gui/e-comp-editor-registry.c
+++ b/calendar/gui/e-comp-editor-registry.c
@@ -34,6 +34,7 @@ struct _ECompEditorRegistryPrivate {
struct _ECompEditorRegistryData
{
+ ECompEditorRegistry *registry;
CompEditor *editor;
char *uid;
};
@@ -41,42 +42,63 @@ struct _ECompEditorRegistryData
typedef struct _ECompEditorRegistryData ECompEditorRegistryData;
typedef struct _ECompEditorRegistryForeachData ECompEditorRegistryForeachData;
-static GtkObjectClass *parent_class = NULL;
+static GObjectClass *parent_class = NULL;
-static void editor_destroy_cb (GtkWidget *widget, gpointer data);
+static void editor_destroy_cb (gpointer data, GObject *where_object_was);
static void
-destroy (GtkObject *obj)
+registry_data_free (gpointer data)
+{
+ ECompEditorRegistryData *rdata = data;
+
+ if (rdata->editor)
+ g_object_weak_unref (G_OBJECT (rdata->editor), editor_destroy_cb, rdata);
+ g_free (rdata->uid);
+ g_free (rdata);
+}
+
+static void
+dispose (GObject *obj)
{
ECompEditorRegistry *reg;
ECompEditorRegistryPrivate *priv;
reg = E_COMP_EDITOR_REGISTRY (obj);
priv = reg->priv;
+
+ if (priv->editors) {
+ g_hash_table_destroy (priv->editors);
+ priv->editors = NULL;
+ }
- if (priv) {
- if (priv->editors) {
- g_hash_table_destroy (priv->editors);
- priv->editors = NULL;
- }
+ (* G_OBJECT_CLASS (parent_class)->dispose) (obj);
+}
- g_free (priv);
- reg->priv = NULL;
- }
+static void
+finalize (GObject *obj)
+{
+ ECompEditorRegistry *reg;
+ ECompEditorRegistryPrivate *priv;
+
+ reg = E_COMP_EDITOR_REGISTRY (obj);
+ priv = reg->priv;
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (obj);
+ g_free (priv);
+
+ (* G_OBJECT_CLASS (parent_class)->finalize) (obj);
}
static void
class_init (ECompEditorRegistryClass *klass)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = GTK_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- object_class->destroy = destroy;
+ object_class->dispose = dispose;
+ object_class->finalize = finalize;
}
static void
@@ -87,16 +109,15 @@ init (ECompEditorRegistry *reg)
priv = g_new0 (ECompEditorRegistryPrivate, 1);
reg->priv = priv;
-
- priv->editors = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->editors = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, registry_data_free);
}
E_MAKE_TYPE (e_comp_editor_registry, "ECompEditorRegistry", ECompEditorRegistry,
- class_init, init, gtk_object_get_type ());
+ class_init, init, G_TYPE_OBJECT);
-GtkObject *
+GObject *
e_comp_editor_registry_new (void)
{
return g_object_new (E_TYPE_COMP_EDITOR_REGISTRY, NULL);
@@ -122,12 +143,14 @@ e_comp_editor_registry_add (ECompEditorRegistry *reg, CompEditor *editor, gboole
rdata = g_new0 (ECompEditorRegistryData, 1);
+ rdata->registry = reg;
rdata->editor = editor;
rdata->uid = g_strdup (uid);
- g_hash_table_insert (priv->editors, rdata->uid, rdata);
- g_signal_connect (editor, "destroy", G_CALLBACK (editor_destroy_cb), reg);
+ g_hash_table_insert (priv->editors, g_strdup (uid), rdata);
+ /* FIXME Need to know when uid on the editor changes (if the component changes locations) */
+ g_object_weak_ref (G_OBJECT (editor), editor_destroy_cb, rdata);
}
CompEditor *
@@ -188,25 +211,12 @@ e_comp_editor_registry_close_all (ECompEditorRegistry *reg)
}
static void
-editor_destroy_cb (GtkWidget *widget, gpointer data)
+editor_destroy_cb (gpointer data, GObject *where_object_was)
{
- ECompEditorRegistry *reg;
- ECompEditorRegistryPrivate *priv;
- ECompEditorRegistryData *rdata;
- ECalComponent *comp;
- const char *uid;
-
- reg = E_COMP_EDITOR_REGISTRY (data);
- priv = reg->priv;
-
- comp = comp_editor_get_comp (COMP_EDITOR (widget));
- e_cal_component_get_uid (comp, &uid);
-
- rdata = g_hash_table_lookup (priv->editors, uid);
+ ECompEditorRegistryData *rdata = data;
- if (rdata != NULL) {
- g_hash_table_remove (priv->editors, rdata->uid);
- g_free (rdata->uid);
- g_free (rdata);
- }
+ /* We null it out because its dead, so we won't try to weak
+ * unref it in the hash destroyer */
+ rdata->editor = NULL;
+ g_hash_table_remove (rdata->registry->priv->editors, rdata->uid);
}
diff --git a/calendar/gui/e-comp-editor-registry.h b/calendar/gui/e-comp-editor-registry.h
index dfcc1b21bc..6ddf2f34e5 100644
--- a/calendar/gui/e-comp-editor-registry.h
+++ b/calendar/gui/e-comp-editor-registry.h
@@ -27,19 +27,16 @@
#include <config.h>
#endif
-#include <gtk/gtk.h>
+#include <glib-object.h>
#include <dialogs/comp-editor.h>
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+G_BEGIN_DECLS
-#define E_TYPE_COMP_EDITOR_REGISTRY (e_comp_editor_registry_get_type ())
-#define E_COMP_EDITOR_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_COMP_EDITOR_REGISTRY, ECompEditorRegistry))
-#define E_COMP_EDITOR_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_COMP_EDITOR_REGISTRY, ECompEditorRegistryClass))
-#define E_IS_COMP_EDITOR_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_COMP_EDITOR_REGISTRY))
-#define E_IS_COMP_EDITOR_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_COMP_EDITOR_REGISTRY))
+#define E_TYPE_COMP_EDITOR_REGISTRY (e_comp_editor_registry_get_type ())
+#define E_COMP_EDITOR_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_COMP_EDITOR_REGISTRY, ECompEditorRegistry))
+#define E_COMP_EDITOR_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_COMP_EDITOR_REGISTRY, ECompEditorRegistryClass))
+#define E_IS_COMP_EDITOR_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_COMP_EDITOR_REGISTRY))
+#define E_IS_COMP_EDITOR_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_COMP_EDITOR_REGISTRY))
typedef struct _ECompEditorRegistry ECompEditorRegistry;
@@ -47,13 +44,13 @@ typedef struct _ECompEditorRegistryPrivate ECompEditorRegistryPrivate;
typedef struct _ECompEditorRegistryClass ECompEditorRegistryClass;
struct _ECompEditorRegistry {
- GtkObject parent;
+ GObject parent;
ECompEditorRegistryPrivate *priv;
};
struct _ECompEditorRegistryClass {
- GtkObjectClass parent_class;
+ GObjectClass parent_class;
};
typedef void (* ECompEditorRegistryForeachFn) (CompEditor *editor, gpointer data);
@@ -61,8 +58,8 @@ typedef void (* ECompEditorRegistryForeachFn) (CompEditor *editor, gpointer data
-GtkType e_comp_editor_registry_get_type (void);
-GtkObject *e_comp_editor_registry_new (void);
+GType e_comp_editor_registry_get_type (void);
+GObject *e_comp_editor_registry_new (void);
void e_comp_editor_registry_add (ECompEditorRegistry *reg,
CompEditor *editor,
gboolean remote);
@@ -70,9 +67,7 @@ CompEditor *e_comp_editor_registry_find (ECompEditorRegistry *reg,
const char *uid);
gboolean e_comp_editor_registry_close_all (ECompEditorRegistry *reg);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* _E_COMP_EDITOR_REGISTRY_H_ */