Re: Beginners guide

2018-04-24 Thread Marshall Lake


Thanks for this.  I can use all the help I can get.



Date: Tue, 24 Apr 2018 19:39:06 +0100
From: Jim Reilly 

I have put together a guide to help beginners to get started using 
gtk+3.0 in the hope that it might be useful. I do not have a web site 
through which I can make it available so I have attached it to this 
e-mail so that, if anyone thinks it is worth reading, they can make it 
accessible to others.


--
Marshall Lake -- ml...@mlake.net -- http://www.mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: future of development for the desktop (C++ vs C)

2012-05-26 Thread Marshall Lake



Is gtk+ 3.*.* now faster than the latest gtk+-2.*.* ?

If not, since even gtk+-2.*.* is slower than Qt, gtk+ loses.
...
Here is another thread: 
http://stackoverflow.com/questions/1887070/what-should-i-choose-gtk-or-qt .

FWIW, Qt now also is LGPL.


I wouldn't mind giving Qt a trial but I don't do C++.  I only use C.  Can 
I use Qt with C ?


Are there any toolkits besides GTK which can be used with C ?

--
Marshall Lake -- ml...@mlake.net -- http://www.mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Timely Display of Dialog Contents

2012-03-25 Thread Marshall Lake


I have an issue where the contents of a dialog (a label & pic) is not 
always displayed in a timely manner (or at all).  In the code below the 
dialog outline (the size of the dialog changes from pic to pic) always 
displays properly as it should.  But the contents of the label and the pic 
in the gtk_image_new_from_pixbuf() call sometimes display appropriately 
and sometimes don't.  (When the dialog content doesn't display properly 
the dialog outline displays but the contents are blank.)


The code below is within a large loop.  There's a lot of other stuff going 
on.  The contents of the dialog (label & pic) changes with each execution 
of the code.  If I slow down execution of the entire code with sleep() I 
get the same results as described above.


The code below is executed within a g_idle_add().

I've tried adding:
while (gtk_events_pending ())
gtk_main_iteration ();

after the gtk_widget_show_all() to no avail.

I appreciate any insight.


batterpicwin = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (batterpicwin), "Batter Pic");
gtk_window_set_default_size (GTK_WINDOW (batterpicwin), 200, 130);
gtk_window_move (GTK_WINDOW (batterpicwin), batpicwinlocX, batpicwinlocY);
gtk_signal_connect (GTK_OBJECT (batterpicwin), "delete_event", 
GTK_SIGNAL_FUNC (donot_delete_event), 0);

strcpy (&work[0], "Batting - ");
strcat (&work[0], &savebattername[0]);

vbox2 = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (batterpicwin)->vbox), vbox2, TRUE, 
TRUE, 0);
label = g_object_new (GTK_TYPE_LABEL, "label", &work[0], NULL);
gtk_box_pack_start (GTK_BOX (vbox2), label, TRUE, TRUE, 0);

vbox2 = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (batterpicwin)->vbox), vbox2, TRUE, 
TRUE, 0);

picbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (picbox), gtk_image_new_from_pixbuf (pic));
gtk_box_pack_start (GTK_BOX (vbox2), picbox, TRUE, TRUE, 0);

gtk_widget_show_all (batterpicwin);


--
Marshall Lake -- ml...@mlake.net -- http://www.mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK & threads

2009-07-07 Thread Marshall Lake



Not long ago I wrote a simple blog post on how to use threads in GTK+
applications. You can find it here:
http://tadeboro.blogspot.com/2009/06/multi-threaded-gtk-applications.html


After reading your blog (which is very good) and screwing around with my 
code a little bit I still can't solve the problem.


Does anyone else have anything (my original post with code included here 
...) ?




I'm developing a program(s) which runs in the client/server environment. 
I'm using GTK, sockets, and threads.  (GTK and threads only on the client 
side.)  I don't have very much experience using threads and this is the 
first time I've tried to call GTK functions within a thread, and I'm 
having problems.  I've tried different ways of approaching the problem but 
can't seem to get anywhere.  I suspect there's something I don't 
understand about thread processing or I'm under some misconception. 
Maybe someone can help me?  Any help is much appreciated.


