Problems with GIOChannel

2003-02-23 Thread Michael Tindal
I am writing a MUD client under GTK+.  Ive got everything working so far
except for one problem that is holding me back.  Ive set up the
GIOChannel to watch for G_IO_IN, and the callback is there to read it,
and it all works great, until I write data to the channel using
g_io_channel_write_chars.  I know the MUD (what it is connecting to) is
sending more information, because I am also writing the MUD Im
connecting to, so any ideas on what may be causing this?  Here is the
relevant code:

void create_connection (gchar *charname, gchar *mudname, gchar *host,
gint port)
{
GtkLabel * conn_label;
GtkTextView * view;
GtkTextBuffer * buffer;
GtkEntry * entry;
GtkVBox * box;
struct sockaddr_in sock_in;
int sock;
static GIOChannel * gio;
static GList * list;
GError * err;
PangoFontDescription * pfd;
GtkScrolledWindow * gsw;

err = NULL;

list = NULL;

sock = socket (PF_INET, SOCK_STREAM, 0);

sock_in.sin_family = AF_INET;
sock_in.sin_addr = *((struct in_addr*)gethostbyname
(host)-h_addr_list[0]);
sock_in.sin_port = htons(port);

if (connect (sock, (struct sockaddr *) sock_in, sizeof(sock_in))  0)
{
perror (MudGnome: connect);
gtk_main_quit ();
exit (-1);
}

gsw = gtk_scrolled_window_new (NULL, NULL);

gtk_scrolled_window_set_policy (gsw, GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
buffer = gtk_text_buffer_new (NULL);

pfd = pango_font_description_new ();
pango_font_description_set_family (pfd, fixed);
pango_font_description_set_size (pfd, 10);

view = gtk_text_view_new_with_buffer (buffer);

gtk_widget_modify_font (GTK_WIDGET(view), pfd);

gtk_container_add (GTK_CONTAINER (gsw), view);
box = gtk_vbox_new (NULL, 5);

entry = gtk_entry_new ();

conn_label = gtk_label_new (g_strconcat (charname,  (, mudname, ),
NULL));

gtk_box_pack_end (box, entry, FALSE, FALSE, 0);

gtk_box_pack_end (box, gsw, TRUE, TRUE, 0);

gtk_widget_show (GTK_WIDGET (conn_label));
gtk_widget_show (GTK_WIDGET (gsw));
gtk_widget_show (GTK_WIDGET (view));
gtk_widget_show (GTK_WIDGET (entry));
gtk_widget_show (GTK_WIDGET (box));
gtk_notebook_append_page (mga-mud_notebook, box, conn_label);

gtk_notebook_set_current_page (mga-mud_notebook, -1);
gio = g_io_channel_unix_new (sock);

g_io_channel_set_buffered (gio, FALSE);
g_io_channel_set_flags (gio, G_IO_FLAG_NONBLOCK, err);
g_io_channel_set_encoding (gio, NULL, err);

g_io_add_watch (gio, G_IO_IN, conn_read, buffer);

list = g_list_append (list, buffer);
list = g_list_append (list, gio);

g_signal_connect (G_OBJECT (entry), key-release-event, G_CALLBACK
(conn_key_release), gio);
}

gbooleanconn_read (GIOChannel *source,
   GIOCondition condition,
   gpointer data)
{
GtkTextBuffer * buffer;
gchar * read;
gsize size;
int i = 0;
GError * err;
gchar ** buf;
GtkTextIter iter;

err = NULL;

g_print (Got G_IO_IN...\n);
buffer = (GtkTextBuffer*)data;

read = g_malloc0 (4096);
g_io_channel_read_chars (source, read, 4096, size, err);

buf = g_strsplit (read, \r, 0);
read = g_strjoinv (NULL, buf);

g_print (:%s\n, read);
if (read != NULL)
{
gtk_text_buffer_get_end_iter (buffer, iter);

gtk_text_buffer_insert (buffer, iter, read, strlen(read));
}

g_strfreev (buf);
g_free (read);

return TRUE;
}

gbooleanconn_key_release (GtkWidget *widget,
 GdkEventKey *event,
 gpointer user_data)
{
GtkEntry * entry;
GtkTextBuffer * buffer;
GtkTextView * view;
gsize size;
GtkTextIter iter;
gchar * txt;
gint page;
GtkScrolledWindow * gsw;
GIOChannel * gio;
GError * ge;
GList * list;

ge = NULL;

if (event-keyval == GDK_Return)
{
entry = (GtkEntry*)widget;

page = gtk_notebook_get_current_page (mga-mud_notebook);

g_print ([%d]\n, page);

list = gtk_container_get_children(gtk_notebook_get_nth_page
(mga-mud_notebook, page));

gsw = g_list_nth_data (list, 0);

view 

gtk2.0 font problem

2003-02-23 Thread Ian Zimmerman

Hi, I searched the archive suspecting this could be a FAQ, but without
luck.

I just installed my first gtk2.0 program and all the dependent
libraries.  It runs fine, but the default widget font is too small
(looks like 9 or 10pt).  gtk1.2 apps work correctly, defaulting to
12pt Helvetica which is what I want.  Here's my .gtkrc file:

# created by KDE, Mon Sep 25 00:44:16 2000
#
# If you do not want KDE to override your GTK settings, select
# Themes/Styles in the control center and disable the checkbox 
# Apply fonts and colors to non-KDE apps
#
# If you had a ~/.gtkrc before starting KDE, its content is
# preserved in ~/.gtkrc-save
#

style default
{
  fontset = -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1

  bg[NORMAL] = { 0.863, 0.863, 0.863 }
  bg[SELECTED] = { 0.000, 0.000, 0.666 }
  bg[INSENSITIVE] = { 0.863, 0.863, 0.863 }
  bg[ACTIVE] = { 0.718, 0.718, 0.718 }
  bg[PRELIGHT] = { 0.863, 0.863, 0.863 }

  base[NORMAL] = { 1.000, 1.000, 1.000 }
  base[SELECTED] = { 0.000, 0.000, 0.666 }
  base[INSENSITIVE] = { 0.863, 0.863, 0.863 }
  base[ACTIVE] = { 1.000, 1.000, 1.000 }
  base[PRELIGHT] = { 1.000, 1.000, 1.000 }

  text[NORMAL] = { 0.000, 0.000, 0.000 }
  text[SELECTED] = { 1.000, 1.000, 1.000 }
  text[INSENSITIVE] = { 0.718, 0.718, 0.718 }
  text[ACTIVE] = { 0.000, 0.000, 0.000 }
  text[PRELIGHT] = { 0.000, 0.000, 0.000 }

  fg[NORMAL] = { 0.000, 0.000, 0.000 }
  fg[SELECTED] = { 1.000, 1.000, 1.000 }
  fg[INSENSITIVE] = { 0.718, 0.718, 0.718 }
  fg[ACTIVE] = { 0.000, 0.000, 0.000 }
  fg[PRELIGHT] = { 0.000, 0.000, 0.000 }
}

class * style default

(I _do not_ run KDE or gnome, the comment is purely for hysterical
raisins).

I copied this file to .gtkrc-2.0 and tried again, but it had no
effect.  Also, looking at the source of the program, it doesn't seem
to hardcode a font anywhere.

So what is going on?

-- 
Ian Zimmerman, Oakland, California, U.S.A. 
if (sizeof(signed)  sizeof(unsigned) + 4) { delete this; }
GPG: 433BA087  9C0F 194F 203A 63F7 B1B8  6E5A 8CA3 27DB 433B A087
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2.0 font problem

2003-02-23 Thread Sven Neumann
Hi,

Ian Zimmerman [EMAIL PROTECTED] writes:

 Hi, I searched the archive suspecting this could be a FAQ, but without
 luck.
 
 I just installed my first gtk2.0 program and all the dependent
 libraries.  It runs fine, but the default widget font is too small
 (looks like 9 or 10pt).  gtk1.2 apps work correctly, defaulting to
 12pt Helvetica which is what I want.

put this into your ~/.gtkrc-2.0 file:

style default
{
  font_name = Sans 12
}

class * style default


Salut, Sven
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


how to reset a gnome canvas?

2003-02-23 Thread Ottavio Campana
How can I delete all the things that I've previously put in a canvas?

-- 
Non c'è più forza nella normalità, c'è solo monotonia.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


fork problem

2003-02-23 Thread Ottavio Campana
I'm trying to execute a new program from a gtk application.
When I call fork I've got:

The program 'visualizzatore' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadIDChoice (invalid resource ID chosen for this
connection)'.
  (Details: serial 1039 error_code 14 request_code 55 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

What's wrong with it?

-- 
Non c'è più forza nella normalità, c'è solo monotonia.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: how to reset a gnome canvas?

2003-02-23 Thread Paul Davis
How can I delete all the things that I've previously put in a canvas?

take the top level canvas group, and:

 gtk_object_destroy (GTK_OBJECT(group));

probably make that:

 g_object_destroy (GOBJECT(group));

if you are using GTK+2.

destroying a group recursively destroys all of its members.

--p
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: fork problem

2003-02-23 Thread Sven Neumann
Hi,

Ottavio Campana [EMAIL PROTECTED] writes:

 I'm trying to execute a new program from a gtk application.
 When I call fork I've got:
 
 The program 'visualizzatore' received an X Window System error.
 
 What's wrong with it?

you probably didn't read the GTK+ FAQ. Your problem is mentioned there.


Salut, Sven
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


clear image

2003-02-23 Thread malo p
hi I have used the function of gtk_new_image_from_file with a fileselection
but my problem is:i can't clean my background for a new image
so after to select a new image my image is displaying under my old image
what can i do or does exist a fucntion which clean my widget
thanks for help
maloSeul le silence est grand, tout le reste n'est que faiblesseDo You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail

dealing with column data

2003-02-23 Thread Carl B. Constantine
I'm writing an app that uses GtkTreeView widget to display data.
However. for two of these GtkTreeViews, the data isn't really row based,
but column based. It's more like a spread sheet and I don't think GTK
has anything akin to what I want.

Essentially, I want to be able to select an individual cell in a table.
Get the data, right-click to popup a menu and perform some function.
GtkTreeView isn't geared for this. I don't want to select an entire row.

Does anyone have any hints on how to accomplish this?


On another note, I've been pooring over the documentation for
GtkTreeView in particular but other widgets as well and it astounds me
(as a veteran technical writer for Metrowerks a while back) the lack of
documentation. I don't mean/want to be harsh, but how can the developers
of Gtk+ expect developers to write apps when there is such a lack of
docs on many of the widget classes and methods? Let me give a practical
example from the GtkTreeView class and one other widget:

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html

The description for GtkTreeView column is incomplete. It says:

The GtkTreeViewColumn object is a visible column in a GtkTreeView
widget. It determines the geometry, type

and that's as far as it gets.

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html#GtkTreeView-select-cursor-row

here, arg1 and returns are blank. What are they supposed to be? When
should this be called?

I really think there needs to be some more docs. The Gtk 2.0 tutorial is
missing docs on several widgets. it would be nice to get these filled
in.

Just my $0.02 worth.

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom


pgp0.pgp
Description: PGP signature


gtk application compile error

2003-02-23 Thread Raheel




hi .

I have written a very basic program using gtk_widgets. 
And tried the command line switches. Below is what i got when try 
to compile: # gcc -Wall wind.c -o wind.o 
'gtk-config --libs --cflags' gcc: gtk-config --libs --cflags: 
No such file or directory wind.c:2:21: gtk/gtk.h: No such file or 
directory wind.c: In function `main': wind.c:7: `GtkWidget' 
undeclared (first use in this function) wind.c:7: (Each undeclared 
identifier is reported only once wind.c:7: for each function it appears 
in.) wind.c:7: `window' undeclared (first use in this function) 
wind.c:9: warning: implicit declaration of function `gtk_init' 
wind.c:11: warning: implicit declaration of function `gtk_window_new' 
wind.c:11: `GTK_WINDOW_TOPLEVEL' undeclared (first use in this function) 
wind.c:12: warning: implicit declaration of function `gtk_widget_show' 
wind.c:14: warning: implicit declaration of function `gtk_main'  
plz help me, I am hanging between all this.  Raheel.
plz note my source code is:

# include gtk/gtk.h

int main( int argc, char *argv[] ){

 GtkWidget *window;

 gtk_init (argc, argv);

 window = gtk_window_new 
(GTK_WINDOW_TOPLEVEL); gtk_widget_show 
(window);

 gtk_main ();

 //printf ("this is first gcc program\n"); //printf ("%s", 
argv[1]); //printf ("%s", argv[2]);

 return 0;}

AND my development box is solaris 8.0 (sparc).