Mercurial > pidgin.yaz
comparison finch/libgnt/gntbox.c @ 21261:7f1910f62246
Add properties to boxes. This is the Right Way of doing things.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 24 Oct 2007 10:14:58 +0000 |
parents | 9187d331aebe |
children | 4c03275346a9 |
comparison
equal
deleted
inserted
replaced
21260:084c5d5472ad | 21261:7f1910f62246 |
---|---|
22 | 22 |
23 #include "gntbox.h" | 23 #include "gntbox.h" |
24 #include "gntutils.h" | 24 #include "gntutils.h" |
25 | 25 |
26 #include <string.h> | 26 #include <string.h> |
27 | |
28 enum | |
29 { | |
30 PROP_0, | |
31 PROP_VERTICAL, | |
32 PROP_HOMO /* ... */ | |
33 }; | |
27 | 34 |
28 enum | 35 enum |
29 { | 36 { |
30 SIGS = 1, | 37 SIGS = 1, |
31 }; | 38 }; |
509 } | 516 } |
510 return FALSE; | 517 return FALSE; |
511 } | 518 } |
512 | 519 |
513 static void | 520 static void |
521 gnt_box_set_property(GObject *obj, guint prop_id, const GValue *value, | |
522 GParamSpec *spec) | |
523 { | |
524 GntBox *box = GNT_BOX(obj); | |
525 switch (prop_id) { | |
526 case PROP_VERTICAL: | |
527 box->vertical = g_value_get_boolean(value); | |
528 break; | |
529 case PROP_HOMO: | |
530 box->homogeneous = g_value_get_boolean(value); | |
531 break; | |
532 default: | |
533 g_return_if_reached(); | |
534 break; | |
535 } | |
536 } | |
537 | |
538 static void | |
539 gnt_box_get_property(GObject *obj, guint prop_id, GValue *value, | |
540 GParamSpec *spec) | |
541 { | |
542 GntBox *box = GNT_BOX(obj); | |
543 switch (prop_id) { | |
544 case PROP_VERTICAL: | |
545 g_value_set_boolean(value, box->vertical); | |
546 break; | |
547 case PROP_HOMO: | |
548 g_value_set_boolean(value, box->homogeneous); | |
549 break; | |
550 default: | |
551 break; | |
552 } | |
553 } | |
554 | |
555 static void | |
514 gnt_box_class_init(GntBoxClass *klass) | 556 gnt_box_class_init(GntBoxClass *klass) |
515 { | 557 { |
558 GObjectClass *gclass = G_OBJECT_CLASS(klass); | |
516 parent_class = GNT_WIDGET_CLASS(klass); | 559 parent_class = GNT_WIDGET_CLASS(klass); |
517 parent_class->destroy = gnt_box_destroy; | 560 parent_class->destroy = gnt_box_destroy; |
518 parent_class->draw = gnt_box_draw; | 561 parent_class->draw = gnt_box_draw; |
519 parent_class->expose = gnt_box_expose; | 562 parent_class->expose = gnt_box_expose; |
520 parent_class->map = gnt_box_map; | 563 parent_class->map = gnt_box_map; |
525 parent_class->lost_focus = gnt_box_lost_focus; | 568 parent_class->lost_focus = gnt_box_lost_focus; |
526 parent_class->gained_focus = gnt_box_gained_focus; | 569 parent_class->gained_focus = gnt_box_gained_focus; |
527 parent_class->confirm_size = gnt_box_confirm_size; | 570 parent_class->confirm_size = gnt_box_confirm_size; |
528 parent_class->size_changed = gnt_box_size_changed; | 571 parent_class->size_changed = gnt_box_size_changed; |
529 | 572 |
530 GNTDEBUG; | 573 gclass->set_property = gnt_box_set_property; |
574 gclass->get_property = gnt_box_get_property; | |
575 g_object_class_install_property(gclass, | |
576 PROP_VERTICAL, | |
577 g_param_spec_boolean("vertical", "Vertical", | |
578 "Whether the child widgets in the box should be stacked vertically.", | |
579 TRUE, | |
580 G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | |
581 ) | |
582 ); | |
583 g_object_class_install_property(gclass, | |
584 PROP_HOMO, | |
585 g_param_spec_boolean("homogeneous", "Homogeneous", | |
586 "Whether the child widgets in the box should have the same size.", | |
587 TRUE, | |
588 G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | |
589 ) | |
590 ); | |
531 } | 591 } |
532 | 592 |
533 static void | 593 static void |
534 gnt_box_init(GTypeInstance *instance, gpointer class) | 594 gnt_box_init(GTypeInstance *instance, gpointer class) |
535 { | 595 { |