Re: [Anjuta-list] Lookup and Textview problem
- From: Johannes Schmid <johannes schmid gmx de>
- To: Michele Bendazzoli <mickymouse mickymouse it>
- Cc: Anjuta-list <anjuta-list lists sourceforge net>
- Subject: Re: [Anjuta-list] Lookup and Textview problem
- Date: Thu Mar 9 05:08:09 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi!
First of all this list is not for general gtk questions, consider to ask
on the gtk-list and read the docs.
Anyway, using the glade generated callbacks.c, etc. files is deprecated.
You should use the libglade project type and work with libglade.
I cannot tell exactly what the problem with your code is but the gtk &
gnome documentation should give you some hints.
Regards,
Johannes
Michele Bendazzoli wrote:
> Before i can go deep into my project I have to resolve some basic
> problems: the first was grasp how to to use of the glib library in
> Anjuta. Thank to Johannes Schmid I'm able to resolve it.
> Now i would like to open a source file and display in a GtkTextView widget.
> To achieve this goal I open glade, set an open file menu item, a
> GtkTextView widget and a GtkFileChooser widget.
> I am able also to modify the automaticaly generated method named
> on_open1_activate in callbacks.c to display the file chooser.
>
> Here is the code.
>
> void
> on_open1_activate (GtkMenuItem *menuitem,
> gpointer user_data)
> {
> GtkWidget *file_selector;
> file_selector = create_filechooseropendialog();
> if (gtk_dialog_run (GTK_DIALOG (file_selector)) == GTK_RESPONSE_ACCEPT)
> {
> char *filename;
> filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
> (file_selector));
> open_file (menuitem,filename,user_data);
> g_free (filename);
> }
> gtk_widget_destroy (file_selector);
> }
>
>
> Now what I'm not able to do is to associate the text in the selected
> filename to the GtkTextView widget (named TextView1).
> To simplify the goal a write an open_file method in callbacks.c that
> simply try to insert some text in the widget.
> I see that in support.c there is a LookUp method to get a particulay
> widget, and the i try to write the method so:
>
> void open_file (GtkMenuItem *menuitem,
> char *filename,
> gpointer user_data)
> {
> GtkWidget *main_window, *textview;
> GtkTextBuffer *buffer;
> main_window = lookup_widget (GTK_WIDGET (menuitem), "window1");
> textview = lookup_widget (main_window, "textview1");
> buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
> gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
> }
>
> It compile fine, but when I open a file obtained by clicking the open
> file menu item and then selecting it from the dialog, the TextView
> widget remain the same.
>
> Any tip?
>
> Thank you in advance for any advice.
>
> ciao, Michele
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Anjuta-list mailing list
> Anjuta-list lists sourceforge net
> https://lists.sourceforge.net/lists/listinfo/anjuta-list
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEECiE7Dsf+G5b/WsRAlQOAKDo3TfofTyjZS6nnv2vWWUq+BTDBwCffMpr
nrWfCOBD48CPa6NGgztst7I=
=bfFA
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]