9 #include "control-factory.h"
11 static GtkWidget *control;
13 struct FileSelectionInfo {
14 BonoboWidget* control;
18 static struct FileSelectionInfo file_selection_info = { NULL, NULL };
21 file_selection_ok_cb (GtkWidget *widget,
24 CORBA_Object interface;
25 const gchar *interface_name;
28 interface_name = "IDL:Bonobo/PersistFile:1.0";
30 CORBA_exception_init (&ev);
31 interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (file_selection_info.control),
33 CORBA_exception_free (&ev);
35 if (interface == CORBA_OBJECT_NIL)
37 g_warning ("The Control does not seem to support `%s'.", interface_name);
41 const gchar *fname = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selection_info.widget));
42 /* load_through_persist_file (fname, interface); */
46 gtk_widget_destroy (file_selection_info.widget);
50 file_selection_destroy_cb (GtkWidget *widget,
53 file_selection_info.widget = NULL;
57 open_dialog (BonoboWindow *app)
60 BonoboWidget *control;
62 control = BONOBO_WIDGET (bonobo_window_get_contents (app));
64 if (file_selection_info.widget != NULL) {
65 gdk_window_show (GTK_WIDGET (file_selection_info.widget)->window);
69 widget = gtk_file_selection_new (_("Open file..."));
71 gtk_window_set_transient_for (GTK_WINDOW (widget),
74 file_selection_info.widget = widget;
75 file_selection_info.control = control;
77 g_signal_connect_object (GTK_FILE_SELECTION (widget)->cancel_button,
78 "clicked", G_CALLBACK (gtk_widget_destroy), widget, G_CONNECT_AFTER);
79 g_signal_connect (GTK_FILE_SELECTION (widget)->ok_button, "clicked", G_CALLBACK (file_selection_ok_cb), NULL);
80 g_signal_connect (file_selection_info.widget, "destroy", G_CALLBACK (file_selection_destroy_cb), NULL);
82 gtk_widget_show (file_selection_info.widget);
85 /* "Open through persist file" dialog. */
87 open_through_persist_file_cb (GtkWidget *widget,
90 open_dialog (BONOBO_WINDOW (data));
94 exit_cb (GtkWidget *widget,
97 gtk_widget_destroy (GTK_WIDGET (data));
101 static BonoboUIVerb verbs [] = {
102 BONOBO_UI_UNSAFE_VERB ("OpenFile", open_through_persist_file_cb),
103 BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb),
108 /* A dirty, non-translatable hack */
112 " <cmd name=\"FileExit\" _label=\"Exit\" _tip=\"Exit the program\""
113 " pixtype=\"stock\" pixname=\"Exit\" accel=\"*Control*q\"/>"
114 " <cmd name=\"FormatHTML\" _label=\"HTML mode\" type=\"toggle\" _tip=\"HTML Format switch\"/>"
117 " <submenu name=\"File\" _label=\"_File\">"
118 " <menuitem name=\"OpenFile\" verb=\"\" _label=\"Open (PersistFile)\" _tip=\"Open using the PersistFile interface\""
119 " pixtype=\"stock\" pixname=\"Open\"/>"
120 " <menuitem name=\"SaveFile\" verb=\"\" _label=\"Save (PersistFile)\" _tip=\"Save using the PersistFile interface\""
121 " pixtype=\"stock\" pixname=\"Save\"/>"
123 " <menuitem name=\"OpenStream\" verb=\"\" _label=\"_Open (PersistStream)\" _tip=\"Open using the PersistStream interface\""
124 " pixtype=\"stock\" pixname=\"Open\"/>"
125 " <menuitem name=\"SaveStream\" verb=\"\" _label=\"_Save (PersistStream)\" _tip=\"Save using the PersistStream interface\""
126 " pixtype=\"stock\" pixname=\"Save\"/>"
127 " <menuitem name=\"SavePlainStream\" verb=\"\" _label=\"Save _plain(PersistStream)\" _tip=\"Save using the PersistStream interface\""
128 " pixtype=\"stock\" pixname=\"Save\"/>"
130 " <menuitem name=\"ViewHTMLSource\" verb=\"\" _label=\"View HTML Source\" _tip=\"View the html source of the current document\"/>"
131 " <menuitem name=\"ViewHTMLSourceHTML\" verb=\"\" _label=\"View HTML Output\" _tip=\"View the html source of the current document as html\"/>"
132 " <menuitem name=\"ViewPlainSource\" verb=\"\" _label=\"View PLAIN Source\" _tip=\"View the plain text source of the current document\"/>"
134 " <menuitem name=\"FileExit\" verb=\"\" _label=\"E_xit\"/>"
136 " <placeholder name=\"Component\"/>"
137 " <submenu name=\"Format\" _label=\"For_mat\">"
138 " <menuitem name=\"FormatHTML\" verb=\"\"/>"
140 " <placeholder name=\"FormatParagraph\"/>"
143 " <dockitem name=\"Toolbar\" behavior=\"exclusive\">"
148 app_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer dummy)
150 gtk_widget_destroy (GTK_WIDGET (widget));
157 container_create (void)
161 BonoboUIComponent *component;
162 BonoboUIContainer *container;
163 CORBA_Environment ev;
165 win = bonobo_window_new ("test-editor",
166 "GtkMathView Control Test");
167 window = GTK_WINDOW (win);
169 container = bonobo_window_get_ui_container (BONOBO_WINDOW (win));
171 g_signal_connect (window, "delete_event", G_CALLBACK (app_delete_cb), NULL);
173 gtk_window_set_default_size (window, 600, 440);
174 gtk_window_set_resizable (window, TRUE);
176 component = bonobo_ui_component_new ("test");
177 bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (component));
179 bonobo_ui_component_set_container (component, BONOBO_OBJREF (container), NULL);
180 bonobo_ui_component_add_verb_list_with_data (component, verbs, win);
181 bonobo_ui_component_set_translate (component, "/", ui, NULL);
183 control = bonobo_widget_new_control (CONTROL_ID, BONOBO_OBJREF (container));
186 g_error ("Cannot get `%s'.", CONTROL_ID);
188 bonobo_window_set_contents (BONOBO_WINDOW (win), control);
190 gtk_widget_show_all (GTK_WIDGET (window));
192 CORBA_exception_init (&ev);
198 load_file (const gchar *fname)
200 CORBA_Object interface;
201 CORBA_Environment ev;
203 printf ("loading: %s\n", fname);
204 CORBA_exception_init (&ev);
205 interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (control)),
206 "IDL:Bonobo/PersistFile:1.0", &ev);
207 CORBA_exception_free (&ev);
208 /* load_through_persist_file (fname, interface); */
215 main (int argc, char **argv)
217 gnome_program_init("test-editor", VERSION, LIBGNOMEUI_MODULE, argc, argv,
218 GNOME_PROGRAM_STANDARD_PROPERTIES,
219 GNOME_PARAM_HUMAN_READABLE_NAME, _("GtkMathView Test Container"),
224 /* We can't make any CORBA calls unless we're in the main loop. So we
225 delay creating the container here. */
226 gtk_idle_add ((GtkFunction) container_create, NULL);
227 if (argc > 1 && *argv [argc - 1] != '-')
228 gtk_idle_add ((GtkFunction) load_file, argv [argc - 1]);
233 return bonobo_ui_debug_shutdown ();