Re: Help with closing a notebook page (GTK2)

2011-07-05 Thread Neil Munro
On 4 July 2011 15:02, walter tallent w41...@yahoo.com wrote:
 Hi.
 I know I'm coming late to this party, but if you're packing the button  into 
 the
 tab, it's a child of that notebook page.  Can't you retrieve  the page you're 
 on
 by simply calling gtk_notebook_page_num () with the  button passed in as the
 child during the button's clicked signal  handler?  Then you pass the returned
 page number to  gtk_notebook_remove_page ().  This way you'll always remove 
 the
 correct  page, and it doesn't matter if the user brings that page to the front
 first or not.

 Or is there something I've overlooked?
 walter



 
 From: Bill C bi...@netspace.net.au
 To: gtk-app-devel-list@gnome.org
 Sent: Sun, July 3, 2011 3:54:13 PM
 Subject: Re: Help with closing a notebook page (GTK2)

 On 04/07/11 06:26, Neil Munro wrote:
 On 3 July 2011 19:31, Thomas  Bollmeiertbollme...@web.de  wrote:
 Ursprüngliche Nachricht-
 Von: Neil Munroneilmu...@gmail.com
 Gesendet: 02.07.2011 23:40:02
 An: gtk-app-devel-list@gnome.org
 Betreff: Help with closing a notebook page (GTK2)

 Hi, I have used pygtk before so I am familiar with some of the basic
 concepts of gtk, but this is my first attempt with an actual gtk+ C
 application and I have run into a few issues.

 I have a notebook that I wish to have a close button on the page tabs
 that when clicked closes the tabs.

 I know that it's a bit off a faf to do as you don't know the page
 prior to the event. So you have to dynamically detect which tab is
 being closed by using a tab child widget.

 Now I believe I have done this in code, except it always returns -1
 which then firmly tells me I have done something wrong.

 I have attached the code for your reference in the hopes that someone
 shall be able to point out my no doubt simple mistake.

 Many thanks in advance,
 Neil Munro
 I faced a similar problem when I wrote an editor for the first version of my
gobjectcreator tool some time ago. It was
 implemented in PyGTK - nevertheless it should work in C as well. The 
 solution
may not be elegant but it
 worked:
 I registered a handler for the clicked-signal of the close button within 
 the
tab label widget (a GtkHBox).
 Within the handler implementation I looped over all pages of the notebook 
 and
checked whether the button instance
 in the page label was identical to the sender instance of the 
 clicked-signal.
If yes then I had to remove the
 corresponding page.
 You can find the code example here:

https://github.com/ThomasBollmeier/GObjectCreator/blob/master/gobject_creator/ui/documents_view.py
y

 (see lines 342ff. and 378ff. respectively)

 Hope that helps.

 Regards,
 Thomas



 ___
 Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
 Toolbar eingebaut! http://produkte.web.de/go/toolbar

 Thanks to this and Bills suggestion the correct page closes, but I
 need to determine a way to re-calculate the page as soon as a tab is
 closed, am sure I will figure something out, but thanks for the
 patience and help!
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
 Hi Neil

 Yes the page numbers can change when a page is closed, so you cant use
 original page numbers directly to switch pages.

 I think I redesigned so that I did not use page numbers. Let the user
 switch pages and process the page the user is working with.  Ensure the
 user cant delete pages that are prior to a page you want to reference
 directly.  As Thomas said...  Not totally elegant.

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


Well I have a method to correctly get the tab page, it might not be
the best way but it's what came naturally to me, I am having issues
with the memory management. Now I understand the principle of linked
lists/memory management etc but I have only previously created small
test programs, nothing inside a real program, so am having trouble
applying theory to practical.

Below is the function I am writing, I am aware I am not freeing any
memory yet, but some tabs wont close even after I have supposedly
adjusted the linked list, so I am at a loss as to how I am to make
this work, any help would be appreciated!

