Combo box investigation + proposed new API

Hi all,

I recently mailed with Havoc that I was wanting to rewrite the GtkImage
widget (which was on the GTK todo list). He told me that the GtkImage
rewrite was already done and that another useful task was to investigate
the combo box. So I investigated the combo box and planned a new

I looked at the current GtkCombo, the GtkClueHunter from beast-gtk and the
GtkComboBox from Gnumeric. I decided to take the best parts of all these
widgets and melt those together in one new combo box for GTK+. Here is the
hierarchy that I have in mind:

 + GtkComboBox
    + GtkComboBoxPixmap
    + GtkComboBoxText

The GtkComboBox will be based on the combo box work in Gnumeric, and will
be implemented using the new GtkTL stuff. The GtkComboBoxPixmap will be
based on PixmapCombo from Gnumeric. 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. Finally, the GtkComboBoxText will be based on
GtkClueHunter from beast-gtk, which will be also implemented using the new
GtkTL stuff.

Please take a look at the attached headers and post your comments. I know
the headers aren't complete yet, #includes and the copyright comments are
missing. I'll add them later.

If everybody is ok with it and if everybody is satisfied with the API,
I'll start implementing it.


"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)
/* -*- linux-c -*- */


#include <gtk/gtkcombobox.h>
#include <gtk/gtktooltips.h>
#include <gdk/gdkpixbuf.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define GTK_TYPE_COMBO_BOX_PIXMAP           (gtk_combo_box_pixmap_get_type ( ))
#define GTK_COMBO_BOX_PIXMAP(object)        (GTK_CHECK_CAST ((object), GTK_TYPE_COMBO_BOX_PIXMAP, GtkComboBoxPixmap))

typedef struct _GtkComboBoxPixmapClass      GtkComboBoxPixmapClass;
typedef struct _GtkComboBoxPixmapItem       GtkComboBoxPixmapItem;
typedef struct _GtkComboBoxPixmap           GtkComboBoxPixmap;

struct _GtkComboBoxPixmapItem
	/* private */
	int           index;
	GtkImage     *image_widget;

	/* public */
	gchar        *tooltip;
	GdkPixbuf    *image;

struct _GtkComboBoxPixmap
	GtkComboBox    cbox;
	int            cols, rows;
	int            max_cols, max_rows;
	int            number_of_elements;
	GList         *box_items;

	GtkWidget     *table;
	GtkWidget     *preview_button;
	GtkTooltips   *tool_tip;

struct _GtkComboBoxPixmapClass
	GtkComboClass     parent_class;

	void  (*select) ( GtkComboBoxPixmap     *cboxpixmap,
			  GtkComboBoxPixmapItem *item );

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 );

#ifdef __cplusplus
#endif /* __cplusplus */

#endif /* __GTK_COMBO_BOX_PIXMAP_H__ */
/* -*- linux-c -*- */

#ifndef __GTK_COMBO_BOX_TEXT_H__
#define __GTK_COMBO_BOX_TEXT_H__

#include <gtk/gtkcombobox.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define GTK_TYPE_COMBO_BOX_TEXT               (gtk_combo_box_text_get_type ( ))
#define GTK_COMBO_BOX_TEXT(object)            (GTK_CHECK_CAST ((object), GTK_TYPE_COMBO_BOX_TEXT, GtkComboBoxText))
#define GTK_IS_COMBO_BOX_TEXT(object)         (GTK_CHECK_TYPE ((object), GTK_TYPE_COMBO_BOX_TEXT))

typedef struct _GtkComboBoxTextClass      GtkComboBoxTextClass;
typedef struct _GtkComboBoxText           GtkComboBoxText;

struct _GtkComboBoxText
	GtkComboBox       cbox;

	gchar            *cstring;

	GtkWidget        *entry;
	GtkWidget        *list;
	GtkWidget        *scrolled_window;

struct _GtkComboBoxTextClass
	GtkComboBoxClass    parent_class;
	void  (*select)  ( GtkComboBoxText   *cboxtext,
			   const gchar       *string );

GtkType    gtk_combo_box_text_get_type          ( void );
GtkWidget *gtk_combo_box_new                    ( void );
void       gtk_combo_box_text_set_tlview        ( GtkComboBoxText   *cboxtext,
						  GtkWidget         *tlview );
void       gtk_combo_box_text_set_entry         ( GtkComboBoxText   *cboxtext,
						  GtkWidget         *entry );
void       gtk_combo_box_text_add_string        ( GtkComboBoxText   *cboxtext,
						  const gchar       *string );
void       gtk_combo_box_text_remove_string     ( GtkComboBoxText   *cboxtext,
						  const gchar       *string );
void       gtk_combo_box_text_remove_matches    ( GtkComboBoxText   *cboxtext,
						  const gchar       *pattern );
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 );

#ifdef __cplusplus
#endif /* __cplusplus */

#endif /* __GTK_COMBO_BOX_TEXT_H__ */
/* -*- linux-c -*- */

#ifndef __GTK_COMBO_BOX_H__
#define __GTK_COMBO_BOX_H__

#include <gtk/gtkhbox.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define GTK_TYPE_COMBO_BOX            (gtk_combo_box_get_type ( ))
#define GTK_COMBO_BOX(object)         (GTK_CHECK_CAST ((object), GTK_TYPE_COMBO_BOX, GtkComboBox))
#define GTK_IS_COMBO_BOX(object)      (GTK_CHECK_TYPE ((object), GTK_TYPE_COMBO_BOX))

typedef struct  _GtkComboBoxClass   GtkComboBoxClass;
typedef struct  _GtkComboBox        GtkComboBox;

struct _GtkComboBox
	GtkHBox       hbox;
	GtkWidget    *pop_down_widget;
	GtkWidget    *display_widget;
	GtkWidget    *box;
	GtkWidget    *arrow_button;
	GtkWidget    *toplevel;
	GtkWidget    *tearoff_window;
	guint         torn_off;
	guint         use_arrows:1;
	GtkWidget    *tearable;
	GtkWidget    *popup;

struct _GtkComboBoxClass
	GtkHBoxClass       parent_class;

	void   (*activate)   ( GtkComboBox    *cbox );
	void   (*popup)      ( GtkComboBox    *cbox );
	void   (*popdown)    ( GtkComboBox    *cbox );

GtkType      gtk_combo_box_get_type             ( void );
void         gtk_combo_box_construct            ( GtkComboBox *cbox,
						  GtkWidget *display_widget,
						  GtkWidget *pop_down_widget );
void         gtk_combo_box_disable_activate     ( GtkComboBox *cbox );
GtkWidget   *gtk_combo_box_new                  ( GtkWidget *display_widget,
						  GtkWidget *pop_down_widget );
void         gtk_combo_box_popup_hide           ( GtkComboBox *cbox );
void         gtk_combo_box_set_display          ( GtkComboBox *cbox,
						  GtkWidget *display_widget );
void         gtk_combo_box_set_arrow_relief     ( GtkComboBox *cbox,
						  GtkReliefStyle relief );
void         gtk_combo_box_set_arrow_sensitive  ( GtkComboBox *cbox,
						  gboolean sensitive );
void         gtk_combo_box_set_title            ( GtkComboBox *cbox,
					          const gchar *title );
void         gtk_combo_box_set_use_arrows       ( GtkComboBox *cbox,
						  gboolean use_arrows );

#ifdef __cplusplus
#endif /* __cplusplus */

#endif /* __GTK_COMBO_BOX_H__ */

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