1999-03-10 Federico Mena Quintero <federico@nuclecu.unam.mx>

This is a semi-big slew of changes to integrate the DESKTOP_BRANCH
	into the main trunk.  Now the gdesktop code creates a temprary
	WPanel structure and passes it on to the core file management
	functions.  Also, the menu code is improved (we now use gpopup2;
	gpopup should go away shortly and gpopup2 should replace it).
	This makes the desktop act consistently with the file panels.
	Thanks to Jonathan for his help with this branch.

	* gdnd.c (perform_action): Use mc_lstat(), not mc_stat().

	* glayout.c (update_panels): Do not update the panels that are
	desktop panels.

	* gdesktop.c (icon_is_in_area): An icon is not considered to be in
	a 0x0 area.

	* gpopup2.c (handle_open): Fetch the desktop icon from the
	filename and call desktop_icon_info_open().

	* gdesktop.c (desktop_icon_info_get_by_filename): New function to
	look up a desktop icon by its filename.

	* glayout.c (create_new_menu_from): Test for the ".desktop" suffix
	correctly.

	* gpopup2.c (handle_properties): If the file comes from a desktop
	panel, always allow edition of the icon image.

1999-03-10  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* file.c (erase_dir): Erase metadata for directories as well.
	(erase_dir_iff_empty): Likewise.
	(copy_file_file): Delete/copy the metadata even for
	char/block/sock/fifo files.  Same thing for when copying symlinks.
	(copy_dir_dir): Delete/copy the metadata.
	(move_dir_dir): Delete/move the metadata.
	(recursive_erase): Delete the metadata.
This commit is contained in:
Miguel de Icaza 1999-03-11 02:40:53 +00:00
parent 7684a17cd3
commit ca1437548b
27 changed files with 1314 additions and 254 deletions

View File

@ -1,3 +1,33 @@
1999-03-10 Federico Mena Quintero <federico@nuclecu.unam.mx>
This is a semi-big slew of changes to integrate the DESKTOP_BRANCH
into the main trunk. Now the gdesktop code creates a temprary
WPanel structure and passes it on to the core file management
functions. Also, the menu code is improved (we now use gpopup2;
gpopup should go away shortly and gpopup2 should replace it).
This makes the desktop act consistently with the file panels.
Thanks to Jonathan for his help with this branch.
* gdnd.c (perform_action): Use mc_lstat(), not mc_stat().
* glayout.c (update_panels): Do not update the panels that are
desktop panels.
* gdesktop.c (icon_is_in_area): An icon is not considered to be in
a 0x0 area.
* gpopup2.c (handle_open): Fetch the desktop icon from the
filename and call desktop_icon_info_open().
* gdesktop.c (desktop_icon_info_get_by_filename): New function to
look up a desktop icon by its filename.
* glayout.c (create_new_menu_from): Test for the ".desktop" suffix
correctly.
* gpopup2.c (handle_properties): If the file comes from a desktop
panel, always allow edition of the icon image.
1999-03-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdialogs.c: Support ui->ctx to be NULL, as file.c will set this
@ -24,6 +54,7 @@
(my_system_get_child_pid): Close also stdin/stdout/stderr
* gdesktop.c (is_mountable): Allow user-nfs devices to be mounted
1999-03-08 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gscreen.c (can_drop_on_clist): New function to figure out if the
@ -78,6 +109,14 @@
* gnome-file-property-dialog.c (create_settings_pane): Add Needs
terminal check box
1999-02-25 Jonathan Blandford <jrb@redhat.com>
* gpopup2.c: even more bug-fixes. Plenty more left to do, but now
all the menu code seems to work other then the
select-and-popup-menu problem.
* gaction.c (gmc_can_view_file): new function. Can we view the file?
1999-02-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gaction.c (gmc_open_filename): Add support for needsterminal.
@ -158,6 +197,13 @@ Tue Feb 23 01:57:22 1999 George Lebl <jirka@5z.com>
* gnome-file-property-dialog.c (apply_metadata_change): Fix memory leak.
1999-02-23 Jonathan Blandford <jrb@redhat.com>
* gpopup2.c (handle_open_with): use the new dialog. Doesn't quite
work -- I'll make sure it does tonight.
* gnome-open-dialog.c: new widget -- an "Open with..." dialog.
1999-02-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_reload_icons): Fix memory leak.
@ -177,6 +223,10 @@ Tue Feb 23 01:57:22 1999 George Lebl <jirka@5z.com>
gint32, fix from George Lebl.
(setup_xdnd_proxy): ditto.
1999-02-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (file_entry_fill): Initialize fe->f.dir_size_computed.
1999-02-18 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gmain.h: Removed set_current_panel() since it was never used.

View File

@ -55,6 +55,7 @@ GNOMESRCS = \
gprint.c \
gprop.c \
gnome-file-property-dialog.c \
gnome-open-dialog.c \
gscreen.c \
gtools.c \
gtkdtree.c \
@ -82,8 +83,10 @@ GNOMEHDRS = \
gpopup.h \
gpopup2.h \
gprefs.h \
gprint.h \
gprop.h \
gnome-file-property-dialog.h \
gnome-open-dialog.h \
gscreen.h \
gtkdtree.h \
gtree.h \
@ -158,6 +161,7 @@ OBJS = \
gprint.o \
gprop.o \
gnome-file-property-dialog.o \
gnome-open-dialog.o \
gscreen.o \
gtools.o \
gtree.o \

View File

