1
1

Added session management support to gmc

Этот коммит содержится в:
Miguel de Icaza 1998-04-30 06:03:17 +00:00
родитель aa4e089bfd
Коммит 530e74ff39
7 изменённых файлов: 186 добавлений и 21 удалений

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

@ -1,3 +1,14 @@
1998-04-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gmain.c (create_panels): Create one panel per directory
specified. For some strange reason the code hangs if you start up
more than one panel at once. This is not a gmc bug, it appears to
be an Imlib/gtk/gdk interaction. I am for now creating one panel
in the main program execution thread and the rest during the idle
handler.
(session_save_state): Added session management support.
1998-04-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gprop.c (gprop_general_new): Added an simple icon preview to the

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

@ -382,18 +382,28 @@ panel_enter_event (GtkWidget *widget, GdkEvent *event, WPanel *panel)
}
WPanel *
create_container (Dlg_head *h, char *name)
create_container (Dlg_head *h, char *name, char *geometry)
{
PanelContainer *container = g_new (PanelContainer, 1);
WPanel *panel;
GtkWidget *app, *vbox;
int xpos, ypos, width, height;
gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height);
container->splitted = 0;
app = gnome_app_new ("gmc", name);
gtk_window_set_wmclass (GTK_WINDOW (app), "gmc", "gmc");
gtk_widget_set_usize (GTK_WIDGET (app), 500, 360);
panel = panel_new (name);
/* Geometry configuration */
if (width != -1 && height != -1)
gtk_widget_set_usize (GTK_WIDGET (app), width, height);
else
gtk_widget_set_usize (GTK_WIDGET (app), 500, 360);
if (xpos != -1 && ypos != -1)
gtk_widget_set_uposition (GTK_WIDGET (app), xpos, ypos);
panel = panel_new (name);
vbox = gtk_vbox_new (0, 0);
gnome_app_set_contents (GNOME_APP (app), vbox);
gnome_app_create_menus_with_data (GNOME_APP (app), gnome_panel_menu, panel);
@ -430,15 +440,21 @@ create_container (Dlg_head *h, char *name)
}
void
new_panel_at (char *dir)
new_panel_with_geometry_at (char *dir, char *geometry)
{
WPanel *panel;
mc_chdir (dir);
panel = create_container (desktop_dlg, dir);
add_widget (desktop_dlg, panel);
mc_chdir (dir);
panel = create_container (desktop_dlg, dir, geometry);
add_widget (desktop_dlg, panel);
set_new_current_panel (panel);
x_flush_events ();
}
void
new_panel_at (char *dir)
{
new_panel_with_geometry_at (dir, NULL);
}
void

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

