⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bonobo-exam.html

📁 这是一个介绍 linux 编程知识的文章。
💻 HTML
📖 第 1 页 / 共 4 页
字号:

  CORBA_Object view;

  GSList *last;

  CORBA_Object client_site;
  impl_POA_GNOME_ClientSite *client_site_servant;
  CORBA_Object view_frame;
  impl_POA_GNOME_ViewFrame *view_frame_servant;


  last = g_slist_last (container_servant->client_site_list);
  client_site_servant =   (impl_POA_GNOME_ClientSite *) last->data;
  client_site = PortableServer_POA_servant_to_reference (poa, 
							 client_site_servant, 
							 &ev);
  view_frame_servant = (impl_POA_GNOME_ViewFrame *) 
    impl_GNOME_ViewFrame__create (poa, client_site_servant, &ev);
  view_frame = PortableServer_POA_servant_to_reference (poa, 
							view_frame_servant, 
							&ev);
  client_site_servant->view_frame_list = 
    g_slist_append (client_site_servant->view_frame_list, 
		    view_frame_servant);
  gtk_box_pack_start (GTK_BOX(container_servant->box), 
		      view_frame_servant->wrapper,
		      FALSE, 0, 0);
  gtk_widget_show_all (container_servant->box);

  view = GNOME_Embeddable_new_view (client_site_servant->embeddable, 
							view_frame, 
							&ev);
  view_frame_servant->view = CORBA_Object_duplicate (view, &ev);
  GNOME_View_set_window (view, 
			 GDK_WINDOW_XWINDOW(view_frame_servant->socket->window), 
			 &ev);
}

void add_component (GtkWidget *menu_item, 
		    impl_POA_GNOME_Container *container_servant)
{
  CORBA_Environment ev;
  GoadServerList *list;
  PortableServer_Servant poa = container_servant->poa;

  CORBA_Object embeddable;
  CORBA_Object view;

  CORBA_Object client_site;
  impl_POA_GNOME_ClientSite *client_site_servant;
  CORBA_Object view_frame;
  impl_POA_GNOME_ViewFrame *view_frame_servant;


  /* Now, create the Component: call its factory */
  list = goad_server_list_get ();
  embeddable = goad_server_activate_with_id (list, 
					    "Component", 
					    GOAD_ACTIVATE_NEW_ONLY, 
					    NULL);
  goad_server_list_free (list);

  /* create the ClientSite for our new component and 
     give it the embeddable ref */
  client_site_servant = impl_GNOME_ClientSite__create (poa, 
						       embeddable,
						       container_servant,
						       &ev);
  client_site = PortableServer_POA_servant_to_reference (poa, 
							 client_site_servant,
							 &ev);
  /* keep the client site ref in some safe place 
     for the container... */
  container_servant->client_site_list = 
    g_slist_append (container_servant->client_site_list, 
		    client_site_servant);


  /* now, just give the newly created component 
     a ref to its ClientSite */
  GNOME_Embeddable_set_client_site (embeddable,
				    client_site, 
				    &ev);
  GNOME_Embeddable_set_host_name (embeddable,
				  "my_component", 
				  "my_component", 
				  &ev);

  /* now, create a new ViewFrame for the 
     future View of the component*/
  view_frame_servant = (impl_POA_GNOME_ViewFrame *) 
    impl_GNOME_ViewFrame__create (poa, client_site_servant, &ev);
  view_frame = PortableServer_POA_servant_to_reference (poa, 
							view_frame_servant, 
							&ev);
  client_site_servant->view_frame_list = 
    g_slist_append (client_site_servant->view_frame_list, 
		    view_frame_servant);
  gtk_box_pack_start (GTK_BOX(container_servant->box), 
		      view_frame_servant->wrapper,
		      FALSE, 0, 0);
  /* realize the socket ... so that it has a GdkWindow 
     otherwise, the GdkWindow not existing will make the 
     prgm crash  when calling set_window...
     A hard to find bug...
  */
  gtk_widget_show_all (container_servant->box);

  /* now, create the View for this ViewFrame */
  view = GNOME_Embeddable_new_view (embeddable, view_frame, &ev);
  view_frame_servant->view = CORBA_Object_duplicate (view, &ev);


  /* Now, give the View its window */
  GNOME_View_set_window (view, 
			 GDK_WINDOW_XWINDOW(view_frame_servant->socket->window), 
			 &ev);

  /* pfew !! now, the view should be displayed ...*/
};

void 
deactivate_view (impl_POA_GNOME_ViewFrame *servant)
{
  CORBA_Environment ev;

  CORBA_exception_init (&ev);
  GNOME_View_activate (servant->view,
		       0, 
		       &ev);
  CORBA_exception_free (&ev);
}
void 
activate_view (impl_POA_GNOME_ViewFrame *servant)
{
  CORBA_Environment ev;

  CORBA_exception_init (&ev);
  GNOME_View_activate (servant->view,
		       1, 
		       &ev);
  servant->client_site_servant->active = servant;
  servant->client_site_servant->container_servant->active = 
    servant->client_site_servant;
  CORBA_exception_free (&ev);
}

