Re: Migrating away from GtkStock stuff

2019-02-07 Thread Gabriele Greco via gtk-app-devel-list
>
>
>> If you're using `edit-find` or `document-save` then you're using a named
> icon from the icon theme, not the stock identifier.
>
> For those, you'll have to ship an icon theme like Adwaita.
>

That's really strange, it seems there is something in my gtk stack that
converts GTK_STOCK_XXX to the icon theme equivalent, anyway they should
show since I've the Adwaita theme installed.

See the following example to see how gtk-about became help-about

#include 

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

GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(w),
gtk_image_new_from_stock(GTK_STOCK_ABOUT, GTK_ICON_SIZE_LARGE_TOOLBAR));
gtk_widget_show_all(w);
gtk_main();
}


shelob-2 $ grep -r GTK_STOCK_ABOUT /usr/local/gtk/include/gtk-3.0/gtk
/usr/local/gtk/include/gtk-3.0/gtk/deprecated/gtkstock.h: * GTK_STOCK_ABOUT:
/usr/local/gtk/include/gtk-3.0/gtk/deprecated/gtkstock.h:#define
GTK_STOCK_ABOUT((GtkStock)"gtk-about")

shelob-2 $ g++ -o test test.c `pkg-config gtk+-3.0 --cflags --libs`
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated [-Wdeprecated]
test.c:8:34: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
gtk_image_new_from_stock(GTK_STOCK_ABOUT,
GTK_ICON_SIZE_LARGE_TOOLBAR));
 ^
/usr/local/gtk/include/gtk-3.0/gtk/deprecated/gtkstock.h:123:38: note:
expanded from macro 'GTK_STOCK_ABOUT'
#define GTK_STOCK_ABOUT((GtkStock)"gtk-about")
 ^
/usr/local/gtk/include/gtk-3.0/gtk/deprecated/gtkstock.h:105:1: note:
'GtkStock' has been explicitly marked deprecated here
G_DEPRECATED
^
/usr/local/gtk/include/glib-2.0/glib/gmacros.h:432:37: note: expanded from
macro 'G_DEPRECATED'
#define G_DEPRECATED __attribute__((__deprecated__))
^
test.c:8:9: warning: 'gtk_image_new_from_stock' is deprecated
[-Wdeprecated-declarations]
gtk_image_new_from_stock(GTK_STOCK_ABOUT,
GTK_ICON_SIZE_LARGE_TOOLBAR));
^
/usr/local/gtk/include/gtk-3.0/gtk/gtkimage.h:121:1: note:
'gtk_image_new_from_stock' has been explicitly marked deprecated here
GDK_DEPRECATED_IN_3_10_FOR(gtk_image_new_from_icon_name)
^
/usr/local/gtk/include/gtk-3.0/gdk/gdkversionmacros.h:329:47: note:
expanded from macro 'GDK_DEPRECATED_IN_3_10_FOR'
# define GDK_DEPRECATED_IN_3_10_FOR(f)GDK_DEPRECATED_FOR(f)
  ^
/usr/local/gtk/include/gtk-3.0/gdk/gdkversionmacros.h:49:31: note: expanded
from macro 'GDK_DEPRECATED_FOR'
#define GDK_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GDK_EXTERN
  ^
/usr/local/gtk/include/glib-2.0/glib/gmacros.h:444:29: note: expanded from
macro 'G_DEPRECATED_FOR'
#define G_DEPRECATED_FOR(f) G_DEPRECATED
^
/usr/local/gtk/include/glib-2.0/glib/gmacros.h:432:37: note: expanded from
macro 'G_DEPRECATED'
#define G_DEPRECATED __attribute__((__deprecated__))
^
2 warnings generated.

shelob-2 $ ./test

(process:77229): Gtk-WARNING **: 14:28:48.629: Locale not supported by C
library.
Using the fallback 'C' locale.

(test:77229): Gtk-WARNING **: 14:28:49.162: Could not find the icon
'help-about'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases

(test:77229): Gtk-WARNING **: 14:28:49.162: Error loading theme icon
'help-about' for stock: Icon 'help-about' not present in theme Adwaita

 --
Ciao,
 Gabry

-- 


Le informazioni contenute nella presente comunicazione e i relativi 
allegati possono essere riservate e sono, comunque, destinate 
esclusivamente alle persone o alla Società sopraindicati e non sono da 
considerarsi comunicazioni personali, quindi eventuali risposte potranno 
essere conosciute da persone appartenenti all’azienda. La diffusione, 
distribuzione e/o copiatura del documento trasmesso da parte di qualsiasi 
soggetto diverso dal destinatario è proibita ai sensi dell’art. 616 c.p. I 
dati forniti verranno trattati ai sensi dell'art. 13 del Regolamento UE 
2016/679 (normativa sulla privacy). Se ha ricevuto questo messaggio per 
errore Ti preghiamo di distruggerlo e di informarci immediatamente 
contattandoci mandando una mail a priv...@wyscout.com 
. Copia integrale dell’informativa potrà essere 
visionata presso le nostre sedi. 

Any information herein included (even 
any attachments) shall be considered confidential and/or privileged 
material and meant to be only for the abovementioned persons and/or 
Company, therefore such communication is intended to be for the addressee 
only. Such information is not personal, that is why this e-mail and any 
replies may be known exclusively by people belonging to the company. It is 
expressively not allowed communicate, disclose and/or copy any 
documentation transmitted by a person other than the recipient, 

Migrating away from GtkStock stuff

2019-02-07 Thread Gabriele Greco via gtk-app-devel-list
Hi guys,

I'm in the process of migrating a big code base from GTK 2.x to GTK 3.x,
I've done most of the work, but I'm facing now some problems with GTK stock
stuff.

I used stock stuff a lot to reduce the localizable strings needed in my
code and to reduce the number of images to ship.

From what I've seen there are no more stock items in GTK 3 (3.24.2 at the
moment), since they have been deprecated in 3.10.

It's more a removal than a deprecation since my code compiles but the
program seems to fail to find at least the icons pointed by the stock item:

(:75970): Gtk-WARNING **: 12:47:16.541: Error loading theme icon
'document-new' for stock: Icon 'document-new' not present in theme Adwaita
(:75970): Gtk-WARNING **: 12:47:16.598: Error loading theme icon
'document-open' for stock: Icon 'document-open' not present in theme Adwaita
(:75970): Gtk-WARNING **: 12:47:16.599: Error loading theme icon
'document-save' for stock: Icon 'document-save' not present in theme Adwaita
(:75970): Gtk-WARNING **: 12:47:16.599: Error loading theme icon
'edit-find' for stock: Icon 'edit-find' not present in theme Adwaita

There is a stack overflow post that suggests how to handle the migration
from a GtkStock item to a "named icon" or a "gtk localized label":

https://stackoverflow.com/questions/36805505/gtk-stock-is-deprecated-whats-the-alternative

... but what about toolbar or buttons that given the theme may have icons,
labels or both?

-- 
*Bye,*
* Gabry*

-- 


Le informazioni contenute nella presente comunicazione e i relativi 
allegati possono essere riservate e sono, comunque, destinate 
esclusivamente alle persone o alla Società sopraindicati e non sono da 
considerarsi comunicazioni personali, quindi eventuali risposte potranno 
essere conosciute da persone appartenenti all’azienda. La diffusione, 
distribuzione e/o copiatura del documento trasmesso da parte di qualsiasi 
soggetto diverso dal destinatario è proibita ai sensi dell’art. 616 c.p. I 
dati forniti verranno trattati ai sensi dell'art. 13 del Regolamento UE 
2016/679 (normativa sulla privacy). Se ha ricevuto questo messaggio per 
errore Ti preghiamo di distruggerlo e di informarci immediatamente 
contattandoci mandando una mail a priv...@wyscout.com 
. Copia integrale dell’informativa potrà essere 
visionata presso le nostre sedi. 

Any information herein included (even 
any attachments) shall be considered confidential and/or privileged 
material and meant to be only for the abovementioned persons and/or 
Company, therefore such communication is intended to be for the addressee 
only. Such information is not personal, that is why this e-mail and any 
replies may be known exclusively by people belonging to the company. It is 
expressively not allowed communicate, disclose and/or copy any 
documentation transmitted by a person other than the recipient, according 
to the Italian Criminal Code, Section 616 and the Regulation EU 2016/679. 
Your provided data are processed in accordance with Regulation EU 2016/679 
(Data Protection Law), Section 13. A full copy of the relevant information 
notice is available at the company’s registered office upon request. If you 
received this in error, please destroy it and inform us immediately by 
sending an e-mail to the following e-mail address priv...@wyscout.com 
. A full copy of the relevant information 
notice is available at the company’s registered office upon request.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GUI size and translations

2017-04-26 Thread Gabriele Greco
I've recently received the localization strings for my application in a few
languages and I've found that few translations keep the gui minimum size
larger that the screen of many notebook (my target is to make it fit 1280
pixels).

I've not found an easy way to understand what string is causing the
problem, also because I've a 12 pages notebook that is used to display the
various GUI layouts (and one of the 12 may be the culprit of the gui
horizontal grow).

I'm quite new to localization and gettext and I was wondering if there is a
standard way to check for this kind of problems without having to explore
every single mask of the program with every supported language... (actually
I will be already in the order of several hundreds tests...)

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Input event reduction

2017-03-30 Thread Gabriele Greco
>
>
> Thanks. While I can remember have read your explanations somewhere
> already, I really missed that g_main_context_invoke() function.


There is some difference/advantage on calling:

g_main_context_invoke(NULL, func, data)?

instead of

g_idle_add(func, data);

As far as I can see from the function documentations g_main_context_invoke
seems useful when having multiple contexts on different threads, I'm wrong?

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gdk_threads_leave is possible to cause segmentation fault?

2017-03-28 Thread Gabriele Greco
> But  now this functions aren't running. This is my main thread
> void *vGtkMain_Thread(gpointer data)
> {
> gdk_threads_enter();
> gtk_main();
> gdk_threads_leave();
> return NULL;
> }
>

You should remove everywhere in your code gtk_threads_ calls.

You cannot call gtk_label_get_text from a thread different from the gtk
main loop one, get the result of the call and pass it to the thread
function as parameter.

You should take care that the functions you call with g_idle_add() return
FALSE otherwise they will be called every time the main loop is idle using
100% of CPU (this can be a desired behaviour in some circumstances).

You should also take care that the global data you access in
iUpdateConfigNow, gbUpdateStatusNow... is not changed while you are
updating the GUI


-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gdk_threads_leave is possible to cause segmentation fault?

2017-03-28 Thread Gabriele Greco
>
>
> In gdk manual i see thath gdk_threads_enter and leave has been
> deprecated and alll gdk and gtk+ calls should be made from main thread.
> How we do this? Someone have any example?
>
> You have to call g_idle_add (that is thread safe) every time you need to
update one or more widgets from an external thread.

Let's think about a common situation, for instance you are encoding a video
file and you want to update a progress bar:

[from encoding thread]
struct progress {
char label[50];
float value;
};

myprg = malloc(sizeof(struct progress));
myprg->value = 75.0;
strncpy(myprg->label, "Second pass", sizeof(myprg->label));
g_idle_add((GCallback)progress_update, myprg);

gboolean progress_update(struct progress *p);
{
 gtk_progress_bar_set_text(p->label);
 gtk_progress_bar_set_fraction(p->value);
 free(p);
 return FALSE; // it means that you want to run this only once
}

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Fwd: Resize and place a background image (Expose Event)

2017-03-02 Thread Gabriele Greco
>
>
> Now, application crash after start, but i think that is because i make
> the unref of pixbuf, and in next expose event, fails (i think)...
>
> GdkPixbuf-CRITICAL **: gdk_pixbuf_scale_simple: assertion 'GDK_IS_PIXBUF
> (src)' failed


This happens because your original "pixbuf"  is a global object, remove the
first of the three _unref and you should be fine!

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Fwd: Resize and place a background image (Expose Event)

