Ejemplo n.º 1
0
static void
gom_resource_fetch_m2m_cb (GomAdapter *adapter,
                           gpointer    user_data)
{
   GSimpleAsyncResult *simple = user_data;
   GomCommandBuilder *builder = NULL;
   GomResourceGroup *group;
   GomRepository *repository;
   const gchar *m2m_table;
   GomResource *resource;
   GomCommand *command = NULL;
   GomCursor *cursor = NULL;
   GomFilter *filter = NULL;
   GError *error = NULL;
   guint count = 0;
   GType resource_type;

   g_return_if_fail(GOM_IS_ADAPTER(adapter));
   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));

   m2m_table = g_object_get_data(G_OBJECT(simple), "m2m-table");
   resource_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(simple),
                                                     "resource-type"));
   filter = g_object_get_data(G_OBJECT(simple), "filter");
   resource = GOM_RESOURCE(g_async_result_get_source_object(G_ASYNC_RESULT(simple)));
   repository = gom_resource_get_repository(resource);

   g_assert(GOM_IS_RESOURCE(resource));
   g_assert(m2m_table);
   g_assert(g_type_is_a(resource_type, GOM_TYPE_RESOURCE));
   g_assert(!filter || GOM_IS_FILTER(filter));
   g_assert(GOM_IS_REPOSITORY(repository));

   builder = g_object_new(GOM_TYPE_COMMAND_BUILDER,
                          "adapter", adapter,
                          "filter", filter,
                          "resource-type", resource_type,
                          "m2m-table", m2m_table,
                          "m2m-type", G_TYPE_FROM_INSTANCE(resource),
                          NULL);

   command = gom_command_builder_build_count(builder);

   if (!gom_command_execute(command, &cursor, &error)) {
      g_simple_async_result_take_error(simple, error);
      goto out;
   }

   if (!gom_cursor_next(cursor)) {
      g_simple_async_result_set_error(simple, GOM_ERROR,
                                      GOM_ERROR_RESOURCE_CURSOR,
                                      _("No result was returned from the cursor."));
      goto out;
   }

   count = gom_cursor_get_column_int64(cursor, 0);
   group = g_object_new(GOM_TYPE_RESOURCE_GROUP,
                        "count", count,
                        "filter", filter,
                        "m2m-table", m2m_table,
                        "m2m-type", G_TYPE_FROM_INSTANCE(resource),
                        "repository", repository,
                        "resource-type", resource_type,
                        NULL);

   g_simple_async_result_set_op_res_gpointer(simple, group, g_object_unref);

out:
   g_object_unref(resource);
   g_clear_object(&command);
   g_clear_object(&cursor);
   g_clear_object(&builder);

   g_simple_async_result_complete_in_idle(simple);
   g_object_unref(simple);
}
Ejemplo n.º 2
0
GbIOEpiphany *
gb_io_epiphany_new (void)
{
	return g_object_new (GB_TYPE_IO_EPIPHANY, NULL);
}
Ejemplo n.º 3
0
/**
 * lasso_lib_authn_context_new:
 *
 * Creates a new #LassoLibAuthnContext object.
 *
 * Return value: a newly created #LassoLibAuthnContext object
 **/