void 
view_frame_cb (GtkWidget *widget, 
	       GdkEvent *event, 
	       gpointer data)
{
  impl_POA_GNOME_ViewFrame *servant = 
    (impl_POA_GNOME_ViewFrame*) data;
  impl_POA_GNOME_ClientSite *active_client_site = 
    servant->client_site_servant->container_servant->active;
  
  if (event->type == GDK_2BUTTON_PRESS 
      && active_client_site == NULL)
    activate_view (servant);
  /* here, no other view in the container was activated */
  else if (event->type == GDK_2BUTTON_PRESS 
	   && active_client_site != NULL) {
    /* here, another view is active. */
    deactivate_view (active_client_site->active);
    activate_view (servant);
  }
}


void 
size_request_cb (GtkWidget *widget, gpointer data)
{
}

void 
size_allocation_cb (GtkWidget *widget, gpointer data)
{
}



void app_quit (void)
{
  gtk_main_quit ();
}


static GNOME_ParseDisplayName
impl_GNOME_ParseDisplayName__create(PortableServer_POA poa,
				    CORBA_Environment * ev)
{
   GNOME_ParseDisplayName retval;
   impl_POA_GNOME_ParseDisplayName *newservant;
   PortableServer_ObjectId *objid;

   newservant = g_new0(impl_POA_GNOME_ParseDisplayName, 1);
   newservant->servant.vepv = &impl_GNOME_ParseDisplayName_vepv;
   newservant->poa = poa;
   POA_GNOME_ParseDisplayName__init((PortableServer_Servant) newservant, ev);
   objid = PortableServer_POA_activate_object(poa, newservant, ev);
   CORBA_free(objid);
   retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);

   return retval;
}

static void
impl_GNOME_ParseDisplayName__destroy(impl_POA_GNOME_ParseDisplayName *
				     servant, CORBA_Environment * ev)
{
   PortableServer_ObjectId *objid;

   objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev);
   PortableServer_POA_deactivate_object(servant->poa, objid, ev);
   CORBA_free(objid);

   POA_GNOME_ParseDisplayName__fini((PortableServer_Servant) servant, ev);
   g_free(servant);
}

static void
impl_GNOME_ParseDisplayName_ref(impl_POA_GNOME_ParseDisplayName * servant,
				CORBA_Environment * ev)
{
}

static void
impl_GNOME_ParseDisplayName_unref(impl_POA_GNOME_ParseDisplayName * servant,
				  CORBA_Environment * ev)
{
}

static CORBA_Object
impl_GNOME_ParseDisplayName_query_interface(impl_POA_GNOME_ParseDisplayName *
					    servant, CORBA_char * repoid,
					    CORBA_Environment * ev)
{
   CORBA_Object retval;

   return retval;
}


static GNOME_Container
impl_GNOME_Container__create(PortableServer_POA poa, 
			     CORBA_Environment * ev)
{
   GNOME_Container retval;
   impl_POA_GNOME_Container *newservant = 
     g_new0(impl_POA_GNOME_Container, 1);
   PortableServer_ObjectId *objid;
   GtkWidget *app;
   GnomeUIInfo menu_file[] = {
     GNOMEUIINFO_MENU_NEW_ITEM("New Component", 
			       "Add a new component",
			       add_component, 
			       newservant),
     GNOMEUIINFO_MENU_NEW_ITEM("New Component View", 
			       "Add a new View to a component",
			       add_component_view, 
			       newservant),

     GNOMEUIINFO_SEPARATOR,
     GNOMEUIINFO_MENU_EXIT_ITEM(app_quit, NULL),
     GNOMEUIINFO_END
   };
   GnomeUIInfo menu_help[] = {
     GNOMEUIINFO_END
   };
   GnomeUIInfo main_menu[] = {
     GNOMEUIINFO_SUBTREE("Files", menu_file),
     GNOMEUIINFO_SUBTREE("Help", menu_help),
     GNOMEUIINFO_END
   };


   newservant->servant.vepv = &impl_GNOME_Container_vepv;
   newservant->poa = poa;
   newservant->client_site_list = NULL;

   app = gnome_app_new ("container 1.0", "Container");
   gnome_app_create_menus (GNOME_APP(app), main_menu);
   gtk_window_set_default_size (GTK_WINDOW(app), 200, 200);
   newservant->box = gtk_vbox_new (TRUE, TRUE);
   gnome_app_set_contents (GNOME_APP(app), newservant->box);
   gtk_widget_show_all (app);

   POA_GNOME_Container__init((PortableServer_Servant) newservant, ev);
   objid = PortableServer_POA_activate_object(poa, newservant, ev);
   CORBA_free(objid);
   retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);

   return retval;
}

