qulogic/libgnt

Merged in default (pull request #41)

2019-04-23, Gary Kramlich
d808614e672c
Merged in default (pull request #41)

Hide some easy GntWS fields

Approved-by: Gary Kramlich
  • +0 -8
    gntwm.c
  • +40 -9
    gntws.c
  • +0 -2
    gntws.h
  • --- a/gntwm.c Mon Apr 22 03:20:47 2019 -0400
    +++ b/gntwm.c Tue Apr 23 20:44:47 2019 +0000
    @@ -1687,16 +1687,8 @@
    return NULL;
    }
    -static void
    -free_workspaces(gpointer data, G_GNUC_UNUSED gpointer n)
    -{
    - GntWS *s = data;
    - g_free(s->name);
    -}
    -
    void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces)
    {
    - g_list_foreach(wm->workspaces, free_workspaces, NULL);
    wm->workspaces = workspaces;
    gnt_wm_switch_workspace(wm, 0);
    }
    --- a/gntws.c Mon Apr 22 03:20:47 2019 -0400
    +++ b/gntws.c Tue Apr 23 20:44:47 2019 +0000
    @@ -29,7 +29,12 @@
    #include "gntwm.h"
    #include "gntws.h"
    -G_DEFINE_TYPE(GntWS, gnt_ws, GNT_TYPE_BINDABLE)
    +typedef struct
    +{
    + gchar *name;
    +} GntWSPrivate;
    +
    +G_DEFINE_TYPE_WITH_PRIVATE(GntWS, gnt_ws, GNT_TYPE_BINDABLE)
    /******************************************************************************
    * Helpers
    @@ -60,16 +65,27 @@
    * GObject Implementation
    *****************************************************************************/
    static void
    +gnt_ws_destroy(GObject *obj)
    +{
    + GntWS *ws = GNT_WS(obj);
    + GntWSPrivate *priv = gnt_ws_get_instance_private(ws);
    +
    + g_free(priv->name);
    +}
    +
    +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)
    +gnt_ws_class_init(GntWSClass *klass)
    {
    + GObjectClass *obj_class = G_OBJECT_CLASS(klass);
    +
    + obj_class->dispose = gnt_ws_destroy;
    }
    /******************************************************************************
    @@ -148,8 +164,13 @@
    void
    gnt_ws_set_name(GntWS *ws, const gchar *name)
    {
    - g_free(ws->name);
    - ws->name = g_strdup(name);
    + GntWSPrivate *priv = NULL;
    +
    + g_return_if_fail(GNT_IS_WS(ws));
    + priv = gnt_ws_get_instance_private(ws);
    +
    + g_free(priv->name);
    + priv->name = g_strdup(name);
    }
    void
    @@ -176,15 +197,25 @@
    widget_show(l->data, nodes);
    }
    -GntWS *gnt_ws_new(const char *name)
    +GntWS *
    +gnt_ws_new(const gchar *name)
    {
    GntWS *ws = GNT_WS(g_object_new(GNT_TYPE_WS, NULL));
    - ws->name = g_strdup(name ? name : "(noname)");
    + GntWSPrivate *priv = gnt_ws_get_instance_private(ws);
    +
    + priv->name = g_strdup(name ? name : "(noname)");
    +
    return ws;
    }
    -const char * gnt_ws_get_name(GntWS *ws)
    +const gchar *
    +gnt_ws_get_name(GntWS *ws)
    {
    - return ws->name;
    + GntWSPrivate *priv = NULL;
    +
    + g_return_val_if_fail(GNT_IS_WS(ws), NULL);
    + priv = gnt_ws_get_instance_private(ws);
    +
    + return priv->name;
    }
    --- a/gntws.h Mon Apr 22 03:20:47 2019 -0400
    +++ b/gntws.h Tue Apr 23 20:44:47 2019 +0000
    @@ -50,10 +50,8 @@
    struct _GntWS
    {
    GntBindable inherit;
    - char *GNTSEAL(name);
    GList *GNTSEAL(list);
    GList *GNTSEAL(ordered);
    - gpointer GNTSEAL(ui_data);
    void *GNTSEAL(res1);
    void *GNTSEAL(res2);