I get the following errors when trying to run the code below (the errors 
show up when the program calls gtk_dialog_run() in the thread 
(Wait4Challenge()):


src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy->last_request_read) - 
(long) (dpy->request)) <= 0)' failed.
Fatal IO error 0 (Success) on X server :0.0.


void *
Wait4Challenge () {
 int wsock, x, port = 0, listensock, connected;
 char buffer[5000], *msg[5], challenger[50];

 listensock = -1;
 for (x = 0; x < 5; x++)
 msg[x] = NULL;

 wsock = get_connection (SOCK_STREAM, port, &listensock);

 connected = 1;
 while (connected) {
 GtkWidget *dialog;
 int response;

 if (sock_gets (wsock, &buffer[0], sizeof (buffer)) < 0) {
 msg[0] = "There is a problem with the server.\n\n";
 outMessage (msg);
 connected = 0;
 }

 if (buffer[0] == 'R')
 connected = 0;

 if (buffer[0] != 'C')
 continue;

 strcpy (&challenger[0], &buffer[1]);

 gdk_threads_enter ();

 dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), 
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
 GTK_BUTTONS_YES_NO, "%s has challenged you to a game.  
Do you wish to play?", challenger);
 gtk_window_set_title (GTK_WINDOW (dialog), "Play Challenger?");
 response = gtk_dialog_run (GTK_DIALOG (dialog));
 gtk_widget_destroy (dialog);

 gdk_flush();
 gdk_threads_leave ();

 if (response == GTK_RESPONSE_YES) {
 sock_puts (wsock, "OK\n");
 connected = 0;
 }
 else {
 sock_puts (wsock, "NO\n");
 for (x = 0; x < 5; x++)
 msg[x] = NULL;
 continue;
 }
 }

 shutdown (wsock, SHUT_RDWR);
 close (wsock);
 return (NULL);
}

int
main (int argc, char *argv[]) {
 g_thread_init (NULL);
 gdk_threads_init ();

 gtk_init (&argc, &argv);

 mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY);
 gtk_widget_realize (mainwin);

 gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK);
 gtk_signal_connect (GTK_OBJECT (mainwin), "delete_event", GTK_SIGNAL_FUNC 
(delete_event), 0);

 gtk_widget_show_all (mainwin);

 if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL))
 syslog (LOG_INFO, "error trying to create new thread");

 gdk_threads_enter ();

 gtk_main ();

 gdk_flush();
 gdk_threads_leave ();

 return 0;
}



--
Marshall Lake -- ml...@mlake.net -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


GTK & threads

2009-06-26 Thread Marshall Lake


I'm developing a program(s) which runs in the client/server environment. 
I'm using GTK, sockets, and threads.  (GTK and threads only on the client 
side.)  I don't have very much experience using threads and this is the 
first time I've tried to call GTK functions within a thread, and I'm 
having problems.  I've tried different ways of approaching the problem but 
can't seem to get anywhere.  I suspect there's something I don't 
understand about thread processing or I'm under some misconception. 
Maybe someone can help me?  Any help is much appreciated.


I get the following errors when trying to run the code below (the errors 
show up when the program calls gtk_dialog_run() in the thread 
(Wait4Challenge()):


src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy->last_request_read) - 
(long) (dpy->request)) <= 0)' failed.
Fatal IO error 0 (Success) on X server :0.0.


void *
Wait4Challenge () {
int wsock, x, port = 0, listensock, connected;
char buffer[5000], *msg[5], challenger[50];

listensock = -1;
for (x = 0; x < 5; x++)
msg[x] = NULL;

wsock = get_connection (SOCK_STREAM, port, &listensock);

connected = 1;
while (connected) {
GtkWidget *dialog;
int response;

if (sock_gets (wsock, &buffer[0], sizeof (buffer)) < 0) {
msg[0] = "There is a problem with the server.\n\n";
outMessage (msg);
connected = 0;
}

if (buffer[0] == 'R')
connected = 0;

if (buffer[0] != 'C')
continue;

strcpy (&challenger[0], &buffer[1]);

gdk_threads_enter ();

dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), 
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO, "%s has challenged you to a game.  
Do you wish to play?", challenger);
gtk_window_set_title (GTK_WINDOW (dialog), "Play Challenger?");
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);

