1
0
Fork 0

Use a folder to add icons

NOTE: it is not working in this release, I have to get how to retrieve
icons from folder.
This commit is contained in:
David 2016-03-07 22:25:30 +01:00
parent d1177d3ade
commit 718a708b93
6 changed files with 39 additions and 7 deletions

View File

@ -140,6 +140,8 @@ otr_unittest_sources = \
themes_sources = themes/*
icons_sources = icons/*
script_sources = bootstrap.sh configure-debug install-all.sh
man_sources = docs/profanity.1
@ -168,6 +170,8 @@ endif
if INCLUDE_GIT_VERSION
BUILT_SOURCES = $(git_include)
endif
profanity_iconsdir = @ICONS_PATH@
profanity_icons_DATA = $(icons_sources)
TESTS = tests/unittests/unittests
check_PROGRAMS = tests/unittests/unittests
@ -187,7 +191,7 @@ endif
man_MANS = $(man_sources)
EXTRA_DIST = $(man_sources) $(themes_sources) $(script_sources) profrc.example LICENSE.txt
EXTRA_DIST = $(man_sources) $(icons_sources) $(themes_sources) $(script_sources) profrc.example LICENSE.txt
if INCLUDE_GIT_VERSION
EXTRA_DIST += .git/HEAD .git/index

View File

@ -192,6 +192,9 @@ AS_IF([test "x$with_themes" = xno -o "x$with_themes" = xyes -o "x$with_themes" =
AC_SUBST(THEMES_PATH)
AM_CONDITIONAL([THEMES_INSTALL], "$THEMES_INSTALL")
ICONS_PATH='${pkgdatadir}/icons'
AC_SUBST(ICONS_PATH)
### cmocka is required only for tests, profanity shouldn't be linked with it
### TODO: pass cmocka_CFLAGS and cmocka_LIBS to Makefile.am
PKG_CHECK_MODULES([cmocka], [cmocka], [],
@ -213,7 +216,7 @@ AM_CFLAGS="-Wall -Wno-deprecated-declarations"
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS ${GTK_CFLAGS}"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
AM_CPPFLAGS="$AM_CPPFLAGS -DICONS_PATH=\"\\\"$ICONS_PATH\\\"\" -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $LIBS ${GTK_LIBS}"
AC_SUBST(AM_CFLAGS)
@ -234,5 +237,6 @@ echo "LIBS : $LIBS"
echo "XML Parser : $PARSER"
echo "Install themes : $THEMES_INSTALL"
echo "Themes path : $THEMES_PATH"
echo "Icons path : $ICONS_PATH"
echo ""
echo "Now you can run \`make' to build profanity"

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -403,6 +403,8 @@ _create_directories(void)
GString *themes_dir = g_string_new(xdg_config);
g_string_append(themes_dir, "/profanity/themes");
GString *icons_dir = g_string_new(xdg_config);
g_string_append(icons_dir, "/profanity/icons");
GString *chatlogs_dir = g_string_new(xdg_data);
g_string_append(chatlogs_dir, "/profanity/chatlogs");
GString *logs_dir = g_string_new(xdg_data);
@ -411,6 +413,9 @@ _create_directories(void)
if (!mkdir_recursive(themes_dir->str)) {
log_error("Error while creating directory %s", themes_dir->str);
}
if (!mkdir_recursive(icons_dir->str)) {
log_error("Error while creating directory %s", icons_dir->str);
}
if (!mkdir_recursive(chatlogs_dir->str)) {
log_error("Error while creating directory %s", chatlogs_dir->str);
}
@ -419,6 +424,7 @@ _create_directories(void)
}
g_string_free(themes_dir, TRUE);
g_string_free(icons_dir, TRUE);
g_string_free(chatlogs_dir, TRUE);
g_string_free(logs_dir, TRUE);

View File

@ -40,12 +40,22 @@
#include "window_list.h"
static GtkStatusIcon *prof_tray = NULL;
static gchar *icon_filename = "src/proIcon.png";
static gchar *icon_msg_filename = "src/proIconMsg.png";
static GString *icon_filename = NULL;
static GString *icon_msg_filename = NULL;
static int unread_messages;
static bool shutting_down;
static guint timer;
static gchar*
_get_icons_dir(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *icons_dir = g_string_new(xdg_config);
g_free(xdg_config);
g_string_append(icons_dir, "/profanity/icons");
return g_string_free(icons_dir, true);
}
gboolean tray_change_icon(gpointer data)
{
if (shutting_down) {
@ -55,9 +65,9 @@ gboolean tray_change_icon(gpointer data)
unread_messages = wins_get_total_unread();
if (unread_messages) {
gtk_status_icon_set_from_file(prof_tray, icon_msg_filename);
gtk_status_icon_set_from_file(prof_tray, icon_msg_filename->str);
} else {
gtk_status_icon_set_from_file(prof_tray, icon_filename);
gtk_status_icon_set_from_file(prof_tray, icon_filename->str);
}
return true;
@ -65,9 +75,15 @@ gboolean tray_change_icon(gpointer data)
void create_tray(void)
{
prof_tray = gtk_status_icon_new_from_file(icon_filename);
gchar *icons_dir = _get_icons_dir();
icon_filename = g_string_new(icons_dir);
icon_msg_filename = g_string_new(icons_dir);
g_string_append(icon_filename, "/proIcon.png");
g_string_append(icon_msg_filename, "/proIconMsg.png");
prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
shutting_down = false;
timer = g_timeout_add(5000, tray_change_icon, NULL);
g_free(icons_dir);
}
void destroy_tray(void)
@ -78,4 +94,6 @@ void destroy_tray(void)
gtk_widget_destroy(GTK_WIDGET(prof_tray));
prof_tray = NULL;
}
g_string_free(icon_filename, false);
g_string_free(icon_msg_filename, false);
}