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:
BIN
src/proIcon.png
BIN
src/proIcon.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -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);
|
||||
|
||||
|
||||
28
src/tray.c
28
src/tray.c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user