mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Run the main loop with GMainLoop
This commit is contained in:
parent
605ee6e99a
commit
f995944734
@ -43,6 +43,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -86,15 +87,15 @@
|
|||||||
static void _init(char* log_level, char* config_file, char* log_file, char* theme_name);
|
static void _init(char* log_level, char* config_file, char* log_file, char* theme_name);
|
||||||
static void _shutdown(void);
|
static void _shutdown(void);
|
||||||
static void _connect_default(const char* const account);
|
static void _connect_default(const char* const account);
|
||||||
|
static gboolean _main_update(gpointer data);
|
||||||
|
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
static gboolean force_quit = FALSE;
|
static gboolean force_quit = FALSE;
|
||||||
|
static GMainLoop* main_loop = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name)
|
prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name)
|
||||||
{
|
{
|
||||||
gboolean cont = TRUE;
|
|
||||||
|
|
||||||
_init(log_level, config_file, log_file, theme_name);
|
_init(log_level, config_file, log_file, theme_name);
|
||||||
plugins_on_start();
|
plugins_on_start();
|
||||||
_connect_default(account_name);
|
_connect_default(account_name);
|
||||||
@ -105,33 +106,9 @@ prof_run(char* log_level, char* account_name, char* config_file, char* log_file,
|
|||||||
|
|
||||||
session_init_activity();
|
session_init_activity();
|
||||||
|
|
||||||
char* line = NULL;
|
main_loop = g_main_loop_new(NULL, TRUE);
|
||||||
while (cont && !force_quit) {
|
g_timeout_add(1000/60, _main_update, NULL);
|
||||||
log_stderr_handler();
|
g_main_loop_run(main_loop);
|
||||||
session_check_autoaway();
|
|
||||||
|
|
||||||
line = inp_readline();
|
|
||||||
if (line) {
|
|
||||||
ProfWin* window = wins_get_current();
|
|
||||||
cont = cmd_process_input(window, line);
|
|
||||||
free(line);
|
|
||||||
line = NULL;
|
|
||||||
} else {
|
|
||||||
cont = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
|
||||||
otr_poll();
|
|
||||||
#endif
|
|
||||||
plugins_run_timed();
|
|
||||||
notify_remind();
|
|
||||||
session_process_events();
|
|
||||||
iq_autoping_check();
|
|
||||||
ui_update();
|
|
||||||
#ifdef HAVE_GTK
|
|
||||||
tray_update();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -140,6 +117,40 @@ prof_set_quit(void)
|
|||||||
force_quit = TRUE;
|
force_quit = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_main_update(gpointer data)
|
||||||
|
{
|
||||||
|
log_stderr_handler();
|
||||||
|
session_check_autoaway();
|
||||||
|
|
||||||
|
gboolean cont = TRUE;
|
||||||
|
char *line = inp_readline();
|
||||||
|
if (line) {
|
||||||
|
ProfWin* window = wins_get_current();
|
||||||
|
cont = cmd_process_input(window, line);
|
||||||
|
free(line);
|
||||||
|
line = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOTR
|
||||||
|
otr_poll();
|
||||||
|
#endif
|
||||||
|
plugins_run_timed();
|
||||||
|
notify_remind();
|
||||||
|
session_process_events();
|
||||||
|
iq_autoping_check();
|
||||||
|
ui_update();
|
||||||
|
#ifdef HAVE_GTK
|
||||||
|
tray_update();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!cont)
|
||||||
|
g_main_loop_quit(main_loop);
|
||||||
|
|
||||||
|
// Always repeat
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_connect_default(const char* const account)
|
_connect_default(const char* const account)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user