gnome-utils r8155 - trunk/logview



Author: cosimoc
Date: Wed Oct 22 11:23:58 2008
New Revision: 8155
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8155&view=rev

Log:
Use G_DEFINE_TYPE macros.

Modified:
   trunk/logview/calendar.c
   trunk/logview/loglist.c
   trunk/logview/logview-findbar.c
   trunk/logview/logview.c

Modified: trunk/logview/calendar.c
==============================================================================
--- trunk/logview/calendar.c	(original)
+++ trunk/logview/calendar.c	Wed Oct 22 11:23:58 2008
@@ -24,8 +24,7 @@
 #include "logview.h"
 #include "calendar.h"
 
-static GObjectClass *parent_class;
-GType calendar_get_type (void);
+G_DEFINE_TYPE (Calendar, calendar, GTK_TYPE_CALENDAR);
 
 struct CalendarPriv
 {
@@ -157,22 +156,19 @@
 }
 
 static void 
-calendar_init (GtkCalendar *widget)
+calendar_init (Calendar *calendar)
 {
-    Calendar *calendar = CALENDAR (widget);
     PangoFontDescription *fontdesc;
     PangoContext *context;
     int size;
 
-    g_assert (IS_CALENDAR (calendar));
-
     calendar->priv = g_new0 (CalendarPriv, 1);
     
-    context = gtk_widget_get_pango_context (GTK_WIDGET(widget));
+    context = gtk_widget_get_pango_context (GTK_WIDGET (calendar));
     fontdesc = pango_context_get_font_description (context);
     size = pango_font_description_get_size (fontdesc) / PANGO_SCALE;
     pango_font_description_set_size (fontdesc, (size-2)*PANGO_SCALE);
-    gtk_widget_modify_font (GTK_WIDGET (widget), fontdesc);
+    gtk_widget_modify_font (GTK_WIDGET (calendar), fontdesc);
 }
 
 static void
@@ -180,39 +176,14 @@
 {
     Calendar *calendar = CALENDAR (object);
     g_free (calendar->priv);
-	parent_class->finalize (object);
+    G_OBJECT_CLASS (calendar_parent_class)->finalize (object);
 }
 
 static void
 calendar_class_init (CalendarClass *klass)
 {
-	GObjectClass *object_class = (GObjectClass *) klass;
+    GObjectClass *object_class = (GObjectClass *) klass;
     object_class->finalize = calendar_class_finalize;
-	parent_class = g_type_class_peek_parent (klass);
-}
-
-GType
-calendar_get_type (void)
-{
-	static GType object_type = 0;
-	
-	if (!object_type) {
-		static const GTypeInfo object_info = {
-			sizeof (CalendarClass),
-			NULL,		/* base_init */
-			NULL,		/* base_finalize */
-			(GClassInitFunc) calendar_class_init,
-			NULL,		/* class_finalize */
-			NULL,		/* class_data */
-			sizeof (Calendar),
-			0,              /* n_preallocs */
-			(GInstanceInitFunc) calendar_init
-		};
-
-		object_type = g_type_register_static (GTK_TYPE_CALENDAR, "Calendar", &object_info, 0);
-	}
-
-	return object_type;
 }
 
 GtkWidget *

Modified: trunk/logview/loglist.c
==============================================================================
--- trunk/logview/loglist.c	(original)
+++ trunk/logview/loglist.c	Wed Oct 22 11:23:58 2008
@@ -28,9 +28,6 @@
 	GtkTreeStore *model;
 };
 
-static GObjectClass *parent_class;
-GType loglist_get_type (void);
-
 enum {
 	LOG_NAME = 0,
 	LOG_POINTER,
@@ -38,6 +35,8 @@
 	LOG_WEIGHT_SET
 };
 
