After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 131403 - interface request
interface request
Status: RESOLVED WONTFIX
Product: libglade
Classification: Deprecated
Component: gtk
CVS HEAD
Other All
: Normal enhancement
: libglade-2.6
Assigned To: James Henstridge
James Henstridge
Depends on:
Blocks:
 
 
Reported: 2004-01-14 03:36 UTC by Todd A. Fisher
Modified: 2011-07-19 23:28 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
sorry i included this in the bug report its my first time submitting a patch this was generated using cvs diff -hpw >with-data.patch (4.85 KB, patch)
2004-01-14 03:40 UTC, Todd A. Fisher
none Details | Review

Description Todd A. Fisher 2004-01-14 03:36:42 UTC
currently there is a glade_xml_autoconnect i have a simple patch that
adds to the lastest cvs head as of 01-13-2004 that adds a 
glade_xml_autoconnect_with_data.  
The addition of this function allows users to in one line connect all the 
functions of a .glade file ensuring that the gpointer user_data parameter
is not null and meaninful.  This same thing can be achieved through
the exisiting interface but using glade_xml_autoconnect is very convient
and can actually be useful given the programmer can pass a parameter. It
can be used as follows:

tyedef struct WidgetFooControler{
/* important state information */
}FooObject;

int main( int argc,char **argv )
{
  GladeXML *xml;
  FooObject foo;
  gtk_init( &argc, &argv );
  xml = glade_xml_new( "gui.xml", "widget-foo", NULL );
  glade_xml_autoconnect_with_data( xml, &foo );
...
  gtk_main();
  return 0;
}

the patch:
##########################################################################
? with-data.patch
Index: glade/glade-xml.c
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-xml.c,v
retrieving revision 1.104
diff -h -p -w -r1.104 glade-xml.c
*** glade/glade-xml.c	23 Jul 2003 14:48:48 -0000	1.104
--- glade/glade-xml.c	14 Jan 2004 03:21:53 -0000
*************** glade_xml_signal_connect (GladeXML *self
*** 270,305 ****
  	}
      }
  }
  
  static void
  autoconnect_foreach(const char *signal_handler, GList *signals,
! 		    GModule *allsymbols)
  {
      GCallback func;
  
!     if (!g_module_symbol(allsymbols, signal_handler, (gpointer *)&func))
  	g_warning("could not find signal handler '%s'.", signal_handler);
!     else
  	for (; signals != NULL; signals = signals->next) {
  	    GladeSignalData *data = signals->data;
  	    if (data->connect_object) {
! 		GladeXML *self = glade_get_widget_tree(
! 					GTK_WIDGET(data->signal_object));
! 		GObject *other = g_hash_table_lookup(self->priv->name_hash,
! 						       data->connect_object);
  
  		g_signal_connect_object(data->signal_object, data->signal_name,
! 			func, other, (data->signal_after ? G_CONNECT_AFTER : 0)
! 					| G_CONNECT_SWAPPED);
  	    } else {
  		/* the signal_data argument is just a string, but may
  		 * be helpful for someone */
! 		if (data->signal_after)
  		    g_signal_connect_after(data->signal_object,
! 					   data->signal_name, func, NULL);
! 		else
! 		    g_signal_connect(data->signal_object, data->signal_name,
! 				     func, NULL);
  	    }
  	}
  }
--- 270,313 ----
  	}
      }
  }
+ typedef struct _AutoConnect{
+ 	GModule *allsymbols;
+ 	gpointer user_data;
+ }AutoConnect;
  
  static void
  autoconnect_foreach(const char *signal_handler, GList *signals,
! 								    AutoConnect *auto_connect )
  {
  	GCallback func;
  
! 	if( !g_module_symbol( auto_connect->allsymbols, signal_handler,
(gpointer*)&func ) ){
  		g_warning("could not find signal handler '%s'.", signal_handler);
! 	}
! 	else{
  		for( ; signals != NULL; signals = signals->next ){
  			GladeSignalData *data = signals->data;
  			if( data->connect_object ){
! 				GladeXML *self = glade_get_widget_tree( GTK_WIDGET(data->signal_object));
! 				GObject *other = g_hash_table_lookup(self->priv->name_hash,
data->connect_object);
  	
  				g_signal_connect_object( data->signal_object, data->signal_name,
! 							func, other, 
! 							(data->signal_after ? G_CONNECT_AFTER : 0) | 
! 							G_CONNECT_SWAPPED );
  			}else{
  			/* the signal_data argument is just a string, but may
  			 * be helpful for someone */
! 				if( data->signal_after ){
  					g_signal_connect_after( data->signal_object,
! 								data->signal_name, func, 
! 								auto_connect->user_data );
! 				}
! 				else{
! 					g_signal_connect( data->signal_object, data->signal_name, func,
auto_connect->user_data );
! 				}
! 			}
! 			gtk_widget_show( GTK_WIDGET( data->signal_object ) );
  		}
  	}
  }
