mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 09:06:22 +00:00
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:
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