[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: g_funcs.c



  User: werner  
  Date: 07/02/24 06:47:35

  Modified:    .        g_funcs.c g_keys.c g_register.c gschem.c x_dialog.c
                        x_event.c
  Log:
  added Patricks keymap patch:
  
  	* scheme/gschem.scm (dump-keymap): New procedure for
  
          g_keys_dump_keymap() replacing old fill-mapped-keys.
  
  
  
  	* src/g_register.c, src/g_funcs.c (g_funcs_key_*): 
  
  	Removed functions. Replaced with g_keys_dump_keymap()
  
  
  
  	* src/g_keys.c (g_keys_dump_keymap): New function to obtain
  
  	current keymap from scheme.
  
  
  
  	* src/x_event.c, src/gschem.c, src/g_keys.c: 
  
  	Removed empty function set_window_current_key() 
  
  
  
  	* src/gschem.c, src/x_dialog.c: Adaptation for new
  
  	g_keys_dump_keymap(). (Patches written by Patrick Bernaud)
  
  
  
  
  Revision  Changes    Path
  1.22      +0 -66     eda/geda/gaf/gschem/src/g_funcs.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_funcs.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_funcs.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- g_funcs.c	22 Feb 2007 17:18:29 -0000	1.21
  +++ g_funcs.c	24 Feb 2007 11:47:33 -0000	1.22
  @@ -236,72 +236,6 @@
     return SCM_BOOL_T;
   }
   
  -/*! \brief */
  -static gchar *key_value_string = NULL;
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - *  \bug there is no string size checking here... so if it core dumps... DOH!
  - *  it's actually pretty usable right now, but needs to be reviewed again
  - */
  -SCM g_funcs_key_name(SCM keystring)
  -{
  -  SCM_ASSERT (SCM_STRINGP (keystring), keystring, 1, "gschem-key-name");
  -
  -  if (key_value_string != NULL) {
  -    x_dialog_hotkeys_fill (key_value_string);
  -    g_free (key_value_string); 
  -    key_value_string = NULL;
  -  }
  -
  -  /* the 25 is for a few spaces and the characters */
  -  key_value_string = g_strdup_printf ("%s :%25c",
  -                                      SCM_STRING_CHARS (keystring), ' ');
  -
  -  return SCM_BOOL_T;
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -SCM g_funcs_key_value(SCM keystring)
  -{
  -  gchar *temp;
  -
  -  SCM_ASSERT (SCM_STRINGP (keystring), keystring, 1, "gschem-key-value");
  -
  -  if (key_value_string == NULL) {
  -    fprintf(stderr, _("Ack! something got fouled up with the keymappings!\n"));
  -    exit(-1);
  -  }
  -
  -  temp = g_strdup_printf ("%s %s",
  -                          key_value_string,
  -                          SCM_STRING_CHARS (keystring));
  -  g_free (key_value_string);
  -  key_value_string = temp;
  -	
  -  return SCM_BOOL_T;
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -SCM g_funcs_key_done(void)
  -{
  -  x_dialog_hotkeys_fill (key_value_string);
  -  g_free(key_value_string);
  -  key_value_string = NULL;
  -  return SCM_BOOL_T;
  -}
  -
  -
   /*! \todo Finish function documentation!!!
    *  \brief
    *  \par Function Description
  
  
  
  1.6       +45 -11    eda/geda/gaf/gschem/src/g_keys.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_keys.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_keys.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- g_keys.c	23 Feb 2007 19:24:34 -0000	1.5
  +++ g_keys.c	24 Feb 2007 11:47:33 -0000	1.6
  @@ -45,17 +45,6 @@
    *  \par Function Description
    *
    */
  -void set_window_current_key(TOPLEVEL *w_current)
  -{
  -       /*window_current = w_current;*/
  -       /* this function is now a nop, remove it */
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
   /* for now this only supports single chars, not shift/alt/ctrl etc... */
   int g_keys_execute(int state, int keyval)
   {
  @@ -108,6 +97,51 @@
     return (SCM_FALSEP (scm_retval)) ? 0 : 1;
   }
   
  +/*! \brief Exports the keymap in scheme to a GLib GArray.
  + *  \par Function Description
  + *  This function converts the list of key sequence/action pairs
  + *  returned by the scheme function \c dump-current-keymap into an
  + *  array of C structures.
  + *
  + *  The returned value must be freed by caller.
  + *
  + *  \return A GArray with keymap data.
  +  */
  +GArray*
  +g_keys_dump_keymap (void)
  +{
  +  SCM dump_proc = scm_c_lookup ("dump-current-keymap");
  +  SCM scm_ret;
  +  GArray *ret = NULL;
  +  struct keyseq_action_t {
  +    gchar *keyseq, *action;
  +  };
  +
  +  dump_proc = scm_variable_ref (dump_proc);
  +  g_return_val_if_fail (SCM_NFALSEP (scm_procedure_p (dump_proc)), NULL);
  +
  +  scm_ret = scm_call_0 (dump_proc);
  +  g_return_val_if_fail (SCM_CONSP (scm_ret), NULL);
  +
  +  ret = g_array_sized_new (FALSE,
  +                           FALSE,
  +                           sizeof (struct keyseq_action_t),
  +                           (guint)scm_ilength (scm_ret));
  +  for (; scm_ret != SCM_EOL; scm_ret = SCM_CDR (scm_ret)) {
  +    SCM scm_keymap_entry = SCM_CAR (scm_ret);
  +    struct keyseq_action_t keymap_entry;
  +
  +    g_return_val_if_fail (SCM_CONSP (scm_keymap_entry) &&
  +                          SCM_SYMBOLP (SCM_CAR (scm_keymap_entry)) &&
  +                          SCM_STRINGP (SCM_CDR (scm_keymap_entry)), ret);
  +    keymap_entry.action = g_strdup (SCM_SYMBOL_CHARS (SCM_CAR (scm_keymap_entry)));
  +    keymap_entry.keyseq = g_strdup (SCM_STRING_CHARS (SCM_CDR (scm_keymap_entry)));
  +    ret = g_array_append_val (ret, keymap_entry);
  +  }
  +
  +  return ret;
  +}
  +
   /*! \brief
    *
    */
  
  
  
  1.52      +0 -3      eda/geda/gaf/gschem/src/g_register.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_register.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_register.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -b -r1.51 -r1.52
  --- g_register.c	23 Feb 2007 19:24:34 -0000	1.51
  +++ g_register.c	24 Feb 2007 11:47:33 -0000	1.52
  @@ -160,9 +160,6 @@
     { "gschem-print",              1, 0, 0, g_funcs_print },
     { "gschem-postscript",         1, 0, 0, g_funcs_postscript },
     { "gschem-image",              1, 0, 0, g_funcs_image },
  -  { "gschem-key-name",           1, 0, 0, g_funcs_key_name },
  -  { "gschem-key-value",          1, 0, 0, g_funcs_key_value },
  -  { "gschem-key-done",           0, 0, 0, g_funcs_key_done },
     { "gschem-use-rc-values",      0, 0, 0, g_funcs_use_rc_values },
     { "gschem-exit",               0, 0, 0, g_funcs_exit },
     { "gschem-log",                1, 0, 0, g_funcs_log },
  
  
  
  1.40      +0 -4      eda/geda/gaf/gschem/src/gschem.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: gschem.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/gschem.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- gschem.c	18 Oct 2006 19:01:29 -0000	1.39
  +++ gschem.c	24 Feb 2007 11:47:34 -0000	1.40
  @@ -59,7 +59,6 @@
     s_attrib_free();
     s_papersizes_free();
     x_stroke_free_all();
  -  x_dialog_hotkeys_free_all();
     s_color_destroy_all();
     o_undo_cleanup();
     /* s_stroke_free(); no longer needed */
  @@ -207,9 +206,6 @@
   
     x_window_setup (w_current);
   
  -  /* so we can call key funcs from guile */
  -  set_window_current_key(w_current);
  -
     /* o_text_init(); goes away */
     /* o_text_init(); Moved inside libgeda_init() */
   
  
  
  
  1.78      +28 -67    eda/geda/gaf/gschem/src/x_dialog.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_dialog.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_dialog.c,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -b -r1.77 -r1.78
  --- x_dialog.c	11 Feb 2007 08:51:39 -0000	1.77
  +++ x_dialog.c	24 Feb 2007 11:47:34 -0000	1.78
  @@ -2373,63 +2373,6 @@
   
   /***************** Start of help/keymapping dialog box **************/
   
  -static GList *hotkeys = NULL;
  -
  -typedef struct _HOTKEY ST_HOTKEY;
  -
  -struct _HOTKEY {
  -  gchar *name;
  -  gchar *value;
  -};
  -
  -
  -/*! \brief Clear the hotkey list of the hotkeys dialog
  - *  \par Function Description
  - *  This function free's all elements allocated by the hotkey dialog
  - */
  -void x_dialog_hotkeys_free_all(void)
  -{
  -  GList *item;
  -  ST_HOTKEY *hotkey;
  -
  -  for (item = hotkeys; item != NULL; item = g_list_next(item)) {
  -    hotkey = item->data;
  -    g_free(hotkey->name);
  -    g_free(hotkey->value);
  -    g_free(hotkey);
  -  }
  -  g_list_free(hotkeys);
  -  hotkeys = NULL;
  -}
  -
  -/*! \brief Insert a hotkey string into the dialog hotkey list
  - *  \par Function Description
  - *  This function splits the given hotkey string and adds it to the hotkey
  - *  list.
  - *  \todo Change the function and its callers to f(char *name, char *value).
  - */
  -void x_dialog_hotkeys_fill(char *string) 
  -{
  -  ST_HOTKEY *hotkey;
  -  gchar **token;
  -  
  -  hotkey = g_new(ST_HOTKEY, 1);
  -  token = g_strsplit(string, ":", 2);
  -
  -  if (token[0] != NULL) {
  -    hotkey->name = g_strdup(token[0]);
  -    if (token[1] != NULL) {
  -      g_strstrip(token[1]);
  -      hotkey->value = g_strdup(token[1]);
  -      hotkeys = g_list_append(hotkeys, hotkey);
  -    }
  -    else {
  -      g_free(hotkey->name);
  -    }
  -  }
  -  g_strfreev(token);
  -}
  -
   /*! \brief Response function for the hotkey dialog
    *  \par Function Description
    *  This function destroys the hotkey dialog and does some cleanup.
  @@ -2460,11 +2403,13 @@
     GtkWidget *vbox, *scrolled_win;
     GtkListStore *store;
     GtkWidget *treeview;
  -  GtkTreeIter iter;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
  -  ST_HOTKEY *hotkey;
  -  GList *item;
  +  GArray *keymap;
  +  gint i;
  +  struct keyseq_action_t {
  +    gchar *keyseq, *action;
  +  };
   
     if (!w_current->hkwindow) {
       w_current->hkwindow = gtk_dialog_new_with_buttons(_("Hotkeys"),
  @@ -2499,15 +2444,31 @@
   
       /* the model */
       store = gtk_list_store_new (2,G_TYPE_STRING, G_TYPE_STRING);
  -    for (item=hotkeys; item != NULL; item =g_list_next(item)) {
  -      hotkey = item->data;
  -      gtk_list_store_append(store, &iter);
  -      gtk_list_store_set(store, &iter,
  -			 0, hotkey->name,
  -			 1, hotkey->value,
  +
  +    /* retrieve current keymap */
  +    keymap = g_keys_dump_keymap ();
  +    /* add each keymap entry to the list store of the dialog */
  +    for (i = 0; i < keymap->len; i++) {
  +      GtkTreeIter iter;
  +      struct keyseq_action_t *keymap_entry;
  +      
  +      keymap_entry = &g_array_index (keymap, struct keyseq_action_t, i);
  +      gtk_list_store_append (store, &iter);
  +      gtk_list_store_set (store, &iter,
  +                          0, keymap_entry->action,
  +                          1, keymap_entry->keyseq,
   			 -1);
       }
   
  +    /* finally free the array for keymap */
  +    for (i = 0; i < keymap->len; i++) {
  +      struct keyseq_action_t *keymap_entry;
  +      keymap_entry = &g_array_index (keymap, struct keyseq_action_t, i);
  +      g_free (keymap_entry->keyseq);
  +      g_free (keymap_entry->action);
  +    }
  +    g_array_free (keymap, TRUE);
  +
       /* the tree view */
       treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
       gtk_container_add(GTK_CONTAINER(scrolled_win), treeview);
  
  
  
  1.44      +0 -2      eda/geda/gaf/gschem/src/x_event.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_event.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_event.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -b -r1.43 -r1.44
  --- x_event.c	21 Dec 2006 20:40:37 -0000	1.43
  +++ x_event.c	24 Feb 2007 11:47:35 -0000	1.44
  @@ -1479,8 +1479,6 @@
     exit_if_null(w_current);
     global_window_current = w_current;
   
  -  set_window_current_key(w_current);
  -
     if (event) {
   #if DEBUG
       printf("x_event_key_pressed: Pressed key %i.\n", event->keyval);
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs