]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcomboboxentry.c
broooooooken pipe
[~andy/gtk] / gtk / gtkcomboboxentry.c
index 9c3e698594ca3f83ca076a4dc4130418cd95c3a0..e4fc737dca1bb7c3ce221dd0839b22dd1edfe693 100644 (file)
@@ -24,6 +24,7 @@
 #include "gtkentry.h"
 #include "gtkcellrenderertext.h"
 
+#include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
@@ -37,9 +38,6 @@ struct _GtkComboBoxEntryPrivate
   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,
@@ -49,12 +47,14 @@ static void gtk_combo_box_entry_get_property     (GObject               *object,
                                                   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);
@@ -65,49 +65,26 @@ enum
   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",
@@ -116,7 +93,7 @@ gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass)
                                                      -1,
                                                      G_MAXINT,
                                                      -1,
-                                                     G_PARAM_READWRITE));
+                                                     GTK_PARAM_READWRITE));
 
   g_type_class_add_private ((GObjectClass *) klass,
                             sizeof (GtkComboBoxEntryPrivate));
@@ -226,7 +203,7 @@ has_frame_changed (GtkComboBoxEntry *entry_box,
 {
   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);
 }
@@ -292,7 +269,7 @@ gtk_combo_box_entry_new_with_model (GtkTreeModel *model,
 
   ret = g_object_new (gtk_combo_box_entry_get_type (),
                       "model", model,
-                      "text_column", text_column,
+                      "text-column", text_column,
                       NULL);
 
   return ret;
@@ -306,7 +283,7 @@ gtk_combo_box_entry_new_with_model (GtkTreeModel *model,
  * 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,
@@ -353,6 +330,15 @@ gtk_combo_box_entry_mnemonic_activate (GtkWidget *widget,
   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 */
 
@@ -383,5 +369,16 @@ gtk_combo_box_entry_new_text (void)
   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"