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

gEDA-cvs: CVS update: i_callbacks.c



  User: pbernaud
  Date: 06/09/23 05:01:06

  Modified:    .        i_callbacks.c x_compselect.c x_window.c
  Log:
  Rewrote component selection dialog with single tree and filtering
  
  
  
  
  Revision  Changes    Path
  1.64      +1 -1      eda/geda/gaf/gschem/src/i_callbacks.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: i_callbacks.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_callbacks.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -b -r1.63 -r1.64
  --- i_callbacks.c	23 Sep 2006 08:47:56 -0000	1.63
  +++ i_callbacks.c	23 Sep 2006 09:01:06 -0000	1.64
  @@ -2492,7 +2492,7 @@
   
     exit_if_null(w_current);
   
  -  x_compselect_setup(w_current);
  +  x_compselect_open (w_current);
   
   #if 0 /* replaced by above */
     setup_place_file_selector(w_current);
  
  
  
  1.3       +650 -950  eda/geda/gaf/gschem/src/x_compselect.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_compselect.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_compselect.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- x_compselect.c	23 Sep 2006 08:41:39 -0000	1.2
  +++ x_compselect.c	23 Sep 2006 09:01:06 -0000	1.3
  @@ -47,1067 +47,767 @@
   
   #include "../include/x_preview.h"
   
  -#define DIR_LIST_WIDTH   180
  -#define DIR_LIST_HEIGHT  180
  -#define FILE_LIST_WIDTH  180
  -#define FILE_LIST_HEIGHT 180
  +#include "../include/x_compselect.h"
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_destroy_window(GtkWidget *widget, FILEDIALOG *f_current)
  -{
  -
  -#if DEBUG
  -  printf("destroy\n");
  -#endif
  -  x_compselect_free_list_buffers(f_current);
  -
  -  if (f_current->directory) {
  -    free(f_current->directory);
  -    f_current->directory = NULL;
  -  }
   
  -  if (f_current->filename) {
  -    free(f_current->filename);
  -    f_current->filename = NULL;
  -  }
  -
  -  gtk_grab_remove(f_current->xfwindow);
  -  f_current->toplevel = NULL;
  -  f_current->xfwindow = NULL;
  -  /* *window = NULL;*/
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Process the response returned by the component selection dialog.
    *  \par Function Description
  + *  This function handles the response <B>arg1</B> of the component
  + *  selection dialog <B>dialog</B>.
    *
  + *  Parameter <B>user_data</B> is a pointer on the relevant toplevel
  + *  structure.
  + *
  + *  \param [in] dialog    The component selection dialog.
  + *  \param [in] arg1      The response ID.
  + *  \param [in] user_data A pointer on the toplevel environment.
    */
  -int
  -x_compselect_keypress(GtkWidget * widget, GdkEventKey * event, 
  -                      FILEDIALOG* f_current)
  +static void
  +x_compselect_callback_response (GtkDialog *dialog,
  +                                gint arg1,
  +                                gpointer user_data)
   {
  -  if (strcmp(gdk_keyval_name(event->keyval), "Escape") == 0) {
  -    x_compselect_close (NULL, f_current);
  -    return TRUE;
  -  }
  +  Preview *preview = (Preview*)dialog;
  +  TOPLEVEL *toplevel = (TOPLEVEL*)user_data;
   
  -  return FALSE;
  -}
  +  switch (arg1) {
  +      case GTK_RESPONSE_APPLY: {
  +        gchar *filename, *directory, *component;
  +        CompselectBehavior behavior;
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_init_list_buffers(FILEDIALOG *f_current) 
  -{
  -  int i;
  +        g_object_get (preview,
  +                      "filename", &filename,
  +                      "behavior", &behavior,
  +                      NULL);
   
  -  for (i = 0; i < MAX_FILES; i++) {
  -    f_current->file_entries[i] = NULL;
  +        toplevel->include_complex = toplevel->embed_complex = 0;
  +        switch (behavior) {
  +            case COMPSELECT_BEHAVIOR_REFERENCE:
  +              break;
  +            case COMPSELECT_BEHAVIOR_EMBED:
  +              toplevel->embed_complex   = 1;
  +              break;
  +            case COMPSELECT_BEHAVIOR_INCLUDE:
  +              toplevel->include_complex = 1;
  +              break;
  +            default:
  +              g_assert_not_reached();
     }
   
  -  for (i = 0; i < MAX_DIRS; i++) {
  -    f_current->directory_entries[i] = NULL;
  +        if (filename == NULL) {
  +          break;
     }
           
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_free_list_buffers(FILEDIALOG *f_current) 
  -{
  -  int i;
  +        component = g_path_get_basename (filename);
  +        directory = g_path_get_dirname  (filename);
  +        g_free (filename);
   
  -  for (i = 0; i < MAX_FILES; i++) {
  -    if (f_current->file_entries[i]) 
  -      free(f_current->file_entries[i]);
  +        if (toplevel->current_clib == NULL ||
  +            g_ascii_strcasecmp (toplevel->current_clib, directory) != 0 ||
  +            toplevel->current_basename == NULL ||
  +            g_ascii_strcasecmp (toplevel->current_basename, component) != 0) {
  +          gint diff_x, diff_y;
  +          
  +          g_free (toplevel->current_clib);
  +          toplevel->current_clib = directory;
  +        
  +          strcpy (toplevel->current_basename, component);
  +          g_free (component);
  +        
  +          if (toplevel->event_state == ENDCOMP) {
  +            diff_x = toplevel->last_x - toplevel->start_x;
  +            diff_y = toplevel->last_y - toplevel->start_y;
   
  -    f_current->file_entries[i] = NULL;
  +            o_complex_translate_display(toplevel,
  +                                        diff_x, diff_y,
  +                                        toplevel->page_current->complex_place_head);
     }
   
  -  for (i = 0; i < MAX_DIRS; i++) {
  -    if (f_current->directory_entries[i]) 
  -    free(f_current->directory_entries[i]);
  +          o_list_delete_rest(toplevel,
  +                             toplevel->page_current->complex_place_head);
  +          o_complex_set_filename(toplevel, toplevel->current_clib,
  +                                 toplevel->current_basename);
   
  -    f_current->directory_entries[i] = NULL;
  +          toplevel->event_state = DRAWCOMP;
  +        } else {
  +          g_free (component);
  +          g_free (directory);
  +        }
  +        break;
  +      }
  +      case GTK_RESPONSE_CLOSE:
  +      case GTK_RESPONSE_DELETE_EVENT:
  +        g_assert (GTK_WIDGET (dialog) == toplevel->cswindow);
  +        gtk_widget_destroy (GTK_WIDGET (dialog));
  +        toplevel->cswindow = NULL;
  +        break;
  +      default:
  +        g_assert_not_reached ();
     }
  -}
   
  -/*! \section component-place-specific-code Component Place Specific Code.
  - *  \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -gint
  -default_components(GtkWidget *w, TOPLEVEL *w_current)
  -{
  -  w_current->embed_complex = 0;
  -  w_current->include_complex = 0;
  -  return(0);
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Opens a component selection dialog.
    *  \par Function Description
  + *  This function opens the component chooser dialog for
  + *  <B>toplevel</B> if it is not already. In this last case, it only
  + *  raises the dialog.
    *
  + *  \param [in] toplevel The toplevel environment.
    */
  -gint
  -embed_components(GtkWidget *w, TOPLEVEL *w_current)
  +void
  +x_compselect_open (TOPLEVEL *toplevel)
   {
  -  w_current->embed_complex = 1;
  -  w_current->include_complex = 0;
  -  return(0);
  -}
  +  if (toplevel->cswindow == NULL) {
  +    toplevel->cswindow = GTK_WIDGET (
  +      g_object_new (TYPE_COMPSELECT,
  +                    NULL));
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -gint
  -include_components(GtkWidget *w, TOPLEVEL *w_current)
  -{
  -  w_current->include_complex = 1;
  -  w_current->embed_complex = 0;
  -  return(0);
  -}
  +    g_signal_connect (toplevel->cswindow,
  +                      "response",
  +                      G_CALLBACK (x_compselect_callback_response),
  +                      toplevel);
  +    
  +    gtk_widget_show (toplevel->cswindow);
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - *  \note
  - *  this is from gtktest.c
  - */
  -static GtkWidget*
  -create_menu (TOPLEVEL *w_current)
  -{
  -  GtkWidget *menu;
  -  GtkWidget *menuitem;
  -  GSList *group;
  -  char *buf;
  -
  -  menu = gtk_menu_new ();
  -  group = NULL;
  -
  -  buf = g_strdup_printf(_("Default behavior - reference component"));
  -  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
  -  free(buf);
  -  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
  -  gtk_menu_append (GTK_MENU (menu), menuitem);
  -  gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
  -                     (GtkSignalFunc) default_components,
  -                     w_current);
  -
  -  gtk_widget_show(menuitem);
  -
  -  buf = g_strdup_printf(_("Embed component in schematic"));
  -  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
  -  free(buf);
  -  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
  -  gtk_menu_append (GTK_MENU (menu), menuitem);
  -  gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
  -                     (GtkSignalFunc) embed_components,
  -                     w_current);
  -  gtk_widget_show(menuitem);
  -
  -  buf = g_strdup_printf(_("Include component as individual objects"));
  -  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
  -  free(buf);
  -  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
  -  gtk_menu_append (GTK_MENU (menu), menuitem);
  -  gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
  -                     (GtkSignalFunc) include_components,
  -                     w_current);
  -  gtk_widget_show(menuitem);
  -
  -  if (w_current->embed_complex) {
  -    gtk_menu_set_active(GTK_MENU (menu),1);
  -    embed_components(NULL, w_current);
     } else {
  -    default_components(NULL, w_current);
  +    gdk_window_raise (toplevel->cswindow->window);
     }
   
  -  return menu;
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Closes the component selection dialog.
    *  \par Function Description
  + *  This function closes the component chooser dialog associated with
  + *  <B>toplevel</B>.
    *
  + *  \param [in] toplevel The toplevel environment.
    */
   void
  -x_compselect_comp_fill_libs(TOPLEVEL *w_current, FILEDIALOG *f_current)
  +x_compselect_close (TOPLEVEL *toplevel)
   {
  -  char *text[2];
  -  char *temp;
  -  int i;
  -  int max_width=0;
  -  int width;
  -  int first,last,done,j;                /* variables for the sort */
  -  const GSList *dirs, *dir;
  -
  -  gtk_clist_freeze (GTK_CLIST (f_current->dir_list));
  -  gtk_clist_clear (GTK_CLIST (f_current->dir_list));
  -
  -  i = 0;
  -  text[0] = NULL;
  -  text[1] = NULL;
  -  max_width = 0;
  -
  -  /* populate the directory list */
  -  dirs = s_clib_get_directories ();
  -  for (dir = dirs; dir != NULL; dir = g_slist_next (dir)) {
  -    gchar *string = (gchar*)dir->data;
  -
  -    temp = strrchr(string, G_DIR_SEPARATOR);
  -    if (temp) {
  -      temp++; /* get past last '/' */
  -      text[0] = temp;
  -    } else {
  -      text[0] = string;
  +  if (toplevel->cswindow) {
  +    g_assert (IS_COMPSELECT (toplevel->cswindow));
  +    gtk_widget_destroy (toplevel->cswindow);
  +    toplevel->cswindow = NULL;
       }
   
  -    f_current->directory_entries[i++] = g_strdup (string);
  +}
       
  -    gtk_clist_append (GTK_CLIST (f_current->dir_list), text);
   
  -    width = gdk_string_width(gtk_style_get_font(f_current->dir_list->style), 
  -                             text[0]);
   
  -    if (width > max_width) {
  -      gtk_clist_set_column_width(GTK_CLIST(f_current->
  -                                           dir_list), 0, width);
  -      max_width = width;
  -    }
  -  }
  +enum {
  +  PROP_FILENAME=1,
  +  PROP_BEHAVIOR,
  +};
   
  -  gtk_clist_thaw (GTK_CLIST (f_current->dir_list));
  -  f_current->last_search_lib = -1;
   
  -  /* added sort for the directory list so it would match the 
  -     automatically sorted clist of directories
  -     Chris Ellec - May 2001                           */
  -  if (w_current->sort_component_library == TRUE) {
  -    done = 0;
  -    first = 0;
  -    last = i;
  -    while(!done) {
  -      done = 1;
  -      for (j = first ; j < last-1; j++) {
  -        /*printf ("%i:",j);*/
  -        if (strcmp(f_current->directory_entries[j], 
  -                   f_current->directory_entries[j+1]) > 0) {
  -          temp = f_current->directory_entries[j];
  -          f_current->directory_entries[j] = 
  -            f_current->directory_entries[j+1];
  -          f_current->directory_entries[j+1] = temp;
  -          done = 0;
  -        }
  -      }
  -      last = last - 1;
  +static void compselect_class_init (CompselectClass *class);
  +static void compselect_init       (Compselect *compselect);
  +static void compselect_set_property (GObject *object,
  +                                     guint property_id,
  +                                     const GValue *value,
  +                                     GParamSpec *pspec);
  +static void compselect_get_property (GObject *object,
  +                                     guint property_id,
  +                                     GValue *value,
  +                                     GParamSpec *pspec);
   
  -#if DEBUG 
  -      pass_count++;
  -#endif
  -    }
  -  }
  -}
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Sets data for a particular cell of the treeview.
    *  \par Function Description
  + *  This function determines what data is to be displayed in the
  + *  component column of the selection tree.
  + *
  + *  Any toplevel entry of the model (that is one without parent)
  + *  represents an absolute path to a directory of the component
  + *  library. Only the last part of the path is displayed. Otherwise it
  + *  simply copies data from the model to the column.
    *
  + *  \param [in] tree_column The GtkTreeColumn.
  + *  \param [in] cell        The GtkCellRenderer that is being rendered
  + *                          by tree_column.
  + *  \param [in] tree_model  The tree model for components.
  + *  \param [in] iter        An iterator on the current row to render.
  + *  \param [in] data        Unused user data.
    */
  -void
  -x_compselect_comp_fill_components(FILEDIALOG *f_current, int row)
  +static void
  +compselect_treeview_set_cell_data (GtkTreeViewColumn *tree_column,
  +                                   GtkCellRenderer   *cell,
  +                                   GtkTreeModel      *tree_model,
  +                                   GtkTreeIter       *iter,
  +                                   gpointer           data)
   {
  -  GSList *filenames, *filename;
  -  gint width = 0, max_width = 0;
  -        
  -  gtk_clist_freeze (GTK_CLIST (f_current->file_list));
  -  gtk_clist_clear (GTK_CLIST (f_current->file_list));
  +  GtkTreeIter parent;
  +  GValue value = { 0, };
   
  -  /* update current_clib in toplevel with new directory name */
  -  if (f_current->toplevel->current_clib) {
  -    free (f_current->toplevel->current_clib);
  +  gtk_tree_model_get_value (tree_model, iter, 0, &value);
  +  if (!gtk_tree_model_iter_parent (tree_model, &parent, iter)) {
  +    g_value_set_string_take_ownership (
  +      &value, g_path_get_basename (g_value_get_string (&value)));
     }
  -  f_current->toplevel->current_clib = g_strdup (
  -    f_current->directory_entries[row]);
  -
  -  /* get the list of filenames in directory */
  -  filenames = s_clib_get_files (f_current->directory_entries[row], ".sym");
  +  g_object_set_property ((GObject*)cell, "text", &value);
   
  -  filename = filenames;
  -  while (filename != NULL) {
  -    gchar *text[2];
  -
  -    text[0] = (gchar*) filename->data;
  -    text[1] = NULL;
  -    
  -    /* add filename to the clist */
  -    gtk_clist_append (GTK_CLIST (f_current->file_list), text);
  -    
  -    width = gdk_string_width (gtk_style_get_font (
  -                                f_current->file_list->style),
  -                              (gchar*) filename->data);
  -    if (width > max_width) {
  -      /* increase the width of the column */
  -      gtk_clist_set_column_width (GTK_CLIST (f_current->file_list),
  -                                  0, width);
  -      max_width = width;
  -    }
  -    
  -    /* continue with the next filename */
  -    filename = g_slist_next (filename);
  -  }
  -
  -  /* get ride of the list of filenames */
  -  g_slist_foreach (filenames, (GFunc)free, NULL);
  -  g_slist_free (filenames);
  -
  -  /* allow visual updates to clist */
  -  gtk_clist_thaw (GTK_CLIST (f_current->file_list));
  +  g_value_unset (&value);
         
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Determines visibility of items of the treeview.
    *  \par Function Description
  + *  This is the function used to filter entries of the component
  + *  selection tree.
    *
  - *  \note
  - *  don't pass in f_current->filename or f_current->directory for component
  - *  or library
  + *  \param [in] model The current selection in the treeview.
  + *  \param [in] iter  An iterator on a component or folder in the tree.
  + *  \param [in] data  The component selection dialog.
  + *  \returns TRUE if item should be visible, FALSE otherwise.
    */
  -void
  -x_compselect_comp_update_current(FILEDIALOG *f_current, 
  -                                 char *library, char *component)
  +static gboolean
  +compselect_model_filter_visible_func (GtkTreeModel *model,
  +                                      GtkTreeIter  *iter,
  +                                      gpointer      data)
   {
  -  char *temp=NULL;
  +  Compselect *compselect = (Compselect*)data;
  +  gchar *compname;
  +  const gchar *text;
  +  gboolean ret;
   
  -  /* component */
  -  if (f_current->filename) {
  -    free(f_current->filename);
  -    f_current->filename = NULL;
  -  }
  +  g_assert (IS_COMPSELECT (data));
   
  -  /* library */
  -  if (f_current->directory) {
  -    free(f_current->directory);
  -    f_current->directory = NULL;
  +  text = gtk_entry_get_text (compselect->entry_filter);
  +  if (text == NULL) {
  +    return TRUE;
     }
   
  -  if (library) {
  -    f_current->directory = g_strdup(library);
  -  } else {
  -    f_current->directory = NULL;
  -  }
  +  if (gtk_tree_model_iter_has_child (model, iter)) {
  +    GtkTreeIter iter2;
   
  -  if (component) {
  -    f_current->filename = g_strdup(component);
  -  } else {
  -    f_current->filename = NULL;
  +    gtk_tree_model_iter_children (model, &iter2, iter);
  +    ret = FALSE;
  +    do {
  +      if (compselect_model_filter_visible_func (model, &iter2, data)) {
  +        ret = TRUE;
  +        break;
     }
  -
  -  if (f_current->directory && f_current->filename) {
  -#ifdef __MINGW32__
  -    if (u_basic_has_trailing(f_current->directory, G_DIR_SEPARATOR)) {
  -        temp = g_strconcat (f_current->directory, 
  -                            f_current->filename, NULL);
  +    } while (gtk_tree_model_iter_next (model, &iter2));
       } else {
  -#endif
  -        temp = g_strconcat (f_current->directory, 
  -                            G_DIR_SEPARATOR_S,
  -                            f_current->filename, NULL);
  -#ifdef __MINGW32__
  -    }
  -#endif
  -    gtk_entry_set_text(GTK_ENTRY(f_current->filename_entry), temp);
  -    free(temp);
  -  } else if (f_current->directory && !f_current->filename) {
  -    gtk_entry_set_text(GTK_ENTRY(f_current->filename_entry), 
  -                       f_current->directory);
  -  } else if (!f_current->directory) {
  -    gtk_entry_set_text(GTK_ENTRY(f_current->filename_entry), 
  -                       "NONE");
  -  }
  -
  -#if 0 /* old code */
  -  if (f_current->directory && f_current->filename) {
  -    temp = g_strconcat (f_current->directory, 
  -                        f_current->filename, NULL);
  -    gtk_label_set(GTK_LABEL(f_current->filename_entry), temp);
  -  } else if (f_current->directory && !f_current->filename) {
  -    gtk_label_set(GTK_LABEL(f_current->filename_entry), 
  -                  f_current->directory);
  -  } else if (!f_current->directory) {
  -    gtk_label_set(GTK_LABEL(f_current->filename_entry), 
  -                  " ");
  -  }
  -#endif
  -
  -#if DEBUG 
  -  printf("directory: %s\n", f_current->directory);
  -  printf("filename: %s\n", f_current->filename);
  -#endif
  +    gtk_tree_model_get (model, iter,
  +                        0, &compname,
  +                        -1);
  +    ret = (strstr (compname, text) != NULL);
  +    g_free (compname);
  +  }
   
  +  return ret;
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Handles changes in the filter entry.
    *  \par Function Description
  + *  This is the callback function that is called every time the user
  + *  select a row in the component treeview of the dialog.
    *
  - */
  -void
  -x_compselect_change_clib(FILEDIALOG *f_current, char *new_clib,
  -                         int row)
  -{
  -  x_compselect_comp_update_current(f_current, new_clib, NULL);
  -  x_compselect_comp_fill_components(f_current, row);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  + *  If the selection is not a selection of a component (a directory
  + *  name), it does nothing. Otherwise it retrieves the component and
  + *  directory name from the model (the directory name is build from
  + *  the ancestors of the row in the model).
    *
  - */
  -void
  -x_compselect_lib_select (GtkWidget *widget, gint row, gint column,
  -                         GdkEventButton *bevent, FILEDIALOG *f_current)
  -{
  -  char *temp = NULL;
  -
  -  gtk_clist_get_text (GTK_CLIST (f_current->dir_list), row, 0, &temp);
  -
  -  if (temp) {   
  -#if DEBUG 
  -    printf("selected: %d _%s_ _%s_\n", row, temp, 
  -           f_current->directory_entries[row]);
  -#endif
  -    if (bevent) {
  -      switch (bevent->type) {
  -        /*      case(GDK_2BUTTON_PRESS): */
  -        default:
  -          x_compselect_change_clib(f_current, 
  -                                   f_current->directory_entries[row],
  -                                   row);
  -          break;
  -
  -      }
  -    }
  -  }
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  + *  It then emits the dialog's <B>apply</B> signal to let its parent
  + *  know that a component has been selected.
    *
  + *  \param [in] selection The current selection in the treeview.
  + *  \param [in] user_data The component selection dialog.
    */
  -void
  -x_compselect_comp_select (GtkWidget *widget, gint row, gint column,
  -                         GdkEventButton *bevent, FILEDIALOG *f_current)
  +static void
  +compselect_callback_tree_selection_changed (GtkTreeSelection *selection,
  +                                            gpointer          user_data)
   {
  -  char *comp = NULL;
  -  int diff_x, diff_y;
  -  TOPLEVEL *w_current;
  +  GtkTreeModel *model;
  +  GtkTreeIter iter, parent;
  +  Compselect *compselect = (Compselect*)user_data;
  +  GString *ret;
  +  gchar *value, *filename;
   
  -  w_current = f_current->toplevel;
  +  if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
  +    return;
  +  }
   
  -  gtk_clist_get_text (GTK_CLIST (f_current->file_list), row, 0, &comp);
  +  if (gtk_tree_model_iter_has_child (model, &iter)) {
  +    /* selected element is not a leaf -> not a component name */
  +    return;
  +  }
   
  -  if (comp) {   
  -    strcpy(w_current->current_basename, comp);
  +  /* build full path to component looking at parents */
  +  gtk_tree_model_get (model, &iter, 0, &value,-1);
  +  ret = g_string_new (value);
  +  g_free (value);
  +  while (gtk_tree_model_iter_parent (model, &parent, &iter)) {
  +    gtk_tree_model_get (model, &parent, 0, &value, -1);
  +    ret = g_string_prepend (ret, G_DIR_SEPARATOR_S);
  +    ret = g_string_prepend (ret, value);
  +    g_free (value);
  +    iter = parent;
  +  }
  +  filename = g_string_free (ret, FALSE);
   
  -    if (w_current->current_clib && comp) {
  -      gchar *filename = g_build_filename (w_current->current_clib,
  -                                          comp, NULL);
  -      g_object_set (f_current->preview,
  +  /* update the treeview with new filename */
  +  g_object_set (compselect->preview,
                       "filename", filename,
                       NULL);
  -      g_free (filename);
  -    }
  -
  -    x_compselect_comp_update_current(f_current, 
  -                                     w_current->current_clib, comp);
   
  -    if (w_current->event_state == ENDCOMP) {
  -      diff_x = w_current->last_x - w_current->start_x;
  -      diff_y = w_current->last_y - w_current->start_y;
  -
  -      o_complex_translate_display(w_current,
  -                                  diff_x, diff_y,
  -                                  w_current->page_current->complex_place_head);
  -    }
  +  /* signal a component has been selected to parent of dialog */
  +  g_signal_emit_by_name (compselect,
  +                         "response",
  +                         GTK_RESPONSE_APPLY,
  +                         NULL);
   
  -    o_list_delete_rest(w_current,
  -                       w_current->page_current->complex_place_head);
  -    o_complex_set_filename(w_current, w_current->current_clib,
  -                           w_current->current_basename);
  +  g_free (filename);
   
  -    w_current->event_state = DRAWCOMP;
  -  }
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Handles changes in the filter entry.
    *  \par Function Description
  + *  This is the callback function called every time the contents of
  + *  the filter entry is modified.
  + *
  + *  If the entry is non-empty, it enables component filtering through
  + *  <B>compselect_component_store_filter_func()</B> that uses the text
  + *  from the entry.
  + *
  + *  Otherwise the filtering capability of the dialog is disabled.
    *
  + *  \param [in] entry     The filter text entry.
  + *  \param [in] user_data The component selection dialog.
    */
  -void
  -x_compselect_comp_apply(GtkWidget *w, FILEDIALOG *f_current)
  +static void
  +compselect_callback_filter_entry_activate (GtkEntry *entry,
  +                                           gpointer  user_data)
   {
  -  TOPLEVEL *w_current;
  -  int diff_x, diff_y;
  -        
  -  w_current = f_current->toplevel;
  +  Compselect *compselect = COMPSELECT (user_data);
  +  GtkTreeModel *model    = gtk_tree_view_get_model (compselect->treeview);
   
  -  if (w_current->current_basename && w_current->current_clib) {
  -    if (w_current->event_state == ENDCOMP) {
  -      diff_x = w_current->last_x - w_current->start_x;
  -      diff_y = w_current->last_y - w_current->start_y;
  +  gtk_tree_model_filter_refilter ((GtkTreeModelFilter*)model);
   
  -      o_complex_translate_display(w_current,
  -                                  diff_x, diff_y,
  -                                  w_current->page_current->complex_place_head);
  -    }
  -
  -    o_list_delete_rest(w_current,
  -                       w_current->page_current->complex_place_head);
  -    o_complex_set_filename(w_current, w_current->current_clib,
  -                           w_current->current_basename);
  -
  -    w_current->event_state = DRAWCOMP;
  -  }
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Handles changes of behavior.
    *  \par Function Description
  + *  This function is called every time the value of the option menu
  + *  for behaviors is modified.
    *
  + *  It emits the dialog's <B>apply</B> signal to let the parent know
  + *  that the requested behavior for the next adding of a component has
  + *  been changed.
  + *
  + *  \param [in] optionmenu The behavior option menu.
  + *  \param [in] user_data  The component selection dialog.
    */
  -void
  -x_compselect_comp_close (GtkWidget *w, FILEDIALOG *f_current)
  +static void
  +compselect_callback_behavior_changed (GtkOptionMenu *optionmenu,
  +                                      gpointer user_data)
   {
  -  TOPLEVEL *w_current;
  -
  -  w_current = f_current->toplevel;
  +  Compselect *compselect = (Compselect*)user_data;
   
  -  /* erase any existing component while it's being placed */
  -  /* do this instead of the below o_redraw_all */
  -  if (w_current->inside_action &&
  -      (w_current->event_state == ENDCOMP ||
  -       w_current->event_state == DRAWCOMP)) {
  -    o_complex_rubbercomplex(w_current);
  -  }
  -
  -  o_list_delete_rest(w_current, w_current->page_current->
  -                     complex_place_head);
  -
  -  i_set_state(w_current, SELECT);
  -  i_update_toolbar(w_current);
  -
  -  gtk_widget_destroy(GTK_WIDGET(f_current->xfwindow));
  -  f_current->xfwindow = NULL;
  -  /* do nothing if close is pressed for SAVEAS_CLOSE case */
  +  g_signal_emit_by_name (compselect,
  +                         "response",
  +                         GTK_RESPONSE_APPLY,
  +                         NULL);
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -int
  -x_compselect_search_library(FILEDIALOG *f_current,
  -                            char *library, const char *string) 
  +static GtkTreeModel*
  +compselect_create_child_model (void)
   {
  -  GSList *filenames, *filename;
  -  int ret;
  +  GtkTreeStore *store;
  +  const GSList *directories, *dir; 
   
  -  /* get the filenames with '.sym' in library */
  -  filenames = s_clib_get_files(library, ".sym");
  +  store = (GtkTreeStore*)gtk_tree_store_new (1,
  +                                             G_TYPE_STRING);
   
  -  if (f_current->last_search == -1) {
  -    /* last search failed: start over */
  -    f_current->last_search = 0;
  -  }
  -
  -  /* start search from last known position */
  -  filename = g_slist_nth (filenames, (guint)f_current->last_search);
  -  while (filename != NULL) {
  -    /* increase position in search */
  -    f_current->last_search++;
  -
  -    /* does filename match the query? */
  -    if (strstr ((gchar*) filename->data, string)) {
  -      /* yes, stop the search, prepare to return last_search */
  -#if DEBUG
  -      printf("found: %s %s %s %d\n", library, filename->data, string, f_current->last_search - 1);
  -#endif
  -      break;
  -    }
  +  /* populate component store */
  +  directories = s_clib_get_directories ();
  +  for (dir = directories; dir != NULL; dir = g_slist_next (dir)) {
  +    GtkTreeIter iter, iter2;
  +    GSList *components, *comp;
       
  -    filename = g_slist_next (filename);
  -  }
  +    gtk_tree_store_append (store, &iter, NULL);
  +    gtk_tree_store_set (store, &iter,
  +                        0, dir->data,
  +                        -1);
   
  -  /* free the list of filenames */
  -  g_slist_foreach (filenames, (GFunc)free, NULL);
  -  g_slist_free (filenames);
  +    components = s_clib_get_files ((gchar*)dir->data, ".sym");
  +    components = g_slist_sort (components, (GCompareFunc)g_ascii_strcasecmp);
  +    for (comp = components; comp != NULL; comp = g_slist_next (comp)) {
  +      gtk_tree_store_append (store, &iter2, &iter);
  +      gtk_tree_store_set (store, &iter2,
  +                          0, comp->data,
  +                          -1);
  +    }
   
  -  /* nothing found? */
  -  if (filename == NULL) {
  -    /* no, reset for next search */
  -    f_current->last_search = -1;
  -    ret = -1;
  -  } else {
  -    /* yes, return the position in the list of the filename found */
  -    ret = f_current->last_search - 1;
  +    g_slist_foreach (components, (GFunc)g_free, NULL);
  +    g_slist_free (components);
     }
   
  -  return ret;
  +  return (GtkTreeModel*)store;
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Create the combo box for behaviors.
    *  \par Function Description
  - *
  - *  \note
  - *  don't use widget, since it can be NULL
  + *  This function creates and returns a <B>GtkComboBox</B> for
  + *  selecting the behavior when a component is added to the sheet.
    */
  -void
  -x_compselect_comp_search(GtkWidget *w, FILEDIALOG *f_current)
  +static GtkWidget*
  +compselect_create_behaviors_combo_box (void)
   {
  -  TOPLEVEL *w_current;
  -  const char *string;
  -  int lib_count;
  -  int flag;
  +  GtkWidget *combobox;
   
  -  w_current = f_current->toplevel;
  +  combobox = gtk_combo_box_new_text ();
   
  -  string = gtk_entry_get_text(GTK_ENTRY(f_current->search_entry));
  +  /* Note: order of items in menu is important */
  +  /* COMPSEL_BEHAVIOR_REFERENCE */
  +  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox),
  +                             _("Default behavior - reference component"));
  +  /* COMPSEL_BEHAVIOR_EMBED */
  +  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), 
  +                             _("Embed component in schematic"));
  +  /* COMPSEL_BEHAVIOR_INCLUDE */
  +  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox),
  +                             _("Include component as individual objects"));
  +
  +  gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
  +  
  +  return combobox;
  +}
  +
  +GType
  +compselect_get_type ()
  +{
  +  static GType compselect_type = 0;
  +  
  +  if (!compselect_type) {
  +    static const GTypeInfo compselect_info = {
  +      sizeof(CompselectClass),
  +      NULL, /* base_init */
  +      NULL, /* base_finalize */
  +      (GClassInitFunc) compselect_class_init,
  +      NULL, /* class_finalize */
  +      NULL, /* class_data */
  +      sizeof(Compselect),
  +      0,    /* n_preallocs */
  +      (GInstanceInitFunc) compselect_init,
  +    };
  +                
  +    compselect_type = g_type_register_static (GTK_TYPE_DIALOG,
  +                                              "Compselect",
  +                                              &compselect_info, 0);
  +  }
  +  
  +  return compselect_type;
  +}
  +
  +static void
  +compselect_class_init (CompselectClass *klass)
  +{
  +  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  +
  +  gobject_class->set_property = compselect_set_property;
  +  gobject_class->get_property = compselect_get_property;
  +
  +  g_object_class_install_property (
  +    gobject_class, PROP_FILENAME,
  +    g_param_spec_string ("filename",
  +                         "",
  +                         "",
  +                         NULL,
  +                         G_PARAM_READABLE));
  +  g_object_class_install_property (
  +    gobject_class, PROP_BEHAVIOR,
  +    g_param_spec_enum ("behavior",
  +                       "",
  +                       "",
  +                       COMPSELECT_TYPE_BEHAVIOR,
  +                       COMPSELECT_BEHAVIOR_REFERENCE,
  +                       G_PARAM_READWRITE));
  +  
  +}
  +
  +static void
  +compselect_init (Compselect *compselect)
  +{
  +  GtkWidget *hbox, *vbox;
  +  GtkWidget *scrolled_win, *treeview, *label, *entry, *preview, *combobox;
  +  GtkTreeModel *child_model, *model;
  +  GtkCellRenderer *renderer;
  +  GtkTreeViewColumn *column;
  +  GtkTreeSelection *selection;
  +
  +  GtkWidget *alignment, *frame;
  +  
  +  /* dialog initialization */
  +  g_object_set (G_OBJECT (compselect),
  +                /* GtkWindow */
  +                "type",            GTK_WINDOW_TOPLEVEL,
  +                "title",           _("Select Component..."),
  +                "default-height",  300,
  +                "default-width",   400,
  +                "modal",           FALSE,
  +                "window-position", GTK_WIN_POS_NONE,
  +                /* GtkDialog */
  +                "has-separator",   TRUE,
  +                NULL);
  +  g_object_set (GTK_DIALOG (compselect)->vbox,
  +                "homogeneous", FALSE,
  +                NULL);
           
  -  if (!string) {
  -    return;
  -  }
   
  -  gtk_entry_select_region(GTK_ENTRY(f_current->search_entry), 0, -1);
  +  /* horizontal box selection and preview */
  +  hbox = GTK_WIDGET (g_object_new (GTK_TYPE_HBOX,
  +                                   /* GtkBox */
  +                                   "homogeneous", FALSE,
  +                                   "spacing",     5,
  +                                   NULL));
  +
  +  /* vertical box for component selection and search entry */
  +  vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
  +                                   /* GtkContainer */
  +                                   "border-width", 5,
  +                                   /* GtkBox */
  +                                   "homogeneous",  FALSE,
  +                                   "spacing",      5,
  +                                   NULL));
  +  
  +  /* -- directory/component selection -- */
  +  child_model  = compselect_create_child_model ();
  +  model = (GtkTreeModel*)g_object_new (GTK_TYPE_TREE_MODEL_FILTER,
  +                                       "child-model",  child_model,
  +                                       "virtual-root", NULL,
  +                                       NULL);
  +/*   gtk_tree_model_filter_set_visible_func ((GtkTreeModelFilter*)model, */
  +/*                                           compselect_model_filter_visible_func, */
  +/*                                           compselect, */
  +/*                                           NULL); */
  +  
  +  scrolled_win = GTK_WIDGET (
  +    g_object_new (GTK_TYPE_SCROLLED_WINDOW,
  +                  /* GtkScrolledWindow */
  +                  "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
  +                  "vscrollbar-policy", GTK_POLICY_ALWAYS,
  +                  "shadow-type",       GTK_SHADOW_ETCHED_IN,
  +                  NULL));
  +  /* create the treeview */
  +  treeview = GTK_WIDGET (g_object_new (GTK_TYPE_TREE_VIEW,
  +                                       /* GtkTreeView */
  +                                       "model",      model,
  +                                       "rules-hint", TRUE,
  +                                       NULL));
  +  /* connect callback to selection */
  +  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
  +  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
  +  g_signal_connect (selection,
  +                    "changed",
  +                    G_CALLBACK (compselect_callback_tree_selection_changed),
  +                    compselect);
  +
  +  /* insert a column to treeview for directory name */
  +  renderer = GTK_CELL_RENDERER (
  +    g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
  +                  /* GtkCellRendererText */
  +                  "editable", FALSE,
  +                  NULL));
  +  column = GTK_TREE_VIEW_COLUMN (
  +    g_object_new (GTK_TYPE_TREE_VIEW_COLUMN,
  +                  /* GtkTreeViewColumn */
  +                  "title", _("Components"),
  +                  NULL));
  +  gtk_tree_view_column_pack_start (column, renderer, TRUE);
  +  gtk_tree_view_column_set_cell_data_func (column, renderer,
  +                                           compselect_treeview_set_cell_data,
  +                                           NULL, NULL);
  +  gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
  +  
  +  /* add the treeview to the scrolled window */
  +  gtk_container_add (GTK_CONTAINER (scrolled_win), treeview);
  +  /* set directory/component treeview of compselect */
  +  compselect->treeview = GTK_TREE_VIEW (treeview);
   
  -  if (f_current->last_search_lib != -1) {
  -    lib_count = f_current->last_search_lib;     
  -    gtk_label_set(GTK_LABEL(f_current->search_label),
  -                  _("Search in Components")); 
  -  } else {
  -    lib_count = 0;
  -    gtk_label_set(GTK_LABEL(f_current->search_label),
  -                  _("Search in Components")); 
  -  }
  -
  -  while(f_current->directory_entries[lib_count] != NULL) {
  -    flag = x_compselect_search_library(f_current, 
  -                                       f_current->directory_entries[lib_count], 
  -                                       string);
  -    if (flag != -1) {
  -      gtk_clist_select_row(GTK_CLIST(f_current->dir_list), 
  -                           lib_count, 0);
  -
  -      gtk_clist_moveto(GTK_CLIST(
  -                                 f_current->dir_list), 
  -                       lib_count, 0, -1, -1);
  -
  -      x_compselect_change_clib(f_current, 
  -                               f_current->
  -                               directory_entries[lib_count],
  -                               lib_count);
  -
  -      gtk_clist_select_row(GTK_CLIST(f_current->file_list), 
  -                           flag, 0);
  -
  -      gtk_clist_moveto(GTK_CLIST(
  -                                 f_current->file_list), 
  -                       flag, 0, -1, -1);
  +  /* add the scrolled window for directories to the vertical box */
  +  gtk_box_pack_start (GTK_BOX (vbox), scrolled_win,
  +                      TRUE, TRUE, 0);
   
  -      f_current->last_search_lib = lib_count; 
  -      return;
  -    } else {
  -      lib_count++;
  -    }
  -  }
   
  +  /* -- filter area -- */
  +  label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
  +                                    /* GtkMisc */
  +                                    "xalign", 0.0,
  +                                    /* GtkLabel */
  +                                    "label",  _("Filter:"),
  +                                    NULL));
  +  /* add the search label to the vertical box */
  +  gtk_box_pack_start (GTK_BOX (vbox), label,
  +                      FALSE, FALSE, 0);
  +  /* create the text entry for search in component */
  +  entry = GTK_WIDGET (g_object_new (GTK_TYPE_ENTRY,
  +                                    /* GtkEntry */
  +                                    "text", "",
  +                                    NULL));
  +  g_signal_connect (entry,
  +                    "activate",
  +                    G_CALLBACK (compselect_callback_filter_entry_activate),
  +                    compselect);
  +  /* add the search entry to the vertical box */
  +  gtk_box_pack_start (GTK_BOX (vbox), entry,
  +                      FALSE, FALSE, 0);
  +  /* set filter entry of compselect */
  +  compselect->entry_filter = GTK_ENTRY (entry);
  +
  +  /* include the vertical box in horizontal box */
  +  gtk_box_pack_start (GTK_BOX (hbox), vbox,
  +                      TRUE, TRUE, 0);
  +
  +  /* now that that we have an entry, set the filter func of model */
  +  gtk_tree_model_filter_set_visible_func ((GtkTreeModelFilter*)model,
  +                                          compselect_model_filter_visible_func,
  +                                          compselect,
  +                                          NULL);
   
  -  f_current->last_search_lib = -1;
  -  f_current->last_search = -1;
   
  -#if 0 /* I'm not sure this is worth the effort and the confusion it causes */
  -  /* now search the library names */
  -  lib_count = 0;
  -  while(f_current->directory_entries[lib_count] != NULL) {
  -    if (strstr(f_current->directory_entries[lib_count], string)) {
  +  /* -- preview area -- */
  +  frame = GTK_WIDGET (g_object_new (GTK_TYPE_FRAME,
  +                                    /* GtkContainer */
  +                                    "border-width", 5,
  +                                    /* GtkFrame */
  +                                    "label",        _("Preview"),
  +                                    NULL));
  +  alignment = GTK_WIDGET (g_object_new (GTK_TYPE_ALIGNMENT,
  +                                        /* GtkAlignment */
  +                                        "right-padding", 5,
  +                                        "left-padding",  5,
  +                                        "xscale",        0.0,
  +                                        "yscale",        0.0,
  +                                        "xalign",        0.5,
  +                                        "yalign",        0.5,
  +                                        NULL));
  +  preview = GTK_WIDGET (g_object_new (TYPE_PREVIEW,
  +                                      /* Preview */
  +                                      "active", TRUE,
  +                                      NULL));
  +  gtk_container_add (GTK_CONTAINER (alignment), preview);
  +  gtk_container_add (GTK_CONTAINER (frame), alignment);
  +  /* set preview of compselect */
  +  compselect->preview = PREVIEW (preview);
   
  -      printf("%s %s\n", f_current->directory_entries[lib_count], string);
  +  gtk_box_pack_start (GTK_BOX (hbox), frame,
  +                      FALSE, TRUE, 0);
   
  -      gtk_clist_select_row(GTK_CLIST(f_current->dir_list), 
  -                           lib_count, 0);
  +  /* add the hbox to the dialog vbox */
  +  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (compselect)->vbox), hbox,
  +                      TRUE, TRUE, 0);
  +  gtk_widget_show_all (hbox);
   
  -      gtk_clist_moveto(GTK_CLIST(
  -                                 f_current->dir_list), 
  -                       lib_count, 0, -1, -1);
   
  -      x_compselect_change_clib(f_current, 
  -                               f_current->
  -                               directory_entries[lib_count],
  -                               lib_count);
  +  /* -- behavior combo box -- */
  +  combobox = compselect_create_behaviors_combo_box ();
  +  g_signal_connect (combobox,
  +                    "changed",
  +                    G_CALLBACK (compselect_callback_behavior_changed),
  +                    compselect);
  +  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (compselect)->vbox), combobox,
  +                      FALSE, FALSE, 10);
  +  gtk_widget_show_all (combobox);
  +  /* set behavior combo box of compselect */
  +  compselect->combobox_behaviors = GTK_COMBO_BOX (combobox);
   
  -      gtk_label_set(GTK_LABEL(f_current->search_label),
  -                    _("Search in Components - Found library only")); 
  -      return;
  -    }
  -    lib_count++;
  -  }
  -  f_current->last_search_lib = -1;
  -#endif
   
  -  gtk_label_set(GTK_LABEL(f_current->search_label),
  -                _("Search in Components - End of list")); 
  +  /* now add buttons in the action area */
  +  gtk_dialog_add_buttons (GTK_DIALOG (compselect),
  +                          /*  - close button */
  +                          GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
  +                          /*  - update button */
  +                          GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
  +                          NULL);
   
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_setup_list_buffers(FILEDIALOG *f_current, 
  -                                int num_files, int num_directories)
  -{
  -  int i;
  -
  -  for (i = 0; i < num_files+1; i++) {
  -    if (f_current->file_entries[i]) {
  -      free(f_current->file_entries[i]);
  -    }
  -    f_current->file_entries[i] = NULL;
  +static void
  +compselect_set_property (GObject *object,
  +                         guint property_id,
  +                         const GValue *value,
  +                         GParamSpec *pspec)
  +{
  +  Compselect *compselect = COMPSELECT (object);
  +
  +  switch(property_id) {
  +    case PROP_BEHAVIOR:
  +      gtk_combo_box_set_active (compselect->combobox_behaviors,
  +                                g_value_get_enum (value));
  +      break;
  +    default:
  +      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
   
  -  for (i = 0; i < num_directories+1; i++) {
  -    if (f_current->directory_entries[i]) {
  -      free(f_current->directory_entries[i]);
  -    }
  -    f_current->directory_entries[i] = NULL;
  -  }
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -int
  -x_compselect_preview_checkbox(GtkWidget *widget, FILEDIALOG *f_current)
  -{
  -  if (f_current == NULL) {
  -    fprintf(stderr, _("x_compselect_preview_checkbox: Oops got a null f_current!\n"));
  -    exit(-1);
  +static void
  +compselect_get_property (GObject *object,
  +                         guint property_id,
  +                         GValue *value,
  +                         GParamSpec *pspec)
  +{
  +  Compselect *compselect = COMPSELECT (object);
  +
  +  switch(property_id) {
  +      case PROP_FILENAME: {
  +        GtkTreeModel *model;
  +        GtkTreeIter iter, parent;
  +        if (gtk_tree_selection_get_selected (
  +              gtk_tree_view_get_selection (compselect->treeview),
  +              &model,
  +              &iter)) {
  +          GString *str;
  +          gchar *tmp;
  +          
  +          gtk_tree_model_get (model, &iter, 0, &tmp, -1);
  +          str = g_string_new (tmp);
  +          g_free (tmp);
  +          while (gtk_tree_model_iter_parent (model, &parent, &iter)) {
  +            gtk_tree_model_get (model, &parent, 0, &tmp, -1);
  +            str = g_string_prepend (str, G_DIR_SEPARATOR_S);
  +            str = g_string_prepend (str, tmp);
  +            g_free (tmp);
  +            iter = parent;
     }
  -
  -  if (f_current->preview_control) {
  -    f_current->preview_control = FALSE;
  -    g_object_set (f_current->preview,
  -                  "active", FALSE,
  -                  NULL);
  +          g_value_take_string (value, g_string_free (str, FALSE));
     } else {
  -    f_current->preview_control = TRUE;
  -    g_object_set (f_current->preview,
  -                  "active", TRUE,
  -                  NULL);
  +          g_value_set_string (value, NULL);
     }
  -  return(0);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_close (GtkWidget *w, FILEDIALOG *f_current)
  -{
  -  gtk_widget_destroy(GTK_WIDGET(f_current->xfwindow));
  -  f_current->xfwindow = NULL;
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void
  -x_compselect_setup (TOPLEVEL *toplevel)
  -{
  -  GtkWidget *buttonapply = NULL;
  -  GtkWidget *buttonclose = NULL;
  -  GtkWidget *scrolled_win;
  -  GtkWidget *action_area;
  -  GtkWidget *separator;
  -  GtkWidget *optionmenu;
  -  GtkWidget *drawbox;
  -  GtkWidget *label;
  -  GtkWidget *searchbox;
  -        
  -  FILEDIALOG *f_current;
  -
  -  GtkWidget *vbox;
  -  GtkWidget *list_hbox;
  -  char *dir_title [2];
  -  char *file_title [2];
  -
  -
  -  f_current = &toplevel->fileselect[COMPSELECT];
  -
  -  if (!f_current->xfwindow) {
  -
  -    f_current->xfwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  -    f_current->toplevel = toplevel;
  -    f_current->type = COMPSELECT;
  -    f_current->filesel_type = -1;
  -    f_current->last_search = -1;
  -    f_current->filename = NULL;
  -    f_current->directory = NULL;
  -
  -    gtk_window_position(GTK_WINDOW(f_current->xfwindow),
  -                        GTK_WIN_POS_NONE);
  -    gtk_window_set_title(GTK_WINDOW(f_current->xfwindow),
  -                         _("Select Component..."));
  -
  -    gtk_signal_connect(GTK_OBJECT(f_current->xfwindow),
  -                       "destroy",
  -                       GTK_SIGNAL_FUNC(x_compselect_destroy_window),
  -                       f_current);
  -
  -    gtk_signal_connect(GTK_OBJECT(f_current->xfwindow), "key_press_event",
  -                       (GtkSignalFunc) x_compselect_keypress, f_current);
  -
  -    vbox = gtk_vbox_new (FALSE, 0);
  -    gtk_container_set_border_width(GTK_CONTAINER (f_current->xfwindow), 10);
  -    gtk_container_add(GTK_CONTAINER (f_current->xfwindow), 
  -                      vbox);
  -    gtk_widget_show (vbox);
  -
  -    action_area = gtk_hbutton_box_new ();
  -    gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area), 
  -                              GTK_BUTTONBOX_END);
  -    gtk_button_box_set_spacing(GTK_BUTTON_BOX(action_area), 5);
  -    gtk_box_pack_end (GTK_BOX (vbox), action_area, TRUE, FALSE, 10);
  -    gtk_widget_show (action_area);
  -
  -
  -    /*  ----- Create the filter selection area -----  */
  -    f_current->filter_type = FILEDIALOG_SYM_ONLY;
  -
  -    list_hbox = gtk_hbox_new (FALSE, 5);
  -    gtk_box_pack_start (GTK_BOX (vbox), list_hbox, TRUE, TRUE, 0);
  -    gtk_widget_show (list_hbox);
  -
  -    separator = gtk_hseparator_new ();
  -    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
  -    gtk_widget_show (separator);
  -
  -    drawbox = gtk_hbox_new (FALSE, 0);
  -    gtk_box_pack_start (GTK_BOX (vbox), drawbox, TRUE, FALSE, 5);
  -    gtk_widget_show (drawbox);
  -
  -    searchbox = gtk_vbox_new (FALSE, 0);
  -    gtk_box_pack_end (GTK_BOX (drawbox), searchbox, TRUE, TRUE, 10);
  -    gtk_widget_show (searchbox);
  -
  -    
  -    /*  -----  Create the "directories"/"libraries" clist widgets -----  */
  -    dir_title[0] = g_strdup(_("Libraries"));
  -    dir_title[1] = NULL;
  -    f_current->dir_list = gtk_clist_new_with_titles(1,
  -                                                    (char**) dir_title);
  -    gtk_widget_set_usize(f_current->dir_list, 
  -                         DIR_LIST_WIDTH, DIR_LIST_HEIGHT);
  -    gtk_signal_connect (GTK_OBJECT (f_current->dir_list), 
  -                        "select_row", (GtkSignalFunc) 
  -                        x_compselect_lib_select, f_current);
  -    gtk_clist_column_titles_passive(GTK_CLIST(f_current->dir_list));
  -
  -    scrolled_win = gtk_scrolled_window_new(NULL, NULL);
  -    gtk_container_add(GTK_CONTAINER (scrolled_win), 
  -                      f_current->dir_list);
  -    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(
  -                                                       scrolled_win),
  -                                   GTK_POLICY_AUTOMATIC, 
  -                                   GTK_POLICY_ALWAYS);
  -    gtk_container_set_border_width(GTK_CONTAINER (scrolled_win), 5);
  -    gtk_box_pack_start(GTK_BOX (list_hbox), scrolled_win, 
  -                       TRUE, TRUE, 0);
  -    if (toplevel->sort_component_library) {
  -      gtk_clist_set_auto_sort(GTK_CLIST(f_current->dir_list), TRUE);
       }
  -    gtk_widget_show (f_current->dir_list);
  -    gtk_widget_show (scrolled_win);
  -    free(dir_title[0]);
  -    
  -    /*  ----- Create the files clist -----  */
  -    file_title[0] = g_strdup (_("Components"));
  -    file_title[1] = NULL;
  -    f_current->file_list = gtk_clist_new_with_titles(1, 
  -                                                     (gchar**) file_title);
  -    gtk_widget_set_usize(f_current->file_list, 
  -                         FILE_LIST_WIDTH, FILE_LIST_HEIGHT);
  -
  -    gtk_signal_connect(GTK_OBJECT (f_current->file_list), 
  -                       "select_row",
  -                       (GtkSignalFunc) x_compselect_comp_select,
  -                       f_current);
  -    gtk_clist_column_titles_passive(GTK_CLIST(f_current->file_list));
  -
  -    scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  -    gtk_container_add(GTK_CONTAINER(scrolled_win), 
  -                      f_current->file_list);
  -    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(
  -                                                       scrolled_win),
  -                                   GTK_POLICY_AUTOMATIC, 
  -                                   GTK_POLICY_ALWAYS);
  -    gtk_container_set_border_width(GTK_CONTAINER(scrolled_win), 5);
  -    gtk_box_pack_start(GTK_BOX (list_hbox), scrolled_win, 
  -                       TRUE, TRUE, 0);
  -    if (toplevel->sort_component_library) {
  -      gtk_clist_set_auto_sort(GTK_CLIST(f_current->file_list), TRUE);
  +        break;
  +      case PROP_BEHAVIOR:
  +        g_value_set_enum (value,
  +                          gtk_combo_box_get_active (
  +                            compselect->combobox_behaviors));
  +        break;
  +      default:
  +        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       }
  -    gtk_widget_show (f_current->file_list);
  -    gtk_widget_show (scrolled_win);
  -    free(file_title[0]);
   
  -    /*  ----- create the preview widget -----  */
  -    f_current->preview = g_object_new (TYPE_PREVIEW,
  -                                       NULL);
  -    gtk_widget_show (f_current->preview);
  -    gtk_box_pack_start (GTK_BOX (drawbox), f_current->preview,
  -                        FALSE, FALSE, 0);
  +}
   
  -    f_current->preview_checkbox = gtk_check_button_new_with_label(
  -                                                                  _("Preview"));
  -    gtk_box_pack_start(GTK_BOX(searchbox), 
  -                       f_current->preview_checkbox, 
  -                       FALSE, FALSE, 0);
  -    /* other checkbox stuff is done AFTER drawing area is mapped */
  -    gtk_widget_show(f_current->preview_checkbox);
   
  -    /* -----  Create the search input text box -----  */
  -    f_current->search_label=gtk_label_new(_("Search in Components"));
  -    gtk_misc_set_alignment(GTK_MISC(f_current->search_label), 0, 0);
  -    gtk_box_pack_start(GTK_BOX(searchbox), f_current->search_label,
  -                       FALSE, FALSE, 5);
  -    gtk_widget_show(f_current->search_label);
  -
  -
  -    f_current->search_entry = gtk_entry_new_with_max_length (255);
  -    gtk_editable_select_region(GTK_EDITABLE(
  -                                            f_current->search_entry), 0, -1);
  -    gtk_box_pack_start(GTK_BOX (searchbox), 
  -                       f_current->search_entry, FALSE, FALSE, 0);
  -    gtk_signal_connect(GTK_OBJECT(f_current->search_entry), 
  -                       "activate", 
  -                       GTK_SIGNAL_FUNC(x_compselect_comp_search),
  -                       f_current);
  -    gtk_widget_grab_focus(f_current->search_entry);
  -    gtk_widget_show(f_current->search_entry);
  -
  -    /*  ----- Create the "Filename" text entry area -----  */
  -    optionmenu = gtk_option_menu_new ();
  -    gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu),
  -                             create_menu (toplevel));
  -    gtk_box_pack_start(GTK_BOX(vbox), optionmenu, 
  -                       FALSE, FALSE, 10);
  -    gtk_widget_show (optionmenu);
   
  -    label=gtk_label_new(_("Filename"));
  -    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
  -    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
  -    gtk_widget_show(label);
  -
  -    f_current->filename_entry = 
  -      gtk_entry_new_with_max_length(1024);
  -    gtk_editable_select_region(GTK_EDITABLE(
  -                                            f_current->filename_entry), 0, -1);
  -    gtk_box_pack_start(GTK_BOX (vbox), 
  -                       f_current->filename_entry, FALSE, FALSE, 0);
  -
  -    gtk_entry_set_editable(GTK_ENTRY(f_current->filename_entry), FALSE);
  -        
  -    gtk_widget_show(f_current->filename_entry);
  -
  -    buttonapply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
  -    gtk_signal_connect(GTK_OBJECT(buttonapply),
  -                       "clicked",
  -                       GTK_SIGNAL_FUNC(x_compselect_comp_apply),
  -                       f_current);
  -
  -    GTK_WIDGET_SET_FLAGS(buttonapply, GTK_CAN_DEFAULT);
  -    gtk_box_pack_start(GTK_BOX(action_area),
  -                       buttonapply, TRUE, TRUE, 0);
  -    /* This makes the "open" button the default */
  -    gtk_widget_grab_default (buttonapply);
  -    gtk_widget_show(buttonapply);
  -
  -    buttonclose = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  -    GTK_WIDGET_SET_FLAGS(buttonclose, GTK_CAN_DEFAULT);
  -    gtk_box_pack_start(GTK_BOX(action_area),
  -                       buttonclose, TRUE, TRUE, 0);
  -    gtk_signal_connect(GTK_OBJECT(buttonclose),
  -                       "clicked",
  -                       GTK_SIGNAL_FUNC(x_compselect_comp_close),
  -                       f_current);
  -    gtk_widget_show(buttonclose);
  -    
  -    /* files data structure is not used for components */
  -    x_compselect_setup_list_buffers(f_current,
  -                                    g_slist_length ((GSList *) s_clib_get_directories()), 0);
  -    x_compselect_comp_update_current(f_current, NULL, NULL);
  -    x_compselect_comp_fill_libs(toplevel, f_current);
  -  }
  -
  -  if (!GTK_WIDGET_VISIBLE(f_current->xfwindow)) {
  -    gtk_widget_show(f_current->xfwindow);
  -    gdk_window_raise(f_current->xfwindow->window);
  -
  -    /* need to delay this till the drawing area is created and
  -     * is showing */
  -    gtk_signal_connect (GTK_OBJECT(f_current->preview_checkbox), 
  -                        "toggled", GTK_SIGNAL_FUNC(x_compselect_preview_checkbox),
  -                        f_current);
  -    if (toplevel->file_preview) {
  -      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
  -                                                     f_current->preview_checkbox), 
  -                                   TRUE);
  -      f_current->preview_control = TRUE;
  -    } else {
  -      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
  -                                                     f_current->preview_checkbox), 
  -                                   FALSE);
  -      f_current->preview_control = FALSE;
  -    }
  +GType
  +compselect_behavior_get_type (void)
  +{
  +  static GType etype = 0;
   
  -  } else {
  -    /* window should already be mapped, otherwise this
  -     * will core */
  -    gdk_window_raise(f_current->xfwindow->window);
  +  if (etype == 0) {
  +    static const GEnumValue values[] = {
  +      { COMPSELECT_BEHAVIOR_REFERENCE, "COMPSELECT_BEHAVIOR_REFERENCE", "reference" },
  +      { COMPSELECT_BEHAVIOR_EMBED,     "COMPSELECT_BEHAVIOR_EMBED",     "embed" },
  +      { COMPSELECT_BEHAVIOR_INCLUDE,   "COMPSELECT_BEHAVIOR_INCLUDE",   "include" },
  +      { 0, NULL, NULL }
  +    };
  +    
  +    etype = g_enum_register_static ("CompselectBehavior", values);
     }
   
  +  return etype;
   }
  -
  -
  
  
  
  1.43      +0 -10     eda/geda/gaf/gschem/src/x_window.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_window.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_window.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -b -r1.42 -r1.43
  --- x_window.c	23 Sep 2006 08:47:56 -0000	1.42
  +++ x_window.c	23 Sep 2006 09:01:06 -0000	1.43
  @@ -117,10 +117,6 @@
     toplevel->ltwindow = NULL;
     toplevel->ftwindow = NULL;
     toplevel->sewindow = NULL;
  -  toplevel->fileselect[COMPSELECT].xfwindow = NULL;
  -  toplevel->fileselect[COMPSELECT].directory = NULL;
  -  toplevel->fileselect[COMPSELECT].filename = NULL;
  -  x_compselect_init_list_buffers(&toplevel->fileselect[COMPSELECT]);
   
     toplevel->coord_world = NULL;
     toplevel->coord_screen = NULL;
  @@ -812,12 +808,6 @@
     if (w_current->sewindow)
     gtk_widget_destroy(w_current->sewindow);
   
  -  if (w_current->fileselect[COMPSELECT].xfwindow) {
  -    gtk_widget_destroy(w_current->fileselect[COMPSELECT].xfwindow);
  -  }
  -
  -  x_compselect_free_list_buffers(&w_current->fileselect[COMPSELECT]);
  -
     g_assert(w_current->prev != NULL);
     if (w_current->next == NULL && w_current->prev->prev == NULL) {
       /* no more window after this one, remember to quit */
  
  
  


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