@ -395,10 +395,57 @@ dialog_panel_callback (struct Dlg_head *h, int id, int msg)
return default_dlg_callback (h, id, msg);
}
extern GList *directory_list;
extern GList *geometry_list;
typedef struct {
char *dir; char *geometry;
} dir_and_geometry;
static int
idle_create_panel (void *data)
{
dir_and_geometry *dg = data;
new_panel_with_geometry_at (dg->dir, dg->geometry);
g_free (data);
return 0;
}
/*
* wrapper for new_panel_with_geometry_at.
* first invocation is called directly, further calls use
* the idle handler
*/
static void
create_one_panel (char *dir, char *geometry)
{
static int first = 1;
if (first){
new_panel_with_geometry_at (dir, geometry);
first = 0;
} else {
dir_and_geometry *dg = g_new (dir_and_geometry, 1);
dg->dir = dir;
dg->geometry = geometry;
gtk_idle_add (idle_create_panel, dg);
}
}
/*
* 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
*/
void
create_panels (void)
{
WPanel *panel;
GList *p, *g;
char *geo;
start_desktop ();
cmdline = command_new (0, 0, 0);
@ -407,14 +454,90 @@ create_panels (void)
gnome_init_panels ();
desktop_dlg = create_dlg (0, 0, 24, 80, 0, dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED);
panel = create_container (desktop_dlg, "My Panel");
add_widget (desktop_dlg, panel);
set_current_panel (0);
if (directory_list){
g = geometry_list;
for (p = directory_list; p; p = p->next){
if (g){
geo = g->data;
g = g->next;
} else
geo = NULL;
create_one_panel (p->data, geo);
}
} else
create_one_panel (".", geometry_list ? geometry_list->data : NULL);
g_list_free (directory_list);
g_list_free (geometry_list);
run_dlg (desktop_dlg);
/* shutdown gnome specific bits of midnight commander */
stop_desktop ();
}
static void
session_die (void)
{
extern int quit;
/* FIXME: This wont get us out from a dialog box */
gtk_main_quit ();
quit = 1;
dlg_stop (desktop_dlg);
}
/*
* 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;
int x, y, w, h;
char *buffer = g_malloc (32);
gdk_window_get_origin (GTK_WIDGET (pc->panel->widget.wdata)->window, &x, &y);
gdk_window_get_size (GTK_WIDGET (pc->panel->widget.wdata)->window, &w, &h);
sprintf (buffer, "%dx%d%s%d%s%d", w, h, x, y);
argv [i++] = pc->panel->cwd;
argv [i++] = "--geometry";
argv [i++] = buffer;
free_list = g_list_append (free_list, buffer);
}
argv [i] = NULL;
gnome_client_set_clone_command (client, i, argv);
gnome_client_set_restart_command (client, i, argv);
for (l = free_list; l; l = l->next)
g_free (l->data);
g_list_free (free_list);
return 1;
}
void
session_management_setup (char *name)
{
GnomeClient *client;
client = gnome_client_new_default ();
if (client){
gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
GTK_SIGNAL_FUNC (session_save_state), name);
gtk_signal_connect (GTK_OBJECT (client), "die",
GTK_SIGNAL_FUNC (session_die), NULL);
}
}

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

@ -4,7 +4,7 @@
void panel_action_view_unfiltered (GtkWidget *widget, WPanel *panel);
void panel_action_view (GtkWidget *widget, WPanel *panel);
WPanel *create_container (Dlg_head *h, char *str);
WPanel *create_container (Dlg_head *h, char *str, char *geometry);
void panel_file_list_configure_contents (GtkWidget *file_list, WPanel *panel, int main_width, int height);
typedef struct {

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

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Date: 1998-04-29 23:04:04-0500\n"
"From: Federico Mena <federico@bananoid.nuclecu.unam.mx>\n"
"Date: 1998-04-29 22:25:20-0500\n"
"From: Miguel de Icaza,computo,622-4680 <miguel@metropolis.nuclecu.unam.mx>\n"
"Content-Type: text/plain; charset=\n"
"Xgettext-Options: --default-domain=mc --directory=.. --add-comments --keyword=_ --keyword=N_ --files-from=./POTFILES.in\n"
"Files: edit/edit.c edit/edit_key_translator.c edit/editcmd.c edit/editmenu.c edit/editoptions.c edit/editwidget.c src/fixhlp.c src/achown.c src/background.c src/boxes.c src/chmod.c src/chown.c src/cmd.c src/command.c src/dialog.c src/dir.c src/ext.c src/file.c src/find.c src/help.c src/hotlist.c src/info.c src/layout.c src/learn.c src/main.c src/menu.c src/option.c src/panelize.c src/screen.c src/subshell.c src/tree.c src/user.c src/util.c src/utilunix.c src/view.c src/win.c src/wtools.c gnome/gcmd.c gnome/gdesktop.c gnome/glayout.c gnome/gprop.c gnome/gscreen.c gnome/gtools.c gnome/gview.c gnome/gwidget.c\n"

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

@ -1,3 +1,8 @@
1998-04-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* main.c (parse_an_arg): GNOME edition keeps track of various
--geometry and various directories passed.
1998-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* main.c (update_panels): Great API simplification. update_panels

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

@ -2552,6 +2552,10 @@ probably_finish_program (void)
}
}
enum {
GEOMETRY_KEY = -1
};
static int
process_args (int c, char *option_arg)
{
@ -2676,10 +2680,13 @@ static struct argp_option argp_options [] = {
{ "version", 'V', NULL, 0, N_("Report versionand configuration options."), 0 },
{ "view", 'v', NULL, 0, N_("Start up into the viewer mode."), 0 },
{ "xterm", 'x', NULL, 0, N_("Force xterm mouse support and screen save/restore"), 0 },
{ "geometry", GEOMETRY_KEY, "GEOMETRY", 0, N_("Geometry for the window"), 0 },
{ NULL, 0, NULL, 0, NULL },
};
GList *directory_list = 0;
GList *geometry_list = 0;
static error_t
parse_an_arg (int key, char *arg, struct argp_state *state)
{
@ -2719,6 +2726,10 @@ parse_an_arg (int key, char *arg, struct argp_state *state)
return 0;
#endif
case GEOMETRY_KEY:
geometry_list = g_list_append (geometry_list, arg);
return 0;
case ARGP_KEY_ARG:
break;
@ -2735,10 +2746,8 @@ parse_an_arg (int key, char *arg, struct argp_state *state)
edit_one_file = strdup (arg);
else if (view_one_file)
view_one_file = strdup (arg);
else if (this_dir)
other_dir = strdup (arg);
else
this_dir = strdup (arg);
else
directory_list = g_list_append (directory_list, arg);
}
return 0;
}
@ -2939,6 +2948,7 @@ int main (int argc, char *argv [])
/* NOTE: This call has to be before any our argument handling :) */
#ifdef HAVE_GNOME
session_management_setup (argv [0]);
{
char *base = x_basename (argv [0]);