Beispiel #1
0
size_t
gc_free_termios (SCM x)
{
  struct termios *gp;

  scm_assert_smob_type (termios_tag, x);

  gp = (struct termios *) SCM_SMOB_DATA (x);

  assert (gp != NULL);
  if (0)
    {
      fprintf (stderr, "Freeing termios at %p\n", gp);
      fprintf (stderr, "Flags: I %u O %u C %u L %u\n", gp->c_iflag,
               gp->c_oflag, gp->c_cflag, gp->c_lflag);
      fprintf (stderr, "Speed: O %u I %u\n", cfgetospeed(gp),
               cfgetispeed(gp));
      fflush (stderr);
      sleep (1);
    }

  scm_gc_free (gp, sizeof (struct termios), "termios");

  SCM_SET_SMOB_DATA (x, NULL);

  return 0;
}
Beispiel #2
0
/*! \brief Weak reference notify function for double-length gEDA smobs.
 * \par Function Description
 * Clears a gEDA smob's second pointer when the target object is
 * destroyed.
 *
 * \see edascm_from_object().
 */
static void
smob_weakref2_notify (void *target, void *smob) {
  SCM s = pack_from_pointer (smob);
  SCM_SET_SMOB_DATA (s, NULL);
  SCM_SET_SMOB_DATA_2 (s, NULL);
  smob_cache_remove (target);
}
Beispiel #3
0
static SCM
scm_g_irepository_get_default (void)
{
        SCM repository = scm_make_smob (repository_t);
        SCM_SET_SMOB_DATA (repository, g_irepository_get_default ());

        return repository;
}
/* Handle GC'ing of the session smob. */
size_t
free_session (SCM session)
{
  struct session_data *sd = (struct session_data *) SCM_SMOB_DATA (session);

  ssh_disconnect (sd->ssh_session);
  ssh_free (sd->ssh_session);

  SCM_SET_SMOB_DATA (session, NULL);

  return 0;
}
Beispiel #5
0
size_t
free_plparams (SCM x)
{
  plPlotterParams *plparams;

  assert (SCM_SMOB_PREDICATE (plparams_tag, x));

  plparams = (plPlotterParams *) SCM_SMOB_DATA (x);
  if (plparams != NULL)
    {
      pl_deleteplparams (plparams);
      SCM_SET_SMOB_DATA (x, 0);
    }

  return 0;
}
Beispiel #6
0
size_t
free_plotter (SCM x)
{
  plPlotter *plotter;

  assert (SCM_SMOB_PREDICATE (plotter_tag, x));

  plotter = (plPlotter *) SCM_SMOB_DATA (x);
  /* Plotters should already be null if delwin has been called on them */
  if (plotter != NULL)
    {
      pl_deletepl_r (plotter);
      SCM_SET_SMOB_DATA (x, 0);
    }

  return 0;
}
Beispiel #7
0
/* Free the C memory of a window */
SCM
gucu_delwin (SCM win)
{
  WINDOW *c_win = _scm_to_window (win);

  SCM_SET_SMOB_DATA (win, NULL);

  if (c_win != NULL)
    {
      int ret = delwin (c_win);
      if (ret == ERR)
	return SCM_BOOL_F;
      else
	return SCM_BOOL_T;
    }
  return SCM_BOOL_F;
}
Beispiel #8
0
static SCM
scm_g_irepository_find_by_name (SCM scm_repository,
                                SCM scm_namespace,
                                SCM scm_name)
{
        GIRepository *repo;
        GIBaseInfo *info;
        GError *error;
        SCM scm_info;

        repo = (GIRepository *) SCM_SMOB_DATA (scm_repository);

        error = NULL;
        info = g_irepository_find_by_name (repo,
                                           scm_to_locale_string (scm_namespace),
                                           scm_to_locale_string (scm_name));
        if (info == NULL)
                return SCM_UNSPECIFIED;

        scm_info = scm_make_smob (base_info_t);
        SCM_SET_SMOB_DATA (scm_info, info);

        return scm_info;
}
Beispiel #9
0
/* FIXME: scm_flags is currently ignored */
static SCM
scm_g_irepository_require (SCM scm_repository,
                           SCM scm_namespace,
                           SCM scm_version,
                           SCM scm_flags)
{
        GIRepository *repo;
        GTypelib *typelib;
        GError *error;
        const char *version;
        SCM scm_typelib;

        repo = (GIRepository *) SCM_SMOB_DATA (scm_repository);

        if (SCM_UNBNDP (scm_version))
                version = NULL;
        else
                version = scm_to_locale_string (scm_version);

        error = NULL;
        typelib = g_irepository_require (repo,
                                         scm_to_locale_string (scm_namespace),
                                         version,
                                         0,
                                         &error);
        if (error) {
                /* FIXME: Throw Guile error here */
                g_critical ("Failed to load typelib: %s", error->message);
                return SCM_UNSPECIFIED;
        }

        scm_typelib = scm_make_smob (typelib_t);
        SCM_SET_SMOB_DATA (scm_typelib, typelib);

        return scm_typelib;
}
Beispiel #10
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void x_window_close(GschemToplevel *w_current)
{
  TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current);
  gboolean last_window = FALSE;

  /* If we're closing whilst inside an action, re-wind the
   * page contents back to their state before we started */
  if (w_current->inside_action) {
    i_callback_cancel (w_current, 0, NULL);
  }

  /* last chance to save possible unsaved pages */
  if (!x_dialog_close_window (w_current)) {
    /* user somehow cancelled the close */
    return;
  }

  x_clipboard_finish (w_current);

#if DEBUG
  o_conn_print_hash(w_current->page_current->conn_table);
#endif

  w_current->dont_invalidate = TRUE;

  /* close all the dialog boxes */
  if (w_current->sowindow)
  gtk_widget_destroy(w_current->sowindow);

  if (w_current->cswindow)
  gtk_widget_destroy(w_current->cswindow);

  if (w_current->tiwindow)
  gtk_widget_destroy(w_current->tiwindow);

  if (w_current->tewindow)
  gtk_widget_destroy(w_current->tewindow);

  if (w_current->aawindow)
  gtk_widget_destroy(w_current->aawindow);

  x_multiattrib_close (w_current);

  if (w_current->aewindow)
  gtk_widget_destroy(w_current->aewindow);

  if (w_current->trwindow)
  gtk_widget_destroy(w_current->trwindow);

  x_pagesel_close (w_current);

  if (w_current->sswindow)
  gtk_widget_destroy(w_current->sswindow);

  if (w_current->iwindow)
  gtk_widget_destroy(w_current->iwindow);

  if (w_current->hkwindow)
  gtk_widget_destroy(w_current->hkwindow);

  if (w_current->cowindow)
  gtk_widget_destroy(w_current->cowindow);

  if (w_current->sewindow)
  gtk_widget_destroy(w_current->sewindow);

  if (g_list_length (global_window_list) == 1) {
    /* no more window after this one, remember to quit */
    last_window = TRUE;
  }

  if (toplevel->major_changed_refdes) {
    GList* current = toplevel->major_changed_refdes;
    while (current)
    {
      /* printf("yeah freeing: %s\n", (char*) current->data); */
      g_free(current->data);
      current = g_list_next(current);
    }
    g_list_free(toplevel->major_changed_refdes);
  }

  /* stuff that has to be done before we free w_current */
  if (last_window) {
    /* close the log file */
    s_log_close ();
    /* free the buffers */
    o_buffer_free (w_current);
  }

  x_window_free_gc(w_current);

  /* Clear Guile smob weak ref */
  if (w_current->smob != SCM_UNDEFINED) {
    SCM_SET_SMOB_DATA (w_current->smob, NULL);
    w_current->smob = SCM_UNDEFINED;
  }

  /* finally close the main window */
  gtk_widget_destroy(w_current->main_window);

  global_window_list = g_list_remove (global_window_list, w_current);
  gschem_toplevel_free (w_current);

  /* just closed last window, so quit */
  if (last_window) {
    gschem_quit();
  }
}
Beispiel #11
0
/*! \brief Weak reference notify function for gEDA smobs.
 * \par Function Description
 * Clears a gEDA smob's pointer when the target object is destroyed.
 */
static void
smob_weakref_notify (void *target, void *smob) {
  SCM s = (SCM) smob;
  SCM_SET_SMOB_DATA (s, NULL);
}
Beispiel #12
0
/* SMOB Helper functions */
void scm_set_smob_data(SCM x, void* p) {
	SCM_SET_SMOB_DATA(x, p);
}