messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

ui.h (3307B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2022--2024 GNUnet e.V.
      4 
      5    GNUnet is free software: you can redistribute it and/or modify it
      6    under the terms of the GNU Affero General Public License as published
      7    by the Free Software Foundation, either version 3 of the License,
      8    or (at your option) any later version.
      9 
     10    GNUnet is distributed in the hope that it will be useful, but
     11    WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Affero General Public License for more details.
     14 
     15    You should have received a copy of the GNU Affero General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18    SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 /*
     21  * @author Tobias Frisch
     22  * @file ui.h
     23  */
     24 
     25 #ifndef UI_H_
     26 #define UI_H_
     27 
     28 #include <gtk-3.0/gtk/gtk.h>
     29 #include <libhandy-1/handy.h>
     30 #include <stdint.h>
     31 
     32 /**
     33  * Returns a new builder instance using the UI
     34  * definitions from a given resource path.
     35  *
     36  * @param resource_path Resource path
     37  * @return New builder
     38  */
     39 GtkBuilder*
     40 ui_builder_from_resource(const char *resource_path);
     41 
     42 /**
     43  * Sets the text of a GtkLabel applying automatic utf8
     44  * conversion.
     45  *
     46  * @param label Label
     47  * @param text Non-utf8 text
     48  */
     49 void
     50 ui_label_set_text(GtkLabel *label,
     51                   const char *text);
     52 
     53 /**
     54  * Sets the text of a GtkLabel applying automatic utf8
     55  * conversion and replaces supported syntax with proper
     56  * markup.
     57  *
     58  * @param label Label
     59  * @param text Non-utf8 text
     60  */
     61 void
     62 ui_label_set_markup_text(GtkLabel *label,
     63                          const char *text);
     64 
     65 /**
     66  * Sets the text of a GtkLabel applying conversion from
     67  * file size to string representation.
     68  *
     69  * @param label Label
     70  * @param size File size
     71  */
     72 void
     73 ui_label_set_size(GtkLabel *label,
     74                   uint64_t size);
     75 
     76 /**
     77  * Sets the text of a GtkEntry applying automatic utf8
     78  * conversion.
     79  *
     80  * @param entry Entry
     81  * @param text Non-utf8 text
     82  */
     83 void
     84 ui_entry_set_text(GtkEntry *entry,
     85                   const char *text);
     86 
     87 /**
     88  * Returns the text from a GtkEntry applying automatic 
     89  * inverse utf8 conversion.
     90  *
     91  * @param entry Entry
     92  */
     93 char*
     94 ui_entry_get_text(GtkEntry *entry);
     95 
     96 /**
     97  * Sets the text of a HdyAvatar applying automatic utf8
     98  * conversion.
     99  *
    100  * @param avatar Avatar
    101  * @param text Non-utf8 text
    102  */
    103 void
    104 ui_avatar_set_text(HdyAvatar *avatar,
    105                    const char *text);
    106 
    107 /**
    108  * Sets the icon of a HdyAvatar.
    109  *
    110  * @param avatar Avatar
    111  * @param icon Loadable icon
    112  */
    113 void
    114 ui_avatar_set_icon(HdyAvatar *avatar,
    115                    GIcon *icon);
    116 
    117 /**
    118  * Searches for a specific data set as qdata inside a 
    119  * container.
    120  *
    121  * @param container Container
    122  * @param quark Quark
    123  * @param data Data
    124  */
    125 gboolean
    126 ui_find_qdata_in_container(GtkContainer *container,
    127                            GQuark quark,
    128                            const gpointer data);
    129 
    130 /**
    131  * Removes children from container which qdata is missing
    132  * inside a list of data.
    133  *
    134  * @param container Container
    135  * @param quark Quark
    136  * @param list List of data
    137  */
    138 void
    139 ui_clear_container_of_missing_qdata(GtkContainer *container,
    140                                     GQuark quark,
    141                                     const GList *list);
    142 
    143 #endif /* UI_H_ */