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
This commit is contained in:
Matthias Clasen 2005-11-21 16:01:56 +00:00 committed by Matthias Clasen
parent 5266d78a6e
commit adcf33fa4d
8 changed files with 115 additions and 2 deletions

View 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.

View 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.

View 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>

View 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>

View 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

View 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)
{

View 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);

View 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)");