+/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView.
+ * Copyright (C) 2003 Luca Padovani <lpadovan@cs.unibo.it>
+ * Pouria Masoudi <pmasoudi@cs.unibo.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For more information, please visit the project's home page
+ * http://helm.cs.unibo.it/gtkmathview-bonobo
+ * or send an email to <lpadovan@cs.unibo.it>
+ */
+
+#include <config.h>
+
+#include <gdome.h>
#include "control-data.h"
GtkMathViewControlData*
-gtk_math_view_control_data_new(GtkMathView *math_view)
+gtk_math_view_control_data_new(BonoboControl* control, GtkMathView *math_view)
{
GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
+ cd->control = control; /* we don't ref the control this is a weak pointer */
cd->math_view = math_view;
+ gtk_widget_ref(GTK_WIDGET(math_view));
+ cd->item_factory = NULL;
cd->semantic_selection = FALSE;
cd->first_selected = NULL;
cd->root_selected = NULL;
+ cd->id_ns_uri = gdome_str_mkref("http://www.cs.unibo.it/helm");
+ cd->id_name = gdome_str_mkref("xref");
+ cd->x = cd->y = 0;
return cd;
}
gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
{
GdomeException exc = 0;
- //gtk_object_unref(cd->math_view);
+ cd->control = NULL; /* don't unref the control, see above */
+ gtk_widget_unref(GTK_WIDGET(cd->math_view));
cd->math_view = NULL;
+ if (cd->item_factory != NULL)
+ {
+ gtk_object_unref(cd->item_factory);
+ cd->item_factory = NULL;
+ }
if (cd->first_selected != NULL)
{
gdome_el_unref(cd->first_selected, &exc);
g_assert(exc == 0);
cd->root_selected = NULL;
}
+ if (cd->id_ns_uri != NULL)
+ {
+ gdome_str_unref(cd->id_ns_uri);
+ cd->id_ns_uri = NULL;
+ }
+ if (cd->id_name != NULL)
+ {
+ gdome_str_unref(cd->id_name);
+ cd->id_name = NULL;
+ }
g_free(cd);
}
+gchar*
+gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData* cd)
+{
+ g_return_val_if_fail(cd != NULL, NULL);
+ return (cd->id_ns_uri != NULL) ? g_strdup(cd->id_ns_uri->str) : NULL;
+}
+
+void
+gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData* cd, const gchar* ns_uri)
+{
+ g_return_if_fail(cd != NULL);
+ if (cd->id_ns_uri != NULL) gdome_str_unref(cd->id_ns_uri);
+ cd->id_ns_uri = (ns_uri != NULL) ? gdome_str_mkref_dup(ns_uri) : NULL;
+}
+
+gchar*
+gtk_math_view_control_data_get_id_name(GtkMathViewControlData* cd)
+{
+ g_return_val_if_fail(cd != NULL, NULL);
+ return (cd->id_name != NULL) ? g_strdup(cd->id_name->str) : NULL;
+}
+
+void
+gtk_math_view_control_data_set_id_name(GtkMathViewControlData* cd, const gchar* name)
+{
+ g_return_if_fail(cd != NULL);
+ if (cd->id_name != NULL) gdome_str_unref(cd->id_name);
+ cd->id_name = (name != NULL) ? gdome_str_mkref_dup(name) : NULL;
+}
+
+void
+gtk_math_view_control_data_set_root_selected(GtkMathViewControlData* cd, GdomeElement* elem)
+{
+ g_return_if_fail(cd != NULL);
+ GdomeException exc = 0;
+
+ gtk_math_view_freeze(cd->math_view);
+
+ if (cd->root_selected != NULL)
+ {
+ gtk_math_view_unselect(cd->math_view, cd->root_selected);
+ gdome_el_unref(cd->root_selected, &exc);
+ g_assert(exc == 0);
+ }
+
+ cd->root_selected = elem;
+ if (cd->root_selected != NULL)
+ {
+ gdome_el_ref(cd->root_selected, &exc);
+ g_assert(exc == 0);
+ gtk_math_view_select(cd->math_view, cd->root_selected);
+ }
+
+ gtk_math_view_thaw(cd->math_view);
+}