mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
fixing leakings
This commit is contained in:
parent
82de077b02
commit
520eee23a9
31
src/tray.c
31
src/tray.c
@ -43,9 +43,19 @@ static GtkStatusIcon *prof_tray = NULL;
|
||||
static GString *icon_filename = NULL;
|
||||
static GString *icon_msg_filename = NULL;
|
||||
static gint unread_messages;
|
||||
static bool shutting_down;
|
||||
static gboolean shutting_down;
|
||||
static guint timer;
|
||||
|
||||
/* {{{ Privates */
|
||||
|
||||
/*
|
||||
* Get icons from installation share folder or (if defined) .locale user's folder
|
||||
*
|
||||
* As implementation, looking through all the entries in the .locale folder is chosen.
|
||||
* While useless as now, it might be useful in case an association name-icon is created.
|
||||
* As now, with 2 icons only, this is pretty useless, but it is not harming ;)
|
||||
*
|
||||
*/
|
||||
static void _get_icons(void)
|
||||
{
|
||||
GString *icons_dir = NULL;
|
||||
@ -74,26 +84,34 @@ static void _get_icons(void)
|
||||
GString *name = g_string_new(g_dir_read_name(dir));
|
||||
while (name->len) {
|
||||
if (g_strcmp0("proIcon.png", name->str) == 0) {
|
||||
g_string_free(icon_filename, true);
|
||||
icon_filename = g_string_new(icons_dir->str);
|
||||
g_string_append(icon_filename, "/proIcon.png");
|
||||
} else
|
||||
if (g_strcmp0("proIconMsg.png", name->str) == 0){
|
||||
g_string_free(icon_msg_filename, true);
|
||||
icon_msg_filename = g_string_new(icons_dir->str);
|
||||
g_string_append(icon_msg_filename, "/proIconMsg.png");
|
||||
}
|
||||
g_string_free(name, true);
|
||||
name = g_string_new(g_dir_read_name(dir));
|
||||
}
|
||||
g_string_free(name, true);
|
||||
} else {
|
||||
fprintf (stderr, "Unable to open dir: %s\n", err->message);
|
||||
g_error_free(err);
|
||||
}
|
||||
g_dir_close(dir);
|
||||
g_free(err);
|
||||
g_string_free(icons_dir, true);
|
||||
}
|
||||
|
||||
gboolean tray_change_icon(gpointer data)
|
||||
/*
|
||||
* Callback for the timer
|
||||
*
|
||||
* This is the callback that the timer is calling in order to check if messages are there.
|
||||
*
|
||||
*/
|
||||
gboolean _tray_change_icon(gpointer data)
|
||||
{
|
||||
if (shutting_down) {
|
||||
return false;
|
||||
@ -110,12 +128,15 @@ gboolean tray_change_icon(gpointer data)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public */
|
||||
|
||||
void create_tray(void)
|
||||
{
|
||||
_get_icons();
|
||||
prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
|
||||
shutting_down = false;
|
||||
timer = g_timeout_add(5000, tray_change_icon, NULL);
|
||||
timer = g_timeout_add(5000, _tray_change_icon, NULL);
|
||||
}
|
||||
|
||||
void destroy_tray(void)
|
||||
@ -129,3 +150,5 @@ void destroy_tray(void)
|
||||
g_string_free(icon_filename, true);
|
||||
g_string_free(icon_msg_filename, true);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
@ -35,7 +35,16 @@
|
||||
#ifndef PROFANITY_TRAY_H
|
||||
#define PROFANITY_TRAY_H
|
||||
|
||||
/*
|
||||
* Create tray icon
|
||||
*
|
||||
* This will initialize the timer that will be called in order to change the icons
|
||||
* and will search the icons in the defaults paths
|
||||
*/
|
||||
void create_tray(void);
|
||||
/*
|
||||
* Destroy tray icon
|
||||
*/
|
||||
void destroy_tray(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user