From fc98d1d1a42292a6603062352b5705a49c61ffa8 Mon Sep 17 00:00:00 2001 From: paulc Date: Wed, 1 Feb 2006 20:08:03 +0000 Subject: [PATCH] Tables inserted in a scroll window behave properly. Tabs can have icons and text just like buttons. git-svn-id: http://yate.null.ro/svn/yate/trunk@676 acf43c95-373e-0410-b603-e72c3f656dc1 --- contrib/gtk2/gtk2client.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/contrib/gtk2/gtk2client.cpp b/contrib/gtk2/gtk2client.cpp index 56c1ce2e..c9fbe462 100644 --- a/contrib/gtk2/gtk2client.cpp +++ b/contrib/gtk2/gtk2client.cpp @@ -396,10 +396,10 @@ static GtkWidget* gtkCheckButtonNew(const gchar* text) return gtk_check_button_new_with_label(text); } -static GtkWidget* populateButton(GtkWidget* btn, const gchar* str) +static GtkWidget* populateIcon(const gchar* str) { - if (null(str) || !btn) - return btn; + if (null(str)) + return 0; String text(str); String icon; Regexp r("^\"\\([^\"]*\\)\" *\\(.*\\)$"); @@ -411,12 +411,23 @@ static GtkWidget* populateButton(GtkWidget* btn, const gchar* str) GtkWidget* box = gtk_vbox_new(FALSE,1); gtk_container_add(GTK_CONTAINER(box),gtk_image_new_from_file(icon.c_str())); gtk_container_add(GTK_CONTAINER(box),gtk_label_new(text.c_str())); - gtk_container_add(GTK_CONTAINER(btn),box); + gtk_widget_show_all(box); + return box; } else if (icon) - gtk_container_add(GTK_CONTAINER(btn),gtk_image_new_from_file(icon.c_str())); + return gtk_image_new_from_file(icon.c_str()); else if (text) - gtk_container_add(GTK_CONTAINER(btn),gtk_label_new(text.c_str())); + return gtk_label_new(text.c_str()); + return 0; +} + +static GtkWidget* populateButton(GtkWidget* btn, const gchar* str) +{ + if (null(str) || !btn) + return btn; + GtkWidget* icon = populateIcon(str); + if (icon) + gtk_container_add(GTK_CONTAINER(btn),icon); return btn; } @@ -834,12 +845,12 @@ void GTKWindow::insert(GtkWidget* wid, int x, int y, int w, int h) gtk_layout_put(GTK_LAYOUT(filler()),wid,x,y); else if (GTK_IS_BOX(filler())) gtk_box_pack_start(GTK_BOX(filler()),wid,(x > 0),(x > 1),y); - else if (GTK_IS_SCROLLED_WINDOW(filler())) + else if (GTK_IS_SCROLLED_WINDOW(filler()) && !GTK_IS_TREE_VIEW(wid)) gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(filler()),wid); else gtk_container_add(GTK_CONTAINER(filler()),wid); if (GTK_IS_NOTEBOOK(filler()) && m_tabName) - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(m_filler),wid,m_tabName.c_str()); + gtk_notebook_set_tab_label(GTK_NOTEBOOK(m_filler),wid,populateIcon(m_tabName)); m_tabName.clear(); }