]> Pileus Git - ~andy/gtk/commitdiff
move function to a somewhat more logical place,
authorKristian Rietveld <kris@gtk.org>
Wed, 19 Nov 2003 22:26:42 +0000 (22:26 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Wed, 19 Nov 2003 22:26:42 +0000 (22:26 +0000)
Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>

* gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
to a somewhat more logical place,
(gtk_combo_box_remove_text): New function (#125262, Owen Taylor).

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcombobox.c
gtk/gtkcombobox.h

index b63d14a88ab8e1faf20490ca319c02bdcfc6f33b..287efa636c3a9ebf28e0301220eca135ac19bf1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
+       to a somewhat more logical place,
+       (gtk_combo_box_remove_text): New function (#125262, Owen Taylor).
+
 Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
index b63d14a88ab8e1faf20490ca319c02bdcfc6f33b..287efa636c3a9ebf28e0301220eca135ac19bf1c 100644 (file)
@@ -1,3 +1,9 @@
+Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
+       to a somewhat more logical place,
+       (gtk_combo_box_remove_text): New function (#125262, Owen Taylor).
+
 Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
index b63d14a88ab8e1faf20490ca319c02bdcfc6f33b..287efa636c3a9ebf28e0301220eca135ac19bf1c 100644 (file)
@@ -1,3 +1,9 @@
+Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
+       to a somewhat more logical place,
+       (gtk_combo_box_remove_text): New function (#125262, Owen Taylor).
+
 Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
index b63d14a88ab8e1faf20490ca319c02bdcfc6f33b..287efa636c3a9ebf28e0301220eca135ac19bf1c 100644 (file)
@@ -1,3 +1,9 @@
+Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
+       to a somewhat more logical place,
+       (gtk_combo_box_remove_text): New function (#125262, Owen Taylor).
+
 Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
index b63d14a88ab8e1faf20490ca319c02bdcfc6f33b..287efa636c3a9ebf28e0301220eca135ac19bf1c 100644 (file)
@@ -1,3 +1,9 @@
+Wed Nov 19 23:19:23 2003  Kristian Rietveld  <kris@gtk.org>
+
+       * gtk/gtkcombobox.[ch] (gtk_combo_box_scroll_event): move function
+       to a somewhat more logical place,
+       (gtk_combo_box_remove_text): New function (#125262, Owen Taylor).
+
 Wed Nov 19 22:15:01 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtkentry.c (gtk_entry_completion_timeout): always resize
index 93b35fe1bebc1b144730f3355ef3805993029217..1e5674e45baba42a66b810f7c721e3543155409d 100644 (file)
@@ -1171,6 +1171,31 @@ gtk_combo_box_expose_event (GtkWidget      *widget,
   return FALSE;
 }
 
+static gboolean
+gtk_combo_box_scroll_event (GtkWidget          *widget,
+                            GdkEventScroll     *event)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+  gint index;
+  gint items;
+    
+  index = gtk_combo_box_get_active (combo_box);
+
+  if (index != -1)
+    {
+      items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
+      
+      if (event->direction == GDK_SCROLL_UP)
+        index--;
+      else 
+        index++;
+
+      gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
+    }
+
+  return TRUE;
+}
+
 /*
  * menu style
  */
@@ -2670,28 +2695,30 @@ gtk_combo_box_prepend_text (GtkComboBox *combo_box,
   gtk_list_store_set (store, &iter, 0, text, -1);
 }
 
-static gboolean
-gtk_combo_box_scroll_event (GtkWidget          *widget,
-                            GdkEventScroll     *event)
+/**
+ * gtk_combo_box_remove_text:
+ * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
+ * @position: Index of the item to remove.
+ *
+ * Removes the string at @position from @combo_box. Note that you can only use
+ * this function with combo boxes constructed with gtk_combo_box_new_text().
+ *
+ * Since: 2.4
+ */
+void
+gtk_combo_box_remove_text (GtkComboBox *combo_box,
+                           gint         position)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-  gint index;
-  gint items;
-    
-  index = gtk_combo_box_get_active (combo_box);
+  GtkTreeIter iter;
+  GtkListStore *store;
 
-  if (index != -1)
-    {
-      items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
-      
-      if (event->direction == GDK_SCROLL_UP)
-        index--;
-      else 
-        index++;
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
+  g_return_if_fail (position >= 0);
 
-      gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
-    }
+  store = GTK_LIST_STORE (combo_box->priv->model);
 
-  return TRUE;
+  if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
+                                     NULL, position))
+    gtk_list_store_remove (store, &iter);
 }
-
index 891a6464d509929b417aa64e580ef4f451cc0e82..504f33edacb9c6c2383349b20eff190fd5b3b183 100644 (file)
@@ -96,6 +96,8 @@ void          gtk_combo_box_insert_text      (GtkComboBox     *combo_box,
                                               const gchar     *text);
 void          gtk_combo_box_prepend_text     (GtkComboBox     *combo_box,
                                               const gchar     *text);
+void          gtk_combo_box_remove_text      (GtkComboBox     *combo_box,
+                                              gint             position);
 
 G_END_DECLS