static void test_engine_container (CORBA_Environment *ev) { MateComponentUIEngine *engine; MateComponentUIContainer *container; MateComponentUIContainer *new_container; fprintf (stderr, " UI container association ...\n"); engine = matecomponent_ui_engine_new (NULL); container = matecomponent_ui_container_new (); new_container = matecomponent_ui_container_new (); matecomponent_ui_engine_set_ui_container (engine, container); g_assert (engine->priv->container == container); g_assert (matecomponent_ui_container_get_engine (container) == engine); matecomponent_ui_engine_set_ui_container (engine, new_container); g_assert (engine->priv->container == new_container); g_assert (matecomponent_ui_container_get_engine (container) == NULL); g_assert (matecomponent_ui_container_get_engine (new_container) == engine); matecomponent_object_unref (new_container); matecomponent_object_unref (container); g_object_unref (engine); }
static void simple_tests (void) { MateComponentControl *control; GtkWidget *widget = gtk_button_new_with_label ("Foo"); control = matecomponent_control_new (widget); matecomponent_object_unref (MATECOMPONENT_OBJECT (control)); control = matecomponent_control_new (gtk_entry_new ()); matecomponent_object_unref (MATECOMPONENT_OBJECT (control)); }
static void mate_panel_applet_frame_matecomponent_finalize (GObject *object) { MatePanelAppletFrameMateComponent *frame = MATE_PANEL_APPLET_FRAME_MATECOMPONENT (object); if (frame->priv->control) { /* do this before unref'ing every matecomponent stuff since it looks * like we can receive some events when unref'ing them */ MateCORBA_small_unlisten_for_broken (frame->priv->control, G_CALLBACK (mate_panel_applet_frame_matecomponent_applet_broken)); matecomponent_object_release_unref (frame->priv->control, NULL); frame->priv->control = CORBA_OBJECT_NIL; } if (frame->priv->property_bag) matecomponent_object_release_unref ( frame->priv->property_bag, NULL); if (frame->priv->applet_shell) matecomponent_object_release_unref ( frame->priv->applet_shell, NULL); if (frame->priv->ui_component) matecomponent_object_unref ( MATECOMPONENT_OBJECT (frame->priv->ui_component)); G_OBJECT_CLASS (mate_panel_applet_frame_matecomponent_parent_class)->finalize (object); }
/** * matecomponent_stream_cache_create: * @cs: a reference to the stream we want to cache * @opt_ev: an optional environment * * Returns a new MateComponentStream object */ MateComponentObject * matecomponent_stream_cache_create (MateComponent_Stream cs, CORBA_Environment *opt_ev) { MateComponentStreamCache *stream; CORBA_Environment ev, *my_ev; matecomponent_return_val_if_fail (cs != NULL, NULL, opt_ev); if (!(stream = g_object_new (matecomponent_stream_cache_get_type (), NULL))) { if (opt_ev) matecomponent_exception_set (opt_ev, ex_MateComponent_Storage_IOError); return NULL; } if (!opt_ev) { CORBA_exception_init (&ev); my_ev = &ev; } else my_ev = opt_ev; stream->priv->cs = matecomponent_object_dup_ref (cs, my_ev); if (MATECOMPONENT_EX (my_ev)) { if (!opt_ev) CORBA_exception_free (&ev); matecomponent_object_unref (MATECOMPONENT_OBJECT (stream)); return NULL; } if (!opt_ev) CORBA_exception_free (&ev); return (MateComponentObject *) stream; }
static void impl_MateComponent_Listener_event (PortableServer_Servant servant, const CORBA_char *event_name, const CORBA_any *args, CORBA_Environment *ev) { MateComponentListener *listener; listener = MATECOMPONENT_LISTENER (matecomponent_object_from_servant (servant)); matecomponent_object_ref (MATECOMPONENT_OBJECT (listener)); if (listener->priv->event_callback) matecomponent_closure_invoke ( listener->priv->event_callback, G_TYPE_NONE, MATECOMPONENT_TYPE_LISTENER, listener, G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, event_name, MATECOMPONENT_TYPE_STATIC_CORBA_ANY, args, MATECOMPONENT_TYPE_STATIC_CORBA_EXCEPTION, ev, G_TYPE_INVALID); g_signal_emit (G_OBJECT (listener), signals [EVENT_NOTIFY], 0, event_name, args, ev); matecomponent_object_unref (MATECOMPONENT_OBJECT (listener)); }
static void last_unref_exit_cb (gpointer context, MateComponentObject *object) { matecomponent_object_unref (object); matecomponent_main_quit (); }
MateComponent_Listener matecomponent_event_source_client_add_listener_full (MateComponent_Unknown object, GClosure *event_callback, const char *opt_mask, CORBA_Environment *opt_ev) { MateComponentListener *listener = NULL; MateComponent_Listener corba_listener = CORBA_OBJECT_NIL; MateComponent_Unknown es; CORBA_Environment *ev, temp_ev; g_return_val_if_fail (event_callback != NULL, CORBA_OBJECT_NIL); if (!opt_ev) { ev = &temp_ev; CORBA_exception_init (ev); } else ev = opt_ev; es = MateComponent_Unknown_queryInterface (object, "IDL:MateComponent/EventSource:1.0", ev); if (MATECOMPONENT_EX (ev) || !es) goto add_listener_end; if (!(listener = matecomponent_listener_new_closure (event_callback))) goto add_listener_end; corba_listener = MATECOMPONENT_OBJREF (listener); if (opt_mask) MateComponent_EventSource_addListenerWithMask ( es, corba_listener, opt_mask, ev); else MateComponent_EventSource_addListener ( es, corba_listener, ev); corba_listener = CORBA_Object_duplicate (corba_listener, ev); matecomponent_object_unref (MATECOMPONENT_OBJECT (listener)); matecomponent_object_release_unref (es, ev); add_listener_end: if (!opt_ev) { if (MATECOMPONENT_EX (ev)) { char *text = matecomponent_exception_get_text (ev); g_warning ("add_listener failed '%s'", text); g_free (text); } CORBA_exception_free (ev); } return corba_listener; }
/** * matecomponent_event_source_notify_listeners: * @event_source: the Event Source that will emit the event. * @event_name: Name of the event being emitted * @opt_value: A CORBA_any value that contains the data that is passed * to interested clients, or NULL for an empty value * @opt_ev: A CORBA_Environment where a failure code can be returned, can be NULL. * * This will notify all clients that have registered with this EventSource * (through the addListener or addListenerWithMask methods) of the availability * of the event named @event_name. The @value CORBA::any value is passed to * all listeners. * * @event_name can not contain comma separators, as commas are used to * separate the various event names. */ void matecomponent_event_source_notify_listeners (MateComponentEventSource *event_source, const char *event_name, const CORBA_any *opt_value, CORBA_Environment *opt_ev) { GSList *l, *notify; CORBA_Environment *ev, temp_ev; const MateComponentArg *my_value; g_return_if_fail (MATECOMPONENT_IS_EVENT_SOURCE (event_source)); if (!opt_ev) { CORBA_exception_init (&temp_ev); ev = &temp_ev; } else ev = opt_ev; if (!opt_value) my_value = matecomponent_arg_new (MATECOMPONENT_ARG_NULL); else my_value = opt_value; notify = NULL; for (l = event_source->priv->listeners; l; l = l->next) { ListenerDesc *desc = (ListenerDesc *) l->data; if (desc->event_masks == NULL || event_match (event_name, desc->event_masks)) { notify = g_slist_prepend ( notify, CORBA_Object_duplicate (desc->listener, ev)); } } matecomponent_object_ref (MATECOMPONENT_OBJECT (event_source)); for (l = notify; l; l = l->next) { MateComponent_Listener_event (l->data, event_name, my_value, ev); CORBA_Object_release (l->data, ev); } matecomponent_object_unref (MATECOMPONENT_OBJECT (event_source)); g_slist_free (notify); if (!opt_ev) CORBA_exception_free (ev); if (!opt_value) matecomponent_arg_release ((MateComponentArg *) my_value); }
static void destroy_test (Test *test, DestroyType type) { switch (type) { case DESTROY_CONTAINED: { /* Highly non-useful, should never happen */ MateComponentControlFrame *frame; gtk_widget_destroy (test->control_widget); g_assert (test->control_widget == NULL); frame = matecomponent_widget_get_control_frame ( MATECOMPONENT_WIDGET (test->matecomponent_widget)); g_assert (MATECOMPONENT_IS_CONTROL_FRAME (frame)); break; } case DESTROY_SOCKET: g_warning ("unimpl"); /* drop through */ case DESTROY_CONTROL: matecomponent_object_unref (test->control); g_assert (test->plug == NULL); g_assert (test->control_widget == NULL); /* drop through */ case DESTROY_TOPLEVEL: gtk_widget_destroy (test->matecomponent_widget); g_assert (test->matecomponent_widget == NULL); g_assert (test->socket == NULL); g_assert (test->frame == NULL); g_assert (test->plug == NULL); g_assert (test->control == NULL); break; default: g_assert_not_reached (); break; } g_assert (test->control_widget == NULL); switch (type) { case DESTROY_CONTAINED: gtk_widget_destroy (test->matecomponent_widget); break; default: break; } g_assert (test->matecomponent_widget == NULL); }
static void control_frame_connection_died_cb (gpointer connection, gpointer user_data) { MateComponentControl *control = MATECOMPONENT_CONTROL (user_data); g_return_if_fail (control != NULL); matecomponent_control_disconnected (control); dbgprintf ("The remote control frame died unexpectedly"); matecomponent_object_unref (MATECOMPONENT_OBJECT (control)); }
static void matecomponent_control_destroy (MateComponentObject *object) { MateComponentControl *control = (MateComponentControl *) object; dbgprintf ("matecomponent_control_destroy %p\n", object); if (control->priv->plug) matecomponent_control_set_plug (control, NULL); matecomponent_control_unset_control_frame (control, NULL); matecomponent_control_set_properties (control, CORBA_OBJECT_NIL, NULL); matecomponent_control_set_ui_component (control, NULL); matecomponent_control_disconnected (control); if (control->priv->widget) { gtk_widget_destroy (GTK_WIDGET (control->priv->widget)); g_object_unref (control->priv->widget); } control->priv->widget = NULL; control->priv->popup_ui_container = matecomponent_object_unref ( (MateComponentObject *) control->priv->popup_ui_container); if (control->priv->popup_ui_engine) g_object_unref (control->priv->popup_ui_engine); control->priv->popup_ui_engine = NULL; control->priv->popup_ui_component = matecomponent_object_unref ( (MateComponentObject *) control->priv->popup_ui_component); control->priv->popup_ui_sync = NULL; control->priv->inproc_frame = NULL; MATECOMPONENT_OBJECT_CLASS (matecomponent_control_parent_class)->destroy (object); }
void matecomponent_control_set_ui_component (MateComponentControl *control, MateComponentUIComponent *component) { g_return_if_fail (MATECOMPONENT_IS_CONTROL (control)); g_return_if_fail (component == NULL || MATECOMPONENT_IS_UI_COMPONENT (component)); if (component == control->priv->ui_component) return; if (control->priv->ui_component) { matecomponent_ui_component_unset_container (control->priv->ui_component, NULL); matecomponent_object_unref (MATECOMPONENT_OBJECT (control->priv->ui_component)); } control->priv->ui_component = matecomponent_object_ref ((MateComponentObject *) component); }
static void xfapplet_unload_applet (XfAppletPlugin *xap) { if (xap->prop_bag) { matecomponent_object_release_unref (xap->prop_bag, NULL); xap->prop_bag = CORBA_OBJECT_NIL; } if (xap->uic) { matecomponent_object_unref (MATECOMPONENT_OBJECT (xap->uic)); xap->uic = NULL; } if (xap->object) { MateCORBA_small_unlisten_for_broken (xap->object, G_CALLBACK (xfapplet_connection_broken)); CORBA_Object_release (xap->object, NULL); xap->object = CORBA_OBJECT_NIL; } }
static void create_frame (Test *test, gboolean fake_remote) { MateComponent_Control control; control = MATECOMPONENT_OBJREF (test->control); /* if (fake_remote) control = MateCORBA_objref_get_proxy (control);*/ test->matecomponent_widget = matecomponent_widget_new_control_from_objref ( control, CORBA_OBJECT_NIL); matecomponent_object_unref (MATECOMPONENT_OBJECT (test->control)); gtk_widget_show (test->matecomponent_widget); test->frame = matecomponent_widget_get_control_frame ( MATECOMPONENT_WIDGET (test->matecomponent_widget)); test->socket = matecomponent_control_frame_get_socket (test->frame); g_object_add_weak_pointer (G_OBJECT (test->frame), (gpointer *) &test->frame); g_object_add_weak_pointer (G_OBJECT (test->socket), (gpointer *) &test->socket); g_object_add_weak_pointer (G_OBJECT (test->matecomponent_widget), (gpointer *) &test->matecomponent_widget); }
MateComponentObject * matecomponent_entry_control_new (void) { MateComponentPropertyBag *pb; MateComponentControl *control; GtkWidget *entry; GParamSpec **pspecs; guint n_pspecs; GtkWidget *box; int i; /* Create the control. */ box = gtk_vbox_new (FALSE, 0); for (i = 0; i < 3; i++) { entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0); gtk_widget_show (entry); } gtk_widget_show (box); #ifdef USE_SCROLLED { GtkWidget *canvas, *scrolled; MateCanvasItem *item; canvas = mate_canvas_new (); gtk_widget_show (canvas); item = mate_canvas_item_new ( mate_canvas_root (MATE_CANVAS (canvas)), MATE_TYPE_CANVAS_WIDGET, "x", 0.0, "y", 0.0, "width", 100.0, "height", 100.0, "widget", box, NULL); mate_canvas_item_show (item); scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add ( GTK_CONTAINER (scrolled), canvas); gtk_widget_show (scrolled); control = matecomponent_control_new (scrolled); } #else control = matecomponent_control_new (box); #endif pb = matecomponent_property_bag_new (NULL, NULL, NULL); matecomponent_control_set_properties (control, MATECOMPONENT_OBJREF (pb), NULL); matecomponent_object_unref (MATECOMPONENT_OBJECT (pb)); g_signal_connect ( GTK_OBJECT (entry), "activate", G_CALLBACK (activate_cb), control); pspecs = g_object_class_list_properties ( G_OBJECT_GET_CLASS (entry), &n_pspecs); matecomponent_property_bag_map_params ( pb, G_OBJECT (entry), (const GParamSpec **)pspecs, n_pspecs); g_free (pspecs); matecomponent_control_life_instrument (control); return MATECOMPONENT_OBJECT (control); }
MateComponentObject * circle_control_new (CommonData *com) { MateComponentPropertyBag *pb; MateComponentControl *control; GParamSpec **pspecs; guint n_pspecs; GtkWidget *button, *frame, *spin, *hbox, *spin_label; GtkObject *adj; GSList **list = &com->list; GSList *li; ObjectData *object = NULL; frame = gtk_frame_new("Circle"); hbox = gtk_hbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(frame), hbox); button = gtk_button_new(); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); spin_label = gtk_label_new ("Speed:"); gtk_box_pack_start (GTK_BOX (hbox), spin_label, FALSE, FALSE, 0); adj = gtk_adjustment_new(100.0, 0.0, 1000.0, 1.0, 10.0, 0.0); g_signal_connect(adj, "value_changed", G_CALLBACK(set_speed), com); spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0); gtk_widget_show_all(frame); control = matecomponent_control_new (frame); pb = matecomponent_property_bag_new (NULL, NULL, NULL); matecomponent_control_set_properties (control, MATECOMPONENT_OBJREF (pb), NULL); matecomponent_object_unref (MATECOMPONENT_OBJECT (pb)); g_signal_connect(button, "clicked", G_CALLBACK(on_press), com); pspecs = g_object_class_list_properties ( G_OBJECT_GET_CLASS (button), &n_pspecs); matecomponent_property_bag_map_params ( pb, G_OBJECT (button), (const GParamSpec **)pspecs, n_pspecs); g_free (pspecs); matecomponent_control_life_instrument (control); li = g_slist_last(*list); if (li) { object = li->data; } if (!object || object->button) { object = g_new0(ObjectData, 1); *list = g_slist_append(*list, object); } object->button = button; object->adj = GTK_ADJUSTMENT(adj); update_button(object, com); set_speed(GTK_ADJUSTMENT(adj), com); return MATECOMPONENT_OBJECT (control); }