mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-16 21:50:34 +00:00
entry completion: Convert to g_object_notify_by_pspec
This avoid pspec lookup overhead in g_object_notify.
This commit is contained in:
parent
e83ccecfab
commit
f4068288e7
@ -115,7 +115,8 @@ enum
|
|||||||
PROP_POPUP_SET_WIDTH,
|
PROP_POPUP_SET_WIDTH,
|
||||||
PROP_POPUP_SINGLE_MATCH,
|
PROP_POPUP_SINGLE_MATCH,
|
||||||
PROP_INLINE_SELECTION,
|
PROP_INLINE_SELECTION,
|
||||||
PROP_CELL_AREA
|
PROP_CELL_AREA,
|
||||||
|
NUM_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -184,6 +185,8 @@ static void connect_completion_signals (GtkEntryCompletion
|
|||||||
static void disconnect_completion_signals (GtkEntryCompletion *completion);
|
static void disconnect_completion_signals (GtkEntryCompletion *completion);
|
||||||
|
|
||||||
|
|
||||||
|
static GParamSpec *entry_completion_props[NUM_PROPERTIES] = { NULL, };
|
||||||
|
|
||||||
static guint entry_completion_signals[LAST_SIGNAL] = { 0 };
|
static guint entry_completion_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
/* GtkBuildable */
|
/* GtkBuildable */
|
||||||
@ -340,22 +343,20 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
G_TYPE_INT);
|
G_TYPE_INT);
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_MODEL] =
|
||||||
PROP_MODEL,
|
g_param_spec_object ("model",
|
||||||
g_param_spec_object ("model",
|
P_("Completion Model"),
|
||||||
P_("Completion Model"),
|
P_("The model to find matches in"),
|
||||||
P_("The model to find matches in"),
|
GTK_TYPE_TREE_MODEL,
|
||||||
GTK_TYPE_TREE_MODEL,
|
GTK_PARAM_READWRITE);
|
||||||
GTK_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_MINIMUM_KEY_LENGTH] =
|
||||||
PROP_MINIMUM_KEY_LENGTH,
|
g_param_spec_int ("minimum-key-length",
|
||||||
g_param_spec_int ("minimum-key-length",
|
P_("Minimum Key Length"),
|
||||||
P_("Minimum Key Length"),
|
P_("Minimum length of the search key in order to look up matches"),
|
||||||
P_("Minimum length of the search key in order to look up matches"),
|
0, G_MAXINT, 1,
|
||||||
0,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
G_MAXINT,
|
|
||||||
1,
|
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:text-column:
|
* GtkEntryCompletion:text-column:
|
||||||
*
|
*
|
||||||
@ -364,15 +365,12 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.6
|
* Since: 2.6
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_TEXT_COLUMN] =
|
||||||
PROP_TEXT_COLUMN,
|
g_param_spec_int ("text-column",
|
||||||
g_param_spec_int ("text-column",
|
P_("Text column"),
|
||||||
P_("Text column"),
|
P_("The column of the model containing the strings."),
|
||||||
P_("The column of the model containing the strings."),
|
-1, G_MAXINT, -1,
|
||||||
-1,
|
GTK_PARAM_READWRITE);
|
||||||
G_MAXINT,
|
|
||||||
-1,
|
|
||||||
GTK_PARAM_READWRITE));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:inline-completion:
|
* GtkEntryCompletion:inline-completion:
|
||||||
@ -384,13 +382,12 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.6
|
* Since: 2.6
|
||||||
**/
|
**/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_INLINE_COMPLETION] =
|
||||||
PROP_INLINE_COMPLETION,
|
g_param_spec_boolean ("inline-completion",
|
||||||
g_param_spec_boolean ("inline-completion",
|
P_("Inline completion"),
|
||||||
P_("Inline completion"),
|
P_("Whether the common prefix should be inserted automatically"),
|
||||||
P_("Whether the common prefix should be inserted automatically"),
|
FALSE,
|
||||||
FALSE,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:popup-completion:
|
* GtkEntryCompletion:popup-completion:
|
||||||
@ -400,13 +397,12 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.6
|
* Since: 2.6
|
||||||
**/
|
**/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_POPUP_COMPLETION] =
|
||||||
PROP_POPUP_COMPLETION,
|
g_param_spec_boolean ("popup-completion",
|
||||||
g_param_spec_boolean ("popup-completion",
|
P_("Popup completion"),
|
||||||
P_("Popup completion"),
|
P_("Whether the completions should be shown in a popup window"),
|
||||||
P_("Whether the completions should be shown in a popup window"),
|
TRUE,
|
||||||
TRUE,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:popup-set-width:
|
* GtkEntryCompletion:popup-set-width:
|
||||||
@ -416,13 +412,12 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.8
|
* Since: 2.8
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_POPUP_SET_WIDTH] =
|
||||||
PROP_POPUP_SET_WIDTH,
|
g_param_spec_boolean ("popup-set-width",
|
||||||
g_param_spec_boolean ("popup-set-width",
|
P_("Popup set width"),
|
||||||
P_("Popup set width"),
|
P_("If TRUE, the popup window will have the same size as the entry"),
|
||||||
P_("If TRUE, the popup window will have the same size as the entry"),
|
TRUE,
|
||||||
TRUE,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:popup-single-match:
|
* GtkEntryCompletion:popup-single-match:
|
||||||
@ -434,13 +429,13 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.8
|
* Since: 2.8
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_POPUP_SINGLE_MATCH] =
|
||||||
PROP_POPUP_SINGLE_MATCH,
|
g_param_spec_boolean ("popup-single-match",
|
||||||
g_param_spec_boolean ("popup-single-match",
|
P_("Popup single match"),
|
||||||
P_("Popup single match"),
|
P_("If TRUE, the popup window will appear for a single match."),
|
||||||
P_("If TRUE, the popup window will appear for a single match."),
|
TRUE,
|
||||||
TRUE,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:inline-selection:
|
* GtkEntryCompletion:inline-selection:
|
||||||
*
|
*
|
||||||
@ -449,32 +444,32 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
|
|||||||
*
|
*
|
||||||
* Since: 2.12
|
* Since: 2.12
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_INLINE_SELECTION] =
|
||||||
PROP_INLINE_SELECTION,
|
g_param_spec_boolean ("inline-selection",
|
||||||
g_param_spec_boolean ("inline-selection",
|
P_("Inline selection"),
|
||||||
P_("Inline selection"),
|
P_("Your description here"),
|
||||||
P_("Your description here"),
|
FALSE,
|
||||||
FALSE,
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkEntryCompletion:cell-area:
|
* GtkEntryCompletion:cell-area:
|
||||||
*
|
*
|
||||||
* The #GtkCellArea used to layout cell renderers in the treeview column.
|
* The #GtkCellArea used to layout cell renderers in the treeview column.
|
||||||
*
|
*
|
||||||
* If no area is specified when creating the entry completion with gtk_entry_completion_new_with_area()
|
* If no area is specified when creating the entry completion with
|
||||||
* a horizontally oriented #GtkCellAreaBox will be used.
|
* gtk_entry_completion_new_with_area() a horizontally oriented
|
||||||
|
* #GtkCellAreaBox will be used.
|
||||||
*
|
*
|
||||||
* Since: 3.0
|
* Since: 3.0
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
entry_completion_props[PROP_CELL_AREA] =
|
||||||
PROP_CELL_AREA,
|
g_param_spec_object ("cell-area",
|
||||||
g_param_spec_object ("cell-area",
|
P_("Cell Area"),
|
||||||
P_("Cell Area"),
|
P_("The GtkCellArea used to layout cells"),
|
||||||
P_("The GtkCellArea used to layout cells"),
|
GTK_TYPE_CELL_AREA,
|
||||||
GTK_TYPE_CELL_AREA,
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
g_object_class_install_properties (object_class, NUM_PROPERTIES, entry_completion_props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1164,7 +1159,7 @@ gtk_entry_completion_set_model (GtkEntryCompletion *completion,
|
|||||||
GTK_TREE_MODEL (completion->priv->filter_model));
|
GTK_TREE_MODEL (completion->priv->filter_model));
|
||||||
g_object_unref (completion->priv->filter_model);
|
g_object_unref (completion->priv->filter_model);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "model");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_MODEL]);
|
||||||
|
|
||||||
if (gtk_widget_get_visible (completion->priv->popup_window))
|
if (gtk_widget_get_visible (completion->priv->popup_window))
|
||||||
_gtk_entry_completion_resize_popup (completion);
|
_gtk_entry_completion_resize_popup (completion);
|
||||||
@ -1245,7 +1240,8 @@ gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->minimum_key_length = length;
|
completion->priv->minimum_key_length = length;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "minimum-key-length");
|
g_object_notify_by_pspec (G_OBJECT (completion),
|
||||||
|
entry_completion_props[PROP_MINIMUM_KEY_LENGTH]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1445,7 +1441,7 @@ gtk_entry_completion_set_text_column (GtkEntryCompletion *completion,
|
|||||||
cell,
|
cell,
|
||||||
"text", column);
|
"text", column);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "text-column");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_TEXT_COLUMN]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1947,7 +1943,7 @@ gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->inline_completion = inline_completion;
|
completion->priv->inline_completion = inline_completion;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "inline-completion");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_INLINE_COMPLETION]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1991,7 +1987,7 @@ gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->popup_completion = popup_completion;
|
completion->priv->popup_completion = popup_completion;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "popup-completion");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_COMPLETION]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2036,7 +2032,7 @@ gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->popup_set_width = popup_set_width;
|
completion->priv->popup_set_width = popup_set_width;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "popup-set-width");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_SET_WIDTH]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2085,7 +2081,7 @@ gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->popup_single_match = popup_single_match;
|
completion->priv->popup_single_match = popup_single_match;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "popup-single-match");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_POPUP_SINGLE_MATCH]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2131,7 +2127,7 @@ gtk_entry_completion_set_inline_selection (GtkEntryCompletion *completion,
|
|||||||
{
|
{
|
||||||
completion->priv->inline_selection = inline_selection;
|
completion->priv->inline_selection = inline_selection;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (completion), "inline-selection");
|
g_object_notify_by_pspec (G_OBJECT (completion), entry_completion_props[PROP_INLINE_SELECTION]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user