Evolving ComboBox API



Hey,

After more thinking and talking, it's time for another round of headers.
A number of things have changed since last time:

- EggCellView and friends will be private widgets,

- The original base class, EggComboBox, has been dropped,

- Quite a number of changes in the TextCombo area, completion will move
to GtkEntry (API details to be announced later on), history handling
will be totally up to the user. Also, EggComboBoxText is now just a
EggComboBox with a GtkEntry as child,

- The TextCombo popdown and the completion items will now come from
separate models. The TextCombo would use the model specified during
construction of the widget. The GtkEntry completion code would get the
items from the model specified during enabling completion.



I've attached the header files (only two!) and they come with some
notes:

- The convenience functions in EggComboBox will create a model for the
user, the user won't be able to access it directly. So he's pretty much
stuck with the chosen layout. There will be checks in the code to avoid
the user from ruining everything by doing evil things,

- The name egg_combo_box_new_text() is badly chosen, we need another
name for this. Maybe something like egg_combo_box_simple_new(),

- The pixtext convenience handlers, which would provide easy API for
creating option menus with pixbuf, text pairs has been dropped. I still
think that this code can be useful, others don't.



Information on the new completion API will follow somewhere in the next
two weeks. Hopefully.



thanks,


	-Kris
#ifndef __EGG_COMBO_BOX_H__
#define __EGG_COMBO_BOX_H__

#include <gtk/gtkbin.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreeview.h>

G_BEGIN_DECLS

#define EGG_TYPE_COMBO_BOX_PICKER             (egg_combo_box_get_type ())
#define EGG_COMBO_BOX(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_COMBO_BOX_PICKER, EggComboBox))
#define EGG_COMBO_BOX_CLASS(vtable)           (G_TYPE_CHECK_CLASS_CAST ((vtable), EGG_TYPE_COMBO_BOX_PICKER, EggComboBoxClass))
#define EGG_IS_COMBO_BOX_PICKER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_COMBO_BOX_PICKER))
#define EGG_IS_COMBO_BOX_PICKER_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), EGG_TYPE_COMBO_BOX_PICKER))
#define EGG_COMBO_BOX_GET_CLASS(inst)         (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_COMBO_BOX_PICKER, EggComboBoxClass))


typedef struct _EggComboBox        EggComboBox;
typedef struct _EggComboBoxClass   EggComboBoxClass;

struct _EggComboBox
{
  GtkBin parent_instance;

  /* private fields omitted */
};

struct _EggComboBoxClass
{
  GtkBinClass parent_class;

  /* signals */
  void     (* popped_up)        (EggComboBox *combo_box);
  void     (* popped_down)      (EggComboBox *combo_box);
  void     (* changed)          (EggComboBox *combo_box);

  /* vtable */
  void     (* set_active)       (EggComboBox *combo_box,
                                 gint         index);
  gint     (* get_active)       (EggComboBox *combo_box);

  /* key bindings signals */
  gboolean (* popup)            (EggComboBox *combo_box);
};


/* construction */
GType         egg_combo_box_get_type         (void);
GtkWidget    *egg_combo_box_new              (GtkTreeModel    *model);

/* manipulate list of cell renderers */
void          egg_combo_box_pack_start       (EggComboBox     *combo_box,
                                              GtkCellRenderer *cell,
                                              gboolean         expand);
void          egg_combo_box_pack_end         (EggComboBox     *combo_box,
                                              GtkCellRenderer *cell,
                                              gboolean         expand);
void          egg_combo_box_set_attributes   (EggComboBox     *combo_box,
                                              GtkCellRenderer *cell,
                                              ...);
void          egg_combo_box_remove           (EggComboBox     *combo_box,
                                              GtkCellRenderer *cell);
void          egg_combo_box_clear            (EggComboBox     *combo_box);

/* grids */
void          egg_combo_box_set_wrap_width   (EggComboBox     *combo_box,
                                              gint             width);
void          egg_combo_box_set_span_columns (EggComboBox     *combo_box,
                                              gint             width_column,
                                              gint             height_column);

/* get/set active item */
gint          egg_combo_box_get_active       (EggComboBox     *combo_box);
void          egg_combo_box_set_active       (EggComboBox     *combo_box,
                                              gint             index);

/* convenience -- text */
GtkWidget    *egg_combo_box_new_text         ();
void          egg_combo_box_append_text      (EggComboBox     *combo_box,
                                              const gchar     *text);
void          egg_combo_box_insert_text      (EggComboBox     *combo_box,
                                              gint             position,
                                              const gchar     *text);
void          egg_combo_box_prepend_text     (EggComboBox     *combo_box,
                                              const gchar     *text);

G_END_DECLS

#endif /* __EGG_COMBO_BOX_H__ */
#ifndef __EGG_COMBO_BOX_TEXT_H__
#define __EGG_COMBO_BOX_TEXT_H__

#include <gtk/gtkentry.h>
#include <gtk/gtktreemodel.h>

G_BEGIN_DECLS

#define EGG_TYPE_COMBO_BOX_TEXT             (egg_combo_box_text_get_type ())
#define EGG_COMBO_BOX_TEXT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_COMBO_BOX_TEXT, EggComboBoxText))
#define EGG_COMBO_BOX_TEXT_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), EGG_TYPE_COMBO_BOX_TEXT, EggComboBoxTextClass))
#define EGG_IS_COMBO_BOX_TEXT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_COMBO_BOX_TEXT))
#define EGG_IS_COMBO_BOX_TEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), EGG_TYPE_COMBO_BOX_TEXT))
#define EGG_COMBO_BOX_TEXT_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_COMBO_BOX_TEXT, EggComboBoxTextClass))

typedef struct _EggComboBoxText             EggComboBoxText;
typedef struct _EggComboBoxTextClass        EggComboBoxTextClass;

struct _EggComboBoxText
{
  EggComboBox parent_instance;

  /*< private >*/
};

struct _EggComboBoxTextClass
{
  EggComboBoxClass parent_class;
};


GType         egg_combo_box_text_get_type  (void);
GtkWidget    *egg_combo_box_text_new       (GtkTreeModel      *model,
                                            gint               text_column);


G_END_DECLS

#endif /* __EGG_COMBO_BOX_TEXT_H__ */


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