*************** autoconnect_foreach(const char *signal_h
*** 318,335 ****
   * supported on the platform.
   */
  void
! glade_xml_signal_autoconnect (GladeXML *self)
  {
!     GModule *allsymbols;
  
      g_return_if_fail(self != NULL);
!     if (!g_module_supported())
! 	g_error("glade_xml_signal_autoconnect requires working gmodule");
  
      /* get a handle on the main executable -- use this to find symbols */
!     allsymbols = g_module_open(NULL, 0);
!     g_hash_table_foreach(self->priv->signals, (GHFunc)autoconnect_foreach,
! 			 allsymbols);
  }
  
  
--- 326,351 ----
   * supported on the platform.
   */
  void       
! glade_xml_signal_autoconnect_with_data( GladeXML *self, gpointer user_data )
  {
! 	AutoConnect conn;
  
  	g_return_if_fail(self != NULL);
! 	
! 	if (!g_module_supported()){
! 			g_error("glade_xml_signal_autoconnect_with_data requires working
gmodule");
! 	}
  
  	/* get a handle on the main executable -- use this to find symbols */
! 	conn.allsymbols = g_module_open(NULL, 0);
! 	conn.user_data  = user_data;
! 
! 	g_hash_table_foreach(self->priv->signals, (GHFunc)autoconnect_foreach,
&conn );
! }
! void
! glade_xml_signal_autoconnect (GladeXML *self)
! {
! 	glade_xml_signal_autoconnect_with_data( self, NULL );
  }
  
  
Index: glade/glade-xml.h
===================================================================
RCS file: /cvs/gnome/libglade/glade/glade-xml.h,v
retrieving revision 1.31
diff -h -p -w -r1.31 glade-xml.h
*** glade/glade-xml.h	26 Apr 2002 14:55:31 -0000	1.31
--- glade/glade-xml.h	14 Jan 2004 03:21:53 -0000
*************** void       glade_xml_signal_connect_data
*** 80,85 ****
--- 80,86 ----
   * for the destroy signal of a window will do what you expect.
   */
  void       glade_xml_signal_autoconnect  (GladeXML *self);
+ void       glade_xml_signal_autoconnect_with_data  (GladeXML *self,
gpointer user_data );
  
  /* if the gtk_signal_connect_object behaviour is required, connect_object
   * will point to the object, otherwise it will be NULL.
Comment 1 Todd A. Fisher 2004-01-14 03:40:01 UTC
Created attachment 23342 [details] [review]
sorry i included this in the bug report its my first time submitting a patch this was generated using cvs diff -hpw >with-data.patch
Comment 2 Murray Cumming 2004-01-14 16:14:49 UTC
I am not a libglade maintainer, but people generally prefer -up
patches, and they like the ChangeLog to be patched.
Comment 3 Luis Villa 2005-01-22 17:28:12 UTC
Todd: FWIW, GNOME milestone shouldn't be set unless the bug is a blocker for the
release. I've added a libglade 2.6 milestone and put this bug on it. Thanks for
the patch- I hope james gets a chance to look at it shortly.
Comment 4 Fabio Durán Verdugo 2011-07-19 23:28:08 UTC
The GNOME Release team has officially deprecated libglade in favor of GtkBuilder[1]. So it's unlikely to get further development. I am closing bugs as WONTFIX. Please feel free to reopen the bugs in future if anyone takes the responsibility for active development.

[1] http://permalink.gmane.org/gmane.comp.gnome.devel.announce/28