1998-02-27 07:54:42 +03:00
|
|
|
/*
|
|
|
|
* Midnight Commander -- GNOME frontend
|
|
|
|
*
|
1998-05-15 09:43:31 +04:00
|
|
|
* Copyright (C) 1997, 1998 The Free Software Foundation
|
1998-02-27 07:54:42 +03:00
|
|
|
*
|
|
|
|
* Author: Miguel de Icaza (miguel@gnu.org)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
1998-12-07 05:36:47 +03:00
|
|
|
#define WANT_WIDGETS /* bleah */
|
1998-05-26 04:53:24 +04:00
|
|
|
#include "tty.h" /* for KEY_BACKSPACE */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "x.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "panel.h"
|
1998-03-04 09:28:35 +03:00
|
|
|
#include "gscreen.h"
|
1999-02-11 00:03:04 +03:00
|
|
|
#include "gcmd.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
#include "gcorba.h"
|
|
|
|
#include "gdesktop.h"
|
|
|
|
#include "gsession.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "command.h"
|
1998-04-17 04:59:58 +04:00
|
|
|
#include "cmd.h"
|
1999-04-02 04:29:05 +04:00
|
|
|
#include <gdk/gdkx.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
GdkColorContext *mc_cc;
|
|
|
|
|
1998-12-29 19:52:49 +03:00
|
|
|
#define MAX_COLOR_PAIRS 40
|
1998-02-27 07:54:42 +03:00
|
|
|
struct gmc_color_pairs_s gmc_color_pairs [MAX_COLOR_PAIRS];
|
|
|
|
|
|
|
|
char *default_edition_colors =
|
1998-03-10 07:45:35 +03:00
|
|
|
"normal=black:"
|
1998-05-08 06:25:00 +04:00
|
|
|
"selected=white,darkblue:"
|
1998-03-12 06:29:45 +03:00
|
|
|
"viewunderline=brightred,blue:"
|
1998-02-27 07:54:42 +03:00
|
|
|
"directory=blue:"
|
1998-05-08 06:25:00 +04:00
|
|
|
"markselect=yellow,darkblue:"
|
1998-03-14 03:42:23 +03:00
|
|
|
"marked=yellow,seagreen:"
|
1998-03-10 23:14:17 +03:00
|
|
|
"execute=slateblue:"
|
|
|
|
"link=green:"
|
1998-12-29 19:52:49 +03:00
|
|
|
"stalledlink=brightred:"
|
1998-02-27 07:54:42 +03:00
|
|
|
"device=magenta:"
|
|
|
|
"core=red:"
|
1998-03-14 03:42:23 +03:00
|
|
|
"menuhotsel=cyan,black:"
|
1998-05-08 06:25:00 +04:00
|
|
|
"errors=white,red:"
|
|
|
|
"reverse=black,lightcyan:"
|
1998-02-27 07:54:42 +03:00
|
|
|
"special=black";
|
|
|
|
|
1998-10-14 06:56:18 +04:00
|
|
|
int dialog_panel_callback (struct Dlg_head *h, int id, int msg);
|
|
|
|
|
1998-04-17 04:21:53 +04:00
|
|
|
/* The Dlg_head for the whole desktop */
|
|
|
|
Dlg_head *desktop_dlg;
|
|
|
|
|
1999-02-24 05:26:11 +03:00
|
|
|
/* Session client */
|
|
|
|
GnomeClient *session_client;
|
|
|
|
|
1999-02-24 04:48:55 +03:00
|
|
|
/* Used during argument processing */
|
|
|
|
extern int finish_program;
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
/* Whether the gmc server was present or not */
|
|
|
|
int corba_have_server = FALSE;
|
|
|
|
|
1998-04-24 22:52:40 +04:00
|
|
|
/* This is only used by the editor, so we provide a dummy implementation */
|
|
|
|
void
|
|
|
|
try_alloc_color_pair (char *str, char *str2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
init_pair (int index, GdkColor *fore, GdkColor *back)
|
|
|
|
{
|
|
|
|
if (index < 0 || index > MAX_COLOR_PAIRS){
|
|
|
|
printf ("init_pair called with invalid index\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
gmc_color_pairs [index].fore = fore;
|
|
|
|
gmc_color_pairs [index].back = back;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
get_color (char *cpp, GdkColor **colp)
|
|
|
|
{
|
|
|
|
GdkColor *new_color;
|
|
|
|
gint status;
|
|
|
|
|
|
|
|
new_color = g_new (GdkColor, 1);
|
|
|
|
gdk_color_parse (cpp, new_color);
|
1998-03-06 22:42:57 +03:00
|
|
|
new_color->pixel = 0;
|
|
|
|
status = 0;
|
|
|
|
gdk_color_context_get_pixels (mc_cc, &new_color->red, &new_color->green, &new_color->blue, 1,
|
|
|
|
&new_color->pixel, &status);
|
1998-02-27 07:54:42 +03:00
|
|
|
*colp = new_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gmc_color_init (void)
|
|
|
|
{
|
|
|
|
mc_cc = gdk_color_context_new (gtk_widget_get_default_visual (),
|
|
|
|
gtk_widget_get_default_colormap ());
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
xtoolkit_init (int *argc, char *argv [])
|
|
|
|
{
|
|
|
|
gmc_color_init ();
|
1998-03-10 04:50:55 +03:00
|
|
|
return 0;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
void
|
|
|
|
interactive_display (char *filename, char *node)
|
|
|
|
{
|
|
|
|
/* FIXME: Implement gnome version */
|
|
|
|
}
|
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
void
|
1998-12-02 08:18:20 +03:00
|
|
|
beep (void)
|
|
|
|
{
|
|
|
|
gdk_beep ();
|
|
|
|
}
|
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
void
|
1998-02-27 07:54:42 +03:00
|
|
|
xtoolkit_end (void)
|
|
|
|
{
|
1998-12-07 00:01:30 +03:00
|
|
|
/* Do nothing */
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
/*
|
|
|
|
* Keystroke event handler for all of the Gtk widgets created by
|
|
|
|
* the GNOME Midnight Commander. A special case is handled at
|
|
|
|
* the top
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
int
|
|
|
|
dialog_key_pressed (GtkWidget *win, GdkEventKey *event, Dlg_head *h)
|
|
|
|
{
|
1998-10-20 09:37:45 +04:00
|
|
|
GtkWidget *w;
|
1998-02-27 07:54:42 +03:00
|
|
|
static int on_escape;
|
|
|
|
int key;
|
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
/*
|
|
|
|
* Find out if the focused widget is an IconList and
|
|
|
|
* if so, check if it has a currently focused item is
|
|
|
|
* on editing mode as we do not want to handle key
|
|
|
|
* events while the icon name is being edited.
|
|
|
|
*/
|
|
|
|
w = win;
|
|
|
|
while (w && (GTK_IS_CONTAINER (w) && !GNOME_IS_ICON_LIST (w)))
|
|
|
|
w = GTK_CONTAINER (w)->focus_child;
|
|
|
|
|
|
|
|
if (w && GNOME_IS_ICON_LIST (w)){
|
|
|
|
GnomeCanvas *c = GNOME_CANVAS (w);
|
|
|
|
|
1998-10-22 03:11:24 +04:00
|
|
|
if (c->focused_item && GNOME_IS_ICON_TEXT_ITEM (c->focused_item)){
|
1998-10-20 09:37:45 +04:00
|
|
|
GnomeIconTextItem *i = GNOME_ICON_TEXT_ITEM (c->focused_item);
|
|
|
|
|
|
|
|
if (i->editing)
|
|
|
|
return FALSE;
|
1999-02-13 23:12:35 +03:00
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
key = translate_gdk_keysym_to_curses (event);
|
|
|
|
if (key == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!on_escape){
|
|
|
|
if (key == 27){
|
|
|
|
on_escape = 1;
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (win), "key_press_event");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (key != 27){
|
|
|
|
if (key >= '0' && key <= '9')
|
|
|
|
key = KEY_F(key - '0');
|
|
|
|
else
|
|
|
|
key = ALT (key);
|
|
|
|
|
|
|
|
if (key == ALT('<'))
|
|
|
|
key = KEY_HOME;
|
|
|
|
if (key == ALT('>'))
|
|
|
|
key = KEY_END;
|
|
|
|
}
|
|
|
|
on_escape = 0;
|
|
|
|
}
|
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
if (dlg_key_event (h, key)){
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (win), "key_press_event");
|
1998-09-26 00:00:42 +04:00
|
|
|
return TRUE;
|
1998-10-20 09:37:45 +04:00
|
|
|
} else
|
1998-09-26 00:00:42 +04:00
|
|
|
return FALSE;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bind_gtk_keys (GtkWidget *w, Dlg_head *h)
|
|
|
|
{
|
|
|
|
gtk_signal_connect (GTK_OBJECT (w),
|
|
|
|
"key_press_event",
|
|
|
|
GTK_SIGNAL_FUNC (dialog_key_pressed),
|
|
|
|
h);
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_data
|
|
|
|
xtoolkit_create_dialog (Dlg_head *h, int flags)
|
|
|
|
{
|
|
|
|
GtkWidget *win, *ted;
|
|
|
|
|
1998-03-15 02:20:51 +03:00
|
|
|
if (!(flags & DLG_NO_TOPLEVEL)){
|
|
|
|
if (flags & DLG_GNOME_APP)
|
|
|
|
win = gnome_app_new ("mc", h->name);
|
1998-10-21 22:05:08 +04:00
|
|
|
else {
|
1998-03-15 02:20:51 +03:00
|
|
|
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
1998-12-01 08:15:12 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_MOUSE);
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
1998-03-15 02:20:51 +03:00
|
|
|
} else
|
|
|
|
win = 0;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
h->grided = flags;
|
1998-03-07 06:02:01 +03:00
|
|
|
h->idle_fn_tag = -1;
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!(flags & DLG_NO_TED)){
|
1998-03-04 09:28:35 +03:00
|
|
|
ted = gtk_ted_new_layout (h->name, LIBDIR "/layout");
|
1998-02-27 07:54:42 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (win), ted);
|
|
|
|
gtk_widget_show (ted);
|
|
|
|
|
|
|
|
bind_gtk_keys (GTK_WIDGET (ted), h);
|
|
|
|
}
|
1998-10-14 06:56:18 +04:00
|
|
|
if (win){
|
1998-10-20 05:52:16 +04:00
|
|
|
bind_gtk_keys (GTK_WIDGET (win), h);
|
1998-10-14 06:56:18 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
return (widget_data) win;
|
|
|
|
}
|
|
|
|
|
1998-03-15 02:20:51 +03:00
|
|
|
/* Used to bind a window for an already created Dlg_head. This is
|
|
|
|
* used together with the DLG_NO_TOPLEVEL: the dialog is created
|
|
|
|
* with the DLG_NO_TOPLEVEL and later, when the window is created
|
|
|
|
* it is assigned with this routine
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
x_dlg_set_window (Dlg_head *h, GtkWidget *win)
|
|
|
|
{
|
|
|
|
h->wdata = (widget_data) win;
|
|
|
|
bind_gtk_keys (GTK_WIDGET (win), h);
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
x_set_dialog_title (Dlg_head *h, char *title)
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (h->wdata), title);
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_data
|
|
|
|
xtoolkit_get_main_dialog (Dlg_head *h)
|
|
|
|
{
|
|
|
|
GtkWidget *win;
|
|
|
|
|
|
|
|
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
return (widget_data) win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates the containers */
|
|
|
|
widget_data
|
|
|
|
x_create_panel_container (int which)
|
|
|
|
{
|
|
|
|
GtkWidget *win;
|
|
|
|
|
|
|
|
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
return (widget_data) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_panel_container_show (widget_data wdata)
|
|
|
|
{
|
|
|
|
gtk_widget_show (GTK_WIDGET (wdata));
|
|
|
|
}
|
|
|
|
|
1998-03-02 23:27:08 +03:00
|
|
|
void
|
|
|
|
x_add_widget (Dlg_head *h, Widget_Item *w)
|
|
|
|
{
|
|
|
|
if (!(h->grided & DLG_NO_TED)){
|
|
|
|
GtkTed *ted = GTK_TED (GTK_BIN (h->wdata)->child);
|
|
|
|
|
|
|
|
gtk_ted_add (ted, GTK_WIDGET (w->widget->wdata), w->widget->tkname);
|
|
|
|
bind_gtk_keys (GTK_WIDGET (w->widget->wdata), h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-15 02:20:51 +03:00
|
|
|
static int
|
1998-03-19 07:51:17 +03:00
|
|
|
gnome_dlg_send_destroy (GtkWidget *widget, GdkEvent *event, Dlg_head *h)
|
1998-03-15 02:20:51 +03:00
|
|
|
{
|
1998-04-08 03:45:27 +04:00
|
|
|
gtk_widget_hide (GTK_WIDGET (h->wdata));
|
1998-03-15 02:20:51 +03:00
|
|
|
h->ret_value = B_CANCEL;
|
|
|
|
dlg_stop (h);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
x_init_dlg (Dlg_head *h)
|
|
|
|
{
|
|
|
|
if (!(h->grided & DLG_NO_TED)){
|
|
|
|
GtkTed *ted = GTK_TED (GTK_BIN (h->wdata)->child);
|
|
|
|
Widget_Item *p, *first;
|
|
|
|
|
|
|
|
first = p = h->current;
|
|
|
|
do {
|
|
|
|
gtk_ted_add (ted, GTK_WIDGET (p->widget->wdata), p->widget->tkname);
|
|
|
|
bind_gtk_keys (GTK_WIDGET (p->widget->wdata), h);
|
|
|
|
p = p->next;
|
|
|
|
} while (p != first);
|
|
|
|
gtk_ted_prepare (ted);
|
1998-04-08 02:27:47 +04:00
|
|
|
|
1998-04-08 22:50:24 +04:00
|
|
|
if (!ted->need_gui){
|
|
|
|
gtk_grab_add (GTK_WIDGET (ted));
|
1998-04-08 03:45:27 +04:00
|
|
|
gtk_window_set_policy (GTK_WINDOW (h->wdata), 0, 0, 0);
|
1998-04-08 22:50:24 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
gtk_widget_show (GTK_WIDGET (h->wdata));
|
|
|
|
}
|
1998-03-15 02:20:51 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (h->wdata), "delete_event",
|
|
|
|
GTK_SIGNAL_FUNC (gnome_dlg_send_destroy), h);
|
1998-03-10 09:31:01 +03:00
|
|
|
x_focus_widget (h->current);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-04-08 03:45:27 +04:00
|
|
|
/*
|
|
|
|
* This function is invoked when the dialog is started to be
|
|
|
|
* destroyed, before any widgets have been destroyed.
|
|
|
|
*
|
|
|
|
* We only hide the toplevel Gtk widget to avoid the flickering
|
|
|
|
* of the destruction process
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
x_destroy_dlg_start (Dlg_head *h)
|
|
|
|
{
|
|
|
|
gtk_widget_hide (GTK_WIDGET (h->wdata));
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-04-08 03:45:27 +04:00
|
|
|
/*
|
|
|
|
* Called when the Dlg_head has been destroyed. This only cleans
|
|
|
|
* up/releases the frontend resources
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
x_destroy_dlg (Dlg_head *h)
|
|
|
|
{
|
1998-03-05 07:53:47 +03:00
|
|
|
if (!(h->grided & DLG_NO_TED))
|
|
|
|
gtk_grab_remove (GTK_WIDGET (GTK_BIN (h->wdata)->child));
|
1998-04-16 06:45:53 +04:00
|
|
|
if (h->wdata){
|
|
|
|
gtk_widget_destroy (GTK_WIDGET(h->wdata));
|
|
|
|
h->wdata = 0;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtkrundlg_event (Dlg_head *h)
|
|
|
|
{
|
|
|
|
gtk_main ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edition_pre_exec ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
edition_post_exec ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
done_screen ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setup_sigwinch ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-03-07 06:02:01 +03:00
|
|
|
void
|
|
|
|
x_flush_events (void)
|
|
|
|
{
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gnome_idle_handler (gpointer data)
|
|
|
|
{
|
|
|
|
Dlg_head *h = data;
|
|
|
|
|
1998-04-08 03:45:27 +04:00
|
|
|
if (h->send_idle_msg){
|
|
|
|
(*h->callback)(h, 0, DLG_IDLE);
|
|
|
|
return TRUE;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
1998-03-07 06:02:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn on and off the idle message sending */
|
|
|
|
void
|
|
|
|
x_set_idle (Dlg_head *h, int enable_idle)
|
|
|
|
{
|
|
|
|
if (enable_idle){
|
|
|
|
if (h->idle_fn_tag != -1)
|
|
|
|
return;
|
|
|
|
h->idle_fn_tag = gtk_idle_add (gnome_idle_handler, h);
|
|
|
|
} else {
|
|
|
|
if (h->idle_fn_tag == -1)
|
|
|
|
return;
|
|
|
|
gtk_idle_remove (h->idle_fn_tag);
|
|
|
|
h->idle_fn_tag = -1;
|
1998-04-08 03:45:27 +04:00
|
|
|
gnome_idle_handler (h);
|
1998-03-07 06:02:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-13 08:18:52 +03:00
|
|
|
int
|
|
|
|
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
|
|
|
|
{
|
|
|
|
WInput *in;
|
1998-04-28 08:29:19 +04:00
|
|
|
Widget_Item *dh;
|
|
|
|
void *current_widget; /* The current widget */
|
1998-03-13 08:18:52 +03:00
|
|
|
|
|
|
|
if (msg == DLG_KEY && id == '\n'){
|
1998-03-24 08:25:56 +03:00
|
|
|
current_widget = (void *) h->current->widget;
|
|
|
|
|
1998-04-28 08:29:19 +04:00
|
|
|
if (is_a_panel (current_widget))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
dh = h->current;
|
|
|
|
do {
|
|
|
|
if (is_a_panel (dh->widget)){
|
|
|
|
WPanel *p = (WPanel *) dh->widget;
|
|
|
|
|
|
|
|
if (current_widget == p->filter_w){
|
|
|
|
in = (WInput *) current_widget;
|
1999-01-27 04:14:57 +03:00
|
|
|
set_panel_filter_to (p, g_strdup (in->buffer));
|
1998-04-28 08:29:19 +04:00
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
1998-03-24 08:25:56 +03:00
|
|
|
|
1998-04-28 08:29:19 +04:00
|
|
|
if (current_widget == p->current_dir){
|
|
|
|
WInput *in = p->current_dir;
|
1998-03-24 08:25:56 +03:00
|
|
|
|
1998-04-28 08:29:19 +04:00
|
|
|
do_panel_cd (p, in->buffer, cd_parse_command);
|
|
|
|
assign_text (in, p->cwd);
|
|
|
|
update_input (in, 1);
|
1998-03-24 08:25:56 +03:00
|
|
|
|
1998-04-28 08:29:19 +04:00
|
|
|
return MSG_HANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dh = dh->next;
|
|
|
|
} while (dh != h->current);
|
1998-03-13 08:18:52 +03:00
|
|
|
}
|
1998-05-05 09:49:57 +04:00
|
|
|
|
|
|
|
if (msg == DLG_UNHANDLED_KEY || msg == DLG_HOTKEY_HANDLED)
|
|
|
|
return midnight_callback (h, id, msg);
|
|
|
|
|
1998-10-20 05:52:16 +04:00
|
|
|
return 0;
|
1998-03-13 08:18:52 +03:00
|
|
|
}
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
/* Ugly function to support the hack described in non_corba_create_panels() */
|
|
|
|
static gint
|
|
|
|
idle_destroy_panel (gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
panel = data;
|
|
|
|
gnome_close_panel (GTK_WIDGET (panel->widget.wdata), panel);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
/* Initializes the desktop and creates the initial panels. This is to be used
|
|
|
|
* when we do not have a CORBA server.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
non_corba_create_panels (void)
|
1998-04-30 10:03:17 +04:00
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
WPanel *panel;
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
desktop_init ();
|
|
|
|
gnome_init_panels ();
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
cmdline = command_new (0, 0, 0);
|
|
|
|
the_hint = label_new (0, 0, 0, NULL);
|
|
|
|
desktop_dlg = create_dlg (0, 0, 24, 80, 0,
|
|
|
|
dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED);
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
session_load ();
|
1998-05-05 00:25:27 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
/* The following is a hack. We have to have at least one panel for
|
|
|
|
* run_dlg() to be happy. So we destroy it in the idle loop if we
|
|
|
|
* didn't need it in the first place. This idle function is to be run
|
|
|
|
* at a higher priority than the one used in session_load().
|
|
|
|
*/
|
1998-05-05 00:25:27 +04:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
panel = new_panel_at (".");
|
|
|
|
gtk_idle_add_priority (GTK_PRIORITY_DEFAULT, idle_destroy_panel, panel);
|
|
|
|
panel->widget.options |= W_PANEL_HIDDEN;
|
|
|
|
|
|
|
|
run_dlg (desktop_dlg);
|
|
|
|
|
|
|
|
desktop_destroy ();
|
1998-04-30 10:03:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only at startup we have a strange condition: if more than one
|
|
|
|
* panel is created, then the code hangs inside X, it keeps waiting
|
|
|
|
* for a reply for something in Imlib that never returns.
|
|
|
|
*
|
|
|
|
* Creating the panels on the idle loop takes care of this
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
create_panels (void)
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
if (!corba_have_server)
|
|
|
|
non_corba_create_panels ();
|
|
|
|
else {
|
|
|
|
if (!nowindows)
|
|
|
|
corba_create_window ();
|
1998-12-30 03:32:41 +03:00
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
session_set_restart (FALSE);
|
1998-05-05 00:25:27 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1998-03-05 07:53:47 +03:00
|
|
|
|
1999-02-24 05:26:11 +03:00
|
|
|
void
|
|
|
|
gmc_do_quit (void)
|
1998-04-30 10:03:17 +04:00
|
|
|
{
|
|
|
|
/* FIXME: This wont get us out from a dialog box */
|
|
|
|
gtk_main_quit ();
|
|
|
|
quit = 1;
|
|
|
|
dlg_stop (desktop_dlg);
|
|
|
|
}
|
1999-03-30 10:09:56 +04:00
|
|
|
#if 0
|
1999-02-24 05:26:11 +03:00
|
|
|
static void
|
|
|
|
session_die (void)
|
|
|
|
{
|
|
|
|
gmc_do_quit ();
|
|
|
|
}
|
|
|
|
|
1998-04-30 10:03:17 +04:00
|
|
|
/*
|
|
|
|
* Save the session callback
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown,
|
|
|
|
GnomeInteractStyle interact_style, gint fast, gpointer client_data)
|
|
|
|
{
|
|
|
|
char *sess_id;
|
|
|
|
char **argv = g_malloc (sizeof (char *) * ((g_list_length (containers) * 3) + 2));
|
|
|
|
GList *l, *free_list = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sess_id = gnome_client_get_id (client);
|
|
|
|
|
|
|
|
argv [0] = client_data;
|
|
|
|
for (i = 1, l = containers; l; l = l->next){
|
|
|
|
PanelContainer *pc = l->data;
|
1998-11-12 21:08:53 +03:00
|
|
|
char *geom;
|
1998-04-30 10:03:17 +04:00
|
|
|
|
1998-11-12 21:08:53 +03:00
|
|
|
geom = gnome_geometry_string (GTK_WIDGET (pc->panel->widget.wdata)->window);
|
|
|
|
|
1998-04-30 10:03:17 +04:00
|
|
|
argv [i++] = pc->panel->cwd;
|
|
|
|
argv [i++] = "--geometry";
|
1998-11-12 21:08:53 +03:00
|
|
|
argv [i++] = geom;
|
1998-11-13 00:35:04 +03:00
|
|
|
free_list = g_list_append (free_list, geom);
|
1998-04-30 10:03:17 +04:00
|
|
|
}
|
1998-05-05 00:25:27 +04:00
|
|
|
|
|
|
|
/* If no windows were open */
|
|
|
|
if (i == 1){
|
|
|
|
argv [i++] = "--nowindows";
|
|
|
|
}
|
1998-05-15 09:43:31 +04:00
|
|
|
|
1998-04-30 10:03:17 +04:00
|
|
|
argv [i] = NULL;
|
|
|
|
gnome_client_set_clone_command (client, i, argv);
|
|
|
|
gnome_client_set_restart_command (client, i, argv);
|
1999-03-09 07:34:05 +03:00
|
|
|
gnome_config_sync ();
|
1998-04-30 10:03:17 +04:00
|
|
|
|
|
|
|
for (l = free_list; l; l = l->next)
|
|
|
|
g_free (l->data);
|
|
|
|
g_list_free (free_list);
|
1998-05-15 09:43:31 +04:00
|
|
|
|
|
|
|
g_free (argv);
|
|
|
|
|
1998-05-26 21:49:41 +04:00
|
|
|
if (shutdown){
|
|
|
|
quit = 1;
|
|
|
|
dlg_stop (midnight_dlg);
|
|
|
|
}
|
1998-04-30 10:03:17 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
session_management_setup (char *name)
|
|
|
|
{
|
1999-02-24 05:26:11 +03:00
|
|
|
session_client = gnome_master_client ();
|
1999-02-24 04:48:55 +03:00
|
|
|
|
1999-02-24 05:26:11 +03:00
|
|
|
if (session_client){
|
|
|
|
gnome_client_set_restart_style (session_client,
|
|
|
|
finish_program ? GNOME_RESTART_NEVER : GNOME_RESTART_IMMEDIATELY);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (session_client), "save_yourself",
|
1998-04-30 10:03:17 +04:00
|
|
|
GTK_SIGNAL_FUNC (session_save_state), name);
|
1999-02-24 05:26:11 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (session_client), "die",
|
1998-04-30 10:03:17 +04:00
|
|
|
GTK_SIGNAL_FUNC (session_die), NULL);
|
|
|
|
}
|
|
|
|
}
|
1999-03-30 10:09:56 +04:00
|
|
|
#endif
|
1999-01-23 23:43:36 +03:00
|
|
|
/*
|
|
|
|
* Configures the GtkWindow/GnomeDialog from a WPanel.
|
|
|
|
*
|
|
|
|
* This makes the window centered on the screen and binds it to
|
|
|
|
* its parent container for better window manager experience
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gmc_window_setup_from_panel (GnomeDialog *dialog, WPanel *panel)
|
|
|
|
{
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
|
|
|
gnome_dialog_set_parent (dialog, GTK_WINDOW (panel->xwindow));
|
|
|
|
}
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gnome_check_super_user:
|
|
|
|
* @void:
|
|
|
|
*
|
|
|
|
* Puts out a warning if the user is running gmc as root. If the user selects
|
|
|
|
* Cancel, then gmc will terminate.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gnome_check_super_user (void)
|
|
|
|
{
|
|
|
|
GtkWidget *warning_dlg;
|
|
|
|
GnomeClient *client;
|
|
|
|
|
|
|
|
if (geteuid () != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
warning_dlg = gnome_message_box_new (
|
1999-04-07 05:49:22 +04:00
|
|
|
_("You are running the GNOME File Manager as root.\n\n"
|
|
|
|
"As root, you can damage your system if you are not careful, and the "
|
|
|
|
"GNOME File Manager will not stop you from doing it."),
|
1999-03-30 10:09:56 +04:00
|
|
|
GNOME_MESSAGE_BOX_WARNING,
|
|
|
|
GNOME_STOCK_BUTTON_OK, NULL);
|
|
|
|
|
|
|
|
gnome_dialog_run (GNOME_DIALOG (warning_dlg));
|
|
|
|
}
|