From 6d274ba846caea15be4f9089235a72000f59a5eb Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 14 Sep 2016 22:13:06 +0100 Subject: [PATCH 01/20] Release 0.5.0 --- Makefile.am | 2 +- configure.ac | 2 +- install-all.sh | 216 ------------------------------------------------- 3 files changed, 2 insertions(+), 218 deletions(-) delete mode 100755 install-all.sh diff --git a/Makefile.am b/Makefile.am index 3e4473c3..754e2deb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -186,7 +186,7 @@ themes_sources = themes/* icons_sources = icons/* -script_sources = bootstrap.sh configure-debug install-all.sh +script_sources = bootstrap.sh configure-debug man_sources = docs/profanity.1 diff --git a/configure.ac b/configure.ac index 5c26bbca..5c20b9ff 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ AS_CASE([$host_os], [cygwin], [PLATFORM="cygwin"], [PLATFORM="nix"]) -PACKAGE_STATUS="development" +PACKAGE_STATUS="release" ### Get git branch and revision if in development if test "x$PACKAGE_STATUS" = xdevelopment; then diff --git a/install-all.sh b/install-all.sh deleted file mode 100755 index 37e3c9de..00000000 --- a/install-all.sh +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash - -set -o errtrace - -STATUS=development - -error_handler() -{ - ERR_CODE=$? - echo "Error $ERR_CODE with command '$BASH_COMMAND' on line ${BASH_LINENO[0]}. Exiting." - exit $ERR_CODE - -} - -trap error_handler ERR - -debian_prepare() -{ - echo - echo Profanity installer ... updating apt repositories - echo - sudo apt-get update - - echo - echo Profanity installer... installing dependencies - echo - sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libreadline-dev libtool libgpgme11-dev libgtk2.0-dev autoconf-archive - -} - -fedora_prepare() -{ - echo - echo Profanity installer... installing dependencies - echo - - sudo dnf -y install gcc git autoconf automake openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool gpgme-devel gtk2-devel autoconf-archive -} - -opensuse_prepare() -{ - echo - echo Profanity installer...installing dependencies - echo - sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool libgpgme-devel autoconf-archive -} - -centos_prepare() -{ - echo - echo Profanity installer...installing dependencies - echo - - sudo yum -y install epel-release - sudo yum -y install git - sudo yum -y install gcc autoconf automake cmake - sudo yum -y install openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool gpgme-devel autoconf-archive -} - -cygwin_prepare() -{ - echo - echo Profanity installer... installing dependencies - echo - - if ! command -v apt-cyg &>/dev/null; then cyg_install_apt_cyg; fi - if [ -n "$CYG_MIRROR" ]; then - apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool libpcre-devel libisl10 libcloog-isl4 autoconf-archive - else - apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool libpcre-devel libisl10 libcloog-isl4 autoconf-archive - - fi -} - -install_lib_mesode() -{ - echo - echo Profanity installer... installing libmesode - echo - git clone https://github.com/boothj5/libmesode.git - cd libmesode - ./bootstrap.sh - ./configure --prefix=$1 - make - sudo make install - - cd .. -} - -install_profanity() -{ - echo - echo Profanity installer... installing Profanity - echo - if [ "${STATUS}" = "development" ]; then - ./bootstrap.sh - fi - ./configure - make - sudo make install -} - -cyg_install_apt_cyg() -{ - echo - echo Profanity installer... installing apt-cyg - echo - wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg - #wget --no-check-certificate https://raw.github.com/boothj5/apt-cyg/master/apt-cyg - #wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg - chmod +x apt-cyg - mv apt-cyg /usr/local/bin/ - -} -cyg_install_lib_mesode() -{ - echo - echo Profanity installer... installing libmesode - echo - git clone https://github.com/boothj5/libmesode.git - cd libmesode - ./bootstrap.sh - ./bootstrap.sh # second call seems to fix problem on cygwin - ./configure --prefix=/usr - make - make install - - cd .. -} - -cyg_install_profanity() -{ - echo - echo Profanity installer... installing Profanity - echo - if [ "${STATUS}" = "development" ]; then - ./bootstrap.sh - fi - ./configure - make - make install -} - -cleanup() -{ - echo - echo Profanity installer... cleaning up - echo - - echo Removing libmesode repository... - rm -rf libmesode - - echo - echo Profanity installer... complete! - echo - echo Type \'profanity\' to run. - echo -} - -while getopts m: opt -do - case "$opt" in - m) CYG_MIRROR=$OPTARG;; - esac -done - -OS=`uname -s` -DIST=unknown - -if [ "${OS}" = "Linux" ]; then - if [ -f /etc/fedora-release ]; then - DIST=fedora - elif [ -f /etc/debian_version ]; then - DIST=debian - elif [ -f /etc/centos-release ]; then - DIST=centos - elif [ -f /etc/os-release ]; then - DIST=opensuse - fi -else - echo $OS | grep -i cygwin - if [ "$?" -eq 0 ]; then - DIST=cygwin - fi -fi - -case "$DIST" in -unknown) echo The install script will not work on this OS. - echo Try a manual install instead. - exit - ;; -fedora) fedora_prepare - install_lib_mesode /usr - install_profanity - ;; -debian) debian_prepare - install_lib_mesode /usr - install_profanity - ;; -opensuse) opensuse_prepare - install_lib_mesode /usr/local - sudo /sbin/ldconfig - install_profanity - ;; -centos) centos_prepare - install_lib_mesode /usr - sudo ldconfig - install_profanity - ;; -cygwin) cygwin_prepare - cyg_install_lib_mesode - cyg_install_profanity - ;; -esac - -cleanup From 751d9624c3802f019a298d000fd35fcede52c08e Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 16 Sep 2016 00:03:23 +0100 Subject: [PATCH 02/20] Set to development version 0.5.1 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5c20b9ff..3b0ad0be 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([profanity], [0.5.0], [boothj5web@gmail.com]) +AC_INIT([profanity], [0.5.1], [boothj5web@gmail.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/main.c]) @@ -26,7 +26,7 @@ AS_CASE([$host_os], [cygwin], [PLATFORM="cygwin"], [PLATFORM="nix"]) -PACKAGE_STATUS="release" +PACKAGE_STATUS="development" ### Get git branch and revision if in development if test "x$PACKAGE_STATUS" = xdevelopment; then From c4d3f19d94e94bb08136e9ecc95ccdad0c76a81d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 19 Sep 2016 00:27:28 +0100 Subject: [PATCH 03/20] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 64c9b1ef..a0fd02e6 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,5 @@ Homepage: http://www.profanity.im Chat room: profanitydev@conference.jabber.org Mailing List: https://groups.google.com/forum/#!forum/profanitydev + +Plugins repository: https://github.com/boothj5/profanity-plugins From 0aa758cbfb0ec50b3d2eb6024515442882cdf63c Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 19 Sep 2016 23:40:45 +0100 Subject: [PATCH 04/20] Add /inputwin top|bottom command closes #853 --- src/command/cmd_ac.c | 13 ++++++-- src/command/cmd_defs.c | 17 +++++++++++ src/command/cmd_funcs.c | 16 +++++++++- src/command/cmd_funcs.h | 1 + src/config/preferences.c | 5 ++++ src/config/preferences.h | 1 + src/config/theme.c | 4 ++- src/ui/console.c | 9 ++++++ src/ui/inputwin.c | 9 +++++- src/ui/statusbar.c | 16 ++++++++-- src/ui/titlebar.c | 18 +++++++++++- src/ui/ui.h | 1 + src/ui/window.c | 57 ++++++++++++++++++++++++++++++------ tests/unittests/ui/stub_ui.c | 1 + theme_template | 1 + themes/bios | 1 + themes/boothj5 | 1 + themes/boothj5_slack | 1 + themes/complex | 1 + themes/forest | 3 ++ themes/original | 3 ++ themes/simple | 1 + 22 files changed, 162 insertions(+), 18 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index cedcadee..917d9db2 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -194,6 +194,7 @@ static Autocomplete blocked_ac; static Autocomplete tray_ac; static Autocomplete presence_ac; static Autocomplete presence_setting_ac; +static Autocomplete inputwin_ac; void cmd_ac_init(void) @@ -735,6 +736,10 @@ cmd_ac_init(void) autocomplete_add(presence_setting_ac, "all"); autocomplete_add(presence_setting_ac, "online"); autocomplete_add(presence_setting_ac, "none"); + + inputwin_ac = autocomplete_new(); + autocomplete_add(inputwin_ac, "top"); + autocomplete_add(inputwin_ac, "bottom"); } void @@ -998,6 +1003,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(tray_ac); autocomplete_reset(presence_ac); autocomplete_reset(presence_setting_ac); + autocomplete_reset(inputwin_ac); autocomplete_reset(script_ac); if (script_show_ac) { @@ -1120,6 +1126,7 @@ cmd_ac_uninit(void) autocomplete_free(tray_ac); autocomplete_free(presence_ac); autocomplete_free(presence_setting_ac); + autocomplete_free(inputwin_ac); } static char* @@ -1200,8 +1207,8 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) } } - gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping" }; - Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac }; + gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/inputwin" }; + Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, inputwin_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE); @@ -1250,7 +1257,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); - g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); + g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); int len = strlen(input); char parsed[len+1]; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index c98b9bf3..ffc9e901 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1302,6 +1302,23 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, + { "/inputwin", + parse_args, 1, 1, &cons_inputwin_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_inputwin) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/inputwin top", + "/inputwin bottom") + CMD_DESC( + "Where to display the input window.") + CMD_ARGS( + { "top", "Show the input window at the top of the screen." }, + { "bottom", "Show the input window at the bottom of the screen." }) + CMD_NOEXAMPLES + }, + { "/notify", parse_args_with_freetext, 0, 4, NULL, CMD_NOSUBFUNCS diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index f4b597c0..d8562194 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1662,7 +1662,7 @@ cmd_theme(ProfWin *window, const char *const command, gchar **args) } else { ui_hide_all_room_rosters(); } - ui_redraw(); + ui_resize(); cons_show("Loaded theme: %s", args[1]); } else { cons_show("Couldn't find theme: %s", args[1]); @@ -5522,6 +5522,20 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args) return TRUE; } +gboolean +cmd_inputwin(ProfWin *window, const char *const command, gchar **args) +{ + if ((g_strcmp0(args[0], "top") == 0) || (g_strcmp0(args[0], "bottom") == 0)) { + prefs_set_string(PREF_INPUTWIN, args[0]); + ui_resize(); + cons_show("Set input window position to %s", args[0]); + } else { + cons_bad_cmd_usage(command); + } + + return TRUE; +} + gboolean cmd_log(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 4d0f4a86..cae68f59 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -149,6 +149,7 @@ gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args); gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 2cd5e304..de75008e 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1211,6 +1211,7 @@ _get_group(preference_t pref) case PREF_RESOURCE_MESSAGE: case PREF_ENC_WARN: case PREF_INPBLOCK_DYNAMIC: + case PREF_INPUTWIN: case PREF_TLS_SHOW: case PREF_CONSOLE_MUC: case PREF_CONSOLE_PRIVATE: @@ -1443,6 +1444,8 @@ _get_key(preference_t pref) return "resource.message"; case PREF_INPBLOCK_DYNAMIC: return "inpblock.dynamic"; + case PREF_INPUTWIN: + return "inputwin.position"; case PREF_ENC_WARN: return "enc.warn"; case PREF_PGP_LOG: @@ -1571,6 +1574,8 @@ _get_default_string(preference_t pref) case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_CHAT: return "all"; + case PREF_INPUTWIN: + return "bottom"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 621b1760..67f3e1e4 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -132,6 +132,7 @@ typedef enum { PREF_RESOURCE_TITLE, PREF_RESOURCE_MESSAGE, PREF_INPBLOCK_DYNAMIC, + PREF_INPUTWIN, PREF_ENC_WARN, PREF_PGP_LOG, PREF_TLS_CERTPATH, diff --git a/src/config/theme.c b/src/config/theme.c index 0133b1f6..d4494e58 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -150,6 +150,8 @@ theme_init(const char *const theme_name) g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green")); g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green")); g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow")); + + _load_preferences(); } gboolean @@ -427,7 +429,7 @@ _load_preferences(void) _set_string_preference("roster.rooms.by", PREF_ROSTER_ROOMS_BY); _set_string_preference("roster.private", PREF_ROSTER_PRIVATE); _set_string_preference("roster.count", PREF_ROSTER_COUNT); - + _set_string_preference("inputwin.position", PREF_INPUTWIN); if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) { gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL); diff --git a/src/ui/console.c b/src/ui/console.c index 80f854c3..3b99e58e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1534,6 +1534,7 @@ cons_show_ui_prefs(void) cons_beep_setting(); cons_flash_setting(); cons_splash_setting(); + cons_inputwin_setting(); cons_wrap_setting(); cons_winstidy_setting(); cons_time_setting(); @@ -1751,6 +1752,14 @@ cons_inpblock_setting(void) } } +void +cons_inputwin_setting(void) +{ + char *pos = prefs_get_string(PREF_INPUTWIN); + cons_show("Input window postion (/inputwin) : %s", pos); + prefs_free_string(pos); +} + void cons_log_setting(void) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index fb7c0b4a..29bf04c4 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -282,7 +282,14 @@ _inp_win_update_virtual(void) { int wrows, wcols; getmaxyx(stdscr, wrows, wcols); - pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(inp_win, 0, pad_start, 0, 0, 0, wcols-2); + } else { + pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2); + } + prefs_free_string(pos); + } static void diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 6a1a72e9..9b87ecdc 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -89,7 +89,13 @@ create_status_bar(void) int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); - status_bar = newwin(1, cols, rows-2, 0); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + status_bar = newwin(1, cols, rows-1, 0); + } else { + status_bar = newwin(1, cols, rows-2, 0); + } + prefs_free_string(pos); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT)); wattron(status_bar, bracket_attrs); mvwprintw(status_bar, 0, cols - 34, _active); @@ -122,7 +128,13 @@ status_bar_resize(void) int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); - mvwin(status_bar, rows-2, 0); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + mvwin(status_bar, rows-1, 0); + } else { + mvwin(status_bar, rows-2, 0); + } + prefs_free_string(pos); wresize(status_bar, 1, cols); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT)); wattron(status_bar, bracket_attrs); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 701c01c2..90775ce7 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -67,7 +67,13 @@ create_title_bar(void) { int cols = getmaxx(stdscr); - win = newwin(1, cols, 0, 0); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + win = newwin(1, cols, 1, 0); + } else { + win = newwin(1, cols, 0, 0); + } + prefs_free_string(pos); wbkgd(win, theme_attrs(THEME_TITLE_TEXT)); title_bar_console(); title_bar_set_presence(CONTACT_OFFLINE); @@ -101,6 +107,16 @@ title_bar_resize(void) { int cols = getmaxx(stdscr); + werase(win); + + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + mvwin(win, 1, 0); + } else { + mvwin(win, 0, 0); + } + prefs_free_string(pos); + wresize(win, 1, cols); wbkgd(win, theme_attrs(THEME_TITLE_TEXT)); diff --git a/src/ui/ui.h b/src/ui/ui.h index 9db4fe33..7a2dc95a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -317,6 +317,7 @@ void cons_reconnect_setting(void); void cons_autoping_setting(void); void cons_autoconnect_setting(void); void cons_inpblock_setting(void); +void cons_inputwin_setting(void); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_offline(PContact contact, char *resource, char *status); void cons_theme_properties(void); diff --git a/src/ui/window.c b/src/ui/window.c index 277ce4e6..a8f9ec63 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -616,13 +616,32 @@ win_update_virtual(ProfWin *window) } else { subwin_cols = win_roster_cols(); } - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); + } else { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + } + prefs_free_string(pos); } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, cols-1); + } else { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1); + } + prefs_free_string(pos); } } else { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1); + } else { + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); + } + prefs_free_string(pos); } } @@ -633,7 +652,13 @@ win_refresh_without_subwin(ProfWin *window) getmaxyx(stdscr, rows, cols); if ((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1); + } else { + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); + } + prefs_free_string(pos); } } @@ -647,13 +672,27 @@ win_refresh_with_subwin(ProfWin *window) if (window->type == WIN_MUC) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; subwin_cols = win_occpuants_cols(); - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); + } else { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + } + prefs_free_string(pos); } else if (window->type == WIN_CONSOLE) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; subwin_cols = win_roster_cols(); - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + char *pos = prefs_get_string(PREF_INPUTWIN); + if (g_strcmp0(pos, "top") == 0) { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); + } else { + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); + } + prefs_free_string(pos); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 928000a3..d4c30698 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -445,6 +445,7 @@ void cons_reconnect_setting(void) {} void cons_autoping_setting(void) {} void cons_autoconnect_setting(void) {} void cons_inpblock_setting(void) {} +void cons_inputwin_setting(void) {} void cons_tray_setting(void) {} void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) diff --git a/theme_template b/theme_template index 20393bab..2afadf3f 100644 --- a/theme_template +++ b/theme_template @@ -138,3 +138,4 @@ pgp.char= console.muc= console.chat= console.private= +inputwin.position= diff --git a/themes/bios b/themes/bios index ad582d7e..ea854036 100644 --- a/themes/bios +++ b/themes/bios @@ -130,3 +130,4 @@ otr.char=@ pgp.char=% tls.show=true console.muc=first +inputwin.position=bottom diff --git a/themes/boothj5 b/themes/boothj5 index bb1f8d27..5fa069b5 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -137,3 +137,4 @@ tls.show=true console.muc=first console.chat=all console.private=all +inputwin.position=bottom diff --git a/themes/boothj5_slack b/themes/boothj5_slack index e7f1a571..d0121c1d 100644 --- a/themes/boothj5_slack +++ b/themes/boothj5_slack @@ -133,3 +133,4 @@ tls.show=true console.muc=first console.chat=all console.private=all +inputwin.position=bottom diff --git a/themes/complex b/themes/complex index 258a7776..78a01c27 100644 --- a/themes/complex +++ b/themes/complex @@ -58,3 +58,4 @@ tls.show=true console.muc=all console.chat=all console.private=all +inputwin.position=bottom diff --git a/themes/forest b/themes/forest index d466eda1..95fc3ad9 100644 --- a/themes/forest +++ b/themes/forest @@ -75,3 +75,6 @@ roster.room.mention=bold_green roster.room.trigger=bold_green occupants.header=bold_green receipt.sent=bold_black + +[ui] +inputwin.position=top diff --git a/themes/original b/themes/original index 33e54fb3..a5e450ef 100644 --- a/themes/original +++ b/themes/original @@ -75,3 +75,6 @@ roster.room.mention=green roster.room.trigger=green occupants.header=yellow receipt.sent=red + +[ui] +inputwin.position=bottom diff --git a/themes/simple b/themes/simple index b63017ab..9e387049 100644 --- a/themes/simple +++ b/themes/simple @@ -45,3 +45,4 @@ tls.show=false console.muc=first console.chat=first console.private=first +inputwin.position=bottom From 580bdb482fc5efd46577b3228870df5d4f098835 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 19 Sep 2016 23:57:37 +0100 Subject: [PATCH 05/20] Update CHANGELOG --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6193bec8..b143d522 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +0.5.1 +===== + +- Allow positioning input window at top of screen (/inputwin) + 0.5.0 ===== From f683a704ad164796ddd1dc6f49ea48098fc39219 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 22 Sep 2016 21:02:34 +0100 Subject: [PATCH 06/20] Update version to 0.6.0 development --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3b0ad0be..46e7c775 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([profanity], [0.5.1], [boothj5web@gmail.com]) +AC_INIT([profanity], [0.6.0], [boothj5web@gmail.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/main.c]) From 3983ee1d6be8245901e83d7d06974005000a1721 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 22 Sep 2016 21:42:00 +0100 Subject: [PATCH 07/20] Rename /titlebar -> /wintitle --- src/command/cmd_ac.c | 24 ++++++++++++------------ src/command/cmd_defs.c | 10 +++++----- src/command/cmd_funcs.c | 6 +++--- src/command/cmd_funcs.h | 2 +- src/config/preferences.c | 25 +++++++++++++++++++------ src/config/preferences.h | 4 ++-- src/profanity.c | 4 ++-- src/ui/console.c | 16 ++++++++-------- src/ui/core.c | 2 +- src/ui/ui.h | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 11 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 917d9db2..b66fce4d 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -83,7 +83,7 @@ static char* _ban_autocomplete(ProfWin *window, const char *const input); static char* _affiliation_autocomplete(ProfWin *window, const char *const input); static char* _role_autocomplete(ProfWin *window, const char *const input); static char* _resource_autocomplete(ProfWin *window, const char *const input); -static char* _titlebar_autocomplete(ProfWin *window, const char *const input); +static char* _wintitle_autocomplete(ProfWin *window, const char *const input); static char* _inpblock_autocomplete(ProfWin *window, const char *const input); static char* _time_autocomplete(ProfWin *window, const char *const input); static char* _receipts_autocomplete(ProfWin *window, const char *const input); @@ -123,7 +123,7 @@ static Autocomplete autoaway_ac; static Autocomplete autoaway_mode_ac; static Autocomplete autoaway_presence_ac; static Autocomplete autoconnect_ac; -static Autocomplete titlebar_ac; +static Autocomplete wintitle_ac; static Autocomplete theme_ac; static Autocomplete theme_load_ac; static Autocomplete account_ac; @@ -281,9 +281,9 @@ cmd_ac_init(void) autocomplete_add(sub_ac, "sent"); autocomplete_add(sub_ac, "received"); - titlebar_ac = autocomplete_new(); - autocomplete_add(titlebar_ac, "show"); - autocomplete_add(titlebar_ac, "goodbye"); + wintitle_ac = autocomplete_new(); + autocomplete_add(wintitle_ac, "show"); + autocomplete_add(wintitle_ac, "goodbye"); log_ac = autocomplete_new(); autocomplete_add(log_ac, "maxsize"); @@ -965,7 +965,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(roster_remove_all_ac); autocomplete_reset(roster_private_ac); autocomplete_reset(group_ac); - autocomplete_reset(titlebar_ac); + autocomplete_reset(wintitle_ac); autocomplete_reset(bookmark_ac); autocomplete_reset(bookmark_property_ac); autocomplete_reset(otr_ac); @@ -1049,7 +1049,7 @@ cmd_ac_uninit(void) autocomplete_free(notify_mention_ac); autocomplete_free(notify_trigger_ac); autocomplete_free(sub_ac); - autocomplete_free(titlebar_ac); + autocomplete_free(wintitle_ac); autocomplete_free(log_ac); autocomplete_free(prefs_ac); autocomplete_free(autoaway_ac); @@ -1242,7 +1242,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete); g_hash_table_insert(ac_funcs, "/role", _role_autocomplete); g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); - g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); + g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete); g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); @@ -2076,21 +2076,21 @@ _resource_autocomplete(ProfWin *window, const char *const input) } static char* -_titlebar_autocomplete(ProfWin *window, const char *const input) +_wintitle_autocomplete(ProfWin *window, const char *const input) { char *found = NULL; - found = autocomplete_param_with_func(input, "/titlebar show", prefs_autocomplete_boolean_choice); + found = autocomplete_param_with_func(input, "/wintitle show", prefs_autocomplete_boolean_choice); if (found) { return found; } - found = autocomplete_param_with_func(input, "/titlebar goodbye", prefs_autocomplete_boolean_choice); + found = autocomplete_param_with_func(input, "/wintitle goodbye", prefs_autocomplete_boolean_choice); if (found) { return found; } - found = autocomplete_param_with_ac(input, "/titlebar", titlebar_ac, FALSE); + found = autocomplete_param_with_ac(input, "/wintitle", wintitle_ac, FALSE); if (found) { return found; } diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index ffc9e901..52c06ae5 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1492,15 +1492,15 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, - { "/titlebar", - parse_args, 2, 2, &cons_titlebar_setting, + { "/wintitle", + parse_args, 2, 2, &cons_wintitle_setting, CMD_NOSUBFUNCS - CMD_MAINFUNC(cmd_titlebar) + CMD_MAINFUNC(cmd_wintitle) CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/titlebar show on|off", - "/titlebar goodbye on|off") + "/wintitle show on|off", + "/wintitle goodbye on|off") CMD_DESC( "Allow Profanity to modify the window title bar.") CMD_ARGS( diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index d8562194..4f8dc993 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5057,7 +5057,7 @@ cmd_states(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_titlebar(ProfWin *window, const char *const command, gchar **args) +cmd_wintitle(ProfWin *window, const char *const command, gchar **args) { if (g_strcmp0(args[0], "show") != 0 && g_strcmp0(args[0], "goodbye") != 0) { cons_bad_cmd_usage(command); @@ -5067,9 +5067,9 @@ cmd_titlebar(ProfWin *window, const char *const command, gchar **args) ui_clear_win_title(); } if (g_strcmp0(args[0], "show") == 0) { - _cmd_set_boolean_preference(args[1], command, "Titlebar show", PREF_TITLEBAR_SHOW); + _cmd_set_boolean_preference(args[1], command, "Window title show", PREF_WINTITLE_SHOW); } else { - _cmd_set_boolean_preference(args[1], command, "Titlebar goodbye", PREF_TITLEBAR_GOODBYE); + _cmd_set_boolean_preference(args[1], command, "Window title goodbye", PREF_WINTITLE_GOODBYE); } return TRUE; diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index cae68f59..b936de63 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -128,7 +128,7 @@ gboolean cmd_status(ProfWin *window, const char *const command, gchar **args); gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args); gboolean cmd_theme(ProfWin *window, const char *const command, gchar **args); gboolean cmd_tiny(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_wintitle(ProfWin *window, const char *const command, gchar **args); gboolean cmd_vercheck(ProfWin *window, const char *const command, gchar **args); gboolean cmd_who(ProfWin *window, const char *const command, gchar **args); gboolean cmd_win(ProfWin *window, const char *const command, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index de75008e..68a132e5 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -143,6 +143,19 @@ prefs_load(void) prefs_free_string(value); } + // move pre 0.5.0 titlebar settings to wintitle + if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.show", NULL)) { + gboolean show = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.show", NULL); + g_key_file_set_boolean(prefs, PREF_GROUP_UI, "wintitle.show", show); + g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.show", NULL); + } + if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL)) { + gboolean goodbye = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL); + g_key_file_set_boolean(prefs, PREF_GROUP_UI, "wintitle.goodbye", goodbye); + g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL); + } + + _save_prefs(); boolean_choice_ac = autocomplete_new(); @@ -1162,8 +1175,8 @@ _get_group(preference_t pref) case PREF_BEEP: case PREF_THEME: case PREF_VERCHECK: - case PREF_TITLEBAR_SHOW: - case PREF_TITLEBAR_GOODBYE: + case PREF_WINTITLE_SHOW: + case PREF_WINTITLE_GOODBYE: case PREF_FLASH: case PREF_INTYPE: case PREF_HISTORY: @@ -1282,10 +1295,10 @@ _get_key(preference_t pref) return "theme"; case PREF_VERCHECK: return "vercheck"; - case PREF_TITLEBAR_SHOW: - return "titlebar.show"; - case PREF_TITLEBAR_GOODBYE: - return "titlebar.goodbye"; + case PREF_WINTITLE_SHOW: + return "wintitle.show"; + case PREF_WINTITLE_GOODBYE: + return "wintitle.goodbye"; case PREF_FLASH: return "flash"; case PREF_TRAY: diff --git a/src/config/preferences.h b/src/config/preferences.h index 67f3e1e4..ee89bd90 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -49,8 +49,8 @@ typedef enum { PREF_BEEP, PREF_VERCHECK, PREF_THEME, - PREF_TITLEBAR_SHOW, - PREF_TITLEBAR_GOODBYE, + PREF_WINTITLE_SHOW, + PREF_WINTITLE_GOODBYE, PREF_FLASH, PREF_TRAY, PREF_TRAY_READ, diff --git a/src/profanity.c b/src/profanity.c index 3cdec902..feedda9a 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -208,8 +208,8 @@ _init(char *log_level) static void _shutdown(void) { - if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { - if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { + if (prefs_get_boolean(PREF_WINTITLE_SHOW)) { + if (prefs_get_boolean(PREF_WINTITLE_GOODBYE)) { ui_goodbye_title(); } else { ui_clear_win_title(); diff --git a/src/ui/console.c b/src/ui/console.c index 3b99e58e..8bc7823f 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1339,17 +1339,17 @@ cons_vercheck_setting(void) } void -cons_titlebar_setting(void) +cons_wintitle_setting(void) { - if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { - cons_show("Titlebar show (/titlebar) : ON"); + if (prefs_get_boolean(PREF_WINTITLE_SHOW)) { + cons_show("Window title show (/wintitle) : ON"); } else { - cons_show("Titlebar show (/titlebar) : OFF"); + cons_show("Window title show (/wintitle) : OFF"); } - if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { - cons_show("Titlebar goodbye (/titlebar) : ON"); + if (prefs_get_boolean(PREF_WINTITLE_GOODBYE)) { + cons_show("Window title goodbye (/wintitle) : ON"); } else { - cons_show("Titlebar goodbye (/titlebar) : OFF"); + cons_show("Window title goodbye (/wintitle) : OFF"); } } @@ -1544,7 +1544,7 @@ cons_show_ui_prefs(void) cons_occupants_setting(); cons_roster_setting(); cons_privileges_setting(); - cons_titlebar_setting(); + cons_wintitle_setting(); cons_encwarn_setting(); cons_presence_setting(); cons_inpblock_setting(); diff --git a/src/ui/core.c b/src/ui/core.c index 2dad71fb..6c42c422 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -133,7 +133,7 @@ ui_update(void) win_update_virtual(current); - if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { + if (prefs_get_boolean(PREF_WINTITLE_SHOW)) { _ui_draw_term_title(); } title_bar_update_virtual(); diff --git a/src/ui/ui.h b/src/ui/ui.h index 7a2dc95a..ef0d808f 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -299,7 +299,7 @@ void cons_presence_setting(void); void cons_wrap_setting(void); void cons_winstidy_setting(void); void cons_time_setting(void); -void cons_titlebar_setting(void); +void cons_wintitle_setting(void); void cons_notify_setting(void); void cons_show_desktop_prefs(void); void cons_states_setting(void); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index d4c30698..685fa476 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -428,7 +428,7 @@ void cons_encwarn_setting(void) {} void cons_time_setting(void) {} void cons_mouse_setting(void) {} void cons_statuses_setting(void) {} -void cons_titlebar_setting(void) {} +void cons_wintitle_setting(void) {} void cons_notify_setting(void) {} void cons_states_setting(void) {} void cons_outtype_setting(void) {} From d3cc5bd7ed9563dfc673b72ac3347cf41fc3d057 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 23 Sep 2016 00:56:53 +0100 Subject: [PATCH 08/20] Allow vertical positioning of all windows --- Makefile.am | 1 + src/command/cmd_ac.c | 16 +- src/command/cmd_defs.c | 63 ++++- src/command/cmd_funcs.c | 130 +++++++++- src/command/cmd_funcs.h | 3 + src/config/preferences.c | 471 ++++++++++++++++++++++++++++++++++- src/config/preferences.h | 22 +- src/config/theme.c | 9 +- src/profanity.c | 1 + src/ui/console.c | 13 +- src/ui/core.c | 2 +- src/ui/inputwin.c | 14 +- src/ui/screen.c | 123 +++++++++ src/ui/screen.h | 40 +++ src/ui/statusbar.c | 26 +- src/ui/titlebar.c | 19 +- src/ui/ui.h | 2 +- src/ui/window.c | 73 ++---- tests/unittests/ui/stub_ui.c | 2 +- themes/bios | 5 +- themes/boothj5 | 6 +- themes/boothj5_slack | 6 +- themes/complex | 6 +- themes/forest | 6 +- themes/original | 5 +- themes/simple | 5 +- 26 files changed, 929 insertions(+), 140 deletions(-) create mode 100644 src/ui/screen.c create mode 100644 src/ui/screen.h diff --git a/Makefile.am b/Makefile.am index 754e2deb..6a98e981 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,7 @@ core_sources = \ src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \ src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \ + src/ui/screen.h src/ui/screen.c \ src/ui/console.c src/ui/notifier.c \ src/ui/win_types.h \ src/ui/window_list.c src/ui/window_list.h \ diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index b66fce4d..adfef4af 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -194,7 +194,7 @@ static Autocomplete blocked_ac; static Autocomplete tray_ac; static Autocomplete presence_ac; static Autocomplete presence_setting_ac; -static Autocomplete inputwin_ac; +static Autocomplete winpos_ac; void cmd_ac_init(void) @@ -737,9 +737,9 @@ cmd_ac_init(void) autocomplete_add(presence_setting_ac, "online"); autocomplete_add(presence_setting_ac, "none"); - inputwin_ac = autocomplete_new(); - autocomplete_add(inputwin_ac, "top"); - autocomplete_add(inputwin_ac, "bottom"); + winpos_ac = autocomplete_new(); + autocomplete_add(winpos_ac, "up"); + autocomplete_add(winpos_ac, "down"); } void @@ -1003,7 +1003,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(tray_ac); autocomplete_reset(presence_ac); autocomplete_reset(presence_setting_ac); - autocomplete_reset(inputwin_ac); + autocomplete_reset(winpos_ac); autocomplete_reset(script_ac); if (script_show_ac) { @@ -1126,7 +1126,7 @@ cmd_ac_uninit(void) autocomplete_free(tray_ac); autocomplete_free(presence_ac); autocomplete_free(presence_setting_ac); - autocomplete_free(inputwin_ac); + autocomplete_free(winpos_ac); } static char* @@ -1207,8 +1207,8 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input) } } - gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/inputwin" }; - Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, inputwin_ac }; + gchar *cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/titlebar", "/mainwin", "/statusbar", "/inputwin" }; + Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac, winpos_ac, winpos_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 52c06ae5..c8732b34 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1302,20 +1302,71 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, + { "/titlebar", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_titlebar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/titlebar up", + "/titlebar down") + CMD_DESC( + "Move the title bar.") + CMD_ARGS( + { "up", "Move the title bar up the screen." }, + { "down", "Move the title bar down the screen." }) + CMD_NOEXAMPLES + }, + + { "/mainwin", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_mainwin) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/mainwin up", + "/mainwin down") + CMD_DESC( + "Move the main window.") + CMD_ARGS( + { "up", "Move the main window up the screen." }, + { "down", "Move the main window down the screen." }) + CMD_NOEXAMPLES + }, + + { "/statusbar", + parse_args, 1, 1, &cons_winpos_setting, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_statusbar) + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/statusbar up", + "/statusbar down") + CMD_DESC( + "Move the status bar.") + CMD_ARGS( + { "up", "Move the status bar up the screen." }, + { "down", "Move the status bar down the screen." }) + CMD_NOEXAMPLES + }, + { "/inputwin", - parse_args, 1, 1, &cons_inputwin_setting, + parse_args, 1, 1, &cons_winpos_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_inputwin) CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/inputwin top", - "/inputwin bottom") + "/inputwin up", + "/inputwin down") CMD_DESC( - "Where to display the input window.") + "Move the input window.") CMD_ARGS( - { "top", "Show the input window at the top of the screen." }, - { "bottom", "Show the input window at the bottom of the screen." }) + { "up", "Move the input window up the screen." }, + { "down", "Move the input window down the screen." }) CMD_NOEXAMPLES }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 4f8dc993..97782e64 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5522,16 +5522,134 @@ cmd_inpblock(ProfWin *window, const char *const command, gchar **args) return TRUE; } +gboolean +cmd_titlebar(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_titlebar_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move title bar up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_titlebar_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move title bar down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + +gboolean +cmd_mainwin(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_mainwin_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move main window up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_mainwin_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move main window down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + +gboolean +cmd_statusbar(ProfWin *window, const char *const command, gchar **args) +{ + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_statusbar_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move status bar up."); + } + + return TRUE; + } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_statusbar_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move status bar down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); + + return TRUE; +} + gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args) { - if ((g_strcmp0(args[0], "top") == 0) || (g_strcmp0(args[0], "bottom") == 0)) { - prefs_set_string(PREF_INPUTWIN, args[0]); - ui_resize(); - cons_show("Set input window position to %s", args[0]); - } else { - cons_bad_cmd_usage(command); + if (g_strcmp0(args[0], "up") == 0) { + gboolean result = prefs_inputwin_pos_up(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move input window up."); + } + + return TRUE; } + if (g_strcmp0(args[0], "down") == 0) { + gboolean result = prefs_inputwin_pos_down(); + if (result) { + ui_resize(); + cons_winpos_setting(); + cons_show(""); + } else { + cons_show("Could not move input window down."); + } + + return TRUE; + } + + cons_bad_cmd_usage(command); return TRUE; } diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index b936de63..69358277 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -149,6 +149,9 @@ gboolean cmd_wrap(ProfWin *window, const char *const command, gchar **args); gboolean cmd_time(ProfWin *window, const char *const command, gchar **args); gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_titlebar(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_mainwin(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inputwin(ProfWin *window, const char *const command, gchar **args); gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 68a132e5..defc582e 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -143,7 +143,7 @@ prefs_load(void) prefs_free_string(value); } - // move pre 0.5.0 titlebar settings to wintitle + // move pre 0.6.0 titlebar settings to wintitle if (g_key_file_has_key(prefs, PREF_GROUP_UI, "titlebar.show", NULL)) { gboolean show = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "titlebar.show", NULL); g_key_file_set_boolean(prefs, PREF_GROUP_UI, "wintitle.show", show); @@ -155,7 +155,6 @@ prefs_load(void) g_key_file_remove_key(prefs, PREF_GROUP_UI, "titlebar.goodbye", NULL); } - _save_prefs(); boolean_choice_ac = autocomplete_new(); @@ -1062,6 +1061,469 @@ prefs_get_room_notify_triggers(void) return result; } +ProfWinPlacement* +prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin) +{ + ProfWinPlacement *placement = malloc(sizeof(ProfWinPlacement)); + placement->titlebar_pos = titlebar; + placement->mainwin_pos = mainwin; + placement->statusbar_pos = statusbar; + placement->inputwin_pos = inputwin; + + return placement; +} + +void +prefs_free_win_placement(ProfWinPlacement *placement) +{ + free(placement); +} + +ProfWinPlacement* +prefs_get_win_placement(void) +{ + // read from settings file + int titlebar_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "titlebar.position", NULL); + int mainwin_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "mainwin.position", NULL); + int statusbar_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "statusbar.position", NULL); + int inputwin_pos = g_key_file_get_integer(prefs, PREF_GROUP_UI, "inputwin.position", NULL); + + // default if setting invalid, or not present + if (titlebar_pos < 1 || titlebar_pos > 4) { + titlebar_pos = 1; + } + if (mainwin_pos < 1 || mainwin_pos > 4) { + mainwin_pos = 2; + } + if (statusbar_pos < 1 || statusbar_pos > 4) { + statusbar_pos = 3; + } + if (inputwin_pos < 1 || inputwin_pos > 4) { + inputwin_pos = 4; + } + + // return default if duplicates found + if (titlebar_pos == mainwin_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + if (titlebar_pos == statusbar_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + if (titlebar_pos == inputwin_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + + if (mainwin_pos == statusbar_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + if (mainwin_pos == inputwin_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + + if (statusbar_pos == inputwin_pos) { + return prefs_create_profwin_placement(1, 2, 3, 5); + } + + // return settings + return prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); +} + +void +prefs_save_win_placement(ProfWinPlacement *placement) +{ + g_key_file_set_integer(prefs, PREF_GROUP_UI, "titlebar.position", placement->titlebar_pos); + g_key_file_set_integer(prefs, PREF_GROUP_UI, "mainwin.position", placement->mainwin_pos); + g_key_file_set_integer(prefs, PREF_GROUP_UI, "statusbar.position", placement->statusbar_pos); + g_key_file_set_integer(prefs, PREF_GROUP_UI, "inputwin.position", placement->inputwin_pos); + _save_prefs(); +} + +gboolean +prefs_titlebar_pos_up(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 1; + if (placement->mainwin_pos == 1) { + placement->mainwin_pos = 2; + } else if (placement->statusbar_pos == 1) { + placement->statusbar_pos = 2; + } else if (placement->inputwin_pos == 1) { + placement->inputwin_pos = 2; + } + + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 2; + if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 3; + } else if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 3; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 3; + } + + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->titlebar_pos == 4) { + placement->titlebar_pos = 3; + if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 4; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 4; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 4; + } + + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_mainwin_pos_up(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 1; + if (placement->titlebar_pos == 1) { + placement->titlebar_pos = 2; + } else if (placement->statusbar_pos == 1) { + placement->statusbar_pos = 2; + } else if (placement->inputwin_pos == 1) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 3; + } else if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 3; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->mainwin_pos == 4) { + placement->mainwin_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 4; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 4; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 4; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_statusbar_pos_up(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 1; + if (placement->titlebar_pos == 1) { + placement->titlebar_pos = 2; + } else if (placement->mainwin_pos == 1) { + placement->mainwin_pos = 2; + } else if (placement->inputwin_pos == 1) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 3; + } else if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 3; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->statusbar_pos == 4) { + placement->statusbar_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 4; + } else if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 4; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 4; + } + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_inputwin_pos_up(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 1; + if (placement->titlebar_pos == 1) { + placement->titlebar_pos = 2; + } else if (placement->mainwin_pos == 1) { + placement->mainwin_pos = 2; + } else if (placement->inputwin_pos == 1) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 3; + } else if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 3; + } else if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->inputwin_pos == 4) { + placement->inputwin_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 4; + } else if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 4; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 4; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_titlebar_pos_down(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->titlebar_pos == 1) { + placement->titlebar_pos = 2; + if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 1; + } else if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 1; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 1; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 3; + if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 2; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 2; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 4; + if (placement->mainwin_pos == 4) { + placement->mainwin_pos = 3; + } else if (placement->statusbar_pos == 4) { + placement->statusbar_pos = 3; + } else if (placement->inputwin_pos == 4) { + placement->inputwin_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_mainwin_pos_down(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->mainwin_pos == 1) { + placement->mainwin_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 1; + } else if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 1; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 1; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 2; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 2; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 4; + if (placement->titlebar_pos == 4) { + placement->titlebar_pos = 3; + } else if (placement->statusbar_pos == 4) { + placement->statusbar_pos = 3; + } else if (placement->inputwin_pos == 4) { + placement->inputwin_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + +gboolean +prefs_statusbar_pos_down(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->statusbar_pos == 1) { + placement->statusbar_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 1; + } else if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 1; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 1; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->statusbar_pos == 2) { + placement->statusbar_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 2; + } else if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 2; + } else if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 4; + if (placement->titlebar_pos == 4) { + placement->titlebar_pos = 3; + } else if (placement->mainwin_pos == 4) { + placement->mainwin_pos = 3; + } else if (placement->inputwin_pos == 4) { + placement->inputwin_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + + +gboolean +prefs_inputwin_pos_down(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + if (placement->inputwin_pos == 1) { + placement->inputwin_pos = 2; + if (placement->titlebar_pos == 2) { + placement->titlebar_pos = 1; + } else if (placement->mainwin_pos == 2) { + placement->mainwin_pos = 1; + } else if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 1; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->inputwin_pos == 2) { + placement->inputwin_pos = 3; + if (placement->titlebar_pos == 3) { + placement->titlebar_pos = 2; + } else if (placement->mainwin_pos == 3) { + placement->mainwin_pos = 2; + } else if (placement->statusbar_pos == 3) { + placement->statusbar_pos = 2; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + if (placement->inputwin_pos == 3) { + placement->inputwin_pos = 4; + if (placement->titlebar_pos == 4) { + placement->titlebar_pos = 3; + } else if (placement->mainwin_pos == 4) { + placement->mainwin_pos = 3; + } else if (placement->statusbar_pos == 4) { + placement->statusbar_pos = 3; + } + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } + + prefs_free_win_placement(placement); + return FALSE; +} + gboolean prefs_add_alias(const char *const name, const char *const value) { @@ -1224,7 +1686,6 @@ _get_group(preference_t pref) case PREF_RESOURCE_MESSAGE: case PREF_ENC_WARN: case PREF_INPBLOCK_DYNAMIC: - case PREF_INPUTWIN: case PREF_TLS_SHOW: case PREF_CONSOLE_MUC: case PREF_CONSOLE_PRIVATE: @@ -1457,8 +1918,6 @@ _get_key(preference_t pref) return "resource.message"; case PREF_INPBLOCK_DYNAMIC: return "inpblock.dynamic"; - case PREF_INPUTWIN: - return "inputwin.position"; case PREF_ENC_WARN: return "enc.warn"; case PREF_PGP_LOG: @@ -1587,8 +2046,6 @@ _get_default_string(preference_t pref) case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_CHAT: return "all"; - case PREF_INPUTWIN: - return "bottom"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index ee89bd90..e0ac7442 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -132,7 +132,6 @@ typedef enum { PREF_RESOURCE_TITLE, PREF_RESOURCE_MESSAGE, PREF_INPBLOCK_DYNAMIC, - PREF_INPUTWIN, PREF_ENC_WARN, PREF_PGP_LOG, PREF_TLS_CERTPATH, @@ -149,6 +148,13 @@ typedef struct prof_alias_t { gchar *value; } ProfAlias; +typedef struct prof_winplacement_t { + int titlebar_pos; + int mainwin_pos; + int statusbar_pos; + int inputwin_pos; +} ProfWinPlacement; + void prefs_load(void); void prefs_close(void); @@ -240,6 +246,20 @@ gboolean prefs_add_room_notify_trigger(const char * const text); gboolean prefs_remove_room_notify_trigger(const char * const text); GList* prefs_get_room_notify_triggers(void); +ProfWinPlacement* prefs_get_win_placement(void); +void prefs_free_win_placement(ProfWinPlacement *placement); + +gboolean prefs_titlebar_pos_up(void); +gboolean prefs_titlebar_pos_down(void); +gboolean prefs_mainwin_pos_up(void); +gboolean prefs_mainwin_pos_down(void); +gboolean prefs_statusbar_pos_up(void); +gboolean prefs_statusbar_pos_down(void); +gboolean prefs_inputwin_pos_up(void); +gboolean prefs_inputwin_pos_down(void); +ProfWinPlacement* prefs_create_profwin_placement(int titlebar, int mainwin, int statusbar, int inputwin); +void prefs_save_win_placement(ProfWinPlacement *placement); + gboolean prefs_get_boolean(preference_t pref); void prefs_set_boolean(preference_t pref, gboolean value); char* prefs_get_string(preference_t pref); diff --git a/src/config/theme.c b/src/config/theme.c index d4494e58..cee95883 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -429,7 +429,6 @@ _load_preferences(void) _set_string_preference("roster.rooms.by", PREF_ROSTER_ROOMS_BY); _set_string_preference("roster.private", PREF_ROSTER_PRIVATE); _set_string_preference("roster.count", PREF_ROSTER_COUNT); - _set_string_preference("inputwin.position", PREF_INPUTWIN); if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) { gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL); @@ -531,6 +530,14 @@ _load_preferences(void) g_free(ch); } } + + int titlebar_pos = g_key_file_get_integer(theme, "ui", "titlebar.position", NULL); + int mainwin_pos = g_key_file_get_integer(theme, "ui", "mainwin.position", NULL); + int statusbar_pos = g_key_file_get_integer(theme, "ui", "statusbar.position", NULL); + int inputwin_pos = g_key_file_get_integer(theme, "ui", "inputwin.position", NULL); + ProfWinPlacement *placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); } void diff --git a/src/profanity.c b/src/profanity.c index feedda9a..d76d03a3 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -203,6 +203,7 @@ _init(char *log_level) tray_init(); #endif inp_nonblocking(TRUE); + ui_resize(); } static void diff --git a/src/ui/console.c b/src/ui/console.c index 8bc7823f..98967206 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1534,7 +1534,7 @@ cons_show_ui_prefs(void) cons_beep_setting(); cons_flash_setting(); cons_splash_setting(); - cons_inputwin_setting(); + cons_winpos_setting(); cons_wrap_setting(); cons_winstidy_setting(); cons_time_setting(); @@ -1753,11 +1753,14 @@ cons_inpblock_setting(void) } void -cons_inputwin_setting(void) +cons_winpos_setting(void) { - char *pos = prefs_get_string(PREF_INPUTWIN); - cons_show("Input window postion (/inputwin) : %s", pos); - prefs_free_string(pos); + ProfWinPlacement *placement = prefs_get_win_placement(); + cons_show("Title bar postion (/titlebar) : %d", placement->titlebar_pos); + cons_show("Main window postion (/mainwin) : %d", placement->mainwin_pos); + cons_show("Status bar postion (/statusbar) : %d", placement->statusbar_pos); + cons_show("Input window postion (/inputwin) : %d", placement->inputwin_pos); + prefs_free_win_placement(placement); } void diff --git a/src/ui/core.c b/src/ui/core.c index 6c42c422..c471aad7 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -370,7 +370,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured) } else { ui_hide_all_room_rosters(); } - ui_redraw(); + ui_resize(); } else { cons_show("Couldn't find account theme: %s", account->theme); } diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 29bf04c4..9197485f 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -62,6 +62,7 @@ #include "config/preferences.h" #include "config/theme.h" #include "ui/ui.h" +#include "ui/screen.h" #include "ui/statusbar.h" #include "ui/inputwin.h" #include "ui/window.h" @@ -280,16 +281,9 @@ inp_put_back(void) static void _inp_win_update_virtual(void) { - int wrows, wcols; - getmaxyx(stdscr, wrows, wcols); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(inp_win, 0, pad_start, 0, 0, 0, wcols-2); - } else { - pnoutrefresh(inp_win, 0, pad_start, wrows-1, 0, wrows-1, wcols-2); - } - prefs_free_string(pos); - + int wcols = getmaxx(stdscr); + int row = screen_inputwin_row(); + pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols-2); } static void diff --git a/src/ui/screen.c b/src/ui/screen.c new file mode 100644 index 00000000..63cdab27 --- /dev/null +++ b/src/ui/screen.c @@ -0,0 +1,123 @@ +/* + * screen.c + * + * Copyright (C) 2012 - 2016 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +#include "config.h" + +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif HAVE_NCURSES_H +#include +#endif + +#include "config/preferences.h" + +int +_screen_line_row(int win_pos, int mainwin_pos) { + int wrows = getmaxy(stdscr); + + if (win_pos == 1) { + return 0; + } + + if (win_pos == 2) { + int row = 1; + if (mainwin_pos == 1) { + row = wrows-3; + } + + return row; + } + + if (win_pos == 3) { + int row = 2; + if (mainwin_pos == 1 || mainwin_pos == 2) { + row = wrows-2; + } + + return row; + } + + return wrows-1; +} + +int +screen_titlebar_row(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + int row = _screen_line_row(placement->titlebar_pos, placement->mainwin_pos); + prefs_free_win_placement(placement); + + return row; +} + +int +screen_statusbar_row(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + int row = _screen_line_row(placement->statusbar_pos, placement->mainwin_pos); + prefs_free_win_placement(placement); + + return row; +} + +int +screen_inputwin_row(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + int row = _screen_line_row(placement->inputwin_pos, placement->mainwin_pos); + prefs_free_win_placement(placement); + + return row; +} + +int +screen_mainwin_row_start(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + int row = placement->mainwin_pos-1; + prefs_free_win_placement(placement); + + return row; +} + +int +screen_mainwin_row_end(void) +{ + ProfWinPlacement *placement = prefs_get_win_placement(); + int wrows = getmaxy(stdscr); + int row = wrows - (5 - placement->mainwin_pos); + prefs_free_win_placement(placement); + + return row; +} diff --git a/src/ui/screen.h b/src/ui/screen.h new file mode 100644 index 00000000..388d6fb5 --- /dev/null +++ b/src/ui/screen.h @@ -0,0 +1,40 @@ +/* + * screen.h + * + * Copyright (C) 2012 - 2016 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +int screen_titlebar_row(void); +int screen_statusbar_row(void); +int screen_inputwin_row(void); + +int screen_mainwin_row_start(void); +int screen_mainwin_row_end(void); diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 9b87ecdc..9964c314 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -49,6 +49,7 @@ #include "ui/ui.h" #include "ui/statusbar.h" #include "ui/inputwin.h" +#include "ui/screen.h" #define TIME_CHECK 60000000 @@ -74,8 +75,8 @@ static void _status_bar_draw(void); void create_status_bar(void) { - int rows, cols, i; - getmaxyx(stdscr, rows, cols); + int i; + int cols = getmaxx(stdscr); is_active[1] = TRUE; is_new[1] = FALSE; @@ -89,13 +90,8 @@ create_status_bar(void) int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - status_bar = newwin(1, cols, rows-1, 0); - } else { - status_bar = newwin(1, cols, rows-2, 0); - } - prefs_free_string(pos); + int row = screen_statusbar_row(); + status_bar = newwin(1, cols, row, 0); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT)); wattron(status_bar, bracket_attrs); mvwprintw(status_bar, 0, cols - 34, _active); @@ -121,20 +117,14 @@ status_bar_update_virtual(void) void status_bar_resize(void) { - int rows, cols; - getmaxyx(stdscr, rows, cols); + int cols = getmaxx(stdscr); werase(status_bar); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - mvwin(status_bar, rows-1, 0); - } else { - mvwin(status_bar, rows-2, 0); - } - prefs_free_string(pos); + int row = screen_statusbar_row(); + mvwin(status_bar, row, 0); wresize(status_bar, 1, cols); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT)); wattron(status_bar, bracket_attrs); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 90775ce7..436b574c 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -46,6 +46,7 @@ #include "ui/inputwin.h" #include "ui/window_list.h" #include "ui/window.h" +#include "ui/screen.h" #include "xmpp/roster_list.h" #include "xmpp/chat_session.h" @@ -67,13 +68,8 @@ create_title_bar(void) { int cols = getmaxx(stdscr); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - win = newwin(1, cols, 1, 0); - } else { - win = newwin(1, cols, 0, 0); - } - prefs_free_string(pos); + int row = screen_titlebar_row(); + win = newwin(1, cols, row, 0); wbkgd(win, theme_attrs(THEME_TITLE_TEXT)); title_bar_console(); title_bar_set_presence(CONTACT_OFFLINE); @@ -109,13 +105,8 @@ title_bar_resize(void) werase(win); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - mvwin(win, 1, 0); - } else { - mvwin(win, 0, 0); - } - prefs_free_string(pos); + int row = screen_titlebar_row(); + mvwin(win, row, 0); wresize(win, 1, cols); wbkgd(win, theme_attrs(THEME_TITLE_TEXT)); diff --git a/src/ui/ui.h b/src/ui/ui.h index ef0d808f..bff1c921 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -317,7 +317,7 @@ void cons_reconnect_setting(void); void cons_autoping_setting(void); void cons_autoconnect_setting(void); void cons_inpblock_setting(void); -void cons_inputwin_setting(void); +void cons_winpos_setting(void); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_offline(PContact contact, char *resource, char *status); void cons_theme_properties(void); diff --git a/src/ui/window.c b/src/ui/window.c index a8f9ec63..4cbe25f4 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -52,6 +52,7 @@ #include "config/preferences.h" #include "ui/ui.h" #include "ui/window.h" +#include "ui/screen.h" #include "xmpp/xmpp.h" #include "xmpp/roster_list.h" @@ -604,9 +605,10 @@ win_resize(ProfWin *window) void win_update_virtual(ProfWin *window) { - int rows, cols; - getmaxyx(stdscr, rows, cols); + int cols = getmaxx(stdscr); + int row_start = screen_mainwin_row_start(); + int row_end = screen_mainwin_row_end(); if (window->layout->type == LAYOUT_SPLIT) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { @@ -616,83 +618,46 @@ win_update_virtual(ProfWin *window) } else { subwin_cols = win_roster_cols(); } - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); - } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); - } - prefs_free_string(pos); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); } else { - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, cols-1); - } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, cols-1); - } - prefs_free_string(pos); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols-1); } } else { - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1); - } else { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); - } - prefs_free_string(pos); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); } } void win_refresh_without_subwin(ProfWin *window) { - int rows, cols; - getmaxyx(stdscr, rows, cols); + int cols = getmaxx(stdscr); if ((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) { - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 2, 0, rows-2, cols-1); - } else { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, 1, 0, rows-3, cols-1); - } - prefs_free_string(pos); + int row_start = screen_mainwin_row_start(); + int row_end = screen_mainwin_row_end(); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); } } void win_refresh_with_subwin(ProfWin *window) { - int rows, cols; - getmaxyx(stdscr, rows, cols); + int cols = getmaxx(stdscr); int subwin_cols = 0; + int row_start = screen_mainwin_row_start(); + int row_end = screen_mainwin_row_end(); if (window->type == WIN_MUC) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; subwin_cols = win_occpuants_cols(); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); - } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); - } - prefs_free_string(pos); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); } else if (window->type == WIN_CONSOLE) { ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; subwin_cols = win_roster_cols(); - char *pos = prefs_get_string(PREF_INPUTWIN); - if (g_strcmp0(pos, "top") == 0) { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 2, 0, rows-2, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 2, (cols-subwin_cols), rows-2, cols-1); - } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, 1, 0, rows-3, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, 1, (cols-subwin_cols), rows-3, cols-1); - } - prefs_free_string(pos); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 685fa476..85cbffc2 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -445,7 +445,7 @@ void cons_reconnect_setting(void) {} void cons_autoping_setting(void) {} void cons_autoconnect_setting(void) {} void cons_inpblock_setting(void) {} -void cons_inputwin_setting(void) {} +void cons_winpos_setting(void) {} void cons_tray_setting(void) {} void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) diff --git a/themes/bios b/themes/bios index ea854036..3d524652 100644 --- a/themes/bios +++ b/themes/bios @@ -130,4 +130,7 @@ otr.char=@ pgp.char=% tls.show=true console.muc=first -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 diff --git a/themes/boothj5 b/themes/boothj5 index 5fa069b5..b22e8648 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -137,4 +137,8 @@ tls.show=true console.muc=first console.chat=all console.private=all -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 + diff --git a/themes/boothj5_slack b/themes/boothj5_slack index d0121c1d..2c306598 100644 --- a/themes/boothj5_slack +++ b/themes/boothj5_slack @@ -133,4 +133,8 @@ tls.show=true console.muc=first console.chat=all console.private=all -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 + diff --git a/themes/complex b/themes/complex index 78a01c27..65e09337 100644 --- a/themes/complex +++ b/themes/complex @@ -58,4 +58,8 @@ tls.show=true console.muc=all console.chat=all console.private=all -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 + diff --git a/themes/forest b/themes/forest index 95fc3ad9..13f0f12d 100644 --- a/themes/forest +++ b/themes/forest @@ -77,4 +77,8 @@ occupants.header=bold_green receipt.sent=bold_black [ui] -inputwin.position=top +titlebar.position=1 +inputwin.position=2 +statusbar.position=3 +mainwin.position=4 + diff --git a/themes/original b/themes/original index a5e450ef..27cc38dd 100644 --- a/themes/original +++ b/themes/original @@ -77,4 +77,7 @@ occupants.header=yellow receipt.sent=red [ui] -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 diff --git a/themes/simple b/themes/simple index 9e387049..b26eebf3 100644 --- a/themes/simple +++ b/themes/simple @@ -45,4 +45,7 @@ tls.show=false console.muc=first console.chat=first console.private=first -inputwin.position=bottom +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 From 6c8def367cd339eb1acc330a433533f2b2b0147c Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 23 Sep 2016 01:04:41 +0100 Subject: [PATCH 09/20] Fix /inputwin up --- src/config/preferences.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/config/preferences.c b/src/config/preferences.c index defc582e..729efa6c 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1202,6 +1202,7 @@ prefs_mainwin_pos_up(void) } else if (placement->inputwin_pos == 1) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1215,6 +1216,7 @@ prefs_mainwin_pos_up(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1228,6 +1230,7 @@ prefs_mainwin_pos_up(void) } else if (placement->inputwin_pos == 3) { placement->inputwin_pos = 4; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1250,6 +1253,7 @@ prefs_statusbar_pos_up(void) } else if (placement->inputwin_pos == 1) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1263,6 +1267,7 @@ prefs_statusbar_pos_up(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1276,6 +1281,9 @@ prefs_statusbar_pos_up(void) } else if (placement->inputwin_pos == 3) { placement->inputwin_pos = 4; } + + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); return TRUE; } @@ -1296,6 +1304,7 @@ prefs_inputwin_pos_up(void) } else if (placement->inputwin_pos == 1) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1309,6 +1318,7 @@ prefs_inputwin_pos_up(void) } else if (placement->statusbar_pos == 2) { placement->statusbar_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1322,6 +1332,7 @@ prefs_inputwin_pos_up(void) } else if (placement->statusbar_pos == 3) { placement->statusbar_pos = 4; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1344,6 +1355,7 @@ prefs_titlebar_pos_down(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 1; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1357,6 +1369,7 @@ prefs_titlebar_pos_down(void) } else if (placement->inputwin_pos == 3) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1370,6 +1383,7 @@ prefs_titlebar_pos_down(void) } else if (placement->inputwin_pos == 4) { placement->inputwin_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1392,6 +1406,7 @@ prefs_mainwin_pos_down(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 1; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1405,6 +1420,7 @@ prefs_mainwin_pos_down(void) } else if (placement->inputwin_pos == 3) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1418,6 +1434,7 @@ prefs_mainwin_pos_down(void) } else if (placement->inputwin_pos == 4) { placement->inputwin_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1440,6 +1457,7 @@ prefs_statusbar_pos_down(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 1; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1453,6 +1471,7 @@ prefs_statusbar_pos_down(void) } else if (placement->inputwin_pos == 3) { placement->inputwin_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1466,6 +1485,7 @@ prefs_statusbar_pos_down(void) } else if (placement->inputwin_pos == 4) { placement->inputwin_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1489,6 +1509,7 @@ prefs_inputwin_pos_down(void) } else if (placement->inputwin_pos == 2) { placement->inputwin_pos = 1; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1502,6 +1523,7 @@ prefs_inputwin_pos_down(void) } else if (placement->statusbar_pos == 3) { placement->statusbar_pos = 2; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; @@ -1515,6 +1537,7 @@ prefs_inputwin_pos_down(void) } else if (placement->statusbar_pos == 4) { placement->statusbar_pos = 3; } + prefs_save_win_placement(placement); prefs_free_win_placement(placement); return TRUE; From 3bf383cec6ec272c0584862f6e863bcb1bae9532 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 20:49:54 +0100 Subject: [PATCH 10/20] Fix defaulting win positions --- src/config/preferences.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index 729efa6c..55cba9d8 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1104,24 +1104,24 @@ prefs_get_win_placement(void) // return default if duplicates found if (titlebar_pos == mainwin_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } if (titlebar_pos == statusbar_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } if (titlebar_pos == inputwin_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } if (mainwin_pos == statusbar_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } if (mainwin_pos == inputwin_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } if (statusbar_pos == inputwin_pos) { - return prefs_create_profwin_placement(1, 2, 3, 5); + return prefs_create_profwin_placement(1, 2, 3, 4); } // return settings From 72f6b2db71bffd47c856689f70aad4cccfe8ad97 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 21:24:29 +0100 Subject: [PATCH 11/20] Tidy window position prefs --- src/config/preferences.c | 424 +++++++++++---------------------------- 1 file changed, 120 insertions(+), 304 deletions(-) diff --git a/src/config/preferences.c b/src/config/preferences.c index 55cba9d8..f6f73995 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1142,47 +1142,24 @@ gboolean prefs_titlebar_pos_up(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 1; - if (placement->mainwin_pos == 1) { - placement->mainwin_pos = 2; - } else if (placement->statusbar_pos == 1) { - placement->statusbar_pos = 2; - } else if (placement->inputwin_pos == 1) { - placement->inputwin_pos = 2; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 2; - if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 3; - } else if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 3; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 3; - } + int pos = 2; + for (pos = 2; pos<5; pos++) { + if (placement->titlebar_pos == pos) { + placement->titlebar_pos = pos-1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->titlebar_pos == 4) { - placement->titlebar_pos = 3; - if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 4; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 4; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 4; - } + if (placement->mainwin_pos == pos-1) { + placement->mainwin_pos = pos; + } else if (placement->statusbar_pos == pos-1) { + placement->statusbar_pos = pos; + } else if (placement->inputwin_pos == pos-1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1193,47 +1170,24 @@ gboolean prefs_mainwin_pos_up(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 1; - if (placement->titlebar_pos == 1) { - placement->titlebar_pos = 2; - } else if (placement->statusbar_pos == 1) { - placement->statusbar_pos = 2; - } else if (placement->inputwin_pos == 1) { - placement->inputwin_pos = 2; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 3; - } else if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 3; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 3; - } + int pos = 2; + for (pos = 2; pos<5; pos++) { + if (placement->mainwin_pos == pos) { + placement->mainwin_pos = pos-1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->mainwin_pos == 4) { - placement->mainwin_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 4; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 4; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 4; - } + if (placement->titlebar_pos == pos-1) { + placement->titlebar_pos = pos; + } else if (placement->statusbar_pos == pos-1) { + placement->statusbar_pos = pos; + } else if (placement->inputwin_pos == pos-1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1244,47 +1198,24 @@ gboolean prefs_statusbar_pos_up(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 1; - if (placement->titlebar_pos == 1) { - placement->titlebar_pos = 2; - } else if (placement->mainwin_pos == 1) { - placement->mainwin_pos = 2; - } else if (placement->inputwin_pos == 1) { - placement->inputwin_pos = 2; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 3; - } else if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 3; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 3; - } + int pos = 2; + for (pos = 2; pos<5; pos++) { + if (placement->statusbar_pos == pos) { + placement->statusbar_pos = pos-1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->statusbar_pos == 4) { - placement->statusbar_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 4; - } else if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 4; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 4; - } + if (placement->titlebar_pos == pos-1) { + placement->titlebar_pos = pos; + } else if (placement->mainwin_pos == pos-1) { + placement->mainwin_pos = pos; + } else if (placement->inputwin_pos == pos-1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1295,47 +1226,24 @@ gboolean prefs_inputwin_pos_up(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 1; - if (placement->titlebar_pos == 1) { - placement->titlebar_pos = 2; - } else if (placement->mainwin_pos == 1) { - placement->mainwin_pos = 2; - } else if (placement->inputwin_pos == 1) { - placement->inputwin_pos = 2; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 3; - } else if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 3; - } else if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 3; - } + int pos = 2; + for (pos = 2; pos<5; pos++) { + if (placement->inputwin_pos == pos) { + placement->inputwin_pos = pos-1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->inputwin_pos == 4) { - placement->inputwin_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 4; - } else if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 4; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 4; - } + if (placement->titlebar_pos == pos-1) { + placement->titlebar_pos = pos; + } else if (placement->mainwin_pos == pos-1) { + placement->mainwin_pos = pos; + } else if (placement->statusbar_pos == pos-1) { + placement->statusbar_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1346,47 +1254,24 @@ gboolean prefs_titlebar_pos_down(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->titlebar_pos == 1) { - placement->titlebar_pos = 2; - if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 1; - } else if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 1; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 1; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 3; - if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 2; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 2; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 2; - } + int pos = 1; + for (pos = 1; pos<4; pos++) { + if (placement->titlebar_pos == pos) { + placement->titlebar_pos = pos+1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 4; - if (placement->mainwin_pos == 4) { - placement->mainwin_pos = 3; - } else if (placement->statusbar_pos == 4) { - placement->statusbar_pos = 3; - } else if (placement->inputwin_pos == 4) { - placement->inputwin_pos = 3; - } + if (placement->mainwin_pos == pos+1) { + placement->mainwin_pos = pos; + } else if (placement->statusbar_pos == pos+1) { + placement->statusbar_pos = pos; + } else if (placement->inputwin_pos == pos+1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1397,47 +1282,24 @@ gboolean prefs_mainwin_pos_down(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->mainwin_pos == 1) { - placement->mainwin_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 1; - } else if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 1; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 1; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 2; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 2; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 2; - } + int pos = 1; + for (pos = 1; pos<4; pos++) { + if (placement->mainwin_pos == pos) { + placement->mainwin_pos = pos+1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 4; - if (placement->titlebar_pos == 4) { - placement->titlebar_pos = 3; - } else if (placement->statusbar_pos == 4) { - placement->statusbar_pos = 3; - } else if (placement->inputwin_pos == 4) { - placement->inputwin_pos = 3; - } + if (placement->titlebar_pos == pos+1) { + placement->titlebar_pos = pos; + } else if (placement->statusbar_pos == pos+1) { + placement->statusbar_pos = pos; + } else if (placement->inputwin_pos == pos+1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1448,47 +1310,24 @@ gboolean prefs_statusbar_pos_down(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->statusbar_pos == 1) { - placement->statusbar_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 1; - } else if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 1; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 1; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->statusbar_pos == 2) { - placement->statusbar_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 2; - } else if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 2; - } else if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 2; - } + int pos = 1; + for (pos = 1; pos<4; pos++) { + if (placement->statusbar_pos == pos) { + placement->statusbar_pos = pos+1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 4; - if (placement->titlebar_pos == 4) { - placement->titlebar_pos = 3; - } else if (placement->mainwin_pos == 4) { - placement->mainwin_pos = 3; - } else if (placement->inputwin_pos == 4) { - placement->inputwin_pos = 3; - } + if (placement->titlebar_pos == pos+1) { + placement->titlebar_pos = pos; + } else if (placement->mainwin_pos == pos+1) { + placement->mainwin_pos = pos; + } else if (placement->inputwin_pos == pos+1) { + placement->inputwin_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); @@ -1500,47 +1339,24 @@ gboolean prefs_inputwin_pos_down(void) { ProfWinPlacement *placement = prefs_get_win_placement(); - if (placement->inputwin_pos == 1) { - placement->inputwin_pos = 2; - if (placement->titlebar_pos == 2) { - placement->titlebar_pos = 1; - } else if (placement->mainwin_pos == 2) { - placement->mainwin_pos = 1; - } else if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 1; - } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->inputwin_pos == 2) { - placement->inputwin_pos = 3; - if (placement->titlebar_pos == 3) { - placement->titlebar_pos = 2; - } else if (placement->mainwin_pos == 3) { - placement->mainwin_pos = 2; - } else if (placement->statusbar_pos == 3) { - placement->statusbar_pos = 2; - } + int pos = 1; + for (pos = 1; pos<4; pos++) { + if (placement->inputwin_pos == pos) { + placement->inputwin_pos = pos+1; - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; - } - if (placement->inputwin_pos == 3) { - placement->inputwin_pos = 4; - if (placement->titlebar_pos == 4) { - placement->titlebar_pos = 3; - } else if (placement->mainwin_pos == 4) { - placement->mainwin_pos = 3; - } else if (placement->statusbar_pos == 4) { - placement->statusbar_pos = 3; - } + if (placement->titlebar_pos == pos+1) { + placement->titlebar_pos = pos; + } else if (placement->mainwin_pos == pos+1) { + placement->mainwin_pos = pos; + } else if (placement->statusbar_pos == pos+1) { + placement->statusbar_pos = pos; + } - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); - return TRUE; + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + return TRUE; + } } prefs_free_win_placement(placement); From 83974728af4030d829295b8a03def367f9fe14e8 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 21:47:00 +0100 Subject: [PATCH 12/20] Remove verbose output on window move --- src/command/cmd_funcs.c | 24 ++++++++---------------- src/config/theme.c | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 97782e64..c8c79e0c 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5529,8 +5529,7 @@ cmd_titlebar(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_titlebar_pos_up(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Title bar moved up."); } else { cons_show("Could not move title bar up."); } @@ -5541,8 +5540,7 @@ cmd_titlebar(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_titlebar_pos_down(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Title bar moved down."); } else { cons_show("Could not move title bar down."); } @@ -5562,8 +5560,7 @@ cmd_mainwin(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_mainwin_pos_up(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Main window moved up."); } else { cons_show("Could not move main window up."); } @@ -5574,8 +5571,7 @@ cmd_mainwin(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_mainwin_pos_down(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Main window moved down."); } else { cons_show("Could not move main window down."); } @@ -5595,8 +5591,7 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_statusbar_pos_up(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Status bar moved up"); } else { cons_show("Could not move status bar up."); } @@ -5607,8 +5602,7 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_statusbar_pos_down(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Status bar moved down."); } else { cons_show("Could not move status bar down."); } @@ -5628,8 +5622,7 @@ cmd_inputwin(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_inputwin_pos_up(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Input window moved up."); } else { cons_show("Could not move input window up."); } @@ -5640,8 +5633,7 @@ cmd_inputwin(ProfWin *window, const char *const command, gchar **args) gboolean result = prefs_inputwin_pos_down(); if (result) { ui_resize(); - cons_winpos_setting(); - cons_show(""); + cons_show("Input window moved down."); } else { cons_show("Could not move input window down."); } diff --git a/src/config/theme.c b/src/config/theme.c index cee95883..44c9c3ff 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -531,13 +531,18 @@ _load_preferences(void) } } - int titlebar_pos = g_key_file_get_integer(theme, "ui", "titlebar.position", NULL); - int mainwin_pos = g_key_file_get_integer(theme, "ui", "mainwin.position", NULL); - int statusbar_pos = g_key_file_get_integer(theme, "ui", "statusbar.position", NULL); - int inputwin_pos = g_key_file_get_integer(theme, "ui", "inputwin.position", NULL); - ProfWinPlacement *placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); - prefs_save_win_placement(placement); - prefs_free_win_placement(placement); + if (g_key_file_has_key(theme, "ui", "titlebar.position", NULL) && + g_key_file_has_key(theme, "ui", "mainwin.position", NULL) && + g_key_file_has_key(theme, "ui", "statusbar.position", NULL) && + g_key_file_has_key(theme, "ui", "inputwin.position", NULL)) { + int titlebar_pos = g_key_file_get_integer(theme, "ui", "titlebar.position", NULL); + int mainwin_pos = g_key_file_get_integer(theme, "ui", "mainwin.position", NULL); + int statusbar_pos = g_key_file_get_integer(theme, "ui", "statusbar.position", NULL); + int inputwin_pos = g_key_file_get_integer(theme, "ui", "inputwin.position", NULL); + ProfWinPlacement *placement = prefs_create_profwin_placement(titlebar_pos, mainwin_pos, statusbar_pos, inputwin_pos); + prefs_save_win_placement(placement); + prefs_free_win_placement(placement); + } } void From 9796b23cfd5c0e3ab061f39bf77708fff4a3f52c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 22:57:43 +0100 Subject: [PATCH 13/20] Use caps_lookup when checking for feature --- src/xmpp/capabilities.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index ca09e703..e09270cb 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -310,8 +310,7 @@ caps_lookup(const char *const jid) gboolean caps_jid_has_feature(const char *const jid, const char *const feature) { - char *ver = g_hash_table_lookup(jid_to_ver, jid); - EntityCapabilities *caps = ver ? _caps_by_ver(ver) : _caps_by_jid(jid); + EntityCapabilities *caps = caps_lookup(jid); if (caps == NULL) { return FALSE; From a48df40138d0e7f3709a2ab45157f5696b6f861b Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 23:30:44 +0100 Subject: [PATCH 14/20] Fix assertion errors in unit tests --- src/plugins/plugins.c | 2 ++ tests/unittests/test_server_events.c | 8 ++++++++ tests/unittests/unittests.c | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 97e328d7..a4846b20 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -839,4 +839,6 @@ plugins_shutdown(void) plugin_settings_close(); callbacks_close(); disco_close(); + g_hash_table_destroy(plugins); + plugins = NULL; } diff --git a/tests/unittests/test_server_events.c b/tests/unittests/test_server_events.c index 9ab54cdb..fb178ac2 100644 --- a/tests/unittests/test_server_events.c +++ b/tests/unittests/test_server_events.c @@ -17,6 +17,7 @@ void console_shows_online_presence_when_set_online(void **state) { prefs_set_string(PREF_STATUSES_CONSOLE, "online"); + plugins_init(); roster_create(); char *barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); @@ -29,11 +30,13 @@ void console_shows_online_presence_when_set_online(void **state) sv_ev_contact_online(barejid, resource, NULL, NULL); roster_destroy(); + plugins_shutdown(); } void console_shows_online_presence_when_set_all(void **state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); + plugins_init(); roster_create(); char *barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); @@ -46,11 +49,13 @@ void console_shows_online_presence_when_set_all(void **state) sv_ev_contact_online(barejid, resource, NULL, NULL); roster_destroy(); + plugins_shutdown(); } void console_shows_dnd_presence_when_set_all(void **state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); + plugins_init(); roster_create(); char *barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); @@ -63,10 +68,12 @@ void console_shows_dnd_presence_when_set_all(void **state) sv_ev_contact_online(barejid, resource, NULL, NULL); roster_destroy(); + plugins_shutdown(); } void handle_offline_removes_chat_session(void **state) { + plugins_init(); roster_create(); chat_sessions_init(); char *barejid = "friend@server.chat.com"; @@ -85,6 +92,7 @@ void handle_offline_removes_chat_session(void **state) roster_destroy(); chat_sessions_clear(); + plugins_shutdown(); } void lost_connection_clears_chat_sessions(void **state) diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index e427e151..e0a5dd34 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -429,7 +429,9 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, load_preferences, close_preferences), - unit_test(handle_offline_removes_chat_session), + unit_test_setup_teardown(handle_offline_removes_chat_session, + load_preferences, + close_preferences), unit_test(lost_connection_clears_chat_sessions), unit_test(cmd_alias_add_shows_usage_when_no_args), From c264da698fef5f1da6fa1a060d7a8fd5a1ae942a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 23:32:52 +0100 Subject: [PATCH 15/20] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b143d522..f958ed0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -0.5.1 +0.6.0 ===== - Allow positioning input window at top of screen (/inputwin) From 4521ad9e113bb8ea466a9e718e62204a9c323b7f Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 25 Sep 2016 23:35:12 +0100 Subject: [PATCH 16/20] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b143d522..f958ed0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -0.5.1 +0.6.0 ===== - Allow positioning input window at top of screen (/inputwin) From 27684e59c3d12e861fae8ad44c689a17f22e53a3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 26 Sep 2016 00:02:36 +0100 Subject: [PATCH 17/20] Update CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f958ed0d..5838b89b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ 0.6.0 ===== -- Allow positioning input window at top of screen (/inputwin) +- Allow moving vertical window positions (/titlebar, /mainwin, /statusbar, /inputwin) 0.5.0 ===== From e78684f6899da393c6f5ca4806d1d10099fa4c34 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 26 Sep 2016 00:16:12 +0100 Subject: [PATCH 18/20] Tests: longer timeout for failing functional test on travis --- tests/functionaltests/test_muc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c index 5a117045..3dfdbbba 100644 --- a/tests/functionaltests/test_muc.c +++ b/tests/functionaltests/test_muc.c @@ -107,7 +107,9 @@ shows_role_and_affiliation_on_join(void **state) prof_input("/join testroom@conference.localhost"); + prof_timeout(60); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); + prof_timeout_reset(); } void From 388a20813c87ceaa45143c09e2b5d68ecc955c5d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 26 Sep 2016 00:39:37 +0100 Subject: [PATCH 19/20] Tests: disable occupants panel in functional tests --- tests/functionaltests/proftest.c | 2 ++ tests/functionaltests/test_muc.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index 20e9da14..0af26a68 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -174,6 +174,8 @@ init_prof_test(void **state) assert_true(prof_output_exact("Word wrap disabled")); prof_input("/roster hide"); assert_true(prof_output_exact("Roster disabled")); + prof_input("/occupants default hide"); + assert_true(prof_output_exact("Occupant list disabled")); prof_input("/time console off"); prof_input("/time console off"); assert_true(prof_output_exact("Console time display disabled.")); diff --git a/tests/functionaltests/test_muc.c b/tests/functionaltests/test_muc.c index 3dfdbbba..5a117045 100644 --- a/tests/functionaltests/test_muc.c +++ b/tests/functionaltests/test_muc.c @@ -107,9 +107,7 @@ shows_role_and_affiliation_on_join(void **state) prof_input("/join testroom@conference.localhost"); - prof_timeout(60); assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none")); - prof_timeout_reset(); } void From b087f84d955e867b579523a7e4eb33588bfa9b2f Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 26 Sep 2016 00:46:09 +0100 Subject: [PATCH 20/20] Allow setting /occupants properties when no connected --- src/command/cmd_funcs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c8c79e0c..d79b713c 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4212,13 +4212,6 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) gboolean cmd_occupants(ProfWin *window, const char *const command, gchar **args) { - jabber_conn_status_t conn_status = connection_get_status(); - - if (conn_status != JABBER_CONNECTED) { - cons_show("You are not currently connected."); - return TRUE; - } - if (g_strcmp0(args[0], "size") == 0) { if (!args[1]) { cons_bad_cmd_usage(command); @@ -4265,6 +4258,12 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) } } + jabber_conn_status_t conn_status = connection_get_status(); + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + if (window->type != WIN_MUC) { cons_show("Cannot apply setting when not in chat room."); return TRUE;