mc/gnome/glayout.c

290 lines
5.8 KiB
C
Raw Normal View History

#include <config.h>
1998-02-27 07:54:42 +03:00
#include "x.h"
#include <stdio.h>
#include <sys/stat.h>
#include "dir.h"
#include "panel.h"
#include "gscreen.h"
#include "main.h"
1998-02-27 07:54:42 +03:00
#include "cmd.h"
#include "boxes.h"
1998-02-27 07:54:42 +03:00
#define UNDEFINED_INDEX -1
1998-02-27 07:54:42 +03:00
1998-03-01 04:29:42 +03:00
GList *containers = 0;
1998-02-27 07:54:42 +03:00
int output_lines = 0;
int command_prompt = 1;
int keybar_visible = 1;
int message_visible = 1;
int xterm_hintbar = 0;
PanelContainer *current_panel_ptr, *other_panel_ptr;
WPanel *
get_current_panel (void)
{
return current_panel_ptr->panel;
}
WPanel *
get_other_panel (void)
{
if (other_panel_ptr)
return other_panel_ptr->panel;
else
return NULL;
}
/* FIXME: we probably want to get rid of this code */
int
get_current_index (void)
{
GList *p;
int i;
for (i = 0, p = containers; p; p = p->next, i++){
if (p->data == current_panel_ptr)
return i;
}
printf ("FATAL: current panel is not in the list\n");
g_assert_not_reached ();
return -1; /* keep -Wall happy */
1998-02-27 07:54:42 +03:00
}
int
get_other_index (void)
{
GList *p;
int i;
for (i = 0, p = containers; p; p = p->next, i++){
if (p->data == other_panel_ptr)
return i;
}
return UNDEFINED_INDEX;
1998-02-27 07:54:42 +03:00
}
void
set_current_panel (int index)
{
GList *p;
for (p = containers; index; p = p->next)
index--;
current_panel_ptr = p->data;
}
1998-03-01 04:29:42 +03:00
void
set_new_current_panel (WPanel *panel)
{
GList *p;
other_panel_ptr = current_panel_ptr;
for (p = containers; p; p = p->next){
if (((PanelContainer *)p->data)->panel == panel){
printf ("Setting current panel to %p\n", p);
current_panel_ptr = p->data;
}
}
}
1998-02-27 07:54:42 +03:00
void
set_hintbar (char *str)
{
gtk_label_set (GTK_LABEL (current_panel_ptr->panel->status), str);
}
void
print_vfs_message (char *msg, ...)
1998-02-27 07:54:42 +03:00
{
va_list ap;
char str [256];
1998-02-27 07:54:42 +03:00
va_start(ap, msg);
vsprintf(str, msg, ap);
va_end(ap);
if (midnight_shutdown)
return;
set_hintbar(str);
1998-02-27 07:54:42 +03:00
}
void
rotate_dash (void)
{
}
int
get_current_type (void)
{
return view_listing;
1998-02-27 07:54:42 +03:00
}
int
get_other_type (void)
{
return other_panel_ptr ? view_listing : view_nothing;
1998-02-27 07:54:42 +03:00
}
int
get_display_type (int index)
{
GList *p;
if (index == UNDEFINED_INDEX)
return -1;
1998-02-27 07:54:42 +03:00
p = g_list_nth (containers, index);
if (p)
return ((PanelContainer *)p->data)->panel->list_type;
else
return -1;
}
void
use_dash (int ignore)
{
/* we dont care in the gnome edition */
}
Widget *
get_panel_widget (int index)
{
GList *p;
for (p = containers; index; p = p->next)
index--;
return (Widget *) ((PanelContainer *)p->data)->panel;
}
void
1998-03-07 03:05:06 +03:00
gnome_listing_cmd (GtkWidget *widget, WPanel *panel)
1998-02-27 07:54:42 +03:00
{
1998-03-07 03:05:06 +03:00
GtkAllocation *alloc = &GTK_WIDGET (panel->list)->allocation;
1998-02-27 07:54:42 +03:00
int view_type, use_msformat;
char *user, *status;
view_type = display_box (panel, &user, &status, &use_msformat, get_current_index ());
1998-02-27 07:54:42 +03:00
if (view_type == -1)
return;
1998-03-07 03:05:06 +03:00
configure_panel_listing (panel, view_type, use_msformat, user, status);
1998-02-27 07:54:42 +03:00
}
void configure_box (void);
1998-03-07 03:05:06 +03:00
1998-02-27 07:54:42 +03:00
GnomeUIInfo gnome_panel_filemenu [] = {
{ GNOME_APP_UI_ITEM, "Network link...", NULL, netlink_cmd },
{ GNOME_APP_UI_ITEM, "FTP link...", NULL, ftplink_cmd },
{ GNOME_APP_UI_ITEM, "Display mode...", NULL, gnome_listing_cmd },
{ GNOME_APP_UI_ITEM, "Sort order...", NULL, sort_cmd },
{ GNOME_APP_UI_ITEM, "Filter...", NULL, filter_cmd },
{ GNOME_APP_UI_ITEM, "Rescan", NULL, reread_cmd },
1998-02-27 07:54:42 +03:00
{ GNOME_APP_UI_ITEM, "Find", NULL, find_cmd },
{ GNOME_APP_UI_ITEM, "Hotlist", NULL, quick_chdir_cmd },
#ifdef USE_VFS
{ GNOME_APP_UI_ITEM, "Active VFS", NULL, reselect_vfs },
#endif
{ GNOME_APP_UI_ITEM, "Confirmation", NULL, confirm_box },
1998-02-27 07:54:42 +03:00
{ GNOME_APP_UI_ITEM, "Options", NULL, configure_box },
{ GNOME_APP_UI_ITEM, "Virtual FS", NULL, configure_vfs },
{ GNOME_APP_UI_ITEM, "Save setup", NULL, save_setup_cmd },
{ GNOME_APP_UI_ITEM, "Mkdir", NULL, mkdir_cmd },
1998-02-27 07:54:42 +03:00
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
GnomeUIInfo gnome_panel_menu [] = {
{ GNOME_APP_UI_SUBTREE, "This is a temporal menu, it will go away", NULL, &gnome_panel_filemenu },
1998-02-27 07:54:42 +03:00
{ GNOME_APP_UI_ENDOFINFO, 0, 0 }
};
void
gnome_init_panels ()
{
current_panel_ptr = NULL;
other_panel_ptr = NULL;
}
static void
panel_enter_event (GtkWidget *widget, GdkEvent *event, WPanel *panel)
{
/* Avoid unnecessary code execution */
if (get_current_panel () == panel)
return;
set_new_current_panel (panel);
dlg_select_widget (panel->widget.parent, panel);
send_message (panel->widget.parent, (Widget *) panel, WIDGET_FOCUS, 0);
}
1998-03-01 04:29:42 +03:00
WPanel *
create_container (Dlg_head *h, char *name)
1998-02-27 07:54:42 +03:00
{
PanelContainer *container = g_new (PanelContainer, 1);
WPanel *panel;
1998-03-01 04:29:42 +03:00
GtkWidget *app, *vbox;
1998-02-27 07:54:42 +03:00
int slot;
container->splitted = 0;
app = gnome_app_new ("gmc", name);
gtk_widget_set_usize (GTK_WIDGET (app), 400, 300);
1998-03-07 03:05:06 +03:00
panel = panel_new (name);
1998-02-27 07:54:42 +03:00
vbox = gtk_vbox_new (0, 0);
gtk_widget_show (vbox);
gnome_app_set_contents (GNOME_APP (app), vbox);
1998-03-07 03:05:06 +03:00
gnome_app_create_menus_with_data (GNOME_APP (app), gnome_panel_menu, panel);
1998-02-27 07:54:42 +03:00
gtk_widget_show (app);
gtk_signal_connect (GTK_OBJECT (app),
"enter_notify_event",
GTK_SIGNAL_FUNC (panel_enter_event),
panel);
1998-03-01 04:29:42 +03:00
/* Ultra nasty hack follows:
* I am setting the panel->widget.wdata value here before the
* panel X stuff gets created in the INIT message section of the
* widget. There I put a pointer to the vbox where the panel
* should pack itself
*/
panel->widget.wdata = (widget_data) vbox;
1998-02-27 07:54:42 +03:00
container->panel = panel;
1998-03-01 04:29:42 +03:00
if (!containers){
containers = g_list_alloc ();
containers->data = container;
} else
containers = g_list_append (containers, container);
1998-02-27 07:54:42 +03:00
if (!current_panel_ptr){
current_panel_ptr = container;
} else if (!other_panel_ptr)
other_panel_ptr = container;
1998-03-01 04:29:42 +03:00
1998-02-27 07:54:42 +03:00
bind_gtk_keys (GTK_WIDGET (app), h);
1998-03-01 04:29:42 +03:00
return panel;
}
void
new_panel_at (char *dir)
{
WPanel *panel;
Dlg_head *h = current_panel_ptr->panel->widget.parent;
1998-02-27 07:54:42 +03:00
1998-03-01 04:29:42 +03:00
mc_chdir (dir);
panel = create_container (h, "Other");
add_widget (h, panel);
1998-02-27 07:54:42 +03:00
1998-03-01 04:29:42 +03:00
set_new_current_panel (panel);
1998-02-27 07:54:42 +03:00
}
void
setup_panels (void)
{
load_hint ();
}