static GtkWidget * control_create (GbWidgetNewData * data, char *obj_id, Bonobo_UIContainer uic) { GtkWidget *widget; BonoboControlFrame *cf; Bonobo_PropertyBag pb; g_return_val_if_fail (obj_id != NULL, NULL); widget = bonobo_widget_new_control (obj_id, uic); g_return_val_if_fail (widget != NULL, NULL); cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (widget)); if (!cf) { g_warning ("Control has no frame!"); gtk_widget_destroy (widget); return NULL; } pb = bonobo_control_frame_get_control_property_bag (cf, NULL); gtk_object_set_data (GTK_OBJECT (widget), GladePropertyBagKey, pb); gtk_object_set_data (GTK_OBJECT (widget), Moniker, g_strdup (obj_id)); /* Make sure the GbWidget for this control is created & registered, and set the real GbWidget for this control. */ data->widget_data->gbwidget = control_get_gb_widget (obj_id); return widget; }
static void load_applet_into_window (const char *moniker, const char *title) { GtkWidget *applet_window; GtkWidget *applet; applet = bonobo_widget_new_control (moniker, NULL); if (!applet) { GtkWidget *dialog; dialog = gtk_message_dialog_new (win ? GTK_WINDOW (win) : NULL, GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Failed to load applet %s"), title); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; } applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_show (applet); gtk_container_add (GTK_CONTAINER (applet_window), applet); //FIXME: we could set the window icon with the applet icon gtk_window_set_title (GTK_WINDOW (applet_window), title); gtk_widget_show (applet_window); }
static void sunone_invitation_list_init (SunOneInvitationList *object) { SunOneInvitationList *list = SUNONE_INVITATION_LIST (object); SunOneInvitationListPrivate *priv; GtkWidget *scroll; int pos; list->priv = g_new0 (SunOneInvitationListPrivate, 1); priv = list->priv; priv->client = gconf_client_get_default (); priv->model = NULL; priv->treeview = NULL; priv->pane = gtk_vpaned_new (); gtk_box_set_homogeneous (GTK_BOX (list), FALSE); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); #if USE_ITIP_VIEW priv->control = sunone_itip_view_new (); #else priv->control = bonobo_widget_new_control (INVITATION_CONTROL_IID, NULL); #endif gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), priv->control); gtk_paned_add2 (GTK_PANED (priv->pane), GTK_WIDGET (scroll)); pos = gconf_client_get_int (priv->client, "/apps/evolution/evolution-jescs/invitationList/panePosition", NULL); gtk_paned_set_position (GTK_PANED (priv->pane), pos); gtk_box_pack_start (GTK_BOX (list), priv->pane, TRUE, TRUE, 0); }
PeacockFileClient * peacock_file_new (PeacockWindow *window) { GtkWidget *control; BonoboUIContainer *uiContainer; PeacockFileClient *fileClient; CORBA_Environment ev; CORBA_Object interface; uiContainer = bonobo_window_get_ui_container (BONOBO_WINDOW (window)); control = bonobo_widget_new_control (PEACOCK_FILE_CONTROL_OAFIID, BONOBO_OBJREF (uiContainer)); peacock_util_activate_bonobo_control (BONOBO_WIDGET (control)); gtk_widget_show (control); /* Get the PersistFile interface for loading/saving. */ CORBA_exception_init (&ev); interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (control)), "IDL:Bonobo/PersistFile:1.0", &ev); CORBA_exception_free (&ev); if (interface == CORBA_OBJECT_NIL) { g_warning ("Oh No! Control doesn't support IDL:Bonobo/PersistFile:1.0!!!"); return NULL; } /* Initialize the PeacockFileClient struct. */ fileClient = peacock_file_client_new (); fileClient->control = control; fileClient->persistFile = interface; fileClient->tabWidget = peacock_file_client_create_tab_widget (fileClient, window); gtk_widget_ref (fileClient->control); gtk_widget_ref (fileClient->tabWidget); /* For setting the current_file in PeacockMDI. */ g_object_set_data (G_OBJECT (fileClient->control), PEACOCK_FILE_CLIENT_TAG, fileClient); return fileClient; }
static GtkWidget * glade_bonobo_widget_new (GladeXML *xml, GType widget_type, GladeWidgetInfo *info) { const gchar *control_moniker = NULL; GtkWidget *widget; GObjectClass *oclass; BonoboControlFrame *cf; Bonobo_PropertyBag pb; gint i; for (i = 0; i < info->n_properties; i++) { if (!strcmp (info->properties[i].name, "moniker")) { control_moniker = info->properties[i].value; break; } } if (!control_moniker) { g_warning (G_STRLOC " BonoboWidget doesn't have moniker property"); return NULL; } widget = bonobo_widget_new_control ( control_moniker, CORBA_OBJECT_NIL); if (!widget) { g_warning (G_STRLOC " unknown bonobo control '%s'", control_moniker); return NULL; } oclass = G_OBJECT_GET_CLASS (widget); cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (widget)); if (!cf) { g_warning ("control '%s' has no frame", control_moniker); gtk_widget_unref (widget); return NULL; } pb = bonobo_control_frame_get_control_property_bag (cf, NULL); if (pb == CORBA_OBJECT_NIL) return widget; for (i = 0; i < info->n_properties; i++) { const gchar *name = info->properties[i].name; const gchar *value = info->properties[i].value; GParamSpec *pspec; if (!strcmp (name, "moniker")) continue; pspec = g_object_class_find_property (oclass, name); if (pspec) { GValue gvalue = { 0 }; if (glade_xml_set_value_from_string(xml, pspec, value, &gvalue)) { g_object_set_property(G_OBJECT(widget), name, &gvalue); g_value_unset(&gvalue); } } else if (pb != CORBA_OBJECT_NIL) { CORBA_TypeCode tc = bonobo_property_bag_client_get_property_type (pb, name, NULL); switch (tc->kind) { case CORBA_tk_boolean: bonobo_property_bag_client_set_value_gboolean (pb, name, value[0] == 'T' || value[0] == 'y', NULL); break; case CORBA_tk_string: bonobo_property_bag_client_set_value_string (pb, name, value, NULL); break; case CORBA_tk_long: bonobo_property_bag_client_set_value_glong (pb, name, strtol (value, NULL,0), NULL); break; case CORBA_tk_float: bonobo_property_bag_client_set_value_gfloat (pb, name, strtod (value, NULL), NULL); break; case CORBA_tk_double: bonobo_property_bag_client_set_value_gdouble (pb, name, strtod (value, NULL), NULL); break; default: g_warning ("Unhandled type %d for `%s'", tc->kind, name); break; } } else { g_warning ("could not handle property `%s'", name); } } bonobo_object_release_unref (pb, NULL); return widget; }