moved functions around...

This commit is contained in:
Jonathan Blandford 1998-12-02 04:33:26 +00:00
parent a065078165
commit b081558a24
8 changed files with 262 additions and 131 deletions

View File

@ -1,3 +1,10 @@
1998-12-01 Jonathan Blandford <jrb@redhat.com>
* Makefile.in: now handles gdialogs*
* gdialogs.h:
* gdialogs.c:Added new files -- takes the place of ../src/filegui.*
1998-12-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gscreen.c (panel_switch_new_display_mode): Destroy the old

View File

@ -33,6 +33,7 @@ GNOMESRCS = \
gpageprop.c \
gpopup.c \
gprop.c \
gdialogs.c \
gscreen.c \
gtools.c \
gtree.c \
@ -55,6 +56,7 @@ GNOMEHDRS = \
gpageprop.h \
gpopup.h \
gprop.h \
gdialogs.h \
gscreen.h \
gtree.h \
gwidget.h
@ -85,7 +87,7 @@ OOBJS = main.o dlg.o screen.o widget.o wtools.o info.o boxes.o \
win.o color.o profile.o user.o ext.o setup.o tree.o \
subshell.o terms.o achown.o fsusage.o mountlist.o \
@XCURSES@ @REGEX_O@ complete.o command.o \
option.o cmd.o utilunix.o xslint.o filegui.o
option.o cmd.o utilunix.o xslint.o gdialogs.o
OBJS = $(LOBJS) $(OOBJS) \
gblist.o \

96
gnome/gdialogs.c Normal file
View File