@ -13,9 +13,12 @@
#include "ext.h" /* regex_command */
#include "cmd.h" /* copy_cmd, ren_cmd, delete_cmd, ... */
#include "gscreen.h"
#include "gmain.h"
#include "dir.h"
#include "dialog.h"
#include "gcmd.h"
#include "../vfs/vfs.h"
#include "gnome-open-dialog.h"
static void
gmc_execute (const char *fname, const char *buf, int needs_terminal)
@ -86,12 +89,12 @@ gmc_open_filename (char *fname, GList *args)
gnome_desktop_entry_free (entry);
}
}
return 0;
}
int
gmc_edit_filename (char *fname)
gmc_edit (char *fname)
{
const char *mime_type;
const char *cmd;
@ -115,7 +118,7 @@ gmc_edit_filename (char *fname)
return 1;
}
}
gnome_config_push_prefix( "/editor/Editor/");
type = gnome_config_get_string ("EDITOR_TYPE=executable");
@ -125,7 +128,7 @@ gmc_edit_filename (char *fname)
return 1;
}
g_free (type);
editor = gnome_config_get_string ("EDITOR=emacs");
on_terminal = gnome_config_get_bool ("NEEDS_TERM=false");
@ -147,53 +150,108 @@ gmc_edit_filename (char *fname)
return 0;
}
int
gmc_open (file_entry *fe)
{
return gmc_open_filename (fe->fname, NULL);
}
int
gmc_open_with (gchar *filename)
{
GtkWidget *dialog;
gchar *command = NULL;
gchar *real_command;
WPanel *panel = cpanel;
dialog = gnome_open_dialog_new (filename);
if (!is_a_desktop_panel (panel))
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (panel->xwindow));
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
case 0:
command = gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (
GNOME_FILE_ENTRY (GNOME_OPEN_DIALOG (dialog)->entry)->gentry))));
/* Assume COMMAND %f */
if (command) {
/* FIXME: these need the needs_terminal argument to be set correctly */
if (strchr (command, '%'))
exec_extension (filename, command, NULL, NULL, 0, FALSE);
else {
/* This prolly isn't perfect, but it will do. */
real_command = g_strconcat (command, " %f", NULL);
exec_extension (filename, real_command, NULL, NULL, 0, FALSE);
g_free (real_command);
}
}
if (command) {
gtk_widget_destroy (dialog);
return 1;
}
gtk_widget_destroy (dialog);
return 0;
case 1:
gtk_widget_destroy (dialog);
default:
return 0;
}
}
static void
gmc_run_view (const char *filename, const char *buf)
{
exec_extension (filename, buf, NULL, NULL, 0, 0);
}
int
gmc_view (char *filename, int start_line)
static gchar *
gmc_view_command (gchar *filename)
{
const char *mime_type, *cmd;
char *buf;
int size;
if (gnome_metadata_get (filename, "fm-view", &size, &buf) == 0){
gmc_run_view (filename, buf);
g_free (buf);
return 1;
}
if (gnome_metadata_get (filename, "fm-view", &size, &buf) == 0)
return buf;
if (gnome_metadata_get (filename, "view", &size, &buf) == 0){
gmc_run_view (filename, buf);
g_free (buf);
return 1;
}
if (gnome_metadata_get (filename, "view", &size, &buf) == 0)
return buf;
mime_type = gnome_mime_type_or_default (filename, NULL);
if (!mime_type)
return 0;
return NULL;
cmd = gnome_mime_get_value (mime_type, "fm-view");
if (cmd){
gmc_run_view (filename, cmd);
return 1;
}
if (cmd)
return g_strdup (cmd);
cmd = gnome_mime_get_value (mime_type, "view");
if (cmd){
gmc_run_view (filename, cmd);
return g_strdup (cmd);
}
return NULL;
}
gboolean
gmc_can_view_file (char *filename)
{
char *cmd;
cmd = gmc_view_command (filename);
if (cmd) {
g_free (cmd);
return 1;
}
return 0;
}
int
gmc_view (char *filename, int start_line)
{
char *cmd;
cmd = gmc_view_command (filename);
if (cmd) {
gmc_run_view (filename, cmd);
g_free (cmd);
return 1;
}
return 0;

View File

@ -23,9 +23,12 @@
#include "gicon.h"
#include "gmain.h"
#include "gmetadata.h"
#include "gcmd.h"
#include "gdnd.h"
#include "gmount.h"
#include "gpopup.h"
#include "gprint.h"
#include "gscreen.h"
#include "../vfs/vfs.h"
#include "main.h"
@ -180,7 +183,7 @@ get_icon_auto_pos (int *x, int *y)
get_slot_from_pos (*x, *y, &u, &v);
start = u * layout_rows + v;
end = layout_rows * layout_cols;
end = layout_cols * layout_rows;
/* Look forwards until the end of the grid. If we could not find an
* empty spot, find the second best.
@ -699,6 +702,28 @@ select_icon (DesktopIconInfo *dii, int event_state)
select_range (dii, TRUE);
}
/* Convenience function to fill a file entry */
static void
file_entry_fill (file_entry *fe, struct stat *s, char *filename)
{
fe->fname = g_strdup (x_basename (filename));
fe->fnamelen = strlen (fe->fname);
fe->buf = *s;
fe->f.marked = FALSE;
fe->f.link_to_dir = FALSE;
fe->f.stalled_link = FALSE;
fe->f.dir_size_computed = FALSE;
if (S_ISLNK (s->st_mode)) {
struct stat s2;
if (mc_stat (filename, &s2) == 0)
fe->f.link_to_dir = S_ISDIR (s2.st_mode) != 0;
else
fe->f.stalled_link = TRUE;
}
}
/* Creates a file entry structure and fills it with information appropriate to the specified file. */
file_entry *
file_entry_from_file (char *filename)
@ -712,22 +737,7 @@ file_entry_from_file (char *filename)
}
fe = g_new (file_entry, 1);
fe->fname = g_strdup (x_basename (filename));
fe->fnamelen = strlen (fe->fname);
fe->buf = s;
fe->f.marked = FALSE;
fe->f.link_to_dir = FALSE;
fe->f.stalled_link = FALSE;
if (S_ISLNK (s.st_mode)) {
struct stat s2;
if (mc_stat (filename, &s2) == 0)
fe->f.link_to_dir = S_ISDIR (s2.st_mode) != 0;
else
fe->f.stalled_link = TRUE;
}
file_entry_fill (fe, &s, filename);
return fe;
}
@ -912,8 +922,6 @@ gboolean
is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
{
char buffer [128], *p;
umode_t mode;
struct stat s;
int len;
if (point)
@ -1079,14 +1087,14 @@ desktop_icon_info_open (DesktopIconInfo *dii)
message (1, _("Error"), "I could not fetch the information from the file");
return;
}
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe))
new_panel_at (filename);
else {
int is_mounted;
char *point;
int launch = FALSE;
if (is_mountable (filename, fe, &is_mounted, &point)){
if (!is_mounted){
if (try_to_mount (filename, fe))
@ -1100,13 +1108,13 @@ desktop_icon_info_open (DesktopIconInfo *dii)
} else {
int size;
char *buf;
if (gnome_metadata_get (filename,"fm-open", &size, &buf) == 0){
g_free (buf);
gmc_open_filename (filename, NULL);
return;
}
if (gnome_metadata_get (filename, "open", &size, &buf) == 0){
g_free (buf);
gmc_open_filename (filename, NULL);
@ -1115,12 +1123,12 @@ desktop_icon_info_open (DesktopIconInfo *dii)
if (is_exe (fe->buf.st_mode) && if_link_is_exe (desktop_directory, fe)){
int needs_terminal = 0;
if (gnome_metadata_get (filename, "flags", &size, &buf) == 0){
needs_terminal = strstr (buf, "needsterminal") != 0;
g_free (buf);
}
if (needs_terminal)
gnome_open_terminal_with_cmd (filename);
else
@ -1170,18 +1178,183 @@ desktop_icon_info_delete (DesktopIconInfo *dii)
desktop_icon_info_destroy (dii);
}
/**
* desktop_icon_info_get_by_filename:
* @filename: A filename relative to the desktop directory
*
* Returns the desktop icon structure that corresponds to the specified filename,
* which should be relative to the desktop directory.
*
* Return value: The sought desktop icon, or NULL if it is not found.
**/
DesktopIconInfo *
desktop_icon_info_get_by_filename (char *filename)
{
int i;
GList *l;
DesktopIconInfo *dii;
g_return_val_if_fail (filename != NULL, NULL);
for (i = 0; i < layout_cols * layout_rows; i++)
for (l = layout_slots[i].icons; l; l = l->next) {
dii = l->data;
if (strcmp (dii->filename, filename) == 0)
return dii;
}
return NULL;
}
/* This is a HORRIBLE HACK. It creates a temporary panel structure for gpopup's
* perusal. Once gmc is rewritten, all file lists including panels will be a
* single data structure, and the world will be happy again.
*/
static WPanel *
create_panel_from_desktop (void)
{
WPanel *panel;
int nicons, count;
int marked_count, dir_marked_count;
long total;
int selected_index;
int i;
file_entry *fe;
GList *l;
struct stat s;
panel = g_new0 (WPanel, 1);
/* Count the number of desktop icons */
nicons = 0;
for (i = 0; i < layout_cols * layout_rows; i++)
nicons += layout_slots[i].num_icons;
/* Create the file entry list */
panel->dir.size = nicons;
panel->dir.list = g_new (file_entry, nicons);
fe = panel->dir.list;
count = 0;
marked_count = 0;
dir_marked_count = 0;
total = 0;
selected_index = -1;
for (i = 0; i < layout_cols * layout_rows; i++)
for (l = layout_slots[i].icons; l; l = l->next) {
DesktopIconInfo *dii;
char *full_name;
dii = l->data;
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
if (mc_lstat (full_name, &s) == -1) {
g_warning ("Could not stat %s, bad things will happen", full_name);
continue;
}
file_entry_fill (fe, &s, full_name);
if (dii->selected) {
#if 0
if (selected_index == -1)
selected_index = count;
#endif
marked_count++;
fe->f.marked = TRUE;
if (S_ISDIR (fe->buf.st_mode))
dir_marked_count++;
total += fe->buf.st_size;
}
g_free (full_name);
fe++;
count++;
}
/* Fill the rest of the panel structure */
panel->list_type = list_icons;
strncpy (panel->cwd, desktop_directory, sizeof (panel->cwd));
panel->count = count; /* the actual number of lstat()ed files */
panel->marked = marked_count;
panel->dirs_marked = dir_marked_count;
panel->total = total;
panel->selected = selected_index;
panel->is_a_desktop_panel = TRUE;
g_assert (panel->count > 0);
#if 0
g_assert (panel->selected != -1);
#endif
return panel;
}
WPanel *
push_desktop_panel_hack (void)
{
WPanel *panel;
PanelContainer *container;
panel = create_panel_from_desktop ();
container = g_new (PanelContainer, 1);
container->splitted = FALSE;
container->panel = panel;
containers = g_list_append (containers, container);
if (!current_panel_ptr)
current_panel_ptr = container;
else if (!other_panel_ptr)
other_panel_ptr = container;
/* Set it as the current panel and invoke the menu */
set_current_panel (panel);
mc_chdir (desktop_directory);
return panel;
}
/* Frees our hacked-up panel created in the function above */
static void
free_panel_from_desktop (WPanel *panel)
{
int i;
for (i = 0; i < panel->count; i++)
g_free (panel->dir.list[i].fname);
g_free (panel->dir.list);
g_free (panel);
}
/* Used to execute the popup menu for desktop icons */
static void
do_popup_menu (DesktopIconInfo *dii, GdkEventButton *event)
{
char *filename;
WPanel *panel;
DesktopIconInfo *dii_temp;
/* Create the panel and the container structure */
panel = push_desktop_panel_hack ();
dii_temp = NULL;
if (panel->marked == 1)
dii_temp = dii;
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
if (gpopup_do_popup (event, NULL, dii, 0, filename) != -1)
if (gpopup_do_popup2 (event, panel, dii_temp) != -1)
desktop_reload_icons (FALSE, 0, 0);
g_free (filename);
layout_panel_gone (panel);
free_panel_from_desktop (panel);
}
/* Idle handler that opens a desktop icon. See below for information on why we
@ -1255,6 +1428,9 @@ icon_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
retval = TRUE;
}
} else if (event->button.button == 3) {
if (!dii->selected)
select_icon (dii, event->button.state);
do_popup_menu (dii, (GdkEventButton *) event);
retval = TRUE;
}
@ -2176,11 +2352,18 @@ handle_rescan_desktop (GtkWidget *widget, gpointer data)
{
desktop_reload_icons (FALSE, 0, 0);
}
static GnomeUIInfo gnome_panel_new_menu [] = {
GNOMEUIINFO_ITEM_NONE(N_("_Terminal"), N_("Launch a new terminal in the current directory"), gnome_open_terminal),
/* If this ever changes, make sure you update create_new_menu accordingly. */
GNOMEUIINFO_ITEM_NONE( N_("_Directory..."), N_("Creates a new directory"), gnome_mkdir_cmd ),
GNOMEUIINFO_END
};
/* The popup menu for the desktop */
GnomeUIInfo desktop_popup_items[] = {
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
GNOMEUIINFO_MENU_NEW_SUBTREE(gnome_panel_new_menu),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
GNOMEUIINFO_ITEM_NONE (N_("Create New Window"), NULL, handle_new_window),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_NONE (N_("Rescan Mountable Devices"), NULL, handle_rescan_devices),
@ -2192,10 +2375,36 @@ GnomeUIInfo desktop_popup_items[] = {
static void
desktop_popup (GdkEventButton *event)
{
GtkWidget *shell;
GtkWidget *popup;
GList *child_list;
gchar *file, *file2;
WPanel *panel;
gint i;
popup = gnome_popup_menu_new (desktop_popup_items);
/* First thing we want to do is strip off the STUPID tear off menu... S-: */
shell = gnome_panel_new_menu[0].widget->parent;
child_list = gtk_container_children (GTK_CONTAINER (shell));
if (GTK_IS_TEAROFF_MENU_ITEM (child_list->data))
gtk_widget_hide (GTK_WIDGET (child_list->data));
i = g_list_length (child_list);
g_list_free (child_list);
file = gnome_unconditional_datadir_file ("mc/templates");
i = create_new_menu_from (file, shell, i);
file2 = gnome_datadir_file ("mc/templates");
if (file2 != NULL){
if (strcmp (file, file2) != 0)
create_new_menu_from (file2, shell, i);
}
g_free (file);
g_free (file2);
panel = push_desktop_panel_hack ();
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, NULL);
layout_panel_gone (panel);
free_panel_from_desktop (panel);
gtk_widget_destroy (popup);
}
@ -2262,6 +2471,9 @@ icon_is_in_area (DesktopIconInfo *dii, int x1, int y1, int x2, int y2)
x2 -= dii->x;
y2 -= dii->y;
if (x1 == x2 && y1 == y2)
return FALSE;
if (x1 < dicon->icon_x + dicon->icon_w - 1
&& x2 > dicon->icon_x
&& y1 < dicon->icon_y + dicon->icon_h - 1

View File

@ -48,12 +48,17 @@ typedef struct {
void desktop_icon_info_open (DesktopIconInfo *dii);
void desktop_icon_info_delete (DesktopIconInfo *dii);
void desktop_icon_update_url (DesktopIconInfo *dii);
DesktopIconInfo *desktop_icon_info_get_by_filename (char *filename);
file_entry *file_entry_from_file (char *filename);
void file_entry_free (file_entry *fe);
gboolean is_mountable (char *filename, file_entry *fe, int *is_mounted, char **mount_point);
gboolean is_ejectable (char *filename);
gboolean do_mount_umount (char *filename, gboolean is_mount);
gboolean do_eject (char *filename);
void desktop_arrange_icons (void);
void desktop_rescan_devices (void);

View File

@ -333,6 +333,7 @@ file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
GtkWidget *qrp_dlg;
GtkWidget *radio;
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *hbox;
GtkWidget *icon;
GtkWidget *label;
@ -362,15 +363,19 @@ file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_window_set_position (GTK_WINDOW (qrp_dlg), GTK_WIN_POS_MOUSE);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
icon = gnome_stock_pixmap_widget (hbox, GNOME_STOCK_PIXMAP_HELP);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qrp_dlg)->vbox), hbox, FALSE, FALSE, 0);
icon = gnome_stock_pixmap_widget (hbox, GNOME_STOCK_PIXMAP_HELP);
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, GNOME_PAD_SMALL);
label = gtk_label_new (_("Some of the files you are trying to copy already "
"exist in the destination folder."));
"exist in the destination folder. Please select "
"the action to be performed."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
@ -378,25 +383,32 @@ file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
vbox2 = gtk_vbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_label (group, _("Prompt me before overwriting any file."));
gtk_object_set_user_data (GTK_OBJECT (radio), GINT_TO_POINTER (REPLACE_PROMPT));
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
radio = gtk_radio_button_new_with_label (group, _("Don't overwrite any files."));
gtk_object_set_user_data (GTK_OBJECT (radio), GINT_TO_POINTER (REPLACE_NEVER));
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
ui->op_radio = gtk_radio_button_new (group);
gtk_object_set_user_data (GTK_OBJECT (ui->op_radio), GINT_TO_POINTER (REPLACE_OPTION_MENU));
gtk_signal_connect (GTK_OBJECT (ui->op_radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), ui);
gtk_box_pack_start (GTK_BOX (vbox2), ui->op_radio, FALSE, FALSE, 0);
hrbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (ui->op_radio), hrbox);
gtk_box_pack_start (GTK_BOX (hrbox), gtk_label_new (_("Overwrite:")), FALSE, FALSE, 0);
/* we set up the option menu. */
@ -425,15 +437,6 @@ file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
gtk_widget_show_all (menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
gtk_signal_connect (GTK_OBJECT (ui->op_radio), "toggled",
GTK_SIGNAL_FUNC (policy_callback), (gpointer) REPLACE_ALWAYS);
gtk_box_pack_start (GTK_BOX (vbox), ui->op_radio, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (ui->op_radio));
gtk_container_add (GTK_CONTAINER (ui->op_radio), hrbox);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (qrp_dlg)->vbox),
hbox, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET (GNOME_DIALOG (qrp_dlg)->vbox));
switch (gnome_dialog_run_and_close (GNOME_DIALOG (qrp_dlg))) {
case 0:
@ -619,16 +622,20 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->follow_links);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->follow_links);
#if 0
gnome_widget_add_help (cbox,
_("Selecting this will copy the files that symlinks point "
"to instead of just copying the link."));
#endif
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
cbox = gtk_check_button_new_with_label (_("Preserve file attributes."));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->op_preserve);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->op_preserve);
#if 0
gnome_widget_add_help (cbox, _("Preserves the permissions and the UID/GID if possible"));
#endif
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
@ -637,7 +644,9 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cbox), ctx->dive_into_subdirs);
gtk_signal_connect (GTK_OBJECT (cbox), "toggled",
(GtkSignalFunc) fmd_check_box_callback, &ctx->dive_into_subdirs);
#if 0
gnome_widget_add_help (cbox, _("If set, this will copy the directories recursively"));
#endif
gtk_box_pack_start (GTK_BOX (vbox), cbox, FALSE, FALSE, 0);
}

