LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2013, 07:00 PM   #1
nuclearphoenix
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Rep: Reputation: Disabled
GTK+2.0 Table Quirk


I am trying to make a perfect tic-tac-toe game. This happens while I run the program.
Code:
(process:1218): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed

(a.out:1218): GLib-GObject-WARNING **: invalid cast from `GtkButton' to `GtkTable'

(a.out:1218): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `GTK_IS_TABLE (table)' failed
Here is the graphical part of my code
Code:
 void display_stuff ( int argc, char *argv[])
{
  gtk_init (&argc, &argv);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  GtkWidget *table;
  GtkWidget *xlabel, *ylabel;
  GtkWidget *button[8];

  table = gtk_table_new ( 3, 3, TRUE);

  gint x;

  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 600, 600);
  gtk_window_set_title (GTK_WINDOW(window), "Tic-Tac-Toe");
  gtk_container_set_border_width(GTK_CONTAINER(window), 5);

  gtk_table_set_row_spacings(GTK_TABLE(table), 10);
  gtk_table_set_col_spacings(GTK_TABLE(table), 10);

  for (x=0; x<=8; x++) {
   button[x] = gtk_button_new();
   g_object_set_data (G_OBJECT (button[x]), "current_pos", (gpointer) x);
   gtk_button_set_relief (GTK_BUTTON (button[x]), GTK_RELIEF_HALF);
  }

  gtk_table_attach_defaults (GTK_TABLE(table), button[(gint)0], 0, 1, 0, 1 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[(gint)1], 1, 2, 0, 1 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[(gint)2], 2, 3, 0, 1 );

  gtk_table_attach_defaults (GTK_TABLE(table), button[3], 0, 1, 1, 2 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[4], 1, 2, 1, 2 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[5], 2, 3, 1, 2 );

  gtk_table_attach_defaults (GTK_TABLE(table), button[6], 0, 1, 2, 3 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[7], 1, 2, 2, 3 );
  gtk_table_attach_defaults (GTK_TABLE(table), button[8], 2, 3, 2, 3 );

  gtk_container_add(GTK_CONTAINER(window), table);

  choose_first ();

  for (x=0; x <= 8; x++)
   g_signal_connect(G_OBJECT(button[x]), "clicked", G_CALLBACK(on_button_clicked), (gpointer)x);

  g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), G_OBJECT(window));

  gtk_widget_show_all(window);

}
When I run GDB on it the warnings come up at gtk_table_attach_defaults.

I am using Arch Linux.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
process flex+bison output in gtk hash table and list store RudraB Programming 1 03-30-2013 11:55 PM
how to create a table using gtk? gktandc Programming 4 04-23-2009 06:28 AM
How do you control size and placement of widgets in table under gtk davimint Programming 1 09-10-2008 12:48 PM
Linux quirk? htnakirs Linux - Newbie 1 08-02-2008 03:48 AM
gtk: table manipulation? jpollack Programming 2 01-27-2005 09:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration