Example #1
0
/*! \brief Clear the current key accelerator string
 *
 *  \par Function Description
 *  This function clears the current keyboard accelerator
 *  string in the status bar of the relevant toplevel.
 *  Called after the action specifed by the keyboard
 *  accelerator is executed and the associated timeout interval
 *  has passed.
 *
 *  \param [in] data a pointer to the GSCHEM_TOPLEVEL
 */
static gboolean clear_keyaccel_string(gpointer data)
{
  GSCHEM_TOPLEVEL *w_current = data;

  /* Find out if the GSCHEM_TOPLEVEL is present... */
  if (g_list_find(global_window_list, w_current) != NULL) {
    g_free(w_current->keyaccel_string);
    w_current->keyaccel_string = NULL;
    i_show_state(w_current, NULL);
  }

  return FALSE;
}
Example #2
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void o_edit_show_hidden (GSCHEM_TOPLEVEL *w_current, const GList *o_list)
{
  /* this function just shows the hidden text, but doesn't toggle it */
  /* this function does not change the CHANGED bit, no real changes are */
  /* made to the schematic */

  /* toggle show_hidden_text variable, which when it is true */
  /* means that hidden text IS drawn */
  w_current->toplevel->show_hidden_text = !w_current->toplevel->show_hidden_text;
  i_show_state(w_current, NULL); /* update screen status */

  o_edit_show_hidden_lowlevel(w_current, o_list);
  o_invalidate_all (w_current);

  if (w_current->toplevel->show_hidden_text) {
    s_log_message(_("Hidden text is now visible\n"));
  } else {
    s_log_message(_("Hidden text is now invisible\n"));
  }
}
Example #3
0
/* for now this only supports single chars, not shift/alt/ctrl etc... */
int g_keys_execute(GSCHEM_TOPLEVEL *w_current, int state, int keyval)
{
  char *guile_string = NULL;
  char *modifier = NULL;
  char *key_name = NULL;
  char *mod_end = NULL;
  SCM scm_retval;

  if (keyval == 0) {
    return 0;
  }

  key_name = gdk_keyval_name(keyval);
  if ( key_name == NULL ) {
    return 0;
  }

  /* don't pass the raw modifier key presses to the guile code */
  if (strstr(key_name, "Alt")    ||
      strstr(key_name, "Shift")  ||
      strstr(key_name, "Control") ) {
    return 0;
  }

  /* Allocate space for concatenation of all strings below */
  modifier = mod_end = g_strnfill(3*10, '\0');

  /* The accels below must be in alphabetic order! */
  if (state & GDK_MOD1_MASK) {
    mod_end = g_stpcpy(mod_end, "Alt ");
  }
  if (state & GDK_CONTROL_MASK) {
    mod_end = g_stpcpy(mod_end, "Control ");
  }
  if (state & GDK_SHIFT_MASK) {
    mod_end = g_stpcpy(mod_end, "Shift ");
  }

  if(strcmp(key_name, "Escape") == 0) {
     g_free(w_current->keyaccel_string);
     w_current->keyaccel_string = NULL;
  } else if(w_current->keyaccel_string &&
        strlen(w_current->keyaccel_string) + strlen(key_name) > 10) {
     g_free(w_current->keyaccel_string);
     w_current->keyaccel_string = g_strconcat(modifier, key_name, NULL);
  } else {
     gchar *p, *r;

     p = w_current->keyaccel_string;
     w_current->keyaccel_string = g_strconcat(modifier, key_name, NULL);
     if(p) {
        r = g_strconcat(p, w_current->keyaccel_string, NULL);
        g_free(p);
        g_free(w_current->keyaccel_string);
        w_current->keyaccel_string = r;
     }
  }

  i_show_state(w_current, NULL);

  guile_string = g_strdup_printf("(press-key \"%s%s\")",
                                 modifier, key_name);

#if DEBUG 
  printf("_%s_\n", guile_string);
#endif
  scm_retval = g_scm_c_eval_string_protected (guile_string);
  g_free(guile_string);
  g_free(modifier);

  return (SCM_FALSEP (scm_retval)) ? 0 : 1;
}
Example #4
0
/*! \brief Set new state, then show state field including some
 *         message
 *
 *  \par Function Description
 *  Set new state, then show state field including some
 *  message.
 *
 *  \param [in] w_current GSCHEM_TOPLEVEL structure
 *  \param [in] newstate The new state
 *  \param [in] message Message to be shown
 *   *EK* Egil Kvaleberg
 */
void i_set_state_msg(GSCHEM_TOPLEVEL *w_current, enum x_states newstate,
		     const char *message)
{
  w_current->event_state = newstate;
  i_show_state(w_current, message);
}