1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added muc_window

This commit is contained in:
James Booth 2013-10-06 17:46:22 +01:00
parent 3cc080b06a
commit fc8982e761
5 changed files with 83 additions and 25 deletions

View File

@ -28,6 +28,7 @@ core_sources = \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/console.c src/ui/notifier.c src/ui/notifier.h \
src/ui/windows.c src/ui/windows.h \
src/ui/muc_window.c src/ui/muc_window.h \
src/command/command.h src/command/command.c src/command/history.c \
src/command/history.h src/tools/parser.c \
src/tools/parser.h \

39
src/ui/muc_window.c Normal file
View File

@ -0,0 +1,39 @@
/*
* muc_window.c
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#include <glib.h>
#include "ui/window.h"
gboolean
muc_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg)
{
gboolean handled = FALSE;
if (g_strcmp0(err_msg, "conflict") == 0) {
win_print_line(self, "Nickname already in use.");
win_refresh(self);
handled = TRUE;
}
return handled;
}

33
src/ui/muc_window.h Normal file
View File

@ -0,0 +1,33 @@
/*
* muc_window.h
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MUC_WINDOW_H
#define MUC_WINDOW_H
#include <glib.h>
#include "ui/window.h"
gboolean muc_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg);
#endif

View File

@ -34,14 +34,11 @@
#include "config/theme.h"
#include "ui/window.h"
#include "ui/muc_window.h"
static gboolean _muc_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg);
static gboolean _default_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg);
static void _win_print_time(ProfWin *self, char show_char);
static void _win_print_line(ProfWin *self, const char * const msg, ...);
static void _win_refresh(ProfWin *self);
static void _win_presence_colour_on(ProfWin *self, const char * const presence);
static void _win_presence_colour_off(ProfWin *self, const char * const presence);
static void _win_show_contact(ProfWin *self, PContact contact);
@ -60,8 +57,8 @@ win_create(const char * const title, int cols, win_type_t type)
new_win->type = type;
new_win->print_time = _win_print_time;
new_win->print_line = _win_print_line;
new_win->refresh_win = _win_refresh;
new_win->print_line = win_print_line;
new_win->refresh_win = win_refresh;
new_win->presence_colour_on = _win_presence_colour_on;
new_win->presence_colour_off = _win_presence_colour_off;
new_win->show_contact = _win_show_contact;
@ -69,7 +66,7 @@ win_create(const char * const title, int cols, win_type_t type)
switch (new_win->type)
{
case WIN_MUC:
new_win->handle_error_message = _muc_handle_error_message;
new_win->handle_error_message = muc_handle_error_message;
break;
default:
new_win->handle_error_message = _default_handle_error_message;
@ -102,8 +99,8 @@ _win_print_time(ProfWin* self, char show_char)
g_free(date_fmt);
}
static void
_win_print_line(ProfWin *self, const char * const msg, ...)
void
win_print_line(ProfWin *self, const char * const msg, ...)
{
va_list arg;
va_start(arg, msg);
@ -115,8 +112,8 @@ _win_print_line(ProfWin *self, const char * const msg, ...)
va_end(arg);
}
static void
_win_refresh(ProfWin *self)
void
win_refresh(ProfWin *self)
{
int rows, cols;
getmaxyx(stdscr, rows, cols);
@ -207,20 +204,6 @@ _win_show_contact(ProfWin *self, PContact contact)
_win_presence_colour_off(self, presence);
}
static gboolean
_muc_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg)
{
gboolean handled = FALSE;
if (g_strcmp0(err_msg, "conflict") == 0) {
_win_print_line(self, "Nickname already in use.");
_win_refresh(self);
handled = TRUE;
}
return handled;
}
static gboolean
_default_handle_error_message(ProfWin *self, const char * const from,
const char * const err_msg)

View File

@ -64,5 +64,7 @@ typedef struct prof_win_t {
ProfWin* win_create(const char * const title, int cols, win_type_t type);
void win_free(ProfWin *window);
void win_print_line(ProfWin *self, const char * const msg, ...);
void win_refresh(ProfWin *self);
#endif