SF.net SVN: geany: [2184] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Jan 23 13:35:11 UTC 2008


Revision: 2184
          http://geany.svn.sourceforge.net/geany/?rev=2184&view=rev
Author:   eht16
Date:     2008-01-23 05:35:08 -0800 (Wed, 23 Jan 2008)

Log Message:
-----------
Move class and label structs to geanywraplabel.c.
Override widget functions instead of using event handlers (trying to fix #1869399).	 

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/geanywraplabel.c
    trunk/src/geanywraplabel.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-01-22 15:19:36 UTC (rev 2183)
+++ trunk/ChangeLog	2008-01-23 13:35:08 UTC (rev 2184)
@@ -1,3 +1,11 @@
+2008-01-23  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/geanywraplabel.c, src/geanywraplabel.h:
+   Move class and label structs to geanywraplabel.c.
+   Override widget functions instead of using event handlers
+   (trying to fix #1869399).
+
+
 2008-01-22  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * THANKS, src/about.c, po/el.po, po/LINGUAS:

Modified: trunk/src/geanywraplabel.c
===================================================================
--- trunk/src/geanywraplabel.c	2008-01-22 15:19:36 UTC (rev 2183)
+++ trunk/src/geanywraplabel.c	2008-01-23 13:35:08 UTC (rev 2184)
@@ -29,6 +29,7 @@
 
 #include <gtk/gtklabel.h>
 #include "geanywraplabel.h"
+#include "utils.h"
 
 
 /* Local data */
@@ -39,15 +40,29 @@
 #define GEANY_WRAP_LABEL_GET_PRIVATE(obj)		(G_TYPE_INSTANCE_GET_PRIVATE((obj),\
 	GEANY_WRAP_LABEL_TYPE, GeanyWrapLabelPrivate))
 
+
+struct _GeanyWrapLabelClass
+{
+	GtkLabelClass parent_class;
+};
+
+struct _GeanyWrapLabel
+{
+	GtkLabel parent;
+};
+
 typedef struct
 {
 	gsize wrap_width;
 } GeanyWrapLabelPrivate;
 
 
-static void geany_wrap_label_class_init	(GeanyWrapLabelClass *klass);
-static void geany_wrap_label_init		(GeanyWrapLabel *self);
-static void geany_wrap_label_finalize	(GObject *object);
+static void geany_wrap_label_class_init		(GeanyWrapLabelClass *klass);
+static void geany_wrap_label_init			(GeanyWrapLabel *self);
+static void geany_wrap_label_finalize		(GObject *object);
+static void geany_wrap_label_size_request	(GtkWidget *widget, GtkRequisition *req);
+static void geany_wrap_label_size_allocate	(GtkWidget *widget, GtkAllocation *alloc);
+static void geany_wrap_label_set_wrap_width	(GtkWidget *widget, gsize width);
 
 
 
@@ -78,12 +93,15 @@
 
 static void geany_wrap_label_class_init(GeanyWrapLabelClass *klass)
 {
-	GObjectClass *g_object_class;
+	GObjectClass *g_object_class = G_OBJECT_CLASS(klass);
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
 
-	g_object_class = G_OBJECT_CLASS(klass);
 	g_object_class->finalize = geany_wrap_label_finalize;
 
-	parent_class = (GObjectClass*) g_type_class_peek(G_TYPE_OBJECT);
+	parent_class = g_type_class_peek_parent(klass);
+	widget_class->size_request = geany_wrap_label_size_request;
+	widget_class->size_allocate = geany_wrap_label_size_allocate;
+
 	g_type_class_add_private(klass, sizeof (GeanyWrapLabelPrivate));
 }
 
@@ -114,6 +132,7 @@
 static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gsize width)
 {
 	GeanyWrapLabelPrivate *priv;
+
 	if (width == 0)
 		return;
 
@@ -134,7 +153,7 @@
 
 /* Forces the height to be the size necessary for the Pango layout, while allowing the
  * width to be flexible. */
-static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req, gpointer data)
+static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req)
 {
 	gint height;
 
@@ -145,10 +164,10 @@
 }
 
 
-/* Sets the wrap width to the be width allocated to us. */
-static void geany_wrap_label_size_allocate(GtkWidget *widget, GtkAllocation *alloc, gpointer data)
+/* Sets the wrap width to the width allocated to us. */
+static void geany_wrap_label_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
 {
-	gtk_widget_size_allocate(widget, alloc);
+	(* GTK_WIDGET_CLASS(parent_class)->size_allocate)(widget, alloc);
 
 	geany_wrap_label_set_wrap_width(widget, alloc->width);
 }
@@ -167,13 +186,11 @@
 {
 	GtkWidget *l = g_object_new(GEANY_WRAP_LABEL_TYPE, NULL);
 
-	gtk_label_set_text(GTK_LABEL(l), text);
+	if (NZV(text))
+		gtk_label_set_text(GTK_LABEL(l), text);
+
 	pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(l)), PANGO_WRAP_WORD_CHAR);
 	gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.0);
 
-	// this is a little ugly but it works (we can't override the default handlers in C)
-	g_signal_connect(l, "size-allocate", G_CALLBACK(geany_wrap_label_size_allocate), NULL);
-	g_signal_connect(l, "size-request", G_CALLBACK(geany_wrap_label_size_request), NULL);
-
 	return l;
 }

Modified: trunk/src/geanywraplabel.h
===================================================================
--- trunk/src/geanywraplabel.h	2008-01-22 15:19:36 UTC (rev 2183)
+++ trunk/src/geanywraplabel.h	2008-01-23 13:35:08 UTC (rev 2184)
@@ -41,16 +41,6 @@
 typedef struct _GeanyWrapLabel       GeanyWrapLabel;
 typedef struct _GeanyWrapLabelClass  GeanyWrapLabelClass;
 
-struct _GeanyWrapLabel
-{
-	GtkLabel parent;
-};
-
-struct _GeanyWrapLabelClass
-{
-	GtkLabelClass parent_class;
-};
-
 GType			geany_wrap_label_get_type			(void);
 GtkWidget*		geany_wrap_label_new				(const gchar *text);
 void			geany_wrap_label_set_text			(GtkLabel *label, const gchar *text);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list