LassoNode*
lasso_lib_authn_context_new() {
	return g_object_new(LASSO_TYPE_LIB_AUTHN_CONTEXT, NULL);
}
EmpathyConnectivity *
empathy_connectivity_dup_singleton (void)
{
  return g_object_new (EMPATHY_TYPE_CONNECTIVITY, NULL);
}
Ejemplo n.º 5
0
GtkWidget *
gtk_gst_widget_new (void)
{
  return (GtkWidget *) g_object_new (GTK_TYPE_GST_WIDGET, NULL);
}
Ejemplo n.º 6
0
int
main (int argc, char *argv[])
{
  GstNetClientInternalClock *clock;
  GstBus *bus;
  GIOChannel *channel;
  GIOStatus status;
  GError *error = NULL;
  GOptionContext *context;
  gchar *line;
  int ret = 1;

  context = g_option_context_new (NULL);
  g_option_context_add_main_entries (context, entries, NULL);
  g_option_context_add_group (context, gst_init_get_option_group ());

  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_print ("Failed to parse options: %s\n\n", error->message);
    g_error_free (error);
    return 1;
  }

  if (input) {
    if (!(channel = g_io_channel_new_file (input, "r", NULL))) {
      g_print ("Could not read input file: %s\n", input);
      return 1;
    }
  } else {
    if (!(channel = g_io_channel_unix_new (0))) {
      g_print ("Could not read stdin");
      return 1;
    }
  }

  clock = g_object_new (GST_TYPE_NET_CLIENT_INTERNAL_CLOCK, NULL);
  bus = gst_bus_new ();

  /* FIXME: Find a way to do this without touching the structure internals */
  if (rtt_limit)
    clock->roundtrip_limit = rtt_limit * GST_MSECOND;
  clock->busses = g_list_prepend (clock->busses, bus);

  while ((status = g_io_channel_read_line (channel, &line, NULL, NULL,
              &error)) == G_IO_STATUS_NORMAL) {
    GstClockTime local_1, local_2, remote_1, remote_2;
    GstMessage *message;

    if (sscanf (line, "%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %"
            G_GUINT64_FORMAT " %" G_GUINT64_FORMAT, &local_1, &remote_1,
            &remote_2, &local_2) != 4) {
      g_print ("Failed to get local/remote time values from: %s\n", line);
      goto done;
    }

    if (debug)
      g_print ("%s", line);

    gst_net_client_internal_clock_observe_times (clock, local_1, remote_1,
        remote_2, local_2);

    g_free (line);

    if ((message = gst_bus_pop_filtered (bus, GST_MESSAGE_ELEMENT))) {
      const GstStructure *st;
      gchar *str;

      st = gst_message_get_structure (message);
      str = gst_structure_to_string (st);

      g_print ("%s\n", str);

      g_free (str);
      gst_message_unref (message);
    }
  }

  if (status == G_IO_CHANNEL_ERROR) {
    g_print ("Error reading file: %s\n", error->message);
    g_error_free (error);
    goto done;
  }

  g_io_channel_unref (channel);
  g_free (input);
  gst_object_unref (bus);

  ret = 0;

done:
  return ret;
}
Ejemplo n.º 7
0
/**
 * xml_writer_new:
 *
 * Creates a new #XmlWriter instance. You can use the #XmlWriter
 * instance to write an XML data stream to a file or a memory
 * buffer. (TODO, add memory support).
 *
 * Return value: the newly created #XmlWriter instance. Use
 *   g_object_unref() when done using it.
 */
XmlWriter*
xml_writer_new (void)
{
  return g_object_new (XML_TYPE_WRITER, NULL);
}
Ejemplo n.º 8
0
/**
 * nemo_context_menu_menu_item_new:
 * @widget: The custom widget to use
 *
 * Creates a new #NemoContextMenuMenuItem.
 *
 * Returns: a new #NemoContextMenuMenuItem.
 */
GtkWidget *
nemo_context_menu_menu_item_new (GtkWidget *widget)
{
    return g_object_new (NEMO_TYPE_CONTEXT_MENU_MENU_ITEM,
                         NULL);
}
GtkWidget*
stm_new_transfer_window_new (void)
{
	StmNewTransferWindow *self = g_object_new (STM_TYPE_NEW_TRANSFER_WINDOW, NULL);
	return GTK_WIDGET (self);
}
/**
 * midgard_query_constraint_group_new:
 *
 * Create new #MidgardQueryConstraintGroup instance with default "AND" group type.
 *
 * Returns: #MidgardQueryConstraintGroup instance or %NULL
 *
 * Since: 10.05.1
 */ 
MidgardQueryConstraintGroup *
midgard_query_constraint_group_new (void)
{	
	return g_object_new (MIDGARD_TYPE_QUERY_CONSTRAINT_GROUP, "grouptype", "AND", NULL);
}
Ejemplo n.º 11
0
/**
 * clutter_group_new:
 *
 * Create a new  #ClutterGroup.
 *
 * Return value: the newly created #ClutterGroup actor
 *
 * Deprecated: 1.10: Use clutter_actor_new() instead.
 */
ClutterActor *
clutter_group_new (void)
{
  return g_object_new (CLUTTER_TYPE_GROUP, NULL);
}
Ejemplo n.º 12
0
/**
 * gdk_gl_pixmap_new:
 * @glconfig: a #GdkGLConfig.
 * @pixmap: the #GdkPixmap to be used as the rendering area.
 * @attrib_list: this must be set to NULL or empty (first attribute of None).
 *
 * Creates an off-screen rendering area.
 * attrib_list is currently unused. This must be set to NULL or empty
 * (first attribute of None). See GLX 1.3 spec.
 *
 * Return value: the new #GdkGLPixmap.
 **/
