#include "gtkentry.h"
#include "gtkcellrenderertext.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h"
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_set_property (GObject *object,
guint prop_id,
const GValue *value,
GValue *value,
GParamSpec *pspec);
+static gchar *gtk_combo_box_entry_get_active_text (GtkComboBox *combo_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);
static gboolean gtk_combo_box_entry_mnemonic_activate (GtkWidget *entry,
gboolean group_cycling);
+static void gtk_combo_box_entry_grab_focus (GtkWidget *widget);
static void has_frame_changed (GtkComboBoxEntry *entry_box,
GParamSpec *pspec,
gpointer data);
PROP_TEXT_COLUMN
};
-
-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;
-}
+G_DEFINE_TYPE (GtkComboBoxEntry, gtk_combo_box_entry, GTK_TYPE_COMBO_BOX)
static void
gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
-
+ GtkComboBoxClass *combo_class;
+
object_class = (GObjectClass *)klass;
object_class->set_property = gtk_combo_box_entry_set_property;
object_class->get_property = gtk_combo_box_entry_get_property;
widget_class = (GtkWidgetClass *)klass;
widget_class->mnemonic_activate = gtk_combo_box_entry_mnemonic_activate;
+ widget_class->grab_focus = gtk_combo_box_entry_grab_focus;
+ combo_class = (GtkComboBoxClass *)klass;
+ combo_class->get_active_text = gtk_combo_box_entry_get_active_text;
+
g_object_class_install_property (object_class,
PROP_TEXT_COLUMN,
g_param_spec_int ("text-column",
-1,
G_MAXINT,
-1,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_type_class_add_private ((GObjectClass *) klass,
sizeof (GtkComboBoxEntryPrivate));
{
gboolean has_frame;
- g_object_get (entry_box, "has_frame", &has_frame, NULL);
+ g_object_get (entry_box, "has-frame", &has_frame, NULL);
gtk_entry_set_has_frame (GTK_ENTRY (entry_box->priv->entry), has_frame);
}
ret = g_object_new (gtk_combo_box_entry_get_type (),
"model", model,
- "text_column", text_column,
+ "text-column", text_column,
NULL);
return ret;
* Sets the model column which @entry_box should use to get strings from
* to be @text_column.
*
- * Since: 2.4.
+ * Since: 2.4
*/
void
gtk_combo_box_entry_set_text_column (GtkComboBoxEntry *entry_box,
return TRUE;
}
+static void
+gtk_combo_box_entry_grab_focus (GtkWidget *widget)
+{
+ GtkComboBoxEntry *entry_box = GTK_COMBO_BOX_ENTRY (widget);
+
+ gtk_widget_grab_focus (entry_box->priv->entry);
+}
+
+
/* convenience API for simple text combos */
return entry_box;
}
+static gchar *
+gtk_combo_box_entry_get_active_text (GtkComboBox *combo_box)
+{
+ GtkComboBoxEntry *combo = GTK_COMBO_BOX_ENTRY (combo_box);
+
+ if (combo->priv->entry)
+ return g_strdup (gtk_entry_get_text (GTK_ENTRY (combo->priv->entry)));
+
+ return NULL;
+}
+
#define __GTK_COMBO_BOX_ENTRY_C__
#include "gtkaliasdef.c"