mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add checks for whether gdk-pixbuf exists before using avatar set
This commit is contained in:
parent
6a44e18853
commit
0cff111249
11
configure.ac
11
configure.ac
@ -65,6 +65,8 @@ AC_ARG_WITH([themes],
|
||||
[AS_HELP_STRING([--with-themes[[=PATH]]], [install themes (default yes)])])
|
||||
AC_ARG_ENABLE([icons-and-clipboard],
|
||||
[AS_HELP_STRING([--enable-icons-and-clipboard], [enable GTK tray icons and clipboard paste support])])
|
||||
AC_ARG_ENABLE([gdk-pixbuf],
|
||||
[AS_HELP_STRING([--enable-gdk-pixbuf], [enable GDK Pixbuf support])])
|
||||
|
||||
# Required dependencies
|
||||
|
||||
@ -306,6 +308,15 @@ if test "x$enable_otr" != xno; then
|
||||
AM_COND_IF([BUILD_OTR], [AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])])
|
||||
fi
|
||||
|
||||
dnl feature: pixbuf
|
||||
AS_IF([test "x$enable_pixbuf" != xno],
|
||||
[PKG_CHECK_MODULES([gdk_pixbuf], [gdk-pixbuf-2.0 >= 2.4],
|
||||
[AC_DEFINE([HAVE_PIXBUF], [1], [gdk-pixbuf module])],
|
||||
[AS_IF([test "x$enable_pixbuf" = xyes],
|
||||
[AC_MSG_ERROR([gdk-pixbuf-2.0 >= 2.4 is required for GDK Pixbuf support])],
|
||||
[AC_MSG_NOTICE([gdk-pixbuf-2.0 >= 2.4 not found, GDK Pixbuf support not enabled])])])])
|
||||
|
||||
|
||||
dnl feature: omemo
|
||||
AM_CONDITIONAL([BUILD_OMEMO], [false])
|
||||
if test "x$enable_omemo" != xno; then
|
||||
|
@ -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
|
||||
|
@ -8,8 +8,11 @@ avatar_get_by_nick(const char* nick)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PIXBUF
|
||||
gboolean
|
||||
avatar_set(const char* path)
|
||||
{
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user