diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-04-04 05:15:32 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-04-04 05:15:32 +0000 |
commit | c4e31ace4d84aa275a857dc60e9ddf6a1fb41339 (patch) | |
tree | 673f011bca3a300187f2e976688909af44c28133 /gtk/gtkentrycompletion.c | |
parent | 36388a1fbfe0955bab5b7884a82788a1a16c2d7f (diff) | |
download | gtk+-c4e31ace4d84aa275a857dc60e9ddf6a1fb41339.tar.gz |
Allow completion popups to be wider than the entry. (#131916, Ross Burton)
2005-04-04 Matthias Clasen <mclasen@redhat.com>
Allow completion popups to be wider than the entry. (#131916,
Ross Burton)
* gtk/gtkentrycompletion.[hc]: Add a boolean popup-set-width property.
* gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup):
Don't force the popup to have the same width as the entry if
popup-set-width is FALSE.
* gtk/gtk.symbols: Add new functions.
Diffstat (limited to 'gtk/gtkentrycompletion.c')
-rw-r--r-- | gtk/gtkentrycompletion.c | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index dd06d71747..403cf35c4d 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -58,7 +58,8 @@ enum PROP_MINIMUM_KEY_LENGTH, PROP_TEXT_COLUMN, PROP_INLINE_COMPLETION, - PROP_POPUP_COMPLETION + PROP_POPUP_COMPLETION, + PROP_POPUP_SET_WIDTH }; #define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate)) @@ -334,6 +335,22 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass) TRUE, GTK_PARAM_READWRITE)); + /** + * GtkEntryCompletion:popup-set-width: + * + * Determines whether the completions popup window will be + * resized to the width of the entry. + * + * Since: 2.8 + */ + g_object_class_install_property (object_class, + PROP_POPUP_SET_WIDTH, + g_param_spec_boolean ("popup-set-width", + P_("Popup set width"), + P_("If TRUE, the popup window will have the same size as the entry"), + TRUE, + GTK_PARAM_READWRITE)); + g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate)); } @@ -365,6 +382,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion) priv->has_completion = FALSE; priv->inline_completion = FALSE; priv->popup_completion = TRUE; + priv->popup_set_width = TRUE; /* completions */ priv->filter_model = NULL; @@ -494,6 +512,10 @@ gtk_entry_completion_set_property (GObject *object, priv->popup_completion = g_value_get_boolean (value); break; + case PROP_POPUP_SET_WIDTH: + priv->popup_set_width = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -531,6 +553,10 @@ gtk_entry_completion_get_property (GObject *object, g_value_set_boolean (value, gtk_entry_completion_get_popup_completion (completion)); break; + case PROP_POPUP_SET_WIDTH: + g_value_set_boolean (value, gtk_entry_completion_get_popup_set_width (completion)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1293,7 +1319,12 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) GTK_WIDGET (completion->priv->entry)->window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border; + if (completion->priv->popup_set_width) + width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border; + else + width = -1; + + gtk_tree_view_columns_autosize (completion->priv->tree_view); gtk_widget_set_size_request (completion->priv->tree_view, width, items * height); /* default on no match */ @@ -1610,5 +1641,52 @@ gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion) return completion->priv->popup_completion; } +/** + * gtk_entry_completion_set_popup_set_width: + * @completion: a #GtkEntryCompletion + * @popup_set_width: %TRUE to make the width of the popup the same as the entry + * + * Sets whether the completion popup window will be resized to be the same + * width as the entry. + * + * Since: 2.8 + */ +void +gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, + gboolean popup_set_width) +{ + g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion)); + + popup_set_width = popup_set_width != FALSE; + + if (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"); + } +} + +/** + * gtk_entry_completion_get_popup_set_width: + * @completion: a #GtkEntryCompletion + * + * Returns whether the completion popup window will be resized to the + * width of the entry. + * + * Return value: %TRUE if the popup window will be resized to the width of + * the entry + * + * Since: 2.8 + **/ +gboolean +gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion) +{ + g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE); + + return completion->priv->popup_set_width; +} + + #define __GTK_ENTRY_COMPLETION_C__ #include "gtkaliasdef.c" |