-
#include <config.h>
-
#include <gnome.h>
#include <bonobo.h>
-
#include <glib.h>
#include "control-factory.h"
+#include "GtkMathView.h"
static GtkWidget *control;
+typedef enum{LOAD_STREAM,LOAD_FILE,NONE}FileSelectionOp;
+
struct FileSelectionInfo {
BonoboWidget* control;
GtkWidget* widget;
+
+ FileSelectionOp Operations;
};
-static struct FileSelectionInfo file_selection_info = { NULL, NULL };
+
+static struct FileSelectionInfo file_selection_info = { NULL, NULL,NONE};
+
+static void
+file_selection_destroy_cb (GtkWidget *widget,gpointer data)
+{
+ file_selection_info.widget = NULL;
+}
+
static void
load_through_persist_file (const gchar *filename,
CORBA_exception_free (&ev);
}
+static void
+load_through_persist_stream(const gchar *filename,
+ Bonobo_PersistStream pstream)
+{
+ BonoboObject *stream = NULL;
+ CORBA_Environment ev;
+ CORBA_exception_init (&ev);
+
+#if 0
+ stream = bonobo_stream_open ("fs", filename,
+ Bonobo_Storage_READ, 0);
+#endif
+
+ /*if (stream == NULL)
+ {
+ g_warning ("Couldn't load `%s'\n", filename);
+ } else*/ {
+ Bonobo_Stream corba_stream;
+ corba_stream = bonobo_object_corba_objref (stream);
+ Bonobo_Stream_truncate (corba_stream, 0, &ev);
+ Bonobo_PersistStream_load (pstream, corba_stream, "application/mathml+xml", &ev);
+ }
+ Bonobo_Unknown_unref (pstream, &ev);
+ CORBA_Object_release (pstream, &ev);
+ CORBA_exception_free (&ev);
+}
+
static void
file_selection_ok_cb (GtkWidget *widget,
gpointer data)
const gchar *interface_name;
CORBA_Environment ev;
- interface_name = "IDL:Bonobo/PersistFile:1.0";
+ if (file_selection_info.Operations == LOAD_FILE)
+ interface_name = "IDL:Bonobo/PersistFile:1.0";
+ else if(file_selection_info.Operations == LOAD_STREAM)
+ interface_name = "IDL:Bonobo/PersistStream:1.0";
+ else printf("failed to get operation type\n");
CORBA_exception_init (&ev);
interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (file_selection_info.control),
}
else
{
- const gchar *fname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selection_info.widget));
- load_through_persist_file (fname, interface);
+ const gchar *fname;
+ fname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selection_info.widget));
+ switch (file_selection_info.Operations) {
+ case LOAD_STREAM:
+ load_through_persist_stream (fname, interface);
+ break;
+ case LOAD_FILE:
+ load_through_persist_file (fname, interface);
+ break;
+ }
}
gtk_widget_destroy (file_selection_info.widget);
}
static void
-file_selection_destroy_cb (GtkWidget *widget,
- gpointer data)
-{
- file_selection_info.widget = NULL;
-}
-
-static void
-open_dialog (BonoboWindow *app)
+open_dialog (BonoboWindow *app,
+ FileSelectionOp operation)
{
GtkWidget *widget;
BonoboWidget *control;
return;
}
- widget = gtk_file_selection_new (_("Open file..."));
+ if(operation == LOAD_STREAM)
+ widget = gtk_file_selection_new(_("Open Stream...."));
+ if(operation == LOAD_FILE)
+ widget = gtk_file_selection_new (_("Open file..."));
gtk_window_set_transient_for (GTK_WINDOW (widget),
GTK_WINDOW (app));
file_selection_info.widget = widget;
file_selection_info.control = control;
+ file_selection_info.Operations = operation;
g_signal_connect_object (GTK_FILE_SELECTION (widget)->cancel_button,
"clicked", G_CALLBACK (gtk_widget_destroy), widget, G_CONNECT_AFTER);
+
g_signal_connect (GTK_FILE_SELECTION (widget)->ok_button, "clicked", G_CALLBACK (file_selection_ok_cb), NULL);
+
g_signal_connect (file_selection_info.widget, "destroy", G_CALLBACK (file_selection_destroy_cb), NULL);
gtk_widget_show (file_selection_info.widget);
open_through_persist_file_cb (GtkWidget *widget,
gpointer data)
{
- open_dialog (BONOBO_WINDOW (data));
+ open_dialog (BONOBO_WINDOW (data), LOAD_FILE);
+}
+
+static void
+open_through_persist_stream_cb(GtkWidget *widget,
+ gpointer data)
+{
+ open_dialog(BONOBO_WINDOW(data), LOAD_STREAM);
+}
+
+static void
+test_view(GtkWidget* widget, gpointer data)
+{
+ CORBA_Object interface;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (bonobo_window_get_contents (BONOBO_WINDOW(data)))),
+ "IDL:GNOME/GtkMathView/View:1.0", &ev);
+ CORBA_exception_free (&ev);
+
+ if (interface == CORBA_OBJECT_NIL)
+ {
+ g_warning ("The Control does not seem to support `View'.");
+ }
+
+ CORBA_exception_init (&ev);
+ GNOME_GtkMathView_View_freeze(interface, &ev);
+ CORBA_exception_free (&ev);
+
+ CORBA_exception_init (&ev);
+ GNOME_GtkMathView_View_thaw(interface, &ev);
+ CORBA_exception_free (&ev);
+
+ CORBA_exception_init (&ev);
+ Bonobo_Unknown_unref (interface, &ev);
+ CORBA_Object_release (interface, &ev);
+ CORBA_exception_free (&ev);
}
static void
bonobo_main_quit ();
}
+static void
+get_size(GtkWidget *widget,
+ gpointer data)
+{
+ gint width,height;
+ BonoboWidget* control;
+ BonoboControlFrame* control_frame;
+
+ Bonobo_PropertyBag prop_bag;
+
+ control = BONOBO_WIDGET (bonobo_window_get_contents (BONOBO_WINDOW (data)));
+ control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
+ prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL);
+
+ width = bonobo_pbclient_get_long(prop_bag,"width",NULL);
+ height = bonobo_pbclient_get_long(prop_bag,"height",NULL);
+
+ printf("Width: %d Height: %d\n",width,height);
+
+ bonobo_object_release_unref (prop_bag,NULL);
+
+};
+
+static void
+get_top(GtkWidget *widget,
+ gpointer data)
+{
+ gint top_x,top_y;
+ BonoboWidget* control;
+ BonoboControlFrame* control_frame;
+ Bonobo_PropertyBag prop_bag;
+
+ control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data)));
+ control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
+ prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL);
+
+ top_x = bonobo_pbclient_get_long(prop_bag,"top-x",NULL);
+ top_y = bonobo_pbclient_get_long(prop_bag,"top-y",NULL);
+
+ printf("Top X: %d ,Top Y: %d\n",top_x,top_y);
+
+ bonobo_object_release_unref(prop_bag,NULL);
+}
+
+static void
+get_font_size(GtkWidget *widget,
+ gpointer data)
+{
+ gint font_size;
+ BonoboWidget* control;
+ BonoboControlFrame* control_frame;
+ Bonobo_PropertyBag prop_bag;
+
+ control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data)));
+ control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
+ prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL);
+
+ font_size = bonobo_pbclient_get_long(prop_bag,"font-size",NULL);
+
+ printf("FontSize : %d\n",font_size);
+
+ bonobo_object_release_unref(prop_bag,NULL);
+}
+
+static void
+get_verbosity(GtkWidget *widget,
+ gpointer data)
+{
+ gint verbosity;
+ BonoboWidget* control;
+ BonoboControlFrame* control_frame;
+ Bonobo_PropertyBag prop_bag;
+
+ control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data)));
+ control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
+ prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL);
+
+ verbosity = bonobo_pbclient_get_long(prop_bag,"verbosity",NULL);
+
+ printf("Verbosity: %d\n",verbosity);
+
+ bonobo_object_release_unref(prop_bag,NULL);
+}
+
static BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("OpenFile", open_through_persist_file_cb),
+ BONOBO_UI_UNSAFE_VERB ("OpenStream", open_through_persist_stream_cb),
+ BONOBO_UI_UNSAFE_VERB ("TestView", test_view),
+ BONOBO_UI_UNSAFE_VERB ("Size", get_size),
+ BONOBO_UI_UNSAFE_VERB ("Top", get_top),
+ BONOBO_UI_UNSAFE_VERB ("Font Size", get_font_size),
+ BONOBO_UI_UNSAFE_VERB ("Verbosity", get_verbosity),
BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb),
-
BONOBO_UI_VERB_END
};
" <submenu name=\"File\" _label=\"_File\">"
" <menuitem name=\"OpenFile\" verb=\"\" _label=\"Open (PersistFile)\" _tip=\"Open using the PersistFile interface\""
" pixtype=\"stock\" pixname=\"Open\"/>"
-" <menuitem name=\"SaveFile\" verb=\"\" _label=\"Save (PersistFile)\" _tip=\"Save using the PersistFile interface\""
-" pixtype=\"stock\" pixname=\"Save\"/>"
+" <menuitem name=\"OpenStream\" verb=\"\" _label=\"_Open Stream (PersistStream)\" _tip=\"Open using the PersistStream interface\""
+" pixtype=\"stock\" pixname=\"Open Stream\"/>"
" <separator/>"
-" <menuitem name=\"OpenStream\" verb=\"\" _label=\"_Open (PersistStream)\" _tip=\"Open using the PersistStream interface\""
-" pixtype=\"stock\" pixname=\"Open\"/>"
-" <menuitem name=\"SaveStream\" verb=\"\" _label=\"_Save (PersistStream)\" _tip=\"Save using the PersistStream interface\""
-" pixtype=\"stock\" pixname=\"Save\"/>"
-" <menuitem name=\"SavePlainStream\" verb=\"\" _label=\"Save _plain(PersistStream)\" _tip=\"Save using the PersistStream interface\""
-" pixtype=\"stock\" pixname=\"Save\"/>"
-" <separator/>"
-" <menuitem name=\"ViewHTMLSource\" verb=\"\" _label=\"View HTML Source\" _tip=\"View the html source of the current document\"/>"
-" <menuitem name=\"ViewHTMLSourceHTML\" verb=\"\" _label=\"View HTML Output\" _tip=\"View the html source of the current document as html\"/>"
-" <menuitem name=\"ViewPlainSource\" verb=\"\" _label=\"View PLAIN Source\" _tip=\"View the plain text source of the current document\"/>"
+" <menuitem name=\"TestView\" verb=\"\" _label=\"Test View\" _tip=\"Test the View interface\"/>"
" <separator/>"
" <menuitem name=\"FileExit\" verb=\"\" _label=\"E_xit\"/>"
" </submenu>"
" <placeholder name=\"Component\"/>"
-" <submenu name=\"Format\" _label=\"For_mat\">"
-" <menuitem name=\"FormatHTML\" verb=\"\"/>"
-" <separator/>"
-" <placeholder name=\"FormatParagraph\"/>"
+" <submenu name=\"PropertyBags\" _label=\"Property_Bag\">"
+" <menuitem name=\"Size\" verb=\"\" _label=\"Size(PropertyBag)\" _tip=\"Get size\""
+" pixtype=\"stock\" pixname=\"Get Size\"/>"
+
+" <menuitem name=\"Top\" verb=\"\" _label=\"Top(PropertyBag)\" _tip=\"Get Top\""
+" pixtype=\"stock\" pixname=\"Get Top\"/>"
+
+" <menuitem name=\"Font Size\" verb=\"\" _label=\"Font Size(PropertyBag)\" _tip=\"Get FontSize\""
+" pixtype=\"stock\" pixname=\"Get FontSize\"/>"
+
+" <menuitem name=\"Verbosity\" verb=\"\" _label=\"Verbosity(PropertyBag)\" _tip=\"Get Verbosity\""
+" pixtype=\"stock\" pixname=\"Get Verbosity\"/>"
" </submenu>"
" </menu>"
" <dockitem name=\"Toolbar\" behavior=\"exclusive\">"
BonoboUIComponent *component;
BonoboUIContainer *container;
CORBA_Environment ev;
+
win = bonobo_window_new ("test-editor",
"GtkMathView Control Test");
bonobo_ui_component_set_container (component, BONOBO_OBJREF (container), NULL);
bonobo_ui_component_add_verb_list_with_data (component, verbs, win);
bonobo_ui_component_set_translate (component, "/", ui, NULL);
-
+
control = bonobo_widget_new_control (CONTROL_ID, BONOBO_OBJREF (container));
if (control == NULL)
return FALSE;
}
+static gint
+load_file_stream(const gchar *fname)
+{
+ CORBA_Object interface;
+ CORBA_Environment ev;
+
+ printf("loading with stream %s\n",fname);
+ CORBA_exception_init(&ev);
+ interface = Bonobo_Unknown_queryInterface(bonobo_widget_get_objref(BONOBO_WIDGET(control)),
+ "IDL:Bonobo/PersistStream:1.0",&ev);
+
+ CORBA_exception_free(&ev);
+ load_through_persist_stream(fname,interface);
+
+ return FALSE;
+}
+
+/*
+static void
+install_property_bag_listener (BonoboWidget *control, BonoboWindow *bonobo_win)
+{
+ Bonobo_Listener corba_listener;
+ BonoboListener *listener;
+ BonoboControlFrame *control_frame;
+ CORBA_Environment ev;
+ Bonobo_PropertyBag prop_bag;
+
+ CORBA_exception_init(&ev);
+
+ control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control));
+ if(!control_frame)
+ g_error("can't find control frame\n");
+
+ prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL);
+ if(prop_bag == CORBA_OBJECT_NIL)
+ g_error("can't connect to property bag\n");
+
+ //connect a listener to the property bag
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn) width_changed,
+ "Bonobo/Property:change:width",NULL,bonobo_win);
+
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)height_changed,
+ "Bonobo/Property:change:height",NULL,bonobo_win);
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_x_changed,
+ "Bonobo/Property:change:top-x",NULL,bonobo_win);
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_y_changed,
+ "Bonobo/Property:change:top-y",NULL,bonobo_win);
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_size_changed,
+ "Bonobo/Property:change:font-size",NULL,bonobo_win);
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)anti_aliasing_changed,
+ "Bonobo/Property:change:verbosity",NULL,bonobo_win);
+ bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_manager_changed,
+ "Bonobo/Property:change:font_manager",NULL,bonobo_win);
+ CORBA_exception_free(&ev);
+}*/
+
+
int
main (int argc, char **argv)
{