Skip to content

Commit

Permalink
Some UI improvements
Browse files Browse the repository at this point in the history
- Bottom tab now only shows indices of active chat windows unless focused
- Always focus Home screen on startup instead of the last loaded conference
- Conference tab names are no longer prefixed with the conference number
- Home and Contact tab names are now capitalized
  • Loading branch information
JFreegman committed Nov 19, 2020
1 parent 41be04a commit 0bf2efb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,6 @@ ToxWindow *new_friendlist(void)
}

ret->help = help;
strcpy(ret->name, "contacts");
strcpy(ret->name, "Contacts");
return ret;
}
6 changes: 1 addition & 5 deletions src/misc_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,7 @@ void set_window_title(ToxWindow *self, const char *title, int len)

char cpy[TOXIC_MAX_NAME_LENGTH + 1];

if (self->type == WINDOW_TYPE_CONFERENCE) { /* keep conferencenumber in title */
snprintf(cpy, sizeof(cpy), "%u %s", self->num, title);
} else {
snprintf(cpy, sizeof(cpy), "%s", title);
}
snprintf(cpy, sizeof(cpy), "%s", title);

if (len > MAX_WINDOW_NAME_LENGTH) {
strcpy(&cpy[MAX_WINDOW_NAME_LENGTH - 3], "...");
Expand Down
2 changes: 1 addition & 1 deletion src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ ToxWindow *new_prompt(void)
ret->onConnectionChange = &prompt_onConnectionChange;
ret->onFriendRequest = &prompt_onFriendRequest;

strcpy(ret->name, "home");
strcpy(ret->name, "Home");

ChatContext *chatwin = calloc(1, sizeof(ChatContext));
StatusBar *stb = calloc(1, sizeof(StatusBar));
Expand Down
1 change: 1 addition & 0 deletions src/toxic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ int main(int argc, char **argv)

pthread_mutex_lock(&Winthread.lock);
print_init_messages(prompt);
set_active_window_index(0);
pthread_mutex_unlock(&Winthread.lock);

cleanup_init_messages();
Expand Down
17 changes: 12 additions & 5 deletions src/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void on_window_resize(void)
}
}

static void draw_window_tab(ToxWindow *toxwin)
static void draw_window_tab(ToxWindow *toxwin, bool active_window)
{
pthread_mutex_lock(&Winthread.lock);

Expand All @@ -505,7 +505,12 @@ static void draw_window_tab(ToxWindow *toxwin)
pthread_mutex_unlock(&Winthread.lock);

clrtoeol();
printw(" [%s]", toxwin->name);

if (active_window || toxwin->index <= 1) {
printw(" [%s]", toxwin->name);
} else {
printw(" [%u]", toxwin->index - 1);
}

pthread_mutex_lock(&Winthread.lock);

Expand Down Expand Up @@ -540,7 +545,9 @@ static void draw_bar(void)
continue;
}

if (i == active_window_index) {
bool active_window = i == active_window_index;

if (active_window) {

#ifdef URXVT_FIX
attron(A_BOLD | COLOR_PAIR(GREEN));
Expand All @@ -550,9 +557,9 @@ static void draw_bar(void)
attron(A_BOLD);
}

draw_window_tab(windows[i]);
draw_window_tab(windows[i], active_window);

if (i == active_window_index) {
if (active_window) {

#ifdef URXVT_FIX
attroff(A_BOLD | COLOR_PAIR(GREEN));
Expand Down

0 comments on commit 0bf2efb

Please sign in to comment.