1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-27 20:30:13 -04:00

Merge remote-tracking branch 'PMaynard/#551'

This commit is contained in:
James Booth 2015-06-02 20:29:35 +01:00
commit f0f3a739f4
13 changed files with 60 additions and 13 deletions

View File

@ -684,6 +684,14 @@ static struct cmd_t command_defs[] =
"Enable or disable word wrapping in the main window.", "Enable or disable word wrapping in the main window.",
NULL } } }, NULL } } },
{ "/winstidy",
cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting,
{ "/winstidy on|off", "Auto tidy windows.",
{ "/winstidy on|off",
"----------------",
"Enable or disable auto window tidy.",
NULL } } },
{ "/time", { "/time",
cmd_time, parse_args, 1, 2, &cons_time_setting, cmd_time, parse_args, 1, 2, &cons_time_setting,
{ "/time setting|statusbar [setting]", "Time display.", { "/time setting|statusbar [setting]", "Time display.",
@ -1921,7 +1929,7 @@ _cmd_complete_parameters(const char * const input)
// autocomplete boolean settings // autocomplete boolean settings
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
"/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history", "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history",
"/vercheck", "/privileges", "/presence", "/wrap", "/carbons" }; "/vercheck", "/privileges", "/presence", "/wrap", "/winstidy", "/carbons" };
for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice); result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice);

View File

@ -689,7 +689,11 @@ cmd_wins(gchar **args, struct cmd_help_t help)
if (args[0] == NULL) { if (args[0] == NULL) {
cons_show_wins(); cons_show_wins();
} else if (strcmp(args[0], "tidy") == 0) { } else if (strcmp(args[0], "tidy") == 0) {
ui_tidy_wins(); if (ui_tidy_wins()) {
cons_show("Windows tidied.");
} else {
cons_show("No tidy needed.");
}
} else if (strcmp(args[0], "prune") == 0) { } else if (strcmp(args[0], "prune") == 0) {
ui_prune_wins(); ui_prune_wins();
} else if (strcmp(args[0], "swap") == 0) { } else if (strcmp(args[0], "swap") == 0) {
@ -718,6 +722,18 @@ cmd_wins(gchar **args, struct cmd_help_t help)
return TRUE; return TRUE;
} }
gboolean
cmd_winstidy(gchar **args, struct cmd_help_t help)
{
gboolean result = _cmd_set_boolean_preference(args[0], help, "Wins Auto Tidy", PREF_WINS_AUTO_TIDY);
if (result && g_strcmp0(args[0], "on") == 0) {
ui_tidy_wins();
}
return result;
}
gboolean gboolean
cmd_win(gchar **args, struct cmd_help_t help) cmd_win(gchar **args, struct cmd_help_t help)
{ {
@ -804,7 +820,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
"/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype", "/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
"/log", "/mouse", "/notify", "/outtype", "/prefs", "/priority", "/log", "/mouse", "/notify", "/outtype", "/prefs", "/priority",
"/reconnect", "/roster", "/splash", "/states", "/statuses", "/theme", "/reconnect", "/roster", "/splash", "/states", "/statuses", "/theme",
"/titlebar", "/vercheck", "/privileges", "/occupants", "/presence", "/wrap" }; "/titlebar", "/vercheck", "/privileges", "/occupants", "/presence", "/wrap", "/winstidy" };
_cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter)); _cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter));
} else if (strcmp(args[0], "navigation") == 0) { } else if (strcmp(args[0], "navigation") == 0) {
@ -3242,6 +3258,11 @@ cmd_close(gchar **args, struct cmd_help_t help)
ui_close_win(index); ui_close_win(index);
cons_show("Closed window %d", index); cons_show("Closed window %d", index);
// Tidy up the window list.
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) {
ui_tidy_wins();
}
return TRUE; return TRUE;
} }

View File

@ -125,6 +125,7 @@ gboolean cmd_vercheck(gchar **args, struct cmd_help_t help);
gboolean cmd_who(gchar **args, struct cmd_help_t help); gboolean cmd_who(gchar **args, struct cmd_help_t help);
gboolean cmd_win(gchar **args, struct cmd_help_t help); gboolean cmd_win(gchar **args, struct cmd_help_t help);
gboolean cmd_wins(gchar **args, struct cmd_help_t help); gboolean cmd_wins(gchar **args, struct cmd_help_t help);
gboolean cmd_winstidy(gchar **args, struct cmd_help_t help);
gboolean cmd_xa(gchar **args, struct cmd_help_t help); gboolean cmd_xa(gchar **args, struct cmd_help_t help);
gboolean cmd_alias(gchar **args, struct cmd_help_t help); gboolean cmd_alias(gchar **args, struct cmd_help_t help);
gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help); gboolean cmd_xmlconsole(gchar **args, struct cmd_help_t help);

View File

@ -507,6 +507,7 @@ _get_group(preference_t pref)
case PREF_MUC_PRIVILEGES: case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE: case PREF_PRESENCE:
case PREF_WRAP: case PREF_WRAP:
case PREF_WINS_AUTO_TIDY:
case PREF_TIME: case PREF_TIME:
case PREF_TIME_STATUSBAR: case PREF_TIME_STATUSBAR:
case PREF_ROSTER: case PREF_ROSTER:
@ -654,6 +655,8 @@ _get_key(preference_t pref)
return "presence"; return "presence";
case PREF_WRAP: case PREF_WRAP:
return "wrap"; return "wrap";
case PREF_WINS_AUTO_TIDY:
return "wins.autotidy";
case PREF_TIME: case PREF_TIME:
return "time"; return "time";
case PREF_TIME_STATUSBAR: case PREF_TIME_STATUSBAR:
@ -700,6 +703,7 @@ _get_default_boolean(preference_t pref)
case PREF_MUC_PRIVILEGES: case PREF_MUC_PRIVILEGES:
case PREF_PRESENCE: case PREF_PRESENCE:
case PREF_WRAP: case PREF_WRAP:
case PREF_WINS_AUTO_TIDY:
case PREF_INPBLOCK_DYNAMIC: case PREF_INPBLOCK_DYNAMIC:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:

