Commit adcf33fa authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Add a tearoff-title property, with getter and setter. (#316482, Olexiy

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
parent 5266d78a
2005-11-21 Matthias Clasen <mclasen@redhat.com> 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, * gtk/gtkpathbar.c: Merge remaining fixes from the 2.8 branch,
pointed out by Michael Natterer. pointed out by Michael Natterer.
......
2005-11-21 Matthias Clasen <mclasen@redhat.com> 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, * gtk/gtkpathbar.c: Merge remaining fixes from the 2.8 branch,
pointed out by Michael Natterer. pointed out by Michael Natterer.
......
2005-11-21 Matthias Clasen <mclasen@redhat.com> 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. * gtk/Makefile.am (HTML_IMAGES): Fix some _ vs - confusion.
2005-11-14 Matthias Clasen <mclasen@redhat.com> 2005-11-14 Matthias Clasen <mclasen@redhat.com>
......
...@@ -753,6 +753,8 @@ gtk_combo_box_get_row_separator_func ...@@ -753,6 +753,8 @@ gtk_combo_box_get_row_separator_func
gtk_combo_box_set_row_separator_func gtk_combo_box_set_row_separator_func
gtk_combo_box_set_add_tearoffs gtk_combo_box_set_add_tearoffs
gtk_combo_box_get_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_set_focus_on_click
gtk_combo_box_get_focus_on_click gtk_combo_box_get_focus_on_click
<SUBSECTION Standard> <SUBSECTION Standard>
......
...@@ -731,6 +731,7 @@ gtk_combo_box_get_model ...@@ -731,6 +731,7 @@ gtk_combo_box_get_model
gtk_combo_box_get_popup_accessible gtk_combo_box_get_popup_accessible
gtk_combo_box_get_row_separator_func gtk_combo_box_get_row_separator_func
gtk_combo_box_get_row_span_column gtk_combo_box_get_row_span_column
gtk_combo_box_get_title
gtk_combo_box_get_type G_GNUC_CONST gtk_combo_box_get_type G_GNUC_CONST
gtk_combo_box_get_wrap_width gtk_combo_box_get_wrap_width
gtk_combo_box_insert_text gtk_combo_box_insert_text
...@@ -749,6 +750,7 @@ gtk_combo_box_set_focus_on_click ...@@ -749,6 +750,7 @@ gtk_combo_box_set_focus_on_click
gtk_combo_box_set_model gtk_combo_box_set_model
gtk_combo_box_set_row_separator_func gtk_combo_box_set_row_separator_func
gtk_combo_box_set_row_span_column gtk_combo_box_set_row_span_column
gtk_combo_box_set_title
gtk_combo_box_set_wrap_width gtk_combo_box_set_wrap_width
#endif #endif
#endif #endif
......
...@@ -121,6 +121,8 @@ struct _GtkComboBoxPrivate ...@@ -121,6 +121,8 @@ struct _GtkComboBoxPrivate
GtkTreeViewRowSeparatorFunc row_separator_func; GtkTreeViewRowSeparatorFunc row_separator_func;
gpointer row_separator_data; gpointer row_separator_data;
GtkDestroyNotify row_separator_destroy; GtkDestroyNotify row_separator_destroy;
gchar *tearoff_title;
}; };
/* While debugging this evil code, I have learned that /* While debugging this evil code, I have learned that
...@@ -196,6 +198,7 @@ enum { ...@@ -196,6 +198,7 @@ enum {
PROP_COLUMN_SPAN_COLUMN, PROP_COLUMN_SPAN_COLUMN,
PROP_ACTIVE, PROP_ACTIVE,
PROP_ADD_TEAROFFS, PROP_ADD_TEAROFFS,
PROP_TEAROFF_TITLE,
PROP_HAS_FRAME, PROP_HAS_FRAME,
PROP_FOCUS_ON_CLICK PROP_FOCUS_ON_CLICK
}; };
...@@ -353,6 +356,7 @@ static void gtk_combo_box_menu_fill (GtkComboBox *combo_box) ...@@ -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, static void gtk_combo_box_menu_fill_level (GtkComboBox *combo_box,
GtkWidget *menu, GtkWidget *menu,
GtkTreeIter *iter); 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_menu_destroy (GtkComboBox *combo_box);
static void gtk_combo_box_relayout_item (GtkComboBox *combo_box, static void gtk_combo_box_relayout_item (GtkComboBox *combo_box,
...@@ -550,7 +554,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) ...@@ -550,7 +554,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
g_signal_new ("popup-show", g_signal_new ("popup-show",
G_OBJECT_CLASS_TYPE (klass), G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
NULL, 0,
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
...@@ -559,7 +563,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) ...@@ -559,7 +563,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
g_signal_new ("popup-hide", g_signal_new ("popup-hide",
G_OBJECT_CLASS_TYPE (klass), G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
NULL, 0,
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
...@@ -709,6 +713,23 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) ...@@ -709,6 +713,23 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
TRUE, TRUE,
GTK_PARAM_READWRITE)); 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, gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("appears-as-list", g_param_spec_boolean ("appears-as-list",
P_("Appears as list"), P_("Appears as list"),
...@@ -805,6 +826,10 @@ gtk_combo_box_set_property (GObject *object, ...@@ -805,6 +826,10 @@ gtk_combo_box_set_property (GObject *object,
g_value_get_boolean (value)); g_value_get_boolean (value));
break; break;
case PROP_TEAROFF_TITLE:
gtk_combo_box_set_title (combo_box, g_value_get_string (value));
break;
default: default:
break; break;
} }
...@@ -852,6 +877,10 @@ gtk_combo_box_get_property (GObject *object, ...@@ -852,6 +877,10 @@ gtk_combo_box_get_property (GObject *object,
g_value_set_boolean (value, combo_box->priv->focus_on_click); g_value_set_boolean (value, combo_box->priv->focus_on_click);
break; break;
case PROP_TEAROFF_TITLE:
g_value_set_string (value, gtk_combo_box_get_title (combo_box));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -2510,6 +2539,8 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box, ...@@ -2510,6 +2539,8 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
gtk_object_sink (GTK_OBJECT (combo_box->priv->column)); gtk_object_sink (GTK_OBJECT (combo_box->priv->column));
gtk_combo_box_sync_cells (combo_box, gtk_combo_box_sync_cells (combo_box,
GTK_CELL_LAYOUT (combo_box->priv->column)); GTK_CELL_LAYOUT (combo_box->priv->column));
gtk_combo_box_update_title (combo_box);
} }
static void static void
...@@ -5117,6 +5148,64 @@ gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box, ...@@ -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 gboolean
_gtk_combo_box_editing_canceled (GtkComboBox *combo_box) _gtk_combo_box_editing_canceled (GtkComboBox *combo_box)
{ {
......
...@@ -81,6 +81,11 @@ void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, ...@@ -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); gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box);
void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box, void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
gboolean add_tearoffs); 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); gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
void gtk_combo_box_set_focus_on_click (GtkComboBox *combo, void gtk_combo_box_set_focus_on_click (GtkComboBox *combo,
gboolean focus_on_click); gboolean focus_on_click);
......
...@@ -1126,6 +1126,7 @@ main (int argc, char **argv) ...@@ -1126,6 +1126,7 @@ main (int argc, char **argv)
is_separator, NULL, NULL); is_separator, NULL, NULL);
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
gtk_combo_box_set_title (GTK_COMBO_BOX (combobox), "Dynamic list");
/* GtkComboBox custom entry */ /* GtkComboBox custom entry */
tmp = gtk_frame_new ("GtkComboBox (custom)"); tmp = gtk_frame_new ("GtkComboBox (custom)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment