gshell



Hi!

I'd like to do some work on gshell. I'd like to make gshell's menus
automatically adapt to the control's/embeddable's interfaces. Attached
please find a patch that goes into this direction: If the
control/embeddable provides Bonobo/PersistStream or Bonobo/PersistFile, a
toolbar item for loading streams or files (respectively) gets added to the
toolbar.

I'd like to continue work on this and would like to ask for permission to
check in my changes. Some questions:

(1) Shouldn't there be a ChangeLog in bonobo/gshell? The ChangeLog for
attached patch could be

2001-07-05  Lutz Müller <urc8 rz uni-karlsruhe de>

	* gshell-ui.xml: Add Toolbar with placeholders
	* gshell.c: Scan for provided interfaces and create tool items.
	* inout.[c,h]: Make  buffer_load_p[f,s] public.

(2) I'd really like to move some code around. The naming of objects, files
and functions is a mess. If gshell would be independent of bonobo, it
would be much easier to do those changes (I wouldn't have to bother this
list with rather huge patches...). Why is gshell in bonobo?

Thank you!

Lutz

                                                        \|||/
+------------------------------------------------+      (o o)
| Lutz Müller            +49 (7156) 34837        +---ooO-(_)-Ooo---+
|                                                                  |
| Hans-Sachs-Straße 5                                              |
| 71254 Ditzingen        http://www.uni-karlsruhe.de/~Lutz.Mueller |
| Germany                urc8 rz uni-karlsruhe de                  |
+------------------------------------------------------------------+
Index: gshell-ui.xml
===================================================================
RCS file: /cvs/gnome/bonobo/gshell/gshell-ui.xml,v
retrieving revision 1.1
diff -r1.1 gshell-ui.xml
144a145,151
> 
>   <dockitem name="Toolbar">
>     <placeholder name="FileOperations"/>
>     <placeholder name="ZoomOperations" delimit="top"/>
>     <placeholder name="ConfigurationOperations" delimit="top"/>
>   </dockitem>
> 
Index: gshell.c
===================================================================
RCS file: /cvs/gnome/bonobo/gshell/gshell.c,v
retrieving revision 1.41
diff -r1.41 gshell.c
187a188,328
> typedef enum
> {
> 	INTERFACE_STREAM,
> 	INTERFACE_P_FILE,
> 	INTERFACE_P_STREAM
> } InterfaceType;
> 
> static void
> file_open_cb (GtkWidget *widget, gpointer data)
> {
> 	Buffer *buffer;
> 	gchar *name;
> 
> 	buffer = gtk_object_get_data (GTK_OBJECT (widget), "buffer");
> 	name = g_strdup (gtk_file_selection_get_filename (app.fs));
> 	gtk_widget_destroy (GTK_WIDGET (app.fs));
> 	if (!name)
> 		return;
> 
> 	switch (GPOINTER_TO_INT (data)) {
> 	case INTERFACE_P_STREAM:
> 		buffer_load_ps (buffer, name);
> 		break;
> 	case INTERFACE_STREAM:
> 		g_warning ("Implement INTERFACE_STREAM!");
> 		break;
> 	case INTERFACE_P_FILE:
> 		buffer_load_pf (buffer, name);
> 		break;
> 	}
> 
> 	g_free (name);
> }
> 
> static void
> create_file_selection (const gchar *title, Buffer *buffer, InterfaceType type)
> {
> 	app.fs = GTK_FILE_SELECTION (gtk_file_selection_new (title));
> 	gtk_file_selection_hide_fileop_buttons (app.fs);
> 	gtk_signal_connect_object (GTK_OBJECT (app.fs->cancel_button),
> 				   "clicked",
> 				   GTK_SIGNAL_FUNC (gtk_widget_destroy),
> 				   (gpointer) app.fs);
> 	gtk_object_set_data (GTK_OBJECT (app.fs->ok_button), "buffer", buffer);
> 	gtk_signal_connect (GTK_OBJECT(app.fs->ok_button),
> 			    "clicked",
> 			    GTK_SIGNAL_FUNC (file_open_cb),
> 			    GINT_TO_POINTER (type));
> 	gtk_widget_show (GTK_WIDGET (app.fs));
> 	gtk_window_set_modal (GTK_WINDOW (app.fs), TRUE);
> }
> 
> static void
> verb_LoadStream_cb (BonoboUIComponent *component, gpointer data, const char *cname)
> {
> 	create_file_selection (_("Open Stream"), data, INTERFACE_STREAM);
> }
> 
> static void
> verb_LoadPFile_cb (BonoboUIComponent *component, gpointer data, const char *cname)
> {
> 	create_file_selection (_("Open Persist File"), data, INTERFACE_P_FILE);
> }
> 
> static void
> verb_LoadPStream_cb (BonoboUIComponent *component, gpointer data, const char *cname)
> {
> 	create_file_selection (_("Open Persist Stream"), data, INTERFACE_P_STREAM);
> }
> 
> #define ITEM_LOAD_STREAM 						\
> "<toolitem name=\"LoadStream\" _label=\"Load stream\""			\
> "          _tip=\"Load stream\" verb=\"\""				\
> "          pixtype=\"stock\" pixname=\"Open\"/>"
> 
> #define ITEM_LOAD_P_FILE						\
> "<toolitem name=\"LoadPFile\" _label=\"Load persist file\""		\
> "          _tip=\"Load persist file\" verb=\"\"" 			\
> "          pixtype=\"stock\" pixname=\"Open\"/>"
> 
> #define ITEM_LOAD_P_STREAM						\
> "<toolitem name=\"LoadPStream\" _label=\"Load persist stream\""		\
> "          _tip=\"Load persist stream\" verb=\"\"" 			\
> "          pixtype=\"stock\" pixname=\"Open\"/>"
> 
> #define ITEM_PROPERTIES							\
> "<toolitem name=\"Properties\" _label=\"Properties\""			\
> "          _tip=\"Properties\" verb=\"\""				\
> "          pixtype=\"stock\" pixname=\"Book Red\"/>"
> 
> static void
> buffer_show_menu (Buffer *buffer, Frame *frame, Bonobo_Control control)
> {
> 	g_return_if_fail (buffer);
> 	g_return_if_fail (frame);
> 	g_return_if_fail (control);
> 
> 	/* Scan for Bonobo/Stream:1.0 */
> 	if (bonobo_object_client_has_interface (buffer->server,
> 						"IDL:Bonobo/Stream:1.0",
> 						NULL)) {
> 		bonobo_ui_component_set_translate (frame->component,
> 						   "/Toolbar/FileOperations",
> 						   ITEM_LOAD_STREAM, NULL);
> 		bonobo_ui_component_add_verb (frame->component,
> 					      "LoadStream", 
> 					      verb_LoadStream_cb, buffer);
> 	}
> 
> 	/* Scan for Bonobo/PersistFile */
> 	if (bonobo_object_client_has_interface (buffer->server,
> 						"IDL:Bonobo/PersistFile:1.0",
> 						NULL)) {
> 		bonobo_ui_component_set_translate (frame->component, 
> 						   "/Toolbar/FileOperations",
> 						   ITEM_LOAD_P_FILE, NULL);
> 		bonobo_ui_component_add_verb (frame->component,
> 					      "LoadPFile",
> 					      verb_LoadPFile_cb, buffer);
> 	}
> 
> 	/* Scan for Bonobo/PersistStream */
> 	if (bonobo_object_client_has_interface (buffer->server,
> 				"IDL:Bonobo/PersistStream:1.0", NULL)) {
> 		bonobo_ui_component_set_translate (frame->component,
> 						   "/Toolbar/FileOperations",
> 						   ITEM_LOAD_P_STREAM, NULL);
> 		bonobo_ui_component_add_verb (frame->component,
> 					      "LoadPStream", 
> 					      verb_LoadPStream_cb, buffer);
> 	}
> 
> 	/* Scan for Bonobo/PropertyControl */
> 	if (bonobo_object_client_has_interface (buffer->server,
> 				"IDL:Bonobo/PropertyControl:1.0", NULL)) {
> 		bonobo_ui_component_set_translate (frame->component,
> 					   "/Toolbar/ConfigurationOperations", 
> 					   ITEM_PROPERTIES, NULL);
> 	}
> }
> 
190a332
> 	Bonobo_Control control;
232a375,378
> 
> 	/* Scan for supported interfaces */
> 	control = bonobo_control_frame_get_control (BONOBO_CONTROL_FRAME (view_frame));
> 	buffer_show_menu (buffer, frame, control);
349a496,499
> 
> 	bonobo_ui_component_rm (frame->component, "/Toolbar/FileOperations/*", NULL);
> 	bonobo_ui_component_rm (frame->component, "/Toolbar/ZoomOperations/*", NULL);
> 	bonobo_ui_component_rm (frame->component, "/Toolbar/ConfigurationOperations/*", NULL);
Index: inout.c
===================================================================
RCS file: /cvs/gnome/bonobo/gshell/inout.c,v
retrieving revision 1.25
diff -r1.25 inout.c
66,67c66,67
< static void
< buffer_load_pf (Buffer *buffer, gchar *filename)
---
> void
> buffer_load_pf (Buffer *buffer, const gchar *filename)
163,164c163,164
< static void
< buffer_load_ps (Buffer *buffer, gchar *filename)
---
> void
> buffer_load_ps (Buffer *buffer, const gchar *filename)
Index: inout.h
===================================================================
RCS file: /cvs/gnome/bonobo/gshell/inout.h,v
retrieving revision 1.6
diff -r1.6 inout.h
14a15,17
> void buffer_load_pf (Buffer *buffer, const gchar *filename);
> void buffer_load_ps (Buffer *buffer, const gchar *filename);
> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]