+G_DEFINE_TYPE (LogList, loglist, GTK_TYPE_TREE_VIEW);
+
 static GtkTreePath *
 loglist_find_directory (LogList *list, gchar *dir)
 {
@@ -306,41 +305,16 @@
 {
 	LogList *list = LOG_LIST (object);
 	g_free (list->priv);
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (loglist_parent_class)->finalize (object);
 }
 
 static void
 loglist_class_init (LogListClass *klass)
 {
 	GObjectClass *object_class = (GObjectClass *) klass;
-	parent_class = g_type_class_peek_parent (klass);
 	object_class->finalize = loglist_finalize;
 }
 
-GType
-loglist_get_type (void)
-{
-	static GType object_type = 0;
-	
-	if (!object_type) {
-		static const GTypeInfo object_info = {
-			sizeof (LogListClass),
-			NULL,		/* base_init */
-			NULL,		/* base_finalize */
-			(GClassInitFunc) loglist_class_init,
-			NULL,/* class_finalize */
-			NULL,		/* class_data */
-			sizeof (LogList),
-			0,              /* n_preallocs */
-			(GInstanceInitFunc) loglist_init
-		};
-
-		object_type = g_type_register_static (GTK_TYPE_TREE_VIEW, "LogList", &object_info, 0);
-	}
-
-	return object_type;
-}
-
 GtkWidget *
 loglist_new (void)
 {

Modified: trunk/logview/logview-findbar.c
==============================================================================
--- trunk/logview/logview-findbar.c	(original)
+++ trunk/logview/logview-findbar.c	Wed Oct 22 11:23:58 2008
@@ -31,8 +31,7 @@
 	gpointer logview;
 };
 
-static GObjectClass *parent_class;
-GType logview_findbar_get_type (void);
+G_DEFINE_TYPE (LogviewFindBar, logview_findbar, GTK_TYPE_HBOX);
 
 static gboolean
 iter_is_visible (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -169,7 +168,7 @@
 	LogviewFindBar *findbar = LOGVIEW_FINDBAR (object);
 
 	g_free (findbar->priv);
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (logview_findbar_parent_class)->finalize (object);
 }
 
 static void
@@ -178,31 +177,6 @@
 	GObjectClass *object_class = (GObjectClass *) klass;
 
 	object_class->finalize = logview_findbar_finalize;
-	parent_class = g_type_class_peek_parent (klass);
-}
-
-GType
-logview_findbar_get_type (void)
-{
-	static GType object_type = 0;
-	
-	if (!object_type) {
-		static const GTypeInfo object_info = {
-			sizeof (LogviewFindBarClass),
-			NULL,		/* base_init */
-			NULL,		/* base_finalize */
-			(GClassInitFunc) logview_findbar_class_init,
-			NULL,		/* class_finalize */
-			NULL,		/* class_data */
-			sizeof (LogviewFindBar),
-			0,              /* n_preallocs */
-			(GInstanceInitFunc) logview_findbar_init
-		};
-
-		object_type = g_type_register_static (GTK_TYPE_HBOX, "LogviewFindBar", &object_info, 0);
-	}
-
-	return object_type;
 }
 
 GtkWidget *

Modified: trunk/logview/logview.c
==============================================================================
--- trunk/logview/logview.c	(original)
+++ trunk/logview/logview.c	Wed Oct 22 11:23:58 2008
@@ -48,12 +48,10 @@
   LOG_LINE_WEIGHT_SET
 };
 
-static GObjectClass *parent_class;
+G_DEFINE_TYPE (LogviewWindow, logview_window, GTK_TYPE_WINDOW);
 
 /* Function Prototypes */
 
-GType logview_window_get_type (void);
-
 static void logview_save_prefs (LogviewWindow *logview);
 static void logview_add_log (LogviewWindow *logview, Log *log);
 static void logview_menu_item_set_state (LogviewWindow *logview, char *path, gboolean state);
@@ -792,11 +790,11 @@
     LogviewWindow *logview = LOGVIEW_WINDOW(object);
 
     g_object_unref (logview->ui_manager);
-    parent_class->finalize (object);
+    G_OBJECT_CLASS (logview_window_parent_class)->finalize (object);
 }
 
 static void
-logview_init (LogviewWindow *logview)
+logview_window_init (LogviewWindow *logview)
 {
    GtkWidget *vbox;
    GtkTreeStore *tree_store;
@@ -968,7 +966,6 @@
 
 	object_class->finalize = logview_window_finalize;
 	object_class->get_property = logview_window_get_property;
-	parent_class = g_type_class_peek_parent (klass);
 
 	g_object_class_install_property (object_class, PROP_DAYS,
 					 g_param_spec_pointer ("days",
@@ -977,30 +974,6 @@
 					 (G_PARAM_READABLE)));
 }
 
-GType
-logview_window_get_type (void)
-{
-	static GType object_type = 0;
-	
-	if (!object_type) {
-		static const GTypeInfo object_info = {
-			sizeof (LogviewWindowClass),
-			NULL,		/* base_init */
-			NULL,		/* base_finalize */
-			(GClassInitFunc) logview_window_class_init,
-			NULL,		/* class_finalize */
-			NULL,		/* class_data */
-			sizeof (LogviewWindow),
-			0,              /* n_preallocs */
-			(GInstanceInitFunc) logview_init
-		};
-
-		object_type = g_type_register_static (GTK_TYPE_WINDOW, "LogviewWindow", &object_info, 0);
-	}
-
-	return object_type;
-}
-
 GtkWidget *
 logview_window_new ()
 {



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