diff options
Diffstat (limited to 'libnautilus/ntl-meta-view-frame.c')
-rw-r--r-- | libnautilus/ntl-meta-view-frame.c | 149 |
1 files changed, 98 insertions, 51 deletions
diff --git a/libnautilus/ntl-meta-view-frame.c b/libnautilus/ntl-meta-view-frame.c index 05d498092..56037dc54 100644 --- a/libnautilus/ntl-meta-view-frame.c +++ b/libnautilus/ntl-meta-view-frame.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * libnautilus: A library for nautilus view implementations. @@ -35,22 +35,25 @@ #include <bonobo/bonobo-property-bag.h> #include <libnautilus/nautilus-gtk-macros.h> +struct NautilusMetaViewFrameDetails { + char *label; +}; -typedef struct { - POA_Nautilus_View servant; - gpointer bonobo_object; +/* Property indices. */ +enum { + LABEL +}; - NautilusMetaViewFrame *view; +typedef struct { + POA_Nautilus_View servant; + gpointer bonobo_object; + + NautilusMetaViewFrame *view; } impl_POA_Nautilus_MetaView; extern POA_Nautilus_View__epv libnautilus_Nautilus_View_epv; - -static POA_Nautilus_MetaView__epv impl_Nautilus_MetaView_epv = { - NULL /* _private */ -}; - -static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; - +static POA_Nautilus_MetaView__epv impl_Nautilus_MetaView_epv; +static PortableServer_ServantBase__epv base_epv; static POA_Nautilus_MetaView__vepv impl_Nautilus_MetaView_vepv = { &base_epv, @@ -65,69 +68,113 @@ static void nautilus_meta_view_frame_initialize_class (NautilusMetaViewFrameClas NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusMetaViewFrame, nautilus_meta_view_frame, NAUTILUS_TYPE_VIEW_FRAME) - static void -nautilus_meta_view_frame_initialize (NautilusMetaViewFrame *view) +nautilus_meta_view_frame_initialize (NautilusMetaViewFrame *view) { + view->details = g_new0 (NautilusMetaViewFrameDetails, 1); } NautilusMetaViewFrame * nautilus_meta_view_frame_new (GtkWidget *widget) { - BonoboObject *control; + BonoboControl *control; - control = BONOBO_OBJECT (bonobo_control_new (widget)); + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + control = bonobo_control_new (widget); + return nautilus_meta_view_frame_new_from_bonobo_control (control); +} - return nautilus_meta_view_frame_new_from_bonobo_control (control); +static void +set_property (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + NautilusMetaViewFrame *view; + + view = NAUTILUS_META_VIEW_FRAME (user_data); + + switch (arg_id) { + case LABEL: + nautilus_meta_view_frame_set_label (view, + BONOBO_ARG_GET_STRING (arg)); + break; + + default: + g_warning ("unknown property"); + } } -NautilusMetaViewFrame * -nautilus_meta_view_frame_new_from_bonobo_control (BonoboObject *bonobo_control) +static void +get_property (BonoboPropertyBag *bag, + BonoboArg *arg, + guint arg_id, + gpointer user_data) { - NautilusMetaViewFrame *view; - - view = NAUTILUS_META_VIEW_FRAME (gtk_object_new (NAUTILUS_TYPE_META_VIEW_FRAME, - "bonobo_control", bonobo_control, - NULL)); + NautilusMetaViewFrame *view; + + view = NAUTILUS_META_VIEW_FRAME (user_data); + + switch (arg_id) { + case LABEL: + BONOBO_ARG_SET_STRING (arg, view->details->label); + break; + + default: + g_warning ("unknown property"); + } +} - return view; +NautilusMetaViewFrame * +nautilus_meta_view_frame_new_from_bonobo_control (BonoboControl *bonobo_control) +{ + NautilusMetaViewFrame *view; + BonoboPropertyBag *bag; + + g_return_val_if_fail (BONOBO_IS_CONTROL (bonobo_control), NULL); + g_return_val_if_fail (bonobo_control_get_property_bag (BONOBO_CONTROL (bonobo_control)) == NULL, NULL); + + view = NAUTILUS_META_VIEW_FRAME (gtk_object_new (NAUTILUS_TYPE_META_VIEW_FRAME, + "bonobo_control", bonobo_control, + NULL)); + + bag = bonobo_property_bag_new (get_property, set_property, view); + bonobo_property_bag_add (bag, "label", LABEL, BONOBO_ARG_STRING, NULL, + _("Label"), 0); + bonobo_control_set_property_bag (bonobo_control, bag); + + return view; } static void -nautilus_meta_view_frame_destroy (NautilusMetaViewFrame *view) -{ - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, GTK_OBJECT (view)); +nautilus_meta_view_frame_destroy (NautilusMetaViewFrame *view) +{ + g_free (view->details->label); + g_free (view->details); + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, GTK_OBJECT (view)); } static void nautilus_meta_view_frame_initialize_class (NautilusMetaViewFrameClass *klass) { - NautilusViewFrameClass *view_class = ((NautilusViewFrameClass *)klass); - - GTK_OBJECT_CLASS(klass)->destroy = (void (*)(GtkObject *))nautilus_meta_view_frame_destroy; - - view_class->servant_init_func = POA_Nautilus_MetaView__init; - view_class->servant_destroy_func = POA_Nautilus_MetaView__fini; - view_class->vepv = &impl_Nautilus_MetaView_vepv; + NautilusViewFrameClass *view_class; + + view_class = NAUTILUS_VIEW_FRAME_CLASS (klass); + + GTK_OBJECT_CLASS (klass)->destroy = (void (*)(GtkObject *)) nautilus_meta_view_frame_destroy; + + view_class->servant_init_func = POA_Nautilus_MetaView__init; + view_class->servant_destroy_func = POA_Nautilus_MetaView__fini; + view_class->vepv = &impl_Nautilus_MetaView_vepv; } void -nautilus_meta_view_frame_set_label(NautilusMetaViewFrame *mvc, const char *label) +nautilus_meta_view_frame_set_label (NautilusMetaViewFrame *view, + const char *label) { - BonoboObject *ctl; - BonoboPropertyBag *bag; - - ctl = nautilus_view_frame_get_bonobo_control (NAUTILUS_VIEW_FRAME (mvc)); - - bag = bonobo_control_get_property_bag (BONOBO_CONTROL (ctl)); - - if (!bag) - { - bag = bonobo_property_bag_new (); - bonobo_control_set_property_bag (BONOBO_CONTROL (ctl), bag); - } + g_return_if_fail (NAUTILUS_IS_META_VIEW_FRAME (view)); - bonobo_property_bag_add (bag, "label", "string", - g_strdup (label), g_strdup (label), - _("Label"), BONOBO_PROPERTY_READ_ONLY); + g_free (view->details->label); + view->details->label = g_strdup (label); } |