qulogic/libgnt

Promote some GntWS functions to public API.

2019-05-10, Elliott Sales de Andrade
7def12661316
Parents c170d9e55711
Children dabd19f1b1bb
Promote some GntWS functions to public API.

These are used in the WM plugins, so cannot be entirely private.
  • +1 -1
    gntmain.c
  • +8 -7
    gntwm.c
  • +31 -30
    gntws.c
  • +38 -0
    gntws.h
  • +0 -3
    gntwsprivate.h
  • +1 -3
    wms/irssi.c
  • +1 -3
    wms/s.c
  • --- a/gntmain.c Sat May 11 01:00:16 2019 +0000
    +++ b/gntmain.c Fri May 10 20:33:50 2019 -0400
    @@ -241,7 +241,7 @@
    } else if (event == GNT_MOUSE_UP) {
    if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) {
    /* Clicked on the taskbar */
    - int n = g_list_length(gnt_ws_get_list(
    + int n = g_list_length(gnt_ws_get_widgets(
    gnt_wm_get_current_workspace(wm)));
    if (n) {
    int width = getmaxx(stdscr) / n;
    --- a/gntwm.c Sat May 11 01:00:16 2019 +0000
    +++ b/gntwm.c Fri May 10 20:33:50 2019 -0400
    @@ -477,7 +477,7 @@
    }
    w = gnt_ws_get_top_widget(priv->cws);
    - list = gnt_ws_get_list(priv->cws);
    + list = gnt_ws_get_widgets(priv->cws);
    orgpos = pos = g_list_index(list, w);
    g_return_if_fail(pos >= 0);
    @@ -531,7 +531,7 @@
    else
    n = 0;
    - if ((l = g_list_nth(gnt_ws_get_list(priv->cws), n)) != NULL) {
    + if ((l = g_list_nth(gnt_ws_get_widgets(priv->cws), n)) != NULL) {
    gnt_wm_raise_window(wm, l->data);
    }
    @@ -659,7 +659,8 @@
    GList *iter;
    GntTree *tree = GNT_TREE(priv->windows->tree);
    if (!workspace) {
    - for (iter = gnt_ws_get_list(priv->cws); iter; iter = iter->next) {
    + for (iter = gnt_ws_get_widgets(priv->cws); iter;
    + iter = iter->next) {
    GntBox *box = GNT_BOX(iter->data);
    gnt_tree_add_row_last(
    @@ -674,7 +675,7 @@
    for (; ws; ws = ws->next) {
    gnt_tree_add_row_last(tree, ws->data,
    gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL);
    - for (iter = gnt_ws_get_list(GNT_WS(ws->data)); iter;
    + for (iter = gnt_ws_get_widgets(GNT_WS(ws->data)); iter;
    iter = iter->next) {
    GntBox *box = GNT_BOX(iter->data);
    @@ -940,7 +941,7 @@
    static void
    shift_window(GntWMPrivate *priv, GntWidget *widget, int dir)
    {
    - GList *all = gnt_ws_get_list(priv->cws);
    + GList *all = gnt_ws_get_widgets(priv->cws);
    GList *list = g_list_find(all, widget);
    int length, pos;
    if (!list)
    @@ -1828,7 +1829,7 @@
    static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid)
    {
    GntWS *s = (GntWS *)workspace;
    - GList *list = gnt_ws_get_list(s);
    + GList *list = gnt_ws_get_widgets(s);
    if (list && g_list_find(list, wid)) {
    return 0;
    }
    @@ -2063,7 +2064,7 @@
    }
    if (s) {
    - pos = g_list_index(gnt_ws_get_list(s), widget);
    + pos = g_list_index(gnt_ws_get_widgets(s), widget);
    if (pos != -1) {
    gnt_ws_remove_widget(s, widget);
    --- a/gntws.c Sat May 11 01:00:16 2019 +0000
    +++ b/gntws.c Fri May 10 20:33:50 2019 -0400
    @@ -148,6 +148,15 @@
    wrefresh(taskbar);
    }
    +gboolean
    +gnt_ws_is_empty(GntWS *ws)
    +{
    + GntWSPrivate *priv = NULL;
    + g_return_val_if_fail(GNT_IS_WS(ws), TRUE);
    + priv = gnt_ws_get_instance_private(ws);
    + return priv->ordered == NULL;
    +}
    +
    void gnt_ws_add_widget(GntWS *ws, GntWidget* wid)
    {
    GntWSPrivate *priv = NULL;
    @@ -174,6 +183,28 @@
    priv->ordered = g_list_remove(priv->ordered, wid);
    }
    +GntWidget *
    +gnt_ws_get_top_widget(GntWS *ws)
    +{
    + GntWSPrivate *priv = NULL;
    +
    + g_return_val_if_fail(GNT_IS_WS(ws), NULL);
    + priv = gnt_ws_get_instance_private(ws);
    +
    + return priv->ordered ? priv->ordered->data : NULL;
    +}
    +
    +GList *
    +gnt_ws_get_widgets(GntWS *ws)
    +{
    + GntWSPrivate *priv = NULL;
    +
    + g_return_val_if_fail(GNT_IS_WS(ws), NULL);
    + priv = gnt_ws_get_instance_private(ws);
    +
    + return priv->list;
    +}
    +
    void
    gnt_ws_set_name(GntWS *ws, const gchar *name)
    {
    @@ -254,26 +285,6 @@
    }
    /* Internal. */
    -GList *
    -gnt_ws_get_list(GntWS *ws)
    -{
    - GntWSPrivate *priv = NULL;
    - g_return_val_if_fail(GNT_IS_WS(ws), NULL);
    - priv = gnt_ws_get_instance_private(ws);
    - return priv->list;
    -}
    -
    -/* Internal. */
    -gboolean
    -gnt_ws_is_empty(GntWS *ws)
    -{
    - GntWSPrivate *priv = NULL;
    - g_return_val_if_fail(GNT_IS_WS(ws), TRUE);
    - priv = gnt_ws_get_instance_private(ws);
    - return priv->ordered == NULL;
    -}
    -
    -/* Internal. */
    gboolean
    gnt_ws_is_single(GntWS *ws)
    {
    @@ -284,16 +295,6 @@
    }
    /* Internal. */
    -GntWidget *
    -gnt_ws_get_top_widget(GntWS *ws)
    -{
    - GntWSPrivate *priv = NULL;
    - g_return_val_if_fail(GNT_IS_WS(ws), NULL);
    - priv = gnt_ws_get_instance_private(ws);
    - return priv->ordered ? priv->ordered->data : NULL;
    -}
    -
    -/* Internal. */
    gboolean
    gnt_ws_is_top_widget(GntWS *ws, GntWidget *widget)
    {
    --- a/gntws.h Sat May 11 01:00:16 2019 +0000
    +++ b/gntws.h Fri May 10 20:33:50 2019 -0400
    @@ -83,6 +83,18 @@
    void gnt_ws_set_name(GntWS *ws, const gchar *name);
    /**
    + * gnt_ws_is_empty:
    + * @ws: The workspace.
    + *
    + * Gets whether the workspace contains no widgets.
    + *
    + * Returns: %TRUE if the workspace is empty, %FALSE otherwise.
    + *
    + * Since: 3.0.0
    + */
    +gboolean gnt_ws_is_empty(GntWS *ws);
    +
    +/**
    * gnt_ws_add_widget:
    * @ws: The workspace.
    * @widget: The widget to add.
    @@ -105,6 +117,32 @@
    void gnt_ws_remove_widget(GntWS *ws, GntWidget *widget);
    /**
    + * gnt_ws_get_top_widget:
    + * @ws: The workspace.
    + *
    + * Gets the widget that is at the top of the workspace.
    + *
    + * Returns: (transfer none): The widget at the top of the workspace.
    + *
    + * Since: 3.0.0
    + */
    +GntWidget *gnt_ws_get_top_widget(GntWS *ws);
    +
    +/**
    + * gnt_ws_get_widgets:
    + * @ws: The workspace.
    + *
    + * Gets all widgets contained in the workspace. This is probably only useful
    + * for implementing #GntWM subclasses.
    + *
    + * Returns: (transfer none) (element-type GntWidget): The list of widgets in
    + * the workspace.
    + *
    + * Since: 3.0.0
    + */
    +GList *gnt_ws_get_widgets(GntWS *ws);
    +
    +/**
    * gnt_ws_widget_hide:
    * @widget: The widget to hide.
    * @nodes: A hashtable containing information about the widgets.
    --- a/gntwsprivate.h Sat May 11 01:00:16 2019 +0000
    +++ b/gntwsprivate.h Fri May 10 20:33:50 2019 -0400
    @@ -29,16 +29,13 @@
    G_BEGIN_DECLS
    /* Private access to some internals. Contact us if you need these. */
    -gboolean gnt_ws_is_empty(GntWS *ws);
    gboolean gnt_ws_is_single(GntWS *ws);
    -GntWidget *gnt_ws_get_top_widget(GntWS *ws);
    gboolean gnt_ws_is_top_widget(GntWS *ws, GntWidget *widget);
    GList *gnt_ws_get_last(GntWS *ws);
    void gnt_ws_append_widget(GntWS *ws, GntWidget *widget);
    void gnt_ws_bring_to_front(GntWS *ws, GntWidget *widget);
    void gnt_ws_set_list(GntWS *ws, GList *list);
    -GList *gnt_ws_get_list(GntWS *ws);
    G_END_DECLS
    --- a/wms/irssi.c Sat May 11 01:00:16 2019 +0000
    +++ b/wms/irssi.c Fri May 10 20:33:50 2019 -0400
    @@ -43,8 +43,6 @@
    #include "gntwindow.h"
    #include "gntlabel.h"
    -#include "gntwsprivate.h"
    -
    #define GNT_TYPE_IRSSI_WM gnt_irssi_wm_get_type()
    G_DECLARE_FINAL_TYPE(GntIrssiWM, gnt_irssi_wm, GNT, IRSSI_WM, GntWM)
    @@ -246,7 +244,7 @@
    g_object_set_data(
    G_OBJECT(win), "irssi-index",
    GINT_TO_POINTER(g_list_index(
    - gnt_ws_get_list(gnt_wm_get_current_workspace(wm)),
    + gnt_ws_get_widgets(gnt_wm_get_current_workspace(wm)),
    win)));
    g_timeout_add(0, (GSourceFunc)update_conv_window_title, node);
    }
    --- a/wms/s.c Sat May 11 01:00:16 2019 +0000
    +++ b/wms/s.c Fri May 10 20:33:50 2019 -0400
    @@ -33,8 +33,6 @@
    #include "gntwindow.h"
    #include "gntlabel.h"
    -#include "gntwsprivate.h"
    -
    #define GNT_TYPE_S_WM gnt_s_wm_get_type()
    G_DECLARE_FINAL_TYPE(GntSWM, gnt_s_wm, GNT, S_WM, GntWM)
    @@ -148,7 +146,7 @@
    static GntWidget *
    find_widget(GntWM *wm, const char *wname)
    {
    - GList *iter = gnt_ws_get_list(gnt_wm_get_current_workspace(wm));
    + GList *iter = gnt_ws_get_widgets(gnt_wm_get_current_workspace(wm));
    for (; iter; iter = iter->next) {
    GntWidget *widget = iter->data;
    const char *name = gnt_widget_get_name(widget);