Changeset 76 for gtkimageview/src

Show
Ignore:
Timestamp:
04/17/07 19:48:42 (6 years ago)
Author:
bjourne
Message:

Patch by Ross Burton fixes #2: Use the G_DEFINE_TYPE macro to remove lots of boilerplate GObject code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/src/gtkimagenav.c

    r73 r76  
    2121#include <math.h> 
    2222 
    23 /*************************************************************/ 
    24 /***** Private data ******************************************/ 
    25 /*************************************************************/ 
    26 static GtkWidgetClass *parent_class = NULL; 
    27  
     23 
     24G_DEFINE_TYPE (GtkImageNav, gtk_image_nav, GTK_TYPE_WINDOW); 
    2825 
    2926/*************************************************************/ 
     
    251248gtk_image_nav_realize (GtkWidget *widget) 
    252249{ 
    253     GTK_WIDGET_CLASS (parent_class)->realize (widget); 
     250    GTK_WIDGET_CLASS (gtk_image_nav_parent_class)->realize (widget); 
    254251    GtkImageNav *nav = GTK_IMAGE_NAV (widget); 
    255252    nav->gc = gdk_gc_new (widget->window); 
     
    266263{ 
    267264    g_object_unref (GTK_IMAGE_NAV (widget)->gc); 
    268     GTK_WIDGET_CLASS (parent_class)->unrealize (widget); 
     265    GTK_WIDGET_CLASS (gtk_image_nav_parent_class)->unrealize (widget); 
    269266} 
    270267 
     
    311308         
    312309        /* Chain up. */ 
    313         G_OBJECT_CLASS (parent_class)->finalize (object); 
     310        G_OBJECT_CLASS (gtk_image_nav_parent_class)->finalize (object); 
    314311} 
    315312 
     
    317314gtk_image_nav_class_init (GtkImageNavClass *klass) 
    318315{ 
    319         parent_class = g_type_class_peek_parent (klass); 
    320  
    321316        GObjectClass *object_class = G_OBJECT_CLASS (klass); 
    322317        object_class->finalize = gtk_image_nav_finalize; 
     
    361356} 
    362357 
    363 /** 
    364  * gtk_image_nav_get_type: 
    365  * @returns: The unique type identifier for this registered type. 
    366  **/ 
    367 GType 
    368 gtk_image_nav_get_type (void) 
    369 { 
    370         static GType our_type = 0; 
    371     if (our_type) 
    372         return our_type; 
    373     GTypeInfo our_info = { 
    374         sizeof (GtkImageNavClass), 
    375         NULL, 
    376         NULL, 
    377         (GClassInitFunc) gtk_image_nav_class_init, 
    378         NULL, 
    379         NULL, 
    380         sizeof (GtkImageNav), 
    381         0, 
    382         (GInstanceInitFunc) gtk_image_nav_init 
    383     }; 
    384     our_type = g_type_register_static (GTK_TYPE_WINDOW, 
    385                                        "GtkImageNav", 
    386                                        &our_info, 
    387                                        0); 
    388     return our_type; 
    389 } 
    390  
    391358 
    392359/*************************************************************/ 
  • gtkimageview/src/gtkimagescrollwin.c

    r67 r76  
    2424/***** PRIVATE DATA ******************************************/ 
    2525/*************************************************************/ 
    26 static GtkWidgetClass *parent_class = NULL; 
    2726 
    2827static char *nav_button_xpm[] = { 
     
    4645}; 
    4746 
     47G_DEFINE_TYPE(GtkImageScrollWin, gtk_image_scroll_win, GTK_TYPE_HBOX); 
    4848 
    4949/*************************************************************/ 
     
    127127         
    128128    /* Chain up. */ 
    129     G_OBJECT_CLASS (parent_class)->finalize (object); 
     129    G_OBJECT_CLASS (gtk_image_scroll_win_parent_class)->finalize (object); 
    130130} 
    131131 
     
    133133gtk_image_scroll_win_class_init (GtkImageScrollWinClass *klass) 
    134134{ 
    135     parent_class = g_type_class_peek_parent (klass); 
    136  
    137135    GObjectClass *object_class = G_OBJECT_CLASS (klass); 
    138136    object_class->finalize = gtk_image_scroll_win_finalize; 
     
    216214} 
    217215 
    218 /** 
    219  * gtk_image_scroll_win_get_type: 
    220  * 
    221  * Returns the unique type identifier for this registered type. 
    222  **/ 
    223 GType 
    224 gtk_image_scroll_win_get_type (void) 
    225 { 
    226     static GType our_type = 0; 
    227     if (our_type) 
    228         return our_type; 
    229     GTypeInfo our_info = { 
    230         sizeof (GtkImageScrollWinClass), 
    231         NULL, 
    232         NULL, 
    233         (GClassInitFunc) gtk_image_scroll_win_class_init, 
    234         NULL, 
    235         NULL, 
    236         sizeof (GtkImageScrollWin), 
    237         0, 
    238         (GInstanceInitFunc) gtk_image_scroll_win_init 
    239     }; 
    240     our_type = g_type_register_static (GTK_TYPE_HBOX, 
    241                                        "GtkImageScrollWin", 
    242                                        &our_info, 
    243                                        0); 
    244     return our_type; 
    245 } 
    246  
    247216/*************************************************************/ 
    248217/***** Read-only properties **********************************/ 
  • gtkimageview/src/gtkimageview.c

    r73 r76  
    5454}; 
    5555 
    56 static GtkWidgetClass *parent_class = NULL; 
    5756static guint gtk_image_view_signals[LAST_SIGNAL] = {0}; 
    5857 
     58G_DEFINE_TYPE(GtkImageView, gtk_image_view, GTK_TYPE_WIDGET); 
    5959 
    6060/*************************************************************/ 
     
    532532    gdk_cursor_unref (view->void_cursor);     
    533533    g_free (view->mouse_handler); 
    534     GTK_WIDGET_CLASS (parent_class)->unrealize (widget); 
     534    GTK_WIDGET_CLASS (gtk_image_view_parent_class)->unrealize (widget); 
    535535} 
    536536 
     
    745745    } 
    746746    /* Chain up. */ 
    747     G_OBJECT_CLASS (parent_class)->finalize (object); 
     747    G_OBJECT_CLASS (gtk_image_view_parent_class)->finalize (object); 
    748748} 
    749749 
     
    874874    gtk_image_view_init_signals (klass); 
    875875 
    876     parent_class = g_type_class_peek_parent (klass); 
    877      
    878876    GObjectClass *object_class = G_OBJECT_CLASS (klass); 
    879877    object_class->finalize = gtk_image_view_finalize; 
     
    10311029} 
    10321030 
    1033 /** 
    1034  * gtk_image_view_get_type: 
    1035  * 
    1036  * @returns: The unique type identifier for this registered type. 
    1037  **/ 
    1038 GType 
    1039 gtk_image_view_get_type (void) 
    1040 { 
    1041     static GType our_type = 0; 
    1042     if (our_type) 
    1043         return our_type; 
    1044      
    1045     GTypeInfo our_info = { 
    1046         sizeof (GtkImageViewClass), 
    1047         NULL, 
    1048         NULL, 
    1049         (GClassInitFunc) gtk_image_view_class_init, 
    1050         NULL, 
    1051         NULL, 
    1052         sizeof (GtkImageView), 
    1053         0, 
    1054         (GInstanceInitFunc) gtk_image_view_init 
    1055     }; 
    1056     our_type = g_type_register_static (GTK_TYPE_WIDGET, 
    1057                                        "GtkImageView", 
    1058                                        &our_info, 
    1059                                        0); 
    1060     return our_type; 
    1061 } 
    1062  
    10631031/*************************************************************/ 
    10641032/***** Read-only properties **********************************/