2017-03-02 Thread Gabriele Greco
>
> This works, but application blocks after a while..
>

I'm quite sure the problem is that you are leaking at least 2 pixbuf and a
pixmap for every expose event your app receives, and anyway, are you sure
you have to do it every time an expose event is thrown and not only when
the window is resized (configure_event)?


>
>
>  pixbuf = gdk_pixbuf_scale_simple(pixbuf, widget->allocation.width,
>

If the original pixbuf has been created just for this operation, this call
leaks a pixbuf object, you shoud do something like:

GdkPixbuf *scaled = gdk_pixbuf_scale_simple(pixbuf,
widget->allocation.width, [...]
g_object_unref(pixbuf);


> widget->allocation.height, GDK_INTERP_BILINEAR);
>  gdk_pixbuf_render_pixmap_and_mask (pixbuf, , NULL, 0);
>

At this point you leak the second pixbuf, use for instance:
g_object_unref(scaled);


>  style->bg_pixmap[0] = background;
>  gtk_widget_set_style (GTK_WIDGET(widget), GTK_STYLE(style));
>

I'm quite sure set_style will increase reference count for 'background', so
after this call you should unref that pixmap:

g_object_unref(background);

You'll receive runtime errors if one of my statements here is not correct,
it's better to add a not needed unref in development and fix it that
release a version that leaks memory.

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how shoul I solve error "The Procedure entry Point deflateSetHeader could not be located in the Dynamic link: ...\gtk3.6.4\bin\libgio-2.0-0.dll"

2017-01-12 Thread Gabriele Greco
>
>
>
> "The Procedure entry Point deflateSetHeader could not be located in the
> Dynamic link:
> ...\gtk3.6.4\bin\libgio-2.0-0.dll".
>
>
You miss libz dll, I find useful to build win32 environment to use
"depends.exe" (http://www.dependencywalker.com/) to find similar problems.

Please note that you do not need .lib, but only dll since that's not a
direct dependency on your application.

Actually my GTK/curl win32 runtime includes the following dlls...

freebl3.dll icuuc56.dll libfontconfig-1.dll
libglib-2.0-0.dll   libjasper-1.dll libpangowin32-1.0-0.dll
libstdc++-6.dll nssdbm3.dll
icudata56.dll   libatk-1.0-0.dlllibfreetype-6.dll
libgmodule-2.0-0.dlllibjpeg-8.dll   libpixman-1-0.dll
libtasn1-6.dll  nssutil3.dll
icui18n56.dll   libcairo-2.dll  libgailutil-18.dll
 libgobject-2.0-0.dllliblzma-5.dll   libplc4.dll
libtiff-5.dll   smime3.dll
icuio56.dll libcairo-gobject-2.dll  libgcc_s_seh-1.dll
 libgpg-error6-0.dll libnspr4.dlllibplds4.dll
 libwinpthread-1.dll softokn3.dll
icule56.dll libcrypto-10.dlllibgcrypt-20.dll
 libgtk-win32-2.0-0.dll  libp11-kit-0.dlllibpng16-16.dll
libxml2-2.dll   ssl3.dll
iculx56.dll libcurl-4.dll   libgdk-win32-2.0-0.dll
 libharfbuzz-0.dll   libpango-1.0-0.dll  libsqlite3-0.dll
 libxslt-1.dll   zlib1.dll
icutest56.dll   libexpat-1.dll  libgdk_pixbuf-2.0-0.dll
libidn-11.dll   libpangocairo-1.0-0.dll libssh2-1.dll
nss3.dll
icutu56.dll libffi-6.dlllibgio-2.0-0.dll
 libintl-8.dll   libpangoft2-1.0-0.dll   libssl-10.dll
nssckbi.dll

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GTK+ 2 and prelight

2016-11-15 Thread Gabriele Greco
... still trying to build from a graphics designer mockup :)

There is a way to override the .gtkrc-2.0 file to avoid button prelight
state?

I want the some widgets (mostly toggle buttons) to keep their actual state
(normal or active) also if the cursor is on them.

It's a functional behaviour, not only aesthetics since a toggle button in
prelight state can be both active or not, but you can't see its state until
you move the mouse pointer...

Thanks in advance!

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkEntry placeholder in GTK2

2016-11-14 Thread Gabriele Greco
Hello,

I know GTK 3.2+ has a nice gtk_entry_set_placeholder_text() method, but I'm
wondering if there is some clever method to do something similar with GTK2,
I've not found anything googling around, but placeholder texts are a so
common interface concept today that I doubt that someone has not yet
"emulated" it in gtk2...

If no one has already done it, I think this could work:

- initialize the widget with placeholder text
- set a user data on the widget telling the text is placeholder
- set the color of the foreground text for this text widget to gray
- add a focus in event and a on change event on the widget
- if focus in and user data == placeholder, erase the text, save it in
another user data, remove the custom style from the gtkentry
- if on changed and result text empty reload the placeholder text and
switch the style
- if on changed and previous text was empty clear the placeholder text and
switch the style

I wonder if this can work... I can also build a subclass string with this
behaviour since I need this in a few different places :(

-- 
*Bye,*
* Gabry*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: final gtk+maverick battles

2014-02-14 Thread Gabriele Greco


 barely compiled gcc 4.8.2 (make install first failed, then, after
 ldconfig, it succeeded)

 The upgraded gcc doesn't seem to have an effect on my gtk+ woes. (!)
 :-((   (unless make is still using the old gcc, but I don't see an
 indication of that)

 Same /bin/sh: --: invalid option error with the git source, but with a
 cleanly unpacked tarball I get a different error :

 http://www.flight.us//misc/gtk_compile_error2.txt



Have you tried with the John Rails scripts?

GTK on MacOSX requires a few dependencies to build and those script
download them all and build them with clang default compiler without too
many issues.

https://wiki.gnome.org/action/show//Projects/GTK+/OSX/Building

-- 
Bye,
 Gabry
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: ScrolledWindow, DrawingArea, and setting step-increment

2013-11-13 Thread Gabriele Greco

 Hmm. I used to have something using that, in one of the early tests,
 but there was either a critical performance problem, or something I
 couldn't do with it. Can that handle mark-and-copy, clickable URLs,
 and so on? Or possibly it's that you say thousands there; to me,
 thousands of lines is just barely getting started. My current session


Mark  copy and clickable urls are supported in the code example I sent you.

About the thousands...

I've not done specific benchmarks but I used to keep a scrollback of 5
lines in my old powerbook 800mhz without slowdowns.


 in Gypsum has barely started and I already have 50K lines; my RosMud
 session currently has 300K lines of scrollback; and I've noted as an
 unsolvable RosMud bug that it's unacceptably slow adding the
 16,777,216th line to the buffer (because it does a naive

 I think that so many lines may be a problem for GtkTextBuffer, I mean,
they are also a problem for an editor like vim :)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: ScrolledWindow, DrawingArea, and setting step-increment

2013-11-12 Thread Gabriele Greco

 I'm developing a MUD client in Pike, using GTK2 for the UI, and
 there's an aspect of scrolling that's bugging me. The display uses
 discrete lines of text of a fixed height (or, to be more technically
 accurate, a fixed distance from the start of one line to the start of
 the next), and I'd really like the scrolling to be done in lines


I suggest you to use GtkTextView for your text output, thank to GtkTextTag
it's flexible enough to do everything a mud client needs, also blinking
text, it scrolls at line boundaries and let you keep thousands of lines of
textbuffer without slowdowns.

For an example of ANSI16 parser/output with GtkTextView using GTK2 you can
look at my own mud client ( source
http://sourceforge.net/p/ggmud/code/HEAD/tree/trunk/ggmud/ ).

I think most of the code you may be interested in is in ansi.c  window. c.

--
Bye,
 Gabry
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GTK2 + SDL2 (partial fail)

2012-12-13 Thread Gabriele Greco
I've a SDL that on linux uses a gtk2 file chooser, I've just migrated it to
SDL2 and I'm finding a strange problem connected with the initialization
order of the two libraries:

SDL_Init - gtk_init - OK

gtk_init - SDL_Init - CRASH

Here is a simple program that trigger this behaviour:

#include gtk/gtk.h
#include SDL.h

int main(int argc, char *argv[]) {
// swap SDL_Init and gtk_init to make it work
gtk_init(argc, argv);
if (SDL_Init(SDL_INIT_VIDEO )  0)  return -1;

GtkWidget *dialog = gtk_file_chooser_dialog_new (Test, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);

if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
(dialog));
fprintf(stderr, Selected %s\n, filename);
g_free (filename);
}
}

Compile it with:
gcc -g -o gtksdl gtksdl.c `pkg-config --cflags --libs gtk+-2.0 sdl2`



Here is the GDB stack trace (crashes inside gtk_dialog_run() ):

Program received signal SIGSEGV, Segmentation fault.
__pthread_mutex_lock (mutex=0x656c7974) at pthread_mutex_lock.c:50
50 pthread_mutex_lock.c: No such file or directory.
(gdb) bt
#0  __pthread_mutex_lock (mutex=0x656c7974) at pthread_mutex_lock.c:50
#1  0x00a7b94d in ?? () from /usr/lib/i386-linux-gnu/libX11.so.6
#2  0x00a96b40 in XrmQGetResource () from
/usr/lib/i386-linux-gnu/libX11.so.6
#3  0x00a72003 in XGetDefault () from /usr/lib/i386-linux-gnu/libX11.so.6
#4  0x00c4b64f in ?? () from /usr/lib/i386-linux-gnu/libcairo.so.2
#5  0x00c4d6da in ?? () from /usr/lib/i386-linux-gnu/libcairo.so.2
#6  0x00c1a8a6 in cairo_surface_get_font_options () from
/usr/lib/i386-linux-gnu/libcairo.so.2
#7  0x00bd951c in ?? () from /usr/lib/i386-linux-gnu/libcairo.so.2
#8  0x00bde00a in ?? () from /usr/lib/i386-linux-gnu/libcairo.so.2
#9  0x00bce05e in cairo_show_glyphs () from
/usr/lib/i386-linux-gnu/libcairo.so.2
#10 0x00a51141 in ?? () from /usr/lib/i386-linux-gnu/libpangocairo-1.0.so.0
#11 0x00a51494 in ?? () from /usr/lib/i386-linux-gnu/libpangocairo-1.0.so.0
#12 0x00e8e2fe in pango_renderer_draw_glyphs () from
/usr/lib/i386-linux-gnu/libpango-1.0.so.0
#13 0x00a517f4 in ?? () from /usr/lib/i386-linux-gnu/libpangocairo-1.0.so.0
#14 0x009bf4d3 in ?? () from /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0
#15 0x00e8e2fe in pango_renderer_draw_glyphs () from
/usr/lib/i386-linux-gnu/libpango-1.0.so.0
#16 0x00e8e3f6 in pango_renderer_draw_glyph_item () from
/usr/lib/i386-linux-gnu/libpango-1.0.so.0
#17 0x00e8f027 in pango_renderer_draw_layout_line () from
/usr/lib/i386-linux-gnu/libpango-1.0.so.0
#18 0x00e8f1aa in pango_renderer_draw_layout () from
/usr/lib/i386-linux-gnu/libpango-1.0.so.0
#19 0x009c060b in gdk_draw_layout_with_colors () from
/usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0
#20 0x009c08b8 in gdk_draw_layout () from
/usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0
#21 0x012590bd in ?? () from
/usr/lib/i386-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
#22 0x00303317 in gtk_paint_layout () from
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#23 0x0025ea64 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#24 0x0026b8a2 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#25 0x005a72fd in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#26 0x005a83d2 in g_closure_invoke () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#27 0x005ba70d in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#28 0x005c1ff5 in g_signal_emit_valist () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#29 0x005c2453 in g_signal_emit () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#30 0x003a5413 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#31 0x001deeb8 in gtk_container_propagate_expose () from
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#32 0x001deee0 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#33 0x0019f4ad in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#34 0x001dd537 in gtk_container_forall () from
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#35 0x001dd782 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#36 0x0026b8a2 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#37 0x005a72fd in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#38 0x005a83d2 in g_closure_invoke () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#39 0x005ba70d in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#40 0x005c1ff5 in g_signal_emit_valist () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#41 0x005c2453 in g_signal_emit () from
/usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#42 0x003a5413 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#43 0x001deeb8 in gtk_container_propagate_expose () from
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#44 0x001deee0 in ?? () from /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0
#45 0x001a236b in ?? () from 

Re: Re: DLL Hell on Windows..

2012-08-06 Thread Gabriele Greco
 I have wondered why we use dlls on windows, we should link statically to
 the libraries.


I think the main reason is to make easier for app developer to be LGPL
compliant.

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0100980150  Fax: +39-0100980184
s-mail: Piazza Della Vittoria 9/3 - 16121 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: need help with final callback

2012-07-19 Thread Gabriele Greco
Guys, I need your help with the last piece of my
 voice-by-computer program.  the appended section compiles to
 the binary xD that lets the user choose the gender,
 word-per-minute speed, delay-between-words, and pitch of th
 e voice.  Without this 'option' the user would type hello
 and hit enter, a male voice would sound thru the speakers.


I don't understand what is the object of your help request.

Your program seems to work.

Do you need to add a text entry to it so that you can write inside it and
call an external program to render the speech?

Do you want to integrate your speech system system-wide?

-- 
Bye,
 Gabry
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK 2.24.10 memory leak on win32?

2012-07-03 Thread Gabriele Greco
 code (that I think is correct) do not leak in linux (ubuntu 12.04, gtk
  2.24.10) nor on win32 (GTK 2.16) while it leaks about 12kbyte/sec with
 GTK
  2.24.10 on win32.
 G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck
 --num-callers=32 src/your-binary


I had already tested there was no leak in linux (same gtk version 2.24.10),
with ps hat is not that accurate in the short term, but if you let your
program run a pair of hours and both VSZ and RSS do not change I think it's
accurate enough.

Anyway I ran valgrind (without suppress file) for a pair of minutes and I
got a positive result (at least I think):

==11727== HEAP SUMMARY:
==11727== in use at exit: 320,761 bytes in 5,570 blocks
==11727==   total heap usage: 72,767 allocs, 67,197 frees, 3,161,964 bytes
allocated
==11727==
==11727== LEAK SUMMARY:
==11727==definitely lost: 0 bytes in 0 blocks
==11727==indirectly lost: 0 bytes in 0 blocks
==11727==  possibly lost: 9,848 bytes in 309 blocks
==11727==still reachable: 310,913 bytes in 5,261 blocks

... on win32 with gtk 2.24.10 (20120208 bundle from gtk.org) the program
leaks about 10kb per sec, and as I said there is no leak also on win32 with
2.16.6 (20100207 bundle from gtk.org)

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0100980150  Fax: +39-0100980184
s-mail: Piazza Della Vittoria 9/3 - 16121 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK 2.24.10 memory leak on win32?

2012-07-03 Thread Gabriele Greco

 ... on win32 with gtk 2.24.10 (20120208 bundle from gtk.org) the program
 leaks about 10kb per sec, and as I said there is no leak also on win32 with
 2.16.6 (20100207 bundle from gtk.org)


Filed bug 679312 https://bugzilla.gnome.org/show_bug.cgi?id=679312

-- 
Bye,
 Gabry
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GTK 2.24.10 memory leak on win32?

2012-07-03 Thread Gabriele Greco
Your code looks a bit strange, but I agree it should work with no
 leaks. Probably a bug.


In the real code there are 1 to X (up to 12) GdkImage(s) that are semaphore
protected and filled by h264 decoders in different threads. Once the thread
fills his  GdkImage with the frame data it uses g_idle_add() to signal the
GUI thread that the associated GdkDrawingArea has to be redraw, the idle
function simply queue the draw of the widget and the expose event locks the
gdkimage and do the real drawing.

This works quite smoothly (25fps) with twelve 352x288 video inputs on any
dual core PC .

I pulled out all the threaded logic and made an example as simple as
possible to trigger the problem, actually I could also remove the drawing
itself, but it was useful to see that the program was not hung :)

-- 
Bye,
 Gabry
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GTK 2.24.10 memory leak on win32?

2012-07-02 Thread Gabriele Greco
We have found a regression that block us to migrate our existing apps from
GTK 2.16.x to GTK 2.24.10 (20120208), it seems there is a memory leak in
g_idle_add() use or something related to queue_draw(), anyway the following
code (that I think is correct) do not leak in linux (ubuntu 12.04, gtk
2.24.10) nor on win32 (GTK 2.16) while it leaks about 12kbyte/sec with GTK
2.24.10 on win32.

I'm posting the code here before creating a bugzilla entry for it since I'm
not sure I can use g_idle_add to notify a new frame is available without
freeing the source, that works in linux and in older WIN32 versions and it
seems correct since g_idle_add() documentation says:

*If the function returns FALSE it is automatically removed from the list of
event sources and will not be called again.*

The (real) code is a video player with multiple realtime streams, this code
use g_timeout_add() to simulate the 25fps of the video, I fill the drawing
area with a simple red/blue pattern without thinking to much to endianness
of the pixel components, but this is a sample, the code leaks on
win32/2.24.10 also if I do not draw inside the GdkImage...

Anyway here is the code, as short as I could make it :)

#include gtk/gtk.h
#include stdint.h

double last_update;
GtkWidget *dest;
GdkImage *img;
GdkGC *gc;
int frames = 0;

int queue_draw() {
gtk_widget_queue_draw(dest);
return FALSE;
}

double get_timer() {
GTimeVal now;
g_get_current_time(now);
return  (double)now.tv_sec + ((double)now.tv_usec / 100.0f);
}

void on_expose() {
gdk_draw_image(dest-window, gc, img, 0, 0, 0, 0, img-width,
img-height);
frames++;
}

int draw_func() {
static int pos = 0;
uint32_t *ptr = (uint32_t *)img-mem;
int x, y;
for (x = 0; x  img-width; ++x) {
for (y = 0; y  pos; ++y)
ptr[x + y * img-width] = 0xff;
for (y = pos; y  pos + (img-height / 2)  y  img-height; ++y)
ptr[x + y * img-width] = 0x00ff;
for (y = pos + img-height / 2 ; y  img-height; ++y)
ptr[x + y * img-width] = 0xff;
}

g_idle_add((GSourceFunc)queue_draw, NULL);
if (++pos = img-height)
pos = 0;

return TRUE;
}


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

GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
dest = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(w), dest);
gtk_widget_set_usize(dest, 352, 288);
g_signal_connect(dest, expose-event, on_expose, NULL);
gtk_widget_set_app_paintable(w, TRUE);
gtk_widget_set_double_buffered(w, FALSE);
gtk_widget_show_all(w);
last_update = get_timer();
double secs = get_timer();
img =  gdk_image_new(GDK_IMAGE_FASTEST, gdk_visual_get_system(), 352,
288);
gc = gdk_gc_new(w-window);