View File

@ -184,7 +184,7 @@ perform_action (GList *names, GdkDragAction action, char *destdir)
dest_name = g_concat_dir_and_file (destdir, x_basename (name));
do {
result = mc_stat (name, &s);
result = mc_lstat (name, &s);
if (result != 0) {
/* FIXME: this error message sucks */
@ -317,14 +317,34 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
const char *mime_type;
char *full_name;
int retval;
GList *names, *l;
int len, i;
char **drops;
retval = FALSE; /* assume we cannot drop */
full_name = g_concat_dir_and_file (directory, dest_fe->fname);
/* Convert the data list into an array of strings */
names = gnome_uri_list_extract_uris (selection_data->data);
len = g_list_length (names);
drops = g_new (char *, len + 1);
for (l = names, i = 0; i < len; i++, l = l->next) {
char *text = l->data;
if (strncmp (text, "file:", 5) == 0)
text += 5;
drops[i] = text;
}
drops[i] = NULL;
/* 1. Try to use a metadata-based drop action */
if (gnome_metadata_get (full_name, "drop-action", &size, &buf) == 0) {
gmc_execute (full_name, buf, 0);
exec_extension (full_name, buf, drops, NULL, 0, 0);
g_free (buf);
retval = TRUE;
goto out;
@ -338,7 +358,7 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
action = gnome_mime_get_value (mime_type, "drop-action");
if (action) {
gmc_execute (full_name, action, 0);
exec_extension (full_name, action, drops, NULL, 0, 0);
retval = TRUE;
goto out;
}
@ -347,35 +367,13 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
/* 3. If executable, try metadata keys for "open" */
if (is_exe (dest_fe->buf.st_mode) && if_link_is_exe (directory, dest_fe)) {
GList *names, *l;
int len, i;
char **drops;
/* FIXME: handle the case for Netscape URLs */
/* Convert the data list into an array of strings */
names = gnome_uri_list_extract_uris (selection_data->data);
len = g_list_length (names);
drops = g_new (char *, len + 1);
for (l = names, i = 0; i < len; i++, l = l->next) {
char *text = l->data;
if (strncmp (text, "file:", 5) == 0)
text += 5;
drops[i] = text;
}
drops[i] = NULL;
if (gnome_metadata_get (full_name, "open", &size, &buf) == 0)
exec_extension (full_name, buf, drops, NULL, 0, 0);
else
exec_extension (full_name, "%f %q", drops, NULL, 0, 0);
g_free (drops);
gnome_uri_list_free_strings (names);
g_free (buf);
retval = TRUE;
@ -383,7 +381,8 @@ drop_on_file (GdkDragContext *context, GtkSelectionData *selection_data,
}
out:
g_free (drops);
gnome_uri_list_free_strings (names);
g_free (full_name);
return retval;
}

View File

@ -88,7 +88,7 @@ get_other_index (void)
return UNDEFINED_INDEX;
}
static void
void
set_current_panel (WPanel *panel)
{
GList *p;
@ -99,6 +99,7 @@ set_current_panel (WPanel *panel)
for (p = containers; p; p = p->next){
if (((PanelContainer *)p->data)->panel == panel){
current_panel_ptr = p->data;
break;
}
}
}
@ -313,7 +314,7 @@ do_desktop_rescan_devices (void)
void configure_box (void);
GtkCheckMenuItem *gnome_toggle_snap (void);
GnomeUIInfo gnome_panel_new_menu [] = {
static GnomeUIInfo gnome_panel_new_menu [] = {
GNOMEUIINFO_ITEM_NONE(N_("_Terminal"), N_("Launch a new terminal in the current directory"), gnome_open_terminal),
/* If this ever changes, make sure you update create_new_menu accordingly. */
GNOMEUIINFO_ITEM_NONE( N_("_Directory..."), N_("Creates a new directory"), gnome_mkdir_cmd ),
@ -465,30 +466,32 @@ panel_enter_event (GtkWidget *widget, GdkEvent *event, WPanel *panel)
send_message (panel->widget.parent, (Widget *) panel, WIDGET_FOCUS, 0);
}
static void
create_new_menu_from (GnomeApp *app, WPanel *panel, char *file)
void
destroy_gde (GtkWidget *unused, void *data)
{
gnome_desktop_entry_free ((GnomeDesktopEntry *) (data));
}
gint
create_new_menu_from (char *file, GtkWidget *shell, gint pos)
{
gint pos;
GtkWidget *shell = NULL;
DIR *dir;
struct stat filedata;
gboolean add_separator = TRUE;
struct dirent *dirstruc;
GnomeDesktopEntry *gde;
GtkWidget *menu;
char *file2;
g_return_val_if_fail (shell != NULL, pos);
dir = opendir (file);
if (dir == NULL)
return;
shell = gnome_app_find_menu_pos (app->menubar, _("File/New/Directory..."), &pos);
menu = gtk_menu_item_new ();
gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
return pos;
if (shell == NULL){
closedir (dir);
return;
return pos;
}
while ((dirstruc = readdir (dir)) != NULL){
@ -499,13 +502,17 @@ create_new_menu_from (GnomeApp *app, WPanel *panel, char *file)
if ((stat (file2, &filedata) != -1) && (S_ISREG (filedata.st_mode))){
char *path;
char *test;
int len;
const int desktoplen = sizeof (".desktop") - 1;
len = strlen (dirstruc->d_name);
if (strcmp (dirstruc->d_name + len - desktoplen, ".desktop") != 0) {
g_free (file2);
continue;
}
gde = gnome_desktop_entry_load (file2);
test = strrchr(dirstruc->d_name, '.');
if (test == NULL || gde == NULL || strcmp (test, ".desktop")){
if (gde == NULL) {
g_free (file2);
continue;
}
@ -513,23 +520,40 @@ create_new_menu_from (GnomeApp *app, WPanel *panel, char *file)
path = gnome_is_program_in_path (gde->tryexec);
g_free (path);
if (!path){
gnome_desktop_entry_free (gde);
g_free (file2);
continue;
}
if (add_separator) {
menu = gtk_menu_item_new ();
gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
add_separator = !add_separator;
}
menu = gtk_menu_item_new_with_label (gde->name);
gtk_widget_show (menu);
gtk_menu_shell_insert (GTK_MENU_SHELL (shell), menu, pos++);
/* This is really bad, but it works. */
/* FIXME: it doesn't work if we free the gde below. --
* need to do this right sometime -jrb
*/
if (gde->comment)
gtk_object_set_data (GTK_OBJECT (menu), "apphelper_statusbar_hint",
gtk_object_set_data (GTK_OBJECT (menu),
"apphelper_statusbar_hint",
gde->comment);
gtk_signal_connect (GTK_OBJECT (menu), "activate", GTK_SIGNAL_FUNC (gnome_run_new),
gtk_signal_connect (GTK_OBJECT (menu), "activate",
GTK_SIGNAL_FUNC (gnome_run_new),
gde);
gtk_signal_connect (GTK_OBJECT (menu), "destroy",
GTK_SIGNAL_FUNC (destroy_gde),
gde);
}
g_free (file2);
}
return pos;
}
/**
@ -541,15 +565,20 @@ static void
create_new_menu (GnomeApp *app, WPanel *panel)
{
gchar *file, *file2;
gint pos;
GtkWidget *shell;
shell = gnome_app_find_menu_pos (app->menubar, _("File/New/Directory..."), &pos);
file = gnome_unconditional_datadir_file ("mc/templates");
create_new_menu_from (app, panel, file);
pos = create_new_menu_from (file, shell, pos);
file2 = gnome_datadir_file ("mc/templates");
if (file2 != NULL){
if (strcmp (file, file2) != 0)
create_new_menu_from (app, panel, file2);
create_new_menu_from (file2, shell, pos);
}
g_free (file);
g_free (file2);
}
@ -718,7 +747,8 @@ update_panels (int force_update, char *current_file)
if (!cpanel)
return;
update_one_panel_widget (cpanel, force_update, current_file);
if (!is_a_desktop_panel (cpanel))
update_one_panel_widget (cpanel, force_update, current_file);
if (reload_others){
for (p = containers; p; p = p->next){
@ -727,7 +757,8 @@ update_panels (int force_update, char *current_file)
if (p->data == current_panel_ptr)
continue;
update_one_panel_widget (pc->panel, force_update, UP_KEEPSEL);
if (!is_a_desktop_panel (pc->panel))
update_one_panel_widget (pc->panel, force_update, UP_KEEPSEL);
}
}
mc_chdir (cpanel->cwd);

View File

@ -412,7 +412,6 @@ x_set_idle (Dlg_head *h, int enable_idle)
int
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
{
WPanel *p;
WInput *in;
Widget_Item *dh;
void *current_widget; /* The current widget */
@ -566,8 +565,6 @@ gmc_do_quit (void)
static void
session_die (void)
{
extern int quit;
gmc_do_quit ();
}
@ -588,7 +585,6 @@ session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_styl
argv [0] = client_data;
for (i = 1, l = containers; l; l = l->next){
PanelContainer *pc = l->data;
int x, y, w, h;
char *geom;
geom = gnome_geometry_string (GTK_WIDGET (pc->panel->widget.wdata)->window);

View File

@ -33,9 +33,15 @@ void gnome_init_panels ();
void bind_gtk_keys (GtkWidget *w, Dlg_head *h);
WPanel *new_panel_at (char *dir);
WPanel *new_panel_with_geometry_at (char *dir, char *geometry);
void set_current_panel (WPanel *panel);
void layout_panel_gone (WPanel *panel);
void gtkrundlg_event (Dlg_head *h);
int gmc_open (file_entry *fe);
int gmc_open_with (char *filename);
int gmc_open_filename (char *fname, GList *args);
int gmc_edit (char *fname);
int gmc_can_view_file (char *filename);
int gmc_view (char *filename, int start_line);
void x_show_info (WInfo *info, struct my_statfs *s, struct stat *b);
void x_create_info (Dlg_head *h, widget_data parent, WInfo *info);

View File

@ -1,5 +1,5 @@
/* gnome-file-property-dialog.c
* Copyright (C) 1999 J. Arthur Random
* Copyright (C) 1999 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -1230,8 +1230,6 @@ static gint
apply_metadata_change (GnomeFilePropertyDialog *fpd)
{
gchar *text;
gchar *icon_name;
char *filename;
/* If we don't have an open_cbox, that means we have no metadata
* to set.

View File

@ -1,5 +1,5 @@
/* gnome-file-property-dialog.h
* Copyright (C) 1999 J. Arthur Random
* Copyright (C) 1999 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public

332
gnome/gnome-open-dialog.c Normal file
View File

@ -0,0 +1,332 @@
/* gnome-open-dialog.c
* Copyright (C) 1999 Red Hat Software. Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gnome.h>
#include "gnome-open-dialog.h"
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
static void gnome_open_dialog_init (GnomeOpenDialog *open_dialog);
static void gnome_open_dialog_class_init (GnomeOpenDialogClass *klass);
static void gnome_open_dialog_destroy (GtkObject *object);
static void gnome_open_dialog_generate_tree_helper (GtkCTree *ctree, GtkCTreeNode *parent, GNode *node);
static void gnome_open_dialog_destroy_func (GtkCTree *ctree, GtkCTreeNode *node, gpointer data);
static GnomeDialogClass *parent_class = NULL;
#define SMALL_ICON_SIZE 20
GtkType
gnome_open_dialog_get_type (void)
{
static GtkType open_dialog_type = 0;
if (!open_dialog_type)
{
static const GtkTypeInfo open_dialog_info =
{
"GnomeOpenDialog",
sizeof (GnomeOpenDialog),
sizeof (GnomeOpenDialogClass),
(GtkClassInitFunc) gnome_open_dialog_class_init,
(GtkObjectInitFunc) gnome_open_dialog_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
open_dialog_type = gtk_type_unique (gnome_dialog_get_type (), &open_dialog_info);
}
return open_dialog_type;
}
static void
gnome_open_dialog_class_init (GnomeOpenDialogClass *klass)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*) klass;
parent_class = gtk_type_class (gnome_dialog_get_type ());
object_class->destroy = gnome_open_dialog_destroy;
}
static void
gnome_open_dialog_destroy_func (GtkCTree *ctree,
GtkCTreeNode *node,
gpointer data)
{
GnomeDesktopEntry *gde;
if (ctree == NULL || node == NULL)
return;
gde = (GnomeDesktopEntry *)gtk_ctree_node_get_row_data (GTK_CTREE (ctree),node);
if (gde)
gnome_desktop_entry_free (gde);
}
static void
gnome_open_dialog_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_OPEN_DIALOG (object));
g_free (GNOME_OPEN_DIALOG (object)->file_name);
gtk_ctree_post_recursive (GTK_CTREE (GNOME_OPEN_DIALOG (object)->ctree),
NULL,
gnome_open_dialog_destroy_func,
NULL);
gtk_widget_unref (GNOME_OPEN_DIALOG (object)->ctree);
gtk_widget_unref (GNOME_OPEN_DIALOG (object)->entry);
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gnome_open_dialog_init (GnomeOpenDialog *open_dialog)
{
}
/* Private internal functions */
/* Stolen from gnomecc:tree.c */
static GNode *
read_directory (gchar *directory)
{
DIR *parent_dir;
struct dirent *child_dir;
struct stat filedata;
GNode *retval = g_node_new(NULL);
parent_dir = opendir (directory);
if (parent_dir == NULL)
return NULL;
while ((child_dir = readdir (parent_dir)) != NULL) {
if (child_dir->d_name[0] != '.') {
/* we check to see if it is interesting. */
GString *name = g_string_new (directory);
g_string_append (name, "/");
g_string_append (name, child_dir->d_name);
if (stat (name->str, &filedata) != -1) {
gchar* test;
if (S_ISDIR (filedata.st_mode)) {
/* it might be interesting... */
GNode *next_dir = read_directory (name->str);
if (next_dir)
/* it is interesting!!! */
g_node_prepend (retval, next_dir);
}
test = rindex(child_dir->d_name, '.');
if (test && !strcmp (".desktop", test)) {
/* it's a .desktop file -- it's interesting for sure! */
GNode *new_node = g_node_new (gnome_desktop_entry_load (name->str));
g_node_prepend (retval, new_node);
}
}
g_string_free (name, TRUE);
}
else if (!strcmp (child_dir->d_name, ".directory")) {
GString *name = g_string_new (directory);
g_string_append (name, "/.directory");
retval->data = gnome_desktop_entry_load (name->str);
g_string_free (name, TRUE);
}
}
#if 0
if (!retval->data) {
/* no .directory file. Well, I guess we abort. */
/* FIXME: i guess we should free memory now... */
return NULL;
}
#endif
if (retval->children == NULL) {
if (retval->data)
gnome_desktop_entry_free (retval->data);
return NULL;
}
return retval;
}
static void
gnome_open_dialog_generate_tree_helper (GtkCTree *ctree, GtkCTreeNode *parent, GNode *node)
{
GNode *i;
GtkCTreeNode *child = NULL;
static char *text[2];
GnomePixmap *icon_gpixmap;
gchar *icon;
GdkPixmap *icon_pixmap, *icon_mask;
text[0] = NULL;
text[1] = NULL;
for (i = node;i;i = i->next) {
icon_pixmap=NULL;
icon_mask=NULL;
icon=NULL;
icon_gpixmap = NULL;
if (i->data && ((GnomeDesktopEntry *)i->data)->name) {
text[0] = ((GnomeDesktopEntry *)i->data)->name;
} else
text[0] = NULL;
if ((i->data) && ((GnomeDesktopEntry *)i->data)->icon)
icon = ((GnomeDesktopEntry *)i->data)->icon;
if (icon && g_file_exists (icon))
icon_gpixmap = (GnomePixmap *)gnome_pixmap_new_from_file_at_size(icon,
SMALL_ICON_SIZE,
SMALL_ICON_SIZE);
if (icon_gpixmap) {
icon_pixmap = icon_gpixmap->pixmap;
icon_mask = icon_gpixmap->mask;
}
if (i->data && text[0]) {
if (((GnomeDesktopEntry *)i->data)->type && !strcmp(((GnomeDesktopEntry *)i->data)->type,"Directory"))
child = gtk_ctree_insert_node (ctree,parent,NULL, text, 3, icon_pixmap, icon_mask, icon_pixmap, icon_mask,FALSE,FALSE);
else
child = gtk_ctree_insert_node (ctree,parent,NULL, text, 3, icon_pixmap, icon_mask, icon_pixmap, icon_mask,TRUE,FALSE);
gtk_ctree_node_set_row_data (ctree, child, i->data);
} else
gnome_desktop_entry_free (i->data);
if (i->children)
gnome_open_dialog_generate_tree_helper (ctree, child, i->children);
/*
if (parent == NULL)
gtk_ctree_expand_recursive (ctree, child);
*/
}
}
static void
gnome_open_dialog_selected_row_callback (GtkWidget *widget, GtkCTreeNode *node, gint column, gpointer *data)
{
GnomeDesktopEntry *gde = NULL;
GnomeOpenDialog *dialog = NULL;
GtkWidget *entry;
if (column < 0)
return;
dialog = GNOME_OPEN_DIALOG (data);
gde = (GnomeDesktopEntry *)gtk_ctree_node_get_row_data (GTK_CTREE (widget),node);
g_return_if_fail (dialog != NULL);
g_return_if_fail (gde != NULL);
if (gde->exec) {
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (dialog->entry));
gtk_entry_set_text (GTK_ENTRY (entry), gde->exec[0]);
}
}
GtkWidget *
gnome_open_dialog_get_tree (GnomeOpenDialog *dialog)
{
GtkWidget *retval;
gchar *prefix;
GNode *node;
/* widget stuff */
retval = gtk_ctree_new (1, 0);
gtk_clist_set_row_height(GTK_CLIST (retval),20);
gtk_ctree_set_line_style (GTK_CTREE (retval), GTK_CTREE_LINES_DOTTED);
gtk_ctree_set_expander_style (GTK_CTREE (retval), GTK_CTREE_EXPANDER_SQUARE);
gtk_clist_set_column_width(GTK_CLIST (retval), 0, 150);
gtk_signal_connect( GTK_OBJECT (retval),
"tree_select_row",
GTK_SIGNAL_FUNC (gnome_open_dialog_selected_row_callback),
dialog);
gtk_ctree_set_indent (GTK_CTREE (retval), 15);
gtk_clist_set_column_auto_resize (GTK_CLIST (retval), 0, TRUE);
/* set up the apps */
prefix = gnome_unconditional_datadir_file ("gnome/apps");
node = read_directory (prefix);
gnome_open_dialog_generate_tree_helper (GTK_CTREE (retval), NULL, node);
g_node_destroy (node);
g_free (prefix);
return retval;
}
/* Public functions */
GtkWidget *
gnome_open_dialog_new (gchar *file_name)
{
GnomeOpenDialog *dialog;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *sw;
gchar *label_string;
g_return_val_if_fail (file_name != NULL, NULL);
dialog = gtk_type_new (gnome_open_dialog_get_type ());
/* the first label */
label_string = g_strconcat (_("Select an application to open \""),
file_name, "\" with.", NULL);
label = gtk_label_new (label_string);
gtk_widget_set_usize (label, 300, -1);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
g_free (label_string);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
/* The entry */
dialog->file_name = g_strdup (file_name);
dialog->entry = gnome_file_entry_new ("GNOME_OPEN_DIALOG",
_("Select a file to run with"));
gtk_widget_ref (dialog->entry);
/* Watch me do something evil... (-: */
label_string = gnome_unconditional_libdir_file ("");
strcpy (label_string + strlen (label_string) - 4, "bin");
g_print ("%s\n", label_string);
gnome_file_entry_set_default_path (GNOME_FILE_ENTRY (dialog->entry),
label_string);
g_free (label_string);
/* the file tree */
frame = gtk_frame_new (_("Applications"));
dialog->ctree = gnome_open_dialog_get_tree (dialog);
gtk_widget_ref (dialog->ctree);
sw = gtk_scrolled_window_new (GTK_CLIST (dialog->ctree)->hadjustment,
GTK_CLIST (dialog->ctree)->vadjustment);
gtk_widget_set_usize (sw, 300, 170);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_set_border_width (GTK_CONTAINER (sw), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (sw), dialog->ctree);
gtk_container_add (GTK_CONTAINER (frame), sw);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
frame, FALSE, FALSE, 0);
frame = gtk_frame_new (_("Program to run"));
gtk_container_set_border_width (GTK_CONTAINER (dialog->entry), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (frame), dialog->entry);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
frame, FALSE, FALSE, 0);
gnome_dialog_append_button (GNOME_DIALOG(dialog),
GNOME_STOCK_BUTTON_OK);
gnome_dialog_append_button (GNOME_DIALOG(dialog),
GNOME_STOCK_BUTTON_CANCEL);
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
return GTK_WIDGET (dialog);
}

61
gnome/gnome-open-dialog.h Normal file
View File

@ -0,0 +1,61 @@
/* gnome-open-dialog.h
* Copyright (C) 1999 Red Hat Software. Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GNOME_OPEN_DIALOG_H__
#define __GNOME_OPEN_DIALOG_H__
#include <gnome.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define GNOME_TYPE_OPEN_DIALOG (gnome_open_dialog_get_type ())
#define GNOME_OPEN_DIALOG(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_OPEN_DIALOG, GnomeOpenDialog))
#define GNOME_OPEN_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_OPEN_DIALOG, GnomeOpenDialogClass))
#define GNOME_IS_OPEN_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_OPEN_DIALOG))
#define GNOME_IS_OPEN_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GNOME_TYPE_OPEN_DIALOG))
typedef struct _GnomeOpenDialog GnomeOpenDialog;
typedef struct _GnomeOpenDialogClass GnomeOpenDialogClass;
struct _GnomeOpenDialog
{
GnomeDialog parent;
gchar *file_name;
GtkWidget *ctree;
GtkWidget *entry;
};
struct _GnomeOpenDialogClass
{
GnomeDialogClass parent_class;
};
GtkType gnome_open_dialog_get_type (void);
GtkWidget *gnome_open_dialog_new (gchar *file_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GNOME_OPEN_DIALOG_H__ */

View File

@ -83,7 +83,7 @@ panel_action_edit (GtkWidget *widget, WPanel *panel)
{
char *full = g_concat_dir_and_file (panel->cwd, selection (panel)->fname);
gmc_edit_filename (full);
gmc_edit (full);
g_free (full);
}
@ -161,7 +161,7 @@ panel_action_properties (GtkWidget *widget, WPanel *panel)
/* if (item_properties (GTK_WIDGET (CLIST_FROM_SW (panel->list)), full_name, NULL) != 0)
reread_cmd ();*/
dlg = gnome_file_property_dialog_new (full_name, we_can_afford_the_speed);
gnome_dialog_set_parent (GNOME_DIALOG (dlg), GTK_WINDOW (gtk_widget_get_toplevel (panel->ministatus)));
gnome_dialog_set_parent (GNOME_DIALOG (dlg), GTK_WINDOW (panel->xwindow));
if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0)
retval = gnome_file_property_dialog_make_changes (GNOME_FILE_PROPERTY_DIALOG (dlg));
gtk_widget_destroy (dlg);

View File

@ -14,7 +14,7 @@
#include "panel.h"
#include "gdesktop.h"
int gpopup_do_popup2 (GdkEventButton *event, WPanel *panel);
int gpopup_do_popup2 (GdkEventButton *event, WPanel *panel, DesktopIconInfo *dii);
int gpopup_do_popup (GdkEventButton *event, WPanel *from_panel,
DesktopIconInfo *dii,

View File

@ -23,6 +23,8 @@
#include "gpageprop.h"
#include "gpopup.h"
#include "gnome-file-property-dialog.h"
#include "gnome-open-dialog.h"
#include "gmain.h"
#define CLIST_FROM_SW(panel_list) GTK_CLIST (GTK_BIN (panel_list)->child)
@ -40,16 +42,23 @@ enum {
F_MIME_ACTIONS = 1 << 7 /* Special marker for the position of MIME actions */
};
/* typedefs */
/* An entry in the actions menu */
typedef gboolean (*menu_func) (WPanel *panel, DesktopIconInfo *dii);
struct action {
char *text; /* Menu item text */
int flags; /* Flags from the above enum */
gpointer callback; /* Callback for menu item */
menu_func func; /* NULL if item is always present; a predicate otherwise */
};
/* Multiple File commands */
static void handle_open (GtkWidget *widget, WPanel *panel);
static void handle_mount (GtkWidget *widget, WPanel *panel);
static void handle_unmount (GtkWidget *widget, WPanel *panel);
static void handle_eject (GtkWidget *widget, WPanel *panel);
static void handle_view (GtkWidget *widget, WPanel *panel);
static void handle_view_unfiltered (GtkWidget *widget, WPanel *panel);
static void handle_edit (GtkWidget *widget, WPanel *panel);
@ -60,47 +69,164 @@ static void handle_move (GtkWidget *widget, WPanel *panel);
/* F_SINGLE file commands */
static void handle_properties (GtkWidget *widget, WPanel *panel);
static void handle_open_with (GtkWidget *widget, WPanel *panel);
static void handle_hard_link (GtkWidget *widget, WPanel *panel);
static void handle_symlink (GtkWidget *widget, WPanel *panel);
static void handle_hard_link (GtkWidget *widget, WPanel *panel);
static void handle_edit_symlink (GtkWidget *widget, WPanel *panel);
/* Helper funcs and testing funcs. */
static gboolean check_mount_func (WPanel *panel, DesktopIconInfo *dii);
static gboolean check_unmount_func (WPanel *panel, DesktopIconInfo *dii);
static gboolean check_eject_func (WPanel *panel, DesktopIconInfo *dii);
static gboolean check_edit_func (WPanel *panel, DesktopIconInfo *dii);
static gboolean check_view_func (WPanel *panel, DesktopIconInfo *dii);
static gchar * get_full_filename (WPanel *panel);
/* Now, the actual code */
static gchar *
get_full_filename (WPanel *panel)
{
if (is_a_desktop_panel (panel)) {
gint i;
for (i = 0; i < panel->count; i++)
if (panel->dir.list [i].f.marked) {
return concat_dir_and_file (panel->cwd,
panel->dir.list [i].fname);
}
g_return_val_if_fail (FALSE, NULL);
} else
return concat_dir_and_file (panel->cwd, selection (panel)->fname);
}
static gboolean
check_mount_umount (DesktopIconInfo *dii, int mount)
{
char *full_name;
file_entry *fe;
int v;
int is_mounted;
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
fe = file_entry_from_file (full_name);
if (!fe) {
g_free (full_name);
return FALSE;
}
v = is_mountable (full_name, fe, &is_mounted, NULL);
file_entry_free (fe);
g_free (full_name);
if (!v)
return FALSE;
if (is_mounted && mount)
return FALSE;
if (!is_mounted && !mount)
return FALSE;
return TRUE;
}
static gboolean
check_mount_func (WPanel *panel, DesktopIconInfo *dii)
{
if (!dii)
return FALSE;
return check_mount_umount (dii, TRUE);
}
static gboolean
check_unmount_func (WPanel *panel, DesktopIconInfo *dii)
{
if (!dii)
return FALSE;
return check_mount_umount (dii, FALSE);
}
static gboolean
check_eject_func (WPanel *panel, DesktopIconInfo *dii)
{
char *full_name;
file_entry *fe;
int v;
int is_mounted;
int retval;
if (!dii)
return FALSE;
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
fe = file_entry_from_file (full_name);
if (!fe) {
g_free (full_name);
return FALSE;
}
v = is_mountable (full_name, fe, &is_mounted, NULL);
file_entry_free (fe);
if (!v)
retval = FALSE;
else if (!is_ejectable (full_name))
retval = FALSE;
else
retval = TRUE;
g_free (full_name);
return retval;
}
static gboolean
check_edit_func (WPanel *panel, DesktopIconInfo *dii)
{
/* As far as I can tell, by looking at gactions.c, edit will _ALWAYS work */
return TRUE;
}
static gboolean
check_view_func (WPanel *panel, DesktopIconInfo *dii)
{
gchar *full_name;
if (is_a_desktop_panel (panel)) {
g_assert (dii != NULL);
full_name = g_concat_dir_and_file (panel->cwd, dii->filename);
} else
full_name = g_concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
return gmc_can_view_file (full_name);
}
/* global vars */
extern int we_can_afford_the_speed;
static struct action file_actions[] = {
{ N_("Open"), F_NOTDEV, handle_open },
{ "", F_NOTDEV, NULL },
{ "", F_MIME_ACTIONS, NULL },
{ N_("Open with..."), F_REGULAR | F_SINGLE, handle_open_with },
{ N_("View"), F_REGULAR | F_SINGLE, handle_view },
{ N_("View Unfiltered"), F_REGULAR | F_ADVANCED | F_SINGLE, handle_view_unfiltered },
{ N_("Edit"), F_REGULAR | F_SINGLE, handle_edit },
{ "", F_REGULAR | F_SINGLE, NULL },
{ N_("Copy..."), F_ALL, handle_copy },
{ N_("Delete"), F_ALL, handle_delete },
{ N_("Move..."), F_ALL, handle_move },
{ N_("Hard Link..."), F_ADVANCED | F_SINGLE, handle_hard_link },
{ N_("Symlink..."), F_SINGLE, handle_symlink },
{ N_("Edit Symlink..."), F_SYMLINK | F_SINGLE, handle_edit_symlink },
{ "", F_SINGLE | F_ALL, NULL },
{ N_("Properties..."), F_SINGLE | F_ALL, handle_properties },
{ NULL, 0, NULL }
{ N_("Open"), F_NOTDEV | F_SINGLE, handle_open, NULL },
{ N_("Mount device"), F_ALL | F_SINGLE, handle_mount, check_mount_func },
{ N_("Unmount device"), F_ALL | F_SINGLE, handle_unmount, check_unmount_func },
{ N_("Eject device"), F_ALL | F_SINGLE, handle_eject, check_eject_func },
{ "", F_NOTDEV | F_SINGLE, NULL, NULL },
{ "", F_MIME_ACTIONS | F_SINGLE, NULL, NULL },
{ N_("Open with..."), F_REGULAR | F_SINGLE, handle_open_with, NULL },
{ N_("View"), F_REGULAR | F_SINGLE, handle_view, check_view_func },
{ N_("View Unfiltered"), F_REGULAR | F_ADVANCED | F_SINGLE, handle_view_unfiltered, NULL },
{ N_("Edit"), F_REGULAR | F_SINGLE, handle_edit, check_edit_func },
{ "", F_REGULAR | F_SINGLE, NULL, NULL },
{ N_("Copy..."), F_ALL, handle_copy, NULL },
{ N_("Delete"), F_ALL, handle_delete, NULL },
{ N_("Move..."), F_ALL, handle_move, NULL },
{ N_("Hard Link..."), F_ADVANCED | F_SINGLE, handle_hard_link, NULL },
{ N_("Symlink..."), F_SINGLE, handle_symlink, NULL },
{ N_("Edit Symlink..."), F_SYMLINK | F_SINGLE, handle_edit_symlink, NULL },
{ "", F_SINGLE | F_ALL, NULL, NULL },
{ N_("Properties..."), F_SINGLE | F_ALL, handle_properties, NULL },
{ NULL, 0, NULL, NULL }
};
#if 0
static action generic_actions[] = {
{ N_("NEW(FIXME)"), F_ALL, NULL },
{ "", F_ALL, NULL },
{ N_("Change Background"), F_DICON, handle_display_properties },
{ N_("Rescan Directory"), F_ALL, handle_rescan },
{ N_("Arrange Icons"), F_DICON, handle_arrange_icons },
{ N_(""), F_DICON, NULL },
{ N_("Logout"), F_DICON, handle_logout },
{ NULL, 0, NULL }
};
#endif
/* This is our custom signal connection function for popup menu items -- see below for the
* marshaller information. We pass the original callback function as the data pointer for the
* marshaller (uiinfo->moreinfo).
@ -184,7 +310,7 @@ mime_action_callback (GtkWidget *widget, gpointer data)
const char *value;
int needs_terminal = 0;
int size;
filename = data;
key = gtk_object_get_user_data (GTK_OBJECT (widget));
@ -219,17 +345,23 @@ mime_action_callback (GtkWidget *widget, gpointer data)
* file in the panel.
*/
static int
create_mime_actions (GtkWidget *menu, WPanel *panel, int pos)
create_mime_actions (GtkWidget *menu, WPanel *panel, int pos, DesktopIconInfo *dii)
{
char *full_name;
const char *mime_type;
GList *keys, *l;
gint pos_init = pos;
GnomeUIInfo uiinfo[] = {
{ 0 },
GNOMEUIINFO_END
};
full_name = g_concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
if (is_a_desktop_panel (panel)) {
g_assert (dii != NULL);
full_name = g_concat_dir_and_file (panel->cwd, dii->filename);
} else
full_name = g_concat_dir_and_file (panel->cwd,
panel->dir.list[panel->selected].fname);
mime_type = gnome_mime_type_or_default (full_name, NULL);
g_free (full_name);
@ -279,8 +411,11 @@ create_mime_actions (GtkWidget *menu, WPanel *panel, int pos)
(GtkSignalFunc) free_on_destroy,
full_name);
}
g_list_free (keys);
if (pos_init != pos) {
uiinfo[0].type = GNOME_APP_UI_SEPARATOR;
fill_menu (GTK_MENU_SHELL (menu), uiinfo, pos++);
g_list_free (keys);
}
return pos;
}
@ -288,7 +423,7 @@ create_mime_actions (GtkWidget *menu, WPanel *panel, int pos)
* which additional menu items should be inserted.
*/
static void
create_actions (GtkWidget *menu, gint flags, WPanel *panel)
create_actions (GtkWidget *menu, gint flags, WPanel *panel, DesktopIconInfo *dii)
{
struct action *action;
int pos;
@ -302,7 +437,7 @@ create_actions (GtkWidget *menu, gint flags, WPanel *panel)
for (action = file_actions; action->text; action++) {
/* Insert the MIME actions if appropriate */
if ((action->flags & F_MIME_ACTIONS) && (flags & F_SINGLE)) {
pos = create_mime_actions (menu, panel, pos);
pos = create_mime_actions (menu, panel, pos, dii);
continue;
}
@ -310,6 +445,9 @@ create_actions (GtkWidget *menu, gint flags, WPanel *panel)
if ((action->flags & flags) != action->flags)
continue;
if (action->func && !((action->func)(panel, dii)))
continue;
/* Create the menu item for this action */
if (action->text[0]) {
uiinfo[0].type = GNOME_APP_UI_ITEM;
@ -357,7 +495,7 @@ get_active_index (GtkMenu *menu)
#define REMOVE(x,f) x &= ~f
int
gpopup_do_popup2 (GdkEventButton *event, WPanel *panel)
gpopup_do_popup2 (GdkEventButton *event, WPanel *panel, DesktopIconInfo *dii)
{
GtkWidget *menu;
gint flags = F_ALL | F_REGULAR | F_SYMLINK | F_SINGLE | F_NOTDEV | F_NOTDIR;
@ -409,7 +547,7 @@ gpopup_do_popup2 (GdkEventButton *event, WPanel *panel)
REMOVE (flags, F_SINGLE);
/* Fill the menu */
create_actions (menu, flags, panel);
create_actions (menu, flags, panel, dii);
/* Run it */
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
@ -420,35 +558,93 @@ gpopup_do_popup2 (GdkEventButton *event, WPanel *panel)
gtk_signal_disconnect (GTK_OBJECT (menu), id);
i = get_active_index (GTK_MENU (menu));
gtk_widget_destroy (menu);
gtk_widget_unref (menu);
return i;
}
static void
handle_open (GtkWidget *widget, WPanel *panel)
{
if (do_enter (panel))
return;
gchar *full_name;
DesktopIconInfo *dii;
handle_open_with (widget, panel);
if (is_a_desktop_panel (panel)) {
dii = desktop_icon_info_get_by_filename (selection (panel)->fname);
g_assert (dii != NULL);
desktop_icon_info_open (dii);
return;
}
full_name = get_full_filename (panel);
if (gmc_open_filename (full_name, 0))
return;
gmc_open_with (full_name);
g_free (full_name);
}
static void
handle_mount (GtkWidget *widget, WPanel *panel)
{
char *full_name;
g_assert (is_a_desktop_panel (panel));
full_name = g_concat_dir_and_file (desktop_directory, selection (panel)->fname);
do_mount_umount (full_name, TRUE);
g_free (full_name);
}
static void
handle_unmount (GtkWidget *widget, WPanel *panel)
{
char *full_name;
g_assert (is_a_desktop_panel (panel));
full_name = g_concat_dir_and_file (desktop_directory, selection (panel)->fname);
do_mount_umount (full_name, FALSE);
g_free (full_name);
}
static void
handle_eject (GtkWidget *widget, WPanel *panel)
{
char *full_name;
g_assert (is_a_desktop_panel (panel));
full_name = g_concat_dir_and_file (desktop_directory, selection (panel)->fname);
do_mount_umount (full_name, FALSE);
do_eject (full_name);
g_free (full_name);
}
static void
handle_view (GtkWidget *widget, WPanel *panel)
{
view_cmd (panel);
gchar *full_name;
full_name = get_full_filename (panel);
gmc_view (full_name, 0);
g_free (full_name);
}
static void
handle_view_unfiltered (GtkWidget *widget, WPanel *panel)
{
view_simple_cmd (panel);
/* We need it to do the right thing later. */
/*view_simple_cmd (panel);*/
return;
}
static void
handle_edit (GtkWidget *widget, WPanel *panel)
{
edit_cmd (panel);
gchar *full_name;
full_name = get_full_filename (panel);
gmc_edit (full_name);
g_free (full_name);
}
static void
@ -473,40 +669,43 @@ handle_move (GtkWidget *widget, WPanel *panel)
static void
handle_properties (GtkWidget *widget, WPanel *panel)
{
gint retval;
file_entry *fe;
char *full_name;
GtkWidget *dlg;
gint retval = 0;
GtkWidget *dialog;
gchar *full_name = NULL;
DesktopIconInfo *dii;
fe = &panel->dir.list [panel->selected];
full_name = concat_dir_and_file (panel->cwd, fe->fname);
full_name = get_full_filename (panel);
dialog = gnome_file_property_dialog_new (full_name,
(is_a_desktop_panel (panel)
? TRUE
: we_can_afford_the_speed));
dlg = gnome_file_property_dialog_new (full_name, we_can_afford_the_speed);
gnome_dialog_set_parent (GNOME_DIALOG (dlg),
GTK_WINDOW (gtk_widget_get_toplevel (panel->ministatus)));
if (!is_a_desktop_panel (panel))
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (panel->xwindow));
if (gnome_dialog_run (GNOME_DIALOG (dlg)) == 0)
retval = gnome_file_property_dialog_make_changes (GNOME_FILE_PROPERTY_DIALOG (dlg));
if (gnome_dialog_run (GNOME_DIALOG (dialog)) == 0)
retval = gnome_file_property_dialog_make_changes (
GNOME_FILE_PROPERTY_DIALOG (dialog));
gtk_widget_destroy (dlg);
if (is_a_desktop_panel (panel)) {
dii = desktop_icon_info_get_by_filename (selection (panel)->fname);
g_assert (dii != NULL);
desktop_icon_update_url (dii);
}
gtk_widget_destroy (dialog);
g_free (full_name);
if (retval)
if (retval && !is_a_desktop_panel (panel))
reread_cmd ();
}
static void
handle_open_with (GtkWidget *widget, WPanel *panel)
{
char *command;
command = input_expand_dialog (_("Open with"),
_("Enter extra arguments:"),
panel->dir.list [panel->selected].fname);
if (!command)
return;
execute (command);
g_free (command);
gchar *full_name;
full_name = get_full_filename (panel);
gmc_open_with (full_name);
g_free (full_name);
}
static void
@ -528,8 +727,3 @@ handle_edit_symlink (GtkWidget *widget, WPanel *panel)
edit_symlink_cmd ();
}
static void
handle_rescan (GtkWidget *widget, WPanel *panel)
{
reread_cmd ();
}

View File

@ -10,6 +10,7 @@
#include "util.h"
#include <libgnome/libgnome.h>
#include "gdesktop.h"
#include "gprint.h"
void
gprint_setup_devices (void)

15
gnome/gprint.h Normal file
View File

@ -0,0 +1,15 @@
/* Printing support for the Midnight Commander
*
* Copyright (C) 1998-1999 The Free Software Foundation
*
* Author: Miguel de Icaza <miguel@nuclecu.unam.mx>
*/
#ifndef GPRINT_H
#define GPRINT_H
void gprint_setup_devices (void);
#endif

View File

@ -309,6 +309,9 @@ x_panel_select_item (WPanel *panel, int index, int value)
void
x_select_item (WPanel *panel)
{
if (is_a_desktop_panel (panel))
return;
do_file_mark (panel, panel->selected, 1);
display_mini_info (panel);
@ -469,8 +472,8 @@ panel_file_list_press_row (GtkWidget *file_list, GdkEvent *event, WPanel *panel)
event->button.x, event->button.y,
&row, &column)) {
gtk_clist_select_row (GTK_CLIST (file_list), row, 0);
#if 0
gpopup_do_popup2 ((GdkEventButton *) event, panel);
#if 1
gpopup_do_popup2 ((GdkEventButton *) event, panel, NULL);
#else
gpopup_do_popup ((GdkEventButton *) event, panel,
NULL, row, panel->dir.list[row].fname);
@ -1403,8 +1406,8 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan
switch (event->type){
case GDK_BUTTON_PRESS:
if (event->button.button == 3) {
#if 0
gpopup_do_popup2 ((GdkEventButton *) event, panel);
#if 1
gpopup_do_popup2 ((GdkEventButton *) event, panel, NULL);
#else
gpopup_do_popup ((GdkEventButton *) event, panel,
NULL, index, panel->dir.list[index].fname);

View File

@ -16,4 +16,5 @@ typedef struct {
extern PanelContainer *current_panel_ptr, *other_panel_ptr;
extern GList *containers;
#endif /* __GSCREEN_H */

View File

@ -1,3 +1,17 @@
1999-03-10 Federico Mena Quintero <federico@nuclecu.unam.mx>
* file.c (erase_dir): Erase metadata for directories as well.
(erase_dir_iff_empty): Likewise.
(copy_file_file): Delete/copy the metadata even for
char/block/sock/fifo files. Same thing for when copying symlinks.
(copy_dir_dir): Delete/copy the metadata.
(move_dir_dir): Delete/move the metadata.
(recursive_erase): Delete the metadata.
1999-03-08 Federico Mena Quintero <federico@nuclecu.unam.mx>
* file.c (real_query_recursive): Removed an unused variable.
1999-03-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
* utilunix.c (g_readlink): New function. Wraps all the nonsense
@ -47,6 +61,11 @@ Mon Mar 1 00:18:48 1999 Timur Bakeyev <mc@bat.ru>
update_gui, which controls whether we want to update the displayed
region in the GUI version.
1999-02-25 Jonathan Blandford <jrb@redhat.com>
* cmd.c (symlink_cmd): little change to handle the case when a
desktop panel is passed in.
1999-02-25 Owen Taylor <otaylor@redhat.com>
* fileopctx.h file.c: Moved recursive delete query

View File

@ -1091,16 +1091,41 @@ void link_cmd (void)
void symlink_cmd (void)
{
do_link (1, selection (cpanel)->fname);
char *filename;
if (is_a_desktop_panel (cpanel)) {
gint i;
for (i = 0; i < cpanel->count; i++)
if (cpanel->dir.list [i].f.marked) {
filename = cpanel->dir.list [i].fname;
break;
}
} else {
filename = selection (cpanel)->fname;
}
do_link (1, filename);
}
void edit_symlink_cmd (void)
{
#ifndef HAVE_GNOME
/* GNOME already checks this, and selection(cpanel) does bbad things */
if (S_ISLNK (selection (cpanel)->buf.st_mode)) {
char buffer [MC_MAXPATHLEN], *p = selection (cpanel)->fname;
#endif
char buffer [MC_MAXPATHLEN];
char *p = NULL;
int i;
char *dest, *q = g_strconcat (_(" Symlink "), name_trunc (p, 32), _(" points to:"), NULL);
if (is_a_desktop_panel (cpanel)) {
gint i;
for (i = 0; i < cpanel->count; i++)
if (cpanel->dir.list [i].f.marked) {
p = cpanel->dir.list [i].fname;
break;
}
} else {
p = selection (cpanel)->fname;
}
i = readlink (p, buffer, MC_MAXPATHLEN);
if (i > 0) {
buffer [i] = 0;
@ -1123,7 +1148,9 @@ void edit_symlink_cmd (void)
}
}
g_free (q);
#ifndef HAVE_GNOME
}
#endif
}
void other_symlink_cmd (void)

View File

@ -554,9 +554,19 @@ copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path, int ask_over
return return_status;
}
if (S_ISLNK (sb.st_mode))
return make_symlink (ctx, src_path, dst_path);
if (S_ISLNK (sb.st_mode)) {
int retval;
retval = make_symlink (ctx, src_path, dst_path);
#ifdef HAVE_GNOME
if (retval == FILE_CONT) {
gnome_metadata_delete (dst_path);
gnome_metadata_copy (src_path, dst_path);
}
#endif
return retval;
}
#endif /* !OS_NT */
if (S_ISCHR (sb.st_mode) || S_ISBLK (sb.st_mode) || S_ISFIFO (sb.st_mode)
@ -585,6 +595,10 @@ copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path, int ask_over
continue;
return temp_status;
}
#endif
#ifdef HAVE_GNOME
gnome_metadata_delete (dst_path);
gnome_metadata_copy (src_path, dst_path);
#endif
return FILE_CONT;
}
@ -806,7 +820,8 @@ copy_file_file (FileOpContext *ctx, char *src_path, char *dst_path, int ask_over
#endif
#ifdef HAVE_GNOME
gnome_metadata_copy (src_path, dst_path);
gnome_metadata_delete (dst_path);
gnome_metadata_copy (src_path, dst_path);
#endif
/*
* .ado: according to the XPG4 standard, the file must be closed before
@ -907,6 +922,10 @@ copy_dir_dir (FileOpContext *ctx, char *s, char *d, int toplevel,
if (move_over){
if (mc_rename (s, d) == 0){
#ifdef HAVE_GNOME
gnome_metadata_delete (d);
gnome_metadata_copy (s, d);
#endif
g_free (parent_dirs);
return FILE_CONT;
}
@ -949,6 +968,11 @@ copy_dir_dir (FileOpContext *ctx, char *s, char *d, int toplevel,
goto ret;
}
#ifdef HAVE_GNOME
gnome_metadata_delete (dest_dir);
gnome_metadata_copy (s, dest_dir);
#endif
lp = g_new (struct link, 1);
mc_stat (dest_dir, &buf);
lp->vfs = vfs_type (dest_dir);
@ -1061,6 +1085,9 @@ move_file_file (FileOpContext *ctx, char *s, char *d, long *progress_count, doub
{
struct stat src_stats, dst_stats;
int return_status = FILE_CONT;
#ifdef HAVE_GNOME
int delete_metadata = TRUE;
#endif
if (file_progress_show_source (ctx, s) == FILE_ABORT
|| file_progress_show_target (ctx, d) == FILE_ABORT)
@ -1115,14 +1142,20 @@ move_file_file (FileOpContext *ctx, char *s, char *d, long *progress_count, doub
if (!ctx->do_append) {
if (S_ISLNK (src_stats.st_mode) && ctx->stable_symlinks) {
if ((return_status = make_symlink (ctx, s, d)) == FILE_CONT)
if ((return_status = make_symlink (ctx, s, d)) == FILE_CONT) {
#ifdef HAVE_GNOME
gnome_metadata_delete (d);
gnome_metadata_rename (s, d);
delete_metadata = FALSE;
#endif
goto retry_src_remove;
else
} else
return return_status;
}
if (mc_rename (s, d) == 0){
#ifdef HAVE_GNOME
gnome_metadata_delete (d);
gnome_metadata_rename (s, d);
#endif
return FILE_CONT;
@ -1163,7 +1196,8 @@ move_file_file (FileOpContext *ctx, char *s, char *d, long *progress_count, doub
return return_status;
}
#ifdef HAVE_GNOME
gnome_metadata_delete (s);
if (delete_metadata)
gnome_metadata_delete (s);
#endif
if (return_status == FILE_CONT)
@ -1222,6 +1256,10 @@ move_dir_dir (FileOpContext *ctx, char *s, char *d, long *progress_count, double
retry_rename:
if (mc_rename (s, destdir) == 0){
#ifdef HAVE_GNOME
gnome_metadata_delete (destdir);
gnome_metadata_rename (s, destdir);
#endif
return_status = FILE_CONT;
goto ret;
}
@ -1364,6 +1402,9 @@ recursive_erase (FileOpContext *ctx, char *s, long *progress_count, double *prog
goto retry_rmdir;
return return_status;
}
#ifdef HAVE_GNOME
gnome_metadata_delete (s);
#endif
return FILE_CONT;
}
@ -1431,6 +1472,9 @@ erase_dir (FileOpContext *ctx, char *s, long *progress_count, double *progress_b
goto retry_rmdir;
return error;
}
#ifdef HAVE_GNOME
gnome_metadata_delete (s);
#endif
return FILE_CONT;
}
@ -1460,6 +1504,9 @@ erase_dir_iff_empty (FileOpContext *ctx, char *s)
goto retry_rmdir;
return error;
}
#ifdef HAVE_GNOME
gnome_metadata_delete (s);
#endif
return FILE_CONT;
}
@ -1479,7 +1526,7 @@ panel_get_file (WPanel *panel, struct stat *stat_buf)
mc_stat (tree->selected_ptr->name, stat_buf);
return tree->selected_ptr->name;
}
}
if (panel->marked){
for (i = 0; i < panel->count; i++)
@ -1952,14 +1999,10 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault, in
}
} /* Copy or move operation */
if (value == FILE_CONT)
if (value == FILE_CONT && !(is_a_desktop_panel(panel)))
unmark_files (panel);
} else {
/* Many files */
/* Need to determine this.*/
#ifdef HAVE_GNOME
int policy_over_write_necessary = 1;
#endif
/* Check destination for copy or move operation */
if (operation != OP_DELETE){
@ -1983,27 +2026,13 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault, in
ctx->progress_bytes = panel->total;
}
#ifdef HAVE_GNOME
if (operation != OP_DELETE){
/* FIXME: we need to determine if this dialog is actually needed. */
/* We need to pre-copy all the files and see if there are any
* over-writes. Ugh, this sounds yucky. )-: */
if (policy_over_write_necessary) {
if (file_progress_query_replace_policy (ctx, TRUE) == FILE_ABORT)
goto clean_up;
else
/* this will initialize some variables */
file_progress_query_replace_policy (ctx, FALSE);
}
}
#endif
/* Loop for every file, perform the actual copy operation */
for (i = 0; i < panel->count; i++) {
if (!panel->dir.list [i].f.marked)
continue; /* Skip the unmarked ones */
source = panel->dir.list [i].fname;
src_stat = panel->dir.list [i].buf; /* Inefficient, should we use pointers? */
src_stat = panel->dir.list [i].buf;
#ifdef WITH_FULL_PATHS
if (source_with_path)
@ -2058,9 +2087,16 @@ panel_operate (void *source_panel, FileOperation operation, char *thedefault, in
if (value == FILE_ABORT)
goto clean_up;
#ifdef HAVE_GNOME
/* if panel->selection is -1, then we have a desktop panel. */
if (value == FILE_CONT && !(is_a_desktop_panel(panel)))
do_file_mark (panel, i, 0);
#else
if (value == FILE_CONT)
do_file_mark (panel, i, 0);
do_file_mark (panel, i, 0);
#endif
if (file_progress_show_count (ctx, count, ctx->progress_count) == FILE_ABORT)
goto clean_up;
@ -2181,7 +2217,7 @@ files_error (char *format, char *file1, char *file2)
static int
real_query_recursive (FileOpContext *ctx, enum OperationMode mode, char *s)
{
char *confirm, *textb;
char *confirm;
gchar *text;
if (ctx->recursive_result < RECURSIVE_ALWAYS){

View File

@ -158,6 +158,7 @@ typedef struct {
int drag_motion_x;
int drag_motion_y;
void *panel_listbox; /* container for the list */
int is_a_desktop_panel;
#endif
} WPanel;
@ -176,7 +177,11 @@ extern int show_mini_info;
extern int panel_scroll_pages;
#define selection(p) (&(p->dir.list [p->selected]))
#ifdef HAVE_GNOME
#define is_a_desktop_panel(p) ((p->is_a_desktop_panel))
#else
#define is_a_desktop_panel(p) FALSE
#endif
extern int fast_reload;
extern int extra_info;

View File

@ -1000,6 +1000,9 @@ panel_new (char *panel_name)
panel->format = 0;
panel->status_format = 0;
panel->format_modified = 1;
#ifdef HAVE_GNOME
panel->is_a_desktop_panel = FALSE;
#endif
panel->panel_name = g_strdup (panel_name);
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);

View File

@ -1441,7 +1441,9 @@ search (WView *view, char *text, int (*search)(WView *, char *, char *, int))
Dlg_head *d = 0;
int search_status;
int abort;
void *gd;
#ifdef HAVE_GNOME
GtkWidget *gd;
#endif
/* Used to keep track of where the line starts, when looking forward */
/* is the index before transfering the line; the reverse case uses */
@ -1833,13 +1835,6 @@ toggle_hex_mode (WView *view)
view_update (view, TRUE);
}
/* Both views */
static void
toggle_hexedit_mode(WView *view)
{
view->hexedit_mode = 1 - view->hexedit_mode;
}
/* Both views */
void
goto_line (WView *view)