1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Make tray icon configurable using /tray cmd

This commit is contained in:
Dominik Heidler 2016-04-16 16:29:32 +02:00
parent 6cc04bc3ba
commit 4cb1d73a83
8 changed files with 72 additions and 2 deletions

View File

@ -1253,6 +1253,21 @@ static struct cmd_t command_defs[] =
CMD_NOEXAMPLES
},
#ifdef HAVE_GTK
{ "/tray",
cmd_tray, parse_args, 1, 1, &cons_tray_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/tray on|off")
CMD_DESC(
"Display an icon in the tray that will indicate new messages.")
CMD_ARGS(
{ "on|off", "Enable or disable tray icon." })
CMD_NOEXAMPLES
},
#endif
{ "/intype",
cmd_intype, parse_args, 1, 1, &cons_intype_setting,
CMD_TAGS(

View File

@ -77,6 +77,9 @@
#include "ui/ui.h"
#include "window_list.h"
#include "event/client_events.h"
#ifdef HAVE_GTK
#include "tray.h"
#endif
static void _update_presence(const resource_presence_t presence,
const char *const show, gchar **args);
@ -5525,6 +5528,24 @@ cmd_flash(ProfWin *window, const char *const command, gchar **args)
return _cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH);
}
#ifdef HAVE_GTK
gboolean
cmd_tray(ProfWin *window, const char *const command, gchar **args)
{
gboolean old = prefs_get_boolean(PREF_TRAY);
gboolean ret = _cmd_set_boolean_preference(args[0], command, "Tray icon", PREF_TRAY);
gboolean new = prefs_get_boolean(PREF_TRAY);
if (old != new) {
if (new) {
create_tray();
} else {
destroy_tray();
}
}
return ret;
}
#endif
gboolean
cmd_intype(ProfWin *window, const char *const command, gchar **args)
{

View File

@ -89,6 +89,9 @@ gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **ar
gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_dnd(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args);
#ifdef HAVE_GTK
gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args);
#endif
gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_grlog(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_group(ProfWin *window, const char *const command, gchar **args);

View File

@ -47,6 +47,10 @@
#include "tools/autocomplete.h"
#include "config/conflists.h"
#ifdef HAVE_GTK
#include "tray.h"
#endif
// preference groups refer to the sections in .profrc, for example [ui]
#define PREF_GROUP_LOGGING "logging"
#define PREF_GROUP_CHATSTATES "chatstates"
@ -1171,6 +1175,9 @@ _get_group(preference_t pref)
case PREF_TITLEBAR_SHOW:
case PREF_TITLEBAR_GOODBYE:
case PREF_FLASH:
#ifdef HAVE_GTK
case PREF_TRAY:
#endif
case PREF_INTYPE:
case PREF_HISTORY:
case PREF_OCCUPANTS:
@ -1289,6 +1296,10 @@ _get_key(preference_t pref)
return "titlebar.goodbye";
case PREF_FLASH:
return "flash";
#ifdef HAVE_GTK
case PREF_TRAY:
return "tray";
#endif
case PREF_INTYPE:
return "intype";
case PREF_HISTORY:

View File

@ -52,6 +52,9 @@ typedef enum {
PREF_TITLEBAR_SHOW,
PREF_TITLEBAR_GOODBYE,
PREF_FLASH,
#ifdef HAVE_GTK
PREF_TRAY,
#endif
PREF_INTYPE,
PREF_HISTORY,
PREF_CARBONS,

View File

@ -373,7 +373,7 @@ _init(char *log_level)
atexit(_shutdown);
plugins_init();
#ifdef HAVE_GTK
if (gtk_ready) {
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
log_debug("Building GTK icon");
create_tray();
}
@ -397,7 +397,7 @@ _shutdown(void)
cl_ev_disconnect();
}
#ifdef HAVE_GTK
if (gtk_ready) {
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
destroy_tray();
}
#endif

View File

@ -1182,6 +1182,17 @@ cons_flash_setting(void)
cons_show("Terminal flash (/flash) : OFF");
}
#ifdef HAVE_GTK
void
cons_tray_setting(void)
{
if (prefs_get_boolean(PREF_TRAY))
cons_show("Tray icon (/tray) : ON");
else
cons_show("Tray icon (/tray) : OFF");
}
#endif
void
cons_splash_setting(void)
{
@ -1497,6 +1508,9 @@ cons_show_ui_prefs(void)
cons_theme_setting();
cons_beep_setting();
cons_flash_setting();
#ifdef HAVE_GTK
cons_tray_setting();
#endif
cons_splash_setting();
cons_wrap_setting();
cons_winstidy_setting();

View File

@ -284,6 +284,9 @@ void cons_privileges_setting(void);
void cons_beep_setting(void);
void cons_console_setting(void);
void cons_flash_setting(void);
#ifdef HAVE_GTK
void cons_tray_setting(void);
#endif
void cons_splash_setting(void);
void cons_encwarn_setting(void);
void cons_tlsshow_setting(void);