By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,682 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,682 IT Pros & Developers. It's quick & easy.

Can someone help with this? Linux GTK / Ncurses

P: n/a
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;

}
Dec 14 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 14 Dec 2007 08:21:42 -0800 (PST), ChuckB
<CE*********@gmail.comwrote in comp.lang.c:
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
Dec 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.