mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Moved gtk specific code to tray.c
This commit is contained in:
parent
507ea5746c
commit
de65f505a8
@ -38,7 +38,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GTK
|
||||
#include <gtk/gtk.h>
|
||||
#include "tray.h"
|
||||
#endif
|
||||
#include <locale.h>
|
||||
@ -96,9 +95,6 @@ char *saved_status;
|
||||
|
||||
static gboolean cont = TRUE;
|
||||
static gboolean force_quit = FALSE;
|
||||
#ifdef HAVE_GTK
|
||||
static gboolean gtk_ready = FALSE;
|
||||
#endif
|
||||
|
||||
void
|
||||
prof_run(char *log_level, char *account_name)
|
||||
@ -138,9 +134,7 @@ prof_run(char *log_level, char *account_name)
|
||||
iq_autoping_check();
|
||||
ui_update();
|
||||
#ifdef HAVE_GTK
|
||||
if (gtk_ready) {
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
tray_update();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -365,16 +359,7 @@ _init(char *log_level)
|
||||
atexit(_shutdown);
|
||||
plugins_init();
|
||||
#ifdef HAVE_GTK
|
||||
gtk_ready = gtk_init_check(0, NULL);
|
||||
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
||||
if (gtk_ready) {
|
||||
gtk_init(0, NULL);
|
||||
gtk_main_iteration_do(FALSE);
|
||||
if (prefs_get_boolean(PREF_TRAY)) {
|
||||
log_debug("Building GTK icon");
|
||||
create_tray();
|
||||
}
|
||||
}
|
||||
tray_init();
|
||||
#endif
|
||||
inp_nonblocking(TRUE);
|
||||
}
|
||||
@ -395,9 +380,7 @@ _shutdown(void)
|
||||
cl_ev_disconnect();
|
||||
}
|
||||
#ifdef HAVE_GTK
|
||||
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
|
||||
destroy_tray();
|
||||
}
|
||||
tray_close();
|
||||
#endif
|
||||
jabber_shutdown();
|
||||
plugins_on_shutdown();
|
||||
|
35
src/tray.c
35
src/tray.c
@ -42,7 +42,9 @@
|
||||
#include "tray.h"
|
||||
#include "window_list.h"
|
||||
#include "log.h"
|
||||
#include "config/preferences.h"
|
||||
|
||||
static gboolean gtk_ready = FALSE;
|
||||
static GtkStatusIcon *prof_tray = NULL;
|
||||
static GString *icon_filename = NULL;
|
||||
static GString *icon_msg_filename = NULL;
|
||||
@ -140,6 +142,39 @@ _tray_change_icon(gpointer data)
|
||||
/* }}} */
|
||||
/* {{{ Public */
|
||||
|
||||
void
|
||||
tray_init(void)
|
||||
{
|
||||
gtk_ready = gtk_init_check(0, NULL);
|
||||
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
||||
if (!gtk_ready) {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_init(0, NULL);
|
||||
gtk_main_iteration_do(FALSE);
|
||||
if (prefs_get_boolean(PREF_TRAY)) {
|
||||
log_debug("Building GTK icon");
|
||||
create_tray();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tray_update(void)
|
||||
{
|
||||
if (gtk_ready) {
|
||||
gtk_main_iteration_do(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tray_close(void)
|
||||
{
|
||||
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
|
||||
destroy_tray();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
create_tray(void)
|
||||
{
|
||||
|
@ -35,6 +35,10 @@
|
||||
#ifndef PROFANITY_TRAY_H
|
||||
#define PROFANITY_TRAY_H
|
||||
|
||||
void tray_init(void);
|
||||
void tray_update(void);
|
||||
void tray_close(void);
|
||||
|
||||
/*
|
||||
* Create tray icon
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user