gdk_flush();
gdk_threads_leave ();

if (response == GTK_RESPONSE_YES) {
sock_puts (wsock, "OK\n");
connected = 0;
}
else {
sock_puts (wsock, "NO\n");
for (x = 0; x < 5; x++)
msg[x] = NULL;
continue;
}
}

shutdown (wsock, SHUT_RDWR);
close (wsock);
return (NULL);
}

int
main (int argc, char *argv[]) {
g_thread_init (NULL);
gdk_threads_init ();

gtk_init (&argc, &argv);

mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY);
gtk_widget_realize (mainwin);

gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (mainwin), "delete_event", GTK_SIGNAL_FUNC 
(delete_event), 0);

gtk_widget_show_all (mainwin);

if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL))
    syslog (LOG_INFO, "error trying to create new thread");

gdk_threads_enter ();

gtk_main ();

gdk_flush();
gdk_threads_leave ();

return 0;
}


--
Marshall Lake -- ml...@mlake.net -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Creating a Modal Dialog from a Routine Called by g_idle_add()

2007-03-21 Thread Marshall Lake

I've run into a problem with my current project and I'm having difficulty 
finding the cause.  I'm sure the problem is because of a lack of 
understanding on my part concerning GTK.  I'm hoping someone here can prod 
me in the right direction.

I have a routine called by g_idle_add() which updates the contents of an 
already-existing modal dialog with data received from a server software. 
This routine gets called continually until the data from the server 
ceases.  Certain data which is received causes a new modal dialog to be 
created which looks for user input.

Things work fine until a new modal dialog needs to be created.  The dialog 
is created fine and the user input is accepted fine, but I cannot destroy 
the new modal dialog.  And at this point the routine is not called again 
by g_idle_add().  The program hangs, and the only thing I can do is kill 
the new modal dialog which in turn kills the whole program.

Can someone clue me in to what might be going on?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Delay in Displaying Dialog

2007-01-16 Thread Marshall Lake

> Marshall--perhaps it would help if you could provide a little more info 
> on the nature of the data coming into the dialog.  Does it come over a 
> socket, or a file descriptor from some type of character device, or 
> what?

I'm receiving the text via a socket.

With your help and prodding I've been able to get past my problem using 
g_idle_add().  Using it does open up new challenges for me but I'm 
thankful for the helping hand.

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Delay in Displaying Dialog

2007-01-16 Thread Marshall Lake

>> After the text being sent to the text widget ends and process flow 
>> falls back into gtk_main() then all the other widgets within the 
>> secondary dialog appear including the first few lines of text which had 
>> been missing.

> This line leads me to believe that you may not be relinquishing control to
> the Gtk mainloop.  When the text comes into the second dialog box, are you
> locking up the program until it is all read?

Yes, I'm locking up the program until all the text is read.

