Re: Combo box investigation + proposed new API



On 5 Oct 2000, Havoc Pennington wrote:
> 
> Kristian Rietveld <kristian planet nl> writes: 
> > GtkHBox
> >  + GtkComboBox
> >     + GtkComboBoxPixmap
> >     + GtkComboBoxText
> > 
> 
> Does the HBox derivation really make sense? It's just a way to avoid
> writing the container boilerplate, but that boilerplate isn't going to
> be very complicated.
> 
> It only really makes sense conceptually if we support users adding
> additional children to the hbox. That seems pretty useless though.

I used the HBox derivation in the new GtkComboBox, because the old
GtkCombo and the GtkComboBox of Gnumeric also use the HBox
derivation. Which is the best widget to derive GtkComboBox from?

> 
> > But I'll change the API of PixmapCombo
> > for GtkComboBoxPixmap, I think that a 'dynamic' version is handier than
> > the original PixmapCombo where you've to give all the elements at the time
> > of creation of the widget.
> 
> Agreed. 
> 
> > Finally, the GtkComboBoxText will be based on
> > GtkClueHunter from beast-gtk, which will be also implemented using the new
> > GtkTL stuff.
> >
> 
> The new tree/list is in CVS HEAD now, conveniently.
> 
> On the patch, some thoughts:
> 
> ===
> 
> struct _GtkComboBoxPixmapItem
> {
> 	/* private */
> 	int           index;
> 	GtkImage     *image_widget;
> 
> 	/* public */
> 	gchar        *tooltip;
> 	GdkPixbuf    *image;
> };
> 
> ...
> 
> GtkComboBoxPixmapItem *gtk_combo_box_pixmap_add_item ( gchar     *tooltip,
> 						       GdkPixbuf *image );
> GtkType    gtk_combo_box_pixmap_get_type ( void );
> GtkWidget *gtk_combo_box_pixmap_new ( int max_cols, int max_rows );
> void       gtk_combo_box_pixmap_remove_item ( GtkComboBoxPixmapItem *item );
> void       gtk_combo_box_pixmap_select_pixmap ( GtkComboBoxPixmap *cboxpixmap,
> 						GtkComboBoxPixmapItem *item );
> 
> 
> ===
> 
> If we go with pixmaps, I'd call it GtkComboBoxPixbuf instead of Pixmap;
> there are no pixmaps involved here anymore. ;-)
> 

I agree.

> I'm not sure what I said in my original combo box notes, but seeing
> this API I think it would be cleaner to simply have GtkComboBoxGrid
> (name open to question) which takes arbitrary widgets. i.e.:
> 
>   gtk_combo_box_grid_add_item (combobox, GtkWidget *item);
> 
> You remove items with gtk_container_remove(combobox, item).
> 
> The user doesn't specify max cols/rows, instead the grid just
> automatically picks a nice arrangement.
> 
> So to make an image combo you'd just add a bunch of GtkImage to the
> GtkComboBoxGrid.
>

This is a wonderful idea.

So we'll get:

+ <new_widget_to_derive_GtkComboBox_from>
  + GtkComboBox
    + GtkComboBoxGrid
       + GtkComboBoxPixbuf

> ===
> 
> void       gtk_combo_box_text_set_tlview        ( GtkComboBoxText   *cboxtext,
> 						  GtkWidget *tlview );
> 
> void       gtk_combo_box_text_set_entry         ( GtkComboBoxText   *cboxtext,
> 						  GtkWidget         *entry );
> 
> ===
> 
> Note that it is no longer called tlview, it's tree_view now I think.
> 
> However I don't think you need these functions, because if you want to
> set custom popdown and entry, you just use the GtkComboBox base class.
>

Should the GtkComboBox base class also use GtkTreeView? I had in mind that
the base class only supplies functions to add the popdown and entry
widgets. The GtkComboBoxGrid won't be using the GtkTreeView, only the
GtkComboBoxText will.

> === 
> 
> void    gtk_combo_box_text_set_pattern_matching ( GtkComboBoxText *cboxtext,
> 						  gboolean         matching );
> void       gtk_combo_box_text_set_keep_history  ( GtkComboBoxText   *cboxtext,
> 						  gboolean           keep );
> void       gtk_combo_box_text_select_entry      ( GtkComboBoxText  *cboxtext,
> 						  const gchar      *string );
> gchar     *gtk_combo_box_text_try_complete      ( GtkComboBoxText  *cboxtext );
> 
> ===
> 
> Need some elaboration on what these functions do. Also, API is missing
> to get the current list of strings in the popdown.

These functions came from the GtkClueHunter. Here is a short explaination
of what each function will do:

gtk_combo_box_text_set_pattern_matching(): sets the pattern matching on or
off. So it'll try to match an entry in the list while you're typing.

gtk_combo_box_text_set_keep_history(): {en,dis}ables the option which will
keep all entered items in the list.

gtk_combo_box_text_select_entry(): whoops! made a little typo here, the
correct prototype is:

void     gtk_combo_box_text_select_on ( GtkComboBoxText *cboxtext,
					const gchar *string );

This function will emit the select signal. But, because the select_on
signal of the GtkClueHunter was renamed to 'select' in GtkComboBoxText, I
think it's better rename the function to:

void     gtk_combo_box_text_select ( GtkComboBoxText *cboxtext,
				     const gchar *string );

gtk_combo_box_text_try_complete(): tries to complete the text which is
currently entered in the entry.

For the function which will get all the strings from the popdown I
propose:

const gchar **gtk_combo_box_text_get_strings ( GtkComboBoxText *cboxtext
);

> 
> ===
> 
> void         gtk_combo_box_disable_activate     ( GtkComboBox *cbox );
> 
> ===
> 
> What does this one do?

This function came from the original GtkCombo, it seems to disable the
activation of the ComboBox. I think we should ditch this function,
because we're able to {en,dis}able to combo box by setting the arrow
sensitive or insensitive.

> 
> I think the overall set of widgets is on the right track, but there
> are lots of little details to be worked out and gotten right. I'd
> suggest jumping into the implementation, and posting code snapshots
> here every so often, so people can comment.

If I've collected all feedback on this headers, I'll post edited ones. If
those will be ok, I'll start implementing.

		Kris

-- 
"Running Windows on a Pentium is like having a brand new Porsche but only
be able to drive backwards with the handbrake on."
	(Unknown source - taken from fortune-mod-1.0-11)





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