g_signal_connect(w, delete-event, (GCallback)gtk_main_quit, NULL);
g_timeout_add(40, (GSourceFunc)draw_func, NULL);
gtk_main();

secs = get_timer() - secs;
g_printf(%d frames in %f seconds, %f fps\n, frames, secs,
(double)frames / secs);
}

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0100980150  Fax: +39-0100980184
s-mail: Piazza Della Vittoria 9/3 - 16121 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Can I develop gtk app in Mac OS X ?

2011-12-02 Thread Gabriele Greco


  Here is a starting point to install GTK on OSX:
 
  http://live.gnome.org/GTK%2B/OSX/

 And  It can running separately from X in OSX?


YES, the build documentation I pointed to is for the native (Quartz)
version of GTK, that works quite well (still has some minor bugs here and
there).

You can also bundle GTK libraries inside an OSX .app with the
gtk-mac-bundler.


The X11 version of GTK can be easily installed from fink or macports, but
it needs an X11 server running on your machine and it's not friendly at all
if you want to create an application you want to share with someone.

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


Re: GTK+ 2.24.8

2011-11-11 Thread Gabriele Greco
  http://download.gnome.org/sources/gtk+/2.24/
  ftp://ftp.gnome.org/pub/GNOME/sources/gtk+/2.24/
 * Win32 updates:
  Major update of the win32 backend, it now works
  at least as well as the old 2.16.x version that
  a lot of windows applications was forced to use


Anyone has a prebuilt package with all the dependencies like the 2.16 and
2.24.0 bundles available in the gtk.org website or a cross-build script to
build them through mingw32, I'd like to try my various win32 projects, all
stuck at 2.16.x, with 2.24.8 but I have no time frame at the moment to
build everything from scratch :(

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


Tooltip in GtkComboBox

2011-06-08 Thread Gabriele Greco
Is possibile to assign different tooltips to the various elements in the
GtkListStore associated to a GtkComboBox?

I've added to the model a column with the tooltip but it seems GtkComboBox
do not have the API GtkTreeView has to do
this (gtk_tree_view_set_tooltip_column), nor anything similar...

I cannot find any hint about how to do this looking at the properties of the
objects involved (GtkComboBox, GtkTreeViewColumn, GtkCellRendererText and
GtkListStore)

I obviously googled for an answer before posting, without luck...

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


g_idle_add source memory leaks

2011-05-09 Thread Gabriele Greco
If I use g_idle_add to send to my main thread that does the GTK rendering
some notifications I have to free the source handle that the function
returns to me every time or not to avoid a memory leak?

Here is a simple code example, that seems not to leak on linux (ps gives
constant resource occupation, gtk 2.22), but it seems to leak on win32 (task
manager mem usage grows, gtk 2.16):

#include gtk/gtk.h

GtkLabel *l;

int mycbk(int val)
{
char buffer[16];
sprintf(buffer, %09d, val);
gtk_label_set_text(l, buffer);
return FALSE;
}

void threadfunc(void *unused) {
int msec = 0;
while (1) {
msec++;
g_usleep(1000);
g_idle_add((GSourceFunc)mycbk, (void *)msec);
}
}

int main(int argc, char *argv[]){
GtkWidget *w;
g_thread_init(NULL);
gtk_init(argc, argv);

g_thread_create((GThreadFunc)threadfunc, NULL, TRUE, NULL);
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
l = GTK_LABEL(gtk_label_new(-));
gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(l));
gtk_widget_show_all(w);
gtk_main();
return 0;
}


-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Horizontal TreeView?

2011-02-08 Thread Gabriele Greco
There is a way to populate a GtkTreeView so that it grows horizontally?

I want to setup cell columns so that physically they are ROWS of the
GtkTreeView and obviously in a fixed number and to make the list grow
horizontally as long as I add elements to my GtkListStore.

I've looked in the GtkTreeView documentation but I didn't find anything that
hints that this is possible (something like
gtk_tree_view_set_orientation(widget, GtkOrientation) would be optimal :) ),
but I wonder if it's possible at rc/style level since GTK already support
right/left or top/bottom writing styles maybe it also can support
left-right lists :)

Otherwise I fear I'll have to build a custom widget, or try to see if adding
widgets that rapresent my elements inside a GtkHBox within a
GtkScrollingWindow is good looking enough :)

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Horizontal TreeView?

2011-02-08 Thread Gabriele Greco
On Tue, Feb 8, 2011 at 2:55 PM, Costin Chirvasuta cost...@gmail.com wrote:

 Would GtkIconView be suitable?


It seems that GtkIconView suffers from the same problems of GtkTreeView, it
grows only vertically, it has gtk_icon_view_set_columns(), but it doesn't
have gtk_icon_view_set_rows(), so when u add items they are arranged
vertically... also if u configure your scrolling window to resize only
horizontally...

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: which gtk-win32 version to use?

2010-09-30 Thread Gabriele Greco
On Tue, Sep 28, 2010 at 2:50 PM, Manu manutm...@gmail.com wrote:



 Thanks. I have just installed gdb for mingw.