GdkGLPixmap *
gdk_gl_pixmap_new (GdkGLConfig *glconfig,
                   GdkPixmap   *pixmap,
                   const int   *attrib_list)
{
  GdkGLPixmap *glpixmap;
  GdkGLPixmapImplX11 *impl;

  Display *xdisplay;
  XVisualInfo *xvinfo;
  Pixmap xpixmap;
  GLXPixmap glxpixmap;

  Window root_return;
  int x_return, y_return;
  unsigned int width_return, height_return;
  unsigned int border_width_return;
  unsigned int depth_return;

  GdkGL_GLX_MESA_pixmap_colormap *mesa_ext;

  GDK_GL_NOTE_FUNC ();

  g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_X11 (glconfig), NULL);
  g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL);

  xdisplay = GDK_GL_CONFIG_XDISPLAY (glconfig);
  xvinfo = GDK_GL_CONFIG_XVINFO (glconfig);

  /*
   * Get X Pixmap.
   */

  xpixmap = GDK_DRAWABLE_XID (GDK_DRAWABLE (pixmap));

  /*
   * Check depth of the X pixmap.
   */

  if (!XGetGeometry (xdisplay, xpixmap,
                     &root_return,
                     &x_return, &y_return,
                     &width_return, &height_return,
                     &border_width_return,
                     &depth_return))
    return NULL;

  if (depth_return != (unsigned int) xvinfo->depth)
    return NULL;

  /*
   * Create GLXPixmap.
   */

  mesa_ext = gdk_gl_get_GLX_MESA_pixmap_colormap (glconfig);
  if (mesa_ext)
    {
      /* If GLX_MESA_pixmap_colormap is supported. */

      GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmapMESA");

      glxpixmap = mesa_ext->glXCreateGLXPixmapMESA (xdisplay,
                                                    xvinfo,
                                                    xpixmap,
                                                    GDK_GL_CONFIG_XCOLORMAP (glconfig));
    }
  else
    {
      GDK_GL_NOTE_FUNC_IMPL ("glXCreateGLXPixmap");

      glxpixmap = glXCreateGLXPixmap (xdisplay,
                                      xvinfo,
                                      xpixmap);
    }

  if (glxpixmap == None)
    return NULL;

  /*
   * Instantiate the GdkGLPixmapImplX11 object.
   */

  glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_X11, NULL);
  impl = GDK_GL_PIXMAP_IMPL_X11 (glpixmap);

  glpixmap->drawable = GDK_DRAWABLE (pixmap);
  g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable),
                             (gpointer *) &(glpixmap->drawable));

  impl->glxpixmap = glxpixmap;

  impl->glconfig = glconfig;
  g_object_ref (G_OBJECT (impl->glconfig));

  impl->is_destroyed = FALSE;

  return glpixmap;
}
Ejemplo n.º 13
0
GtkWidget *
gimp_template_view_new (GimpViewType     view_type,
                        GimpContainer   *container,
                        GimpContext     *context,
                        gint             view_size,
                        gint             view_border_width,
                        GimpMenuFactory *menu_factory)
{
  GimpTemplateView    *template_view;
  GimpContainerEditor *editor;

  template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW, NULL);

  if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (template_view),
                                         view_type,
                                         container, context,
                                         view_size, view_border_width,
                                         menu_factory, "<Templates>",
                                         "/templates-popup"))
    {
      g_object_unref (template_view);
      return NULL;
    }

  editor = GIMP_CONTAINER_EDITOR (template_view);

  if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view))
    {
      GimpContainerTreeView *tree_view;

      tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view);

      gimp_container_tree_view_connect_name_edited (tree_view,
                                                    G_CALLBACK (gimp_template_view_tree_name_edited),
                                                    template_view);
    }

  template_view->create_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates",
                                   "templates-create-image", NULL);

  template_view->new_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates",
                                   "templates-new", NULL);

  template_view->duplicate_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates",
                                   "templates-duplicate", NULL);

  template_view->edit_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates",
                                   "templates-edit", NULL);

  template_view->delete_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates",
                                   "templates-delete", NULL);

  gimp_container_view_enable_dnd (editor->view,
                                  GTK_BUTTON (template_view->create_button),
                                  GIMP_TYPE_TEMPLATE);
  gimp_container_view_enable_dnd (editor->view,
                                  GTK_BUTTON (template_view->duplicate_button),
                                  GIMP_TYPE_TEMPLATE);
  gimp_container_view_enable_dnd (editor->view,
                                  GTK_BUTTON (template_view->edit_button),
                                  GIMP_TYPE_TEMPLATE);
  gimp_container_view_enable_dnd (editor->view,
                                  GTK_BUTTON (template_view->delete_button),
                                  GIMP_TYPE_TEMPLATE);

  gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor);

  return GTK_WIDGET (template_view);
}
GtkEntryBuffer*
seahorse_secure_buffer_new (void)
{
	return g_object_new (SEAHORSE_TYPE_SECURE_BUFFER, NULL);
}
Ejemplo n.º 15
0
static void
on_operations_icon_draw (GtkWidget       *widget,
                         cairo_t         *cr,
                         NautilusToolbar *self)
{
        gfloat elapsed_progress = 0;
        gint remaining_progress = 0;
        gint total_progress;
        gdouble ratio;
        GList *progress_infos;
        GList *l;
        guint width;
        guint height;
        gboolean all_cancelled;
        GdkRGBA background = {.red = 0, .green = 0, .blue = 0, .alpha = 0.2 };
        GdkRGBA foreground = {.red = 0, .green = 0, .blue = 0, .alpha = 0.7 };

        all_cancelled = TRUE;
        progress_infos = nautilus_progress_info_manager_get_all_infos (self->priv->progress_manager);
        for (l = progress_infos; l != NULL; l = l->next) {
                if (!nautilus_progress_info_get_is_cancelled (l->data)) {
                        all_cancelled = FALSE;
                        remaining_progress += nautilus_progress_info_get_remaining_time (l->data);
                        elapsed_progress += nautilus_progress_info_get_elapsed_time (l->data);
                }
        }

        total_progress = remaining_progress + elapsed_progress;

        if (all_cancelled) {
                ratio = 1.0;
        } else {
                if (total_progress > 0) {
                        ratio = MAX (0.05, elapsed_progress / total_progress);
                } else {
                        ratio = 0.05;
                }
        }


        width = gtk_widget_get_allocated_width (widget);
        height = gtk_widget_get_allocated_height (widget);

        gdk_cairo_set_source_rgba(cr, &background);
        cairo_arc (cr,
                   width / 2.0, height / 2.0,
                   MIN (width, height) / 2.0,
                   0, 2 *G_PI);
        cairo_fill (cr);
        cairo_move_to (cr, width / 2.0, height / 2.0);
        gdk_cairo_set_source_rgba (cr, &foreground);
        cairo_arc (cr,
                   width / 2.0, height / 2.0,
                   MIN (width, height) / 2.0,
                   -G_PI / 2.0, ratio * 2 * G_PI - G_PI / 2.0);

        cairo_fill (cr);
}

