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

Merge branch 'master' into caps

This commit is contained in:
James Booth 2013-01-22 01:39:18 +00:00
commit 114d251b68
4 changed files with 53 additions and 1 deletions

View File

@ -120,6 +120,7 @@ static gboolean _cmd_set_autoping(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_titlebar(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_autoaway(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_mouse(gchar **args, struct cmd_help_t help);
static gboolean _cmd_set_statuses(gchar **args, struct cmd_help_t help);
static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help);
static gboolean _cmd_away(gchar **args, struct cmd_help_t help);
static gboolean _cmd_online(gchar **args, struct cmd_help_t help);
@ -561,6 +562,15 @@ static struct cmd_t setting_commands[] =
"---------------",
"Set priority for the current session.",
"value : Number between -128 and 127. Default value is 0.",
NULL } } },
{ "/statuses",
_cmd_set_statuses, parse_args, 1, 1,
{ "/statuses on|off", "Set notifications for status messages.",
{ "/statuses on|off",
"---------------",
"Set notifications for status messages, such as online/offline or join/part channels.",
"When notifications are off status messages, such as online/offline or join/part, are not displayed.",
NULL } } }
};
@ -666,6 +676,7 @@ cmd_init(void)
p_autocomplete_add(notify_ac, strdup("message"));
p_autocomplete_add(notify_ac, strdup("typing"));
p_autocomplete_add(notify_ac, strdup("remind"));
p_autocomplete_add(notify_ac, strdup("status"));
sub_ac = p_autocomplete_new();
p_autocomplete_add(sub_ac, strdup("request"));
@ -939,6 +950,8 @@ _cmd_complete_parameters(char *input, int *size)
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/vercheck",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/statuses",
prefs_autocomplete_boolean_choice);
if (win_current_is_groupchat()) {
PAutocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient());
@ -2009,7 +2022,8 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help)
cons_show("Usage: /notify typing on|off");
}
} else { // remind
// set remind setting
} else if (strcmp(kind, "remind") == 0) {
gint period = atoi(value);
prefs_set_notify_remind(period);
if (period == 0) {
@ -2019,6 +2033,9 @@ _cmd_set_notify(gchar **args, struct cmd_help_t help)
} else {
cons_show("Message reminder period set to %d seconds.", period);
}
} else {
cons_show("Unknown command: %s.", kind);
}
return TRUE;
@ -2159,6 +2176,13 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help)
return TRUE;
}
static gboolean
_cmd_set_statuses(gchar **args, struct cmd_help_t help)
{
return _cmd_set_boolean_preference(args[0], help,
"Status notifications", prefs_set_statuses);
}
static gboolean
_cmd_vercheck(gchar **args, struct cmd_help_t help)
{

View File

@ -421,12 +421,30 @@ prefs_get_mouse(void)
}
}
gboolean
prefs_get_statuses(void)
{
if (g_key_file_has_key(prefs, "ui", "statuses", NULL)) {
return g_key_file_get_boolean(prefs, "ui", "statuses", NULL);
} else {
return TRUE;
}
}
void
prefs_set_mouse(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "mouse", value);
_save_prefs();
}
void
prefs_set_statuses(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "statuses", value);
_save_prefs();
}
static void
_save_prefs(void)
{

View File

@ -70,6 +70,8 @@ gchar * prefs_get_theme(void);
void prefs_set_theme(gchar *value);
gboolean prefs_get_mouse(void);
void prefs_set_mouse(gboolean value);
void prefs_set_statuses(gboolean value);
gboolean prefs_get_statuses(void);
void prefs_set_notify_message(gboolean value);
gboolean prefs_get_notify_message(void);

View File

@ -1286,6 +1286,11 @@ cons_show_ui_prefs(void)
cons_show("Mouse handling (/mouse) : ON");
else
cons_show("Mouse handling (/mouse) : OFF");
if (prefs_get_statuses())
cons_show("Status (/statuses) : ON");
else
cons_show("Status (/statuses) : OFF");
}
void
@ -2061,6 +2066,9 @@ _show_status_string(WINDOW *win, const char * const from,
GDateTime *last_activity, const char * const pre,
const char * const default_show)
{
if (!prefs_get_statuses())
return;
_win_show_time(win, '-');
if (show != NULL) {