1
1

* background.c: Leave only code used when WITH_BACKGROUND is

defined. The rest goes ...
* wtools.c: ... here.
Этот коммит содержится в:
Pavel Roskin 2003-10-25 21:54:55 +00:00
родитель 50045218ab
Коммит 00d12acfb3
5 изменённых файлов: 69 добавлений и 59 удалений

Просмотреть файл

@ -1,5 +1,9 @@
2003-10-25 Pavel Roskin <proski@gnu.org>
* background.c: Leave only code used when WITH_BACKGROUND is
defined. The rest goes ...
* wtools.c: ... here.
* background.c: Remove mymsg.
* util.c (msglen): Constify first argument.

Просмотреть файл

@ -22,6 +22,9 @@
/* }}} */
#include <config.h>
#ifdef WITH_BACKGROUND
#include <stdarg.h>
#include <sys/types.h>
#include <errno.h>
@ -42,9 +45,7 @@
* We currenlty only support one way of comunicating the background
* and foreground process by using the socketpair system call
*/
#ifdef WITH_BACKGROUND
# include <sys/socket.h>
#endif
#include <sys/socket.h>
#include "fileopctx.h"
#include "key.h" /* For add_select_channel(), delete_select_channel() */
#include "eregex.h"
@ -54,8 +55,6 @@
/* If true, this is a background process */
int we_are_background = 0;
#ifdef WITH_BACKGROUND
#ifndef HAVE_SOCKETPAIR
int socketpair(int, int, int, int fd[2]);
#endif /* HAVE_SOCKETPAIR */
@ -153,15 +152,6 @@ do_background (struct FileOpContext *ctx, char *info)
}
}
static void
bg_message (enum OperationMode mode, int *flags, char *title,
const char *text)
{
title = g_strdup_printf ("%s %s", _("Background process:"), title);
message (*flags, title, "%s", text);
g_free (title);
}
/* {{{ Parent handlers */
/* Parent/child protocol
@ -397,7 +387,7 @@ parent_call (void *routine, struct FileOpContext *ctx, int argc, ...)
return i;
}
static char *
char *
parent_call_string (void *routine, int argc, ...)
{
va_list ap;
@ -429,44 +419,5 @@ tell_parent (int msg)
{
write (parent_fd, &msg, sizeof (int));
}
#endif /* WITH_BACKGROUND */
/* Show message box, background safe */
void
mc_message (int flags, char *title, const char *text, ...)
{
char *p;
va_list ap;
va_start (ap, text);
p = g_strdup_vprintf (text, ap);
va_end (ap);
#ifdef WITH_BACKGROUND
if (we_are_background) {
if (title == MSG_ERROR)
title = _("Error");
parent_call ((void *) bg_message, NULL, 3, sizeof (flags), &flags,
strlen (title), title, strlen (text), text);
} else
#endif /* WITH_BACKGROUND */
message (flags, title, "%s", text);
g_free (p);
}
/* Show input dialog, background safe */
char *
input_dialog_help (char *header, char *text, char *help, char *def_text)
{
#ifdef WITH_BACKGROUND
if (we_are_background)
return parent_call_string ((void *) real_input_dialog_help, 4,
strlen (header), header, strlen (text),
text, strlen (help), help,
strlen (def_text), def_text);
else
#endif /* WITH_BACKGROUND */
return real_input_dialog_help (header, text, help, def_text);
}

Просмотреть файл

@ -33,6 +33,7 @@ void tell_parent (int msg);
struct FileOpContext;
int do_background (struct FileOpContext *ctx, char *info);
int parent_call (void *routine, struct FileOpContext *ctx, int argc, ...);
char *parent_call_string (void *routine, int argc, ...);
void unregister_task_running (pid_t, int fd);

Просмотреть файл

@ -38,6 +38,7 @@
#include "wtools.h"
#include "key.h" /* For mi_getch() */
#include "complete.h" /* INPUT_COMPLETE_CD */
#include "background.h" /* parent_call */
Listbox *
@ -258,6 +259,43 @@ message (int flags, const char *title, const char *text, ...)
}
/* Show message box from background */
#ifdef WITH_BACKGROUND
static void
bg_message (int dummy, int *flags, char *title, const char *text)
{
title = g_strdup_printf ("%s %s", _("Background process:"), title);
message (*flags, title, "%s", text);
g_free (title);
}
#endif /* WITH_BACKGROUND */
/* Show message box, background safe */
void
mc_message (int flags, char *title, const char *text, ...)
{
char *p;
va_list ap;
va_start (ap, text);
p = g_strdup_vprintf (text, ap);
va_end (ap);
#ifdef WITH_BACKGROUND
if (we_are_background) {
if (title == MSG_ERROR)
title = _("Error");
parent_call ((void *) bg_message, NULL, 3, sizeof (flags), &flags,
strlen (title), title, strlen (text), text);
} else
#endif /* WITH_BACKGROUND */
message (flags, title, "%s", text);
g_free (p);
}
/* {{{ Quick dialog routines */
#define I18N(x) (do_int && *x ? (x = _(x)): x)
@ -395,8 +433,10 @@ int quick_dialog (QuickDialog *qd)
/* {{{ Input routines */
#define INPUT_INDEX 2
char *
real_input_dialog_help (char *header, char *text, char *help,
/* Show dialog, not background safe */
static char *
fg_input_dialog_help (char *header, char *text, char *help,
char *def_text)
{
QuickDialog Quick_input;
@ -473,6 +513,22 @@ real_input_dialog_help (char *header, char *text, char *help,
return 0;
}
/* Show input dialog, background safe */
char *
input_dialog_help (char *header, char *text, char *help, char *def_text)
{
#ifdef WITH_BACKGROUND
if (we_are_background)
return parent_call_string ((void *) fg_input_dialog_help, 4,
strlen (header), header, strlen (text),
text, strlen (help), help,
strlen (def_text), def_text);
else
#endif /* WITH_BACKGROUND */
return fg_input_dialog_help (header, text, help, def_text);
}
/* Show input dialog with default help, background safe */
char *input_dialog (char *header, char *text, char *def_text)
{
return input_dialog_help (header, text, "[Input Line Keys]", def_text);

Просмотреть файл

@ -63,8 +63,6 @@ int quick_dialog_skip (QuickDialog *qd, int nskip);
char *input_dialog (char *header, char *text, char *def_text);
char *input_dialog_help (char *header, char *text, char *help, char *def_text);
char *input_expand_dialog (char *header, char *text, char *def_text);
char *real_input_dialog (char *header, char *text, char *def_text);
char *real_input_dialog_help (char *header, char *text, char *help, char *def_text);
void query_set_sel (int new_sel);