static void
on_operations_button_toggled (NautilusToolbar *self)
{
        unschedule_remove_finished_operations (self);
        if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
                schedule_remove_finished_operations (self);
        } else {
                update_operations (self);
        }
}

static void
nautilus_toolbar_init (NautilusToolbar *self)
{
	GtkBuilder *builder;

	self->priv = nautilus_toolbar_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));

	self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
	gtk_container_add (GTK_CONTAINER (self->priv->path_bar_container),
					  self->priv->path_bar);

	self->priv->location_entry = nautilus_location_entry_new ();
	gtk_container_add (GTK_CONTAINER (self->priv->location_entry_container),
					  self->priv->location_entry);

	builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-toolbar-view-menu.xml");
	self->priv->view_menu_widget =  GTK_WIDGET (gtk_builder_get_object (builder, "view_menu_widget"));
	self->priv->zoom_level_scale = GTK_WIDGET (gtk_builder_get_object (builder, "zoom_level_scale"));
	self->priv->zoom_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "zoom_adjustment"));

	self->priv->sort_menu =  GTK_WIDGET (gtk_builder_get_object (builder, "sort_menu"));
	self->priv->sort_trash_time =  GTK_WIDGET (gtk_builder_get_object (builder, "sort_trash_time"));
	self->priv->sort_search_relevance =  GTK_WIDGET (gtk_builder_get_object (builder, "sort_search_relevance"));
	self->priv->visible_columns =  GTK_WIDGET (gtk_builder_get_object (builder, "visible_columns"));
	self->priv->reload =  GTK_WIDGET (gtk_builder_get_object (builder, "reload"));
	self->priv->stop =  GTK_WIDGET (gtk_builder_get_object (builder, "stop"));

	g_signal_connect (self->priv->view_menu_widget, "closed",
			  G_CALLBACK (view_menu_popover_closed), self);
	gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->priv->view_button),
				     self->priv->view_menu_widget);
	g_object_unref (builder);

	builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-toolbar-action-menu.xml");
	self->priv->action_menu = G_MENU (gtk_builder_get_object (builder, "action-menu"));
	gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->priv->action_button),
					G_MENU_MODEL (self->priv->action_menu));
	g_object_unref (builder);

        self->priv->progress_manager = nautilus_progress_info_manager_dup_singleton ();
	g_signal_connect (self->priv->progress_manager, "new-progress-info",
			  G_CALLBACK (on_new_progress_info), self);
        update_operations (self);

	g_object_set_data (G_OBJECT (self->priv->back_button), "nav-direction",
			   GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_BACK));
	g_object_set_data (G_OBJECT (self->priv->forward_button), "nav-direction",
			   GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD));
	g_signal_connect (self->priv->back_button, "button-press-event",
			  G_CALLBACK (navigation_button_press_cb), self);
	g_signal_connect (self->priv->back_button, "button-release-event",
			  G_CALLBACK (navigation_button_release_cb), self);
	g_signal_connect (self->priv->forward_button, "button-press-event",
			  G_CALLBACK (navigation_button_press_cb), self);
	g_signal_connect (self->priv->forward_button, "button-release-event",
			  G_CALLBACK (navigation_button_release_cb), self);
	g_signal_connect (self->priv->zoom_level_scale, "value-changed",
			  G_CALLBACK (zoom_level_changed), self);

	gtk_widget_show_all (GTK_WIDGET (self));
	toolbar_update_appearance (self);
}
Ejemplo n.º 16
0
Archivo: cm-dinsig.c Proyecto: gpg/gpa
/************************************************************
 **********************  Public API  ************************
 ************************************************************/
