Re: g_log_set_fatal_mask() not working for me.
- From: cecashon aol com
- To: richard rshann plus com, gtk-app-devel-list gnome org
- Subject: Re: g_log_set_fatal_mask() not working for me.
- Date: Sun, 17 Dec 2017 17:54:11 -0500
Hi Richard,
This sounds similar to the problem Dino Aljević had in "Scrolled TreeView and size allocation warnings" in
this list in September?
I can get the warning
"(treeview4:3830): Gtk-WARNING **: Allocating size to GtkWindow 0x843e188 without calling
gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?"
with the following code with GTK3.22.26 but I don't see the warning in GTK3.18.9. To get the warning expand
the treeview until the list extends past the window boundry. I looked on Bugzilla but I didn't see it listed
there. I am not great at finding things on Bugzilla so that doesn't mean it isn't there.
Do you have some test code to produce the GtkScrollbar warning you are seeing?
For the g_log_set_fatal_mask() and a runtime stop, try starting your code with
G_DEBUG=fatal-warnings
It is a warning though. Something needs to be fixed but your program should run fine.
Eric
/*
gcc -Wall treeview4.c -o treeview4 `pkg-config --cflags --libs gtk+-3.0`
Tested on Ubuntu16.04 with GTK3.18.9 and GTK3.22.26
run with
G_DEBUG=fatal-warnings GTK_THEME=Adwaita:dark ./treeview4
this theme doesn't produce any css warnings with GTK3.22.26.
*/
#include<gtk/gtk.h>
static GtkTreeStore* get_tree_store();
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
g_print("%i.%i.%i\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
g_log_set_fatal_mask("Gtk", G_LOG_LEVEL_WARNING);
GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Tree View");
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 300);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
GtkTreeStore *store=get_tree_store();
GtkWidget *tree=gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), TRUE);
g_object_unref(G_OBJECT(store));
GtkCellRenderer *renderer1=gtk_cell_renderer_text_new();
g_object_set(renderer1, "editable", TRUE, NULL);
GtkTreeViewColumn *column1 = gtk_tree_view_column_new_with_attributes("Shape Coordinates", renderer1,
"text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column1);
GtkWidget *scroll=gtk_scrolled_window_new(NULL, NULL);
gtk_container_set_border_width(GTK_CONTAINER(scroll), 5);
gtk_widget_set_vexpand(scroll, TRUE);
gtk_widget_set_hexpand(scroll, TRUE);
gtk_container_add(GTK_CONTAINER(scroll), tree);
GtkWidget *grid=gtk_grid_new();
gtk_container_set_border_width(GTK_CONTAINER(grid), 20);
gtk_grid_attach(GTK_GRID(grid), scroll, 0, 0, 1, 1);
gtk_container_add(GTK_CONTAINER(window), grid);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
static GtkTreeStore* get_tree_store()
{
gint i=0;
gint j=0;
GtkTreeStore *store=gtk_tree_store_new(1, G_TYPE_STRING);
GtkTreeIter iter1;
GtkTreeIter iter2;
gtk_tree_store_append(store, &iter1, NULL);
for(i=0;i<3;i++)
{
gchar *string1=g_strdup_printf("S%i", i);
gtk_tree_store_set(store, &iter1, 0, string1, -1);
g_free(string1);
for(j=0;j<5;j++)
{
gtk_tree_store_append(store, &iter2, &iter1);
gchar *string2=g_strdup_printf("C%i", j);
gtk_tree_store_set(store, &iter2, 0, string2, -1);
g_free(string2);
}
gtk_tree_store_append(store, &iter1, NULL);
}
return store;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]