Another thing that helps to catch problems that you cannot reproduce easily
is Dr.Mingw, you can find it in the mingw-utils package. It's a crash
handler to be installed on the windows machine.

If you compile your source code with -gstabs debug symbols is able to show
you the stack trace of your program when it crashes.

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


Re: GTK deadlock in gtk_main

2010-08-04 Thread Gabriele Greco
2010/8/3 Tomas Soltys tomas.sol...@range-software.com

 All right, so at the end it was my bug :)

 Thank you all for your explanations.


Note also that part of the magic of gdk_threads_enter/leave that you can use
on unix to use gtk functions in subthreads does not work on win32 (and also
on OSX).

I had really some bad headaches trying to use it in a cross platform way
then I gave up and redesigned the application to use a lot of small idle
functions executed when needed (returning false they are executed only
once, and you can queue multiple idle functions also from different threads
in a safe way since the idle function queue is protected by a lock) from the
subthreads to update the GUI so that every GTK function is called on the
main thread. This works quite well and does not require locking at all.

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


From GdkPixbuf to GdkImage

2010-07-21 Thread Gabriele Greco
As subject says, what is the correct way to blit from a GdkPixbuf to a
GdkImage without passing through a drawable?

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


Re: From GdkPixbuf to GdkImage

2010-07-21 Thread Gabriele Greco
 On 07/21/2010 04:18 PM, Gabriele Greco wrote:
  As subject says, what is the correct way to blit from a GdkPixbuf to a
  GdkImage without passing through a drawable?
 I *know* you asked for GdkImage.
 That I do not know. My usage has been from GdkPixbuf to GtkImage -- Hope
 this
 might help...


Sadly it does not, the operation should be done in memory without any widget
affected, blitting to gtkimage probabily requires a realized widget and a
flush operation that I need to avoid.

The problem I have is that I have to update my gdkimage (allocated with the
FASTEST method) in a way that is blitted on a GtkDrawingArea at every expose
event.

Usually this gdkimage is composed with a YUV (4:2:0) - RGB conversion, but
when the video is not available I want to blit a video unavailable image
instead of the actual black image.

I can read the byte by byte the source gdkpixbuf and copy them on my
gdkimage, but this will require different code paths cause I don't know the
pixel format of the gdkimage in advance.

It's strange that GDK does not provide a method to do this since it already
provides method to blit gdkpixbufs to every other client or server type of
bitmap objects :)

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


Re: Setting a Tree View Cell to insensitive and uneditable

2010-04-19 Thread Gabriele Greco


 Is it possible to set a cell in a specific column and row to insensitive
 and uneditable and not affect the rest of the cells in the same column?


Yes, you should change your TreeModel to have two additional boolean columns
to map the sensitive and editable boolean field for your TreeViewColumn,
something like (let's get the simple case of a single editable text field):


mymodel = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);

gtk_list_store_set(mymodel, it, 0, Editable Cell, 1, TRUE, 2, TRUE, -1);
gtk_list_store_set(mymodel, it, 0, Not editable Cell, 1, TRUE, 2, FALSE,
-1);
gtk_list_store_set(mymodel, it, 0, Insensitive Cell, 1, FALSE, 2, FALSE
/*may be also true*/, -1);

gtk_tree_view_insert_column_with_attributes(mytreeview, -1,
My column title, r, markup, 0, sensitive, 1,
editable, 2,
NULL);

I've written not the full code but just the lines that should differ from
your actual implementation :)

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


gtk_builder_add_from_file error handling

2010-01-13 Thread Gabriele Greco
I just found that with a builder file with a syntax error my app crashed
with:

*** glibc detected *** ./packager: double free or corruption (out):
0x09aa33d0 ***

I think I'm using gtkbuilder error handling in the right way and
documentation does not suggest my how to use it:

GError *err = NULL;
if (!gtk_builder_add_from_file(builder_, myfile.xml, erro)) {

}

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk_builder_add_from_file error handling

2010-01-13 Thread Gabriele Greco
Sorry last message was sent by accident pushing an hotkey while editing...

This should be the complete version of my question:


I just found that with a builder file with a syntax error my app crashed
with:

*** glibc detected *** ./packager: double free or corruption (out):
0x09aa33d0 ***

I think I'm using gtkbuilder error handling in the right way and
documentation does not suggest my how to use it:

GError *err = NULL;
if (!gtk_builder_add_from_file(builder_, myfile.xml, err)) {
   if (err) {
  cerr  builder load fail:   err-message  '\n';
  g_free(err); // commenting this solves the crash but other gtk apis
  // and examples I've found always free error handling
pointers
   }
   else
  cerr  builder load fail, unknown error\n;

   return false;
}

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


Re: gtk_builder_add_from_file error handling

2010-01-13 Thread Gabriele Greco
 GError *err = NULL;
  if (!gtk_builder_add_from_file(builder_, myfile.xml, err)) {
 if (err) {
g_free(err); // commenting this solves the crash but other gtk apis

 I don't know gtkmm, but at least in C GErrors are freed with
 g_error_free(err).


You are obviously right. I always used g_free() to free errors, my fault.
I've grepped tons of sources and I had everywhere the code bugged, then I
googled around to search some more examples and I've found there are a lot
of other sources in the net where a GError is freed with g_free, I think
improving the documentation of the functions that use a GError as input
parameter may help programmers do not write wrong code in this situation.

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


Re: gtk_builder_add_from_file error handling

2010-01-13 Thread Gabriele Greco


 The proper handling of GErrors is described in great detail in the
 GError documentation.

 I don't think it is reasonable to explain this in the documentation of
 every function that uses GError to report errors as there are almost 80
 of them just in Gtk+ (and over 400 in GLib, and many more elsewhere).


I think, and I'm used to see in almost every framework documentations, that
every time a function allocates something that the API user must free
himself the documentation should explicitly say so. Documentation should be
redundant when it may cause errors the fact it is not.

This is the case of GError and for
instance gtk_ui_manager_add_ui_from_file/string
and gtk_builder_add_from_file/string.

It's not a case that in UI toolkit debates one of the most common criticism
to GTK is the lack of documentation.

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


Re: GTK+ 2.16.6 released

2009-09-10 Thread Gabriele Greco
On Sat, Aug 29, 2009 at 4:47 PM, Matthias Clasen mcla...@redhat.com wrote:

 GTK+ 2.16.6 is now available for download at:

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


Any chance or problem for the windows binaries on the website/ftp?

I'm too used to update my runtime using the binary bundle that Tor usually
makes available on the website :)

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


Re: GTK+ 2.16.4 released

2009-07-03 Thread Gabriele Greco
On Thu, Jul 2, 2009 at 5:28 PM, Thomas Stover tho...@wsinnovations.comwrote:


 There is some official (like Tor Win32 bundles) or unofficial OSX framework
 released or we have to build from sources?

 Building an OSX universal binary framework compatible with 10.4+ is not
 exactly easy like configure/make :)




 I have some notes from August '08 when I built gtk for osx with the x11
 back end. Let me know if you are interested. Most of the steps should be
 about the same. It was sort of funny in the sense that I have still never
 even used osx in gui mode. A friend set me up a shell account on his osx box
 on our lan, and from there via ssh and no root access, I made it all the way
 to screen shots for a presentation. I was very


Compile an X11 version or also a quartz version in the standard way it's
quite easy, the problem is that u get a ton of libraries for only one
architecture and it's really tough to fit them inside your application
bundle.

What I need are updated frameworks built like the one on www.gtk-osx.org,
that are really outdated (2.14.3).

Yesterday I've lost half of my afternoon trying to make the jhbuild scripts
used to build universal frameworks to work without luck...

The info on http://live.gnome.org/GTK%2B/OSX are not enough, neither are
some other I found googling around...

Maybe most of the problems I have are related to the fact I'm trying to
compile on 10.4.

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


Re: GTK+ 2.16.4 released

2009-07-02 Thread Gabriele Greco
On Thu, Jul 2, 2009 at 12:58 AM, Matthias Clasen mcla...@redhat.com wrote:

 GTK+ 2.16.4 is now available for download at:



About 2.16 releases:

There is some official (like Tor Win32 bundles) or unofficial OSX framework
released or we have to build from sources?

Building an OSX universal binary framework compatible with 10.4+ is not
exactly easy like configure/make :)


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


Re: latest glib and gtk for Windows?

2009-04-21 Thread Gabriele Greco
On Sun, Apr 19, 2009 at 5:53 PM, Tor Lillqvist t...@iki.fi wrote:
 I don't mean to be a pest, but when might glib 2.20.1 and gtk
 2.16.1 become available at
 http://www.gtk.org/download-windows.html ?

 Soon... Been a bit busy with other hackinh.

About this issue, I've been able to build the whole win32 GTK
environment only on WIN32 mingw since all the configure process relies
too much on pkg-config to be usable from a cross-compiler (we usually
build all of our apps on linux with the mingw crosscompiler
distributed with all the debian derived distro).

Anyone has some ./configure lines for the various
glib/cairo/pango/atk/gtk packages to crossbuild them in a clean way
without manual hacking on the generated files? :)

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


Re: latest glib and gtk for Windows?

2009-04-21 Thread Gabriele Greco
On Tue, Apr 21, 2009 at 11:16 AM, Tor Lillqvist t...@iki.fi wrote:
 Soon...

 The binaries are at the usual place
 (http://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/2.16/ etc) but the
 http://www.gtk.org/download-windows.html page has not updated,
 apparently thanks to some missing git hooks or whatever.


Thx, I'm cutting down a runtime package from the bundle.

Just a question:

In the bin directory I can safely remove every binary except:

gspawn-win32-helper-console.exe
gspawn-win32-helper.exe

... if I only need a RUNTIME package, isn't it?

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


Re: GIO channels and connection closed by foreign host on WIN32

2009-03-18 Thread Gabriele Greco
On Tue, Mar 17, 2009 at 6:59 PM, Tor Lillqvist t...@iki.fi wrote:
 (Yes, it might well be that it should be considerd a bug that one on
 Windows has to explicitly watch for G_IO_HUP in addition to G_IO_IN to
 be able to catch EOF. Please file a bug for that.

This change made the trick:

g_io_add_watch(ch, (GIOCondition) G_IO_IN|G_IO_HUP, cbk, NULL);


I filed a bug about this behaviour, 575806, I just replied here to
tell that with G_IO_HUP in the callback also the classic logic

if recv(fd) == 0 then IS DISCONNECT

works.

 The exact intended semantics of the GIOChannel API isn' clearly
 specified IMHO, and even if it was, one can say that it is more
 important that code that de facto does work on Unix should also work
 on Windows, even if strictly speaking the code would not need to work
 even on Unix according to specs... )

Why? The only real problem was the fact the cbk was void.

GIOChannel API give the user a g_io_channel_unix_get_fd() call, so I
suppose it should be supported handling the channel yourself. This is
a very important feature since there are a few network toolkit that
can be made interoperable with GTK through this feature.

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


GIO channels and connection closed by foreign host on WIN32

2009-03-17 Thread Gabriele Greco
I have a problem with the WIN32 port of a project.

I use a GIO channel to wrap the socket, I handle the socket as async
(so in case of error I check for EWOULDBLOCK/EINPROGRESS...), the
program works ok and the callback is called when there is data on the
socket.

The problem I have is that on linux if the connecton is closed from
the foreign host (ctrl + c in a shell with nc -lp 4000 in my basic
tests) the callback is called and recv() returns a 0, so I can detect
the socket is closed.

On WIN32 closing the remote host connection has no effect at all, no
callback is called. I detect the situation only if I send()
something

I thought it was a different behaviour of win32 / linux socket
implementation, so I've built a small program that uses select()
instead of GTK+ to wait for the sockets, and I get a consistent
behaviour both in win32 and linux (select trigger - FD_ISSET sock -
recv sock - returns 0).

I checked the GIO channel documentation but except for the well known
fact that polling a GSource on Win32 put the socket in async mode I
found nothing else...

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


Re: GIO channels and connection closed by foreign host on WIN32

2009-03-17 Thread Gabriele Greco
On Tue, Mar 17, 2009 at 4:26 PM, Tor Lillqvist t...@iki.fi wrote:
 Do you have a minimal but complete sample program that exhibits the problem?

 --tml


Here it is, I've made it as minimal as a crossplatform gtk socket
program can be, the code may give a pair of warnings and passes the fd
as userdata, this is to mimic the real code that passes a class base
pointer that contains also the FD and to specify that the code doesn't
use gio channels API to get FD or read/write.

It compiles both on win32 and linux, command line on linux for both builds:

Linux native:
gcc -o t test.c `pkg-config gtk+-2.0 --cflags --libs`

WIN32 cross:
/usr/i586-mingw32msvc/bin/gcc -o test.exe -gstabs
-I/usr/i586-mingw32msvc//include/glib-2.0
-I/usr/i586-mingw32msvc//lib/glib-2.0/include/
-I/usr/i586-mingw32msvc//include/cairo
-I/usr/i586-mingw32msvc//include/gtk-2.0
-I/usr/i586-mingw32msvc//include/atk-1.0
-I/usr/i586-mingw32msvc//include/pango-1.0
-I/usr/i586-mingw32msvc//lib/gtk-2.0/include -mno-cygwin
-mms-bitfields -DOOGTK_DEBUG socktest.c
-L/usr/i586-mingw32msvc//lib/gtk-2.0 -lgtk-win32-2.0 -lgdk-win32-2.0
-latk-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lpangowin32-1.0 -lgmodule-2.0
-lgobject-2.0 -lgthread-2.0 -lglib-2.0 -luser32 -lws2_32

How to reproduce:
On a linux server machine type (say with address 192.168.1.10):
nc -vlp 4000

On a client machine (if win32 you should run it from a cmd since it
does most of this output on stderr):
test 192.168.1.10 4000

Now type something in the shell where you launched netcat (hello
enter, hi enter...)

You should see the label of the gtk program update.

Last step, the one where the problem is, close netcat with CTRL+C.

If the gtk client is linux it will disconnect.
*** If the gtk client is win32 it will not receive any error ***

Test is done both on win32 and linux with GTK 2.14.x (latest version
before the 2.16 stable).

Source:

#include gtk/gtk.h
#include stdlib.h
#ifdef WIN32
#include winsock2.h
#else
#include sys/socket.h
#include netinet/in.h
#endif

GtkWidget *label;
void cbk(GIOChannel *c, int cond, int fd)
{
char buffer[1024];
int rc = recv(fd, buffer, sizeof(buffer), 0);
if (rc == 0) {
fprintf(stderr, Connection closed\n);
gtk_main_quit();
}
else if (rc  0) {
fprintf(stderr, Error handling removed!\n);
gtk_main_quit();
}
else {
fprintf(stderr, Received %d bytes\n, rc);
buffer[rc] = 0;
gtk_label_set_text(GTK_LABEL(label), buffer);
}
}
int main(int argc, char *argv[])
{
GtkWidget *w;
GIOChannel *ch;
struct sockaddr_in addr;
int fd;
if (argc != 3) {
fprintf(stderr, Use %s host port\n, argv[0]);
exit(0);
}
#ifdef WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD( 2, 0 ), wsaData) != 0) return;
#endif
gtk_init(argc, argv);
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
label = gtk_label_new(NULL);
gtk_container_add(GTK_CONTAINER(w), label);

fd = socket(AF_INET, SOCK_STREAM, 0);
memset((void*)addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(atoi(argv[2]));
addr.sin_addr.s_addr = inet_addr(argv[1]);

if (connect(fd, (struct sockaddr *)addr, sizeof(addr))  0) {
fprintf(stderr, Error in connect to %s/%d!\n, argv[1], atoi(argv[2]));
exit(0);
}
#ifdef WIN32
ch = g_io_channel_win32_new_socket(fd);
#else
ch = g_io_channel_unix_new(fd);
#endif
g_io_add_watch(ch, G_IO_IN, cbk, fd);
gtk_widget_show_all(w);
gtk_main();
}

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


Re: GIO channels and connection closed by foreign host on WIN32

2009-03-17 Thread Gabriele Greco
 Here it is, I've made it as minimal as a crossplatform gtk socket
 program can be, the code may give a pair of warnings and passes the fd
 as userdata, this is to mimic the real code that passes a class base
 pointer that contains also the FD and to specify that the code doesn't
 use gio channels API to get FD or read/write.

BTW if this can be useful:

I've made a modified version of the program that uses GIO functions to
read datas from the server, it also sets the encoding to NULL and
buffering to FALSE since I've seen that is the right way to have a
behaviour similar to a plain recv() and it checks the return code with
G_IO_STATUS_EOF, the result is the same as the bare socket version:

In linux a ctrl+c on the server notify the client that receive
G_IO_STATUS_EOF, in windows it doesn't.

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


Re: Stop text view to scroll on pageup/down (Gabriele Greco)

2008-10-08 Thread Gabriele Greco
On Tue, Oct 7, 2008 at 4:14 PM, Garth's KidStuff
[EMAIL PROTECTED]wrote:

Thanks for the reply!

the scrolledwindow but without results:

g_signal_connect(sw, key-press-event, (GCallback)eat_pageupdown,
 NULL);

 I just asked a very similar question a few days ago on the list and Murray
 was kind enough to point out that I needed to connect my signal *before*
 the
 regular signal handler (as opposed to after, which is the default).  In
 gtkmm, this was easy as the connect function has a parameter for that very
 purpose.  I don't see how to so so here.  Sorry :(


g_signal_connect_before doesn't exists because the documentation of
g_signal_connect says:

Connects a 
GCallbackhttp://library.gnome.org/devel/gobject/2.6/gobject-Closures.html#GCallbackfunction
to a signal for a particular object.

The handler will be called before the default handler of the signal.

As far as I've seen gtkmm there is no connect_before() also there, but there
is a boolean flag after... Anyway it seems that none of the widget
involved (textview, scrolledwindow, verticalscrollbar) receive
key-press-event nor key-release-event so connecting it before or after
the default handler will not change the behaviour...

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


Stop text view to scroll on pageup/down

2008-10-06 Thread Gabriele Greco
I've assigned a global meaning to the PageUp/Down keys in a application and
I catch them with a key snooper. The keys are catched and the action
performed, but if the window contains a textview also the textview contents
are scrolled, so I tried to catch the keys in the textview, and then in
the scrolledwindow but without results:

g_signal_connect(sw, key-press-event, (GCallback)eat_pageupdown,
NULL);
g_signal_connect(tv, key-press-event, (GCallback)eat_pageupdown,
NULL);
g_signal_connect(sw, key-release-event, (GCallback)eat_pageupdown,
NULL);
g_signal_connect(tv, key-release-event, (GCallback)eat_pageupdown,
NULL);

Where eat_pageupdown is:

gboolean eat_pageupdown(GtkWidget  *widget, GdkEventKey *event, gpointer
user_data)
{
return (event-keyval == GDK_Page_Up || event-keyval == GDK_Page_Down);
}

Obviously this doesn't work... So here is my question: what is the correct
way to override the standard paging keys for a TextView?

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


Re: [semi-OT] dependencies libraries

2008-09-01 Thread Gabriele Greco
On Sun, Aug 31, 2008 at 10:46 AM, Brian J. Tarricone [EMAIL PROTECTED]wrote:

  for example: if i develop with gtk 2.12 (but i can do the same
  reasoning with any other library) how can i do to know if i used (or
  not) new functions/classes introduced on that version? (of course
  without look inside library documentation for every function/class
  that i used)

 That's pretty much the only way to do it, looking through the
 documentation.  If you really want to target a specific minimum version
 (say, 2.8), then you should develop against that version.


The autopackage project (www.autopackage.org) distributes a set of OLD gtk
headers/linklibs (I think 2.4, or 2.6 ones), suited to develop GTK+ apps
that runs on the vast majority of linux distro actually deployed.

Linking to them also remove the dependency from cairo. This is important
because if you link to a recent version of GTK (2.8+) also if you take care
to use only 2.0 apis you'll give your program an implicit dependency from
cairo.

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


Re: CellRendererToggle with custom pixbuf?

2008-08-19 Thread Gabriele Greco
On Sun, Aug 17, 2008 at 10:52 PM, Jeffrey Barish
[EMAIL PROTECTED]wrote:

 I am using a CellRendererToggle.  I would like to be able to specify
 pixbufs
 to use to draw the toggle in its two states.  Basically, I want to toggle
 between two images in a TreeView.  When I click on one image, it changes to
 the other.  Is there an easy way to do this?


I think the best way it's to make a GDK_TYPE_PIXBUF column and switch
between the two images attaching an handler to the button_press event and
using gtk_tree_view_get_path_at_pos to find if the image was clicked or
another place in the row to check if you have to switch the image in the
model or not.

I've seen that also pixbuf engine based themes do not allow to change the
aspect of the toggle buttons inside a treeview, so I fear this is the only
way to go.

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


Re: XML and treeviews

2008-07-25 Thread Gabriele Greco
 Couldn't you just add another row in the TreeStore for the closing tag?
 If root is 0 and node is 0:0, then inserting a row after node
 with parent root would be 0:1.


The problem doing it in this way is that I've to attach an handler to every
collapse/expand event and I've to show/hide a line for each of those events,
I can do it but I thought there was a cleaner solution like an attribute of
the CellRenderer to change the indent level of a given column item.


-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240 Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Getting a Column Number

2008-07-16 Thread Gabriele Greco

 How do you get the column number from a GtkTreeViewColumn pointer?  Is
 there a way to get the previous and/or next Column or column number?



Use  gtk_tree_view_get_columns() to get a GList of all the column and check
the pointer of focus_column against the GList with g_list_index(), this will
return your column number.

You can also add the column number as data to your GtkTreeViewColumn objects
with something like:

g_object_set_data(column, colnum, GINT_TO_POINTER(X))

when you create the columns...

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


Re: Using g_signal_connect in class

2008-07-15 Thread Gabriele Greco
On Tue, Jul 15, 2008 at 12:09 PM, Marco Rocco [EMAIL PROTECTED] wrote:

 Hello, this is my first post on this mailing list, now i do my request:
 can i use g_signal_connect  in a method of my class, using as c_handler a
 private function of class? ...and if i can, how i can do ?


If you use C++ and plain GTK, supposing you are initializing your callback
in the  you should do something like this:

class MyClass
{
  GtkWidget *mywidget_;
  static void handle_click_cbk(GtkWidget *mywidget_, MyClass *data) {
data-handle_click(); }

  void handle_click(); // your real callback
public:
  MyClass() {
 mywidget_ = gtk_button_new();
 g_signal_connect(mywidget_, clicked, GCallback(handle_click_cbk),
this);
  }
};

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


Trimming GTK+ win32 runtime

2008-07-09 Thread Gabriele Greco
I'm trying to trim down GTK runtime to the minimum possible.

I've read a Tor mail in this list of a month ago about this topic and
applied its suggestions.

My starting point was the bundle.

- all the documentation, all the headers, all the link libraries, all the
translations...
- all immodules except im-ime.dll (can I remove also that one?),  I've
updated the relative index file.
- the pixbuf loaders I don't use and I've updated the relative file.
- the pangoft2 dll.
- all executables in bin except gspawn-win32-*.exe
- charset.alias (was empty)

I tried also to strip the .dlls with mingw strip tool but the application
didn't run after that!

My application SEEMS to work this way, my question is this kind of trimmed
down runtime can be considered enough generic to be used on other western
languages only applications (except for the missing translations of course)

Anyway the runtime size bzipped is about 3.5mb this way.

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


Re: Forking from Gtk

2008-07-08 Thread Gabriele Greco
On Mon, Jul 7, 2008 at 11:03 PM, G Hasse [EMAIL PROTECTED] wrote:

 Hello,

 I have a small demo app. This works on FreeBSD but I can't
 get to work on Linux. I know that in Linux setsid will fail
 if the child has the same session_id as the parent. So on
 Linux you must fork twice. But it also seems that the parent
 must do an exit. And I don't want that. The code is not very
 long - so I include it here.



I think you should avoid fork and use one of the functions glib provide to
spawn processes (
http://library.gnome.org/devel/glib/stable/glib-Spawning-Processes.html), or
a thread if you need to simply call a function.

In general using fork() in a GUI program is a bad idea.


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


About GTK 2.13.x window redirection

2008-05-30 Thread Gabriele Greco
I've read with much interest the new features of the unstable branch, will
the window redirection feature allow to use GTK+ to render to offscreen
bitmaps?

This will allow a quite easy GTK+ deployment on top of OpenGL, that will be
a very useful feature...

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


Re: How to make a gtktreeview column flexible?

2008-04-28 Thread Gabriele Greco

 How do i make the column always use a much space as possible but never
 more than available?



You have to call the following function:

gtk_tree_view_column_set_expand(your_column, TRUE);

Maybe you'll have also to call:

gtk_tree_view_column_set_fixed_width (column, width);

or

gtk_tree_view_column_set_expand(column, FALSE);

... for the other columns.

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: image update

2008-04-23 Thread Gabriele Greco
  I am working in images with pifbuf and gtkimage. I want draw other
  image using the composite method. The problem is when use this method
  the pifbuf don´t update well.
 
 Solved making the widget visible to false and after making the visible
 true.
 a better method?


 What is the type of widget you are rendering to?

If it's a drawing area (and I think it's the best suited one for this kind
of stuff) you should do your drawing inside an expose event handler.

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


function parameters not const

2008-04-15 Thread Gabriele Greco
There is a reason for functions like:

gtk_tree_store_iter_depth, gtk_tree_store_iter_is_valid,
gtk_list_store_iter_is_valid

[large part of all the iterator related api, mostly for GtkTreeIter type]

does not use a const GtkTreeIter * but a simple GtkTreeIter *?

In C programs is almost the same but for C++ programmers and compilers in
general specifying const where it's correct to do so will be very useful,
and AFAIK in a few API functions this has been already done (most
GtkTextIter related API have their prototypes using const where possible).

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


Re: Gtk::ProgressBar doesn't work synchronously

2008-04-09 Thread Gabriele Greco
 Start a complex task
 Create a Progress Monitor dialog and show it
 Update the dialog as the task progresses
 Destroy the dialog


Every time you update the dialog (or also more often if you can) you should
do something like:

while (gtk_events_pending())
   gtk_main_iteration();

To let GTK update the interface.

GTK runs only when you give the control to gtk_main() or if you give him
some space with gtk_main_iteration() :)

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


Re: Video overlay problem

2008-04-04 Thread Gabriele Greco
On 3/30/08, Colm Aengus Murphy [EMAIL PROTECTED] wrote:


 It looks like the video is being overlayed over all tabs.
 The only widget that it doesn't get overlayed on is a gtktextview widget.

 Any ideas on how I can ensure the video is only ever seen in its own tab ?


Add a GtkEventBox to the other tabs where the video should not be seen.

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


Re: GTK from assembly

2008-03-27 Thread Gabriele Greco
On 3/26/08, Jason Ward [EMAIL PROTECTED] wrote:

 It didn't work.
 was there something else I am supposed to do after I download this bundle.
 I
 do have the run-time installed since I installed Pidgin


Note that there is at least one version of Pidgin that installs a private
copy of GTK inside it's directory, so you cannot see it from your
application, install the full GTK+ bundle:

http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-2.12.9-bundle.zip

And place your executable in the path where DLLs are.

If your assembler don't let you build executables maybe you should tell it
where to find GTK dlls or def files, I cannot tell you how to do that since
it's specific to your development enviroment, but you find all the
developers files in the package in the link.

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


Re: Quitting an application

2008-03-27 Thread Gabriele Greco

 I am writing a music library manager and I have a small problem when
 terminating the application.
 On starting the app, I scan a DB and load the tracks into a treeview.
 When this is in progress, if the user closes the application, a segfault
 occurs
 because gtk_main_quit() has been called and the scanning function tries to
 access
 data structures that are no more. How do I synchronize between them ?


Intercept the delete_event or modify the callback where you do the
gtk_main_quit() and insert there some thread sync code.

You should take care also when you add the rows to your Tree/ListStore if
you do that directly from the  thread that scans the db.

I suppose there is a thread since if there isn't one when you quit the main
loop nothing can crash it (except something you call after gtk_main()) :)

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


