mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Load/destroy tray icons on init/shutdown
This commit is contained in:
parent
de65f505a8
commit
12727744ab
@ -5546,9 +5546,9 @@ cmd_tray(ProfWin *window, const char *const command, gchar **args)
|
||||
gboolean new = prefs_get_boolean(PREF_TRAY);
|
||||
if (old != new) {
|
||||
if (new) {
|
||||
create_tray();
|
||||
tray_enable();
|
||||
} else {
|
||||
destroy_tray();
|
||||
tray_disable();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -380,7 +380,7 @@ _shutdown(void)
|
||||
cl_ev_disconnect();
|
||||
}
|
||||
#ifdef HAVE_GTK
|
||||
tray_close();
|
||||
tray_shutdown();
|
||||
#endif
|
||||
jabber_shutdown();
|
||||
plugins_on_shutdown();
|
||||
|
16
src/tray.c
16
src/tray.c
@ -145,6 +145,7 @@ _tray_change_icon(gpointer data)
|
||||
void
|
||||
tray_init(void)
|
||||
{
|
||||
_get_icons();
|
||||
gtk_ready = gtk_init_check(0, NULL);
|
||||
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
||||
if (!gtk_ready) {
|
||||
@ -155,7 +156,7 @@ tray_init(void)
|
||||
gtk_main_iteration_do(FALSE);
|
||||
if (prefs_get_boolean(PREF_TRAY)) {
|
||||
log_debug("Building GTK icon");
|
||||
create_tray();
|
||||
tray_enable();
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,24 +169,25 @@ tray_update(void)
|
||||
}
|
||||
|
||||
void
|
||||
tray_close(void)
|
||||
tray_shutdown(void)
|
||||
{
|
||||
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
|
||||
destroy_tray();
|
||||
tray_disable();
|
||||
}
|
||||
g_string_free(icon_filename, TRUE);
|
||||
g_string_free(icon_msg_filename, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
create_tray(void)
|
||||
tray_enable(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);
|
||||
}
|
||||
|
||||
void
|
||||
destroy_tray(void)
|
||||
tray_disable(void)
|
||||
{
|
||||
shutting_down = TRUE;
|
||||
g_source_remove(timer);
|
||||
@ -193,8 +195,6 @@ destroy_tray(void)
|
||||
g_clear_object(&prof_tray);
|
||||
prof_tray = NULL;
|
||||
}
|
||||
g_string_free(icon_filename, TRUE);
|
||||
g_string_free(icon_msg_filename, TRUE);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
void tray_init(void);
|
||||
void tray_update(void);
|
||||
void tray_close(void);
|
||||
void tray_shutdown(void);
|
||||
|
||||
/*
|
||||
* Create tray icon
|
||||
@ -45,10 +45,10 @@ void tray_close(void);
|
||||
* 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);
|
||||
void tray_enable(void);
|
||||
/*
|
||||
* Destroy tray icon
|
||||
*/
|
||||
void destroy_tray(void);
|
||||
void tray_disable(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user