Ticket #1414: small refactoring before major modifications.

Fixed missed includes.
Fised widget_set_size() declaration.
Moved default widget callback (default_proc()) from dialog.[ch] to widget.[ch].

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-08-16 12:11:59 +04:00
parent 3033429645
commit f2e6817363
7 changed files with 30 additions and 26 deletions

View File

@ -97,27 +97,6 @@ init_widget (Widget *w, int y, int x, int lines, int cols,
w->options = W_WANT_CURSOR;
}
/* Default callback for widgets */
cb_ret_t
default_proc (widget_msg_t msg, int parm)
{
(void) parm;
switch (msg) {
case WIDGET_INIT:
case WIDGET_FOCUS:
case WIDGET_UNFOCUS:
case WIDGET_DRAW:
case WIDGET_DESTROY:
case WIDGET_CURSOR:
case WIDGET_IDLE:
return MSG_HANDLED;
default:
return MSG_NOT_HANDLED;
}
}
/* Clean the dialog area, draw the frame and the title */
void
common_dialog_repaint (struct Dlg_head *h)

View File

@ -177,7 +177,7 @@ void set_idle_proc (Dlg_head *d, int enable);
void dlg_redraw (Dlg_head *h);
void destroy_dlg (Dlg_head *h);
void widget_set_size (Widget *widget, int x1, int y1, int x2, int y2);
void widget_set_size (Widget *widget, int y, int x, int lines, int cols);
void dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse);
@ -187,9 +187,6 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
/* Default callback for dialogs */
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm);
/* Default callback for widgets */
cb_ret_t default_proc (widget_msg_t msg, int parm);
/* Default paint routine for dialogs */
void common_dialog_repaint (struct Dlg_head *h);

View File

@ -29,6 +29,7 @@
#include "../src/tty/mouse.h" /* Gpm_Event */
#include "../src/tty/color.h"
#include "dialog.h"
#include "widget.h" /* default_proc*/
#include "info.h"
#include "dir.h" /* required by panel */
#include "panel.h" /* for the panel structure */

View File

@ -37,6 +37,7 @@
#include "menu.h"
#include "help.h"
#include "dialog.h"
#include "widget.h"
#include "main.h" /* is_right */
#include "strutil.h"

View File

@ -148,6 +148,28 @@ draw_hotkey (Widget *w, const struct hotkey_t hotkey, gboolean focused)
tty_print_string (hotkey.end);
}
/* Default callback for widgets */
cb_ret_t
default_proc (widget_msg_t msg, int parm)
{
(void) parm;
switch (msg) {
case WIDGET_INIT:
case WIDGET_FOCUS:
case WIDGET_UNFOCUS:
case WIDGET_DRAW:
case WIDGET_DESTROY:
case WIDGET_CURSOR:
case WIDGET_IDLE:
return MSG_HANDLED;
default:
return MSG_NOT_HANDLED;
}
}
static int button_event (Gpm_Event *event, void *);
int quote = 0;

View File

@ -162,6 +162,9 @@ typedef struct WGroupbox {
} WGroupbox;
/* Default callback for widgets */
cb_ret_t default_proc (widget_msg_t msg, int parm);
/* Constructors */
WButton *button_new (int y, int x, int action, int flags, const char *text,
bcback callback);

View File

@ -65,6 +65,7 @@ What to do with this?
/* \todo Fix: Namespace pollution: horrible */
#include <config.h>
#include <stdlib.h> /* atoi() */
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
#include <netdb.h> /* struct hostent */
#include <sys/socket.h> /* AF_INET */
@ -1039,7 +1040,7 @@ again:
port = ntohs (port);
addr = malloc (NI_MAXHOST);
addr = g_malloc (NI_MAXHOST);
if (addr == NULL)
ERRNOR (ENOMEM, -1);