Can someone help with this? Linux GTK / Ncurses

C

ChuckB

Ok, I'm trying to create a GTK+ application that scrolls Hs across the
screen until you press q or Q. I've got it working in console wise
using ncurses. What I'm trying to do now is make a full screen GTK+
gui based way of it to scroll the Hs until the keypress. I tried
manipulating them together, but the console loads up first, and when
you hit q, it'll fill the data into the GTK+ text_view, but it's quit
at that time.

If anyone could shed some light and help I'd apprietiate it.

-Chuck

** CODE FOLLOWS **

#include <gtk/gtk.h>
#include <ncurses.h>

static gboolean delete_event( GtkWidget *widget,
GdkEvent *event,
gpointer data )
{
g_print ("delete event occurred\n");
return TRUE;

}

/* Another callback */
static void destroy( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();

}

int main( int argc,
char *argv[] )
{
GtkWidget *window;
GtkWidget *textview;
GtkTextBuffer *buffer;

gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_fullscreen(GTK_WINDOW(window));

g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (delete_event), NULL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);

textview = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));

gtk_container_add (GTK_CONTAINER (window), textview);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_CHAR);
gtk_widget_show (textview);
gtk_widget_show (window);
/* int timer = 0;
while (timer != 10000)
{
gtk_text_buffer_insert_at_cursor(buffer, "H", -1);
timer = timer + 1;
}*/

//
*******************************************************************************************************
int ch = 0;
int backg = 0;
int foreg = 7;
initscr();
start_color();
init_pair(1, 2, 3); // 0-7
cbreak();
noecho();
nodelay(stdscr, TRUE);
do
{
ch = getch();
init_pair(1, foreg, backg);
attron(COLOR_PAIR(1));
gtk_text_buffer_insert_at_cursor(buffer, "H", -1); //
wprintw(stdscr,
"H");
switch( ch )
{
case 'Q' :
case 'q' : gtk_text_buffer_insert_at_cursor(buffer,
"QUITTING",
-1); //wprintw(stdscr, "\nQuitting...");
break;
case 'B' :
case 'b' : if (backg == 7) backg = 0;
else backg = backg + 1;
break;
case 'F' :
case 'f' : if (foreg == 7) foreg = 0;
else foreg = foreg + 1;
break;
default : break;
}
attroff(COLOR_PAIR(1));
refresh();

} while ((ch != 113) && (ch != 81));
gtk_main ();
refresh();
getch();
endwin();
//
*********************************************************************************************************

return 0;

}
 
J

Jack Klein

Ok, I'm trying to create a GTK+ application that scrolls Hs across the
screen until you press q or Q. I've got it working in console wise
using ncurses. What I'm trying to do now is make a full screen GTK+
gui based way of it to scroll the Hs until the keypress. I tried
manipulating them together, but the console loads up first, and when
you hit q, it'll fill the data into the GTK+ text_view, but it's quit
at that time.

If anyone could shed some light and help I'd apprietiate it.

-Chuck

** CODE FOLLOWS **

#include <gtk/gtk.h>
#include <ncurses.h>

[snip]

I'd suggest you try new:comp.os.linux.development.apps.

As far as the C language and this group are concerned, gtk and ncurses
are both just non-standard 3rd party libraries, and off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top