How do you write common codes for GObject?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How do you write common codes for GObject?

Kouhei Sutou
Hi,

We need to write common codes for GObject like the
followings:

#define GTK_TYPE_WIDGET  (gtk_widget_get_type ())
#define GTK_WIDGET(widget)  (G_TYPE_CHECK_INSTANCE_CAST ((widget), GTK_TYPE_WIDGET, GtkWidget))
#define GTK_WIDGET_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET, GtkWidgetClass))
#define GTK_IS_WIDGET(widget)  (G_TYPE_CHECK_INSTANCE_TYPE ((widget), GTK_TYPE_WIDGET))
#define GTK_IS_WIDGET_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET))
#define GTK_WIDGET_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET, GtkWidgetClass))


How do you write them?

  a. Write them from scratch
  b. Copy from existing codes, paste them to new source file
     and substitute them
  c. Generate them by script
  d. Other

My approach is b. If there is better approach, I want to use
it. Please share your approach.


Thanks,
--
kou
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: How do you write common codes for GObject?

Emmanuele Bassi
On 4 September 2017 at 15:03, Kouhei Sutou <[hidden email]> wrote:

> Hi,
>
> We need to write common codes for GObject like the
> followings:
>
> #define GTK_TYPE_WIDGET                   (gtk_widget_get_type ())
> #define GTK_WIDGET(widget)                (G_TYPE_CHECK_INSTANCE_CAST ((widget), GTK_TYPE_WIDGET, GtkWidget))
> #define GTK_WIDGET_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET, GtkWidgetClass))
> #define GTK_IS_WIDGET(widget)             (G_TYPE_CHECK_INSTANCE_TYPE ((widget), GTK_TYPE_WIDGET))
> #define GTK_IS_WIDGET_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET))
> #define GTK_WIDGET_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET, GtkWidgetClass))
>
>
> How do you write them?

>   d. Other

Use G_DECLARE_FINAL_TYPE and G_DECLARE_DERIVABLE_TYPE from GObject.

https://developer.gnome.org/gobject/stable/howto-gobject.html#howto-gobject-header

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: How do you write common codes for GObject?

Gtk+ - General mailing list
In reply to this post by Kouhei Sutou
use new macros if you don't need back compatibility


Il giorno lun 04 set 2017 16:03:55 CEST, Kouhei Sutou ha scritto:

> Hi,
>
> We need to write common codes for GObject like the
> followings:
>
> #define GTK_TYPE_WIDGET  (gtk_widget_get_type ())
> #define GTK_WIDGET(widget)  (G_TYPE_CHECK_INSTANCE_CAST ((widget),  
> GTK_TYPE_WIDGET, GtkWidget))
> #define GTK_WIDGET_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST  
> ((klass), GTK_TYPE_WIDGET, GtkWidgetClass))
> #define GTK_IS_WIDGET(widget)  (G_TYPE_CHECK_INSTANCE_TYPE  
> ((widget), GTK_TYPE_WIDGET))
> #define GTK_IS_WIDGET_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE  
> ((klass), GTK_TYPE_WIDGET))
> #define GTK_WIDGET_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS  
> ((obj), GTK_TYPE_WIDGET, GtkWidgetClass))
>
>
> How do you write them?
>
>   a. Write them from scratch
>   b. Copy from existing codes, paste them to new source file
>      and substitute them
>   c. Generate them by script
>   d. Other
>
> My approach is b. If there is better approach, I want to use
> it. Please share your approach.
>
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: How do you write common codes for GObject?

Gergely Polonkai
In reply to this post by Kouhei Sutou
If I ned to be backwards compatible, I go with GobGen (an Emacs package I wrote, available on MELPA). If not, see ebassi’s answer.

On Mon, Sep 4, 2017, 16:46 Kouhei Sutou <[hidden email]> wrote:
Hi,

We need to write common codes for GObject like the
followings:

#define GTK_TYPE_WIDGET                   (gtk_widget_get_type ())
#define GTK_WIDGET(widget)                (G_TYPE_CHECK_INSTANCE_CAST ((widget), GTK_TYPE_WIDGET, GtkWidget))
#define GTK_WIDGET_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WIDGET, GtkWidgetClass))
#define GTK_IS_WIDGET(widget)             (G_TYPE_CHECK_INSTANCE_TYPE ((widget), GTK_TYPE_WIDGET))
#define GTK_IS_WIDGET_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WIDGET))
#define GTK_WIDGET_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WIDGET, GtkWidgetClass))


How do you write them?

  a. Write them from scratch
  b. Copy from existing codes, paste them to new source file
     and substitute them
  c. Generate them by script
  d. Other

My approach is b. If there is better approach, I want to use
it. Please share your approach.


Thanks,
--
kou
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: How do you write common codes for GObject?

Kouhei Sutou
In reply to this post by Emmanuele Bassi
Hi,

Thanks to all!

In <CALnHYQGtLYzZ1BjXkxt6TdgzX-63mKCmkyG=pm2=[hidden email]>
  "Re: How do you write common codes for GObject?" on Mon, 4 Sep 2017 15:49:34 +0100,
  Emmanuele Bassi <[hidden email]> wrote:

>> We need to write common codes for GObject like the
>> followings:
...
>> How do you write them?
>
>>   d. Other
>
> Use G_DECLARE_FINAL_TYPE and G_DECLARE_DERIVABLE_TYPE from GObject.
>
> https://developer.gnome.org/gobject/stable/howto-gobject.html#howto-gobject-header

Oh! I didn't know the API. I'll use them.


Thanks,
--
kou
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list