CLEANFILES = $(server_in_files:.server.in.in=.server)
-IDL = $(top_srcdir)/idl/GNOME_GtkMathView_View.idl
+IDL = $(top_srcdir)/idl/GtkMathView.idl
IDL_GENERATED_C = \
GNOME_GtkMathView_View-common.c \
libgtkmathview_bonobo_la_SOURCES = \
$(IDL_GENERATED_C) \
+ control-data.c \
control-factory.c \
persist-file.c \
persist-stream.c \
--- /dev/null
+
+#include "control-data.h"
+
+GtkMathViewControlData*
+gtk_math_view_control_data_new(GtkMathView *math_view)
+{
+ GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
+ cd->math_view = math_view;
+ cd->semantic_selection = FALSE;
+ cd->first_selected = NULL;
+ cd->root_selected = NULL;
+ return cd;
+}
+
+void
+gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
+{
+ GdomeException exc = 0;
+ //gtk_object_unref(cd->math_view);
+ cd->math_view = NULL;
+ if (cd->first_selected != NULL)
+ {
+ gdome_el_unref(cd->first_selected, &exc);
+ g_assert(exc == 0);
+ cd->first_selected = NULL;
+ }
+ if (cd->root_selected != NULL)
+ {
+ gdome_el_unref(cd->root_selected, &exc);
+ g_assert(exc == 0);
+ cd->root_selected = NULL;
+ }
+ g_free(cd);
+}
+
-#ifndef __CONTROL_DATA__
-#define __CONTROL_DATA__
+
+#ifndef __control_data_h__
+#define __control_data_h__
+
+#include <gtkmathview.h>
+#include <gdome.h>
typedef struct _GtkMathViewControlData
{
- gboolean semantic_selection;
- GdomeElement* first_selected;
- GdomeElement* root_selected;
- GtkMathView *math_view;
+ GtkMathView* math_view;
+ gboolean semantic_selection;
+ GdomeElement* first_selected;
+ GdomeElement* root_selected;
} GtkMathViewControlData;
-#endif
+#endif // __control_data_h__
#include "control-data.h"
#include "view.h"
-enum {
- MATH_VIEW_WIDTH,
- MATH_VIEW_HEIGHT,
- MATH_VIEW_TOP_X,
- MATH_VIEW_TOP_Y,
- MATH_VIEW_FONT_SIZE,
- MATH_VIEW_ANTI_ALIASING,
- MATH_VIEW_TRANSPARENCY,
- MATH_VIEW_VERBOSITY,
- MATH_VIEW_FONT_MANAGER
-} math_args;
-
-
-static GtkMathViewControlData*
-gtk_math_view_control_data_new(GtkMathView *math_view)
-{
- GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
- cd->math_view = math_view;
- cd->semantic_selection = FALSE;
- cd->doc_name = NULL;
- cd->first_selected = NULL;
- cd->root_selected = NULL;
- return cd;
-}
-
-static void
-gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
-{
- //gtk_object_unref(cd->math_view);
- cd->math_view = NULL;
-
- g_free(cd);
-}
+enum
+ {
+ MATH_VIEW_WIDTH,
+ MATH_VIEW_HEIGHT,
+ MATH_VIEW_TOP_X,
+ MATH_VIEW_TOP_Y,
+ MATH_VIEW_FONT_SIZE,
+ MATH_VIEW_ANTI_ALIASING,
+ MATH_VIEW_TRANSPARENCY,
+ MATH_VIEW_VERBOSITY,
+ MATH_VIEW_FONT_MANAGER
+ } math_args;
static void
-get_prop(BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
+get_prop(BonoboPropertyBag* bag,
+ BonoboArg* arg,
+ guint arg_id,
CORBA_Environment *ev,
- gpointer user_data)
+ gpointer user_data)
{
GtkMathView *math_view;
math_view = GTK_MATH_VIEW(user_data);
- switch(arg_id)
+ switch (arg_id)
{
case MATH_VIEW_WIDTH:
{
case MATH_VIEW_HEIGHT:
{
guint i = gtk_math_view_get_height(math_view);
-
g_assert(arg->_type == BONOBO_ARG_INT);
BONOBO_ARG_SET_INT(arg,i);
}
case MATH_VIEW_TOP_X:
{
guint new_top_y,new_top_x;
-
g_assert(arg->_type == BONOBO_ARG_INT);
gtk_math_view_get_top(math_view,&new_top_x, &new_top_y);
BONOBO_ARG_SET_INT(arg,new_top_x);
case MATH_VIEW_TOP_Y:
{
guint new_top_y,new_top_x;
-
g_assert(arg->_type == BONOBO_ARG_INT);
gtk_math_view_get_top(math_view,&new_top_x,&new_top_y);
BONOBO_ARG_SET_INT(arg,new_top_y);
{
guint i = gtk_math_view_get_font_size(math_view);
g_assert(arg->_type == BONOBO_ARG_INT);
-
BONOBO_ARG_SET_INT(arg,i);
}
break;
{
gboolean i = gtk_math_view_get_anti_aliasing(math_view);
g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
-
BONOBO_ARG_SET_BOOLEAN(arg,i);
}
break;
{
gboolean i = gtk_math_view_get_transparency(math_view);
g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
-
BONOBO_ARG_SET_BOOLEAN(arg,i);
}
break;
{
gint i = gtk_math_view_get_log_verbosity(math_view);
g_assert(arg->_type == BONOBO_ARG_INT);
-
BONOBO_ARG_SET_INT(arg,i);
}
break;
case MATH_VIEW_FONT_MANAGER:
{
- gint i = (gint) gtk_math_view_get_font_manager_type(math_view);
- BONOBO_ARG_SET_INT(arg,i);
+ gint i = (gint) gtk_math_view_get_font_manager_type(math_view);
+ BONOBO_ARG_SET_INT(arg,i);
}
break;
default:
}
static void
-set_prop(BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
+set_prop(BonoboPropertyBag* bag,
+ const BonoboArg* arg,
+ guint arg_id,
+ CORBA_Environment* ev,
+ gpointer user_data)
{
GtkMathView *math_view;
math_view = GTK_MATH_VIEW(user_data);
- switch(arg_id)
+ switch (arg_id)
{
case MATH_VIEW_TOP_X:
{
guint old_top_y;
g_assert(arg->_type == BONOBO_ARG_INT);
-
gtk_math_view_get_top(math_view, NULL, &old_top_y);
gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_y);
}
{
guint old_top_x;
g_assert(arg->_type == BONOBO_ARG_INT);
-
gtk_math_view_get_top(math_view, &old_top_x, NULL);
gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_x);
}
{
guint i = gtk_math_view_get_font_size(math_view);
g_assert(arg->_type == BONOBO_ARG_INT);
-
BONOBO_ARG_SET_INT(arg,i);
}
break;
{
gboolean i = gtk_math_view_get_anti_aliasing(math_view);
g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
-
BONOBO_ARG_SET_BOOLEAN(arg,i);
}
break;
{
gboolean i = gtk_math_view_get_transparency(math_view);
g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
-
BONOBO_ARG_SET_BOOLEAN(arg,i);
}
break;
{
gint i = gtk_math_view_get_log_verbosity(math_view);
g_assert(arg->_type == BONOBO_ARG_INT);
-
BONOBO_ARG_SET_INT(arg,i);
}
break;
}
break;
default:
- bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
+ bonobo_exceptionset (ev, ex_Bonobo_PropertyBag_NotFound);
break;
}
}
static void
-control_destroy(BonoboObject *object,GtkMathViewControlData *cd)
+control_destroy(BonoboObject *object, GtkMathViewControlData *cd)
{
- gtk_math_view_control_data_destroy(cd);
+ gtk_math_view_control_data_destroy(cd);
}
static void
-gtk_math_view_control_init(BonoboControl *control,GtkWidget *scrolled_window)
+gtk_math_view_control_init(BonoboControl *control, GtkWidget *scrolled_window)
{
GtkMathViewControlData *control_data;
GtkWidget *math_view;
prop_bag = bonobo_property_bag_new(get_prop, set_prop, math_view);
bonobo_control_set_properties(control, BONOBO_OBJREF(prop_bag), NULL);
- bonobo_property_bag_add(prop_bag,"width",MATH_VIEW_WIDTH,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"width",
+ MATH_VIEW_WIDTH, BONOBO_ARG_INT,
NULL,"width",0);
- bonobo_property_bag_add(prop_bag,"height",MATH_VIEW_HEIGHT,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"height",
+ MATH_VIEW_HEIGHT, BONOBO_ARG_INT,
NULL,"height",0);
- bonobo_property_bag_add(prop_bag,"top_x",MATH_VIEW_TOP_X,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"top_x",
+ MATH_VIEW_TOP_X, BONOBO_ARG_INT,
NULL,"top_x",0);
- bonobo_property_bag_add(prop_bag,"top_y",MATH_VIEW_TOP_Y,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"top_y",
+ MATH_VIEW_TOP_Y, BONOBO_ARG_INT,
NULL,"top_y",0);
- bonobo_property_bag_add(prop_bag,"font_size",MATH_VIEW_FONT_SIZE,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"font_size",
+ MATH_VIEW_FONT_SIZE, BONOBO_ARG_INT,
NULL,"font_size",0);
- bonobo_property_bag_add(prop_bag,"anti_aliasing",MATH_VIEW_ANTI_ALIASING,BONOBO_ARG_BOOLEAN,
+ bonobo_property_bag_add(prop_bag,"anti_aliasing",
+ MATH_VIEW_ANTI_ALIASING, BONOBO_ARG_BOOLEAN,
NULL,"anti_aliasing",0);
- bonobo_property_bag_add(prop_bag,"transparency",MATH_VIEW_TRANSPARENCY,BONOBO_ARG_BOOLEAN,
+ bonobo_property_bag_add(prop_bag,"transparency",
+ MATH_VIEW_TRANSPARENCY, BONOBO_ARG_BOOLEAN,
NULL,"transparency",0);
- bonobo_property_bag_add(prop_bag,"verbosity",MATH_VIEW_VERBOSITY,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"verbosity",
+ MATH_VIEW_VERBOSITY, BONOBO_ARG_INT,
NULL,"verbosity",0);
- bonobo_property_bag_add(prop_bag,"font_manager",MATH_VIEW_FONT_MANAGER,BONOBO_ARG_INT,
+ bonobo_property_bag_add(prop_bag,"font_manager",
+ MATH_VIEW_FONT_MANAGER, BONOBO_ARG_INT,
NULL,"font_manager",0);
bonobo_object_unref(BONOBO_OBJECT(prop_bag));
- g_signal_connect(control,"set_frame",G_CALLBACK(set_frame),control_data);
- g_signal_connect(control_data->math_view, "click", G_CALLBACK (click_cb),control_data);
- g_signal_connect(control_data->math_view, "select_begin",G_CALLBACK(select_begin_cb),control_data);
- g_signal_connect(control_data->math_view, "select_over",G_CALLBACK(select_over_cb),control_data);
- g_signal_connect(control_data->math_view, "select_end",G_CALLBACK(select_end_cb),control_data);
- g_signal_connect(control_data->math_view, "select_abort",G_CALLBACK(select_abort_cb),control_data);
+ g_signal_connect(control,"set_frame", G_CALLBACK(set_frame), control_data);
+ g_signal_connect(control_data->math_view, "click", G_CALLBACK (click_cb),
+ control_data);
+ g_signal_connect(control_data->math_view, "select_begin", G_CALLBACK(select_begin_cb),
+ control_data);
+ g_signal_connect(control_data->math_view, "select_over", G_CALLBACK(select_over_cb),
+ control_data);
+ g_signal_connect(control_data->math_view, "select_end", G_CALLBACK(select_end_cb),
+ control_data);
+ g_signal_connect(control_data->math_view, "select_abort", G_CALLBACK(select_abort_cb),
+ control_data);
}
static BonoboObject*
-gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id, gpointer closure)
+gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id,
+ gpointer closure)
{
BonoboControl *control;
GtkWidget *scrolled_window;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show_all (scrolled_window);
control = bonobo_control_new(scrolled_window);
if(control)
- {
- gtk_math_view_control_init(control,scrolled_window);
- return BONOBO_OBJECT(control);
- }
+ {
+ gtk_math_view_control_init(control,scrolled_window);
+ return BONOBO_OBJECT(control);
+ }
else
- return NULL;
+ return NULL;
}
-BONOBO_ACTIVATION_SHLIB_FACTORY (CONTROL_FACTORY_ID, "GtkMathView Factory", gtk_math_view_control_factory, NULL);
+BONOBO_ACTIVATION_SHLIB_FACTORY (CONTROL_FACTORY_ID, "GtkMathView Factory",
+ gtk_math_view_control_factory, NULL);
+
#include "handlers.h"
void
-set_frame(BonoboControl *control,gpointer data)
+set_frame(BonoboControl *control, gpointer data)
{
- /*Bonobo_UIContainer remote_ui_container;
- BonoboUIComponent *ui_component;
- GtkMathViewControlData *control_data;
- GtkWidget *scrolled_window;
- Bonobo_ControlFrame frame;
- control_data = (GtkMathViewControlData *) data;*/
}
void
-click_cb(GtkMathView* math_view, GdomeElement* elem, gint state, GtkMathViewControlData* control_data)
+click_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
+ GtkMathViewControlData* control_data)
{
- GdomeException exc;
- GdomeDOMString* name;
- GdomeDOMString* ns_uri;
- //GdomeElement* p;
+ GdomeException exc = 0;
g_return_if_fail(math_view != NULL);
-
- printf("*** click signal: %p %x %p\n", elem, state, control_data);
+ g_return_if_fail(control_data != NULL);
if (elem != NULL)
- {
+ {
GdomeElement* action;
GdomeDOMString* href = find_hyperlink(elem);
+
if (href != NULL)
- {
- /* printf("hyperlink %s\n", href->str); */
+ {
gtk_math_view_load_uri(math_view,href->str);
gdome_str_unref(href);
- }
- else
- {
- action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction");
- /* printf("action? %p\n", action); */
- if (action != NULL)
- {
- gtk_math_view_freeze(math_view);
- action_toggle(action);
- gtk_math_view_thaw(math_view);
- gdome_el_unref(action, &exc);
- g_assert(exc == 0);
- return;
- }
- }
- if (control_data->root_selected != NULL)
- {
- gtk_math_view_freeze(math_view);
- gtk_math_view_unselect(math_view, control_data->root_selected);
- gtk_math_view_thaw(math_view);
- gdome_el_unref(control_data->root_selected, &exc);
- g_assert(exc == 0);
- control_data->root_selected = NULL;
- }
- }
+ return;
+ }
+
+ action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction");
+ if (action != NULL)
+ {
+ gtk_math_view_freeze(math_view);
+ action_toggle(action);
+ gtk_math_view_thaw(math_view);
+ gdome_el_unref(action, &exc);
+ g_assert(exc == 0);
+ return;
+ }
+ }
+
+ if (control_data->root_selected != NULL)
+ {
+ gtk_math_view_freeze(math_view);
+ gtk_math_view_unselect(math_view, control_data->root_selected);
+ gtk_math_view_thaw(math_view);
+ gdome_el_unref(control_data->root_selected, &exc);
+ g_assert(exc == 0);
+ control_data->root_selected = NULL;
+ }
}
void
-select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
+select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
+ GtkMathViewControlData* control_data)
{
g_return_if_fail(math_view != NULL);
- g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
- printf("*** select_begin signal: %p %x\n", elem, state);
+ g_return_if_fail(control_data != NULL);
+
if (elem != NULL)
{
GdomeException exc = 0;
gtk_math_view_freeze(math_view);
if (control_data->root_selected != NULL)
- {
- gtk_math_view_unselect(math_view,control_data->root_selected);
- gdome_el_unref(control_data->root_selected, &exc);
- g_assert(exc == 0);
- control_data->root_selected = NULL;
- }
+ {
+ gtk_math_view_unselect(math_view, control_data->root_selected);
+ gdome_el_unref(control_data->root_selected, &exc);
+ g_assert(exc == 0);
+ control_data->root_selected = NULL;
+ }
if (control_data->semantic_selection)
- {
- GdomeElement* new_elem = find_xref_element(elem);
- if (new_elem != NULL)
- {
- gdome_el_ref(new_elem, &exc);
- g_assert(exc == 0);
- }
- control_data->first_selected = control_data->root_selected = new_elem;
- }
+ {
+ GdomeElement* new_elem = find_xref_element(elem);
+ if (new_elem != NULL)
+ {
+ gdome_el_ref(new_elem, &exc);
+ g_assert(exc == 0);
+ }
+ control_data->first_selected = control_data->root_selected = new_elem;
+ }
else
- {
- gdome_el_ref(elem, &exc);
- g_assert(exc == 0);
- gdome_el_ref(elem, &exc);
- g_assert(exc == 0);
- control_data->first_selected = control_data->root_selected = elem;
- }
+ {
+ gdome_el_ref(elem, &exc);
+ g_assert(exc == 0);
+ gdome_el_ref(elem, &exc);
+ g_assert(exc == 0);
+ control_data->first_selected = control_data->root_selected = elem;
+ }
if (control_data->root_selected != NULL)
- gtk_math_view_select(math_view, control_data->root_selected);
+ gtk_math_view_select(math_view, control_data->root_selected);
gtk_math_view_thaw(math_view);
}
}
void
-select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
+select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
+ GtkMathViewControlData* control_data)
{
g_return_if_fail(math_view != NULL);
- g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
-
- printf("*** select_over signal: %p %x\n", elem, state);
+ g_return_if_fail(control_data != NULL);
if (control_data->first_selected != NULL && elem != NULL)
{
GdomeException exc = 0;
gtk_math_view_freeze(math_view);
-
+
if (control_data->root_selected != NULL)
- {
+ {
gtk_math_view_unselect(math_view, control_data->root_selected);
gdome_el_unref(control_data->root_selected, &exc);
g_assert(exc == 0);
control_data->root_selected = NULL;
- }
-
+ }
+
if (control_data->semantic_selection)
- {
- GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem);
- if (new_root != NULL)
- {
- control_data->root_selected = find_xref_element(new_root);
- gdome_el_unref(new_root, &exc);
- g_assert(exc == 0);
- }
- else
- control_data->root_selected = NULL;
- }
+ {
+ GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem);
+ if (new_root != NULL)
+ {
+ control_data->root_selected = find_xref_element(new_root);
+ gdome_el_unref(new_root, &exc);
+ g_assert(exc == 0);
+ }
+ else
+ control_data->root_selected = NULL;
+ }
else
control_data->root_selected = find_common_ancestor(control_data->first_selected, elem);
-
+
if (control_data->root_selected != NULL)
gtk_math_view_select(math_view, control_data->root_selected);
-
+
gtk_math_view_thaw(math_view);
}
}
void
-select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
+select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
+ GtkMathViewControlData* control_data)
{
g_return_if_fail(math_view != NULL);
- g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
-
- printf("*** select_end signal: %p %x\n", elem, state);
+ g_return_if_fail(control_data != NULL);
if (control_data->first_selected != NULL)
- {
+ {
GdomeException exc = 0;
gdome_el_unref(control_data->first_selected, &exc);
g_assert(exc == 0);
control_data->first_selected = NULL;
- }
+ }
}
void
-select_abort_cb(GtkMathView* math_view,GtkMathViewControlData* control_data)
+select_abort_cb(GtkMathView* math_view, GtkMathViewControlData* control_data)
{
GdomeException exc = 0;
g_return_if_fail(math_view != NULL);
- g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
-
- printf("*** select_abort signal\n");
+ g_return_if_fail(control_data != NULL);
if (control_data->first_selected != NULL)
- {
+ {
gdome_el_unref(control_data->first_selected, &exc);
g_assert(exc == 0);
control_data->first_selected = NULL;
- }
+ }
+
if (control_data->root_selected != NULL)
{
gtk_math_view_freeze(math_view);
-#ifndef __handlers___
-#define __handlers___
+
+#ifndef __handlers_h__
+#define __handlers_h__
#include <bonobo.h>
-#include <gtkmathview.h>
#include <gdome.h>
-#include "control-data.h"
-
-void
-set_frame(BonoboControl*,gpointer);
-
-void
-click_cb(GtkMathView*, GdomeElement*, gint,GtkMathViewControlData*);
-
-void
-select_begin_cb(GtkMathView*,GdomeElement*, gint,GtkMathViewControlData*);
-
-void
-select_over_cb(GtkMathView*,GdomeElement*,gint,GtkMathViewControlData*);
+#include <gtkmathview.h>
-void
-select_end_cb(GtkMathView*,GdomeElement*,gint,GtkMathViewControlData*);
+#include "control-data.h"
-void
-select_abort_cb(GtkMathView*,GtkMathViewControlData*);
+void set_frame(BonoboControl*, gpointer);
+void click_cb(GtkMathView*, GdomeElement*, gint, GtkMathViewControlData*);
+void select_begin_cb(GtkMathView*,GdomeElement*, gint, GtkMathViewControlData*);
+void select_over_cb(GtkMathView*,GdomeElement*,gint, GtkMathViewControlData*);
+void select_end_cb(GtkMathView*,GdomeElement*,gint, GtkMathViewControlData*);
+void select_abort_cb(GtkMathView*, GtkMathViewControlData*);
-#endif
+#endif // __handlers_h__