qulogic/libgnt

Hide GntWM->name_places and GntWM->title_places.

2019-05-10, Elliott Sales de Andrade
21693d24a116
Parents df3ccd076dbe
Children 4ac81525515d
Hide GntWM->name_places and GntWM->title_places.
  • +8 -4
    gntstyle.c
  • +34 -5
    gntwm.c
  • +0 -2
    gntwm.h
  • +3 -0
    gntwmprivate.h
  • --- a/gntstyle.c Fri May 10 02:39:07 2019 -0400
    +++ b/gntstyle.c Fri May 10 02:49:35 2019 -0400
    @@ -28,6 +28,8 @@
    #include "gntcolors.h"
    #include "gntws.h"
    +#include "gntwmprivate.h"
    +
    #include <glib.h>
    #include <ctype.h>
    #include <stdlib.h>
    @@ -188,15 +190,17 @@
    titles = g_key_file_get_string_list(gkfile, group, "window-names", &c, NULL);
    if (titles) {
    - for (j = 0; j < c; ++j)
    - g_hash_table_replace(wm->name_places, g_strdup(titles[j]), ws);
    + for (j = 0; j < c; ++j) {
    + gnt_wm_set_place_by_name(wm, titles[j], ws);
    + }
    g_strfreev(titles);
    }
    titles = g_key_file_get_string_list(gkfile, group, "window-titles", &c, NULL);
    if (titles) {
    - for (j = 0; j < c; ++j)
    - g_hash_table_replace(wm->title_places, g_strdup(titles[j]), ws);
    + for (j = 0; j < c; ++j) {
    + gnt_wm_set_place_by_title(wm, titles[j], ws);
    + }
    g_strfreev(titles);
    }
    }
    --- a/gntwm.c Fri May 10 02:39:07 2019 -0400
    +++ b/gntwm.c Fri May 10 02:49:35 2019 -0400
    @@ -86,6 +86,9 @@
    GntListWindow *windows; /* Window-list window */
    GntListWindow *actions; /* Action-list window */
    + GHashTable *name_places; /* window name -> ws */
    + GHashTable *title_places; /* window title -> ws */
    +
    GList *acts; /* List of actions */
    /* Currently active menu. There can be at most one menu at a time on
    @@ -430,8 +433,10 @@
    {
    GntWMPrivate *priv = gnt_wm_get_instance_private(wm);
    - 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);
    + priv->name_places =
    + g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    + priv->title_places =
    + g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    gnt_style_read_workspaces(wm);
    if (priv->workspaces == NULL) {
    priv->cws = gnt_ws_new("default");
    @@ -1896,14 +1901,14 @@
    const gchar *name, *title;
    title = gnt_box_get_title(GNT_BOX(widget));
    if (title) {
    - ret = g_hash_table_find(wm->title_places, (GHRFunc)match_title,
    - (gpointer)title);
    + ret = g_hash_table_find(priv->title_places,
    + (GHRFunc)match_title, (gpointer)title);
    }
    if (ret)
    return ret;
    name = gnt_widget_get_name(widget);
    if (name) {
    - ret = g_hash_table_find(wm->name_places, (GHRFunc)match_title,
    + ret = g_hash_table_find(priv->name_places, (GHRFunc)match_title,
    (gpointer)name);
    }
    return ret ? ret : priv->cws;
    @@ -2436,6 +2441,30 @@
    /* Private. */
    void
    +gnt_wm_set_place_by_name(GntWM *wm, const gchar *name, GntWS *ws)
    +{
    + GntWMPrivate *priv = NULL;
    +
    + g_return_if_fail(GNT_IS_WM(wm));
    + priv = gnt_wm_get_instance_private(wm);
    +
    + g_hash_table_replace(priv->name_places, g_strdup(name), ws);
    +}
    +
    +/* Private. */
    +void
    +gnt_wm_set_place_by_title(GntWM *wm, const gchar *title, GntWS *ws)
    +{
    + GntWMPrivate *priv = NULL;
    +
    + g_return_if_fail(GNT_IS_WM(wm));
    + priv = gnt_wm_get_instance_private(wm);
    +
    + g_hash_table_replace(priv->title_places, g_strdup(title), ws);
    +}
    +
    +/* Private. */
    +void
    gnt_wm_add_action(GntWM *wm, GntAction *action)
    {
    GntWMPrivate *priv = NULL;
    --- a/gntwm.h Fri May 10 02:39:07 2019 -0400
    +++ b/gntwm.h Fri May 10 02:49:35 2019 -0400
    @@ -87,8 +87,6 @@
    /*< public >*/
    GHashTable *GNTSEAL(nodes); /* GntWidget -> GntNode */
    - GHashTable *GNTSEAL(name_places); /* window name -> ws*/
    - GHashTable *GNTSEAL(title_places); /* window title -> ws */
    GHashTable *GNTSEAL(positions);
    --- a/gntwmprivate.h Fri May 10 02:39:07 2019 -0400
    +++ b/gntwmprivate.h Fri May 10 02:49:35 2019 -0400
    @@ -52,6 +52,9 @@
    */
    gboolean gnt_wm_is_list_window(GntWM *wm, GntWidget *widget);
    +void gnt_wm_set_place_by_name(GntWM *wm, const gchar *name, GntWS *ws);
    +void gnt_wm_set_place_by_title(GntWM *wm, const gchar *title, GntWS *ws);
    +
    void gnt_wm_add_action(GntWM *wm, GntAction *action);
    GntMenu *gnt_wm_get_menu(GntWM *wm);