static void Close( GtkWidget *widget, struct data *tmp )
{
// Re-configure linked list to reflect new tab positions
struct node *ptr = head;
struct node *prev = ptr;

g_print( Old list!\n\n ); 

ptr = head;

while( ptr-Next != NULL )
{
if( ptr == tmp-Ptr )
{
  

Strange glibc detected invalid pointer with gtk_entry

2011-07-05 Thread Herbert Gasiorowski
I have an issue with nearly all gtk+ programs: since about one week the programs 
crash at startup with some fault like this:


*** glibc detected *** ./gtk-tab2: munmap_chunk(): invalid pointer: 
0x01aa8eb0 ***

=== Backtrace: =
/lib64/libc.so.6[0x365a47703a]
/lib64/libglib-2.0.so.0(g_free+0x23)[0x365c449743]

But if I start the program via ssh it runs as expected:
   ssh -X $HOSTNAME myprogram
AND if I link without -lmcheck it is ok too ...

I deleted all code which did not affect this issue:
It is not much more than another Hello World example but using gtk_entry to 
display the text (#if 1):


Fedora 15 and gtk3-3.0.11-1.fc15.x86_64
(gtk2 will fail too)

Can someone tell me what I should do next?

==
/* test with
 *  gcc -Wall -g -o gtk-tab gtk-tab.c -lmcheck `pkg-config --cflags --libs 
gtk+-3.0`  ./gtk-tab

 */

#include stdlib.h
#include string.h
#include gtk/gtk.h

#define SUMMARY gtk test
#define TRACE(l,fmt,args...) fprintf(stderr,#%03d#%9.9s:%3d#  
fmt\n,l,__FILE__,__LINE__,##args)


int main( int argc, char **argv ) {
GtkWidget *window;
GtkWidget *value;
TRACE(9,gtk init);
gtk_init (argc, argv);

TRACE(12,gtk create a new window);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), SUMMARY);
g_signal_connect (G_OBJECT (window), destroy,
G_CALLBACK (gtk_main_quit), NULL);

TRACE(12,Create the text);
#if 1
value = gtk_entry_new();
gtk_entry_set_text( GTK_ENTRY(value), test 123 );
#else
value = gtk_label_new(test 123);
#endif

gtk_container_add (GTK_CONTAINER (window), value);

TRACE(12,gtk show all);
gtk_widget_show_all (window);
TRACE(11,gtk loop: start);
gtk_main ();
TRACE(11,gtk loop: done);
return 0;
}
==
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Strange glibc detected invalid pointer with gtk_entry

2011-07-05 Thread zz
On Tuesday 05 July 2011 14:24:48 Herbert Gasiorowski wrote:
 I have an issue with nearly all gtk+ programs: since about one week the 
 programs 
 crash at startup with some fault like this:
 
 *** glibc detected *** ./gtk-tab2: munmap_chunk(): invalid pointer: 
 0x01aa8eb0 ***
 === Backtrace: =
 /lib64/libc.so.6[0x365a47703a]
 /lib64/libglib-2.0.so.0(g_free+0x23)[0x365c449743]
 
 But if I start the program via ssh it runs as expected:
 ssh -X $HOSTNAME myprogram
 AND if I link without -lmcheck it is ok too ...
 
 I deleted all code which did not affect this issue:
 It is not much more than another Hello World example but using gtk_entry to 
 display the text (#if 1):
 
 Fedora 15 and gtk3-3.0.11-1.fc15.x86_64
 (gtk2 will fail too)
 
 Can someone tell me what I should do next?
 
 ==
 /* test with
   *  gcc -Wall -g -o gtk-tab gtk-tab.c -lmcheck `pkg-config --cflags --libs 
 gtk+-3.0`  ./gtk-tab
   */
 
 #include stdlib.h
 #include string.h
 #include gtk/gtk.h
 
 #define SUMMARY gtk test
 #define TRACE(l,fmt,args...) fprintf(stderr,#%03d#%9.9s:%3d#  
 fmt\n,l,__FILE__,__LINE__,##args)
 
 int main( int argc, char **argv ) {
   GtkWidget *window;
   GtkWidget *value;
   TRACE(9,gtk init);
   gtk_init (argc, argv);
 
   TRACE(12,gtk create a new window);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), SUMMARY);
   g_signal_connect (G_OBJECT (window), destroy,
   G_CALLBACK (gtk_main_quit), NULL);
   
   TRACE(12,Create the text);
 #if 1
   value = gtk_entry_new();
   gtk_entry_set_text( GTK_ENTRY(value), test 123 );
 #else
   value = gtk_label_new(test 123);
 #endif
 
   gtk_container_add (GTK_CONTAINER (window), value);
 
   TRACE(12,gtk show all);
   gtk_widget_show_all (window);
   TRACE(11,gtk loop: start);
   gtk_main ();
   TRACE(11,gtk loop: done);
   return 0;
 }
 ==

I in the past used this function this insert text in entry widgets, don't know 
if it helps in your case:

void my_gtk_entry_set_text(GtkEntry *entry, char *data)
{
char *tmp;

if (!data) data = ;

if (g_utf8_validate(data, -1, NULL) != TRUE) {
tmp = g_locale_to_utf8(data, -1, NULL, NULL, NULL); 
gtk_entry_set_text(entry, tmp);
xfree(tmp);
} else {
gtk_entry_set_text(entry, data);
}
}

Hope this helps.

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


Re: Strange glibc detected invalid pointer with gtk_entry

2011-07-05 Thread Emmanuele Bassi
On 2011-07-05 at 15:05, z...@excite.it wrote:
 void my_gtk_entry_set_text(GtkEntry *entry, char *data)
 {
   char *tmp;
 
   if (!data) data = ;
 
   if (g_utf8_validate(data, -1, NULL) != TRUE) {
   tmp = g_locale_to_utf8(data, -1, NULL, NULL, NULL); 
   gtk_entry_set_text(entry, tmp);
   xfree(tmp);


agh!

g_locale_to_utf8() returns memory allocated through the GLib API; you
need to call g_free() to free it. *do not* mix GLib's memory allocation
functions with other allocation functions.

ciao,
 Emmanuele.

-- 
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Help with closing a notebook page (GTK2)

2011-07-05 Thread walter tallent
You seem to be unintentionally making things very hard for yourself.  I don't 
know anything about the purpose of your app, but you do not need to implement 
your own linked list, GLib already has a very capable list API built in.  Also, 
the notebook already behaves like a linked list, so all the list related 
operations you're coding are only serving to cause you headaches.  If you want 
to code a linked list for learning purposes, choose a very simple approach, 
like 
a list of integers.  Code it in a separate program.  Once you understand how 
all 
the operations affect the list, use the GLib code.  It is already stable and 
effective.  If it's an issue of not knowing whether the functionality is 
implemented for you, check the reference material.  Don't be hesitant about 
consulting the GLib/GTK docs or code.  There's much to be learned there.
As far as things like page numbers, if you need to keep track of information 
that is associated with the page, but not actually part of the page, I suggest 
you look into using g_object_set_data () and g_object_get_data ().  Again, the 
wheel has already been invented and debugged.
You made a statement that I think might be at the heart of your troubles.  If 
you are not interested in using the best method, you are only making things 
harder on yourself.  Of course the best method is always subjective.  A 
method 
tends to be the viewed as the best when it gets the job done in the fewest 
lines 
of code, and takes most advantage of code that has already been written and 
stabilized.  You would do yourself a huge favor by making this your approach.  
That may mean more reading than coding at first, but the payoff is undeniable.
take it easy
walter  





From: Neil Munro neilmu...@gmail.com
To: gtk-app-devel-list@gnome.org
Sent: Tue, July 5, 2011 6:51:01 AM
Subject: Re: Help with closing a notebook page (GTK2)

On 4 July 2011 15:02, walter tallent w41...@yahoo.com wrote:
 Hi.
 I know I'm coming late to this party, but if you're packing the button  into 
the
 tab, it's a child of that notebook page.  Can't you retrieve  the page you're 
on
 by simply calling gtk_notebook_page_num () with the  button passed in as the
 child during the button's clicked signal  handler?  Then you pass the returned
 page number to  gtk_notebook_remove_page ().  This way you'll always remove 
the
 correct  page, and it doesn't matter if the user brings that page to the front
 first or not.

 Or is there something I've overlooked?
 walter



 
 From: Bill C bi...@netspace.net.au
 To: gtk-app-devel-list@gnome.org
 Sent: Sun, July 3, 2011 3:54:13 PM
 Subject: Re: Help with closing a notebook page (GTK2)

 On 04/07/11 06:26, Neil Munro wrote:
 On 3 July 2011 19:31, Thomas  Bollmeiertbollme...@web.de  wrote:
 Ursprüngliche Nachricht-
 Von: Neil Munroneilmu...@gmail.com
 Gesendet: 02.07.2011 23:40:02
 An: gtk-app-devel-list@gnome.org
 Betreff: Help with closing a notebook page (GTK2)

 Hi, I have used pygtk before so I am familiar with some of the basic
 concepts of gtk, but this is my first attempt with an actual gtk+ C
 application and I have run into a few issues.

 I have a notebook that I wish to have a close button on the page tabs
 that when clicked closes the tabs.

 I know that it's a bit off a faf to do as you don't know the page
 prior to the event. So you have to dynamically detect which tab is
 being closed by using a tab child widget.

 Now I believe I have done this in code, except it always returns -1
 which then firmly tells me I have done something wrong.

 I have attached the code for your reference in the hopes that someone
 shall be able to point out my no doubt simple mistake.

 Many thanks in advance,
 Neil Munro
 I faced a similar problem when I wrote an editor for the first version of my
gobjectcreator tool some time ago. It was
 implemented in PyGTK - nevertheless it should work in C as well. The 
solution
may not be elegant but it
 worked:
 I registered a handler for the clicked-signal of the close button within 
the
tab label widget (a GtkHBox).
 Within the handler implementation I looped over all pages of the notebook 
and
checked whether the button instance
 in the page label was identical to the sender instance of the 
clicked-signal.
If yes then I had to remove the
 corresponding page.
 You can find the code example here:

https://github.com/ThomasBollmeier/GObjectCreator/blob/master/gobject_creator/ui/documents_view.py

y

 (see lines 342ff. and 378ff. respectively)

 Hope that helps.

 Regards,
 Thomas



 ___
 Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
 Toolbar eingebaut! http://produkte.web.de/go/toolbar

 Thanks to this and Bills suggestion the correct page closes, but I
 need to determine a way to re-calculate the page as soon as a tab is
 closed, am sure I will figure something out, but thanks for the
 

GTK+ 3.1.8

2011-07-05 Thread Matthias Clasen
GTK+ 3.1.8 is now available for download at:

 ftp://ftp.gtk.org/pub/gtk/3.1/
 http://download.gnome.org/sources/gtk+/3.1/

0a0bb52af6c8220c40ed82e7361d353e6e1010480cba7b37863178c1d8f16d3e  gtk
+-3.1.8.tar.xz
e51970133bb6ff7d585ce9f678e8ce6e3073a1b1d455cc42671503ce71d93533  gtk
+-3.1.8.tar.bz2

Another release in the 3.1 development cycle.



GTK+ is a multi-platform toolkit for creating graphical user
interfaces. Offering a complete set of widgets, GTK+ is suitable for
projects ranging from small one-off tools to complete application
suites.

GTK+ has been designed from the ground up to support a range of
languages, not only C/C++. Using GTK+ from languages such as Perl and
Python (especially in combination with the Glade GUI builder) provides
an effective method of rapid application development.

GTK+ is free software and part of the GNU Project. However, the
licensing terms for GTK+, the GNU LGPL, allow it to be used by all
developers, including those developing proprietary software, without
any license fees or royalties.


Overview of Changes in GTK+ 3.1.8
=

* Theming improvements:
  - Multiple colors are now supported
  - Support CSS font properties like font-size, font-family, etc
  - nth-child works for toolbars too

* Bug fixes:
 652506 Improve GtkAssistant button labels
 652618 themingengine: shrink the background size to the padding-box
 652769 Reordering/removing hidden children in GtkBox results in 100%
CPU
 653053 Avoid GApplication being released twice...
 653191 uninitialized variable in completion_match_func
 65 Assigned value is garbage or undefined in gtktoolpalette.c:565
 653512 GtkEntryCompletion: Use a PAGE_STEP macro instead of a magic
number
 653785 GtkStyleContext ignores style classes when getting style
properties

* Translation updates:
 Belarusian
 Dutch
 Galician
 Hebrew
 Norwegian bokmål
 Persian
 Slovenian
 Spanish


Thanks to all contributors:
Benjamin Otte
Juan A. Suarez Romero
William Jon McCann
Xan Lopez
Cosimo Cecchi
Chun-wei Fan
José Aliste
Javier Jardón
Claudio Saavedra
Colin Walters
Scott Moreau
Murray Cumming
Paolo Borelli
Mike Gorse
John Palmieri
Juan Pablo Ugarte
Vincent Untz


July 5, 2011
Matthias Clasen


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

GLib 2.29.10

2011-07-05 Thread Matthias Clasen
GLib 2.29.10 is now available for download at:

  ftp://ftp.gtk.org/pub/glib/2.29/
  http://download.gnome.org/sources/glib/2.29/

260f91e9cf051b712a344d34579a5403eb1dfb58127a4395b0d7f7385f1305cd
glib-2.29.10.tar.xz
81eabdc56ac8a64900e798805f35655395f20f5155b57b42f577311ee45234bb
glib-2.29.10.tar.bz2

The is another development snapshot of the 2.29 series.


Overview of changes from GLib 2.29.8 to 2.29.10
===

* New features:
 - g_desktop_app_info_get_nodisplay: a function that is required
   to port gnome-menus to GDesktopAppInfo
 - g_hash_Table_iter_replace: new function to replace a value
   while iterating over a hash table
 - g_utf8_substring: convenience API to extract substrings from
   UTF-8 strings
 - g_action_group_add_entries: convenience API for creating lots
   of actions quickly
 - Use eventfd instead of pipes for waking up main contexts and
   for cancellation when available
 - GMatchInfo is now a refcounted boxed type

* API changes in GAction:
 - the 'set_state' entry in the GActionInterface vtable has been
   renamed to 'change_state
 - g_action_set_state has been renamed to g_action_change_state
 - the 'state' property has been changed to read-only
 - GSimpleAction can no longer be subclassed

* Bug fixes
 647796 g_variant_new_variant is not marked as constructor
 652072 gmain: make use of signalfd()
 652168 Crosscompiling Fails if build=2.24 and host 2.24
 652750 make dist fails
 652758 GDataInputStream: Clarify g_data_input_stream_read_line docs...
 652822 Add a g_hash_table_iter_replace
 652897 tiny docs clarification for g_utf8_to_ucs4_fast
 653140 gmain: use Linux eventfd() for main context wake up
 653429 drop AM_MAINTAINER_MODE or enable it by default
 653484 GAsyncCallbacks should default to allow-none
Add missing fundamental types to the generic marshaller

* Translation updates
 Belarusian
 Galician
 Russian

Thanks to all contributors:
Vincent Untz
Xan Lopez
Colin Walters
David Zeuthen
Ryan Lortie
Murray Cumming
Patrick Welche
Chun-wei Fan
Christian Persch
Javier Jardón
Philip Van Hoof
Dan Winship
Sebastian Dröge
Krzesimir Nowak
Claudio Saavedra
Emmanuele Bassi
Dieter Verfaillie


July 5, 2011
Matthias Clasen


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

Re: Strange glibc detected invalid pointer with gtk_entry

2011-07-05 Thread zz
On Tuesday 05 July 2011 16:19:00 Emmanuele Bassi wrote:
 On 2011-07-05 at 15:05, z...@excite.it wrote:
  void my_gtk_entry_set_text(GtkEntry *entry, char *data)
  {
  char *tmp;
  
  if (!data) data = ;
  
  if (g_utf8_validate(data, -1, NULL) != TRUE) {
  tmp = g_locale_to_utf8(data, -1, NULL, NULL, NULL); 
  gtk_entry_set_text(entry, tmp);
  xfree(tmp);
 
 
 agh!
 
 g_locale_to_utf8() returns memory allocated through the GLib API; you
 need to call g_free() to free it. *do not* mix GLib's memory allocation
 functions with other allocation functions.

Hi,
to be honest :-) I'm doing this for a long time and never experienced problems.
Cannot imagine glib calling something different than malloc/calloc/realloc at 
the low level
so unless there are some special profiler or debug functions free should be ok 
or at least
it for me worked flawlessly in linux and windows. I think there must be more 
than a simple no-no.
Thanks for your hint will try to correct this bad habit in the future.
To fix my code a simple

#define malloc g_malloc
#define free g_free
#define calloc  g_calloc
#define realloc g_realloc

should do it. Right?

Ciao,
Tito
 ciao,
  Emmanuele.
 
 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list