GtkWidget *
gpa_cm_dinsig_new ()
{
  return GTK_WIDGET (g_object_new (GPA_CM_DINSIG_TYPE, NULL));
}
Ejemplo n.º 17
0
int main()
{
  FILE *f;
  GPtrArray *examinees;
  OscatsSpace *contSpace, *binSpace;
  OscatsItemBank *bank;
  OscatsExaminee *e;
  OscatsDim dim;
  OscatsPoint *initTheta, *initAlpha;
  const guint num_tests = 4;
  const gchar *test_names[] = { "random", "FI", "KL.3PL", "KL.DINA" };
  OscatsTest *test[num_tests];
  OscatsAlgExposureCounter *exposure[num_tests];
  OscatsAlgClassRates *rates[num_tests];
  guint i, j, k;
  
  g_type_init();
  g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);         // For debugging
  
  /* In the previous examples, we had only one latent space; but, here we
   * want to use two different models from *different* latent spaces.  The
   * first latent space is a unidimensional continuous space (for the 3PL
   * model); the second is an N_ATTR-dimensional binary space (for the DINA
   * model).  If appropriate to the simulation (e.g. to compare 2PL vs. 3PL)
   * we could have created two different models from the same space.
   *
   * Note: Even though OscatsSpace accommodates mixed-type (continuous and
   * binary) latent spaces, the models we use here are either only
   * continuous or only binary, so they come from different latent spaces. 
   * A mixed-type model would be something like the Fusion model, which has
   * both binary and continuous components.
   */
  contSpace = g_object_new(OSCATS_TYPE_SPACE, "numCont", 1, NULL);
  binSpace = g_object_new(OSCATS_TYPE_SPACE, "numBin", N_ATTR, NULL);
  initTheta = oscats_point_new_from_space(contSpace);
  initAlpha = oscats_point_new_from_space(binSpace);

  printf("Reading examinees.\n");
  f = fopen("ex03-person.dat", "r");
  examinees = read_examinees(f, contSpace, binSpace);
  fclose(f);
  printf("Reading items.\n");
  f = fopen("ex03-items.dat", "r");
  bank = read_items(f, contSpace, binSpace);
  fclose(f);

  printf("Creating tests.\n");
  for (j=0; j < num_tests; j++)
  {
    // Create a new test with the given properties
    // Be sure to end calls to g_object_new() with NULL!
    test[j] = g_object_new(OSCATS_TYPE_TEST, "id", test_names[j],
                           "itembank", bank, "length_hint", LEN, NULL);

    // Register the common CAT algorithms for this test.
    
    // Here, we always simulate from the DINA model.
    oscats_algorithm_register(
      g_object_new(OSCATS_TYPE_ALG_SIMULATE,
                   "modelKey", "DINA", "thetaKey", "trueAlpha", NULL),
      test[j]);

    // Usually we would only have one estimate algorithm, but here, we need
    // to estimate both the continuous ability and the latent class, each
    // based on a separate model.
    oscats_algorithm_register(
      g_object_new(OSCATS_TYPE_ALG_ESTIMATE,
                   "modelKey", "3PL", "thetaKey", "estTheta", NULL),
      test[j]);
    oscats_algorithm_register(
      g_object_new(OSCATS_TYPE_ALG_ESTIMATE,
                   "modelKey", "DINA", "thetaKey", "estAlpha", NULL),
      test[j]);

    exposure[j] = oscats_algorithm_register(g_object_new(OSCATS_TYPE_ALG_EXPOSURE_COUNTER, NULL), test[j]);
    g_object_ref(exposure[j]);
    rates[j] = oscats_algorithm_register(
      g_object_new(OSCATS_TYPE_ALG_CLASS_RATES, "simKey", "trueAlpha",
                   "estKey", "estAlpha", NULL), test[j]);
    g_object_ref(rates[j]);

    oscats_algorithm_register(g_object_new(OSCATS_TYPE_ALG_FIXED_LENGTH,
                                           "len", LEN, NULL), test[j]);
  }
  
  // Register the item selection criteria for the different tests:
  // Since we aren't just using the default model for everything, we have to
  // tell each algorithm which model/theta to use for selection.
  oscats_algorithm_register(g_object_new(OSCATS_TYPE_ALG_PICK_RAND, NULL), test[0]);
  oscats_algorithm_register(
    g_object_new(OSCATS_TYPE_ALG_MAX_FISHER, "num", 5,
                 "modelKey", "3PL", "thetaKey", "estTheta", NULL), test[1]);
  oscats_algorithm_register(
    g_object_new(OSCATS_TYPE_ALG_MAX_KL, "num", 5,
                 "modelKey", "3PL", "thetaKey", "estTheta", NULL), test[2]);
  oscats_algorithm_register(
    g_object_new(OSCATS_TYPE_ALG_MAX_KL, "num", 5,
                 "modelKey", "DINA", "thetaKey", "estAlpha", NULL), test[3]);
  
  printf("Administering.\n");
  f = fopen("ex03-person-results.dat", "w");
  fprintf(f, "ID\ttrue.theta\ttrue.alpha\tinit.theta\tinit.alpha");
  for (j=0; j < num_tests; j++)
    fprintf(f, "\t%s.theta\t%s.alpha", test_names[j], test_names[j]);
  fprintf(f, "\n");
  for (i=0; i < N_EXAMINEES; i++)
  {
    OscatsPoint *tmp;
    e = g_ptr_array_index(examinees, i);
    tmp = oscats_examinee_get_theta_by_name(e, "trueTheta");
    dim = OSCATS_DIM_CONT+0;	// first continuous dimension
    fprintf(f, "%s\t%g\t", e->id, oscats_point_get_cont(tmp, dim));
    tmp = oscats_examinee_get_theta_by_name(e, "trueAlpha");
    dim = OSCATS_DIM_BIN+0;	// first binary dimension
    for (k=0; k < N_ATTR; k++, dim++)
      fprintf(f, oscats_point_get_bin(tmp, dim) ? "1" : "0");

    // Choose initial theta and alpha for this examinee
    // We'll use the same initial abilities for all four tests
    dim = OSCATS_DIM_CONT+0;	// first continuous dimension
    oscats_point_set_cont(initTheta, dim, oscats_rnd_normal(sqrt(0.05))-0.37);
    dim = OSCATS_DIM_BIN+0;	// first binary dimension
    for (k=0; k < N_ATTR; k++, dim++)
      oscats_point_set_bin(initAlpha, dim, oscats_rnd_uniform() < 0.5);
    
    // Initialize ability estimates for this examinee
    // (Examinee takes references for the new OscatsPoint objects)
    oscats_examinee_set_theta_by_name(e, "estTheta",
                                      oscats_point_new_from_space(contSpace));
    oscats_examinee_set_theta_by_name(e, "estAlpha",
                                      oscats_point_new_from_space(binSpace));

    for (j=0; j < num_tests; j++)
    {
      // Reset initial latent ability for this test
      oscats_point_copy(
        oscats_examinee_get_theta_by_name(e, "estTheta"), initTheta);
      oscats_point_copy(
        oscats_examinee_get_theta_by_name(e, "estAlpha"), initAlpha);

      // Do the administration!
      oscats_test_administer(test[j], e);

      // Output the resulting theta.hat and alpha.hat
      tmp = oscats_examinee_get_theta_by_name(e, "estTheta");
      dim = OSCATS_DIM_CONT+0;	// first continuous dimension
      fprintf(f, "\t%g\t", oscats_point_get_cont(tmp, dim));
      tmp = oscats_examinee_get_theta_by_name(e, "estAlpha");
      dim = OSCATS_DIM_BIN+0;	// first binary dimension
      for (k=0; k < N_ATTR; k++, dim++)
        fprintf(f, oscats_point_get_bin(tmp, dim) ? "1" : "0");
    }
    fprintf(f, "\n");
  }
  fclose(f);
  
  f = fopen("ex03-exposure.dat", "w");
  fprintf(f, "ID");
  for (j=0; j < num_tests; j++)
    fprintf(f, "\t%s", test_names[j]);
  fprintf(f, "\n");
  for (i=0; i < N_ITEMS; i++)
  {
    OscatsItem *item = OSCATS_ITEM(oscats_item_bank_get_item(bank, i));
    fprintf(f, "%d", i+1);
    // Get the exposure rate for this item in each test
    for (j=0; j < num_tests; j++)
      fprintf(f, "\t%g",
            oscats_alg_exposure_counter_get_rate(exposure[j], item));
    fprintf(f, "\n");
  }
  fclose(f);

  f = fopen("ex03-rates.dat", "w");
  fprintf(f, "Rate");
  for (j=0; j < num_tests; j++)
    fprintf(f, "\t%s", test_names[j]);
  fprintf(f, "\nPattern");
  for (j=0; j < num_tests; j++)
    fprintf(f, "\t%g", oscats_alg_class_rates_get_pattern_rate(rates[j]));
  for (k=0; k < N_ATTR; k++)
  {
    fprintf(f, "\nattr.%d", k+1);
    for (j=0; j < num_tests; j++)
      fprintf(f, "\t%g",
              oscats_alg_class_rates_get_attribute_rate(rates[j], k));
  }
  for (k=0; k <= N_ATTR; k++)
  {
    fprintf(f, "\nfreq.%d", k);
    for (j=0; j < num_tests; j++)
      fprintf(f, "\t%g",
              oscats_alg_class_rates_get_misclassify_freq(rates[j], k));
  }
  fprintf(f, "\n");
  fclose(f);

  // Clean up
  printf("Done.\n");
  for (j=0; j < num_tests; j++)
  {
    g_object_unref(exposure[j]);
    g_object_unref(rates[j]);
    g_object_unref(test[j]);
  }
  g_object_unref(bank);
  g_ptr_array_free(examinees, TRUE);
  g_object_unref(initTheta);
  g_object_unref(initAlpha);
  g_object_unref(contSpace);
  g_object_unref(binSpace);
  
  return 0;
}
Ejemplo n.º 18
0
GimpLayer *
text_render (GimpImage    *image,
             GimpDrawable *drawable,
             GimpContext  *context,
             gint          text_x,
             gint          text_y,
             const gchar  *fontname,
             const gchar  *text,
             gint          border,
             gboolean      antialias)
{
  PangoFontDescription *desc;
  GimpText             *gtext;
  GimpLayer            *layer;
  GimpRGB               color;
  gchar                *font;
  gdouble               size;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), NULL);
  g_return_val_if_fail (drawable == NULL ||
                        gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (fontname != NULL, NULL);
  g_return_val_if_fail (text != NULL, NULL);

  if (border < 0)
    border = 0;

  desc = pango_font_description_from_string (fontname);
  size = PANGO_PIXELS (pango_font_description_get_size (desc));

  pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
  font = pango_font_description_to_string (desc);

  pango_font_description_free (desc);

  gimp_context_get_foreground (context, &color);

  gtext = g_object_new (GIMP_TYPE_TEXT,
                        "text",      text,
                        "font",      font,
                        "font-size", size,
                        "antialias", antialias,
                        "border",    border,
                        "color",     &color,
                        NULL);

  g_free (font);

  layer = gimp_text_layer_new (image, gtext);

  g_object_unref (gtext);

  if (!layer)
    return NULL;

  /*  Start a group undo  */
  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TEXT,
                               _("Add Text Layer"));

  /*  Set the layer offsets  */
  gimp_item_set_offset (GIMP_ITEM (layer), text_x, text_y);

  /*  If there is a selection mask clear it--
   *  this might not always be desired, but in general,
   *  it seems like the correct behavior.
   */
  if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
    gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);

  if (drawable == NULL)
    {
      /*  If the drawable is NULL, create a new layer  */
      gimp_image_add_layer (image, layer, NULL, -1, TRUE);
    }
  else
    {
      /*  Otherwise, instantiate the text as the new floating selection */
      floating_sel_attach (layer, drawable);
    }

  /*  end the group undo  */
  gimp_image_undo_group_end (image);

  return layer;
}
GtkWidget *ryosconfig_key_illumination_selector_new(void) {
	return GTK_WIDGET(g_object_new(RYOSCONFIG_KEY_ILLUMINATION_SELECTOR_TYPE, NULL));
}
Ejemplo n.º 20
0
GeditMultiNotebook *
gedit_multi_notebook_new ()
{
	return g_object_new (GEDIT_TYPE_MULTI_NOTEBOOK, NULL);
}
Ejemplo n.º 21
0
GtkIconHelper *
_gtk_icon_helper_new (void)
{
  return g_object_new (GTK_TYPE_ICON_HELPER, NULL);
}
/**
 * gtk_tearoff_menu_item_new:
 *
 * Creates a new #GtkTearoffMenuItem.
 *
 * Returns: a new #GtkTearoffMenuItem.
 *
 * Deprecated: 3.4: #GtkTearoffMenuItem is deprecated and should not be
 *     used in newly written code.
 */