Re: Problem with references

2008-03-17 Thread Gabriele Greco
  After some headache with my gtk C++ classes I've found  with a small
  test program this fact about the gobject references:
 Sorry, not sure what you're trying to do.  Are you trying to do
 something with gtkmm?  Or are you creating your own bindings?


I'm doing some experimental header only bindings for an application I'm
writing, maybe I'll publish the binding once the app is finished if I find
they provide some REAL advantages over gtkmm, and IF I have the time to
cover at least a good part of the GTK api.

Actually I cover only the widgets I use in this app. I'm not using gtkmm
mostly to avoid extra dependencies.

Anyway let's talk about the problem.

Gtk owns all toplevel windows.  It already does _ref_sink() on
 GtkWindows on creation (see gtk_window_init() in gtk/gtkwindow.c).  In
 this case, if you want to keep an extra reference to 'w', you'd just
 call g_object_ref() on it.


Ok, the problem is that I expected to be able to delete those top level
windows with g_object_unref(), but it seems it's not enough, here is an
example:

int main()
{
gtk_init(NULL, NULL);

GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_widget_show(w);

GtkWidget *d = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
Hello!);
gtk_dialog_run(GTK_DIALOG(d));
fprintf(stderr, After run!\n);
g_object_unref(d);
fprintf(stderr, After unref\n);

gtk_main();
}

The message dialog is still opened after the unref, if I want to get rid of
it I have to use gtk_widget_destroy() that is not what I want cause I may
not be the owner of the object.

This should be ok as well, IFF you've previously called g_object_ref()
 and thus own a reference to it.  As I said, Gtk owns the initial
 (non-floating) reference GtkWindow that you get back with
 gtk_window_new().


Adding an additional reference to the dialog don't help me close it with
g_object_unref()...

This more or less works (because non-window GtkObjects are created
 floating), but that's usually not what you'd want to do.  Again you'd
 probably want to just take a normal reference on the widget and then
 unref it when you don't need it anymore.  When you add a widget to a
 container, it will take care of ditching the floating reference and
 taking a real reference.


This is what I want and it works perfectly except for top level windows :)
With toplevel windows I'm unable to get rid of them  with the same method I
use with the other objects (g_object_unref), I can superclass it to do
gtk_widget_destroy() if I see that the object count is 2 or less (since my
reference is added to the initial one of GTK), but I'd like a cleaner way.

It's strange that if you call twice g_object_unref() the top level window
closes but you also get this kind of error:
(unknown:6412): GLib-GObject-WARNING **: instance with invalid (NULL)
class pointer

(unknown:6412): GLib-GObject-CRITICAL **: g_signal_handlers_destroy:
assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

Seems like GTK wants to do something more on the dialog after I remove his
last reference!


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


Problem with references

2008-03-14 Thread Gabriele Greco
After some headache with my gtk C++ classes I've found  with a small test
program this fact about the gobject references:

Window
Creation: 1 Sink: 2 End: 1
Label
Creation: 1 Sink: 1 End: 0

It seems that window derived widgets are created with a not floating
reference, so they should be handled differently, are window classes the
only GTK objects created with a strong reference or there are also other
widgets?

The strange thing is that both GtkWindow and GtkLabel derive from
GObjectInitiallyUnowned. And that if I use:

g_object_is_floating() to avoid the additional reference on the window
object when I unref it I get:

(unknown:29976): GLib-GObject-WARNING **: instance with invalid (NULL)
class pointer

(unknown:29976): GLib-GObject-CRITICAL **: g_signal_handlers_destroy:
assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
End: -1


Here is the code (tested with GTK 2.12):

#include gtk/gtk.h

int main()
{
gtk_init(NULL, NULL);

GtkWindow *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *l = gtk_label_new(Test);

printf(Window\nStart: %d , G_OBJECT(w)-ref_count);
g_object_ref_sink(G_OBJECT(w));
printf(Sink: %d , ((GObject *)w)-ref_count);
g_object_unref(G_OBJECT(w));
printf(End: %d\n, ((GObject *)w)-ref_count);

printf(Label\nStart: %d , G_OBJECT(l)-ref_count);
g_object_ref_sink(G_OBJECT(l));
printf(Sink: %d , ((GObject *)l)-ref_count);
g_object_unref(G_OBJECT(l));
printf(End: %d\n, ((GObject *)l)-ref_count);
}

-- 
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240  Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Signal prototypes

2008-02-21 Thread Gabriele Greco
Given that different signals may have different prototypes:

clicked: void (*)(GtkWidget *, void *)
keypress: gboolean (*)(GtkWidget *, GdkEvent *, void *)
delete_event: gboolean (*)(GtkWidget *, void *)
[...]

There is a way, from the signal name, to find in ADVANCE what kind of 
prototype the signal will expect?

---
Bye,
 Gabry


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


GtkBuilder, win32 signals

2008-02-13 Thread Gabriele Greco
I'm doing some tests with GtkBuilder and I've built a simple program
that open a window with a pair of buttons with a signal for each button
and it works perfectly in linux.

I've tried to crosscompile it to win32 with this command line:

i586-mingw32msvc-gcc -o main.exe main.c -mno-cygwin -mms-bitfields
-I$CROSSDIR/include/gtk-2.0/glib-2.0
-I$CROSSDIR/lib/gtk2/glib-2.0/include/ -I$CROSSDIR/include/cairo
-I$CROSSDIR/include/gtk-2.0 -I$CROSSDIR/include/atk-1.0
-I$CROSSDIR/include/pango-1.0 -I$CROSSDIR/lib/gtk-2.0/include  -s
-L$CROSSDIR/lib/gtk-2.0 -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lpango-1.0 -lpangowin32-1.0  -lgmodule-2.0
-lgobject-2.0 -lglib-2.0 -lgthread-2.0 -Wl,--export-dynamic

This is mostly the line I use in our production enviroment, the program
compile and link, but complains about missing signal handlers when I call:
gtk_builder_connect_signals (b, NULL);

I'm wondering if the gmodule inspecting feature to link the handlers
is broken in win32 or if I have to add some more flag (gmodule-2.0.pc of
the win32 dev archive doesn't show anything relevant...) and
g_module_supported() returns true!

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


Re: GtkBuilder, win32 signals

2008-02-13 Thread Gabriele Greco
On 2/13/08, Tor Lillqvist [EMAIL PROTECTED] wrote:

   I'm wondering if the gmodule inspecting feature to link the handlers
   is broken in win32 or if I have to add some more flag

 I quote the documentation for gtk_builder_connect_signals() in trunk:

 * When compiling applications for Windows, you must declare signal
 callbacks
 * with G_MODULE_EXPORT, or they will not be put in the symbol table.
 * On Linux and Unices, this is not necessary; applications should instead
 * be compiled with the -Wl,--export-dynamic CFLAGS, and linked against
 * gmodule-export-2.0.

 I.e. define your callback functions like this:

 G_MODULE_EXPORT int
 foobar (...)
 {
 ...
 }


That works perfectly thanks, I'm replying to the list just because this is
not available in the stable documentation in gtk.org and maybe someone
else has interest on this topic.

Nice addon this GtkBuilder BTW :)

I think I'll try to move on the development of our applications from the
built in code generation to this, the fact that doesn't need an external
library and that connects signals is a big plus over the libglade approach.

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


Change interface font in a GTK application at runtime without reopening windows

2007-12-12 Thread Gabriele Greco
A lot of users are asking me for the capability to change the font of an
  application runtime.

I know that the correct answer should be change your gtk theme or edit
the application RC file, but while this kind of answer is good with
power users, normal users often want to be able to grab a font from a
list and quickly try it on the REAL application interface without the
need of a restart.

I know that I can change the font of a single widget with
gtk_widget_modify_font(), and that I can change the font of EVERY future
widget with something like:


gtk_rc_parse_string(gtk-font-name=\sans 13\\n);

But what if I want to change the font of the actual interface without
having to close all the application window and open them again?

I'm quite sure it's possible since I've seen a few apps doing it. Sadly
I don't remember the apps, otherwise I'd go peek at their sources :)

I think there should be cleaner way that a full iteration on the widget
tree of every window and a gtk_widget_modify_font() Call on each widget,
isn't it? :)

Bye,
  Gabry


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


Re: Multiple threads and gtk_main()

2007-07-11 Thread Gabriele Greco
Eduardo M KALINOWSKI wrote:
 Make your threads add stuff to a single GAsyncQueue. Let an idle 
 function (or a timeout function) always run, that checks the GAsyncQueue 
 and does something if there is something to do, or simply returns if it 
 is empty. Wouldn't that work?
   
Yes, but that would be polling, and polling is what I'm trying to avoid.

--
Bye,
 Gabry

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


Multiple threads and gtk_main()

2007-07-10 Thread Gabriele Greco
I've a few threads (more than one) doing some work (not accessing GTK 
functions), I'd like to have a general way to make them notify their 
work to the main loop.

I used the g_idle_add() in the previous context where I had only a 
thread with this behaviour, but with two or more threads the 
g_idle_add() method of notification is not correct IMHO (what happens if 
  two threads call g_idle_add() before the call of the first one is 
processed by the glib main loop?)

I thought about a mutex solution, something like this:

thread X:
lock idle_mutex
g_idle_add(my_idle_func)

my_idle_func:
unlock idle_mutex
[update the gui]
return FALSE

This way should work but when I use mutexes in context I've not full 
control on I always fear unhandled deadlock situations...

I though about using a GAsyncQueue for every thread but in this way the 
problem I have is how to notify the main loop that there is something on 
a queue, I've not found anything in the documentation... I fear the only 
  way it's to use a pipe or a socket, or an idle function, but in this 
case I will occur again in the locking problem, I hope I'm wrong about 
this so I'm asking here :)

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


Fast animation prototype code

2007-07-09 Thread Gabriele Greco
I've wrote this example code and it seems to work properly both on Linux 
and Win32, I'm wandering if some GTK guru has some suggestions to 
improve it, obviously it's only an example, but this will be the 
structure that will be included in the application, the thread that 
build the image will be an h263 decoder that get the video through the 
net, this is why the simple image creation of the demo is made in a 
separate thread. It works without changes both in win32/linux and uses 
5/10% of CPU of pretty old machines.


I'm wandering what happens if I set an idle_function with g_idle_add() 
while the previous idle cbk has not yet completed (the coherence of the 
image is not a problem because I already plan to use a SpinBuffer for it 
in the real app).


I'm wandering also if it's better to use gdk_flush() when I draw a frame 
or it's also safe/fast to do gtk_widget_queue_redraw() for the drawing

area widget...

Compile with:

gcc -o test gtkview.c `pkg-config gtk+-2.0 --cflags --libs` `pkg-config 
gthread-2.0 --cflags --libs`


--
Bye,
 Gabry

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

Re: [SPAM] Fast animation prototype code

2007-07-09 Thread Gabriele Greco
Gabriele Greco wrote:

The source file as attach was cutted,  I'm pasting it inline, it's short :)
 I've wrote this example code and it seems to work properly both on 
 Linux and Win32, I'm wandering if some GTK guru has some suggestions 
 to improve it, obviously it's only an example, but this will be the 
 structure that will be included in the application, the thread that 
 build the image will be an h263 decoder that get the video through the 
 net, this is why the simple image creation of the demo is made in a 
 separate thread. It works without changes both in win32/linux and uses 
 5/10% of CPU of pretty old machines.

 I'm wandering what happens if I set an idle_function with g_idle_add() 
 while the previous idle cbk has not yet completed (the coherence of 
 the image is not a problem because I already plan to use a SpinBuffer 
 for it in the real app).

 I'm wandering also if it's better to use gdk_flush() when I draw a 
 frame or it's also safe/fast to do gtk_widget_queue_redraw() for the 
 drawing
 area widget...

 Compile with:

 gcc -o test gtkview.c `pkg-config gtk+-2.0 --cflags --libs` 
 `pkg-config gthread-2.0 --cflags --libs`
#include gtk/gtk.h
#include stdlib.h

GtkWidget *label;
GdkGC *mygc;
GdkDrawable *mydest;

gboolean blit_fast(GdkImage *img)
{
static int frames = 0;
static time_t timer = 0;

gdk_draw_image(mydest, mygc, img, 0, 0, 0, 0, img-width, img-height);
gdk_flush();

if ((frames % 100) == 0) {
time_t newtime = time(NULL);

if (timer != 0) {
char buffer[80];
newtime -= timer;

if (newtime != 0) {
sprintf(buffer, Frames: %d time: %d, %d fps, frames, 
newtime, frames / newtime);
gtk_label_set(GTK_LABEL(label), buffer);
}
}
else
timer = newtime;
}

frames++;

return FALSE;
}

void *myloop(GdkImage *img)
{
static int pos = 0;
int i, j;
GTimer *t = g_timer_new();
gdouble needed = 0.0f;
g_timer_start(t);

for(;;) {
unsigned long *ptr = img-mem;

for (j = 0; j  img-height; ++j) {
for (i = 0; i  img-width; ++i) {
if (i  pos || i  (pos + 100))
*ptr = 0;
else {
*ptr = 0xff;
}
ptr++;
}
}
pos ++;
if (pos == 640)
pos = -99;

while (g_timer_elapsed(t, NULL)  needed)
g_usleep(1);

g_idle_add(blit_fast, img);
needed += 0.040;
}
}


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

GdkVisual *vis = gdk_visual_get_system ();

GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(win), box);
GtkWidget *area = gtk_drawing_area_new();
gtk_widget_set_usize(area, 640, 480);
gtk_box_pack_start_defaults(GTK_BOX(box), area);
label = gtk_label_new(--- fps);
gtk_box_pack_end_defaults(GTK_BOX(box), label);

gtk_widget_set_app_paintable(area, TRUE);
//gtk_widget_set_double_buffered(win, FALSE);
gtk_widget_set_double_buffered(area, FALSE);

gtk_signal_connect(GTK_OBJECT(win), destroy,
GTK_SIGNAL_FUNC(exit), (void *)0);

GdkImage *img = gdk_image_new(GDK_IMAGE_FASTEST, vis, 640, 480);

printf(Img- %dx%d depth:%d bpp:%d bpl:%d\n, img-width, img-height,
img-depth, img-bpp, img-bpl);

if (img-bpp != 4) // actually only 32bit support since it's a test
return -1;

gtk_widget_show_all(win);

mygc = gdk_gc_new(area-window);
mydest = area-window;

g_thread_create(myloop, img, FALSE, NULL);

gtk_main();
}

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


Simple video playing with SDL

2007-07-06 Thread Gabriele Greco
Someone can point me some code that does video playback using *only* GTK?

If the code is not available also some directions will be enough:

- What kind of widget to use? (GtkDrawingArea, GtkImage...)
- How to handle double buffering? (perform a queue_draw after each frame
update?)
- How to blit efficiently my data (what pixel format is best suited, I
have to use my yuv - rgb conversion code? RGB24? ARGB? RGBA?)
- It's SDL blit architecture optimized enough for video playing?

I don't need big performance, I've a small 352x288 10fps stream, my
actual solution is using SDL on a GtkDrawingArea with the SDL_WINDOWID
hack. It works both on win32 and linux, but I'd like a cleaner
architecture

-- 
Bye,
  Gabry

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


Re: [SPAM] Simple video playing with SDL [- WITHOUT SDL]

2007-07-06 Thread Gabriele Greco
Gabriele Greco wrote:

Just correcting the title of my previous post, obviously I intended 
WITHOUT SDL or any external library (except the one I use to decode the 
stream :) ).
 Someone can point me some code that does video playback using *only* GTK?

 If the code is not available also some directions will be enough:

 - What kind of widget to use? (GtkDrawingArea, GtkImage...)
 - How to handle double buffering? (perform a queue_draw after each frame
 update?)
 - How to blit efficiently my data (what pixel format is best suited, I
 have to use my yuv - rgb conversion code? RGB24? ARGB? RGBA?)
 - It's SDL blit architecture optimized enough for video playing?

 I don't need big performance, I've a small 352x288 10fps stream, my
 actual solution is using SDL on a GtkDrawingArea with the SDL_WINDOWID
 hack. It works both on win32 and linux, but I'd like a cleaner
 architecture
   
Bye,
 Gabry


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


Re: [SPAM] cross compiling and ld auto-import errors

2007-06-07 Thread Gabriele Greco
Bethany Seeger wrote:
 From what I've read, I need to force (external) constants to be
 variables, but I'm not sure how I can do that when the errors are coming
 from the glib library, underneath Gtk/Gdk.  (or declare them explicitly
 with __declspec(dllimport)).  

 I'm relatively new to cross-compiling, so I'm a little baffled as to
 where to go with this. 
   
If this can be of any use when I crosscompile I don't link directly with 
the DLLs but with the import files provided in the gtk-*-dev archives:

In my makefile I have this (I've a win32 target that uses CROSSDIR, 
CROSSCXX, CROSSLIBS instead of the standard ones):

CROSSLIBS = -L$(CROSSDIR)/lib/gtk-2.0 -mwindows -mno-cygwin \
 -mms-bitfields -lgtk-win32-2.0.dll -lgdk-win32-2.0.dll -\
 -latk-1.0.dll -lgdk_pixbuf-2.0.dll -lpango-1.0.dll 
-lpangowin32-1.0.dll \
 -lgmodule-2.0.dll -lgobject-2.0.dll -lglib-2.0.dll 
-lgthread-2.0.dll \
 -lstdc++ -luser32 -lws2_32 -lexpat -ljpeg

ls /usr/i586-mingw32msvc/lib/gtk-2.0/
lib libgdk_pixbuf-2.0.dll.a  libgmodule-2.0.dll.a  
libgtk-win32-2.0.dll.a   libpangoft2-1.0.dll.a
libatk-1.0.dll.alibglib-2.0.dll.alibgobject-2.0.dll.a  
libpango-1.0.dll.a   libpangowin32-1.0.dll.a
libgdk-win32-2.0.dll.a  libglib.dll.alibgthread-2.0.dll.a  
libpangocairo-1.0.dll.a


--
Bye,
 Gabry

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


Re: [SPAM] Re: cross compiling and ld auto-import errors

2007-06-07 Thread Gabriele Greco
Tor Lillqvist wrote:
 I would leave out the .dll here to avoid risking confusion. (Somebody
 might think you are referring to the dll files themselves here.) The
 Win32-targeted linker looks for also libfoo.dll.a, not just libfoo.a
 when it encounters -lfoo. At least natively, presumably also when
 cross-compiling.
   
Yes, just tried it and it works also without the DLL :) (at least with 
the mingw version packaged in the debian 4+).

---
Bye,
 Gabry


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


g_idle_add and thread safety

2007-06-06 Thread Gabriele Greco
I know GTK APIs are not thread safe, I've an app with a thread doing a 
massive job that wants to update the gui status every few cycles, to do 
so I remembered an old post speaking about g_idle_add.

The question I have and which I didn't find answers both googling, both 
looking at the sources is if g_idle_add can be called without any extra 
mutex/lock from another thread.

- I have to use gdk_threads_init() mechanism?
- I have to use gdk_threads_enter/leave() around gtk_main() and around 
the g_idle_add call?
- If so, if I use the gdk_threads_idle_add() facility I can avoid all 
the locks or I have to lock around gtk_main anyway? (the example doesn't 
clarify this)

Ideally my code should be something like:

static progress_datas;

gint myfunc(vod *unused)
{
gtk_label_set_text(blablabla, progress_data);

return FALSE; // call only once
}

work_thread() {
while(1) {
loops++;
[... do the real work ...]
if ((loops % 1000) == 0) {
update_progress_datas();
g_idle_add(myfunc, NULL);
}
}
}

int main()
{
[..gui init and thread start]
gtk_main()
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: [SPAM] Re: How to create a self contained GTK+ Application for Linux

2007-05-23 Thread Gabriele Greco
Michael Ekstrand wrote:
 You might want to take a look at what the autopackage folks are doing.
 At the very least, they have a lot of documentation on what's required
 to prepare relocatable, portable binary packages.
   
Anyway the GTK hardcoded path are not a good thing IMHO. With some care 
and the use of -rpath linker option and LD_LIBRARY_PATH you can ship 
linux binaries using a wide library range.

I've shipped a commercial game with ogre, cegui, sdl, devil, boost, 
libjpeg/png/tiff, libstdc++ and other stuff, but the installer (loki) 
that use GTK, should stay compatibile with gtk 2.0.x and gtk 1.2.x 
(there are two versions) cause there is no reliable way to ship gtk 
statically linked or in a particular path (for the installer for 
instance a CDROM relative path).

Having relative paths in the gtk core libraries what problem could 
cause? In windows paths are relative so I suppose this could work also 
on linux, maybe there will be some rework in the autoconf/make scripts 
at most :)

Eg make libgtk-2.0.so try to load:

./gtk-2.0/2.10.0/loaders/libpixbufloader-gif.so

Instead of: /usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-gif.so

Bye,
 Gabry

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


Re: [SPAM] Portable network layer

2007-05-11 Thread Gabriele Greco
Jonathan Winterflood wrote:
 I'd like to keep the dependencies to a strict minimum (preferably
 bundle-able vs installable), free, and I only need basic functionality
   
If you want to avoid new dependencies you can use the sockets directly, 
the differences between winsock and the standard bsd sockets are mostly 
in the error management and can be solved with a few #defines and a call 
to WSAStartup() at the beginning of the program.

Please consider that you can also run the socket code in your main 
thread attaching the socket signal to the gtk main loop via gio channels.

If you want an higher level api you can try:

http://www.gnetlibrary.org/

---
Bye,
 Gabry


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


Abount the missing gtk_tree_model_iter_prev()

2007-05-08 Thread Gabriele Greco
Is this the optimal way to implement a bi-directional search on a
liststore or there is something better that can be done?

 while(valid) {
 gchar *body;

 gtk_tree_model_get(m_model, it,
Body, body, -1);

 if ( (cs  strstr(body, match.c_str())) ||
  (!cs  strcasestr(body, match.c_str(
 found = gtk_tree_model_get_path(m_model, it);

 g_free(body);

 if (found)
 return found;

 if (searchdown)
 valid = gtk_tree_model_iter_next(m_model, it);
 else {
 if ((valid = gtk_tree_path_prev(start)))
 valid = gtk_tree_model_get_iter(m_model, it, start);
 }
 }


---
Bye,
  Gabry

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


Enable/Disable a button and mouse clicks

2007-01-03 Thread Gabriele Greco
I've found that if I disable a button after a click on it 
(gtk_widget_set_sensitive(button, FALSE)), and then enable it back after 
a timed event or something else occurs (...set_sensitive(button, TRUE) 
), I'm unable to click on the button with the mouse pointer unless I 
exit with the pointer from the button rectangle and enter back in it.

This is a minimal example showing this strange behaviour, I think it's a 
wanted behaviour and not a bug (I found this behaviour in GTK 2.6, 2.8, 
but not in GTK 2.4), but it's not what I want from my button, there is 
any workaround for it?

#include gtk/gtk.h
#include stdio.h

int do_timeout(GtkWidget *w)
{
 printf(Timed out, enabling button\n);
 gtk_widget_set_sensitive(w, TRUE);
 return 0;
}

int clicked(GtkWidget *w)
{
 printf(Button clicked!\n);
 gtk_widget_set_sensitive(w, FALSE);
 g_timeout_add(2000, do_timeout, w);
}

int main(int argc, char *argv[])
{
 gtk_init(argc, argv);
 GtkWidget *w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 GtkWidget *b = gtk_button_new_with_label(Test);
 gtk_container_add(GTK_CONTAINER(w), b);
 g_signal_connect(b, clicked, clicked, NULL);
 gtk_widget_show_all(w);
 gtk_main();
}

Bye,
  Gabry



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


Re: [SPAM] Re: Enable/Disable a button and mouse clicks

2007-01-03 Thread Gabriele Greco
Ed Catmur wrote:

 You've discovered bug 56070[1].  There are some workarounds at the bug, but 
 we're fairly close to getting it fixed in GTK+. 
After a complete read of the thread I've implemented the workaround 
based on the window motion events capture, seems to work correctly both 
on linux and win32.

Bye,
 Gabry


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


Change GtkTreeViewColumn header background color

2006-12-18 Thread Gabriele Greco
There is an easy way to do it, a rc option would be very nice but I've 
not found it!

Adding a custom object as column header is not ok, since you get your 
background only under the label (the border and the arrow keep the old 
background).

Lurking in the sources I've found this way, but it's way too 
implementation dependant:

 GtkWidget *l = gtk_label_new(title.c_str());
 gtk_widget_show(l);
 gtk_tree_view_column_set_widget(col, l);
 GtkWidget *w = gtk_tree_view_column_get_widget(col);

 // From the sources this is the object hiearchy:
 //   get_widget object - alignment - hbox - button

 GtkWidget *b = w-parent-parent-parent;

 GdkColor bg;
 gdk_color_parse(#b8b8b8, bg);
 gtk_widget_modify_bg(b, GTK_STATE_NORMAL, bg);


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


How to find custom engines

2006-12-06 Thread Gabriele Greco
I want to use a custom engine in my gtk app, the problem is that I find 
no way to tell GTK where my engine is located, the app is multiplatform 
(linux/w32) and it doesn't find the engine except if I put it in the 
default engine path (Common Files/GTK/lib/gtk-2.0/engines or 
usr/lib/gtk-2.0/engines).

I've tried both:

(in the app rc file)

module_path my/engine/path

(also with the absolute path it doesn't work)

and:

export GTK_PATH=my/absolute/engine/path

In both cases gtk doesn't find my engine and starts with the default look!

Bye,
  Gabry

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


Re: Fullscreen window

2006-11-27 Thread Gabriele Greco
Gabriele Greco wrote:
 I'd like to open my application with the window expanded, so that it 
 covers all the visible part of the desktop except the kde/gnome/windows 
 taskbar(s).

 There is a portable way to do this?

 gtk_window_fullscreen does something similar but removes both the 
 titlebar and the taskbar, at least on win32, on linux it doesn't do 
 nothing but this is maybe dued to the fact I'm using a remote display 
 for the application.
   
Sorry gtk_window_maximize() :)

I've found it now, I don't know how I missed it while searching for it 
before posting :)

Bye,
 Gabry


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


Theme writing guide/tutorial

2006-11-22 Thread Gabriele Greco
There is a guide not aimed to programmers about theme writing for GTK 
(I'm mostly intrested in pixbuf themes, but also a generic guide could 
be useful)?

I've to explain a graphic artist how to design a theme for a GTK 
application and what I've found till now it's too much programmers 
oriented, but maybe I've not googled in the right direction :)

Bye,
  Gabry

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


Use GtkWidgets inside of a custom cell renderer

2006-11-07 Thread Gabriele Greco
As subject says it's possibile?

I've set up a custom cell renderer following the example in the treeview 
tutorial, now I'd like to use some GTK objects inside it instead of 
reinvent the wheel to draw lines and texts with GDK.

The problem is that what I get in the render method of my subclass is 
the treeview widget and a cell_area where to draw... there is a way to 
force a widget to be drawn inside an area instead of being attached to 
another widget?

What I want to be able to draw in a cell is a GtkFrame with inside a 
pair of boxes with a GtkImage and a few separators and GtkLabels with 
markups... not very confortable with Gdk primitives :)

Bye,
  Gabry

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


GTK 2.10.x status on WIN32

2006-10-02 Thread Gabriele Greco
I've seen GTK 2.10 is not yet distributed as stable for WIN32 (at
least is not in the Gimp website or in the Tor GTk-win32 page).

There are still major issues or I can target is as a stable platform for
an application due do be released in december?

Bye,
  Gabry




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


Mockup builder

2006-02-15 Thread Gabriele Greco

It does exist such a thing for GTK?

I mean not an interface builder like glade but something that let you 
create simple mockups to be used in the analysis phase of the project.


The problem with a GLADE mockup is that I cannot give for instance any 
viable hint of the CONTENTS of lists and trees (it's not fast at all to 
populate complex treeviews that holds images, text and widgets).


For instance Microsoft Visio has a mockup builder, that is in fact 
something like a vector graphics program. Very different as concept from 
an interface builder.


Just wondering if there is a GUI tool to do such tasks. The target is to 
be able to assign the design phase of the interface to a person more 
involved with graphics than to assign this task to a programmer.


Bye,
 Gabry

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


Re: Sockets with GTK 2.8.9 on WIN32

2006-02-13 Thread Gabriele Greco

Daniel Atallah wrote:

That is one of the changes that were made in Glib 2.8.x.  All of the
win32 GIOChannel stuff was changed such that it'll leave your sockets
in non-blocking mode.  See this bug report for more information: 
http://bugzilla.gnome.org/show_bug.cgi?id=147392
  
This seems very strange for me since glib 2.8 on Unix does not behave 
this way.


How can GTK be used as a multiplatform development system if it behave 
in different ways for the different platform it supports?

Basically, if you want your socket to be non-blocking, you have to
make it so in the input function every time it is triggered.
  
So I've to add something like this in my input function (error checking 
omitted):


#ifdef WIN32
   unsigned long par = 0;
   ioctlsocket(fd, FIONBIO, par);
#endif

This is quite ugly.

I thought that I had seen this in the documentation somewhere, but
apparently not.
  

I've not found anything related to GLIB 2.6 - 2.8 differences at least at:

http://www.gtk.org/api/

(incompatible differences seems related to 2.0 - 2.2 migration)

Bye,
Gabry


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


Re: Numeric keypad on win32 (GTK 2.6.9)

2005-12-12 Thread Gabriele Greco

Tor Lillqvist wrote:

Are you sure the behaviour you see on Linux happens on all important
Linux distributions and/or most Linux X server versions? What about
other Unixes?
  
I've tested also on OSX 10.3 with the fink gtk 2.2.x and the apple X 
server, the behaviour of GTK is the same I got in linux (tried at work 
with Xfree 4.3 and at home with Xorg) and is to give GTK_KP_* events if 
the numlock key is active.


I've applied a patch on the GTK 1.3.x to fix this behaviour, it works 
perfectly in win32, now I've migrated my application to GTK 2 and I'm 
not able to fix it it in the 2.6 tree cause I've problems to 
crosscompile GTK 2.6.x with mingw on my linux hosted crosscompiler cause 
I get a lot of dependency problems with pkg-config... (gtk 1.3 had 
mingw32 prebuilt makefiles and doesn't need to pass through configure).


Bye,
Gabry


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


Numeric keypad on win32 (GTK 2.6.9)

2005-12-06 Thread Gabriele Greco

I've seen that events from numeric keypad are different in win32 and unix.

If num lock is selected the linux port give the events:

GDK_KP_0 .. GDK_KP_9

while the win32 version gives GDK_0 .. GDK_9.

Looking at the sourcecode it seems that in:

gdk/win32/gdkkeys-win32.c in the function handle_special() the 
appropriate VK_NUMPAD_* codes are not converted as they should to 
GDK_KP_* events.


Is this wanted? Can I submit a patch to fix this behaviour?

It causes a lot of problems in my application since actually I see no 
way to check the difference between 1 on the main keyboard and 1 on 
the numeric pad (that in my application on unix and osx have very 
different meanings).


Bye,
 Gabry



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