kov changed libgksu/trunk/ChangeLog, libgksu/trunk/libgksu/libgksu.c, libgksu/trunk/libgksu/libgksu.h

Gustavo Noronha kov at alioth.debian.org
Mon Jan 22 11:08:19 CET 2007


Mensagem de log: 
turn GksuContext into a boxed type; patch by
"Gian Mario Tagliaretti" <g.tagliaretti at gmail.com>


-----


Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog	2007-01-10 07:24:08 UTC (rev 769)
+++ libgksu/trunk/ChangeLog	2007-01-22 10:08:18 UTC (rev 770)
@@ -1,3 +1,11 @@
+2007-01-22  Gustavo Noronha Silva  <kov at debian.org>
+
+	* libgksu/libgksu.[ch]:
+	- accepted patch by "Gian Mario Tagliaretti"
+	  <g.tagliaretti at gmail.com> to turn GksuContext into
+	  a boxed type, so that it can be used in a saner way
+	  in bindings
+
 2007-01-05  Gustavo Noronha Silva  <kov at debian.org>
 
 	* libgksu/libgksu.c:

Modified: libgksu/trunk/libgksu/libgksu.c
===================================================================
--- libgksu/trunk/libgksu/libgksu.c	2007-01-10 07:24:08 UTC (rev 769)
+++ libgksu/trunk/libgksu/libgksu.c	2007-01-22 10:08:18 UTC (rev 770)
@@ -1339,6 +1339,8 @@
 
   context->sn_context = NULL;
   context->sn_id = NULL;
+  
+  context->ref_count = 1;
 
   get_configuration_options (context);
   startup_notification_initialize (context);
@@ -1754,6 +1756,52 @@
 }
 
 /**
+ * gksu_context_ref
+ * @context: A #GksuContext struct.
+ *
+ * Increments the reference count of the given #GksuContext.
+ */
+GksuContext*
+gksu_context_ref (GksuContext *context)
+{
+  context->ref_count++;
+  return context;
+}
+
+/**
+ * gksu_context_unref
+ * @context: A #GksuContext struct.
+ *
+ * Decrements the reference count of the given #GksuContext struct,
+ * freeing it if the reference count falls to zero.
+ */
+void
+gksu_context_unref (GksuContext *context)
+{
+  if (--context->ref_count == 0)
+    {
+        gksu_context_free (context);
+    }
+}
+
+GType
+gksu_context_get_type (void)
+{
+  static GType type_gksu_context = 0;
+
+  if (!type_gksu_context)
+    type_gksu_context = g_boxed_type_register_static
+      ("GksuContext", 
+       (GBoxedCopyFunc) gksu_context_ref,
+       (GBoxedFreeFunc) gksu_context_unref);
+
+  return type_gksu_context;
+}
+
+
+
+
+/**
  * gksu_su_full:
  * @context: a #GksuContext
  * @ask_pass: a #GksuAskPassFunc to be called when the lib determines

Modified: libgksu/trunk/libgksu/libgksu.h
===================================================================
--- libgksu/trunk/libgksu/libgksu.h	2007-01-10 07:24:08 UTC (rev 769)
+++ libgksu/trunk/libgksu/libgksu.h	2007-01-22 10:08:18 UTC (rev 770)
@@ -33,7 +33,8 @@
 
 G_BEGIN_DECLS
 
-typedef struct
+typedef struct _GksuContext GksuContext;
+struct _GksuContext
 {
   /*
    * Protected
@@ -64,10 +65,22 @@
   /* startup notification */
   SnLauncherContext *sn_context;
   gchar *sn_id;
+  
+  /* ref counting */
+  gint ref_count;
 
   gboolean debug;
-} GksuContext;
+};
 
+#define GKSU_TYPE_CONTEXT gksu_context_get_type()
+GType                gksu_context_get_type  (void);
+GksuContext*         gksu_context_new       (void);
+GksuContext*         gksu_context_ref       (GksuContext *context);
+void                 gksu_context_unref     (GksuContext *context);
+
+GType gksu_error_get_type (void);
+#define GKSU_TYPE_ERROR (gksu_error_get_type ())
+
 typedef enum
 {
   GKSU_ERROR_XAUTH,
@@ -94,9 +107,6 @@
 void
 (*GksuPassNotNeededFunc) (GksuContext *context, gpointer user_data);
 
-GksuContext*
-gksu_context_new ();
-
 /*
    getters and setters for the configuration
    options




More information about the gksu-commits mailing list