]> Pileus Git - ~andy/gtk/commitdiff
Add a tearoff-title property, with getter and setter. (#316482, Olexiy
authorMatthias Clasen <mclasen@redhat.com>
Mon, 21 Nov 2005 16:01:56 +0000 (16:01 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 21 Nov 2005 16:01:56 +0000 (16:01 +0000)
2005-11-21  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtk.symbols:
* gtk/gtkcombobox.[hc]: Add a tearoff-title property,
with getter and setter.  (#316482, Olexiy Avramchenko)

* tests/testcombo.c (main): Test gtk_combo_box_set_title

ChangeLog
ChangeLog.pre-2-10
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkcombobox.c
gtk/gtkcombobox.h
tests/testcombo.c

index 43cedd5547df4e289a8806f88b6ba767e1b10511..01117215587ce5b41b789dbd21bb691905570b8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2005-11-21  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols:
+       * gtk/gtkcombobox.[hc]: Add a tearoff-title property,
+       with getter and setter.  (#316482, Olexiy Avramchenko)
+
+       * tests/testcombo.c (main): Test gtk_combo_box_set_title
+
        * gtk/gtkpathbar.c: Merge remaining fixes from the 2.8 branch,
        pointed out by Michael Natterer.
 
index 43cedd5547df4e289a8806f88b6ba767e1b10511..01117215587ce5b41b789dbd21bb691905570b8e 100644 (file)
@@ -1,5 +1,11 @@
 2005-11-21  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols:
+       * gtk/gtkcombobox.[hc]: Add a tearoff-title property,
+       with getter and setter.  (#316482, Olexiy Avramchenko)
+
+       * tests/testcombo.c (main): Test gtk_combo_box_set_title
+
        * gtk/gtkpathbar.c: Merge remaining fixes from the 2.8 branch,
        pointed out by Michael Natterer.
 
index 6293720e2f38416a857278c5fb75aeabbd8adc4e..40e230e28cdbe8b270c741e05f9d5a489a280d48 100644 (file)
@@ -1,5 +1,7 @@
 2005-11-21  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk-sections.txt: Add gtk_combo_box_[sg]et_title
+
        * gtk/Makefile.am (HTML_IMAGES): Fix some _ vs - confusion. 
 
 2005-11-14  Matthias Clasen  <mclasen@redhat.com>
index 4d71c325c3179ddf06c601616c7c7f888d684c3a..75a1ad328743c062cace9a284d87c3a3ee073040 100644 (file)
@@ -753,6 +753,8 @@ gtk_combo_box_get_row_separator_func
 gtk_combo_box_set_row_separator_func
 gtk_combo_box_set_add_tearoffs
 gtk_combo_box_get_add_tearoffs
+gtk_combo_box_set_title
+gtk_combo_box_get_title
 gtk_combo_box_set_focus_on_click
 gtk_combo_box_get_focus_on_click
 <SUBSECTION Standard>
index 4a42eb045d5c5721f2e934bd992e293004befdae..da23d2989215570e96f4e4b9961b33f19493827c 100644 (file)
@@ -731,6 +731,7 @@ gtk_combo_box_get_model
 gtk_combo_box_get_popup_accessible
 gtk_combo_box_get_row_separator_func
 gtk_combo_box_get_row_span_column
+gtk_combo_box_get_title
 gtk_combo_box_get_type G_GNUC_CONST
 gtk_combo_box_get_wrap_width
 gtk_combo_box_insert_text
@@ -749,6 +750,7 @@ gtk_combo_box_set_focus_on_click
 gtk_combo_box_set_model
 gtk_combo_box_set_row_separator_func
 gtk_combo_box_set_row_span_column
+gtk_combo_box_set_title
 gtk_combo_box_set_wrap_width
 #endif
 #endif
index 1a2aa834fbd11bcb10611e271f4203016ad3ddfd..526b16c751c5fc49bdd99b358ff284ff17a7bd0e 100644 (file)
@@ -121,6 +121,8 @@ struct _GtkComboBoxPrivate
   GtkTreeViewRowSeparatorFunc row_separator_func;
   gpointer                    row_separator_data;
   GtkDestroyNotify            row_separator_destroy;
+
+  gchar *tearoff_title;
 };
 
 /* While debugging this evil code, I have learned that
@@ -196,6 +198,7 @@ enum {
   PROP_COLUMN_SPAN_COLUMN,
   PROP_ACTIVE,
   PROP_ADD_TEAROFFS,
+  PROP_TEAROFF_TITLE,
   PROP_HAS_FRAME,
   PROP_FOCUS_ON_CLICK
 };
@@ -353,6 +356,7 @@ static void     gtk_combo_box_menu_fill            (GtkComboBox      *combo_box)
 static void     gtk_combo_box_menu_fill_level      (GtkComboBox      *combo_box,
                                                    GtkWidget        *menu,
                                                    GtkTreeIter      *iter);
+static void     gtk_combo_box_update_title         (GtkComboBox      *combo_box);
 static void     gtk_combo_box_menu_destroy         (GtkComboBox      *combo_box);
 
 static void     gtk_combo_box_relayout_item        (GtkComboBox      *combo_box,
@@ -550,7 +554,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
     g_signal_new ("popup-show",
                   G_OBJECT_CLASS_TYPE (klass),
                   G_SIGNAL_RUN_LAST,
-                  NULL,
+                  0,
                   NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
@@ -559,7 +563,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
     g_signal_new ("popup-hide",
                   G_OBJECT_CLASS_TYPE (klass),
                   G_SIGNAL_RUN_LAST,
-                  NULL,
+                  0,
                   NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
@@ -709,6 +713,23 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                         TRUE,
                                                         GTK_PARAM_READWRITE));
 
+  /**
+   * GtkComboBox:tearoff-title:
+   *
+   * A title that may be displayed by the window manager 
+   * when the popup is torn-off.
+   *
+   * Since: 2.10
+   */
+  g_object_class_install_property (object_class,
+                                   PROP_TEAROFF_TITLE,
+                                   g_param_spec_string ("tearoff-title",
+                                                        P_("Tearoff Title"),
+                                                        P_("A title that may be displayed by the window manager when the popup is torn-off"),
+                                                        "",
+                                                        GTK_PARAM_READWRITE));
+
+
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_boolean ("appears-as-list",
                                                                  P_("Appears as list"),
@@ -805,6 +826,10 @@ gtk_combo_box_set_property (GObject      *object,
                                          g_value_get_boolean (value));
         break;
 
+      case PROP_TEAROFF_TITLE:
+       gtk_combo_box_set_title (combo_box, g_value_get_string (value));
+        break;
+
       default:
         break;
     }
@@ -852,6 +877,10 @@ gtk_combo_box_get_property (GObject    *object,
         g_value_set_boolean (value, combo_box->priv->focus_on_click);
         break;
 
+      case PROP_TEAROFF_TITLE:
+        g_value_set_string (value, gtk_combo_box_get_title (combo_box));
+        break;
+
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -2510,6 +2539,8 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
   gtk_object_sink (GTK_OBJECT (combo_box->priv->column));
   gtk_combo_box_sync_cells (combo_box, 
                            GTK_CELL_LAYOUT (combo_box->priv->column));
+
+  gtk_combo_box_update_title (combo_box);
 }
 
 static void
@@ -5117,6 +5148,64 @@ gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
     }
 }
 
+/**
+ * gtk_combo_box_get_title:
+ * @combo_box: a #GtkComboBox
+ *
+ * Gets the current title of the menu in tearoff mode. See
+ * gtk_combo_box_set_add_tearoffs().
+ *
+ * Returns: the menu's title in tearoff mode. This is an internal copy of the
+ * string which must not be freed.
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar*
+gtk_combo_box_get_title (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
+  
+  return combo_box->priv->tearoff_title;
+}
+
+static void
+gtk_combo_box_update_title (GtkComboBox *combo_box)
+{
+  gtk_combo_box_check_appearance (combo_box);
+  
+  if (combo_box->priv->popup_widget && 
+      GTK_IS_MENU (combo_box->priv->popup_widget))
+    gtk_menu_set_title (GTK_MENU (combo_box->priv->popup_widget), 
+                       combo_box->priv->tearoff_title);
+}
+
+/**
+ * gtk_combo_box_set_title:
+ * @combo_box: a #GtkComboBox 
+ * @title: a title for the menu in tearoff mode.
+ *  
+ * Sets the menu's title in tearoff mode.
+ *
+ * Since: 2.10
+ */
+void
+gtk_combo_box_set_title (GtkComboBox *combo_box,
+                        const gchar *title)
+{
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  if (strcmp (title ? title : "", 
+             combo_box->priv->tearoff_title ? combo_box->priv->tearoff_title : "") != 0)
+    {
+      g_free (combo_box->priv->tearoff_title);
+      combo_box->priv->tearoff_title = g_strdup (title);
+
+      gtk_combo_box_update_title (combo_box);
+
+      g_object_notify (G_OBJECT (combo_box), "tearoff-title");
+    }
+}
+
 gboolean
 _gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
 {
index e8b2a46cc4220f5c1f4048725c5455ad533c841f..6ab2d954540c17b3a1835d9a117046edf4913b40 100644 (file)
@@ -81,6 +81,11 @@ void          gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
 gboolean      gtk_combo_box_get_add_tearoffs       (GtkComboBox *combo_box);
 void          gtk_combo_box_set_add_tearoffs       (GtkComboBox *combo_box,
                                                    gboolean     add_tearoffs);
+
+G_CONST_RETURN gchar *gtk_combo_box_get_title      (GtkComboBox *combo_box);
+void                  gtk_combo_box_set_title      (GtkComboBox *combo_box,
+                                                   const gchar *title);
+
 gboolean      gtk_combo_box_get_focus_on_click     (GtkComboBox *combo);
 void          gtk_combo_box_set_focus_on_click     (GtkComboBox *combo,
                                                    gboolean     focus_on_click);
index ba753420724d4a0ef0936807c489b840c7caf470..32ee4d1cad71a4fb23fdffd3d009acc6670aa23c 100644 (file)
@@ -1126,6 +1126,7 @@ main (int argc, char **argv)
                                              is_separator, NULL, NULL);
                                                
         gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
+       gtk_combo_box_set_title (GTK_COMBO_BOX (combobox), "Dynamic list");
 
         /* GtkComboBox custom entry */
         tmp = gtk_frame_new ("GtkComboBox (custom)");