View File

@ -74,6 +74,7 @@ typedef enum {
PREF_MUC_PRIVILEGES, PREF_MUC_PRIVILEGES,
PREF_PRESENCE, PREF_PRESENCE,
PREF_WRAP, PREF_WRAP,
PREF_WINS_AUTO_TIDY,
PREF_TIME, PREF_TIME,
PREF_TIME_STATUSBAR, PREF_TIME_STATUSBAR,
PREF_STATUSES, PREF_STATUSES,

View File

@ -428,6 +428,7 @@ _load_preferences(void)
_set_boolean_preference("flash", PREF_FLASH); _set_boolean_preference("flash", PREF_FLASH);
_set_boolean_preference("splash", PREF_SPLASH); _set_boolean_preference("splash", PREF_SPLASH);
_set_boolean_preference("wrap", PREF_WRAP); _set_boolean_preference("wrap", PREF_WRAP);
_set_boolean_preference("wins.autotidy", PREF_WINS_AUTO_TIDY);
_set_string_preference("time", PREF_TIME); _set_string_preference("time", PREF_TIME);
_set_string_preference("time.statusbar", PREF_TIME_STATUSBAR); _set_string_preference("time.statusbar", PREF_TIME_STATUSBAR);

View File

@ -871,6 +871,15 @@ cons_wrap_setting(void)
cons_show("Word wrap (/wrap) : OFF"); cons_show("Word wrap (/wrap) : OFF");
} }
void
cons_winstidy_setting(void)
{
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY))
cons_show("Window Auto Tidy (/winstidy) : ON");
else
cons_show("Window Auto Tidy (/winstidy) : OFF");
}
void void
cons_presence_setting(void) cons_presence_setting(void)
{ {
@ -1035,6 +1044,7 @@ cons_show_ui_prefs(void)
cons_flash_setting(); cons_flash_setting();
cons_splash_setting(); cons_splash_setting();
cons_wrap_setting(); cons_wrap_setting();
cons_winstidy_setting();
cons_time_setting(); cons_time_setting();
cons_resource_setting(); cons_resource_setting();
cons_vercheck_setting(); cons_vercheck_setting();

View File

@ -1105,16 +1105,10 @@ ui_close_win(int index)
status_bar_active(1); status_bar_active(1);
} }
void gboolean
ui_tidy_wins(void) ui_tidy_wins(void)
{ {
gboolean tidied = wins_tidy(); return wins_tidy();
if (tidied) {
cons_show("Windows tidied.");
} else {
cons_show("No tidy needed.");
}
} }
void void

View File

@ -216,7 +216,7 @@ void ui_show_all_room_rosters(void);
void ui_hide_all_room_rosters(void); void ui_hide_all_room_rosters(void);
gboolean ui_chat_win_exists(const char * const barejid); gboolean ui_chat_win_exists(const char * const barejid);
void ui_tidy_wins(void); gboolean ui_tidy_wins(void);
void ui_prune_wins(void); void ui_prune_wins(void);
gboolean ui_swap_wins(int source_win, int target_win); gboolean ui_swap_wins(int source_win, int target_win);
@ -305,6 +305,7 @@ void cons_occupants_setting(void);
void cons_roster_setting(void); void cons_roster_setting(void);
void cons_presence_setting(void); void cons_presence_setting(void);
void cons_wrap_setting(void); void cons_wrap_setting(void);
void cons_winstidy_setting(void);
void cons_time_setting(void); void cons_time_setting(void);
void cons_mouse_setting(void); void cons_mouse_setting(void);
void cons_statuses_setting(void); void cons_statuses_setting(void);

View File

@ -315,7 +315,9 @@ void ui_redraw_all_room_rosters(void) {}
void ui_show_all_room_rosters(void) {} void ui_show_all_room_rosters(void) {}
void ui_hide_all_room_rosters(void) {} void ui_hide_all_room_rosters(void) {}
void ui_tidy_wins(void) {} gboolean ui_tidy_wins(void) {
return TRUE;
}
void ui_prune_wins(void) {} void ui_prune_wins(void) {}
gboolean ui_swap_wins(int source_win, int target_win) gboolean ui_swap_wins(int source_win, int target_win)
{ {
@ -458,6 +460,7 @@ void cons_occupants_setting(void) {}
void cons_roster_setting(void) {} void cons_roster_setting(void) {}
void cons_presence_setting(void) {} void cons_presence_setting(void) {}
void cons_wrap_setting(void) {} void cons_wrap_setting(void) {}
void cons_winstidy_setting(void) {}
void cons_time_setting(void) {} void cons_time_setting(void) {}
void cons_mouse_setting(void) {} void cons_mouse_setting(void) {}
void cons_statuses_setting(void) {} void cons_statuses_setting(void) {}

View File

@ -72,3 +72,4 @@ roster.size=
occupants= occupants=
occupants.size= occupants.size=
occupants.jid= occupants.jid=
wins.autotidy=

View File

@ -73,3 +73,4 @@ roster.size=25
occupants=true occupants=true
occupants.size=15 occupants.size=15
occupants.jid=true occupants.jid=true
wins.autotidy=true

View File

@ -21,3 +21,4 @@ privileges=false
presence=false presence=false
intype=false intype=false
otr.warn=false otr.warn=false
wins.autotidy=false