[Solucionado] Problema con GtkText [Linux][GTK+]

Iniciado por DaniekL, 23 Febrero 2013, 11:14 AM

0 Miembros y 3 Visitantes están viendo este tema.

DaniekL

Buenas;

Estoy programando una aplicación para tomar notas, la idea es que conky ejecute la parte de leer notas y yo la parte de crear una nueva. Como es obvio para tomar la nota necesito una textbox, bien, como en el ordenador que voy a usar este programa usa OpenBox he decidido hacerla en Gtk+ (la versión 2.0 más concretamente).

El problema viene cuando compilo el código. Me da el siguiente error:

$ gcc -o notes notes.c `pkg-config --cflags gtk+-2.0 --libs`
notes.c: En la función 'main':
notes.c:22:3: aviso: declaración implícita incompatible de la función interna 'exit' [activado por defecto]
notes.c:34:4: aviso: declaración implícita incompatible de la función interna 'exit' [activado por defecto]
notes.c: En la función 'create_window':
notes.c:88:11: aviso: la asignación crea un puntero desde un entero sin una conversión [activado por defecto]
notes.c:89:25: error: 'GtkText' no se declaró aquí (primer uso en esta función)
notes.c:89:25: nota: cada identificador sin declarar se reporta sólo una vez para cada función en el que aparece
notes.c:89:34: error: expected expression before ')' token


El fallo sobretodo es que identifique GtkText, que es un GtkWidget, como una función. Me han dicho que podría ser un fallo con los includes, pero no tengo ni idea de como arreglarlo.

Gracias de antemano.
El código: http://pastebin.com/i8t8X4L7

Stakewinner00

el único error es
error: expected expression before ')' token

Fijate bien haber que hay allí

DaniekL

No me explique bien :xD, ya edite explicandolo mejor.

0xDani

Si no posteas la parte del codigo que te da problemas no creo que haya mucho que hacer...
I keep searching for something that I never seem to find, but maybe I won't, because I left it all behind!

I code for $$$
Hago trabajos en C/C++
Contactar por PM

DaniekL

#4
Puse un link a pastebin con el código, pero bueno, posteo la función problemática igualmente.

void create_window(int argc, char **argv) {
    /**
     * Creates a GTK+ dialog for editing the note          
     */
    GtkWidget *window, *save_button, *text_box, *container;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title((GtkWindow *) window, "Notes");
    gtk_window_set_default_size((GtkWindow *) window, 300,160);
    g_signal_connect((GObject *) window, "delete-event", (GCallback) gtk_main_quit, NULL);

    save_button = gtk_button_new_with_label("Save");
    g_signal_connect((GObject *) save_button, "clicked", (GCallback) save_note, NULL /*By the way*/);

    container = gtk_vbox_new(FALSE, 1);

    text_box = gtk_text_new(NULL, NULL);
    gtk_text_set_editable((GtkText *) text_box, TRUE);

    gtk_box_pack_start((GtkBox *) container, text_box, FALSE, FALSE, 0);
    gtk_box_pack_start((GtkBox *) container, save_button, FALSE, FALSE, 0);

    gtk_container_add((GtkContainer *) window, container);

    gtk_widget_show_all(window);
    gtk_main();
}

0xDani

Perdon, no habia visto el link  :P

Prueba a cambiar esta linea:

gtk_text_set_editable((GtkText *) text_box, TRUE);

Por esta:

gtk_text_set_editable(GTK_TEXT(text_box), TRUE);

Saludos.
I keep searching for something that I never seem to find, but maybe I won't, because I left it all behind!

I code for $$$
Hago trabajos en C/C++
Contactar por PM

DaniekL

Cita de: 0xDani en 23 Febrero 2013, 19:51 PM
Prueba a cambiar esta linea:

gtk_text_set_editable((GtkText *) text_box, TRUE);

Por esta:

gtk_text_set_editable(GTK_TEXT(text_box), TRUE);

Ya probe esa solución y no me funcionó, pero gracias de todas formas  :D

naderST

Citar
Warning

GtkText is deprecated and unsupported. It is known to be buggy. To use it, you must define the symbol GTK_ENABLE_BROKEN prior to including the GTK+ header files. Use GtkTextView instead.


gcc -o hello-gtk  -DGTK_ENABLE_BROKEN hello-gtk.c `pkg-config gtk+-2.0 --cflags --libs`


Información sacada de:
http://www.linuxquestions.org/questions/programming-9/%91gtk_text%92-was-not-declared-in-this-scope-832024/

DaniekL

Funcionó cambiando el Widget a GtkTextView  :laugh:. Muchisimas gracias por la solución.  ;-) ;-) ;-)