I haven't taken the time to test your belief but assuming you're correct 
(and I'm sure you are) that brings to mind a couple of questions ...

Can there be more than one gtk_main() call in one program?  And could that 
possibly help me?

How does MODAL and gtk_dialog_run() work?  Do they both integrate 
themselves with the GTK main loop "behind the scenes"?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Delay in Displaying Dialog

2007-01-15 Thread Marshall Lake

I'm encountering a problem in an application I'm working on which I don't 
understand.  It may be due to a misconception I have with GTK+ 
functionality.

The application has a main window which comes up with program execution. 
Further processing is driven by events initiated by the user selecting 
drop-down menu items from this main window.

In one menu item a dialog is displayed where the user selects certain 
criteria with which to proceed.  Upon completion of establishing the 
criteria the dialog is destroyed and a new dialog is created.  Within this 
new dialog are a couple of boxes and a couple of tables.  Within one of 
the tables is a non-editable text widget with a vertical scrollbar.

A gtk_widget_show_all() is issued for this new dialog once it's created, 
however the dialog is not displayed at this point.  Additionally, the 
first dialog has not yet disappeared from the display.

Immediately after creation of this new dialog, text begins to be sent on a 
somewhat streaming basis to the text widget.  After a few seconds the 
first dialog disappears and the secondary dialog appears.  However, the 
only widget within the secondary dialog which appears is the text widget. 
No other widgets appear.  The appropriate text begins appearing and 
scrolling within the text widget.  But missing are the first four or five 
lines of text which were (probably) sent to the text widget during the 
time it was not displayed.

After the text being sent to the text widget ends and process flow falls 
back into gtk_main() then all the other widgets within the secondary 
dialog appear including the first few lines of text which had been 
missing.

Can anyone give me an idea (or point me someplace) which will tell me 
what's going on?  Thanks.

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Need Help Understanding a Compile Error

2004-07-22 Thread Marshall Lake

I need help in understanding a problem I'm encountering when compiling a
particular GTK program.

When compiling, at link time I get the following errors:

/usr/local/lib/libpangoxft-1.0.so: undefined reference to 
`pango_fc_font_map_cache_clear'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_get_type'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to 
`pango_fc_font_map_create_context'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_shutdown'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_type'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_lock_face'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_has_char'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_glyph'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to 
`pango_fc_font_get_unknown_glyph'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to 
`pango_fc_font_get_raw_extents'
/usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_unlock_face'

In this case /usr/local/lib/libpangoxft-1.0.so is linked to
/usr/local/lib/libpangoxft-1.0.so.0.501.0.  If I change libpangoxft-1.0.so
to be linked to /usr/local/lib/libpangoxft-1.0.so.0.200.5 the program
compiles correctly.

Can someone tell me why?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Trouble Installing Pango

2004-07-21 Thread Marshall Lake

> > [undefined references]

> On my system (Slackware 9), the undefined references (started with 2.4)
> were due to libtool adding the older versions of the libraries (in
> /usr/lib)  in front of the newer versions (in /usr/local/lib) as part of
> the link command.
>
> I fiddled with ld.so.config and libtool for days with no success, so I
> ended up editing the *.la files by hand to get everything to link to the
> proper libraries.
>
> There is a newer version of libtool out that may or may not fix the
> problem.

I installed the latest version of libtool and that didn't help.  So, then
I changed the pertinent .la files (actually just copied over the newer
ones) and all's well.  Thanks for the push in the right direction.

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Trouble Installing Pango

2004-07-21 Thread Marshall Lake

> > While trying to install pango 1.5.1 near the (seemingly) end of
> > compilation I get the following errors:
> >
> > /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to 
> > `g_type_instance_get_private'
> > /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to 
> > `g_type_class_add_private'
> > /home/mlake/pango-1.5.1/pango/.libs/libpango-1.0.so: undefined reference to 
> > `g_unichar_get_mirror_char'

> These are GLib-2.4 things.  You need GLib-2.4.  I'm sure
> Pango README mentions this dependency.

I successfully installed GLib-2.5 and I'm getting the same errors when
trying to install pango 1.5.1.  The GLib version doesn't have to be
exactly 2.4, does it?

What else could be causing the errors?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Trouble Installing Pango

2004-07-20 Thread Marshall Lake

While trying to install pango 1.5.1 near the (seemingly) end of
compilation I get the following errors:

/home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to 
`g_type_instance_get_private'
/home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to 
`g_type_class_add_private'
/home/mlake/pango-1.5.1/pango/.libs/libpango-1.0.so: undefined reference to 
`g_unichar_get_mirror_char'

Can anyone tell me what's going wrong and how I can correct the situation?
Thanks.

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Problems Compiling Pango

2004-03-19 Thread Marshall Lake

I'm having trouble installing the current version of pango (1.4.0) on a
Linux box.  I installed glib 2.4.0 successfully, but when trying to make
pango I get the following errors messages:

/home/mlake/pango-1.4.0/pango/.libs/libpangoft2-1.0.so: undefined reference to 
`g_type_instance_get_private'
/home/mlake/pango-1.4.0/pango/.libs/libpangoft2-1.0.so: undefined reference to 
`g_type_class_add_private'
/home/mlake/pango-1.4.0/pango/.libs/libpango-1.0.so: undefined reference to 
`g_unichar_get_mirror_char'

I haven't had any problems installing previous versions of glib/pango/gtk.
Can someone give me a clue as to what's going wrong and how I can get
around my current installation problems?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list