qulogic/libgnt

Use G_DEFINE_TYPE for GntWM and GntWS.

2019-04-03, Elliott Sales de Andrade
44cdc95eabee
Parents c3de29b0a6c5
Children 8643bb415dca
Use G_DEFINE_TYPE for GntWM and GntWS.
  • +3 -29
    gntwm.c
  • +24 -37
    gntws.c
  • --- a/gntwm.c Wed Apr 03 20:44:30 2019 -0400
    +++ b/gntwm.c Wed Apr 03 20:58:39 2019 -0400
    @@ -104,6 +104,8 @@
    static gboolean started_python = FALSE;
    #endif
    +G_DEFINE_TYPE(GntWM, gnt_wm, GNT_TYPE_BINDABLE)
    +
    static GList *
    g_list_bring_to_front(GList *list, gpointer data)
    {
    @@ -380,9 +382,8 @@
    }
    static void
    -gnt_wm_init(GTypeInstance *instance, gpointer class)
    +gnt_wm_init(GntWM *wm)
    {
    - GntWM *wm = GNT_WM(instance);
    wm->workspaces = NULL;
    wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    @@ -1584,33 +1585,6 @@
    /******************************************************************************
    * GntWM API
    *****************************************************************************/
    -GType
    -gnt_wm_get_type(void)
    -{
    - static GType type = 0;
    -
    - if(type == 0) {
    - static const GTypeInfo info = {
    - sizeof(GntWMClass),
    - NULL, /* base_init */
    - NULL, /* base_finalize */
    - (GClassInitFunc)gnt_wm_class_init,
    - NULL,
    - NULL, /* class_data */
    - sizeof(GntWM),
    - 0, /* n_preallocs */
    - gnt_wm_init, /* instance_init */
    - NULL /* value_table */
    - };
    -
    - type = g_type_register_static(GNT_TYPE_BINDABLE,
    - "GntWM",
    - &info, 0);
    - }
    -
    - return type;
    -}
    -
    void
    gnt_wm_add_workspace(GntWM *wm, GntWS *ws)
    {
    --- a/gntws.c Wed Apr 03 20:44:30 2019 -0400
    +++ b/gntws.c Wed Apr 03 20:58:39 2019 -0400
    @@ -29,6 +29,11 @@
    #include "gntwm.h"
    #include "gntws.h"
    +G_DEFINE_TYPE(GntWS, gnt_ws, GNT_TYPE_BINDABLE)
    +
    +/******************************************************************************
    + * Helpers
    + *****************************************************************************/
    static void
    widget_hide(gpointer data, gpointer nodes)
    {
    @@ -51,6 +56,25 @@
    }
    }
    +/******************************************************************************
    + * GObject Implementation
    + *****************************************************************************/
    +static void
    +gnt_ws_init(GntWS *ws)
    +{
    + ws->list = NULL;
    + ws->ordered = NULL;
    + ws->name = NULL;
    +}
    +
    +static void
    +gnt_ws_class_init(G_GNUC_UNUSED GntWSClass *klass)
    +{
    +}
    +
    +/******************************************************************************
    + * GObject Implementation
    + *****************************************************************************/
    void
    gnt_ws_draw_taskbar(GntWS *ws, gboolean reposition)
    {
    @@ -105,15 +129,6 @@
    wrefresh(taskbar);
    }
    -static void
    -gnt_ws_init(GTypeInstance *instance, gpointer class)
    -{
    - GntWS *ws = GNT_WS(instance);
    - ws->list = NULL;
    - ws->ordered = NULL;
    - ws->name = NULL;
    -}
    -
    void gnt_ws_add_widget(GntWS *ws, GntWidget* wid)
    {
    GntWidget *oldfocus;
    @@ -161,34 +176,6 @@
    widget_show(l->data, nodes);
    }
    -GType
    -gnt_ws_get_type(void)
    -{
    - static GType type = 0;
    -
    - if(type == 0) {
    - static const GTypeInfo info = {
    - sizeof(GntWSClass),
    - NULL, /* base_init */
    - NULL, /* base_finalize */
    - NULL,
    - /*(GClassInitFunc)gnt_ws_class_init,*/
    - NULL,
    - NULL, /* class_data */
    - sizeof(GntWS),
    - 0, /* n_preallocs */
    - gnt_ws_init, /* instance_init */
    - NULL /* value_table */
    - };
    -
    - type = g_type_register_static(GNT_TYPE_BINDABLE,
    - "GntWS",
    - &info, 0);
    - }
    -
    - return type;
    -}
    -
    GntWS *gnt_ws_new(const char *name)
    {
    GntWS *ws = GNT_WS(g_object_new(GNT_TYPE_WS, NULL));