@ -0,0 +1,96 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* New dialogs... */
#include <gnome.h>
#include "../vfs/vfs.h"
#include "file.h"
#include "panel.h"
static GtkWidget *op_win = NULL;
FileProgressStatus
file_progress_show_source (char *path)
{
g_warning ("Show source!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_show_target (char *path)
{
g_warning ("memo: file_progress_show_target!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_show_deleting (char *path)
{
g_warning ("memo: file_progress_show_deleting!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_show (long done, long total)
{
g_warning ("memo: file_progress_show!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_show_count (long done, long total)
{
g_warning ("memo: file_progress_show_count!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_show_bytes (long done, long total)
{
g_warning ("memo: file_progress_show_bytes!\n");
return FILE_CONT;
}
FileProgressStatus
file_progress_real_query_replace (enum OperationMode mode, char *destname, struct stat *_s_stat, struct stat *_d_stat)
{
g_warning ("memo: file_progress_real_query_replace!\n");
return FILE_CONT;
}
void
file_progress_set_stalled_label (char *stalled_msg)
{
g_warning ("memo: file_progress_set_stalled_label!\n");
}
char *
file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_one, int *do_background)
{
g_warning ("memo: file_mask_dialog!\n");
return NULL;
}
void
create_op_win (FileOperation op, int with_eta)
{
if (op_win == NULL) {
op_win = gnome_dialog_new ("Op Win -- change this title", GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (op_win)->vbox), gtk_label_new ("borp\n"), FALSE, FALSE, 0);
}
gtk_widget_show(GTK_WIDGET(op_win));
g_print ("create_op_win\n");
}
void
destroy_op_win (void)
{
if (op_win) {
g_print ("hiding in destroy_op_win\n");
gtk_widget_hide (op_win);
}
}
void
fmd_init_i18n()
{
/* unneccessary func */
}

18
gnome/gdialogs.h Normal file
View File

@ -0,0 +1,18 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* New dialogs... */
#include "../vfs/vfs.h"
#include "file.h"
#include "panel.h"
FileProgressStatus file_progress_show_source (char *path);
FileProgressStatus file_progress_show_target (char *path);
FileProgressStatus file_progress_show_deleting (char *path);
FileProgressStatus file_progress_show (long done, long total);
FileProgressStatus file_progress_show_count (long done, long total);
FileProgressStatus file_progress_show_bytes (long done, long total);
FileProgressStatus file_progress_real_query_replace (enum OperationMode mode, char *destname, struct stat *_s_stat, struct stat *_d_stat);
void file_progress_set_stalled_label (char *stalled_msg);
char *file_mask_dialog (FileOperation operation, char *text, char *def_text, int only_one, int *do_background);
void create_op_win (FileOperation op, int with_eta);
void destroy_op_win (void);
void fmd_init_i18n();

View File

@ -1,3 +1,7 @@
1998-12-01 Jonathan Blandford <jrb@redhat.com>
* file.c (panel_operate_generate_prompt): moved from filegui.c
1998-11-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
* panel.h (WPanel): Added the missing tree/pane/view_table fields

View File

@ -1958,3 +1958,133 @@ query_replace (char *destname, struct stat *_s_stat, struct stat *_d_stat)
Local variables:
end:
*/
/*
* This array introduced to avoid translation problems. The former (op_names)
* is assumed to be nouns, suitable in dialog box titles; this one should
* contain whatever is used in prompt itself (i.e. in russian, it's verb).
* Notice first symbol - it is to fool gettext and force these strings to
* be different for it. First symbol is skipped while building a prompt.
* (I don't use spaces around the words, because someday they could be
* dropped, when widgets get smarter)
*/
static char *op_names1 [] = { N_("1Copy"), N_("1Move"), N_("1Delete") };
#define FMD_XLEN 64
int fmd_xlen = FMD_XLEN, fmd_i18n_flag = 0;
/*
* These are formats for building a prompt. Parts encoded as follows:
* %o - operation from op_names1
* %f - file/files or files/directories, as appropriate
* %m - "with source mask" or question mark for delete
* %s - source name (truncated)
* %d - number of marked files
*/
static char* one_format = N_("%o %f \"%s\"%m");
static char* many_format = N_("%o %d %f%m");
static char* prompt_parts [] =
{
N_("file"), N_("files"), N_("directory"), N_("directories"),
N_("files/directories"), N_(" with source mask:")
};
char*
panel_operate_generate_prompt (char* cmd_buf, WPanel* panel, int operation, int only_one,
struct stat* src_stat)
{
register char *sp, *cp;
register int i;
char format_string [200];
char *dp = format_string;
char* source = NULL;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
if (!i18n_flag)
{
if (!fmd_i18n_flag)
fmd_init_i18n(); /* to get proper fmd_xlen */
for (i = sizeof (op_names1) / sizeof (op_names1 [0]); i--;)
op_names1 [i] = _(op_names1 [i]);
for (i = sizeof (prompt_parts) / sizeof (prompt_parts [0]); i--;)
prompt_parts [i] = _(prompt_parts [i]);
one_format = _(one_format);
many_format = _(many_format);
i18n_flag = 1;
}
#endif /* ENABLE_NLS */
sp = only_one ? one_format : many_format;
if (only_one)
source = panel_get_file (panel, src_stat);
while (*sp)
{
switch (*sp)
{
case '%':
cp = NULL;
switch (sp[1])
{
case 'o':
cp = op_names1 [operation] + 1;
break;
case 'm':
cp = operation == OP_DELETE ? "?" : prompt_parts [5];
break;
case 'f':
if (only_one)
{
cp = S_ISDIR (src_stat->st_mode) ?
prompt_parts [2] : prompt_parts [0];
}
else
{
cp = (panel->marked == panel->dirs_marked)
? prompt_parts [3]
: (panel->dirs_marked ? prompt_parts [4]
: prompt_parts [1]);
}
break;
default:
*dp++ = *sp++;
}
if (cp)
{
sp += 2;
while (*cp)
*dp++ = *cp++;
}
break;
default:
*dp++ = *sp++;
}
}
*dp = '\0';
if (only_one)
{
i = fmd_xlen - strlen(format_string) - 4;
sprintf (cmd_buf, format_string, name_trunc (source, i));
}
else
{
sprintf (cmd_buf, format_string, panel->marked);
i = strlen (cmd_buf) + 6 - fmd_xlen;
if (i > 0)
{
fmd_xlen += i;
fmd_init_i18n(); /* to recalculate positions of child widgets */
}
}
return source;
}

View File

@ -692,7 +692,7 @@ file_progress_set_stalled_label (char *stalled_msg)
#define FMDY 13
#define FMD_XLEN 64
static int fmd_xlen = FMD_XLEN, fmd_i18n_flag = 0;
extern int fmd_xlen, fmd_i18n_flag;
static QuickWidget fmd_widgets [] = {
#define FMCB0 FMDC
@ -749,7 +749,7 @@ static QuickWidget fmd_widgets [] = {
&dive_into_subdirs, 0, XV_WLAY_BELOWOF, "dive" },
{ 0 } };
static void
void
fmd_init_i18n()
{
#ifdef ENABLE_NLS
@ -924,130 +924,3 @@ ask_file_mask:
*do_background = 1;
return dest_dir;
}
/*
* This array introduced to avoid translation problems. The former (op_names)
* is assumed to be nouns, suitable in dialog box titles; this one should
* contain whatever is used in prompt itself (i.e. in russian, it's verb).
* Notice first symbol - it is to fool gettext and force these strings to
* be different for it. First symbol is skipped while building a prompt.
* (I don't use spaces around the words, because someday they could be
* dropped, when widgets get smarter)
*/
static char *op_names1 [] = { N_("1Copy"), N_("1Move"), N_("1Delete") };
/*
* These are formats for building a prompt. Parts encoded as follows:
* %o - operation from op_names1
* %f - file/files or files/directories, as appropriate
* %m - "with source mask" or question mark for delete
* %s - source name (truncated)
* %d - number of marked files
*/
static char* one_format = N_("%o %f \"%s\"%m");
static char* many_format = N_("%o %d %f%m");
static char* prompt_parts [] =
{
N_("file"), N_("files"), N_("directory"), N_("directories"),
N_("files/directories"), N_(" with source mask:")
};
char*
panel_operate_generate_prompt (char* cmd_buf, WPanel* panel, int operation, int only_one,
struct stat* src_stat)
{
register char *sp, *cp;
register int i;
char format_string [200];
char *dp = format_string;
char* source = NULL;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
if (!i18n_flag)
{
if (!fmd_i18n_flag)
fmd_init_i18n(); /* to get proper fmd_xlen */
for (i = sizeof (op_names1) / sizeof (op_names1 [0]); i--;)
op_names1 [i] = _(op_names1 [i]);
for (i = sizeof (prompt_parts) / sizeof (prompt_parts [0]); i--;)
prompt_parts [i] = _(prompt_parts [i]);
one_format = _(one_format);
many_format = _(many_format);
i18n_flag = 1;
}
#endif /* ENABLE_NLS */
sp = only_one ? one_format : many_format;
if (only_one)
source = panel_get_file (panel, src_stat);
while (*sp)
{
switch (*sp)
{
case '%':
cp = NULL;
switch (sp[1])
{
case 'o':
cp = op_names1 [operation] + 1;
break;
case 'm':
cp = operation == OP_DELETE ? "?" : prompt_parts [5];
break;
case 'f':
if (only_one)
{
cp = S_ISDIR (src_stat->st_mode) ?
prompt_parts [2] : prompt_parts [0];
}
else
{
cp = (panel->marked == panel->dirs_marked)
? prompt_parts [3]
: (panel->dirs_marked ? prompt_parts [4]
: prompt_parts [1]);
}
break;
default:
*dp++ = *sp++;
}
if (cp)
{
sp += 2;
while (*cp)
*dp++ = *cp++;
}
break;
default:
*dp++ = *sp++;
}
}
*dp = '\0';
if (only_one)
{
i = fmd_xlen - strlen(format_string) - 4;
sprintf (cmd_buf, format_string, name_trunc (source, i));
}
else
{
sprintf (cmd_buf, format_string, panel->marked);
i = strlen (cmd_buf) + 6 - fmd_xlen;
if (i > 0)
{
fmd_xlen += i;
fmd_init_i18n(); /* to recalculate positions of child widgets */
}
}
return source;
}

View File

@ -17,6 +17,7 @@ FileProgressStatus file_progress_real_query_replace (enum OperationMode mode,
struct stat *_d_stat);
void file_progress_set_stalled_label (char *stalled_msg);
void fmd_init_i18n();
/*
* Shared variables used to pass information from the file.c module to