Re: Proper use of g_main_context_iteration

2015-08-12 Thread David King

Hi

On 2015-08-11 20:27, Jacques Pelletier jpellet...@ieee.org wrote:

I'm using a separate thread for accepting clients on a socket server.
In this thread, the g_main_context_iteration is called to update the GUI.

Do I need to use g_main_context_acquire and/or g_main_context_release?

Apart from the code and the reference manuals, there's not much infos
about the proper use of these functions.
What are these for? Where can I get a more detailled description of
these functions?


There is a useful section of the GNOME programming guidelines on main 
contexts:


https://developer.gnome.org/programming-guidelines/stable/main-contexts.html

Philip Withnall deserves the credit for writing this. Thanks Philip!

--
http://amigadave.com/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Could not find signal handler...

2013-12-11 Thread David King

Hi Ken

On 2013-12-11 11:06, Ken Bass daytoo...@gmail.com wrote:

   /* Create new GtkBuilder object */
   builder = gtk_builder_new();
   if( ! gtk_builder_add_from_file( builder, UI_FILE, error ) )
   {
   g_warning( %s, error-message );
   g_free( error );
   return( 1 );
   }

/* Connect signals */
   gtk_builder_connect_signals( builder, NULL );

   /* Destroy builder, since we don't need it anymore */
   g_object_unref( G_OBJECT( builder ) );

   /* Show window. All other widgets are automatically shown by GtkBuilder
*/
   gtk_widget_show(GTK_WIDGET(gtk_builder_get_object(builder,
main_window));)


It is probably unrelated, but note that you call g_object_unref() on 
builder, and then use it again later when you call 
gtk_builder_get_object(). You should move the g_object_unref() call to 
after the last call that uses builder.


Also, you should use g_error_free() on error, rather than g_free().

--
http://amigadave.com/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GList empty after iteration?

2011-09-13 Thread David King

On 2011-09-12 15:10, Craig craigbakal...@verizon.net wrote:

Hi All,

I am confused about GList. My application is parsing a file and creating
midi data with it. I am using GList to store the midi data.  I have
created a GtkListStore to view the parsed data (to insure I am parsing
the data properly).  So, below I iterate through the GList and copy
the data into a tree view.  But, I am shocked to see that after I
iterate through the GList, I cannot iterate through the list again.  I
have debugged the list after the iteration with g_list_length(events)
which shows the list length at 0.  What is up with this?  The first
while loop has data, the second while loop has not data. The code is


Another option to those offered in this thread is to use the handy 
g_list_foreach() to iterate over the list.


http://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html#g-list-foreach

This nicely separates out the loop into a function, something like 
(I have not tested this, and it can probably be simplified):


void my_list_foreach_store (gpointer data, gpointer user_data)
{
GtkTreeIter tree_iter;
struct midi_event *me = data;
GtkListStore list_store = GTK_LIST_STORE (user_data);

gtk_list_store_append (list_store, tree_iter);
gtk_list_store_set (list_store, tree_iter,
0, me-time_stamp,
1, me-event_type,
2, me-message1,
3, me-message2,
   -1);
}

void my_list_foreach_print (gpointer data, gpointer user_data)
{
g_print (midi event \n);
}

void a_function ()
{
 GList *events = NULL;
 GtkListStore *store = gtk_list_store_new();

 events = g_list_prepend (events, some_data);
 /* insert more items */

 events = g_list_reverse (events);
 /* No need for g_list_first (), already handled by 
  * g_list_reverse ().


 g_list_foreach (events, my_list_foreach_store, store);
 g_list_foreach (events, my_list_foreach_print, NULL);
}

--
http://amigadave.com/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkBuilder

2011-03-14 Thread David King

On 2011-03-13 16:23, Craig Bakalian craigbakal...@verizon.net wrote:

Hi,

I am slowly moving my application to gtk+-3.0.  The biggest step is
moving away from GladeXML to GtkBuilder.  The casting is hard work.
But, it appears that gtk_builder_connect_signals  isn't connecting
signals from my GtkBuilder file.  What is up with this?

Do I have to use gtk_builder_connect_signals_full?  That is even more
hard work!


Did you read the documentation for gtk_builder_connect_signals(), and 
follow the advice about compiling and linking against 
gmodule-export-2.0?


http://library.gnome.org/devel/gtk/unstable/GtkBuilder.html#gtk-builder-connect-signals

For instance, if you are using pkg-config, add gmodule-export-2.0 to 
your PKG_CHECK_MODULES call:


PKG_CHECK_MODULES([DEPS], [gtk+-3.0 gmodule-export-2.0])

Note that if you are building your application for Windows, you must add 
G_MODULE_EXPORT to the declaration of signal callbacks. As this is a 
no-op on Linux and other Unices, it is good practice to declare every 
signal callback like this, even if you only plan to build for Linux.



Is anybody out there having difficulty making the transition to gtk3 on
ubuntu 11.04 like I am having?


GtkBuilder has been in GTK+ 2 since 2.12, so I do not think that this is 
a new problem.


--
http://amigadave.com/ | dav...@openismus.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Why is ChangeValue reentrant on a gtk_dialog_run?

2009-08-11 Thread David King

On 2009-08-11 15:32, Boggess Rod rbogg...@corefurnace.com wrote:

-Original Message-
From: Michael Cronenworth [mailto:m...@cchtml.com] 
Sent: Tuesday, August 11, 2009 3:22 PM

To: Boggess Rod
Cc: GTK Devel
Subject: Re: Why is ChangeValue reentrant on a gtk_dialog_run?

Boggess Rod on 08/11/2009 08:08 AM wrote:
 At the risk of beating a dead horse, I've figured out what 
the problem 
 is, I just don't understand why it's occurring or how to fix it.
 



You're thread jacking. Please stop.

Not sure what you mean, so I don't know how to stop.  Why is
ChangeValue reentrant on a gtk_dialog_run? is the thread I started, and
my responses have all pertained to this same issue.  Am I missing
something?


Yes, you also replied to scalable icons Windows, causing your thread
to be joined to that one. See

http://mail.gnome.org/archives/gtk-app-devel-list/2009-August/msg00041.html

--
David King, amigad...@gmail.com | amigad...@hotmail.com | d.c.k...@bath.ac.uk
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Why is there no gtk_window_free() ?

2009-03-23 Thread David King
On Mon, 2009-03-23 at 09:49 +, John Emmas wrote:
 Does gtk_window_new() allocate any system memory?  I've always assumed
 so - and yet whenever I see examples of gtk_window_new() in use, the
 returned pointer is never freed anywhere, which suggests that no memory was
 ever allocated.  Which is right?

A GtkWindow is also a GtkWidget, and looking at the reference
documentation
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-destroy you 
can use gtk_widget_destroy() on a window to decrease its reference count by 
one. When this reference count reaches 0, the widget is finalized and its 
resources returned to the system. This technique is applicable to all objects 
that inherit from GtkWidget.

This reference-counting system is based on GObject, which has some nice
reference documentation at
http://library.gnome.org/devel/gobject/unstable/gobject-memory.html if
you want to read further.

--
David King | http://amigadave.blogspot.com/ | dav...@openismus.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list