Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6850867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:10:38+00:00 2026-05-27T01:10:38+00:00

First things first, I hope you’re doing great. Now, I’m doing a game with

  • 0

First things first, I hope you’re doing great. Now, I’m doing a game with GTK in C, I’m trying to resize the Box where the board is and I’m not sure of if what I should be resizing is the box it is in or the table of the buttons itself.

I want the resize it so its user-friendly, keep in mind I’m a noob with GTK.

#include<gtk/gtk.h>
#include<stdio.h>
#include<stdlib.h>

void boton_click (GtkWidget * widget, gpointer info);
void salida (Gtkdget * widget, gpointer info);
gboolean cierra_ventana (GtkWidget * widget, GdkEvent * event, gpointer info);

int
main (int argc, char *argv[])
{
    GtkWidget *ventana, *cajavertjugador1, *namejugador1, *imageplayer1,
    *framejugador1, *labeljugador1, *cajavertjugador2, *namejugador2,
    *imageplayer2, *framejugador2, *labeljugador2, *cajaH, *cajaboton,
    *separador, *separadorvjug1, *separadorvjug2, *cajatablero, *boton,
    *botoncancel, *tabla, *tablero[20][20];
    int i, j;
    gchar *arch1 = "troll.jpg";
    gchar *arch2 = "challenge.jpg";

    //***********************************1.-Initialize Enviroment
    gtk_init (&argc, &argv);

    //***************************************2.-Create Widgets and attributes
    imageplayer1 = gtk_image_new_from_file (arch1);
    imageplayer2 = gtk_image_new_from_file (arch2);
    tabla = gtk_table_new (20, 20, TRUE);
    ventana = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (ventana), "Pente");
    cajaH = gtk_hbox_new (FALSE, 25);
    cajavertjugador1 = gtk_vbox_new (FALSE, 0);
    cajatablero = gtk_hbox_new (TRUE, 500);
    cajavertjugador2 = gtk_vbox_new (TRUE, 5);
    cajaboton = gtk_hbox_new (TRUE, 5);
    boton = gtk_button_new_with_label ("Ok");
    botoncancel = gtk_button_new_with_label ("Cancel");
    separador = gtk_hseparator_new ();
    separadorvjug1 = gtk_vseparator_new ();
    separadorvjug2 = gtk_vseparator_new ();
    framejugador1 = gtk_frame_new ("Fichas Comidas");
    namejugador1 = gtk_label_new ("Variable Nombre Jugador1");
    labeljugador1 = gtk_label_new ("Aqui Imagenes de Las Fichas Comidas\n");
    gtk_label_set_justify (GTK_LABEL (labeljugador1), GTK_JUSTIFY_LEFT);
    framejugador2 = gtk_frame_new ("Fichas Comidas");
    namejugador2 = gtk_label_new ("Variable Nombre Jugador2");
    labeljugador2 = gtk_label_new ("Aqui Imagenes de Las Fichas Comidas\n");
    gtk_label_set_justify (GTK_LABEL (labeljugador1), GTK_JUSTIFY_LEFT);

    for (i = 0; i < 20; i++)
    {
        for (j = 0; j < 20; j++)
        {
            tablero[i][j] = gtk_button_new ();
        }
    }

    //**********************************3.Register Function Calls
    g_signal_connect (G_OBJECT (ventana), "delete_event",
            G_CALLBACK (cierra_ventana), NULL);
    g_signal_connect (G_OBJECT (ventana), "destroy", G_CALLBACK (salida), NULL);

    //***********************************4.-Hierarchy of Elements

    gtk_container_add (GTK_CONTAINER (ventana), cajaH);
    gtk_container_add (GTK_CONTAINER (cajaH), cajavertjugador1);
    gtk_container_add (GTK_CONTAINER (cajaH), separadorvjug1);
    gtk_container_add (GTK_CONTAINER (cajavertjugador1), namejugador1);
    gtk_container_add (GTK_CONTAINER (cajavertjugador1), imageplayer1);
    gtk_container_add (GTK_CONTAINER (framejugador1), labeljugador1);
    gtk_container_add (GTK_CONTAINER (cajavertjugador1), framejugador1);
    gtk_container_add (GTK_CONTAINER (cajatablero), tabla);
    gtk_container_set_focus_vadjustment (GTK_CONTAINER (cajatablero),
                       GTK_ADJUSTMENT (50));
    gtk_container_add (GTK_CONTAINER (cajaH), cajatablero);
    gtk_container_add (GTK_CONTAINER (cajaH), separadorvjug2);
    gtk_container_add (GTK_CONTAINER (cajavertjugador2), namejugador2);
    gtk_container_add (GTK_CONTAINER (cajavertjugador2), imageplayer2);
    gtk_container_add (GTK_CONTAINER (framejugador2), labeljugador2);
    gtk_container_add (GTK_CONTAINER (cajavertjugador2), framejugador2);
    gtk_container_add (GTK_CONTAINER (cajaH), cajavertjugador2);


    for (i = 0; i < 20; i++)
    {
        for (j = 0; j < 20; j++)
        {
            gtk_table_attach_defaults (GTK_TABLE (tabla), tablero[i][j], i,
                         i + 1, j, j + 1);
        }
    }
    //****************************5.Show the Widddgggeetss
    gtk_widget_show_all (ventana);

    //****************************6.Process Signals and Events
    gtk_main ();
    return 1;

}//main

gboolean
cierra_ventana (GtkWidget * widget, GdkEvent * event, gpointer info)
{
  return FALSE;
}

void
salida (GtkWidget * widget, gpointer info)
{
  gtk_main_quit ();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:10:39+00:00Added an answer on May 27, 2026 at 1:10 am

    It is not very clear what you are trying to say, if you mean that the table which you have added buttons to does not appear to be expanded to fit between the separators then it is due to the fact that when creating cajaH you have specified spacing as 25 pixel. Try changing it to lesser different value or 0 and see if you get what you wanted. As you are using default packing for table & using gtk_container_add packing will expand & fit.
    Also as you are using GtkHBox & GtkVBox gtk_box_pack_start & gtk_box_pack_end will give you a greater control on layout then using gtk_container_add. See this question for information.
    When using gtk_container_set_focus_vadjustment you need to create a new GtkAdjustment using gtk_adjustment_new. Typecasting 50 as GTK_ADJUSTMENT is not the way to do it!
    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on my first 'real' F# assembly, and trying to do things right.
I'm here now because of two things. First: I need to modify a jQuery
I have two requirements, and im not sure is those things possible in AS3.
This is my first post, so hope I haven't missed anything important. I'm doing
One of the first things I learned in C++ was that #include <iostream> int
One of the first things I like to do when I make a site
One if the first things I learned when I started with C# was the
I've installed PowerShell recently and one of the first things I started looking for
Everything is an object was one of the first things I learned about Ruby,
I know the bits just came out today, but one of the first things

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.