qulogic/libgnt

Finch-OTR: implement e2ee conversation menu

2014-04-26, Tomasz Wasilczyk
2df252827bbd
Parents e371fbc0847d
Children 192e8ff66e5f
Finch-OTR: implement e2ee conversation menu
  • +2 -0
    gnt.h
  • +2 -0
    gntmenu.c
  • +26 -0
    gntmenuitem.c
  • +38 -0
    gntmenuitem.h
  • --- a/gnt.h Sat Apr 26 15:04:55 2014 +0200
    +++ b/gnt.h Sat Apr 26 19:55:55 2014 +0200
    @@ -64,6 +64,8 @@
    *
    * You have to call this before #gnt_init. You might want to call this
    * with %NULL, to free the resources, but not before a call to #gnt_quit.
    + *
    + * Since: 2.8.0
    */
    void gnt_set_config_dir(const gchar *config_dir);
    --- a/gntmenu.c Sat Apr 26 15:04:55 2014 +0200
    +++ b/gntmenu.c Sat Apr 26 19:55:55 2014 +0200
    @@ -87,6 +87,8 @@
    for (i = 0, iter = menu->list; iter; iter = iter->next, i++) {
    GntMenuItem *item = GNT_MENU_ITEM(iter->data);
    + if (!gnt_menuitem_is_visible(item))
    + continue;
    type = ' ' | gnt_color_pair(GNT_COLOR_HIGHLIGHT);
    if (i == menu->selected)
    type |= A_REVERSE;
    --- a/gntmenuitem.c Sat Apr 26 15:04:55 2014 +0200
    +++ b/gntmenuitem.c Sat Apr 26 19:55:55 2014 +0200
    @@ -65,6 +65,10 @@
    static void
    gnt_menuitem_init(GTypeInstance *instance, gpointer klass)
    {
    + GntMenuItem *item = GNT_MENU_ITEM(instance);
    + GntMenuItemPriv *priv = &item->priv;
    +
    + priv->visible = TRUE;
    }
    /******************************************************************************
    @@ -157,3 +161,25 @@
    return FALSE;
    }
    +void
    +gnt_menuitem_set_visible(GntMenuItem *item, gboolean visible)
    +{
    + GntMenuItemPriv *priv = &item->priv;
    +
    + priv->visible = visible;
    +}
    +
    +gboolean
    +gnt_menuitem_is_visible(GntMenuItem *item)
    +{
    + g_return_val_if_fail(GNT_IS_MENU_ITEM(item), FALSE);
    +
    + return item->priv.visible;
    +}
    +
    +void
    +gnt_menuitem_set_text(GntMenuItem *item, const gchar *text)
    +{
    + g_free(item->text);
    + item->text = g_strdup(text);
    +}
    --- a/gntmenuitem.h Sat Apr 26 15:04:55 2014 +0200
    +++ b/gntmenuitem.h Sat Apr 26 19:55:55 2014 +0200
    @@ -56,6 +56,7 @@
    int y;
    char trigger;
    char *id;
    + gboolean visible;
    };
    typedef void (*GntMenuItemCallback)(GntMenuItem *item, gpointer data);
    @@ -195,6 +196,43 @@
    */
    gboolean gnt_menuitem_activate(GntMenuItem *item);
    +/**
    + * gnt_menuitem_set_visible:
    + * @item: The menuitem.
    + * @visible: %TRUE to make @item visible, %FALSE to hide it.
    + *
    + * Sets @item visible or not.
    + *
    + * Since: 2.8.0
    + */
    +void
    +gnt_menuitem_set_visible(GntMenuItem *item, gboolean visible);
    +
    +/**
    + * gnt_menuitem_is_visible:
    + * @item: The menuitem.
    + *
    + * Checks, if the @item is visible.
    + *
    + * Returns: %TRUE, if the @item is visible.
    + *
    + * Since: 2.8.0
    + */
    +gboolean
    +gnt_menuitem_is_visible(GntMenuItem *item);
    +
    +/**
    + * gnt_menuitem_set_text:
    + * @item: The menuitem.
    + * @text: The new text.
    + *
    + * Changes the text for an @item.
    + *
    + * Since: 2.8.0
    + */
    +void
    +gnt_menuitem_set_text(GntMenuItem *item, const gchar *text);
    +
    G_END_DECLS
    #endif /* GNT_MENUITEM_H */