LinuxQuestions.org
Register a domain and help support LQ
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 01-31-2006, 08:38 AM   #1
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Rep: Reputation: 15
How to parse log files into text view using GLADE


hi to all,

i want to display the contents of log files (e.g. /var/log/messages) in the textview of the GUI, but i don't know how to do that. i'm using GLADE for the gui.

please help me...
 
Old 01-31-2006, 01:07 PM   #2
con
Member
 
Registered: Jul 2005
Location: Finland
Distribution: Slackware
Posts: 213

Rep: Reputation: 30
Code:
/* This line gets a pointer to the text widget */
 GtkWidget * textview = lookup_widget(GTK_WIDGET(button), "textview1");

/* ...and thils line prints the the text into the text box */
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)), _(text_2_be_printed), -1);
working on something similar myself. Hope this helps
 
Old 01-31-2006, 11:52 PM   #3
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Hello,
Thanx for the info..

*****gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)), _(text_2_be_printed), -1);******

i just want to know if it is possible that i could have the text to be printed from a certain folder. (e.g from var/log/messages) i want to display the messages in the textview.
 
Old 02-01-2006, 01:22 AM   #4
con
Member
 
Registered: Jul 2005
Location: Finland
Distribution: Slackware
Posts: 213

Rep: Reputation: 30
First you gotta read the file into a variable, there is a great function for this in glib called g_file_get_contents() then do the code I posted above.
http://developer.gnome.org/doc/API/2...e-get-contents
 
Old 02-01-2006, 07:52 AM   #5
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Original Poster
Rep: Reputation: 15
hello,

I've read the API with the link that u gave. I just want to ask if there is anything that i should add in my main.c inorder to use this function.
I'm also confused on where to put this function, is it in callbacks.c, interface.c or main.c.

Thank you very much for ur help, i just badly need it.
 
Old 02-01-2006, 03:21 PM   #6
con
Member
 
Registered: Jul 2005
Location: Finland
Distribution: Slackware
Posts: 213

Rep: Reputation: 30
That I think depends on how you want the program to work i.e if you want it to display the text when the user pushes a button. But most likely it will go into a function in callbacks.c.
 
Old 02-02-2006, 10:46 AM   #7
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Original Poster
Rep: Reputation: 15
hello,

thanks again, i can already view the contents of the file into the textview provided that the log file or any file will be place in the src folder of my project folder.
i would have wanted to display a log file from any directory (e.g. from /var/log/messages.log) without copying this to my src file. would that be possible?
 
Old 02-02-2006, 10:55 AM   #8
con
Member
 
Registered: Jul 2005
Location: Finland
Distribution: Slackware
Posts: 213

Rep: Reputation: 30
Quote:
thanks again,
You're welcome
Quote:
would have wanted to display a log file from any directory
just pass the full path to the file, to the function that reads the file...and do some reading on file I/O
 
Old 02-07-2006, 09:13 PM   #9
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Thanks con,

I can already display the contents of any file when i inserted g_file_get_contents()in my interface.c
But when i tried to have it in my main.c or callbacks.c, its compilation is successful but when i run the program, it would display an error like this:

The Application "myFilename" has quit unexpectedly.

Hope u can help me with this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
view text files in konsole wearerowan Linux - Software 5 08-29-2005 03:29 AM
parse log file hourly onewave Programming 2 03-28-2005 02:52 PM
need C code to diplay text in Glade skie_knite007 Programming 1 02-13-2005 07:03 AM
bash script help to parse out text slack guy Linux - Newbie 3 12-30-2004 09:42 AM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 11:55 PM


All times are GMT -5. The time now is 04:52 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration