Re: Tutorial for writing widgets in Gtk3

2018-07-29 Thread Nicola Fontana
Il Sun, 29 Jul 2018 18:19:25 +0100 Göran Hasse  scrisse:

> I have have those applications. But they just use stock widgets.
> 
> I don't find an example creating a new widget from scratch...
> 
> Eg how to write your own widget. I have my widget in the tarfile and this is 
> what
> I want to be running in Gtk3...

Ah sorry. I was reading the whole thread and answering to Scott
Mayo question asking for full blooded examples of GTK+3 apps.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Tutorial for writing widgets in Gtk3

2018-07-29 Thread Nicola Fontana
Il Thu, 26 Jul 2018 08:42:26 +0100 Göran Hasse  scrisse:

> Hello!
> 
> I try to write a custom widget in Gtk3. I study the source for other widgets 
> but I find no totorial
> for how to write a widget in Gtk3. (There was for Gtk2 - but they are not of 
> any use anymore...).

Hi,

in case you did not notice, the git repository (and maybe the
tarball) has some stand-alone examples you can check:

https://gitlab.gnome.org/GNOME/gtk/tree/master/examples

I just checked application1 and application10 and they are up to
date. Just read the README before:

https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/README

IMO this is more than enough to get you started.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK's interfaces and language bindings

2017-07-20 Thread Nicola Fontana
Il Tue, 18 Jul 2017 22:00:52 +0200 Stefan Salewski  scrisse:

> ...
> So the second parameter is of type GtkStyleProvider, which is an
> interface. GtkCssProvider provides that interface, so we can pass a
> variable of that type. GTK_STYLE_PROVIDER() is basically only a cast, a
> re-interpretation of the bit pattern, maybe with additional security
> checks.

Hi Stefan,

I'll give you my view that will not necessarily match the view of
who wrote GInterface.

Although GTK_STYLE_PROVIDER() is similar to e.g. G_OBJECT(), they
are fundamentally different. While the latter matches exactly your
description (a GtkCssProvider is also a GObject), the former
should be considered only a check.

If you dig enough in that macro you will discover this function:

https://git.gnome.org/browse/glib/tree/gobject/gtype.c?h=2.52.3#n3440

G_OBJECT() is matched by the first branch (support_inheritance)
while GTK_STYLE_PROVIDER() by the second one (support_interfaces).

This difference is purely theorethical though, because
GtkStyleProvider is not even defined. In other words one could
argue that GTK_STYLE_PROVIDER() is a real cast to an undefined
type.

> ...
> So I assume,
> that for all functions which has interfaces as parameters, I can just
> pass all objects (gobjects) which provides that interface?

Yes.

> I even guess hat interfaces are fully abstract entities, so we will
> never pass an instance of an interface, but always only objects
> providing the interface. So we have only to provide functions which can
> accepts all the objects providing the that interface, but we do not
> really need functions which would accepts the interface parameter type
> itself?

Correct. As pointed out before, even in C interface instances are
only dummy typedefs.

I see interfaces as a "contract" that (1) enforces an object
to implement some feature (properties and/or methods) and
consequently (2) gives the users a common API that can be used
across unrelated objects.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject introspection and cairo?

2017-07-15 Thread Nicola Fontana
Il Sat, 15 Jul 2017 13:47:22 +0200 Stefan Salewski  scrisse:

> On Tue, 2017-05-09 at 17:05 +0200, Nicola Fontana wrote:
> > ...
> > 
> > https://bugzilla.gnome.org/show_bug.cgi?id=743364
> > 
> > No idea how long does it take to have that upstream.
> > 
> > Ciao.  
> 
> Is it already known when these patches will be available for ordinary
> users?
> ...

They have been included in gobject-introspection 1.53.2, released
on may:

https://git.gnome.org/browse/gobject-introspection/log/

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Cross-compiling GTK+, missing icons

2017-05-29 Thread Nicola Fontana
Il Mon, 29 May 2017 12:09:49 +0200 Gerardo Ballabio 
 scrisse:

> > if with "style" you mean the GTK+ theme then yes, you need to
> > include it separately.
> >
> > I'm used to cross-compile for Windows on Linux and lately (since
> > 3.14.0 IIRC) the adwaita theme became a new external dependency in
> > the toolchain I use.
> >  
> 
> Which toolchain are you using please?

I'm using my aur-fedora-mingw toolchain for Archlinux [1] that in
turn is based on the Fedora one [2].

> Do you generate self-contained
> binaries or do you need to install extra stuff?

I build a single installer with NSiS [3]. This will unzip all the
needed stuff under "C:\Program files\Whatever": see my script [4]
as an example.

It seems to be a lot of work (and it is!) but now I can build the
installer (for win32 or win64) by simply issuing a make command in
the appropriate build tree. My only problem is I cannot check the
result because I don't own a windows box ;)

[1] https://github.com/ntd/aur-fedora-mingw
[2] https://fedoraproject.org/wiki/MinGW/CrossCompilerFramework
[3] http://nsis.sourceforge.net/Main_Page
[4] https://github.com/ntd/adg/blob/master/build/adg.nsi

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Cross-compiling GTK+, missing icons

2017-05-28 Thread Nicola Fontana
Il Sun, 28 May 2017 18:27:46 +0200 Vilem Otte  scrisse:

> ...
> I'm not even sure you can include whole style for Gtk+ 3.x inside the
> library (although I might be wrong here!).
> ...

Hi Vilem,

if with "style" you mean the GTK+ theme then yes, you need to
include it separately.

I'm used to cross-compile for Windows on Linux and lately (since
3.14.0 IIRC) the adwaita theme became a new external dependency in
the toolchain I use.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject introspection and cairo?

2017-05-09 Thread Nicola Fontana
Il Tue, 09 May 2017 16:39:10 +0200 Stefan Salewski  scrisse:

> I am currently working again on the gobject introspection based
> bindings for Nim language (https://github.com/StefanSalewski/nim-gi).
> 
> And I wonder why there is only minimal support for cairo --
> /usr/share/gir-1.0/cairo-1.0.gir is minimal.

Hi Stefan,

not so long ago Emmanuele accepted a few patches that improves
this situation:

https://bugzilla.gnome.org/show_bug.cgi?id=743364

No idea how long does it take to have that upstream.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: gobject

2016-10-12 Thread Nicola Fontana
Il Thu, 13 Oct 2016 01:41:03 +1100 Timothy Ward  scrisse:

> Is there a good tutorial or reference material on gtk gobject "c"
> coding.
> 
> 1) Explaining in detail the whole process from what should be in
> header files and source files, structure declarations, boiler plate
> code the stages of object creation and dispose and finalize functions.
> What each function actually does and the interaction between them.
> 
> Google search info is fragmented in this respect.
> 
> Also any tutorial or reference material on gobject "c" coding without
> using the boiler plate code and supporting glue etc. 

Hi,

what's wrong with the official documentation?

https://developer.gnome.org/gobject/stable/

It provides overview, tutorials and API reference.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Parent receiving child's button press event

2016-08-30 Thread Nicola Fontana
Il Tue, 30 Aug 2016 17:48:34 -0700 Jim Heald  scrisse:

> Thank you so much! It's literally these return True things that keep
> throwing me off.
> 
> Do you have a suggestion of somewhere I can read about all of these
> conventions?
> ...

They are not conventions, they are documented behavior: just pay
attention to the signal documentation. In your specific case you
probably connected a callback to the "button-press-event" signal.
Citing the relevant documentation [1]:

Returns: TRUE to stop other handlers from being invoked for
the event. FALSE to propagate the event further.

I think this is respected for all "*-event" signals.

[1] 
https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-button-press-event

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Drag and drop widgets

2016-08-29 Thread Nicola Fontana
Il Sun, 28 Aug 2016 16:23:49 -0700 Jim Heald  scrisse:

> So the only problem with this is the Gdl doesn't seem to be implemented in
> Python unfortunately. Any other ideas?

I do not use python but, from the configure.in of GDL [1], it
seems GObject introspection support is available. This, together
with PyGI [2], means GDL should be callable from Python.

[1] 
https://git.gnome.org/browse/gdl/tree/configure.in?id=f3de14fe3962c84775d18d7dc26418830be982a4#n149
[2] https://wiki.gnome.org/action/show/Projects/PyGObject

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK3 on Darwin

2016-05-08 Thread Nicola Fontana
Il Sun, 8 May 2016 10:28:43 +0100 Andrea Giammarchi 
 scrisse:

> If I understand correctly you're saying I shouldn't even file a bug if the
> issue is not on Linux, right? Can you point me at any place where this
> could be discussed? I'm sure having the ability to open an external link,
> even just for an about section, is kinda essential. Thanks

He said quite the opposite: you should file a bug and *actively*
participate to find the solution because the developers cannot see
how GTK+ behaves on your system.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Run a GTK application without desktop environment

2016-03-19 Thread Nicola Fontana
Il Thu, 17 Mar 2016 22:00:03 -0700 "Jasper St. Pierre"  
scrisse:

> I highly recommend against this. A window manager should be around to
> manage windows, since a lot of functionality to applications is
> provided by the WM. Having it missing could cause strange bugs.
> 
> Please just use a lightweight window manager like Matchbox or metacity.

I used openbox in a similar application, i.e. a single window and
no other dialogs. I had to hunt every single way a user could
escape, e.g. keyboard shortcuts, mouse events, borders, titlebar
etc... quite flaky.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Needed information about GTK+

2016-02-20 Thread Nicola Fontana
Il Sat, 20 Feb 2016 02:50:31 -0200 Diogo Campos  
scrisse:

> Hi,
> 
> I'm building a Free Software crowdfunding campaign, and GTK+ is one of the
> candidates to be benefited.

Hi,

I think gtk-devel-list would be a better place for your questions:
CCing to it.

> This would mean for GTK+ to have 1 additional person working on it, and
> full-time.
> 
> So, I would like to know from maintainers, contributors and interested
> individuals some information about GTK+.
> 
> - There is interest in this additional person?
> 
> - What are the functions needed today? Development? UI Design? Bug triage?
> Documentation? Translation? Anything else?
> 
> - What tasks such contributors can do? And what is the skill level required
> to perform each of these tasks? Student? Amateur? Intermediate? Advanced?
> Expert?
> 
> - What are the programming languages used?
> 
> - There is a Roadmap and/or TODO list? If yes, what they define?
> 
> - What is the current health of the project? How many people work on it
> regularly? How many of these are paid to do it?

For this kind of research you can leverage openhub: it is really
good for showing aggregate information.

https://www.openhub.net/p/gtk

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Events in custom widgets

2016-01-14 Thread Nicola Fontana
Il Thu, 14 Jan 2016 08:41:46 +0100 Jozef Molnar  
scrisse:

> Dear subscribers,
> 
> I want to create a custom widget derived from either GtkDrawingArea or
> GtkLayout (still do not know, which is better for my purpose - I need some
> advice).
> Nevertheless, if I derive my widget from GtkDrawingArea, I can draw using
> Cairo (the draw callback gets called) but I cannot receive mouse events. I

Hi Jozef,

GtkDrawingArea *can* handle mouse events. From its documentation:

To receive mouse events on a drawing area, you will need to
enable them with gtk_widget_add_events().

so I suspect you are missing that call in your testing code. E.g.

gtk_widget_add_events(drawing_area, GDK_POINTER_MOTION_MASK);

enables you to connect a callback to the "motion-notify-event"
signal of your drawing area.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Outdated win32 bundle

2015-06-19 Thread Nicola Fontana
Il Fri, 19 Jun 2015 10:04:43 +0100 Emmanuele Bassi  scrisse:

> > https://bugzilla.gnome.org/show_bug.cgi?id=658126#c25
> >
> > I also have an installer with Lua bindings (based on gi) that
> > seems to work, at least on wine. The approach is far from straight
> > but I was honestly expecting much more feedback though.
> 
> Sadly, it's a niche of a niche.
> 
> Since you have commits on a GitHub branch, care to attach them to
> Bugzilla, so at least they don't get lost and somebody can review
> them? That would already help.

Ok, done.

> Using Wine to cross-compile is not a huge stretch;
> https://bugzilla.gnome.org/show_bug.cgi?id=696773 is a bug about using
> qemu to cross-compile on ARM. I guess we could find a way to make it
> easier to spawn an environment that builds the introspection data, and
> solve both issues.

Yes, I gathered from Bugzilla all the info I found before
starting, also because I did not want to start in the first place.
In the bug I attached a patch to use an external launcher via
enviornmental variables, similar to what done for ARM with qemu.
The tricky part is to get a wine wrapper that is *not*
interactive... something not obvious but possible:

https://github.com/ntd/aur-fedora-mingw/blob/master/afm-mingw-w64-gobject-introspection/winewrapper

If relevant I can attach to the bug report that wrapper too.

> There are other issues about portability, though, especially related
> to per-platform constants and functions; the introspection scanner
> will currently drop re-defined symbols — see bug:
> https://bugzilla.gnome.org/show_bug.cgi?id=696935

Cross-building from Linux makes use of / as directory separator,
so I did not meet that problem. In my first (failed) attempt to
build everything for the host I had directory separator problems
though, as witnessed by some of the patches I submitted.

> > AFAIK Fedora already has something similar for their fedora-mingw
> > port. Are you aware of that or am I missing something?
> 
> I'm well aware of the Fedora packages — I use them myself when I need
> to test cross-compilation of other projects. What I'm asking is
> creating a CI environment with them that picks up changes from the Git
> repository and builds GTK with the Windows backend enabled.

Ah ok, I assumed Fedora was already owning such build system.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Outdated win32 bundle

2015-06-19 Thread Nicola Fontana
Il Fri, 19 Jun 2015 00:24:31 +0100 Emmanuele Bassi  scrisse:

> as Daniel pointed out,
> cross-compiling the introspection data is currently not possible

Hi Emmanuele,

with the current code base it is not possible but I managed to
crossbuild gobject-introspection months ago with only few
adjustments:

https://bugzilla.gnome.org/show_bug.cgi?id=658126#c25

I also have an installer with Lua bindings (based on gi) that
seems to work, at least on wine. The approach is far from straight
but I was honestly expecting much more feedback though.

My main problem is I am on that code only when I need it, i.e.
a fistful of times per year. I cannot be of much help here.

> So, let's try and get to something actionable. Can somebody try and
> set up a CI for GTK that either cross-compiles GTK or compiles it
> natively?

AFAIK Fedora already has something similar for their fedora-mingw
port. Are you aware of that or am I missing something?

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK-doc appears to be missing a struct when generating documentation

2015-04-11 Thread Nicola Fontana
Il Fri, 10 Apr 2015 09:15:31 +1200 Koz Ross  scrisse:

> I've been trying to get GTK-doc to make documentation for my file, which can 
> be viewed at https://notabug.org/koz.ross/libudp/src/master/headers/udp.h
> 
> Basically, for some reason, the udp_results_s struct (line 70 or so in the 
> file) always seems to be missed by GTK-doc. I have tried including a 'dummy' 
> struct, and GTK-doc seems to miss that one also. 

Hi,

which version of gtk-doc are you using? Old versions were picky on the
syntax because used the /\s*typedef\s+enum\s*({)?.../ regex. You should
strictly follow the following convention:

typedef enum {
...
} enumname;

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GHashTable strange behavior

2015-03-06 Thread Nicola Fontana
Il Wed, 4 Mar 2015 20:44:04 +0200 Stathis Gkotsis  
scrisse:

> Hi all,
> 
> I am facing some strange behavior with GHashTable. When I use
> g_hash_table_insert to insert the same key twice, it does not return
> FALSE, but TRUE:

Hi,

in your example you are not inserting the same key but two different
keys with the same content. Depending on the hash function (that you did
not provide) those two keys can be considered equals or not.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Is Unicode character set a problem when compiling GTK sources?

2015-02-18 Thread Nicola Fontana
Il Tue, 17 Feb 2015 19:09:58 + John Emmas  scrisse:

> [...] Windows Unicode uses 
> precisely 2 bytes to represent each character. But UTF-8 can use 
> anywhere between 1 byte and 4 bytes
> [...]

Just a side note: Windows uses UTF-16 encoding which is not
fixed-length either: it can use 2 or 4 bytes per character.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: use gio with serialport

2014-09-23 Thread Nicola Fontana
Il Tue, 23 Sep 2014 15:48:45 +0800 Matrix  scrisse:

> the qustion is how read the buf as line by line ?
> ...
> and then i use g_buffered_input_stream_set_buffer_size to change the 
> buffer size to 1 byte

Hi,

if you are looking for a 1 byte termination (as you are when reading
line by line) you must read 1 byte at a time: I don't see any other way
around (apart playing with timeout settings).

> it works, but it should be not efficient

This is a non-issue, especially when serial communications are involved.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: A bug or a screw up?

2014-05-07 Thread Nicola Fontana
Il Wed, 07 May 2014 09:22:48 -0400 Chris Moller  scrisse:

> Is there something new I'm missing?  It didn't used to work that way.

Hi,

I just removed what seems wrong to me (cairo_identity_matrix) and it
appears to work the way you want.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: TreeView/ListStore reordering by DND

2014-03-01 Thread Nicola Fontana
Il Sat, 01 Mar 2014 19:35:08 +0100 Stefan Salewski  scrisse:

> On Sat, 2014-03-01 at 02:08 +0100, Stefan Salewski wrote:
> [...]
> Here is my complete C code:
> 
> http://www.ssalewski.de/tmp/test.c
> 
> I inserted these lines:
> 
> void on_row_inserted(GtkTreeModel *tree_model, GtkTreePath *path,
> GtkTreeIter *iter, gpointer user_data)
> {
>   char *value;
>   printf("row_inserted\n");
>   gtk_tree_model_get(tree_model, iter, LIST_ITEM, &value, -1);
>   g_printf("value = %s\n", value);
>   gint *i = gtk_tree_path_get_indices(path);
>   g_printf("row ins = %d\n", i[0]);
> }
> 
> void on_row_deleted(GtkTreeModel *tree_model, GtkTreePath *path, gpointer 
> user_data)
> {
>   printf("row_deleted\n");
>   gint *i = gtk_tree_path_get_indices(path);
>   g_printf("row del = %d\n", i[0]);
> }
> 
> First question:
> When I exchange rows by drag and drop, I get
> 
> value = (null)
> 
> similar to my test from Ruby yesterday. Is this intended, or is my code
> wrong (I have not much practice with using GTK from plain C...)

Hi,

this is intended behavior. The problem is the insertion is done in two
steps: (1) an empty row is created (and your on_row_inserted() callback
is called) and (2) that row is filled with data.

If you want 'value' to be meaningful you must postpone your callback, e.g.
by using g_idle_add(). Try to substitute your on_row_inserted() with the
following code:


typedef struct {
GtkTreeModel *model;
GtkTreePath *path;
} CallbackData;

static gboolean
real_row_inserted(CallbackData *data)
{
GtkTreeIter iter;

if (gtk_tree_model_get_iter(data->model, &iter, data->path)) {
gchar *value;
gtk_tree_model_get(data->model, &iter, LIST_ITEM, &value, -1);
g_print("Row inserted: value = '%s'\n", value);
g_free(value);
}

gtk_tree_path_free(data->path);
g_free(data);
return FALSE;
}

static void
on_row_inserted(GtkTreeModel *tree_model, GtkTreePath *path,
GtkTreeIter *iter, gpointer user_data)
{
CallbackData *data = g_new(CallbackData, 1);
data->model = tree_model;
data->path = gtk_tree_path_copy(path);
g_idle_add((GSourceFunc) real_row_inserted, data);
}


Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Web and gtk-doc integration

2013-09-01 Thread Nicola Fontana
Hi all,

I am struggling to get decent integration between web and gtk-doc
documentation for quite a while now and silverstripe-gtkdoc [1] is the
final result.

I wanted to implement the integration on the top of a CMS suitable for
generic website development. Furthermore I needed to get this stuff
working on a typical LAMP platform, possibly on a shared hosting too.
I should add I'm not particularly fond of either SilverStripe and PHP,
but I found them to be the best choices for my use cases.

The demo web site [2] includes gtk-doc reference manuals of GLib and
GObject 2.12.3 and GOffice 0.10.5, the latter being AFAIK a typical
project that lacks a home.

The project should be considered in beta stage, that is I do not plan
to add any new feature but I'm aware there is room for improvements,
especially in the URL mangling and in the performance sides.

Any feedback is welcome.

Ciao.
-- 
Nicola


[1] http://dev.entidi.com/p/silverstripe-gtkdoc/
[2] http://gtkdoc.entidi.com/
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: setting a dialog to popup instead of toplevel

2013-02-02 Thread Nicola Fontana
Il Sat, 2 Feb 2013 10:52:15 + Chris Morley  
scrisse:
> Are you referring to the comment about the limitations of using popup
> rather then toplevel (the window manager ignores it) that doesn't seem
> to be a big disadvantage that I can see at this time.

It also disables the wm keybindings. And if your user switches
application when the filechooser is opened, I suspect that dialog
will stay on top forever. To be verified though.

Fullscreen applications are weird beasts.

> I know nothing about wmclasses so I will do some research.
> Of course the other problem is the end user can change the window manager
> so I am looking for a solution that will work no matter what.

I was thinking (for unknown reasons) you were working on a whole
system, not on an application. This makes my suggestions on
tackling the problem from the window manager side pretty useless.

wmclasses are a way to identify sets of windows so you'll be able
to set hints on them from outside the application, for example by
using an external program such as wmctrl.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: setting a dialog to popup instead of toplevel

2013-02-02 Thread Nicola Fontana
Il Sat, 2 Feb 2013 09:37:53 + Chris Morley  
scrisse:

> I'm working on the linuxcnc project using Pygtk 2.6-
> 
> The operator screen I am working on is in fullscreen.
> When we use gtk.FileChooserDialog(), the menu bars show.

What do you mean with menu bars? If that is gnome-panel (or
equivalent) this seems to me a window manager issue. I've yet
encountered this problem while using the oroborus wm.

> I have discovered that setting dialogs to popup instead of toplevel
> fixes this problem. I did this in the GLADE file (for a different dialog) .

This is a bad work-around: see the doc [1] for more details.
Furthermore, GtkWindow:type is a construct-only property and
gtk_file_chooser_dialog_new() does not give access to that
property, so (if you really wanted to) you should use something
like the Python equivalent to:

g_object_new(GTK_TYPE_FILE_CHOOSER_DIALOG,
 "type", GTK_WINDOW_POPUP, NULL);

But I'd try to use a proper fix instead, such as setting the
keep-above flag on the parent window and specifying it as parent
for the filechooser dialog. If not working, I'd check if I can
modify the behavior on the window manager side by using wmclasses.

Ciao.
-- 
Nicola

[1] 
http://developer.gnome.org/gtk3/stable/gtk3-Standard-Enumerations.html#GtkWindowType
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject Destruction

2012-12-19 Thread Nicola Fontana
Il Tue, 18 Dec 2012 21:49:13 +0100 David Nečas  scrisse:
> I'm not sure whether multiple executions of dipose() can occur in a
> single-threaded program (see the source if you can understand).  But
> how would break reference cycles when, for instance, a GtkWindow is
> destroyed in a single-step finalisation method?

By exposing only dispose() and internalizing finalization in
libgobject. I'was just curious if an hypothetical new libgobject
would be implemented in the same way.

> (Disclaimer: I'm not a GLib developer neither I can read the mind of
> any.)
> 
> > You'd need to protect your code from NULLs
> 
> But I don't need to, that is the point (or, almost never need).  In my
> obects I find that, normally, members unreferenced and nullified in
> dispose() are those that can be NULL anyway so there is no special
> protection against NULL related only to destruction.

We are saying the same thing: if a dynamic string is protected
against NULL throughout your code (no "special" protection
intended here), freeing and nullifying it in dispose() or freeing
in finalize() gives the same final result.

The dispose() propose sparkled from a specific request. I still
consider it a better approach than duplicating information. I
condider anything (with "anything" including globals, if
applicable) much better than duplicating.

A cleaner solution would be to implement a getter in the parent
object that returns X,Y by directly accessing the fields in the
instance struct (hence not passing throught the gobject property
mechanism). In this case using finalize() would be acceptable.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject Destruction

2012-12-18 Thread Nicola Fontana
Il Tue, 18 Dec 2012 19:46:40 +0100 David Nečas  scrisse:

> On Tue, Dec 18, 2012 at 07:19:33PM +0100, Nicola Fontana wrote:
> > I always free dynamic stuff (included allocated memory) in
> > dispose(), not in finalize(), protecting it from double calls.
> > There you should have a still valid instance to query.
> 
> GObject gives the following, somewhat contradictory, requirements for
> dispose():
> 
> When dispose ends, the object should not hold any reference to any
> other member object. The object is also expected to be able to
> answer client method invocations (with possibly an error code but no
> memory violation) until finalize is executed. dispose can be
> executed more than once.  dispose should chain up to its parent
> implementation just before returning to the caller.
> 
> If you free everything in dipose() you may have troubles with the ‘able
> to answer client requests’ part.

That really depends on how you handle the data you are freeing.

I always wondered if this double step finalization is hystorical
craft. Why not drop finalize() altogether and avoid double dispose
calls directly from libgobject? You'd need to protect your code from
NULLs (something not new in C) but the finalization would be way
cleaner.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject Destruction

2012-12-18 Thread Nicola Fontana
Il Tue, 18 Dec 2012 04:57:52 +0100 Günther Wutz  scrisse:

> I have an Class A, which stores two Integer as properties (say x and y)
> and an Class B which inherits from A and makes a multidimensional array
> on the heap with size x*y. In my finalize method i want to free the
> dynamically allocated multidimensional array, therefore i ned the
> borders from Class A. If i write g_object_get(obj, "x", &x, NULL); i get
> an

You are using g_object_get(), so I suppose the integers are stored
in the instance, not in the class (and consequentially the
finalize method refers to the instance finalization).

I always free dynamic stuff (included allocated memory) in
dispose(), not in finalize(), protecting it from double calls.
There you should have a still valid instance to query.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK+ library access issue?

2011-10-25 Thread Nicola Fontana
Il giorno lun, 24/10/2011 alle 17.59 -0700, David Buchan ha scritto:
> Interesting. I just tried compiling a simple non-gtk c program:
> 
> 
> #include 
> #include 
> #include 
> 
> int
> main()
> {
>   int i;
>   double a =3.14;
>   double c;
> 
>   c = log(a);
> 
>   c = pow(a, i);
> 
> }
> 
> 
> 
> 
> $ gcc -lm test.c
> /tmp/cc9RccRJ.o: In function `main':
> test.c:(.text+0x1b): undefined reference to `log'
> test.c:(.text+0x33): undefined reference to `pow'
> collect2: ld returned 1 exit status

Try "gcc test.c -lm": I found the object order is important on recent
Ubuntu. Not sure is gcc or ubuntu related.

With autotools I had to move the libs flags in LDADD instead of LDFLAGS.

Ciao.
-- 
Nicola


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


Re: Does g_key_file_free() free pointers from g_key_file_get_string()?

2011-06-17 Thread Nicola Fontana
Il giorno Fri, 17 Jun 2011 14:13:32 +0100
Chris Vine  ha scritto:

> On Fri, 17 Jun 2011 10:43:24 +0200
> Tadej Borovšak  wrote:
> > Another indicator that returned value should be freed is lack of const
> > modifier on return value.
> > 
> > If API docs state:
> > 
> > const char * get_something () -> do not free result
> >   char * get_another_thing () -> free result
> 
> This is certainly not true of the C language: in the C language, naming
> a variable as const has no effect on whether its storage may or may not
> be freed where it happens to be allocated on the heap, and the same is
> true of C++ (the delete expression may happily to applied to pointers to
> const, or indeed const pointers to const).

If you have to free a const pointer you need to explicitely cast it to
non-const to avoid a warning (in gcc at least). This seems to me a clear
indicator the returned value should not be freed.

> Furthermore, I do not believe it to be a convention adopted by GTK+/glib
> either.  Apart from the case of C strings, I believe GTK+ eschews any
> use of the const keyword in order to avoid const poisoning.  I am happy
> to be proved wrong, but I cannot off the top of my head recall any case,
> other than a C string, where an object is returned in GTK+ by pointer
> to const.

I had this same issue on my own project: you cannot use const on any
referenced type because this prevents you from further
referencing/dereferencing the returned instance. I suppose GTK+
has the same problem and does not use const more because of a
lack of syntactic sugar.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GTK+ Warning: Can't set a parent on widget which has a parent

2011-06-03 Thread Nicola Fontana
Il giorno Fri, 3 Jun 2011 04:08:22 -0400
Phong Cao  ha scritto:

> Hello everybody,
> 
> I am trying to write the interface for my music manager using GTK+. The
> program was compiled successfully. However, when I executed it, the machine
> returned errors:
> 
> (dingo_draft:6462): Gtk-WARNING **: Can't set a parent on widget which
> has a parent

Hi Phong,

you are adding songinfo to infohbox and to vpaned. Choose a single container
or duplicate the widget.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Timer start registration breaks the gtk_main()

2011-03-26 Thread Nicola Fontana
Il giorno Sat, 26 Mar 2011 11:38:27 -0700 (GMT-07:00)
iko...@earthlink.net ha scritto:

> Hi, Robert,
> 
> 
> -Original Message-
> >From: Robert Pearce 
> >Sent: Mar 26, 2011 2:19 AM
> >To: gtk-list@gnome.org
> >Cc: iko...@earthlink.net
> >Subject: Re: Timer start registration breaks the gtk_main()
> >
> >Hi iko...@earthlink.net,
> >
> >On Sat, 26 Mar 2011 01:54:31 -0700 (GMT-07:00) you wrote:
> >> Hi, ALL,
> >> Is it possible for the timer to cause gtk_main() to crash?
> >>
> >It's possible for anything to become the point where your program
> >crashes if you are sufficiently badly abusing it. Why do you pick on
> >"the timer" as your suspect? 
> 
> If I comment out the call to g_timer_add_seconds() it does not crash.
> 
> Here is what I do:
> 
> int main()
> {
>   CFrame *frame = new CFrame();
>   result = frame->OpenPort();
>   if( !result )
>   return 1;
>   else
>   {
>g_timer_add_seconds( 1, (GSourceFunc) frame->ReadData(), NULL );
>gtk_widget_show( window );
>frame->ReadData();
>gtk_main();
>   }
> }
> 
> in frame.h:
> 
> class CFrame
> {
>  void ReadData();
> }
> 
> Do you see any problems with that?
> Basically followed example from 
> http://zetcode.com/tutorials/gtktutorial/gtkevents/.

ReadData() is not a good old C function, but a C++ method, carrying
around a pointer to the CFrame instance. You should make ReadData() static
or use more advanced tecniques, such as libsigc++ [1].

Ciao.
-- 
Nicola


[1] http://libsigc.sourceforge.net/

> 
> >
> >> How do I debug/fix it?
> >> 
> >
> >There are many answers to this, all outside the scope of this mailing
> >list. How do you normally approach debugging?
> 
> Just run the program under gdb and get the point of crash.
> Check all the variables at runtime under gdb.
> Then study the code and see what the problem is.
> 
> Thank you.
> 
> >
> >Cheers,
> >Rob
> 
> ___
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Doubts about creating a new widget

2010-07-12 Thread Nicola Fontana
Il giorno Mon, 12 Jul 2010 14:19:12 +0200
CaStarCo  ha scritto:

> Hello, my name is Andreu and i'm new in this list.
> 
> I have a doubt about if I should create a new widget or if there is a widget
> that could supply my needs.
> 
> I'll describe what I need: I want to make a left column in the window with
> "flat" toggle buttons (with the 100% of the column width) that, when I press
> one of the buttons then the buttons that are below than it should go down to
> give space to a icon list with a vertical scroll bar.
> 
> I need it to sort the elements in a diagram editor that i'm programming.

>From what I understood, I'd use GtkExpander.

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


Re: How to get Width and height..

2010-06-16 Thread Nicola Fontana
Il giorno Wed, 16 Jun 2010 15:42:09 +0530
Lohitha R  ha scritto:

> Hi all,
> 
>   Is there any way to get the screen resolution(monitor) in 
> gtk..??

If by resolution you mean size in pixels, you could use
gdk_screen_get_{width,height}() with the default screen.

http://library.gnome.org/devel/gdk/stable/GdkScreen.html

> or is there any way to get the size of the maximized gtk 
> window(gtk widget) in gtk.

If you need to read the size after the window is mapped, you can
connect a callback to the GtkWidget:configure-event signal:

http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-configure-event

You'll get also a notification whenever the window is resized for
free.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: problem about cross compiling win32 program under linux

2010-06-08 Thread Nicola Fontana
Il giorno Tue, 8 Jun 2010 21:14:59 +0800
Roy Chang  ha scritto:

> *I tend to compile win32 gtk program under linux using mingw like this:*
> 
> i486-mingw32-gcc  `pkg-config --libs --cflags gtk+-2.0`
> -Isoftware/win_gtk_dev/zlib-dev_1.2.4-2_win32/include
> -Lsoftware/win_gtk_dev/zlib-dev_1.2.4-2_win32/lib -lz
> -Isoftware/win_gtk_dev/gettext-runtime-dev-0.17-1/include
> -Lsoftware/win_gtk_dev/gettext-runtime-dev-0.17-1/lib hello.c -o hello.exe

First of all, I'd suggest to read this:

http://mail.gnome.org/archives/gtk-app-devel-list/2010-February/msg00036.html

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


Re: Pango context in size request

2010-03-24 Thread Nicola Fontana
Il giorno Wed, 24 Mar 2010 19:03:06 +
Robert Pearce  ha scritto:

> Hi group,
> 
> This is probably a dumb-ass question that I ought to know the answer
> to, but...
> 
> I'm building a custom widget which includes some text that needs to be
> fitted round. To do it right I need to obtain the size of these by
> calling Pango functions with a context obtained for the widget. Is it
> guaranteed OK to do this in the .._size_request function? I kind of
> figure it must be because lots of widgets (labels, for example) must
> surely do so, but I can't find any definite confirmation in the docs.


The question is not dumb, but I fail to understand why people are so
scared of source code:

http://git.gnome.org/browse/gtk+/tree/gtk/gtklabel.c#n3133

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Draw on top of a window

2010-03-12 Thread Nicola Fontana
Il giorno Fri, 12 Mar 2010 10:41:04 +0800
Richard Kung  ha scritto:

> I want to use cairo to draw on top of a window but don't know how to 
> achieve it.
> [...]
>g_signal_connect(window, "expose-event", G_CALLBACK 
> (on_expose_event), NULL);

Using g_signal_connect_after() instead of g_signal_connect() should
call your callback after the default handler.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: array in g_signal_new

2009-11-25 Thread Nicola Fontana
Il giorno Wed, 25 Nov 2009 23:20:24 +
Daniel Carvalho  ha scritto:

> The problem is the library needs to emit a signal where the argument
> is an list of integers. I could use an int[] or a GArray in this
> case... Want to ask you how to specify the gtype of the param. Or
> please point me to any open source app that uses this kind of thing.
> 
> 
> How to declare it?
> 
> klass->fields_destroyed_signal =
>   g_signal_new(I_("fields-destroyed"),
>G_OBJECT_CLASS_TYPE(klass),
>G_SIGNAL_RUN_LAST,
>G_STRUCT_OFFSET(VteTerminalClass,
> fields_destroyed), NULL,
>NULL,
>g_cclosure_marshal_VOID__VOID,
>G_TYPE_NONE, 1,
>G_TYPE_UINT // what to put here???
>);

What's wrong in using a G_TYPE_POINTER? Also notice you'll need to use
a properly marshaller.

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GPtrArray has no insert?

2009-11-10 Thread Nicola Fontana
Il giorno Mon, 09 Nov 2009 18:10:49 +0100
Martin Kalbfuß  ha scritto:

> So a GPtrArray would be the right choice. But I can't see any
> insertion function like the GArray has. Is such a function not
> present or is it simply not documented?
> 
> And what happens when I try to access a non existent element with an
> out of range index? The documentation says nothing about this?

Hi,

there is no g_array_insert_val() equivalent for GPtrArray, you must
implement it by yourself. If you just want to write data, access directy
the pdata field or use g_ptr_array_index().

If you access out of bounds items you get the same results you encounter
with any array: plain garbage if you are reading and a segmentation
fault if you are writing (and lucky).

Ciao.
-- 
Nicola
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list