soylent r63 - trunk/src



Author: treitter
Date: Sun Feb 10 05:40:34 2008
New Revision: 63
URL: http://svn.gnome.org/viewvc/soylent?rev=63&view=rev

Log:
add a general utilities function file

Added:
   trunk/src/soylent-utils.c   (contents, props changed)

Added: trunk/src/soylent-utils.c
==============================================================================
--- (empty file)
+++ trunk/src/soylent-utils.c	Sun Feb 10 05:40:34 2008
@@ -0,0 +1,61 @@
+/* 
+ *  Soylent people browser
+ *
+ *  Author: Travis Reitter <treitter-dev netdrain com>
+ *  Author: Rob Taylor <rob taylor codethink co uk>
+ *  Author: Chris Lord <chris o-hand com>
+ *   (Some code copied from Contacts, by Chris Lord)
+ *
+ *  Copyright (c) 2005 OpenedHand Ltd - http://o-hand.com
+ *  Copyright (c) 2007 Codethink Ltd - http://codethink.co.uk
+ *  Copyright (c) 2007 Travis Reitter
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ */
+
+#include "soylent-defs.h"
+#include "soylent-utils.h"
+
+#define G_SIGNAL_HANDLER_MIN_VALID 1
+
+/* Retrieve the named widget from the wtree, then attach the callback and
+ * user_data to the widget's given signal.
+ *
+ * Return TRUE for success, FALSE for any failure */
+gboolean
+widget_signal_connect (GladeXML *wtree, gchar *widget_name, gchar *signal,
+                       gpointer callback, gpointer user_data)
+{
+  gboolean retval = FALSE;
+  GtkWidget *widget = NULL;
+
+  g_return_val_if_fail (wtree != NULL, retval);
+  g_return_val_if_fail (GLADE_IS_XML (wtree), retval);
+  g_return_val_if_fail (widget_name != NULL, retval);
+  g_return_val_if_fail (signal != NULL, retval);
+  g_return_val_if_fail (callback != NULL, retval);
+
+  widget = glade_xml_get_widget (wtree, widget_name);
+  if (widget && GTK_IS_WIDGET (widget))
+    {
+      gint handler_id = -1;
+
+      handler_id = g_signal_connect (G_OBJECT (widget), signal,
+                                     G_CALLBACK (callback), user_data);
+      if (handler_id >= G_SIGNAL_HANDLER_MIN_VALID)
+        {
+          retval = TRUE;
+        }
+    }
+
+  return retval;
+}



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