GtkWidget*
gtk_tearoff_menu_item_new (void)
{
  return g_object_new (GTK_TYPE_TEAROFF_MENU_ITEM, NULL);
}
Ejemplo n.º 23
0
/**
 * lasso_idwsf2_sb2_consent_new:
 *
 * Creates a new #LassoIdWsf2Sb2Consent object.
 *
 * Return value: a newly created #LassoIdWsf2Sb2Consent object
 **/
LassoIdWsf2Sb2Consent*
lasso_idwsf2_sb2_consent_new()
{
	return g_object_new(LASSO_TYPE_IDWSF2_SB2_CONSENT, NULL);
}
Ejemplo n.º 24
0
LOCAL_SYMBOL MetaShadowFactory *
meta_shadow_factory_new (void)
{
  return g_object_new (META_TYPE_SHADOW_FACTORY, NULL);
}
Ejemplo n.º 25
0
MarinaSource*
marina_google_reader_source_new ()
{
  return g_object_new (MARINA_TYPE_GOOGLE_READER_SOURCE, NULL);
}
GstUriDownloader *
gst_uri_downloader_new (void)
{
  return g_object_new (GST_TYPE_URI_DOWNLOADER, NULL);
}
GPInstructLessonTestWordPool *
gpinstruct_lesson_test_word_pool_new (void)
{
	return g_object_new (GPINSTRUCT_TYPE_LESSON_TEST_WORD_POOL, NULL);
}
Ejemplo n.º 28
0
void 
midgard_init() 
{	
	GType type;
	/* g_type_init_with_debug_flags(G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_NONE); */


	gda_init ();

	type = MIDGARD_TYPE_BLOB;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_USER;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_CONNECTION;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_CONFIG;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_COLLECTOR;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_QUERY_BUILDER;
	g_assert (type != 0);
	g_type_class_ref (type);
	
	type = MIDGARD_TYPE_DBOBJECT;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_OBJECT;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_VIEW;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_METADATA;
	g_assert (type != 0);
	g_type_class_ref (type);
	/* Initialize MidgardMetadataClass */
	MidgardMetadata *m = g_object_new (MIDGARD_TYPE_METADATA, NULL);
	g_object_unref (m);

	type = MIDGARD_TYPE_WORKSPACE;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_WORKSPACE_STORAGE;
	g_assert (type != 0);

	type = MIDGARD_TYPE_REPLIGARD;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_BASE_ABSTRACT;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_QUERY_EXECUTOR;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_QUERY_SELECT;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_BASE_INTERFACE;
	g_assert (type != 0);

	type = MIDGARD_TYPE_BASE_MIXIN;
	g_assert (type != 0);

	type = MIDGARD_TYPE_JOB;
	g_assert (type != 0);

	type = MIDGARD_TYPE_OBJECT_REFERENCE;
	g_assert (type != 0);
	g_type_class_ref (type);

	type = MIDGARD_TYPE_SQL_CONTENT_MANAGER_JOB;
	g_assert (type != 0);
	g_type_class_ref (type);

	/* Register transform function explicitly, we need own routine */
	g_value_register_transform_func (G_TYPE_STRING, G_TYPE_FLOAT, __transform_string_to_float);
  	g_value_register_transform_func (G_TYPE_STRING, G_TYPE_BOOLEAN, __transform_string_to_boolean);
}
Ejemplo n.º 29
0
NMDHCP6Config *
nm_dhcp6_config_new (void)
{
	return NM_DHCP6_CONFIG (g_object_new (NM_TYPE_DHCP6_CONFIG, NULL));
}
Ejemplo n.º 30
0
NMShellWatcher *
nm_shell_watcher_new (void)
{
    return g_object_new (NM_TYPE_SHELL_WATCHER, NULL);
}