anastasis-gtk

Demonstrator GUI for Anastasis
Log | Files | Refs | README | LICENSE

anastasis-gtk_helper.h (4466B)


      1 /*
      2      This file is part of anastasis-gtk.
      3      Copyright (C) 2020-2021 Anastasis SARL
      4 
      5      Anastasis is free software; you can redistribute it and/or modify
      6      it under the terms of the GNU General Public License as published
      7      by the Free Software Foundation; either version 3, or (at your
      8      option) any later version.
      9 
     10      Anastasis 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      General Public License for more details.
     14 
     15      You should have received a copy of the GNU General Public License
     16      along with Anastasis; see the file COPYING.  If not, write to the
     17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     18      Boston, MA 02110-1301, USA.
     19 */
     20 
     21 /**
     22  * @file src/include/anastasis-gtk_helper.h
     23  * @brief Definition of helpers.
     24  * @author Christian Grothoff
     25  * @author Dennis Neufeld
     26  */
     27 #ifndef ANASTASIS_GTK_HELPER_H
     28 #define ANASTASIS_GTK_HELPER_H
     29 #include <gtk/gtk.h>
     30 #include <anastasis/anastasis_service.h>
     31 #include <anastasis/anastasis_redux.h>
     32 #include "anastasis-gtk.h"
     33 #include <gdk-pixbuf/gdk-pixbuf.h>
     34 
     35 
     36 /**
     37  * true if we are currently showing an error message.
     38  */
     39 extern bool AG_have_error;
     40 
     41 
     42 /**
     43  * Hide widget of the given @a name of the main window
     44  *
     45  * @param name widget to hide
     46  */
     47 void
     48 AG_hide (const char *name);
     49 
     50 
     51 /**
     52  * Show widget of the given @a name of the main window
     53  *
     54  * @param name widget to show
     55  */
     56 void
     57 AG_show (const char *name);
     58 
     59 
     60 /**
     61  * Make widget of the given @a name of the main window insensitive.
     62  *
     63  * @param name widget to make insensitive
     64  */
     65 void
     66 AG_insensitive (const char *name);
     67 
     68 
     69 /**
     70  * Make widget of the given @a name of the main window sensitive.
     71  *
     72  * @param name widget to make sensitive
     73  */
     74 void
     75 AG_sensitive (const char *name);
     76 
     77 
     78 /**
     79  * Make the 'next' button sensitive (and trigger it via 'Return').
     80  */
     81 void
     82 AG_enable_next (void);
     83 
     84 
     85 /**
     86  * Make widget of the given @a name the focus.
     87  *
     88  * @param name widget to focus
     89  */
     90 void
     91 AG_focus (const char *name);
     92 
     93 
     94 /**
     95  * Thaw the user interface.
     96  */
     97 void
     98 AG_thaw (void);
     99 
    100 
    101 /**
    102  * Freeze the user interface while the action completes.
    103  */
    104 void
    105 AG_freeze (void);
    106 
    107 
    108 /**
    109  * Hide all of the children of the container widget @a name in the main window.
    110  *
    111  * @param name name of the object
    112  */
    113 void
    114 AG_hide_children (const char *name);
    115 
    116 
    117 /**
    118  * Make all of the children of the container widget @a name in the main window
    119  * insensitive.
    120  *
    121  * @param name name of the object
    122  */
    123 void
    124 AG_insensitive_children (const char *name);
    125 
    126 
    127 /**
    128  * Show all of the children of the container widget @a name in the main window.
    129  *
    130  * @param name name of the object
    131  */
    132 void
    133 AG_show_children (const char *name);
    134 
    135 
    136 /**
    137  * Get an object from the main window.
    138  *
    139  * @param name name of the object
    140  * @return NULL on error
    141  */
    142 GObject *
    143 GCG_get_main_window_object (const char *name);
    144 
    145 
    146 /**
    147  * Checks the actual state. True, if state is correct, else false.
    148  *
    149  * @param state the state to check
    150  * @param expected_state the expected state as string
    151  * @return bool
    152  */
    153 bool
    154 AG_check_state (json_t *state,
    155                 const char *expected_state);
    156 
    157 
    158 /**
    159  * Hides all frames;
    160  */
    161 void
    162 AG_hide_all_frames (void);
    163 
    164 
    165 /**
    166  * Show error message.
    167  *
    168  * @param format format string
    169  * @param ... arguments for format string
    170  */
    171 void
    172 AG_error (const char *format,
    173           ...)
    174 __attribute__ ((format (printf, 1, 2)));
    175 
    176 
    177 /**
    178  * Stop showing error message.
    179  */
    180 void
    181 AG_error_clear (void);
    182 
    183 
    184 /**
    185  * Setup QR code image for a widget @a w.
    186  *
    187  * @param w widget to use to determine screen resolution
    188  * @param text text to encode
    189  * @param text_size number of bytes in @a text
    190  * @return NULL on failure
    191  */
    192 GdkPixbuf *
    193 AG_setup_qrcode (GtkWidget *w,
    194                  const char *text,
    195                  size_t text_size);
    196 
    197 
    198 /**
    199  * Display @a pb in the GtkImage @a img.  GTK4 images render paintables,
    200  * so the pixbuf is wrapped in a texture first.
    201  *
    202  * @param img image widget to update
    203  * @param pb pixbuf to show
    204  */
    205 void
    206 AG_image_set_from_pixbuf (GtkImage *img,
    207                           GdkPixbuf *pb);
    208 
    209 
    210 /**
    211  * Expand base @a name of a widget based on the @a type to
    212  * create the name of the widget with the data.
    213  *
    214  * @param name base name of the widget
    215  * @param type type of the widget
    216  * @return NULL on error
    217  */
    218 char *
    219 AG_expand_name (const char *name,
    220                 const char *type);
    221 
    222 
    223 #endif