diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-11-11 21:41:05 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-11-11 22:03:56 +0800 |
commit | 379f636d605a99f04fbd29481ff755e783f34707 (patch) | |
tree | df9c758efcfb163647b25b4d5322d24b3bdb6634 /libempathy-gtk/empathy-input-text-view.c | |
parent | 1c7e66a2a609bf5e956c6f76bf7db7e585860731 (diff) | |
download | gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar.gz gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar.bz2 gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar.lz gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar.xz gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.tar.zst gsoc2013-empathy-379f636d605a99f04fbd29481ff755e783f34707.zip |
move size-requst handling in input-text-view
Diffstat (limited to 'libempathy-gtk/empathy-input-text-view.c')
-rw-r--r-- | libempathy-gtk/empathy-input-text-view.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-input-text-view.c b/libempathy-gtk/empathy-input-text-view.c index 73ef32a45..4b9a61150 100644 --- a/libempathy-gtk/empathy-input-text-view.c +++ b/libempathy-gtk/empathy-input-text-view.c @@ -30,14 +30,61 @@ G_DEFINE_TYPE (EmpathyInputTextView, empathy_input_text_view, GTK_TYPE_TEXT_VIEW); +#define MAX_INPUT_HEIGHT 150 + struct _EmpathyInputTextViewPrivate { - gpointer unused; + gboolean has_input_vscroll; }; +static gboolean +chat_input_set_size_request_idle (gpointer sw) +{ + gtk_widget_set_size_request (sw, -1, MAX_INPUT_HEIGHT); + + return FALSE; +} + +static void +empathy_input_text_view_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + EmpathyInputTextView *self = (EmpathyInputTextView *) widget; + GtkWidget *sw; + + sw = gtk_widget_get_parent (widget); + if (requisition->height >= MAX_INPUT_HEIGHT && !self->priv->has_input_vscroll) + { + /* Display scroll bar */ + g_idle_add (chat_input_set_size_request_idle, sw); + + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_NEVER, + GTK_POLICY_ALWAYS); + + self->priv->has_input_vscroll = TRUE; + } + + if (requisition->height < MAX_INPUT_HEIGHT && self->priv->has_input_vscroll) + { + /* Hide scroll bar */ + gtk_widget_set_size_request (sw, -1, -1); + + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_NEVER, + GTK_POLICY_NEVER); + + self->priv->has_input_vscroll = FALSE; + } +} + static void empathy_input_text_view_class_init (EmpathyInputTextViewClass *cls) { + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (cls); + + widget_class->size_request = empathy_input_text_view_size_request; + g_type_class_add_private (cls, sizeof (EmpathyInputTextViewPrivate)); } |