static void
impl_GNOME_Container__destroy(impl_POA_GNOME_Container * servant,
			      CORBA_Environment * ev)
{
   PortableServer_ObjectId *objid;

   objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev);
   PortableServer_POA_deactivate_object(servant->poa, objid, ev);
   CORBA_free(objid);

   POA_GNOME_Container__fini((PortableServer_Servant) servant, ev);
   g_free(servant);
}

static GNOME_Container_ObjectList *
impl_GNOME_Container_enum_objects(impl_POA_GNOME_Container * servant,
				  CORBA_Environment * ev)
{
   GNOME_Container_ObjectList *retval;

   return retval;
}

static GNOME_Unknown
impl_GNOME_Container_get_object(impl_POA_GNOME_Container * servant,
				CORBA_char * item_name,
				CORBA_boolean only_if_exists,
				CORBA_Environment * ev)
{
   GNOME_Unknown retval;

   return retval;
}

static void
impl_GNOME_Container_ref(impl_POA_GNOME_Container * servant,
			 CORBA_Environment * ev)
{
  servant->refcount++;

}

static void
impl_GNOME_Container_unref(impl_POA_GNOME_Container * servant,
			   CORBA_Environment * ev)
{
  if ((--servant->refcount) == 0)
    impl_GNOME_Container__destroy (servant, ev);

}

static CORBA_Object
impl_GNOME_Container_query_interface(impl_POA_GNOME_Container * servant,
				     CORBA_char * repoid,
				     CORBA_Environment * ev)
{
   CORBA_Object retval = CORBA_OBJECT_NIL;

   if (strcmp (repoid, "IDL:GNOME/Container:1.0"))
     retval = PortableServer_POA_servant_to_reference (servant->poa, 
						       servant, 
						       ev);

   return retval;
}



static impl_POA_GNOME_ClientSite *
impl_GNOME_ClientSite__create(PortableServer_POA poa, 
			      GNOME_Embeddable embeddable, 
			      impl_POA_GNOME_Container *container_servant,
			      CORBA_Environment * ev)
{
   impl_POA_GNOME_ClientSite *retval;
   impl_POA_GNOME_ClientSite *newservant;
   PortableServer_ObjectId *objid;

   newservant = g_new0(impl_POA_GNOME_ClientSite, 1);
   newservant->servant.vepv = &impl_GNOME_ClientSite_vepv;
   newservant->poa = poa;
   newservant->embeddable = embeddable;
   newservant->container_servant = container_servant;

   POA_GNOME_ClientSite__init((PortableServer_Servant) newservant, ev);
   objid = PortableServer_POA_activate_object(poa, newservant, ev);
   CORBA_free(objid);
   retval = newservant;

   return retval;
}

static void
impl_GNOME_ClientSite__destroy(impl_POA_GNOME_ClientSite * servant,
			       CORBA_Environment * ev)
{
   PortableServer_ObjectId *objid;

   objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev);
   PortableServer_POA_deactivate_object(servant->poa, objid, ev);
   CORBA_free(objid);

   POA_GNOME_ClientSite__fini((PortableServer_Servant) servant, ev);
   g_free(servant);
}

static GNOME_Container
impl_GNOME_ClientSite_get_container(impl_POA_GNOME_ClientSite * servant,
				    CORBA_Environment * ev)
{
   GNOME_Container retval;

   return retval;
}

static void
impl_GNOME_ClientSite_show_window(impl_POA_GNOME_ClientSite * servant,
				  CORBA_boolean shown, 
				  CORBA_Environment * ev)
{
  /* store whether the component will be 
     edited in-place or out-place */
  servant->show = shown;

}

static void
impl_GNOME_ClientSite_ref(impl_POA_GNOME_ClientSite * servant,
			  CORBA_Environment * ev)
{
}

static void
impl_GNOME_ClientSite_unref(impl_POA_GNOME_ClientSite * servant,
			    CORBA_Environment * ev)
{
}

static CORBA_Object
impl_GNOME_ClientSite_query_interface(impl_POA_GNOME_ClientSite * servant,
				      CORBA_char * repoid,
				      CORBA_Environment * ev)
{
   CORBA_Object retval;

   return retval;
}

static impl_POA_GNOME_ViewFrame *
impl_GNOME_ViewFrame__create(PortableServer_POA poa, 
			     impl_POA_GNOME_ClientSite *client_site_servant, 
			     CORBA_Environment * ev)
{
   impl_POA_GNOME_ViewFrame *retval ;
   impl_POA_GNOME_ViewFrame *newservant;
   PortableServer_ObjectId *objid;

   newservant = g_new0(impl_POA_GNOME_ViewFrame, 1);
   newservant->servant.vepv = &impl_GNOME_ViewFrame_vepv;
   newservant->poa = poa;
   newservant->client_site_servant = client_site_servant;

   /* create the GtkSocket for the embeddable view */
   newservant->socket = gtk_socket_new ();
   newservant->wrapper = gnome_wrapper_new ();
   gnome_wrapper_set_covered (GNOME_WRAPPER(newservant->wrapper),
			      1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -