3
* Copyright (c) 2003 Michael Vogt
5
* Author: Michael Vogt <mvo@debian.org>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of the
10
* License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
35
void RGFlushInterface()
37
XSync(gdk_display, False);
39
while (gtk_events_pending()) {
45
* SizeToStr: Converts a size long into a human-readable SI string
46
* ----------------------------------------------------
47
* A maximum of four digits are shown before conversion to the next highest
48
* unit. The maximum length of the string will be five characters unless the
49
* size is more than ten yottabytes.
51
* mvo: we use out own SizeToStr function as the SI spec says we need a
52
* space between the number and the unit (this isn't the case in stock apt
54
string SizeToStr(double Size)
64
/* Bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, exabytes,
65
* zettabytes, yottabytes.
67
char Ext[] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
70
if (ASize < 100 && I != 0) {
71
snprintf(S, 300, "%.1f %cB", ASize, Ext[I]);
76
snprintf(S, 300, "%.0f %cB", ASize, Ext[I]);
86
bool is_binary_in_path(const char *program)
88
gchar **path = g_strsplit(getenv("PATH"), ":", 0);
90
for (int i = 0; path[i] != NULL; i++) {
91
char *s = g_strdup_printf("%s/%s", path[i], program);
103
char *gtk_get_string_from_color(GdkColor * colp)
105
static char *_str = NULL;
112
_str = g_strdup_printf("#%4X%4X%4X", colp->red, colp->green, colp->blue);
113
for (char *ptr = _str; *ptr; ptr++)
120
void gtk_get_color_from_string(const char *cpp, GdkColor **colp)
126
if (strlen(cpp) == 0) {
131
GdkColormap *colormap = gdk_colormap_get_system();
133
new_color = g_new(GdkColor, 1);
134
result = gdk_color_parse(cpp, new_color);
135
gdk_colormap_alloc_color(colormap, new_color, FALSE, TRUE);
139
const char *utf8_to_locale(const char *str)
141
static char *_str = NULL;
144
if (g_utf8_validate(str, -1, NULL) == false)
148
_str = g_locale_from_utf8(str, -1, NULL, NULL, NULL);
152
const char *utf8(const char *str)
154
static char *_str = NULL;
157
if (g_utf8_validate(str, -1, NULL) == true)
161
_str = g_locale_to_utf8(str, -1, NULL, NULL, NULL);