You are not logged in.

#1 2006-12-17 18:45:50

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

GTK: Setting window size?

I'm programming a simple C app, and I am trying to get the function gtk_window_set_size() to work, this is what I have:

gtk_window_set_size((GtkWindow*)main_win, 240,250);

When i compile I get this error:

undefined reference to `gtk_window_set_size'
collect2: ld returned 1 exit status
make: *** Error 1

Is gtk_window_set_size() the right command to be using?

Offline

#2 2006-12-17 22:35:41

High|ander
Member
From: Skövde, Sweden
Registered: 2005-10-28
Posts: 188
Website

Re: GTK: Setting window size?

gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

This worked for me


When death smiles at you, all you can do is smile back!
Blog

Offline

#3 2006-12-18 05:03:52

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: GTK: Setting window size?

This only sets the default size within the init_main code portion of your GTK window, it doesn't allow you to change the size this way by a button or menu item, ect.

Offline

#4 2006-12-18 06:28:18

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: GTK: Setting window size?

twiistedkaos wrote:

When i compile I get this error:

undefined reference to `gtk_window_set_size'
collect2: ld returned 1 exit status
make: *** Error 1

How do you compile it? Post the command line.  It looks like you forgot to link to the gtk library.

Offline

#5 2006-12-18 07:05:53

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: GTK: Setting window size?

Snowman wrote:
twiistedkaos wrote:

When i compile I get this error:

undefined reference to `gtk_window_set_size'
collect2: ld returned 1 exit status
make: *** Error 1

How do you compile it? Post the command line.  It looks like you forgot to link to the gtk library.

With a makefile, but it is linking the gtk2.0 libs

VERSION = 0.1
CC = gcc
INSTALL=install
STRIP=strip
CFLAGS = -DVERSION="$(VERSION)" `pkg-config --cflags gtk+-2.0` `pkg-config --cflags xmms2-client`
LDFLAGS = `pkg-config --libs gtk+-2.0` `pkg-config --libs xmms2-client` `pkg-config --libs xmms2-client-glib`
OBJS = sXMMS2.o
BIN = sXMMS2

all: $(BIN)

$(BIN): $(OBJS)
    $(CC) $(LDFLAGS) -o $(BIN) $(OBJS)

file.o: file.c
    $(CC) -c $(CFLAGS) -o sXMMS2.o sXMMS2.c

Offline

#6 2006-12-22 07:57:16

bboozzoo
Member
From: Poland
Registered: 2006-08-01
Posts: 125

Re: GTK: Setting window size?

use gtk_window_resize

Offline

#7 2006-12-22 09:54:22

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: GTK: Setting window size?

I love this factoid from the bot in ##C++:

 undefined reference is a linker error. It's not a compile error. Adding #includes doesn't help. You did not define the thing in the error message, or you forgot to link the file that defines it, or you forgot to link to the library that defines it. Check which one. (Note that on some compilers it's called unresolved external symbol or similar)  

There is your error.

Offline

#8 2006-12-24 00:36:53

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: GTK: Setting window size?

phrakture wrote:

I love this factoid from the bot in ##C++:

 undefined reference is a linker error. It's not a compile error. Adding #includes doesn't help. You did not define the thing in the error message, or you forgot to link the file that defines it, or you forgot to link to the library that defines it. Check which one. (Note that on some compilers it's called unresolved external symbol or similar)  

There is your error.

Thanks, but gtk_window_resize works fine smile

Offline

#9 2006-12-24 17:48:35

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: GTK: Setting window size?

Another question, for selecting and deselecting items in a treeview, I am using this to select a current song in my playlist:

    path = gtk_tree_path_new_from_indices( playlist_pos, -1 );
    sel = gtk_tree_view_get_selection( (GtkTreeView*)list_view );
    gtk_tree_selection_select_path( sel, path );
    gtk_tree_path_free( path );

Problem is, it doesn't deselect the last selection in the playlist, so everytime  song is changed it select the next song leaving the provious selected also.

Offline

#10 2006-12-28 06:30:15

e_tank
Member
Registered: 2006-12-21
Posts: 80

Re: GTK: Setting window size?

seems to me like you'll either want to set the selection mode to GTK_SELECTION_SINGLE, or unselect all the previously selected items before you make that selection in your program

Offline

#11 2006-12-28 23:41:19

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: GTK: Setting window size?

e_tank wrote:

seems to me like you'll either want to set the selection mode to GTK_SELECTION_SINGLE, or unselect all the previously selected items before you make that selection in your program

Thanks, that worked smile

Offline

Board footer

Powered by FluxBB