Add checks for whether gdk-pixbuf exists before using avatar set
This commit is contained in:
@@ -9196,9 +9196,13 @@ cmd_avatar(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "set") == 0) {
|
||||
#ifdef HAVE_PIXBUF
|
||||
if (avatar_set(args[1])) {
|
||||
cons_show("Avatar updated successfully");
|
||||
}
|
||||
#else
|
||||
cons_show("This version of Profanity has not been built with GDK Pixbuf support enabled");
|
||||
#endif
|
||||
} else if (g_strcmp0(args[0], "get") == 0) {
|
||||
avatar_get_by_nick(args[1], false);
|
||||
} else if (g_strcmp0(args[0], "open") == 0) {
|
||||
|
||||
@@ -173,6 +173,12 @@ main(int argc, char** argv)
|
||||
g_print("GTK icons/clipboard: Disabled\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PIXBUF
|
||||
g_print("GDK Pixbuf: Enabled\n");
|
||||
#else
|
||||
g_print("GDK Pixbuf: Disabled\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ avatar_pep_subscribe(void)
|
||||
shall_open = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PIXBUF
|
||||
gboolean
|
||||
avatar_set(const char* path)
|
||||
{
|
||||
@@ -104,7 +105,7 @@ avatar_set(const char* path)
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(expanded_path, &err);
|
||||
|
||||
if (pixbuf == NULL) {
|
||||
cons_show("An error occurred while opening %s: %s.", expanded_path, err ? err->message : "No error message given");
|
||||
cons_show_error("An error occurred while opening %s: %s.", expanded_path, err ? err->message : "No error message given");
|
||||
return FALSE;
|
||||
}
|
||||
free(expanded_path);
|
||||
@@ -129,7 +130,7 @@ avatar_set(const char* path)
|
||||
gsize len = -1;
|
||||
|
||||
if (!gdk_pixbuf_save_to_buffer(pixbuf, &img_data, &len, "png", &err, NULL)) {
|
||||
cons_show("Unable to scale and convert avatar.");
|
||||
cons_show_error("Unable to scale and convert avatar.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -146,6 +147,7 @@ avatar_set(const char* path)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
avatar_get_by_nick(const char* nick, gboolean open)
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
|
||||
void avatar_pep_subscribe(void);
|
||||
gboolean avatar_get_by_nick(const char* nick, gboolean open);
|
||||
#ifdef HAVE_PIXBUF
|
||||
gboolean avatar_set(const char* path);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user