Commit c920afd9 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

Landing the new ComboBox. Note that only gtkcombobox.h and

Fri Sep 26 23:49:44 2003  Kristian Rietveld  <kris@gtk.org>

	Landing the new ComboBox. Note that only gtkcombobox.h and
	gtkcomboboxentry.h are public.

	* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
	gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.

	* gtk/Makefile.am, gtk/gtk.h: adding the new files.

	* tests/testcombo.c: and a new test.

	* tests/Makefile.am: adding the new test.
parent 4a2de86c
Fri Sep 26 23:49:44 2003 Kristian Rietveld <kris@gtk.org>
Landing the new ComboBox. Note that only gtkcombobox.h and
gtkcomboboxentry.h are public.
* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.
* gtk/Makefile.am, gtk/gtk.h: adding the new files.
* tests/testcombo.c: and a new test.
* tests/Makefile.am: adding the new test.
2003-09-25 Tor Lillqvist <tml@iki.fi>
* demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows.
......
Fri Sep 26 23:49:44 2003 Kristian Rietveld <kris@gtk.org>
Landing the new ComboBox. Note that only gtkcombobox.h and
gtkcomboboxentry.h are public.
* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.
* gtk/Makefile.am, gtk/gtk.h: adding the new files.
* tests/testcombo.c: and a new test.
* tests/Makefile.am: adding the new test.
2003-09-25 Tor Lillqvist <tml@iki.fi>
* demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows.
......
Fri Sep 26 23:49:44 2003 Kristian Rietveld <kris@gtk.org>
Landing the new ComboBox. Note that only gtkcombobox.h and
gtkcomboboxentry.h are public.
* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.
* gtk/Makefile.am, gtk/gtk.h: adding the new files.
* tests/testcombo.c: and a new test.
* tests/Makefile.am: adding the new test.
2003-09-25 Tor Lillqvist <tml@iki.fi>
* demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows.
......
Fri Sep 26 23:49:44 2003 Kristian Rietveld <kris@gtk.org>
Landing the new ComboBox. Note that only gtkcombobox.h and
gtkcomboboxentry.h are public.
* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.
* gtk/Makefile.am, gtk/gtk.h: adding the new files.
* tests/testcombo.c: and a new test.
* tests/Makefile.am: adding the new test.
2003-09-25 Tor Lillqvist <tml@iki.fi>
* demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows.
......
Fri Sep 26 23:49:44 2003 Kristian Rietveld <kris@gtk.org>
Landing the new ComboBox. Note that only gtkcombobox.h and
gtkcomboboxentry.h are public.
* gtk/gtkcellview.[ch], gtk/gtkcellviewmenuitem.[ch],
gtk/gtkcombobox.[ch], gtk/gtkcomboboxentry.[ch]: new files.
* gtk/Makefile.am, gtk/gtk.h: adding the new files.
* tests/testcombo.c: and a new test.
* tests/Makefile.am: adding the new test.
2003-09-25 Tor Lillqvist <tml@iki.fi>
* demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows.
......
......@@ -118,6 +118,8 @@ gtk_public_h_sources = \
gtkcolorsel.h \
gtkcolorseldialog.h \
gtkcombo.h \
gtkcombobox.h \
gtkcomboboxentry.h \
gtkcontainer.h \
gtkctree.h \
gtkcurve.h \
......@@ -249,6 +251,8 @@ gtk_public_h_sources = \
# GTK+ header files that don't get installed
gtk_private_h_sources = \
gtkcellview.h \
gtkcellviewmenuitem.h \
gtkentryprivate.h \
gtkrbtree.h \
gtktextbtree.h \
......@@ -290,6 +294,8 @@ gtk_c_sources = \
gtkcellrendererpixbuf.c \
gtkcellrenderertext.c \
gtkcellrenderertoggle.c \
gtkcellview.c \
gtkcellviewmenuitem.c \
gtkcheckbutton.c \
gtkcheckmenuitem.c \
gtkclipboard.c \
......@@ -298,6 +304,8 @@ gtk_c_sources = \
gtkcolorsel.c \
gtkcolorseldialog.c \
gtkcombo.c \
gtkcombobox.c \
gtkcomboboxentry.c \
gtkcontainer.c \
gtkctree.c \
gtkcurve.c \
......
......@@ -58,6 +58,8 @@
#include <gtk/gtkcolorsel.h>
#include <gtk/gtkcolorseldialog.h>
#include <gtk/gtkcombo.h>
#include <gtk/gtkcombobox.h>
#include <gtk/gtkcomboboxentry.h>
#include <gtk/gtkcontainer.h>
#include <gtk/gtkctree.h>
#include <gtk/gtkcurve.h>
......
This diff is collapsed.
/* gtkcellview.h
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_CELL_VIEW_H__
#define __GTK_CELL_VIEW_H__
#include <gtk/gtkwidget.h>
#include <gtk/gtkcellrenderer.h>
#include <gtk/gtktreemodel.h>
G_BEGIN_DECLS
#define GTK_TYPE_CELL_VIEW (gtk_cell_view_get_type ())
#define GTK_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_VIEW, GtkCellView))
#define GTK_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_CELL_VIEW, GtkCellViewClass))
#define GTK_IS_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_VIEW))
#define GTK_IS_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_CELL_VIEW))
#define GTK_CELL_VIEW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_CELL_VIEW, GtkCellViewClass))
#define GTK_CELL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_VIEW, GtkCellViewPrivate))
typedef struct _GtkCellView GtkCellView;
typedef struct _GtkCellViewClass GtkCellViewClass;
typedef struct _GtkCellViewPrivate GtkCellViewPrivate;
struct _GtkCellView
{
GtkWidget parent_instance;
/*< private >*/
GtkCellViewPrivate *priv;
};
struct _GtkCellViewClass
{
GtkWidgetClass parent_class;
};
GType gtk_cell_view_get_type (void);
GtkWidget *gtk_cell_view_new (void);
GtkWidget *gtk_cell_view_new_with_text (const gchar *text);
GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup);
GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf);
void gtk_cell_view_pack_start (GtkCellView *cell_view,
GtkCellRenderer *renderer,
gboolean expand);
void gtk_cell_view_pack_end (GtkCellView *cell_view,
GtkCellRenderer *renderer,
gboolean expand);
void gtk_cell_view_clear (GtkCellView *cell_view);
void gtk_cell_view_add_attribute (GtkCellView *cell_view,
GtkCellRenderer *renderer,
const gchar *attribute,
gint column);
void gtk_cell_view_clear_attributes (GtkCellView *cell_view,
GtkCellRenderer *attribute);
void gtk_cell_view_set_attributes (GtkCellView *cell_view,
GtkCellRenderer *renderer,
...);
void gtk_cell_view_set_value (GtkCellView *cell_view,
GtkCellRenderer *renderer,
gchar *property,
GValue *value);
void gtk_cell_view_set_values (GtkCellView *cell_view,
GtkCellRenderer *renderer,
...);
void gtk_cell_view_set_model (GtkCellView *cell_view,
GtkTreeModel *model);
void gtk_cell_view_set_displayed_row (GtkCellView *cell_view,
GtkTreePath *path);
GtkTreePath *gtk_cell_view_get_displayed_row (GtkCellView *cell_view);
void gtk_cell_view_set_background_color (GtkCellView *cell_view,
GdkColor *color);
G_END_DECLS
#endif /* __GTK_CELL_VIEW_H__ */
/* gtkcellviewmenuitem.c
* Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkcellviewmenuitem.h>
#include <gtk/gtkcellview.h>
struct _GtkCellViewMenuItemPrivate
{
GtkWidget *cell_view;
};
static void gtk_cell_view_menu_item_init (GtkCellViewMenuItem *item);
static void gtk_cell_view_menu_item_class_init (GtkCellViewMenuItemClass *klass);
GType
gtk_cell_view_menu_item_get_type (void)
{
static GType cell_view_menu_item_type = 0;
if (!cell_view_menu_item_type)
{
static const GTypeInfo cell_view_menu_item_info =
{
sizeof (GtkCellViewMenuItemClass),
NULL,
NULL,
(GClassInitFunc) gtk_cell_view_menu_item_class_init,
NULL,
NULL,
sizeof (GtkCellViewMenuItem),
0,
(GInstanceInitFunc) gtk_cell_view_menu_item_init
};
cell_view_menu_item_type =
g_type_register_static (GTK_TYPE_MENU_ITEM, "GtkCellViewMenuItem",
&cell_view_menu_item_info, 0);
}
return cell_view_menu_item_type;
}
static void
gtk_cell_view_menu_item_class_init (GtkCellViewMenuItemClass *klass)
{
g_type_class_add_private ((GObjectClass *)klass,
sizeof (GtkCellViewMenuItemPrivate));
}
static void
gtk_cell_view_menu_item_init (GtkCellViewMenuItem *item)
{
item->priv = GTK_CELL_VIEW_MENU_ITEM_GET_PRIVATE (item);
}
GtkWidget *
gtk_cell_view_menu_item_new (void)
{
GtkCellViewMenuItem *item;
item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL);
item->priv->cell_view = gtk_cell_view_new ();
gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view);
gtk_widget_show (item->priv->cell_view);
return GTK_WIDGET (item);
}
GtkWidget *
gtk_cell_view_menu_item_new_with_pixbuf (GdkPixbuf *pixbuf)
{
GtkCellViewMenuItem *item;
item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL);
item->priv->cell_view = gtk_cell_view_new_with_pixbuf (pixbuf);
gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view);
gtk_widget_show (item->priv->cell_view);
return GTK_WIDGET (item);
}
GtkWidget *
gtk_cell_view_menu_item_new_with_text (const gchar *text)
{
GtkCellViewMenuItem *item;
item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL);
item->priv->cell_view = gtk_cell_view_new_with_text (text);
gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view);
gtk_widget_show (item->priv->cell_view);
return GTK_WIDGET (item);
}
GtkWidget *
gtk_cell_view_menu_item_new_with_markup (const gchar *markup)
{
GtkCellViewMenuItem *item;
item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL);
item->priv->cell_view = gtk_cell_view_new_with_markup (markup);
gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view);
gtk_widget_show (item->priv->cell_view);
return GTK_WIDGET (item);
}
GtkWidget *
gtk_cell_view_menu_item_new_from_model (GtkTreeModel *model,
GtkTreePath *path)
{
GtkCellViewMenuItem *item;
item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL);
item->priv->cell_view = gtk_cell_view_new ();
gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view);
gtk_cell_view_set_model (GTK_CELL_VIEW (item->priv->cell_view), model);
gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (item->priv->cell_view), path);
gtk_widget_show (item->priv->cell_view);
return GTK_WIDGET (item);
}
/* gtkcellviewmenuitem.h
* Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_CELL_VIEW_MENU_ITEM_H__
#define __GTK_CELL_VIEW_MENU_ITEM_H__
#include <gtk/gtkmenuitem.h>
#include <gtk/gtktreemodel.h>
G_BEGIN_DECLS
#define GTK_TYPE_CELL_VIEW_MENU_ITEM (gtk_cell_view_menu_item_get_type ())
#define GTK_CELL_VIEW_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItem))
#define GTK_CELL_VIEW_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItemClass))
#define GTK_IS_CELL_VIEW_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM))
#define GTK_IS_CELL_VIEW_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_VIEW_MENU_ITEM))
#define GTK_CELL_VIEW_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItemClass))
#define GTK_CELL_VIEW_MENU_ITEM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItemPrivate))
typedef struct _GtkCellViewMenuItem GtkCellViewMenuItem;
typedef struct _GtkCellViewMenuItemClass GtkCellViewMenuItemClass;
typedef struct _GtkCellViewMenuItemPrivate GtkCellViewMenuItemPrivate;
struct _GtkCellViewMenuItem
{
GtkMenuItem parent_instance;
/*< private >*/
GtkCellViewMenuItemPrivate *priv;
};
struct _GtkCellViewMenuItemClass
{
GtkMenuItemClass parent_class;
};
GType gtk_cell_view_menu_item_get_type (void);
GtkWidget *gtk_cell_view_menu_item_new (void);
GtkWidget *gtk_cell_view_menu_item_new_with_pixbuf (GdkPixbuf *pixbuf);
GtkWidget *gtk_cell_view_menu_item_new_with_text (const gchar *text);
GtkWidget *gtk_cell_view_menu_item_new_with_markup (const gchar *markup);
GtkWidget *gtk_cell_view_menu_item_new_from_model (GtkTreeModel *model,
GtkTreePath *path);
G_END_DECLS
#endif /* __GTK_CELL_VIEW_MENU_ITEM_H__ */
This diff is collapsed.
/* gtkcombobox.h
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_COMBO_BOX_H__
#define __GTK_COMBO_BOX_H__
#include <gtk/gtkbin.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreeview.h>
G_BEGIN_DECLS
#define GTK_TYPE_COMBO_BOX (gtk_combo_box_get_type ())
#define GTK_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO_BOX, GtkComboBox))
#define GTK_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_COMBO_BOX, GtkComboBoxClass))
#define GTK_IS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO_BOX))
#define GTK_IS_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_COMBO_BOX))
#define GTK_COMBO_BOX_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_COMBO_BOX, GtkComboBoxClass))
#define GTK_COMBO_BOX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_COMBO_BOX, GtkComboBoxPrivate))
typedef struct _GtkComboBox GtkComboBox;
typedef struct _GtkComboBoxClass GtkComboBoxClass;
typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate;
struct _GtkComboBox
{
GtkBin parent_instance;
/*< private >*/
GtkComboBoxPrivate *priv;
};
struct _GtkComboBoxClass
{
GtkBinClass parent_class;
/* signals */
void (* changed) (GtkComboBox *combo_box);
};
/* construction */
GType gtk_combo_box_get_type (void);
GtkWidget *gtk_combo_box_new (GtkTreeModel *model);
/* manipulate list of cell renderers */
void gtk_combo_box_pack_start (GtkComboBox *combo_box,
GtkCellRenderer *cell,
gboolean expand);
void gtk_combo_box_pack_end (GtkComboBox *combo_box,
GtkCellRenderer *cell,
gboolean expand);
void gtk_combo_box_set_attributes (GtkComboBox *combo_box,
GtkCellRenderer *cell,
...);
void gtk_combo_box_clear (GtkComboBox *combo_box);
/* grids */
void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
gint width);
void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
gint row_span);
void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
gint column_span);
/* get/set active item */
gint gtk_combo_box_get_active (GtkComboBox *combo_box);
void gtk_combo_box_set_active (GtkComboBox *combo_box,
gint index);
/* getters and setters */
GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box);
/* convenience -- text */
GtkWidget *gtk_combo_box_new_text (void);
void gtk_combo_box_append_text (GtkComboBox *combo_box,
const gchar *text);
void gtk_combo_box_insert_text (GtkComboBox *combo_box,
gint position,
const gchar *text);
void gtk_combo_box_prepend_text (GtkComboBox *combo_box,
const gchar *text);
G_END_DECLS
#endif /* __GTK_COMBO_BOX_H__ */
/* gtkcomboboxentry.c
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gtk/gtkcomboboxentry.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkcellrenderertext.h>
struct _GtkComboBoxEntryPrivate
{
GtkWidget *entry;
gint text_column;
};
static void gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass);
static void gtk_combo_box_entry_init (GtkComboBoxEntry *entry_box);
static void gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
gpointer user_data);
static void gtk_combo_box_entry_contents_changed (GtkEntry *entry,
gpointer user_data);
GType
gtk_combo_box_entry_get_type (void)
{
static GType combo_box_entry_type = 0;
if (!combo_box_entry_type)
{
static const GTypeInfo combo_box_entry_info =
{
sizeof (GtkComboBoxEntryClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_combo_box_entry_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkComboBoxEntry),
0,
(GInstanceInitFunc) gtk_combo_box_entry_init
};
combo_box_entry_type = g_type_register_static (GTK_TYPE_COMBO_BOX,
"GtkComboBoxEntry",
&combo_box_entry_info,
0);
}
return combo_box_entry_type;
}
static void
gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass)
{
g_type_class_add_private ((GObjectClass *) klass,
sizeof (GtkComboBoxEntryPrivate));
}
static void
gtk_combo_box_entry_init (GtkComboBoxEntry *entry_box)
{
entry_box->priv = GTK_COMBO_BOX_ENTRY_GET_PRIVATE (entry_box);
}
static void
gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
gpointer user_data)
{
gint index;
GtkComboBoxEntry *entry_box = GTK_COMBO_BOX_ENTRY (combo_box);
index = gtk_combo_box_get_active (combo_box);
g_signal_handlers_block_by_func (entry_box->priv->entry,
gtk_combo_box_entry_contents_changed,
combo_box);
if (index < 0)
gtk_entry_set_text (GTK_ENTRY (entry_box->priv->entry), "");
else
{
gchar *str = NULL;
GtkTreeIter iter;
GtkTreeModel *model;
model = gtk_combo_box_get_model (combo_box);
gtk_tree_model_iter_nth_child (model, &iter, NULL, index);
gtk_tree_model_get (model, &iter,
entry_box->priv->text_column, &str,
-1);
gtk_entry_set_text (GTK_ENTRY (entry_box->priv->entry), str);
g_free (str);
}
g_signal_handlers_unblock_by_func (entry_box->priv->entry,
gtk_combo_box_entry_contents_changed,
combo_box);
}
static void
gtk_combo_box_entry_contents_changed (GtkEntry *entry,
gpointer user_data)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
g_signal_handlers_block_by_func (combo_box,
gtk_combo_box_entry_active_changed,
NULL);
gtk_combo_box_set_active (combo_box, -1);
g_signal_handlers_unblock_by_func (combo_box,
gtk_combo_box_entry_active_changed,
NULL);
}
/* public API */
GtkWidget *
gtk_combo_box_entry_new (GtkTreeModel *model,
gint text_column)
{
GtkWidget *ret;
GtkCellRenderer *renderer;
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
g_return_val_if_fail (text_column >= 0, NULL);
g_return_val_if_fail (text_column < gtk_tree_model_get_n_columns (model), NULL);
ret = g_object_new (gtk_combo_box_entry_get_type (),
"model", model,
NULL);
GTK_COMBO_BOX_ENTRY (ret)->priv->entry = gtk_entry_new ();
gtk_container_add (GTK_CONTAINER (ret),
GTK_COMBO_BOX_ENTRY (ret)->priv->entry);
GTK_COMBO_BOX_ENTRY (ret)->priv->text_column = text_column;
renderer = gtk_cell_renderer_text_new ();
gtk_combo_box_pack_start (GTK_COMBO_BOX (ret), renderer, TRUE);
gtk_combo_box_set_attributes (GTK_COMBO_BOX (ret), renderer,
"text", text_column,
NULL);
g_signal_connect (GTK_COMBO_BOX_ENTRY (ret)->priv->entry, "changed",
G_CALLBACK (gtk_combo_box_entry_contents_changed), ret);
g_signal_connect (ret, "changed",
G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
return ret;
}
gint
gtk_combo_box_entry_get_text_column (GtkComboBoxEntry *entry_box)
{
g_return_val_if_fail (GTK_IS_COMBO_BOX_ENTRY (entry_box), 0);
return entry_box->priv->text_column;
}
/* gtkcomboboxentry.h
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_COMBO_BOX_ENTRY_H__
#define __GTK_COMBO_BOX_ENTRY_H__