File: MakerDialogUtil.h

package info (click to toggle)
ibus-chewing 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 856 kB
  • sloc: ansic: 6,013; xml: 103; sh: 84; makefile: 33
file content (139 lines) | stat: -rw-r--r-- 4,211 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright © 2014  Red Hat, Inc. All rights reserved.
 * Copyright © 2014  Ding-Yi Chen <dchen at redhat.com>
 *
 * This file is part of the ibus-chewing Project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * SECTION:MakerDialogUtil.h
 * @short_description: Utility functions for MakerDialog
 * @title: MakerDialog Util
 * @stability: Stable
 * @include: MakerDialogUtil.h
 *
 * Utility functions for MakerDialog.
 * The functions have <emphasis>mkdg_</emphasis> prefix,
 * while definitions have <emphasis>Mkdg</emphasis> prefix.
 */

#ifndef _MAKER_DIALOG_UTIL_H_
#    define _MAKER_DIALOG_UTIL_H_
#    include <stdio.h>
#    include <string.h>
#    include <glib-object.h>

/**
 * MkdgLogLevel:
 * @ERROR: Show auses of failure, the program should stop
 * @WARN:  Show issues to be address, the program will still run.
 * @MSG:   Show normal message
 * @INFO:  Show information message
 * @DEBUG: Show debug message
 *
 * Message verbose level, from low to high. Similar to Log level of Gtk.
 *
 */
typedef enum {
    ERROR,
    WARN,
    MSG,
    INFO,
    DEBUG
} MkdgLogLevel;

void mkdg_log_set_level(MkdgLogLevel level);

void mkdg_log_set_domain(const gchar * domain);

void mkdg_log_set_file(FILE * file);

void mkdg_log(MkdgLogLevel level, const gchar * format, ...);

void mkdg_log_domain(const gchar * domain, MkdgLogLevel level,
                     const gchar * format, ...);

gchar *mkdg_g_value_to_string(GValue * value);

gboolean mkdg_g_value_reset(GValue * value, GType type, gboolean overwrite);

gboolean mkdg_g_value_from_string(GValue * value, const gchar * str);

gint mkdg_g_ptr_array_find_string(GPtrArray * array, const gchar * str);

#    define mkdg_g_value_is_boolean(value) (G_VALUE_TYPE(value)==G_TYPE_BOOLEAN)

#    define mkdg_g_value_is_int(value) (G_VALUE_TYPE(value)==G_TYPE_INT)

#    define mkdg_g_value_is_uint(value) (G_VALUE_TYPE(value)==G_TYPE_UINT)

#    define mkdg_g_value_is_string(value) (G_VALUE_TYPE(value)==G_TYPE_STRING)

void mkdg_g_variant_to_g_value(GVariant * gVar, GValue * value);

GVariant *mkdg_g_value_to_g_variant(GValue * value);


/**************************************
 * String Utility Macros and Functions
 */

#    define QUOTE_ME_INNER(s) #s
#    define QUOTE_ME(s) QUOTE_ME_INNER(s)

#    define STRING_IS_EMPTY(str) \
    (!str  || \
     (str[0] == '\0')\
    )

#    define STRING_EQUALS(str1, str2) \
    ((str1==NULL && str2==NULL) ||\
     ((str1!=NULL && str2!=NULL) && strcmp(str1, str2)==0) \
    )

gchar *mkdg_str_dash_to_camel(const gchar * argStr);

/**************************************
 * Flag Utility Macros
 */

#    define mkdg_clear_flag(flagSet, flag) (flagSet &= ~(flag))
#    define mkdg_has_flag(flagSet, flag) ((flagSet & flag) == flag)
#    define mkdg_set_flag(flagSet, flag) (flagSet |= flag)

/**************************************
 * XML data structure and functions
 */

typedef enum {
    MKDG_XML_TAG_TYPE_NO_TAG,
    MKDG_XML_TAG_TYPE_EMPTY,
    MKDG_XML_TAG_TYPE_SHORT,
    MKDG_XML_TAG_TYPE_LONG,
    MKDG_XML_TAG_TYPE_BEGIN_ONLY,
    MKDG_XML_TAG_TYPE_END_ONLY,
} MkdgXmlTagType;

gchar *mkdg_xml_attr_append(gchar * buf, gint bufferSize,
                            const gchar * attr, const gchar * value);

gboolean mkdg_xml_tags_write(FILE * outF, const gchar * tagName,
                             MkdgXmlTagType type, const gchar * attribute,
                             const gchar * value);

#    define MAKER_DIALOG_VALUE_LENGTH 200
#endif                          /* _MAKER_DIALOG_UTIL_H_ */