3 #include <bonobo/bonobo-shlib-factory.h>
5 #include <gtkmathview.h>
7 #include "control-factory.h"
15 MATH_VIEW_ANTI_ALIASING,
16 MATH_VIEW_TRANSPARENCY,
18 MATH_VIEW_FONT_MANAGER
23 make_reg_id(const char *iid)
26 id = bonobo_activation_make_registration_id(iid,Display_String(gdk_display));
31 get_prop(BonoboPropertyBag *bag,
34 CORBA_Environment *ev,
37 GtkMathView *math_view;
39 g_return_if_fail(GTK_IS_MATH_VIEW(user_data));
41 math_view = GTK_MATH_VIEW(user_data);
47 gint i = gtk_math_view_get_width(math_view);
48 g_assert(arg->_type == BONOBO_ARG_INT);
49 BONOBO_ARG_SET_INT(arg,i);
52 case MATH_VIEW_HEIGHT:
54 guint i = gtk_math_view_get_height(math_view);
56 g_assert(arg->_type == BONOBO_ARG_INT);
57 BONOBO_ARG_SET_INT(arg,i);
62 guint new_top_y,new_top_x;
64 g_assert(arg->_type == BONOBO_ARG_INT);
65 gtk_math_view_get_top(math_view,&new_top_x, &new_top_y);
66 BONOBO_ARG_SET_INT(arg,new_top_x);
71 guint new_top_y,new_top_x;
73 g_assert(arg->_type == BONOBO_ARG_INT);
74 gtk_math_view_get_top(math_view,&new_top_x,&new_top_y);
75 BONOBO_ARG_SET_INT(arg,new_top_y);
78 case MATH_VIEW_FONT_SIZE:
80 guint i = gtk_math_view_get_font_size(math_view);
81 g_assert(arg->_type == BONOBO_ARG_INT);
83 BONOBO_ARG_SET_INT(arg,i);
86 case MATH_VIEW_ANTI_ALIASING:
88 gboolean i = gtk_math_view_get_anti_aliasing(math_view);
89 g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
91 BONOBO_ARG_SET_BOOLEAN(arg,i);
94 case MATH_VIEW_TRANSPARENCY:
96 gboolean i = gtk_math_view_get_transparency(math_view);
97 g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
99 BONOBO_ARG_SET_BOOLEAN(arg,i);
102 case MATH_VIEW_VERBOSITY:
104 gint i = gtk_math_view_get_log_verbosity(math_view);
105 g_assert(arg->_type == BONOBO_ARG_INT);
107 BONOBO_ARG_SET_INT(arg,i);
110 case MATH_VIEW_FONT_MANAGER:
111 {gint i = (gint) gtk_math_view_get_font_manager_type(math_view);
112 BONOBO_ARG_SET_INT(arg,i);
121 set_prop(BonoboPropertyBag *bag,
122 const BonoboArg *arg,
124 CORBA_Environment *ev,
127 GtkMathView *math_view;
129 g_return_if_fail(GTK_IS_MATH_VIEW(user_data));
131 math_view = GTK_MATH_VIEW(user_data);
135 /*case MATH_VIEW_WIDTH:
136 g_assert(arg->_type == BONOBO_ARG_INT);
138 guint i = gtk_math_view_set_width(math_view);
139 BONOBO_ARG_SET_INT(arg,i);
141 case MATH_VIEW_HEIGHT:
142 g_assert(arg->_type == BONOBO_ARG_INT);
144 guint i = gtk_math_view_get_height(math_view);
145 BONOBO_ARG_SET_INT(arg,i);
147 case MATH_VIEW_TOP_X:
150 g_assert(arg->_type == BONOBO_ARG_INT);
152 gtk_math_view_get_top(math_view, NULL, &old_top_y);
153 gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_y);
156 case MATH_VIEW_TOP_Y:
159 g_assert(arg->_type == BONOBO_ARG_INT);
161 gtk_math_view_get_top(math_view, &old_top_x, NULL);
162 gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_x);
165 case MATH_VIEW_FONT_SIZE:
167 guint i = gtk_math_view_get_font_size(math_view);
168 g_assert(arg->_type == BONOBO_ARG_INT);
170 BONOBO_ARG_SET_INT(arg,i);
173 case MATH_VIEW_ANTI_ALIASING:
175 gboolean i = gtk_math_view_get_anti_aliasing(math_view);
176 g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
178 BONOBO_ARG_SET_BOOLEAN(arg,i);
181 case MATH_VIEW_TRANSPARENCY:
183 gboolean i = gtk_math_view_get_transparency(math_view);
184 g_assert(arg->_type == BONOBO_ARG_BOOLEAN);
186 BONOBO_ARG_SET_BOOLEAN(arg,i);
189 case MATH_VIEW_VERBOSITY:
191 gint i = gtk_math_view_get_log_verbosity(math_view);
192 g_assert(arg->_type == BONOBO_ARG_INT);
194 BONOBO_ARG_SET_INT(arg,i);
197 case MATH_VIEW_FONT_MANAGER:
199 gint i = (gint) gtk_math_view_get_font_manager_type(math_view);
200 BONOBO_ARG_SET_INT(arg,i);
209 gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id, gpointer closure)
211 BonoboControl *control;
212 BonoboPropertyBag *prop_bag;
213 GtkWidget *math_view;
215 math_view = gtk_math_view_new(NULL,NULL);
216 gtk_widget_show(math_view);
218 control = bonobo_control_new(math_view);
221 persist_file = gtk_math_view_persist_file_new(GTK_MATH_VIEW(math_view));
222 bonobo_object_add_interface(BONOBO_OBJECT(control), persist_file);
225 prop_bag = bonobo_property_bag_new(get_prop, set_prop, math_view);
226 bonobo_control_set_properties(control, BONOBO_OBJREF(prop_bag), NULL);
228 bonobo_property_bag_add(prop_bag,"width",MATH_VIEW_WIDTH,BONOBO_ARG_INT,
230 bonobo_property_bag_add(prop_bag,"height",MATH_VIEW_HEIGHT,BONOBO_ARG_INT,
232 bonobo_property_bag_add(prop_bag,"top_x",MATH_VIEW_TOP_X,BONOBO_ARG_INT,
234 bonobo_property_bag_add(prop_bag,"top_y",MATH_VIEW_TOP_Y,BONOBO_ARG_INT,
236 bonobo_property_bag_add(prop_bag,"font_size",MATH_VIEW_FONT_SIZE,BONOBO_ARG_INT,
238 bonobo_property_bag_add(prop_bag,"anti_aliasing",MATH_VIEW_ANTI_ALIASING,BONOBO_ARG_BOOLEAN,
239 NULL,"anti_aliasing",0);
240 bonobo_property_bag_add(prop_bag,"transparency",MATH_VIEW_TRANSPARENCY,BONOBO_ARG_BOOLEAN,
241 NULL,"transparency",0);
242 bonobo_property_bag_add(prop_bag,"verbosity",MATH_VIEW_VERBOSITY,BONOBO_ARG_INT,
244 bonobo_property_bag_add(prop_bag,"font_manager",MATH_VIEW_FONT_MANAGER,BONOBO_ARG_NULL,
245 NULL,"font_manager",0);
247 bonobo_object_unref(BONOBO_OBJECT(prop_bag));
249 return BONOBO_OBJECT(control);
252 BONOBO_ACTIVATION_SHLIB_FACTORY (CONTROL_FACTORY_ID, "GtkMathView Factory", gtk_math_view_control_factory, NULL);