303
303
gchar *substitute_time_and_date_pattern(gchar *pattern) {
304
304
// Substitue time+date pattern
306
// Typical pattern is: "%Y-%m-%d-%H:%M:%S"
306
// Typical pattern is: "%Y-%m-%d-%H-%M-%S"
307
307
// See: https://linux.die.net/man/3/strftime
749
749
g_free(filename_pattern);
751
751
// Translators: This is a default filename pattern. You can keept this as it is.
752
filename_pattern = g_strdup(_("%Y-%m-%d-%H:%M:%S"));
752
filename_pattern = g_strdup(_("%Y-%m-%d-%H-%M-%S"));
753
753
conf_save_string_value("filename-pattern", filename_pattern);
892
gchar *g_strrstr0(gchar *haystack, gchar *needle) {
892
gchar *g_strrstr0(const gchar *haystack, const gchar *needle) {
893
893
// Same as g_strrstr() but this tests for NULL values (and avoids annoying warnings).
894
894
if (!(haystack && needle)) return NULL;
895
895
return g_strrstr(haystack, needle);
932
932
GdkPixbuf *load_icon_pixbuf(gchar *icon_name, guint _size) {
933
933
// Load icon pixbuf from current icon theme.
934
GdkPixbuf *pixbuf = NULL;
936
934
if (!icon_name) {
940
// Normally icon name should equal exec name (without path) in .desktip files
938
// Normally icon name should equal exec name (without path) in .desktop files
942
940
// Current icon theme
943
941
GtkIconTheme *theme = gtk_icon_theme_get_default();
945
943
// Load icon from its theme
946
pixbuf = gtk_icon_theme_load_icon(theme, icon_name, _size, 0, NULL);
944
GError *error = NULL;
945
GdkPixbuf *pixbuf = NULL;
947
// Check first with gtk_icon_theme_has_icon() to avoid GTK-warning
948
if (gtk_icon_theme_has_icon(theme, icon_name)) {
949
pixbuf = gtk_icon_theme_load_icon(theme, icon_name, _size, 0, &error);
949
if (!GDK_IS_PIXBUF(pixbuf)) {
950
954
// Some media players set entire path for the icon in .desktop file (this is probably a mistake)
951
955
// Like: /snap/imsplayer/34/usr/share/imsplayer/icons/imsplayer-128.png
953
959
// Load directly from a file
954
960
pixbuf = get_pixbuf_from_file(icon_name, _size, _size);
974
GdkPixbuf *load_icon_pixbuf_from_name_list(gchar *icon_name_list, gchar *delim, guint _size) {
975
// icon_name_list has candidate icon names delimited by delim.
977
// If ordinary icon_names fail, then try to locad own "xxx.png" icon.
978
// Eg. "audio-card\naudio-speaker-center\nloudspeakers.png";
980
GdkPixbuf *pixbuf = NULL;
982
gchar **lst = g_strsplit(icon_name_list, delim, 20);
984
while (lst && lst[i]) {
986
pixbuf = load_icon_pixbuf((gchar*)lst[i], _size);
988
// Got an icon image?
989
if (GDK_IS_PIXBUF(pixbuf)) {
993
// Is it our own "xxx.png" icon?
994
if (g_strrstr0(lst[i], ".")) {
996
gchar *path = get_image_path(lst[i]);
997
pixbuf = get_pixbuf_from_file(path, _size, _size);
1000
// Got an icon image?
1001
if (GDK_IS_PIXBUF(pixbuf)) {
1017
GdkPixbuf* load_icon_pixbuf(gchar *icon_name) {
1018
GtkIconTheme *icon_theme;
1020
GError *error = NULL;
1024
icon_theme = gtk_icon_theme_get_default();
1026
pixbuf = gtk_icon_theme_load_icon(icon_theme, icon_name, size, 0, &error);
1029
g_debug("Couldn't load icon: %s", error->message);
1030
g_error_free(error);
968
1038
void kill_program_by_name(gchar *app_name, GPid preserve_pid) {
969
1039
// Kill all app_name processes. But do not kill preserve_pid.
970
1040
// Use this to kill programs that do not respond to client requests (dbus request).