mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -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);
|
gboolean new = prefs_get_boolean(PREF_TRAY);
|
||||||
if (old != new) {
|
if (old != new) {
|
||||||
if (new) {
|
if (new) {
|
||||||
create_tray();
|
tray_enable();
|
||||||
} else {
|
} else {
|
||||||
destroy_tray();
|
tray_disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -380,7 +380,7 @@ _shutdown(void)
|
|||||||
cl_ev_disconnect();
|
cl_ev_disconnect();
|
||||||
}
|
}
|
||||||
#ifdef HAVE_GTK
|
#ifdef HAVE_GTK
|
||||||
tray_close();
|
tray_shutdown();
|
||||||
#endif
|
#endif
|
||||||
jabber_shutdown();
|
jabber_shutdown();
|
||||||
plugins_on_shutdown();
|
plugins_on_shutdown();
|
||||||
|
16
src/tray.c
16
src/tray.c
@ -145,6 +145,7 @@ _tray_change_icon(gpointer data)
|
|||||||
void
|
void
|
||||||
tray_init(void)
|
tray_init(void)
|
||||||
{
|
{
|
||||||
|
_get_icons();
|
||||||
gtk_ready = gtk_init_check(0, NULL);
|
gtk_ready = gtk_init_check(0, NULL);
|
||||||
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
||||||
if (!gtk_ready) {
|
if (!gtk_ready) {
|
||||||
@ -155,7 +156,7 @@ tray_init(void)
|
|||||||
gtk_main_iteration_do(FALSE);
|
gtk_main_iteration_do(FALSE);
|
||||||
if (prefs_get_boolean(PREF_TRAY)) {
|
if (prefs_get_boolean(PREF_TRAY)) {
|
||||||
log_debug("Building GTK icon");
|
log_debug("Building GTK icon");
|
||||||
create_tray();
|
tray_enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,24 +169,25 @@ tray_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tray_close(void)
|
tray_shutdown(void)
|
||||||
{
|
{
|
||||||
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
|
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
|
void
|
||||||
create_tray(void)
|
tray_enable(void)
|
||||||
{
|
{
|
||||||
_get_icons();
|
|
||||||
prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
|
prof_tray = gtk_status_icon_new_from_file(icon_filename->str);
|
||||||
shutting_down = FALSE;
|
shutting_down = FALSE;
|
||||||
timer = g_timeout_add(5000, _tray_change_icon, NULL);
|
timer = g_timeout_add(5000, _tray_change_icon, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
destroy_tray(void)
|
tray_disable(void)
|
||||||
{
|
{
|
||||||
shutting_down = TRUE;
|
shutting_down = TRUE;
|
||||||
g_source_remove(timer);
|
g_source_remove(timer);
|
||||||
@ -193,8 +195,6 @@ destroy_tray(void)
|
|||||||
g_clear_object(&prof_tray);
|
g_clear_object(&prof_tray);
|
||||||
prof_tray = NULL;
|
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_init(void);
|
||||||
void tray_update(void);
|
void tray_update(void);
|
||||||
void tray_close(void);
|
void tray_shutdown(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create tray icon
|
* 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
|
* This will initialize the timer that will be called in order to change the icons
|
||||||
* and will search the icons in the defaults paths
|
* and will search the icons in the defaults paths
|
||||||
*/
|
*/
|
||||||
void create_tray(void);
|
void tray_enable(void);
|
||||||
/*
|
/*
|
||||||
* Destroy tray icon
|
* Destroy tray icon
|
||||||
*/
|
*/
|
||||||
void destroy_tray(void);
|
void tray_disable(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user