1998-10-30 03:47:54 +03:00
|
|
|
/* Desktop management for the Midnight Commander
|
|
|
|
*
|
1999-02-17 03:38:16 +03:00
|
|
|
* Copyright (C) 1998-1999 The Free Software Foundation
|
1998-02-27 08:10:44 +03:00
|
|
|
*
|
1998-10-30 03:47:54 +03:00
|
|
|
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
|
|
|
* Miguel de Icaza <miguel@nuclecu.unam.mx>
|
1998-02-27 08:10:44 +03:00
|
|
|
*/
|
1998-11-07 04:19:53 +03:00
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
#include <config.h>
|
1999-01-31 00:52:40 +03:00
|
|
|
#include "global.h"
|
1998-12-03 02:37:27 +03:00
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#include <gtk/gtkinvisible.h>
|
1998-10-30 03:47:54 +03:00
|
|
|
#include <gnome.h>
|
1998-10-31 02:22:35 +03:00
|
|
|
#include "dialog.h"
|
1998-12-07 05:36:47 +03:00
|
|
|
#define DIR_H_INCLUDE_HANDLE_DIRENT /* bleah */
|
|
|
|
#include "dir.h"
|
1999-01-14 04:10:32 +03:00
|
|
|
#include "ext.h"
|
1998-12-30 05:51:01 +03:00
|
|
|
#include "file.h"
|
1999-01-14 04:10:32 +03:00
|
|
|
#include "fileopctx.h"
|
1999-01-02 21:41:59 +03:00
|
|
|
#include "gconf.h"
|
1998-10-30 03:47:54 +03:00
|
|
|
#include "gdesktop.h"
|
1998-10-31 02:22:35 +03:00
|
|
|
#include "gdesktop-icon.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
#include "gdesktop-init.h"
|
1998-12-09 20:23:38 +03:00
|
|
|
#include "gicon.h"
|
1998-12-07 05:36:47 +03:00
|
|
|
#include "gmain.h"
|
1998-10-30 20:08:03 +03:00
|
|
|
#include "gmetadata.h"
|
1999-03-11 05:40:53 +03:00
|
|
|
#include "gcmd.h"
|
1998-12-03 02:37:27 +03:00
|
|
|
#include "gdnd.h"
|
1998-11-25 06:29:23 +03:00
|
|
|
#include "gpopup.h"
|
1999-09-20 20:34:38 +04:00
|
|
|
#include "gprint.h"
|
1999-03-11 05:40:53 +03:00
|
|
|
#include "gscreen.h"
|
1998-10-30 03:47:54 +03:00
|
|
|
#include "../vfs/vfs.h"
|
1999-02-05 01:30:54 +03:00
|
|
|
#include "main.h"
|
1999-03-20 21:08:52 +03:00
|
|
|
#include "gmount.h"
|
2001-06-15 10:50:31 +04:00
|
|
|
#include "gprefs.h"
|
1998-10-30 03:47:54 +03:00
|
|
|
|
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
struct layout_slot {
|
1998-12-11 11:58:26 +03:00
|
|
|
int num_icons; /* Number of icons in this slot */
|
|
|
|
GList *icons; /* The list of icons in this slot */
|
1998-11-03 04:32:38 +03:00
|
|
|
};
|
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
|
1998-10-30 20:08:03 +03:00
|
|
|
/* Configuration options for the desktop */
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
int desktop_use_shaped_icons = TRUE;
|
1998-10-30 20:08:03 +03:00
|
|
|
int desktop_auto_placement = FALSE;
|
1999-02-16 01:48:00 +03:00
|
|
|
int desktop_snap_icons = FALSE;
|
1999-08-09 07:41:39 +04:00
|
|
|
int desktop_arr_r2l = FALSE;
|
|
|
|
int desktop_arr_b2t = FALSE;
|
|
|
|
int desktop_arr_rows = FALSE;
|
1998-10-30 03:47:54 +03:00
|
|
|
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
/*
|
|
|
|
* Possible values for this one:
|
|
|
|
*
|
|
|
|
* 0 -- Enable shaped text only if window manager is GNOME compliant
|
|
|
|
* 1 -- Enable shaped text always
|
|
|
|
* 2 -- Disable shaped text
|
|
|
|
*
|
2000-01-25 13:30:53 +03:00
|
|
|
* This might seem a bit strange, but it is like that for compatibility reasons.
|
|
|
|
*/
|
|
|
|
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
int desktop_use_shaped_text = 0;
|
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
/* The computed name of the user's desktop directory */
|
1999-02-17 05:18:12 +03:00
|
|
|
char *desktop_directory;
|
1998-10-30 03:47:54 +03:00
|
|
|
|
2001-04-08 19:23:59 +04:00
|
|
|
/* Time of the last directory reload */
|
|
|
|
time_t desktop_dir_modify_time;
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Layout information: number of rows/columns for the layout slots, and the
|
|
|
|
* array of slots. Each slot is an integer that specifies the number of icons
|
|
|
|
* that belong to that slot.
|
1998-10-31 02:22:35 +03:00
|
|
|
*/
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
static int layout_spacer_width;
|
|
|
|
static int layout_spacer_height;
|
1998-12-07 18:47:00 +03:00
|
|
|
static int layout_screen_width;
|
|
|
|
static int layout_screen_height;
|
1998-10-30 03:47:54 +03:00
|
|
|
static int layout_cols;
|
|
|
|
static int layout_rows;
|
1998-11-03 04:32:38 +03:00
|
|
|
static struct layout_slot *layout_slots;
|
1998-10-30 03:47:54 +03:00
|
|
|
|
1999-02-23 04:56:09 +03:00
|
|
|
|
|
|
|
int desktop_wm_is_gnome_compliant = -1;
|
|
|
|
|
1998-11-03 19:29:47 +03:00
|
|
|
#define l_slots(u, v) (layout_slots[(u) * layout_rows + (v)])
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
/* The last icon to be selected */
|
1998-12-31 04:43:11 +03:00
|
|
|
static DesktopIconInfo *last_selected_icon;
|
1998-11-03 04:32:38 +03:00
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
/* Drag and drop sources and targets */
|
1998-12-05 04:01:13 +03:00
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
static GtkTargetEntry dnd_icon_sources[] = {
|
1999-01-21 12:46:01 +03:00
|
|
|
{ TARGET_MC_DESKTOP_ICON_TYPE, 0, TARGET_MC_DESKTOP_ICON },
|
|
|
|
{ TARGET_URI_LIST_TYPE, 0, TARGET_URI_LIST },
|
|
|
|
{ TARGET_TEXT_PLAIN_TYPE, 0, TARGET_TEXT_PLAIN },
|
|
|
|
{ TARGET_URL_TYPE, 0, TARGET_URL }
|
1998-12-05 04:01:13 +03:00
|
|
|
};
|
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
static GtkTargetEntry dnd_icon_targets[] = {
|
1999-01-21 12:46:01 +03:00
|
|
|
{ TARGET_MC_DESKTOP_ICON_TYPE, 0, TARGET_MC_DESKTOP_ICON },
|
1999-01-31 00:52:40 +03:00
|
|
|
{ TARGET_URI_LIST_TYPE, 0, TARGET_URI_LIST },
|
1999-02-03 14:46:01 +03:00
|
|
|
{ TARGET_URL_TYPE, 0, TARGET_URL }
|
1998-12-08 04:31:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static GtkTargetEntry dnd_desktop_targets[] = {
|
1999-01-21 12:46:01 +03:00
|
|
|
{ TARGET_MC_DESKTOP_ICON_TYPE, 0, TARGET_MC_DESKTOP_ICON },
|
1999-02-02 05:34:46 +03:00
|
|
|
{ TARGET_URI_LIST_TYPE, 0, TARGET_URI_LIST },
|
|
|
|
{ TARGET_URL_TYPE, 0, TARGET_URL }
|
1998-12-03 02:37:27 +03:00
|
|
|
};
|
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
static int dnd_icon_nsources = sizeof (dnd_icon_sources) / sizeof (dnd_icon_sources[0]);
|
|
|
|
static int dnd_icon_ntargets = sizeof (dnd_icon_targets) / sizeof (dnd_icon_targets[0]);
|
|
|
|
static int dnd_desktop_ntargets = sizeof (dnd_desktop_targets) / sizeof (dnd_desktop_targets[0]);
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
/* Proxy window for DnD and clicks on the desktop */
|
|
|
|
static GtkWidget *proxy_invisible;
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1998-12-08 00:07:27 +03:00
|
|
|
/* Offsets for the DnD cursor hotspot */
|
|
|
|
static int dnd_press_x, dnd_press_y;
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Whether a call to select_icon() is pending because the initial click on an
|
1999-01-21 20:38:38 +03:00
|
|
|
* icon needs to be resolved at button release time. Also, we store the
|
|
|
|
* event->state.
|
|
|
|
*/
|
1998-12-11 05:05:19 +03:00
|
|
|
static int dnd_select_icon_pending;
|
1999-01-21 20:38:38 +03:00
|
|
|
static guint dnd_select_icon_pending_state;
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Whether the button release signal on a desktop icon should be stopped due to
|
|
|
|
* the icon being selected by clicking on the text item.
|
|
|
|
*/
|
|
|
|
static int icon_select_on_text;
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Proxy window for clicks on the root window */
|
|
|
|
static GdkWindow *click_proxy_gdk_window;
|
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
/* GC for drawing the rubberband rectangle */
|
|
|
|
static GdkGC *click_gc;
|
|
|
|
|
|
|
|
/* Starting click position and event state for rubberbanding on the desktop */
|
|
|
|
static int click_start_x;
|
|
|
|
static int click_start_y;
|
|
|
|
static int click_start_state;
|
|
|
|
|
|
|
|
/* Current mouse position for rubberbanding on the desktop */
|
|
|
|
static int click_current_x;
|
|
|
|
static int click_current_y;
|
|
|
|
|
|
|
|
static int click_dragging;
|
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
static DesktopIconInfo *desktop_icon_info_new (char *filename, char *url, char *caption,
|
|
|
|
int xpos, int ypos);
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
static GHashTable *icon_hash;
|
1998-12-07 05:36:47 +03:00
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/* Convenience function to figure out the (x, y) position from a slot */
|
|
|
|
static void
|
|
|
|
get_pos_from_slot (int u, int v, int *x, int *y)
|
|
|
|
{
|
|
|
|
int xx, yy;
|
|
|
|
|
|
|
|
xx = (layout_spacer_width / 2) +
|
|
|
|
(u * (DESKTOP_SNAP_X + layout_spacer_width));
|
|
|
|
|
|
|
|
yy = (layout_spacer_height / 2) +
|
|
|
|
(v * (DESKTOP_SNAP_Y + layout_spacer_height));
|
|
|
|
|
|
|
|
*x = CLAMP (xx, 0, layout_screen_width);
|
|
|
|
*y = CLAMP (yy, 0, layout_screen_height);
|
|
|
|
|
|
|
|
}
|
1998-12-07 05:36:47 +03:00
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
/* Convenience function to figure out the slot corresponding to an (x, y) position */
|
|
|
|
static void
|
|
|
|
get_slot_from_pos (int x, int y, int *u, int *v)
|
|
|
|
{
|
1999-04-07 05:49:22 +04:00
|
|
|
int uu, vv;
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
uu = x / (DESKTOP_SNAP_X + layout_spacer_width);
|
|
|
|
vv = y / (DESKTOP_SNAP_Y + layout_spacer_height);
|
1999-04-07 05:49:22 +04:00
|
|
|
|
|
|
|
*u = CLAMP (uu, 0, layout_cols - 1);
|
|
|
|
*v = CLAMP (vv, 0, layout_rows - 1);
|
1999-02-16 01:44:18 +03:00
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Swaps two integer variables */
|
|
|
|
static void
|
|
|
|
swap (int *a, int *b)
|
|
|
|
{
|
1999-08-09 07:41:39 +04:00
|
|
|
int tmp;
|
|
|
|
|
|
|
|
tmp = *a;
|
|
|
|
*a = *b;
|
|
|
|
*b = tmp;
|
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
/* Looks for a free slot in the layout_slots array and returns the coordinates
|
|
|
|
* that coorespond to it. "Free" means it either has zero icons in it, or it
|
|
|
|
* has the minimum number of icons of all the slots. Returns the number of
|
|
|
|
* icons in the sought spot (ideally 0).
|
1998-10-31 02:22:35 +03:00
|
|
|
*/
|
1999-02-16 01:44:18 +03:00
|
|
|
static int
|
1999-08-09 07:41:39 +04:00
|
|
|
auto_pos (int sx, int ex, int sy, int ey, int *slot)
|
1999-02-16 01:44:18 +03:00
|
|
|
{
|
|
|
|
int min, min_slot;
|
1999-08-09 07:41:39 +04:00
|
|
|
int x, y;
|
2001-04-08 19:23:59 +04:00
|
|
|
int val = 0;
|
1999-08-10 02:54:02 +04:00
|
|
|
int xinc, yinc;
|
1999-08-09 07:41:39 +04:00
|
|
|
int r, b;
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
min = l_slots (sx, sy).num_icons;
|
1999-08-09 07:41:39 +04:00
|
|
|
min_slot = sx * layout_rows + sy;
|
1999-08-10 02:54:02 +04:00
|
|
|
xinc = yinc = 1;
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
if (desktop_arr_rows) {
|
|
|
|
swap (&ex, &ey);
|
|
|
|
swap (&sx, &sy);
|
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (desktop_arr_r2l)
|
|
|
|
swap (&sx, &ex);
|
|
|
|
|
|
|
|
if (desktop_arr_b2t)
|
|
|
|
swap (&sy, &ey);
|
|
|
|
#endif
|
|
|
|
if (desktop_arr_r2l)
|
|
|
|
xinc = -1;
|
|
|
|
|
|
|
|
if (desktop_arr_b2t)
|
|
|
|
yinc = -1;
|
|
|
|
|
|
|
|
if (desktop_arr_rows)
|
|
|
|
swap (&xinc, &yinc);
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
r = desktop_arr_r2l;
|
|
|
|
b = desktop_arr_b2t;
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
if (desktop_arr_rows)
|
|
|
|
swap (&r, &b);
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
for (x = sx; (r ? (x >= ex) : (x <= ex)); x += xinc) {
|
|
|
|
for (y = sy; (b ? (y >= ey) : (y <= ey)); y += yinc) {
|
1999-08-09 07:41:39 +04:00
|
|
|
if (desktop_arr_rows)
|
1999-08-10 02:54:02 +04:00
|
|
|
val = l_slots (y, x).num_icons;
|
1999-08-09 07:41:39 +04:00
|
|
|
else
|
1999-08-10 02:54:02 +04:00
|
|
|
val = l_slots (x, y).num_icons;
|
1999-02-16 01:44:18 +03:00
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
if (val < min || val == 0) {
|
|
|
|
min = val;
|
|
|
|
if (desktop_arr_rows)
|
|
|
|
min_slot = (y * layout_rows + x);
|
|
|
|
else
|
|
|
|
min_slot = (x * layout_rows + y);
|
|
|
|
if (val == 0)
|
|
|
|
break;
|
|
|
|
}
|
1999-02-16 01:44:18 +03:00
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
if (val == 0)
|
|
|
|
break;
|
1999-02-16 01:44:18 +03:00
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
*slot = min_slot;
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Looks for free space in the icon grid, scanning it in column-wise order */
|
1998-10-31 02:22:35 +03:00
|
|
|
static void
|
|
|
|
get_icon_auto_pos (int *x, int *y)
|
|
|
|
{
|
1999-08-10 02:54:02 +04:00
|
|
|
int val1;
|
|
|
|
int slot1;
|
1999-02-16 01:44:18 +03:00
|
|
|
int slot;
|
1999-08-09 07:41:39 +04:00
|
|
|
int sx, sy, ex, ey;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
int u, v;
|
|
|
|
int xx, yy;
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
#if 0
|
|
|
|
get_slot_from_pos (*x, *y, &sx, &sy);
|
|
|
|
#endif
|
|
|
|
/* FIXME funky stuff going on with the efficient positioning thingy */
|
|
|
|
if (desktop_arr_r2l)
|
|
|
|
sx = layout_cols - 1;
|
|
|
|
else
|
|
|
|
sx = 0;
|
|
|
|
|
|
|
|
if (desktop_arr_b2t)
|
|
|
|
sy = layout_rows - 1;
|
|
|
|
else
|
|
|
|
sy = 0;
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
if (desktop_arr_r2l)
|
|
|
|
ex = 0;
|
|
|
|
else
|
|
|
|
ex = layout_cols - 1;
|
|
|
|
|
|
|
|
if (desktop_arr_b2t)
|
|
|
|
ey = 0;
|
|
|
|
else
|
|
|
|
ey = layout_rows - 1;
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
/* Look forwards until the end of the grid. If we could not find an
|
|
|
|
* empty spot, find the second best.
|
|
|
|
*/
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
val1 = auto_pos (sx, ex, sy, ey, &slot1);
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
slot = slot1;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* to be used at a later date */
|
|
|
|
if (val1 == 0)
|
1999-02-16 01:44:18 +03:00
|
|
|
slot = slot1;
|
|
|
|
else {
|
1999-08-10 02:54:02 +04:00
|
|
|
if (desktop_arr_r2l)
|
|
|
|
sx = layout_cols - 1;
|
|
|
|
else
|
|
|
|
sx = 0;
|
|
|
|
|
|
|
|
if (desktop_arr_b2t)
|
|
|
|
sy = layout_rows - 1;
|
|
|
|
else
|
|
|
|
sy = 0;
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
val2 = auto_pos (sx, ex, sy, ey, &slot2);
|
1999-02-16 01:44:18 +03:00
|
|
|
if (val2 < val1)
|
|
|
|
slot = slot2;
|
1999-08-10 02:54:02 +04:00
|
|
|
}
|
|
|
|
#endif
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
u = slot / layout_rows;
|
|
|
|
v = slot % layout_rows;
|
|
|
|
|
|
|
|
get_pos_from_slot(u, v, &xx, &yy);
|
|
|
|
|
|
|
|
*x = xx;
|
|
|
|
*y = yy;
|
1998-10-31 02:22:35 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Snaps the specified position to the icon grid. It looks for the closest free spot on the grid,
|
|
|
|
* or the closest one that has the least number of icons in it.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
get_icon_snap_pos (int *x, int *y)
|
|
|
|
{
|
|
|
|
int min, min_x, min_y;
|
|
|
|
int min_dist;
|
|
|
|
int u, v;
|
|
|
|
int val, dist;
|
|
|
|
int dx, dy;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
int ux, vy;
|
2000-05-15 21:29:02 +04:00
|
|
|
int this_icon_u, this_icon_v;
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
min = l_slots (0, 0).num_icons;
|
1998-10-31 02:22:35 +03:00
|
|
|
min_x = min_y = 0;
|
|
|
|
min_dist = INT_MAX;
|
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
get_slot_from_pos(*x, *y, &this_icon_u, &this_icon_v);
|
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
for (u = 0; u < layout_cols; u++)
|
|
|
|
for (v = 0; v < layout_rows; v++) {
|
1998-11-03 04:32:38 +03:00
|
|
|
val = l_slots (u, v).num_icons;
|
2000-05-15 21:29:02 +04:00
|
|
|
|
|
|
|
if (u==this_icon_u && v==this_icon_v)
|
|
|
|
val--;
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
get_pos_from_slot(u, v, &ux, &vy);
|
|
|
|
dx = *x - ux;
|
|
|
|
dy = *y - vy;
|
1998-10-31 02:22:35 +03:00
|
|
|
dist = dx * dx + dy * dy;
|
|
|
|
|
1998-11-03 19:29:47 +03:00
|
|
|
if ((val == min && dist < min_dist) || (val < min)) {
|
1998-12-05 04:01:13 +03:00
|
|
|
min = val;
|
1998-10-31 02:22:35 +03:00
|
|
|
min_dist = dist;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
min_x = ux;
|
|
|
|
min_y = vy;
|
1998-10-31 02:22:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
*x = min_x;
|
|
|
|
*y = min_y;
|
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
}
|
1998-10-30 03:47:54 +03:00
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
/* Removes an icon from the slot it is in, if any */
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
remove_from_slot (DesktopIconInfo *dii)
|
1998-11-03 04:32:38 +03:00
|
|
|
{
|
|
|
|
if (dii->slot == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_assert (layout_slots[dii->slot].num_icons >= 1);
|
|
|
|
g_assert (layout_slots[dii->slot].icons != NULL);
|
|
|
|
|
|
|
|
layout_slots[dii->slot].num_icons--;
|
|
|
|
layout_slots[dii->slot].icons = g_list_remove (layout_slots[dii->slot].icons, dii);
|
1999-02-15 20:59:49 +03:00
|
|
|
|
|
|
|
dii->slot = -1;
|
|
|
|
dii->x = 0;
|
|
|
|
dii->y = 0;
|
1998-11-03 04:32:38 +03:00
|
|
|
}
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* Places a desktop icon on the specified position */
|
1998-10-30 20:08:03 +03:00
|
|
|
static void
|
1999-02-15 20:59:49 +03:00
|
|
|
desktop_icon_info_place (DesktopIconInfo *dii, int xpos, int ypos)
|
1998-10-30 20:08:03 +03:00
|
|
|
{
|
1998-10-31 02:22:35 +03:00
|
|
|
int u, v;
|
1998-11-24 06:58:05 +03:00
|
|
|
char *filename;
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
remove_from_slot (dii);
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
if (xpos < (layout_spacer_width / 2))
|
|
|
|
xpos = layout_spacer_width / 2;
|
|
|
|
else if (xpos > layout_screen_width - (DESKTOP_SNAP_X + (layout_spacer_width / 2)))
|
|
|
|
xpos = layout_screen_width - (DESKTOP_SNAP_X + (layout_spacer_width / 2));
|
|
|
|
|
|
|
|
if (ypos < (layout_spacer_height / 2))
|
|
|
|
ypos = layout_spacer_height / 2;
|
|
|
|
else if (ypos > layout_screen_height - (DESKTOP_SNAP_Y + (layout_spacer_height / 2)))
|
|
|
|
ypos = layout_screen_height - (DESKTOP_SNAP_Y + (layout_spacer_height / 2));
|
1998-12-07 18:47:00 +03:00
|
|
|
|
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
/* Increase the number of icons in the corresponding slot */
|
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
get_slot_from_pos (xpos, ypos, &u, &v);
|
1998-11-03 04:32:38 +03:00
|
|
|
|
|
|
|
dii->slot = u * layout_rows + v;
|
|
|
|
layout_slots[dii->slot].num_icons++;
|
|
|
|
layout_slots[dii->slot].icons = g_list_append (layout_slots[dii->slot].icons, dii);
|
1998-10-31 02:22:35 +03:00
|
|
|
|
|
|
|
/* Move the icon */
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
dii->x = xpos;
|
|
|
|
dii->y = ypos;
|
|
|
|
gtk_widget_set_uposition (dii->dicon, xpos, ypos);
|
1998-11-24 06:58:05 +03:00
|
|
|
|
|
|
|
/* Save the information */
|
|
|
|
|
|
|
|
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
|
|
|
gmeta_set_icon_pos (filename, dii->x, dii->y);
|
|
|
|
g_free (filename);
|
1998-10-30 20:08:03 +03:00
|
|
|
}
|
|
|
|
|
1999-02-19 00:43:07 +03:00
|
|
|
/* Destroys the specified desktop icon */
|
|
|
|
static void
|
|
|
|
desktop_icon_info_destroy (DesktopIconInfo *dii)
|
|
|
|
{
|
1999-04-10 01:13:04 +04:00
|
|
|
if (last_selected_icon == dii)
|
|
|
|
last_selected_icon = NULL;
|
|
|
|
|
1999-02-19 00:43:07 +03:00
|
|
|
gtk_widget_destroy (dii->dicon);
|
|
|
|
remove_from_slot (dii);
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
g_hash_table_remove (icon_hash, dii->filename);
|
|
|
|
|
1999-02-19 00:43:07 +03:00
|
|
|
g_free (dii->url);
|
|
|
|
g_free (dii->filename);
|
|
|
|
g_free (dii);
|
|
|
|
}
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Destroys all the current desktop icons */
|
|
|
|
static void
|
|
|
|
destroy_desktop_icons (void)
|
1998-12-07 00:01:30 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-07 00:01:30 +03:00
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++) {
|
|
|
|
l = layout_slots[i].icons;
|
|
|
|
|
|
|
|
while (l) {
|
1998-12-07 00:01:30 +03:00
|
|
|
dii = l->data;
|
1999-01-02 21:41:59 +03:00
|
|
|
l = l->next;
|
|
|
|
|
|
|
|
desktop_icon_info_destroy (dii);
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
1999-01-02 21:41:59 +03:00
|
|
|
}
|
|
|
|
}
|
1998-12-07 00:01:30 +03:00
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Returns a list with all of the icons on the desktop */
|
|
|
|
static GList *
|
|
|
|
get_all_icons (void)
|
|
|
|
{
|
|
|
|
GList *l, *res;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
res = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots [i].icons; l; l = l->next)
|
|
|
|
res = g_list_prepend (res, l->data);
|
|
|
|
|
|
|
|
return res;
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Returns the node in the list of DesktopIconInfo structures that contains the
|
|
|
|
* icon for the specified filename. If no icon is found, then returns NULL.
|
|
|
|
*/
|
1998-12-30 05:51:01 +03:00
|
|
|
static GList *
|
|
|
|
icon_exists_in_list (GList *list, char *filename)
|
|
|
|
{
|
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-30 05:51:01 +03:00
|
|
|
|
1998-12-31 04:43:11 +03:00
|
|
|
for (l = list; l; l = l->next) {
|
|
|
|
dii = l->data;
|
1998-12-30 05:51:01 +03:00
|
|
|
|
|
|
|
if (strcmp (filename, dii->filename) == 0)
|
|
|
|
return l;
|
|
|
|
}
|
1998-12-31 04:43:11 +03:00
|
|
|
|
1998-12-30 05:51:01 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-03-11 06:18:48 +03:00
|
|
|
/* Loads from the metadata updated versions of the caption and the url */
|
|
|
|
static void
|
|
|
|
update_url (DesktopIconInfo *dii)
|
|
|
|
{
|
|
|
|
char *fullname = g_concat_dir_and_file (desktop_directory, dii->filename);
|
|
|
|
char *caption = NULL;
|
|
|
|
char *url = NULL;
|
|
|
|
int size;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-03-11 06:18:48 +03:00
|
|
|
gnome_metadata_get (fullname, "icon-caption", &size, &caption);
|
|
|
|
if (caption){
|
|
|
|
desktop_icon_set_text (DESKTOP_ICON (dii->dicon), caption);
|
|
|
|
g_free (caption);
|
|
|
|
}
|
|
|
|
|
|
|
|
gnome_metadata_get (fullname, "desktop-url", &size, &url);
|
|
|
|
if (url){
|
|
|
|
if (dii->url)
|
|
|
|
g_free (dii->url);
|
|
|
|
dii->url = url;
|
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-03-11 06:18:48 +03:00
|
|
|
g_free (fullname);
|
|
|
|
}
|
|
|
|
|
1999-01-31 00:52:40 +03:00
|
|
|
typedef struct {
|
|
|
|
char *filename;
|
|
|
|
char *url;
|
1999-02-06 04:57:26 +03:00
|
|
|
char *caption;
|
1999-01-31 00:52:40 +03:00
|
|
|
} file_and_url_t;
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
/* get_drop_grid generates a compact organization for icons that are dragged out
|
|
|
|
* of applications on to the desktop.
|
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
get_drop_grid (gint xpos, gint ypos, gint need_position_list_length, GSList *grid_list)
|
|
|
|
{
|
|
|
|
gint i = 1;
|
|
|
|
gint my_bool = 0;
|
|
|
|
gint j;
|
|
|
|
gint k;
|
|
|
|
gint new_xpos;
|
|
|
|
gint new_ypos;
|
|
|
|
|
|
|
|
/* Determine size of a square grid in which to put the dropped icons */
|
|
|
|
while (!my_bool) {
|
|
|
|
if (need_position_list_length <= i * i)
|
|
|
|
my_bool = 1;
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure no icons are off the side of the screen */
|
|
|
|
if ((xpos + (i * DESKTOP_SNAP_X) + ((i - 1) * layout_spacer_width) +
|
|
|
|
(layout_spacer_width / 2)) > layout_screen_width) {
|
|
|
|
xpos = layout_screen_width - (layout_spacer_width / 2) -
|
|
|
|
(i * DESKTOP_SNAP_X) - ((i - 1) * layout_spacer_width);
|
|
|
|
}
|
|
|
|
if ((ypos + (i * DESKTOP_SNAP_Y) + ((i - 1) * layout_spacer_height) +
|
|
|
|
(layout_spacer_height / 2)) > layout_screen_height) {
|
|
|
|
ypos = layout_screen_height - (layout_spacer_height / 2) -
|
|
|
|
(i * DESKTOP_SNAP_Y) - ((i - 1) * layout_spacer_height);
|
|
|
|
}
|
|
|
|
if (xpos < layout_spacer_width / 2) {
|
|
|
|
xpos = layout_spacer_width / 2;
|
|
|
|
}
|
|
|
|
if (ypos < layout_spacer_height / 2) {
|
|
|
|
ypos = layout_spacer_height / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now write the (x, y) coordinates of the dropped icons */
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
for (k = 0; k < i; k++) {
|
|
|
|
new_xpos = xpos + k * (DESKTOP_SNAP_X + layout_spacer_width);
|
|
|
|
new_ypos = ypos + j * (DESKTOP_SNAP_Y + layout_spacer_height);
|
|
|
|
|
|
|
|
if (desktop_snap_icons) {
|
|
|
|
get_icon_snap_pos (&new_xpos, &new_ypos);
|
|
|
|
}
|
|
|
|
|
2001-04-13 05:03:22 +04:00
|
|
|
grid_list = g_slist_append (grid_list, (void *) new_xpos);
|
|
|
|
grid_list = g_slist_append (grid_list, (void *) new_ypos);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return grid_list;
|
|
|
|
|
|
|
|
}
|
2001-04-13 05:03:22 +04:00
|
|
|
|
|
|
|
#define NAUTILUS_KEY "<?xml version=\"1.0\"?>\n<nautilus_object nautilus_link=\""
|
|
|
|
#define NAUTILUS_MOUNT_KEY "Mount Link\""
|
|
|
|
#define NAUTILUS_GENERIC_KEY "Generic Link\""
|
|
|
|
#define NAUTILUS_HOME_KEY "Home Link\""
|
|
|
|
#define NAUTILUS_TRASH_KEY "Trash Link\""
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
should_skip_nautilus_file (char *name)
|
|
|
|
{
|
|
|
|
char buffer [256], *full, *p;
|
|
|
|
FILE *f;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (strcmp (name, ".nautilus-metafile.xml") == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (strcmp (name, "Trash") == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
full = g_concat_dir_and_file (desktop_directory, name);
|
|
|
|
f = fopen (full, "r");
|
|
|
|
g_free (full);
|
|
|
|
|
|
|
|
if (f == NULL)
|
|
|
|
return FALSE;
|
|
|
|
n = fread (buffer, sizeof (buffer), 1, f);
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strncmp (buffer, NAUTILUS_KEY, strlen (NAUTILUS_KEY)) != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
p = buffer + strlen (NAUTILUS_KEY);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
|
2001-04-13 05:03:22 +04:00
|
|
|
if (strncmp (p, NAUTILUS_HOME_KEY, strlen (NAUTILUS_HOME_KEY)) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (strncmp (p, NAUTILUS_TRASH_KEY, strlen (NAUTILUS_TRASH_KEY)) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (strncmp (p, NAUTILUS_MOUNT_KEY, strlen (NAUTILUS_MOUNT_KEY)) == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* Reloads the desktop icons efficiently. If there are "new" files for which no
|
1999-02-02 05:34:46 +03:00
|
|
|
* icons have been created, then icons for them will be created started at the
|
|
|
|
* specified position if user_pos is TRUE. If it is FALSE, the icons will be
|
|
|
|
* auto-placed.
|
1998-12-07 00:01:30 +03:00
|
|
|
*/
|
1999-02-23 04:56:09 +03:00
|
|
|
void
|
|
|
|
desktop_reload_icons (int user_pos, int xpos, int ypos)
|
1998-12-07 00:01:30 +03:00
|
|
|
{
|
|
|
|
struct dirent *dirent;
|
|
|
|
DIR *dir;
|
|
|
|
char *full_name;
|
2000-05-15 21:29:02 +04:00
|
|
|
int have_pos, x, y, size;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
2001-04-08 19:23:59 +04:00
|
|
|
GSList *need_position_list, *sl, *drop_grid_list = NULL, *drop_gl_copy = NULL;
|
1999-01-02 21:41:59 +03:00
|
|
|
GList *all_icons, *l;
|
1999-02-06 04:57:26 +03:00
|
|
|
char *desktop_url, *caption;
|
1999-02-17 22:58:24 +03:00
|
|
|
const char *mime;
|
1999-02-16 01:44:18 +03:00
|
|
|
int orig_xpos, orig_ypos;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
guint need_position_list_length;
|
2000-05-15 21:29:02 +04:00
|
|
|
static int first_reload = TRUE;
|
1999-02-01 09:26:55 +03:00
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
dir = mc_opendir (desktop_directory);
|
|
|
|
if (!dir) {
|
|
|
|
message (FALSE,
|
|
|
|
_("Warning"),
|
1999-02-01 09:26:55 +03:00
|
|
|
_("Could not open %s; will not have desktop icons"),
|
1998-12-07 00:01:30 +03:00
|
|
|
desktop_directory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-08 19:23:59 +04:00
|
|
|
/*
|
|
|
|
* Save the last time we scanned the directory
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
if (stat (desktop_directory, &buf) != -1)
|
|
|
|
desktop_dir_modify_time = buf.st_ctime;
|
|
|
|
else
|
|
|
|
desktop_dir_modify_time = time (NULL);
|
|
|
|
}
|
|
|
|
|
1999-01-11 04:22:44 +03:00
|
|
|
gnome_metadata_lock ();
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Read the directory. For each file for which we do have an existing
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
* icon, do nothing. Otherwise, store it in a list
|
|
|
|
* of new icons for which positioning is pending. If we have metadata for
|
|
|
|
* the file but no icon, delete the metadata and treat the file as new.
|
1998-12-07 00:01:30 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
need_position_list = NULL;
|
1999-01-02 21:41:59 +03:00
|
|
|
all_icons = get_all_icons ();
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
while ((dirent = mc_readdir (dir)) != NULL) {
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Skip . and .. */
|
1998-12-30 05:51:01 +03:00
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
if ((dirent->d_name[0] == '.' && dirent->d_name[1] == 0)
|
|
|
|
|| (dirent->d_name[0] == '.' && dirent->d_name[1] == '.'
|
|
|
|
&& dirent->d_name[2] == 0))
|
|
|
|
continue;
|
1998-12-07 00:01:30 +03:00
|
|
|
|
2001-04-13 05:03:22 +04:00
|
|
|
if (should_skip_nautilus_file (dirent->d_name))
|
|
|
|
continue;
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
l = icon_exists_in_list (all_icons, dirent->d_name);
|
|
|
|
if (l) {
|
1999-02-01 09:26:55 +03:00
|
|
|
GdkImlibImage *im;
|
|
|
|
file_entry *fe;
|
|
|
|
|
|
|
|
/* Reload the icon for this file, as it may have changed */
|
|
|
|
|
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, dirent->d_name);
|
|
|
|
fe = file_entry_from_file (full_name);
|
1999-02-23 09:14:02 +03:00
|
|
|
if (!fe){
|
|
|
|
g_free (full_name);
|
|
|
|
continue;
|
|
|
|
}
|
1999-02-17 03:38:16 +03:00
|
|
|
im = gicon_get_icon_for_file (desktop_directory, fe, FALSE);
|
1999-02-01 09:26:55 +03:00
|
|
|
file_entry_free (fe);
|
|
|
|
g_free (full_name);
|
|
|
|
|
|
|
|
dii = l->data;
|
1999-02-02 05:34:46 +03:00
|
|
|
desktop_icon_set_icon (DESKTOP_ICON (dii->dicon), im);
|
1999-02-01 09:26:55 +03:00
|
|
|
|
1999-03-11 06:18:48 +03:00
|
|
|
update_url (dii);
|
|
|
|
|
1999-02-01 09:26:55 +03:00
|
|
|
/* Leave the icon in the desktop by removing it from the list */
|
|
|
|
|
1999-06-15 02:50:45 +04:00
|
|
|
all_icons = g_list_remove_link (all_icons, l);
|
1999-01-02 21:41:59 +03:00
|
|
|
continue;
|
1998-12-30 05:51:01 +03:00
|
|
|
}
|
1998-12-07 00:01:30 +03:00
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, dirent->d_name);
|
1998-12-07 00:01:30 +03:00
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
have_pos = gmeta_get_icon_pos (full_name, &x, &y);
|
|
|
|
|
1999-02-06 02:59:13 +03:00
|
|
|
if (gnome_metadata_get (full_name, "desktop-url", &size, &desktop_url) != 0)
|
1999-01-31 00:52:40 +03:00
|
|
|
desktop_url = NULL;
|
1999-02-01 09:26:55 +03:00
|
|
|
|
1999-02-06 04:57:26 +03:00
|
|
|
caption = NULL;
|
|
|
|
gnome_metadata_get (full_name, "icon-caption", &size, &caption);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
if (first_reload && have_pos) {
|
|
|
|
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, x, y);
|
|
|
|
gtk_widget_show (dii->dicon);
|
|
|
|
} else {
|
|
|
|
file_and_url_t *fau;
|
|
|
|
fau = g_new0 (file_and_url_t, 1);
|
|
|
|
fau->filename = g_strdup (dirent->d_name);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
if (desktop_url)
|
|
|
|
fau->url = g_strdup (desktop_url);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
if (caption)
|
|
|
|
fau->caption = g_strdup (caption);
|
1999-01-31 00:52:40 +03:00
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
need_position_list = g_slist_prepend (need_position_list, fau);
|
|
|
|
}
|
|
|
|
|
1999-02-23 05:53:30 +03:00
|
|
|
g_free (full_name);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-01-31 00:52:40 +03:00
|
|
|
if (desktop_url)
|
|
|
|
g_free (desktop_url);
|
1999-02-06 04:57:26 +03:00
|
|
|
|
|
|
|
if (caption)
|
|
|
|
g_free (caption);
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
if (first_reload)
|
|
|
|
first_reload = FALSE;
|
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
mc_closedir (dir);
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* all_icons now contains a list of all of the icons that were not found
|
|
|
|
* in the ~/desktop directory, remove them. To be paranoically tidy,
|
|
|
|
* also delete the icon position information -- someone may have deleted
|
|
|
|
* a file under us.
|
1998-12-30 05:51:01 +03:00
|
|
|
*/
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
for (l = all_icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
|
1999-02-16 23:18:34 +03:00
|
|
|
gnome_metadata_delete (full_name);
|
1999-01-02 21:41:59 +03:00
|
|
|
g_free (full_name);
|
|
|
|
desktop_icon_info_destroy (dii);
|
1998-12-30 05:51:01 +03:00
|
|
|
}
|
1999-01-02 21:41:59 +03:00
|
|
|
|
1998-12-30 05:51:01 +03:00
|
|
|
g_list_free (all_icons);
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/* Now create the icons for all the files that did not have their
|
|
|
|
* position set. This makes auto-placement work correctly without
|
|
|
|
* overlapping icons.
|
1998-12-07 00:01:30 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
need_position_list = g_slist_reverse (need_position_list);
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
need_position_list_length = g_slist_length (need_position_list);
|
|
|
|
|
|
|
|
/* Get a position list for the dragged icons, to nicely place multiple icon drops */
|
|
|
|
if (user_pos && (need_position_list_length != 0)) {
|
|
|
|
drop_grid_list = NULL;
|
|
|
|
drop_grid_list = get_drop_grid (xpos, ypos, need_position_list_length, drop_grid_list);
|
|
|
|
drop_gl_copy = drop_grid_list;
|
|
|
|
}
|
|
|
|
|
1999-02-16 01:44:18 +03:00
|
|
|
orig_xpos = orig_ypos = 0;
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
for (sl = need_position_list; sl; sl = sl->next) {
|
1999-02-18 03:07:26 +03:00
|
|
|
file_and_url_t *fau;
|
|
|
|
|
|
|
|
fau = sl->data;
|
1999-02-01 09:26:55 +03:00
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
if (user_pos) {
|
1999-02-16 01:44:18 +03:00
|
|
|
if (desktop_auto_placement) {
|
|
|
|
xpos = ypos = 0;
|
|
|
|
get_icon_auto_pos (&xpos, &ypos);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
} else { /* Place the icons according to the position list obtained above */
|
|
|
|
xpos = (int) drop_gl_copy->data;
|
|
|
|
drop_gl_copy = drop_gl_copy->next;
|
|
|
|
ypos = (int) drop_gl_copy->data;
|
|
|
|
drop_gl_copy = drop_gl_copy->next;
|
|
|
|
}
|
1999-02-16 01:44:18 +03:00
|
|
|
} else {
|
|
|
|
xpos = orig_xpos;
|
|
|
|
ypos = orig_ypos;
|
1999-02-15 20:59:49 +03:00
|
|
|
get_icon_auto_pos (&xpos, &ypos);
|
1999-02-16 01:44:18 +03:00
|
|
|
}
|
1999-02-15 20:59:49 +03:00
|
|
|
|
1999-02-18 03:07:26 +03:00
|
|
|
/* If the file dropped was a .desktop file, pull the suggested
|
1999-02-17 22:58:24 +03:00
|
|
|
* title and icon from there
|
|
|
|
*/
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
if (use_magic)
|
|
|
|
{
|
|
|
|
char *full_name;
|
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, fau->filename);
|
|
|
|
mime = gnome_mime_type_or_default_of_file (full_name, NULL);
|
|
|
|
g_free (full_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mime = gnome_mime_type_or_default (fau->filename, NULL);
|
1999-02-18 03:07:26 +03:00
|
|
|
if (mime && strcmp (mime, "application/x-gnome-app-info") == 0) {
|
1999-02-17 22:58:24 +03:00
|
|
|
GnomeDesktopEntry *entry;
|
1999-02-18 03:07:26 +03:00
|
|
|
char *fullname;
|
|
|
|
|
|
|
|
fullname = g_concat_dir_and_file (desktop_directory, fau->filename);
|
1999-02-17 22:58:24 +03:00
|
|
|
entry = gnome_desktop_entry_load (fullname);
|
1999-02-18 03:07:26 +03:00
|
|
|
if (entry) {
|
|
|
|
if (entry->name) {
|
1999-02-17 22:58:24 +03:00
|
|
|
if (fau->caption)
|
|
|
|
g_free (fau->caption);
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-02-17 22:58:24 +03:00
|
|
|
fau->caption = g_strdup (entry->name);
|
|
|
|
gnome_metadata_set (fullname, "icon-caption",
|
1999-02-18 03:07:26 +03:00
|
|
|
strlen (fau->caption) + 1,
|
|
|
|
fau->caption);
|
1999-02-17 22:58:24 +03:00
|
|
|
}
|
1999-02-18 03:07:26 +03:00
|
|
|
|
|
|
|
if (entry->icon)
|
1999-02-17 22:58:24 +03:00
|
|
|
gnome_metadata_set (fullname, "icon-filename",
|
1999-02-18 03:07:26 +03:00
|
|
|
strlen (entry->icon) + 1,
|
|
|
|
entry->icon);
|
|
|
|
|
1999-02-17 22:58:24 +03:00
|
|
|
gnome_desktop_entry_free (entry);
|
|
|
|
}
|
|
|
|
g_free (fullname);
|
|
|
|
}
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
dii = desktop_icon_info_new (fau->filename, fau->url, fau->caption, xpos, ypos);
|
1998-12-07 00:01:30 +03:00
|
|
|
gtk_widget_show (dii->dicon);
|
1999-01-31 00:52:40 +03:00
|
|
|
|
1999-02-06 04:57:26 +03:00
|
|
|
if (fau->url)
|
|
|
|
g_free (fau->url);
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-02-06 04:57:26 +03:00
|
|
|
if (fau->caption)
|
|
|
|
g_free (fau->caption);
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-01-31 00:52:40 +03:00
|
|
|
g_free (fau->filename);
|
|
|
|
g_free (fau);
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
if ((need_position_list_length != 0) && user_pos) {
|
|
|
|
g_slist_free (drop_grid_list);
|
|
|
|
}
|
|
|
|
|
1998-12-07 00:01:30 +03:00
|
|
|
g_slist_free (need_position_list);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
|
1999-01-31 00:52:40 +03:00
|
|
|
gnome_metadata_unlock ();
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
static WPanel *create_panel_from_desktop(); /* Fwd decl */
|
|
|
|
static void free_panel_from_desktop(WPanel *panel);
|
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
/* Run all of the desktop icons through snap-to-grid */
|
|
|
|
void
|
|
|
|
desktop_tidy_icons (void)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
DesktopIconInfo *dii;
|
|
|
|
int i;
|
|
|
|
dir_list dir;
|
|
|
|
int xpos, ypos;
|
|
|
|
|
|
|
|
panel = create_panel_from_desktop ();
|
|
|
|
if (panel->count == 0) {
|
|
|
|
free_panel_from_desktop (panel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = panel->dir;
|
|
|
|
g_assert (dir.list != NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < dir.size; i++) {
|
|
|
|
dii = desktop_icon_info_get_by_filename (dir.list[i].fname);
|
|
|
|
xpos = dii->x;
|
|
|
|
ypos = dii->y;
|
|
|
|
get_icon_snap_pos (&xpos, &ypos);
|
|
|
|
desktop_icon_info_place (dii, xpos, ypos);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_panel_from_desktop (panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* Perform automatic arrangement of the desktop icons */
|
2000-01-25 13:30:53 +03:00
|
|
|
void
|
1999-08-09 07:41:39 +04:00
|
|
|
desktop_arrange_icons (SortType type)
|
1999-02-15 20:59:49 +03:00
|
|
|
{
|
1999-08-09 07:41:39 +04:00
|
|
|
WPanel *panel;
|
1999-08-10 02:54:02 +04:00
|
|
|
sortfn *sfn;
|
1999-08-09 07:41:39 +04:00
|
|
|
DesktopIconInfo *dii;
|
|
|
|
int i;
|
|
|
|
dir_list dir;
|
1999-02-15 20:59:49 +03:00
|
|
|
int xpos, ypos;
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
panel = create_panel_from_desktop ();
|
1999-11-30 00:17:14 +03:00
|
|
|
if (panel->count == 0) {
|
|
|
|
free_panel_from_desktop (panel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
sfn = sort_get_func_from_type (type);
|
|
|
|
g_assert (sfn != NULL);
|
|
|
|
|
|
|
|
do_sort (&panel->dir, sfn, panel->count - 1, FALSE, FALSE);
|
1999-08-09 07:41:39 +04:00
|
|
|
dir = panel->dir;
|
1999-08-10 02:54:02 +04:00
|
|
|
g_assert (dir.list != NULL);
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
for (i = 0; i < dir.size; i++)
|
2000-05-15 21:29:02 +04:00
|
|
|
remove_from_slot (desktop_icon_info_get_by_filename (dir.list[i].fname));
|
1999-08-09 07:41:39 +04:00
|
|
|
|
|
|
|
for (i = 0; i < dir.size; i++) {
|
1999-08-10 02:54:02 +04:00
|
|
|
dii = desktop_icon_info_get_by_filename (dir.list[i].fname);
|
1999-02-16 06:42:52 +03:00
|
|
|
xpos = ypos = 0;
|
1999-02-15 20:59:49 +03:00
|
|
|
get_icon_auto_pos (&xpos, &ypos);
|
1999-08-09 07:41:39 +04:00
|
|
|
desktop_icon_info_place (dii, xpos, ypos);
|
1999-02-15 20:59:49 +03:00
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
free_panel_from_desktop (panel);
|
1999-02-15 20:59:49 +03:00
|
|
|
}
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Unselects all the desktop icons except the one in exclude */
|
1998-11-02 02:21:24 +03:00
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
unselect_all (DesktopIconInfo *exclude)
|
1998-11-02 02:21:24 +03:00
|
|
|
{
|
1998-11-03 04:32:38 +03:00
|
|
|
int i;
|
1998-11-02 02:21:24 +03:00
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-11-02 02:21:24 +03:00
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
1998-11-02 02:21:24 +03:00
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
if (dii->selected && dii != exclude) {
|
1998-11-03 04:32:38 +03:00
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), FALSE);
|
|
|
|
dii->selected = FALSE;
|
|
|
|
}
|
1998-11-02 02:21:24 +03:00
|
|
|
}
|
1998-11-03 04:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sets the selection state of a range to the specified value. The range starts at the
|
|
|
|
* last_selected_icon and ends at the specified icon.
|
|
|
|
*/
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
select_range (DesktopIconInfo *dii, int sel)
|
1998-11-03 04:32:38 +03:00
|
|
|
{
|
1998-11-03 19:29:47 +03:00
|
|
|
int du, dv, lu, lv;
|
|
|
|
int min_u, min_v;
|
|
|
|
int max_u, max_v;
|
|
|
|
int u, v;
|
1998-11-03 04:32:38 +03:00
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *ldii;
|
1998-11-03 04:32:38 +03:00
|
|
|
|
|
|
|
/* Find out the selection range */
|
|
|
|
|
|
|
|
if (!last_selected_icon)
|
|
|
|
last_selected_icon = dii;
|
|
|
|
|
1998-11-03 19:29:47 +03:00
|
|
|
du = dii->slot / layout_rows;
|
|
|
|
dv = dii->slot % layout_rows;
|
|
|
|
lu = last_selected_icon->slot / layout_rows;
|
|
|
|
lv = last_selected_icon->slot % layout_rows;
|
|
|
|
|
|
|
|
if (du < lu) {
|
|
|
|
min_u = du;
|
|
|
|
max_u = lu;
|
1998-11-03 04:32:38 +03:00
|
|
|
} else {
|
1998-11-03 19:29:47 +03:00
|
|
|
min_u = lu;
|
|
|
|
max_u = du;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dv < lv) {
|
|
|
|
min_v = dv;
|
|
|
|
max_v = lv;
|
|
|
|
} else {
|
|
|
|
min_v = lv;
|
|
|
|
max_v = dv;
|
1998-11-02 02:21:24 +03:00
|
|
|
}
|
1998-11-03 04:32:38 +03:00
|
|
|
|
1998-11-04 19:51:57 +03:00
|
|
|
/* Select all the icons in the rectangle */
|
1998-11-03 04:32:38 +03:00
|
|
|
|
1998-11-03 19:29:47 +03:00
|
|
|
for (u = min_u; u <= max_u; u++)
|
|
|
|
for (v = min_v; v <= max_v; v++)
|
|
|
|
for (l = l_slots (u, v).icons; l; l = l->next) {
|
|
|
|
ldii = l->data;
|
1998-11-03 04:32:38 +03:00
|
|
|
|
1998-11-03 19:29:47 +03:00
|
|
|
desktop_icon_select (DESKTOP_ICON (ldii->dicon), sel);
|
|
|
|
ldii->selected = sel;
|
|
|
|
}
|
1998-11-02 02:21:24 +03:00
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Handles icon selection and unselection due to button presses. The
|
1998-12-11 05:05:19 +03:00
|
|
|
* event_state is the state field of the event.
|
|
|
|
*/
|
1998-11-02 02:21:24 +03:00
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
select_icon (DesktopIconInfo *dii, int event_state)
|
1998-11-02 02:21:24 +03:00
|
|
|
{
|
1998-11-03 04:32:38 +03:00
|
|
|
int range;
|
|
|
|
int additive;
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
range = ((event_state & GDK_SHIFT_MASK) != 0);
|
|
|
|
additive = ((event_state & GDK_CONTROL_MASK) != 0);
|
1998-11-03 04:32:38 +03:00
|
|
|
|
|
|
|
if (!additive)
|
1998-12-11 05:05:19 +03:00
|
|
|
unselect_all (NULL);
|
1998-11-03 04:32:38 +03:00
|
|
|
|
|
|
|
if (!range) {
|
|
|
|
if (additive) {
|
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), !dii->selected);
|
|
|
|
dii->selected = !dii->selected;
|
|
|
|
} else if (!dii->selected) {
|
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), TRUE);
|
|
|
|
dii->selected = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_selected_icon = dii;
|
1998-11-04 19:51:57 +03:00
|
|
|
|
|
|
|
if (dii->selected)
|
|
|
|
gdk_window_raise (dii->dicon->window);
|
1998-11-03 04:32:38 +03:00
|
|
|
} else
|
|
|
|
select_range (dii, TRUE);
|
1998-11-02 02:21:24 +03:00
|
|
|
}
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
/* Convenience function to fill a file entry */
|
|
|
|
static void
|
|
|
|
file_entry_fill (file_entry *fe, struct stat *s, char *filename)
|
1998-12-07 00:01:30 +03:00
|
|
|
{
|
1998-12-07 05:36:47 +03:00
|
|
|
fe->fname = g_strdup (x_basename (filename));
|
|
|
|
fe->fnamelen = strlen (fe->fname);
|
1999-03-11 05:40:53 +03:00
|
|
|
fe->buf = *s;
|
1998-12-07 05:36:47 +03:00
|
|
|
fe->f.marked = FALSE;
|
|
|
|
fe->f.link_to_dir = FALSE;
|
|
|
|
fe->f.stalled_link = FALSE;
|
1999-03-11 05:40:53 +03:00
|
|
|
fe->f.dir_size_computed = FALSE;
|
1998-12-07 05:36:47 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (S_ISLNK (s->st_mode)) {
|
1998-12-07 05:36:47 +03:00
|
|
|
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;
|
|
|
|
}
|
1999-03-11 05:40:53 +03:00
|
|
|
}
|
1998-12-07 05:36:47 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
/* Creates a file entry structure and fills it with information appropriate to the specified file. */
|
|
|
|
file_entry *
|
|
|
|
file_entry_from_file (char *filename)
|
|
|
|
{
|
|
|
|
file_entry *fe;
|
|
|
|
struct stat s;
|
|
|
|
|
|
|
|
if (mc_lstat (filename, &s) == -1) {
|
|
|
|
g_warning ("Could not stat %s, bad things will happen", filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fe = g_new (file_entry, 1);
|
|
|
|
file_entry_fill (fe, &s, filename);
|
1998-12-07 05:36:47 +03:00
|
|
|
return fe;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Frees a file entry structure */
|
1999-01-19 01:37:39 +03:00
|
|
|
void
|
1998-12-07 05:36:47 +03:00
|
|
|
file_entry_free (file_entry *fe)
|
|
|
|
{
|
|
|
|
if (fe->fname)
|
|
|
|
g_free (fe->fname);
|
1998-12-07 00:01:30 +03:00
|
|
|
|
1998-12-07 05:36:47 +03:00
|
|
|
g_free (fe);
|
1998-12-07 00:01:30 +03:00
|
|
|
}
|
|
|
|
|
1999-06-18 02:42:01 +04:00
|
|
|
/* Sets the wmclass and name of a desktop icon to an unique value */
|
|
|
|
static void
|
|
|
|
set_icon_wmclass (DesktopIconInfo *dii)
|
|
|
|
{
|
|
|
|
XClassHint *h;
|
|
|
|
|
|
|
|
g_assert (GTK_WIDGET_REALIZED (dii->dicon));
|
|
|
|
|
|
|
|
h = XAllocClassHint ();
|
|
|
|
if (!h) {
|
|
|
|
g_warning ("XAllocClassHint() failed!");
|
|
|
|
return; /* eek */
|
|
|
|
}
|
|
|
|
|
|
|
|
h->res_name = dii->filename;
|
|
|
|
h->res_class = "gmc-desktop-icon";
|
|
|
|
|
|
|
|
XSetClassHint (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (GTK_WIDGET (dii->dicon)->window), h);
|
|
|
|
XFree (h);
|
|
|
|
}
|
|
|
|
|
1999-08-07 00:10:34 +04:00
|
|
|
/* Removes the Gtk and Gdk grabs that are present when editing a desktop icon */
|
|
|
|
static void
|
|
|
|
remove_editing_grab (DesktopIconInfo *dii)
|
|
|
|
{
|
|
|
|
gtk_grab_remove (dii->dicon);
|
|
|
|
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
|
|
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback used when an icon's text changes. We must validate the
|
1998-12-17 07:51:24 +03:00
|
|
|
* rename and return the appropriate value. The desktop icon info
|
|
|
|
* structure is passed in the user data.
|
1998-11-06 02:24:47 +03:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
text_changed (GnomeIconTextItem *iti, gpointer data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-11-07 04:19:53 +03:00
|
|
|
char *new_name;
|
1998-11-06 02:24:47 +03:00
|
|
|
char *source;
|
|
|
|
char *dest;
|
1999-03-15 03:00:00 +03:00
|
|
|
char *buf;
|
|
|
|
int size;
|
1998-11-06 02:24:47 +03:00
|
|
|
int retval;
|
|
|
|
|
|
|
|
dii = data;
|
1999-08-07 00:10:34 +04:00
|
|
|
remove_editing_grab (dii);
|
1998-11-06 02:24:47 +03:00
|
|
|
|
|
|
|
source = g_concat_dir_and_file (desktop_directory, dii->filename);
|
1998-11-07 04:19:53 +03:00
|
|
|
new_name = gnome_icon_text_item_get_text (iti);
|
1998-11-06 02:24:47 +03:00
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
if (gnome_metadata_get (source, "icon-caption", &size, &buf) != 0) {
|
1999-10-21 04:36:10 +04:00
|
|
|
if (strcmp (new_name, dii->filename) == 0) {
|
|
|
|
g_free (source);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
/* No icon caption metadata, so rename the file */
|
1998-11-06 02:24:47 +03:00
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
dest = g_concat_dir_and_file (desktop_directory, new_name);
|
1998-11-06 02:24:47 +03:00
|
|
|
|
1999-08-14 02:45:07 +04:00
|
|
|
if (rename_file_with_context (source, dest) == FILE_CONT) {
|
1999-08-07 00:10:34 +04:00
|
|
|
GList *icons;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
/* See if there was an icon for the new name. If so,
|
|
|
|
* destroy it first; desktop_reload_icons() will not be
|
|
|
|
* happy if two icons have the same filename.
|
|
|
|
*/
|
|
|
|
|
|
|
|
icons = get_all_icons ();
|
|
|
|
l = icon_exists_in_list (icons, new_name);
|
|
|
|
if (l)
|
|
|
|
desktop_icon_info_destroy (l->data);
|
|
|
|
|
|
|
|
g_list_free (icons);
|
|
|
|
|
|
|
|
/* Set the new name */
|
1999-06-18 02:42:01 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
g_hash_table_remove (icon_hash, dii->filename);
|
1999-03-15 03:00:00 +03:00
|
|
|
g_free (dii->filename);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
dii->filename = g_strdup (new_name);
|
1999-08-10 02:54:02 +04:00
|
|
|
g_hash_table_insert (icon_hash, dii->filename, dii);
|
1999-06-18 02:42:01 +04:00
|
|
|
set_icon_wmclass (dii);
|
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
retval = TRUE;
|
|
|
|
} else
|
|
|
|
retval = FALSE; /* FIXME: maybe pop up a warning/query dialog? */
|
1998-11-06 02:24:47 +03:00
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
g_free (dest);
|
|
|
|
} else {
|
|
|
|
/* The icon has the icon-caption metadata, so change that instead */
|
1999-01-31 00:52:40 +03:00
|
|
|
|
1999-03-15 03:00:00 +03:00
|
|
|
g_free (buf);
|
|
|
|
|
|
|
|
buf = gnome_icon_text_item_get_text (iti);
|
|
|
|
if (*buf) {
|
|
|
|
gnome_metadata_set (source, "icon-caption", strlen (buf) + 1, buf);
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
retval = TRUE;
|
|
|
|
} else
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (source);
|
|
|
|
return retval;
|
1999-01-31 00:52:40 +03:00
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Sets up the mouse grab for when a desktop icon is being edited */
|
|
|
|
static void
|
|
|
|
setup_editing_grab (DesktopIconInfo *dii)
|
|
|
|
{
|
|
|
|
GdkCursor *ibeam;
|
|
|
|
|
|
|
|
ibeam = gdk_cursor_new (GDK_XTERM);
|
|
|
|
gdk_pointer_grab (dii->dicon->window,
|
|
|
|
TRUE,
|
|
|
|
(GDK_BUTTON_PRESS_MASK
|
|
|
|
| GDK_BUTTON_RELEASE_MASK
|
|
|
|
| GDK_POINTER_MOTION_MASK
|
|
|
|
| GDK_ENTER_NOTIFY_MASK
|
|
|
|
| GDK_LEAVE_NOTIFY_MASK),
|
|
|
|
NULL,
|
|
|
|
ibeam,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
gdk_cursor_destroy (ibeam);
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Callback used when the user begins editing the icon text item in a
|
|
|
|
* desktop icon. It installs the mouse and keyboard grabs that are
|
|
|
|
* required while an icon is being edited.
|
1998-11-05 02:01:24 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
editing_started (GnomeIconTextItem *iti, gpointer data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-11-05 02:01:24 +03:00
|
|
|
|
|
|
|
dii = data;
|
|
|
|
|
1998-12-11 06:18:41 +03:00
|
|
|
/* Disable drags from this icon until editing is finished */
|
|
|
|
|
|
|
|
gtk_drag_source_unset (DESKTOP_ICON (dii->dicon)->canvas);
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Unselect all icons but this one */
|
|
|
|
unselect_all (dii);
|
|
|
|
|
1998-12-11 11:58:26 +03:00
|
|
|
gtk_grab_add (dii->dicon);
|
1999-01-20 14:27:20 +03:00
|
|
|
setup_editing_grab (dii);
|
1999-01-18 22:22:23 +03:00
|
|
|
gdk_keyboard_grab (GTK_LAYOUT (DESKTOP_ICON (dii->dicon)->canvas)->bin_window,
|
|
|
|
FALSE, GDK_CURRENT_TIME);
|
1998-11-05 02:01:24 +03:00
|
|
|
}
|
|
|
|
|
1998-12-11 06:18:41 +03:00
|
|
|
/* Sets up the specified icon as a drag source, but does not connect the signals */
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
setup_icon_dnd_actions (DesktopIconInfo *dii)
|
1998-12-11 06:18:41 +03:00
|
|
|
{
|
|
|
|
gtk_drag_source_set (DESKTOP_ICON (dii->dicon)->canvas,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
|
|
dnd_icon_sources,
|
|
|
|
dnd_icon_nsources,
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Callback used when the user finishes editing the icon text item in
|
|
|
|
* a desktop icon. It removes the mouse and keyboard grabs.
|
1998-11-05 02:01:24 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
editing_stopped (GnomeIconTextItem *iti, gpointer data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
dii = data;
|
1999-08-07 00:10:34 +04:00
|
|
|
remove_editing_grab (dii);
|
1998-12-11 06:18:41 +03:00
|
|
|
|
|
|
|
/* Re-enable drags from this icon */
|
|
|
|
|
|
|
|
setup_icon_dnd_actions (dii);
|
1998-11-05 02:01:24 +03:00
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Callback used when the user stops selecting text in a desktop icon. This function
|
|
|
|
* restores the mouse grab that we had set up initially (the selection process changes
|
|
|
|
* the grab and then removes it, so we need to restore the initial grab).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
selection_stopped (GnomeIconTextItem *iti, gpointer data)
|
|
|
|
{
|
|
|
|
DesktopIconInfo *dii;
|
|
|
|
|
|
|
|
dii = data;
|
|
|
|
setup_editing_grab (dii);
|
|
|
|
}
|
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
static char *mount_known_locations [] = {
|
|
|
|
"/sbin/mount", "/bin/mount", "/etc/mount",
|
|
|
|
"/usr/sbin/mount", "/usr/etc/mount", "/usr/bin/mount",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *umount_known_locations [] = {
|
|
|
|
"/sbin/umount", "/bin/umount", "/etc/umount",
|
|
|
|
"/usr/sbin/umount", "/usr/etc/umount", "/usr/bin/umount",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the full path to the mount command
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
find_command (char **known_locations)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; known_locations [i]; i++){
|
|
|
|
if (g_file_exists (known_locations [i]))
|
|
|
|
return known_locations [i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
1999-02-23 04:56:09 +03:00
|
|
|
is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
|
1999-02-17 05:18:12 +03:00
|
|
|
{
|
1999-02-23 04:56:09 +03:00
|
|
|
char buffer [128], *p;
|
1999-02-25 07:08:43 +03:00
|
|
|
int len;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-23 04:56:09 +03:00
|
|
|
if (point)
|
|
|
|
*point = NULL;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
if (!S_ISLNK (fe->buf.st_mode))
|
|
|
|
return FALSE;
|
|
|
|
|
1999-02-25 07:08:43 +03:00
|
|
|
len = readlink (filename, buffer, sizeof (buffer));
|
|
|
|
if (len == -1)
|
1999-02-17 05:18:12 +03:00
|
|
|
return FALSE;
|
1999-06-15 02:50:45 +04:00
|
|
|
buffer [len] = 0;
|
|
|
|
|
1999-02-23 04:56:09 +03:00
|
|
|
p = is_block_device_mountable (buffer);
|
|
|
|
if (!p)
|
1999-02-17 05:18:12 +03:00
|
|
|
return FALSE;
|
|
|
|
|
1999-02-23 04:56:09 +03:00
|
|
|
if (point)
|
|
|
|
*point = p;
|
1999-02-23 19:39:00 +03:00
|
|
|
else
|
|
|
|
g_free (point);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
*is_mounted = is_block_device_mounted (buffer);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
do_mount_umount (char *filename, gboolean is_mount)
|
|
|
|
{
|
|
|
|
static char *mount_command;
|
|
|
|
static char *umount_command;
|
1999-02-18 03:07:26 +03:00
|
|
|
char *op;
|
1999-03-11 10:53:26 +03:00
|
|
|
char *buffer;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
if (is_mount){
|
|
|
|
if (!mount_command)
|
|
|
|
mount_command = find_command (mount_known_locations);
|
|
|
|
op = mount_command;
|
|
|
|
} else {
|
|
|
|
if (!umount_command)
|
|
|
|
umount_command = find_command (umount_known_locations);
|
|
|
|
op = umount_command;
|
|
|
|
}
|
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
buffer = g_readlink (filename);
|
|
|
|
if (buffer == NULL)
|
1999-02-17 05:18:12 +03:00
|
|
|
return FALSE;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
if (op){
|
1999-03-18 21:43:52 +03:00
|
|
|
gboolean success = TRUE;
|
1999-02-17 05:18:12 +03:00
|
|
|
char *command;
|
|
|
|
FILE *f;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
command = g_strconcat (op, " ", buffer, NULL);
|
|
|
|
open_error_pipe ();
|
|
|
|
f = popen (command, "r");
|
1999-03-18 21:43:52 +03:00
|
|
|
if (f == NULL){
|
|
|
|
success = !close_error_pipe (1, _("While running the mount/umount command"));
|
1999-06-15 02:50:45 +04:00
|
|
|
} else
|
1999-03-18 21:43:52 +03:00
|
|
|
success = !close_error_pipe (0, 0);
|
1999-02-17 05:18:12 +03:00
|
|
|
pclose (f);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
g_free (buffer);
|
1999-03-18 21:43:52 +03:00
|
|
|
return success;
|
1999-02-17 05:18:12 +03:00
|
|
|
}
|
1999-03-11 10:53:26 +03:00
|
|
|
g_free (buffer);
|
1999-02-17 05:18:12 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-17 19:32:12 +03:00
|
|
|
static char *eject_known_locations [] = {
|
|
|
|
"/usr/bin/eject",
|
|
|
|
"/sbin/eject",
|
|
|
|
"/bin/eject",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns whether the device is ejectable
|
|
|
|
*
|
|
|
|
* Right now the test only checks if this system has the eject
|
|
|
|
* command
|
|
|
|
*/
|
1999-06-15 02:50:45 +04:00
|
|
|
gboolean
|
1999-02-17 19:32:12 +03:00
|
|
|
is_ejectable (char *filename)
|
|
|
|
{
|
1999-03-09 06:56:54 +03:00
|
|
|
char *buf;
|
|
|
|
int size, retval;
|
|
|
|
|
|
|
|
if (gnome_metadata_get (filename, "device-is-ejectable", &size, &buf) == 0){
|
|
|
|
if (*buf)
|
|
|
|
retval = TRUE;
|
|
|
|
else
|
|
|
|
retval = FALSE;
|
|
|
|
g_free (buf);
|
|
|
|
|
|
|
|
if (retval)
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 19:32:12 +03:00
|
|
|
if (find_command (eject_known_locations))
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ejects the device pointed by filename
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
do_eject (char *filename)
|
|
|
|
{
|
|
|
|
char *eject_command = find_command (eject_known_locations);
|
1999-03-11 10:53:26 +03:00
|
|
|
char *command, *device;
|
1999-02-17 19:32:12 +03:00
|
|
|
FILE *f;
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-02-17 19:32:12 +03:00
|
|
|
if (!eject_command)
|
1999-02-18 03:07:26 +03:00
|
|
|
return FALSE;
|
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
device = mount_point_to_device (filename);
|
|
|
|
if (!device)
|
1999-03-11 22:23:23 +03:00
|
|
|
return FALSE;
|
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
command = g_strconcat (eject_command, " ", device, NULL);
|
1999-02-17 19:32:12 +03:00
|
|
|
open_error_pipe ();
|
|
|
|
f = popen (command, "r");
|
|
|
|
if (f == NULL)
|
|
|
|
close_error_pipe (1, _("While running the eject command"));
|
|
|
|
else
|
|
|
|
close_error_pipe (0, 0);
|
1999-02-18 03:07:26 +03:00
|
|
|
|
1999-02-17 19:32:12 +03:00
|
|
|
pclose (f);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-02-17 05:18:12 +03:00
|
|
|
static gboolean
|
|
|
|
try_to_mount (char *filename, file_entry *fe)
|
|
|
|
{
|
|
|
|
int x;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-23 04:56:09 +03:00
|
|
|
if (!is_mountable (filename, fe, &x, NULL))
|
1999-02-17 05:18:12 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return do_mount_umount (filename, TRUE);
|
|
|
|
}
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* 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;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
marked_count = 0;
|
|
|
|
dir_marked_count = 0;
|
|
|
|
total = 0;
|
|
|
|
selected_index = -1;
|
|
|
|
|
|
|
|
if (nicons != 0) {
|
|
|
|
panel->dir.list = g_new (file_entry, nicons);
|
|
|
|
|
|
|
|
fe = panel->dir.list;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
marked_count++;
|
|
|
|
fe->f.marked = TRUE;
|
|
|
|
|
1999-04-13 06:05:15 +04:00
|
|
|
if (dii == last_selected_icon)
|
|
|
|
selected_index = count;
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
if (S_ISDIR (fe->buf.st_mode)) {
|
|
|
|
dir_marked_count++;
|
|
|
|
if (fe->f.dir_size_computed)
|
|
|
|
total += fe->buf.st_size;
|
|
|
|
} else
|
|
|
|
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;
|
|
|
|
panel->id = -1;
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pushes our hacked-up desktop panel into the containers list */
|
|
|
|
WPanel *
|
|
|
|
push_desktop_panel_hack (void)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
PanelContainer *container;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
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);
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
if (panel->dir.list)
|
|
|
|
g_free (panel->dir.list);
|
|
|
|
|
|
|
|
g_free (panel);
|
|
|
|
}
|
|
|
|
|
1999-01-02 21:41:59 +03:00
|
|
|
/**
|
|
|
|
* desktop_icon_info_open:
|
|
|
|
* @dii: The desktop icon to open.
|
1999-06-15 02:50:45 +04:00
|
|
|
*
|
1999-01-02 21:41:59 +03:00
|
|
|
* Opens the specified desktop icon when the user double-clicks on it.
|
|
|
|
**/
|
1998-12-30 05:51:01 +03:00
|
|
|
void
|
1999-01-02 21:41:59 +03:00
|
|
|
desktop_icon_info_open (DesktopIconInfo *dii)
|
1998-12-11 05:05:19 +03:00
|
|
|
{
|
|
|
|
char *filename;
|
|
|
|
file_entry *fe;
|
1999-03-11 10:53:26 +03:00
|
|
|
int is_mounted;
|
|
|
|
char *point;
|
1999-03-11 22:23:23 +03:00
|
|
|
int launch;
|
|
|
|
|
|
|
|
filename = NULL;
|
|
|
|
fe = NULL;
|
|
|
|
launch = FALSE;
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-03-11 22:37:24 +03:00
|
|
|
/* Set the cursor */
|
1999-03-11 22:23:23 +03:00
|
|
|
|
1999-03-11 22:37:24 +03:00
|
|
|
desktop_icon_set_busy (dii, TRUE);
|
1999-03-11 22:23:23 +03:00
|
|
|
|
|
|
|
/* Open the icon */
|
|
|
|
|
|
|
|
if (dii->url) {
|
1999-01-31 00:52:40 +03:00
|
|
|
gnome_url_show (dii->url);
|
1999-03-11 22:23:23 +03:00
|
|
|
goto out;
|
1999-01-31 00:52:40 +03:00
|
|
|
}
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-03-11 22:23:23 +03:00
|
|
|
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
1998-12-11 05:05:19 +03:00
|
|
|
fe = file_entry_from_file (filename);
|
1999-02-23 09:14:02 +03:00
|
|
|
if (!fe){
|
|
|
|
message (1, _("Error"), "I could not fetch the information from the file");
|
1999-03-11 22:23:23 +03:00
|
|
|
goto out;
|
1999-02-23 09:14:02 +03:00
|
|
|
}
|
1999-03-11 05:40:53 +03:00
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
if (is_mountable (filename, fe, &is_mounted, &point)){
|
|
|
|
if (!is_mounted){
|
|
|
|
if (try_to_mount (filename, fe))
|
1999-02-23 04:56:09 +03:00
|
|
|
launch = TRUE;
|
1999-03-18 21:43:52 +03:00
|
|
|
else
|
|
|
|
launch = FALSE;
|
1999-03-11 10:53:26 +03:00
|
|
|
} else
|
|
|
|
launch = TRUE;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-03-11 10:53:26 +03:00
|
|
|
if (launch)
|
|
|
|
new_panel_at (point);
|
|
|
|
g_free (point);
|
|
|
|
} else {
|
1999-04-09 05:18:06 +04:00
|
|
|
WPanel *panel;
|
|
|
|
panel = push_desktop_panel_hack ();
|
1999-04-13 06:05:15 +04:00
|
|
|
do_enter_on_file_entry (fe);
|
1999-04-09 05:18:06 +04:00
|
|
|
layout_panel_gone (panel);
|
|
|
|
free_panel_from_desktop (panel);
|
1999-02-05 01:30:54 +03:00
|
|
|
}
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-03-11 22:23:23 +03:00
|
|
|
out:
|
|
|
|
|
|
|
|
if (fe)
|
|
|
|
file_entry_free (fe);
|
|
|
|
|
|
|
|
if (filename)
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
/* Reset the cursor */
|
|
|
|
|
1999-03-11 22:37:24 +03:00
|
|
|
desktop_icon_set_busy (dii, FALSE);
|
1998-12-11 05:05:19 +03:00
|
|
|
}
|
|
|
|
|
1998-12-30 05:51:01 +03:00
|
|
|
void
|
1999-01-02 21:41:59 +03:00
|
|
|
desktop_icon_info_delete (DesktopIconInfo *dii)
|
1998-12-30 05:51:01 +03:00
|
|
|
{
|
|
|
|
char *full_name;
|
|
|
|
struct stat s;
|
1999-01-14 04:10:32 +03:00
|
|
|
FileOpContext *ctx;
|
1998-12-30 05:51:01 +03:00
|
|
|
long progress_count = 0;
|
|
|
|
double progress_bytes = 0;
|
|
|
|
|
|
|
|
/* 1. Delete the file */
|
1999-01-14 04:10:32 +03:00
|
|
|
ctx = file_op_context_new ();
|
|
|
|
file_op_context_create_ui (ctx, OP_DELETE, TRUE);
|
1998-12-30 05:51:01 +03:00
|
|
|
x_flush_events ();
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-30 05:51:01 +03:00
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
|
1999-01-14 04:10:32 +03:00
|
|
|
|
|
|
|
if (lstat (full_name, &s) != -1) {
|
1999-01-13 02:49:37 +03:00
|
|
|
if (S_ISLNK (s.st_mode))
|
1999-01-14 04:10:32 +03:00
|
|
|
erase_file (ctx, full_name, &progress_count, &progress_bytes, TRUE);
|
1999-01-13 02:49:37 +03:00
|
|
|
else {
|
|
|
|
if (S_ISDIR (s.st_mode))
|
1999-01-14 04:10:32 +03:00
|
|
|
erase_dir (ctx, full_name, &progress_count, &progress_bytes);
|
1999-01-13 02:49:37 +03:00
|
|
|
else
|
1999-01-14 04:10:32 +03:00
|
|
|
erase_file (ctx, full_name, &progress_count, &progress_bytes, TRUE);
|
|
|
|
}
|
|
|
|
|
1999-02-16 23:18:34 +03:00
|
|
|
gnome_metadata_delete (full_name);
|
1999-01-13 02:49:37 +03:00
|
|
|
}
|
1999-01-14 04:10:32 +03:00
|
|
|
|
1998-12-30 05:51:01 +03:00
|
|
|
g_free (full_name);
|
1999-01-14 04:10:32 +03:00
|
|
|
file_op_context_destroy (ctx);
|
1998-12-30 05:51:01 +03:00
|
|
|
|
|
|
|
/* 2. Destroy the dicon */
|
1999-01-02 21:41:59 +03:00
|
|
|
desktop_icon_info_destroy (dii);
|
1998-12-30 05:51:01 +03:00
|
|
|
}
|
|
|
|
|
1999-03-11 22:37:24 +03:00
|
|
|
/**
|
|
|
|
* desktop_icon_set_busy:
|
|
|
|
* @dii: A desktop icon
|
|
|
|
* @busy: TRUE to set a watch cursor, FALSE to reset the normal arrow cursor
|
1999-06-15 02:50:45 +04:00
|
|
|
*
|
1999-03-11 22:37:24 +03:00
|
|
|
* Sets a wait/normal cursor for a desktop icon.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
desktop_icon_set_busy (DesktopIconInfo *dii, int busy)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
g_return_if_fail (dii != NULL);
|
|
|
|
|
|
|
|
if (!GTK_WIDGET_REALIZED (dii->dicon))
|
|
|
|
return;
|
|
|
|
|
2001-04-15 13:39:24 +04:00
|
|
|
cursor = gdk_cursor_new (busy ? GDK_WATCH : GDK_LEFT_PTR);
|
1999-03-11 22:37:24 +03:00
|
|
|
gdk_window_set_cursor (dii->dicon->window, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
/**
|
|
|
|
* desktop_icon_info_get_by_filename:
|
|
|
|
* @filename: A filename relative to the desktop directory
|
1999-06-15 02:50:45 +04:00
|
|
|
*
|
1999-03-11 05:40:53 +03:00
|
|
|
* Returns the desktop icon structure that corresponds to the specified filename,
|
|
|
|
* which should be relative to the desktop directory.
|
1999-06-15 02:50:45 +04:00
|
|
|
*
|
1999-03-11 05:40:53 +03:00
|
|
|
* Return value: The sought desktop icon, or NULL if it is not found.
|
|
|
|
**/
|
|
|
|
DesktopIconInfo *
|
|
|
|
desktop_icon_info_get_by_filename (char *filename)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
return g_hash_table_lookup (icon_hash, filename);
|
1999-03-11 05:40:53 +03:00
|
|
|
}
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Used to execute the popup menu for desktop icons */
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
do_popup_menu (DesktopIconInfo *dii, GdkEventButton *event)
|
1998-12-11 05:05:19 +03:00
|
|
|
{
|
|
|
|
char *filename;
|
1999-03-11 05:40:53 +03:00
|
|
|
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;
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (gpopup_do_popup2 (event, panel, dii_temp) != -1)
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
g_free (filename);
|
1999-03-11 05:40:53 +03:00
|
|
|
layout_panel_gone (panel);
|
|
|
|
free_panel_from_desktop (panel);
|
1998-12-11 05:05:19 +03:00
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Idle handler that opens a desktop icon. See below for information on why we
|
|
|
|
* do things this way.
|
1998-12-11 11:58:26 +03:00
|
|
|
*/
|
|
|
|
static gint
|
1999-01-18 22:22:23 +03:00
|
|
|
idle_open_icon (gpointer data)
|
1998-12-11 11:58:26 +03:00
|
|
|
{
|
1999-01-18 22:22:23 +03:00
|
|
|
desktop_icon_info_open (data);
|
1998-12-11 11:58:26 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Event handler for desktop icons. Button events are ignored when the icon is
|
|
|
|
* being edited; these will be handled either by the icon's text item or the
|
|
|
|
* icon_event_after() fallback.
|
|
|
|
*/
|
1998-12-05 04:01:13 +03:00
|
|
|
static gint
|
1999-01-18 22:22:23 +03:00
|
|
|
icon_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
|
1998-12-05 04:01:13 +03:00
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1999-01-18 22:22:23 +03:00
|
|
|
GnomeIconTextItem *iti;
|
|
|
|
int on_text;
|
1998-12-11 05:05:19 +03:00
|
|
|
int retval;
|
1998-12-05 04:01:13 +03:00
|
|
|
|
|
|
|
dii = data;
|
1999-01-18 22:22:23 +03:00
|
|
|
iti = GNOME_ICON_TEXT_ITEM (DESKTOP_ICON (dii->dicon)->text);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
on_text = item == GNOME_CANVAS_ITEM (iti);
|
1998-12-11 05:05:19 +03:00
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
1999-03-15 03:00:00 +03:00
|
|
|
if (event->button.button == 1 || event->button.button == 2) {
|
1999-01-18 22:22:23 +03:00
|
|
|
/* If se are editing, do not handle the event ourselves
|
|
|
|
* -- either let the text item handle it, or wait until
|
|
|
|
* we fall back to the icon_event_after() callback.
|
|
|
|
*/
|
|
|
|
if (iti->editing)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Save the mouse position for DnD */
|
|
|
|
|
|
|
|
dnd_press_x = event->button.x;
|
|
|
|
dnd_press_y = event->button.y;
|
|
|
|
|
|
|
|
/* Handle icon selection if we are not on the text item
|
|
|
|
* or if the icon is not selected in the first place.
|
|
|
|
* Otherwise, if there are modifier keys pressed, handle
|
|
|
|
* icon selection instead of starting editing.
|
|
|
|
*/
|
|
|
|
if (!on_text
|
|
|
|
|| !dii->selected
|
1999-03-15 03:00:00 +03:00
|
|
|
|| (event->button.state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
|
|
|
|
|| event->button.button == 2) {
|
1999-01-18 22:22:23 +03:00
|
|
|
/* If click on text, and the icon was not
|
|
|
|
* selected in the first place or shift is down,
|
|
|
|
* save this flag.
|
|
|
|
*/
|
|
|
|
if (on_text
|
|
|
|
&& (!dii->selected || (event->button.state & GDK_SHIFT_MASK)))
|
|
|
|
icon_select_on_text = TRUE;
|
|
|
|
|
1999-01-21 20:38:38 +03:00
|
|
|
if ((dii->selected
|
|
|
|
&& !(event->button.state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
|
|
|
|
|| ((event->button.state & GDK_CONTROL_MASK)
|
|
|
|
&& !(event->button.state & GDK_SHIFT_MASK))) {
|
1999-01-18 22:22:23 +03:00
|
|
|
dnd_select_icon_pending = TRUE;
|
1999-01-21 20:38:38 +03:00
|
|
|
dnd_select_icon_pending_state = event->button.state;
|
|
|
|
} else
|
1999-01-18 22:22:23 +03:00
|
|
|
select_icon (dii, event->button.state);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
}
|
1999-01-18 22:22:23 +03:00
|
|
|
} else if (event->button.button == 3) {
|
1999-03-11 05:40:53 +03:00
|
|
|
if (!dii->selected)
|
|
|
|
select_icon (dii, event->button.state);
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
do_popup_menu (dii, (GdkEventButton *) event);
|
1998-12-11 05:05:19 +03:00
|
|
|
retval = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_2BUTTON_PRESS:
|
1999-01-18 22:22:23 +03:00
|
|
|
if (event->button.button != 1 || iti->editing)
|
1998-12-11 05:05:19 +03:00
|
|
|
break;
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* We have an interesting race condition here. If we open the
|
|
|
|
* desktop icon here instead of doing it in the idle handler,
|
|
|
|
* the icon thinks it must begin editing itself, even when the
|
|
|
|
* icon_select_on_text flag tries to prevent it. I have no idea
|
|
|
|
* why this happens :-( - Federico
|
|
|
|
*/
|
|
|
|
gtk_idle_add (idle_open_icon, dii);
|
|
|
|
/* desktop_icon_info_open (dii); */
|
|
|
|
icon_select_on_text = TRUE;
|
1998-12-11 05:05:19 +03:00
|
|
|
retval = TRUE;
|
|
|
|
break;
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
case GDK_BUTTON_RELEASE:
|
1999-03-16 23:08:35 +03:00
|
|
|
if (!(event->button.button == 1 || event->button.button != 2))
|
1999-01-18 22:22:23 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (on_text && icon_select_on_text) {
|
|
|
|
icon_select_on_text = FALSE;
|
|
|
|
retval = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dnd_select_icon_pending) {
|
1999-01-21 20:38:38 +03:00
|
|
|
select_icon (dii, dnd_select_icon_pending_state);
|
1999-01-18 22:22:23 +03:00
|
|
|
dnd_select_icon_pending = FALSE;
|
1999-01-21 20:38:38 +03:00
|
|
|
dnd_select_icon_pending_state = 0;
|
1999-01-18 22:22:23 +03:00
|
|
|
retval = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* If the click was on the text and we actually did something, then we
|
|
|
|
* need to stop the text item's event handler from executing.
|
|
|
|
*/
|
|
|
|
if (on_text && retval)
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (iti), "event");
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Fallback handler for when the icon is being edited and the user clicks
|
|
|
|
* outside the icon's text item. This indicates that editing should be accepted
|
|
|
|
* and terminated.
|
1998-12-11 05:05:19 +03:00
|
|
|
*/
|
|
|
|
static gint
|
1999-01-18 22:22:23 +03:00
|
|
|
icon_event_after (GtkWidget *widget, GdkEventButton *event, gpointer data)
|
1998-12-11 05:05:19 +03:00
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1999-01-18 22:22:23 +03:00
|
|
|
GnomeIconTextItem *iti;
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
dii = data;
|
1999-01-18 22:22:23 +03:00
|
|
|
iti = GNOME_ICON_TEXT_ITEM (DESKTOP_ICON (dii->dicon)->text);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
if (event->type != GDK_BUTTON_PRESS)
|
|
|
|
return FALSE;
|
1998-12-11 11:58:26 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
g_return_val_if_fail (iti->editing, FALSE); /* sanity check for dropped events */
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
gnome_icon_text_item_stop_editing (iti, TRUE);
|
|
|
|
return TRUE;
|
1998-12-05 04:01:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback used when a drag from the desktop icons is started. We set the drag icon to the proper
|
|
|
|
* pixmap.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
drag_begin (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-05 04:01:13 +03:00
|
|
|
DesktopIcon *dicon;
|
|
|
|
GtkArg args[3];
|
|
|
|
GdkImlibImage *im;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
dii = data;
|
|
|
|
dicon = DESKTOP_ICON (dii->dicon);
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* See if the icon was pending to be selected */
|
|
|
|
|
|
|
|
if (dnd_select_icon_pending) {
|
|
|
|
if (!dii->selected)
|
1999-01-21 20:38:38 +03:00
|
|
|
select_icon (dii, dnd_select_icon_pending_state);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
dnd_select_icon_pending = FALSE;
|
1999-01-21 20:38:38 +03:00
|
|
|
dnd_select_icon_pending_state = 0;
|
1998-12-11 05:05:19 +03:00
|
|
|
}
|
|
|
|
|
1998-12-05 04:01:13 +03:00
|
|
|
/* FIXME: see if it is more than one icon and if so, use a multiple-files icon. */
|
|
|
|
|
|
|
|
args[0].name = "image";
|
|
|
|
args[1].name = "x";
|
|
|
|
args[2].name = "y";
|
|
|
|
gtk_object_getv (GTK_OBJECT (dicon->icon), 3, args);
|
|
|
|
im = GTK_VALUE_BOXED (args[0]);
|
|
|
|
x = GTK_VALUE_DOUBLE (args[1]);
|
|
|
|
y = GTK_VALUE_DOUBLE (args[2]);
|
|
|
|
|
|
|
|
gdk_imlib_render (im, im->rgb_width, im->rgb_height);
|
|
|
|
pixmap = gdk_imlib_copy_image (im);
|
|
|
|
mask = gdk_imlib_copy_mask (im);
|
|
|
|
|
|
|
|
gtk_drag_set_icon_pixmap (context,
|
|
|
|
gtk_widget_get_colormap (dicon->canvas),
|
|
|
|
pixmap,
|
|
|
|
mask,
|
1998-12-08 00:07:27 +03:00
|
|
|
dnd_press_x - x,
|
|
|
|
dnd_press_y - y);
|
1998-12-05 04:01:13 +03:00
|
|
|
|
|
|
|
gdk_pixmap_unref (pixmap);
|
|
|
|
gdk_bitmap_unref (mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Builds a string with the URI-list of the selected desktop icons */
|
|
|
|
static char *
|
|
|
|
build_selected_icons_uri_list (int *len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-05 04:01:13 +03:00
|
|
|
char *filelist, *p;
|
|
|
|
int desktop_dir_len;
|
|
|
|
|
|
|
|
/* First, count the number of selected icons and add up their filename lengths */
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
desktop_dir_len = strlen (desktop_directory);
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
|
|
|
|
/* "file:" + desktop_directory + "/" + dii->filename + "\r\n" */
|
|
|
|
|
|
|
|
if (dii->selected)
|
|
|
|
*len += 5 + desktop_dir_len + 1 + strlen (dii->filename) + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Second, create the file list string */
|
|
|
|
|
|
|
|
filelist = g_new (char, *len + 1); /* plus 1 for null terminator */
|
|
|
|
p = filelist;
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
|
|
|
|
if (dii->selected) {
|
|
|
|
strcpy (p, "file:");
|
|
|
|
p += 5;
|
|
|
|
|
|
|
|
strcpy (p, desktop_directory);
|
|
|
|
p += desktop_dir_len;
|
|
|
|
|
|
|
|
*p++ = '/';
|
|
|
|
|
|
|
|
strcpy (p, dii->filename);
|
|
|
|
p += strlen (dii->filename);
|
|
|
|
|
|
|
|
strcpy (p, "\r\n");
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
return filelist;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback used to get the drag data from the desktop icons */
|
|
|
|
static void
|
|
|
|
drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
|
|
|
|
guint info, guint32 time, gpointer data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-05 04:01:13 +03:00
|
|
|
char *filelist;
|
|
|
|
int len;
|
1998-12-11 21:12:21 +03:00
|
|
|
GList *files;
|
1998-12-05 04:01:13 +03:00
|
|
|
|
|
|
|
dii = data;
|
1998-12-11 21:12:21 +03:00
|
|
|
filelist = build_selected_icons_uri_list (&len);
|
1998-12-05 04:01:13 +03:00
|
|
|
|
|
|
|
switch (info) {
|
|
|
|
case TARGET_MC_DESKTOP_ICON:
|
|
|
|
case TARGET_URI_LIST:
|
|
|
|
case TARGET_TEXT_PLAIN:
|
|
|
|
gtk_selection_data_set (selection_data,
|
|
|
|
selection_data->target,
|
|
|
|
8,
|
|
|
|
filelist,
|
|
|
|
len);
|
1998-12-11 21:12:21 +03:00
|
|
|
break;
|
|
|
|
|
1999-02-06 07:15:29 +03:00
|
|
|
case TARGET_URL:
|
|
|
|
if (dii->url)
|
1998-12-11 21:12:21 +03:00
|
|
|
gtk_selection_data_set (selection_data,
|
|
|
|
selection_data->target,
|
|
|
|
8,
|
1999-02-06 07:15:29 +03:00
|
|
|
dii->url,
|
|
|
|
strlen (dii->url));
|
|
|
|
else {
|
|
|
|
files = gnome_uri_list_extract_uris (filelist);
|
|
|
|
if (files)
|
|
|
|
gtk_selection_data_set (selection_data,
|
|
|
|
selection_data->target,
|
|
|
|
8,
|
|
|
|
files->data,
|
|
|
|
strlen (files->data));
|
|
|
|
|
|
|
|
gnome_uri_list_free_strings (files);
|
1998-12-11 21:12:21 +03:00
|
|
|
}
|
1999-02-06 07:15:29 +03:00
|
|
|
|
1998-12-05 04:01:13 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
1998-12-11 21:12:21 +03:00
|
|
|
|
|
|
|
g_free (filelist);
|
1998-12-05 04:01:13 +03:00
|
|
|
}
|
|
|
|
|
1999-02-10 06:51:56 +03:00
|
|
|
/* Callback used when a drag from the desktop is finished. We need to reload
|
|
|
|
* the desktop.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
|
|
|
{
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
1999-02-10 06:51:56 +03:00
|
|
|
}
|
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
/* Set up a desktop icon as a DnD source */
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
setup_icon_dnd_source (DesktopIconInfo *dii)
|
1998-12-08 04:31:17 +03:00
|
|
|
{
|
1998-12-11 06:18:41 +03:00
|
|
|
setup_icon_dnd_actions (dii);
|
1998-12-08 04:31:17 +03:00
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_begin",
|
|
|
|
(GtkSignalFunc) drag_begin,
|
|
|
|
dii);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_data_get",
|
1999-04-06 07:49:34 +04:00
|
|
|
(GtkSignalFunc) drag_data_get,
|
1998-12-08 04:31:17 +03:00
|
|
|
dii);
|
1999-02-10 06:51:56 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_end",
|
1999-04-06 07:49:34 +04:00
|
|
|
(GtkSignalFunc) drag_end,
|
1999-02-10 06:51:56 +03:00
|
|
|
dii);
|
1998-12-08 04:31:17 +03:00
|
|
|
}
|
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
/* Callback used when we get a drag_motion event from a desktop icon. We have
|
1999-01-21 12:46:01 +03:00
|
|
|
* to decide which operation to perform based on the type of the data the user
|
|
|
|
* is dragging.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
icon_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
DesktopIconInfo *dii;
|
|
|
|
char *filename;
|
|
|
|
file_entry *fe;
|
|
|
|
GdkDragAction action;
|
1999-02-03 14:46:01 +03:00
|
|
|
GtkWidget *source_widget;
|
|
|
|
int is_desktop_icon;
|
1999-01-21 12:46:01 +03:00
|
|
|
|
|
|
|
dii = data;
|
|
|
|
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
|
|
|
fe = file_entry_from_file (filename);
|
|
|
|
g_free (filename);
|
1999-02-03 14:46:01 +03:00
|
|
|
if (!fe)
|
|
|
|
return 0; /* eeek */
|
1999-01-21 12:46:01 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
gdnd_find_panel_by_drag_context (context, &source_widget);
|
|
|
|
is_desktop_icon = gdnd_drag_context_has_target (context, TARGET_MC_DESKTOP_ICON);
|
|
|
|
|
|
|
|
action = gdnd_validate_action (context,
|
|
|
|
TRUE,
|
|
|
|
source_widget != NULL,
|
|
|
|
source_widget && is_desktop_icon,
|
1999-02-18 03:07:26 +03:00
|
|
|
desktop_directory,
|
1999-02-03 14:46:01 +03:00
|
|
|
fe,
|
|
|
|
dii->selected);
|
1999-01-21 12:46:01 +03:00
|
|
|
|
|
|
|
gdk_drag_status (context, action, time);
|
1999-02-23 05:53:30 +03:00
|
|
|
file_entry_free (fe);
|
1999-01-21 12:46:01 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-01-31 00:52:40 +03:00
|
|
|
/*
|
|
|
|
* Returns the desktop icon that started the drag from the specified
|
|
|
|
* context
|
|
|
|
*/
|
1999-01-21 12:46:01 +03:00
|
|
|
static DesktopIconInfo *
|
|
|
|
find_icon_by_drag_context (GdkDragContext *context)
|
|
|
|
{
|
|
|
|
GtkWidget *source;
|
|
|
|
int i;
|
|
|
|
GList *l;
|
|
|
|
DesktopIconInfo *dii;
|
|
|
|
|
|
|
|
source = gtk_drag_get_source_widget (context);
|
|
|
|
if (!source)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
source = gtk_widget_get_toplevel (source);
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
|
|
|
|
if (dii->dicon == source)
|
|
|
|
return dii;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-01-31 00:52:40 +03:00
|
|
|
* Performs a drop of desktop icons onto the desktop. It basically
|
|
|
|
* moves the icons from their original position to the new
|
|
|
|
* coordinates.
|
1999-01-21 12:46:01 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
drop_desktop_icons (GdkDragContext *context, GtkSelectionData *data, int x, int y)
|
|
|
|
{
|
|
|
|
DesktopIconInfo *source_dii, *dii;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
int dx, dy, sl_x, sl_y, sl_max_x, sl_max_y, sl_min_x, sl_min_y;
|
1999-01-21 12:46:01 +03:00
|
|
|
int i;
|
|
|
|
GList *l;
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
GSList *sel_icons, *sl, *sl2, *sl2_p;
|
1999-01-21 12:46:01 +03:00
|
|
|
|
|
|
|
/* Find the icon that the user is dragging */
|
|
|
|
|
|
|
|
source_dii = find_icon_by_drag_context (context);
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
if (!source_dii) {
|
|
|
|
g_warning ("Eeeeek, could not find the icon that started the drag!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
x -= dnd_press_x;
|
|
|
|
y -= dnd_press_y;
|
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
/* Compute the distance to move icons */
|
|
|
|
|
|
|
|
if (desktop_snap_icons)
|
|
|
|
get_icon_snap_pos (&x, &y);
|
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
dx = x - source_dii->x;
|
|
|
|
dy = y - source_dii->y;
|
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
|
|
|
|
/* Build a list of selected icons */
|
|
|
|
|
|
|
|
sel_icons = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
if (dii->selected)
|
|
|
|
sel_icons = g_slist_prepend (sel_icons, l->data);
|
|
|
|
}
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* Move the icons. FIXME: handle auto-placement by reinserting the
|
|
|
|
* icons in the proper place.
|
|
|
|
*/
|
1999-01-21 12:46:01 +03:00
|
|
|
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
if (!desktop_auto_placement) {
|
|
|
|
sl2 = NULL;
|
|
|
|
sl2_p = NULL;
|
|
|
|
for (sl = sel_icons; sl; sl = sl->next) {
|
|
|
|
dii = sl->data;
|
|
|
|
sl2 = g_slist_prepend (sl2, (void *) (dii->x + dx));
|
|
|
|
sl2 = g_slist_prepend (sl2, (void *) (dii->y + dy));
|
|
|
|
}
|
|
|
|
|
|
|
|
sl_max_x = 0;
|
|
|
|
sl_max_y = 0;
|
|
|
|
sl_min_x = INT_MAX;
|
|
|
|
sl_min_y = INT_MAX;
|
|
|
|
sl2_p = sl2;
|
|
|
|
|
|
|
|
/* For multiple icon drags, get the min/max x and y coordinates */
|
|
|
|
for (sl = sel_icons; sl; sl = sl->next) {
|
|
|
|
sl_y = (int) sl2_p->data;
|
|
|
|
sl2_p = sl2_p->next;
|
|
|
|
sl_x = (int) sl2_p->data;
|
|
|
|
sl2_p = sl2_p->next;
|
|
|
|
|
|
|
|
if (sl_x > sl_max_x) {
|
|
|
|
sl_max_x = sl_x;
|
|
|
|
}
|
|
|
|
if (sl_x < sl_min_x) {
|
|
|
|
sl_min_x = sl_x;
|
|
|
|
}
|
|
|
|
if (sl_y > sl_max_y) {
|
|
|
|
sl_max_y = sl_y;
|
|
|
|
}
|
|
|
|
if (sl_x < sl_min_y) {
|
|
|
|
sl_min_y = sl_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (sl2);
|
|
|
|
|
|
|
|
/* Make sure that no icons are placed off the screen, and keep their relative positions */
|
|
|
|
if (sl_max_x > layout_screen_width - (DESKTOP_SNAP_X + layout_spacer_width / 2)) {
|
|
|
|
dx -= (sl_max_x - (layout_screen_width -
|
|
|
|
(DESKTOP_SNAP_X + layout_spacer_width / 2)));
|
|
|
|
}
|
|
|
|
if (sl_max_y > layout_screen_height - (DESKTOP_SNAP_Y + layout_spacer_height / 2)) {
|
|
|
|
dy -= (sl_max_y - (layout_screen_height -
|
|
|
|
(DESKTOP_SNAP_Y + layout_spacer_width / 2)));
|
|
|
|
}
|
|
|
|
if (sl_min_x < layout_spacer_width / 2) {
|
|
|
|
dx += (layout_spacer_width / 2 - sl_min_x);
|
|
|
|
}
|
|
|
|
if (sl_min_y < layout_spacer_height / 2) {
|
|
|
|
dy += (layout_spacer_height / 2 - sl_min_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Place the icons */
|
1999-02-15 20:59:49 +03:00
|
|
|
for (sl = sel_icons; sl; sl = sl->next) {
|
|
|
|
dii = sl->data;
|
|
|
|
desktop_icon_info_place (dii, dii->x + dx, dii->y + dy);
|
|
|
|
}
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
}
|
1999-01-21 12:46:01 +03:00
|
|
|
/* Clean up */
|
|
|
|
|
|
|
|
g_slist_free (sel_icons);
|
|
|
|
}
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* Handler for drag_data_received for desktop icons */
|
1998-12-30 06:24:46 +03:00
|
|
|
static void
|
|
|
|
icon_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
|
|
|
GtkSelectionData *data, guint info, guint time, gpointer user_data)
|
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-30 06:24:46 +03:00
|
|
|
|
|
|
|
dii = user_data;
|
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
if (gdnd_drag_context_has_target (context, TARGET_MC_DESKTOP_ICON) && dii->selected)
|
|
|
|
drop_desktop_icons (context, data, x + dii->x, y + dii->y);
|
|
|
|
else {
|
|
|
|
char *full_name;
|
|
|
|
file_entry *fe;
|
1999-01-25 19:50:38 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
|
|
|
|
fe = file_entry_from_file (full_name);
|
1999-08-31 00:07:33 +04:00
|
|
|
if (!fe) {
|
1999-03-10 20:54:33 +03:00
|
|
|
g_free (full_name);
|
|
|
|
return;
|
|
|
|
}
|
1999-01-21 12:46:01 +03:00
|
|
|
|
1999-08-27 09:01:08 +04:00
|
|
|
if (gdnd_perform_drop (context, data, full_name, fe))
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
1998-12-08 04:31:17 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
file_entry_free (fe);
|
1999-03-10 20:54:33 +03:00
|
|
|
g_free (full_name);
|
1998-12-08 04:31:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up a desktop icon as a DnD destination */
|
|
|
|
static void
|
1998-12-31 04:43:11 +03:00
|
|
|
setup_icon_dnd_dest (DesktopIconInfo *dii)
|
1998-12-08 04:31:17 +03:00
|
|
|
{
|
|
|
|
gtk_drag_dest_set (DESKTOP_ICON (dii->dicon)->canvas,
|
1999-01-21 12:46:01 +03:00
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1998-12-08 04:31:17 +03:00
|
|
|
dnd_icon_targets,
|
|
|
|
dnd_icon_ntargets,
|
1999-01-21 12:46:01 +03:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
1998-12-08 04:31:17 +03:00
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_motion",
|
|
|
|
(GtkSignalFunc) (icon_drag_motion),
|
|
|
|
dii);
|
1998-12-08 04:31:17 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_data_received",
|
1999-01-21 12:46:01 +03:00
|
|
|
(GtkSignalFunc) icon_drag_data_received,
|
1998-12-08 04:31:17 +03:00
|
|
|
dii);
|
|
|
|
}
|
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
/* Creates a new desktop icon. The filename is the pruned filename inside the
|
|
|
|
* desktop directory. It does not show the icon.
|
1998-10-30 03:47:54 +03:00
|
|
|
*/
|
1998-12-31 04:43:11 +03:00
|
|
|
static DesktopIconInfo *
|
1999-02-15 20:59:49 +03:00
|
|
|
desktop_icon_info_new (char *filename, char *url, char *caption, int xpos, int ypos)
|
1998-10-30 03:47:54 +03:00
|
|
|
{
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-09 20:23:38 +03:00
|
|
|
file_entry *fe;
|
1998-10-30 20:08:03 +03:00
|
|
|
char *full_name;
|
1998-12-09 20:23:38 +03:00
|
|
|
GdkImlibImage *icon_im;
|
1999-03-15 03:00:00 +03:00
|
|
|
|
1998-11-02 02:21:24 +03:00
|
|
|
/* Create the icon structure */
|
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
full_name = g_concat_dir_and_file (desktop_directory, filename);
|
1998-12-09 20:23:38 +03:00
|
|
|
fe = file_entry_from_file (full_name);
|
1999-02-23 09:14:02 +03:00
|
|
|
if (!fe)
|
|
|
|
return NULL;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-31 04:43:11 +03:00
|
|
|
dii = g_new (DesktopIconInfo, 1);
|
1998-11-03 04:32:38 +03:00
|
|
|
dii->x = 0;
|
|
|
|
dii->y = 0;
|
|
|
|
dii->slot = -1;
|
1999-02-06 02:15:52 +03:00
|
|
|
|
1999-02-06 05:40:38 +03:00
|
|
|
if (url) {
|
1999-02-06 02:15:52 +03:00
|
|
|
dii->url = g_strdup (url);
|
1999-02-06 04:57:26 +03:00
|
|
|
if (!caption)
|
|
|
|
caption = url;
|
1999-02-06 02:15:52 +03:00
|
|
|
} else {
|
|
|
|
dii->url = NULL;
|
1999-02-17 22:58:24 +03:00
|
|
|
if (caption == NULL)
|
|
|
|
caption = filename;
|
1999-02-06 02:15:52 +03:00
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1999-02-17 03:38:16 +03:00
|
|
|
icon_im = gicon_get_icon_for_file (desktop_directory, fe, FALSE);
|
1999-02-06 02:15:52 +03:00
|
|
|
dii->dicon = desktop_icon_new (icon_im, caption);
|
1998-10-30 20:08:03 +03:00
|
|
|
dii->filename = g_strdup (filename);
|
|
|
|
dii->selected = FALSE;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-09 20:23:38 +03:00
|
|
|
file_entry_free (fe);
|
1998-10-30 20:08:03 +03:00
|
|
|
g_free (full_name);
|
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
/* Connect to the icon's signals. We connect to the image/stipple and
|
|
|
|
* text items separately so that the callback can distinguish between
|
|
|
|
* them. This is not a hack.
|
|
|
|
*/
|
1998-11-02 02:21:24 +03:00
|
|
|
|
1999-01-18 22:22:23 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->icon), "event",
|
|
|
|
(GtkSignalFunc) icon_event,
|
1998-11-02 02:21:24 +03:00
|
|
|
dii);
|
1999-01-18 22:22:23 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->stipple), "event",
|
|
|
|
(GtkSignalFunc) icon_event,
|
1998-11-02 02:21:24 +03:00
|
|
|
dii);
|
1999-01-18 22:22:23 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->text), "event",
|
|
|
|
(GtkSignalFunc) icon_event,
|
|
|
|
dii);
|
|
|
|
|
|
|
|
/* Connect_after to button presses on the icon's window. This is a
|
|
|
|
* fallback for when the icon is being edited and a button press is not
|
|
|
|
* handled by the icon's text item -- this means the user has clicked
|
|
|
|
* outside the text item and wishes to accept and terminate editing.
|
|
|
|
*/
|
|
|
|
gtk_signal_connect_after (GTK_OBJECT (dii->dicon), "button_press_event",
|
|
|
|
(GtkSignalFunc) icon_event_after,
|
1998-12-11 11:58:26 +03:00
|
|
|
dii);
|
1998-10-31 02:22:35 +03:00
|
|
|
|
1998-11-05 02:01:24 +03:00
|
|
|
/* Connect to the text item's signals */
|
|
|
|
|
1998-11-06 02:24:47 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->text), "text_changed",
|
1999-03-15 03:00:00 +03:00
|
|
|
(GtkSignalFunc) text_changed, dii);
|
1999-01-31 00:52:40 +03:00
|
|
|
|
1998-11-05 02:01:24 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->text), "editing_started",
|
|
|
|
(GtkSignalFunc) editing_started,
|
|
|
|
dii);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->text), "editing_stopped",
|
|
|
|
(GtkSignalFunc) editing_stopped,
|
|
|
|
dii);
|
1999-01-18 22:22:23 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->text), "selection_stopped",
|
|
|
|
(GtkSignalFunc) selection_stopped,
|
|
|
|
dii);
|
1998-11-05 02:01:24 +03:00
|
|
|
|
1999-06-18 02:42:01 +04:00
|
|
|
/* We must set the icon's wmclass and name. It is already realized (it
|
|
|
|
* comes out realized from desktop_icon_new()).
|
|
|
|
*/
|
|
|
|
set_icon_wmclass (dii);
|
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
/* Prepare the DnD functionality for this icon */
|
1998-12-05 04:01:13 +03:00
|
|
|
|
1998-12-08 04:31:17 +03:00
|
|
|
setup_icon_dnd_source (dii);
|
|
|
|
setup_icon_dnd_dest (dii);
|
1998-12-05 04:01:13 +03:00
|
|
|
|
1998-11-02 02:21:24 +03:00
|
|
|
/* Place the icon and append it to the list */
|
1999-02-15 20:59:49 +03:00
|
|
|
desktop_icon_info_place (dii, xpos, ypos);
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Put into icon hash table */
|
|
|
|
g_hash_table_insert (icon_hash, dii->filename, dii);
|
|
|
|
|
1998-10-31 02:22:35 +03:00
|
|
|
return dii;
|
|
|
|
}
|
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
/* Creates the layout information array */
|
|
|
|
static void
|
|
|
|
create_layout_info (void)
|
|
|
|
{
|
1998-12-07 18:47:00 +03:00
|
|
|
layout_screen_width = gdk_screen_width ();
|
|
|
|
layout_screen_height = gdk_screen_height ();
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
layout_cols = layout_screen_width / DESKTOP_SNAP_X;
|
|
|
|
layout_rows = layout_screen_height / DESKTOP_SNAP_Y;
|
|
|
|
|
|
|
|
/* Adjust icon size to spread the icons evenly across the screen */
|
|
|
|
layout_spacer_width = (layout_screen_width / layout_cols) - DESKTOP_SNAP_X;
|
|
|
|
layout_spacer_height = (layout_screen_height / layout_rows) - DESKTOP_SNAP_Y;
|
|
|
|
|
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
layout_slots = g_new0 (struct layout_slot, layout_cols * layout_rows);
|
1998-10-30 03:47:54 +03:00
|
|
|
}
|
|
|
|
|
2001-04-13 05:03:22 +04:00
|
|
|
/*
|
|
|
|
* Rename old Trash directory if found
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
migrate_init (void)
|
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
char *old_trash_dir = g_concat_dir_and_file (desktop_directory, "Trash");
|
|
|
|
if (stat (old_trash_dir, &buf) == 0 && S_ISDIR (buf.st_mode)){
|
|
|
|
char *new_trash_dir = g_concat_dir_and_file (desktop_directory, "Trash.gmc");
|
|
|
|
|
|
|
|
rename (old_trash_dir, new_trash_dir);
|
|
|
|
gnome_metadata_rename (old_trash_dir, new_trash_dir);
|
|
|
|
g_free (new_trash_dir);
|
|
|
|
}
|
|
|
|
g_free (old_trash_dir);
|
|
|
|
}
|
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
/*
|
|
|
|
* Check that the user's desktop directory exists, and if not, create the
|
1999-02-19 00:43:07 +03:00
|
|
|
* default desktop setup.
|
1998-10-30 03:47:54 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
create_desktop_dir (void)
|
|
|
|
{
|
2001-07-12 22:23:53 +04:00
|
|
|
char *desktop_symlink;
|
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
if (getenv ("GNOME_DESKTOP_DIR") != NULL)
|
|
|
|
desktop_directory = g_strdup (getenv ("GNOME_DESKTOP_DIR"));
|
|
|
|
else
|
|
|
|
desktop_directory = g_concat_dir_and_file (gnome_user_home_dir, DESKTOP_DIR_NAME);
|
1998-10-30 03:47:54 +03:00
|
|
|
|
|
|
|
if (!g_file_exists (desktop_directory)) {
|
2001-07-12 22:23:53 +04:00
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
/* Create the directory */
|
|
|
|
mkdir (desktop_directory, 0777);
|
|
|
|
|
1999-09-20 20:34:38 +04:00
|
|
|
/* Create the default set of icons */
|
|
|
|
|
|
|
|
gdesktop_links_init ();
|
|
|
|
gmount_setup_devices ();
|
|
|
|
gprint_setup_devices ();
|
1998-10-30 03:47:54 +03:00
|
|
|
}
|
2001-07-12 22:23:53 +04:00
|
|
|
|
|
|
|
/* Create a user-visible symlink at ~/Desktop */
|
|
|
|
desktop_symlink = g_concat_dir_and_file (gnome_user_home_dir, "Desktop");
|
|
|
|
|
|
|
|
if (! g_file_exists (desktop_symlink))
|
|
|
|
symlink (desktop_directory, desktop_symlink);
|
|
|
|
|
|
|
|
g_free (desktop_symlink);
|
|
|
|
|
2001-04-13 05:03:22 +04:00
|
|
|
migrate_init ();
|
1998-10-30 03:47:54 +03:00
|
|
|
}
|
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
/* Property placed on target windows */
|
|
|
|
typedef struct {
|
|
|
|
guint8 byte_order;
|
|
|
|
guint8 protocol_version;
|
|
|
|
guint8 protocol_style;
|
|
|
|
guint8 pad;
|
|
|
|
guint32 proxy_window;
|
|
|
|
guint16 num_drop_sites;
|
|
|
|
guint16 padding;
|
|
|
|
guint32 total_size;
|
|
|
|
} MotifDragReceiverInfo;
|
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
/* Sets up a proxy window for DnD on the specified X window. Courtesy of Owen Taylor */
|
1999-06-15 02:50:45 +04:00
|
|
|
static gboolean
|
1998-12-03 02:37:27 +03:00
|
|
|
setup_xdnd_proxy (guint32 xid, GdkWindow *proxy_window)
|
|
|
|
{
|
|
|
|
GdkAtom xdnd_proxy_atom;
|
1999-02-23 01:59:58 +03:00
|
|
|
Window proxy_xid;
|
1998-12-03 02:37:27 +03:00
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, after;
|
|
|
|
Window *proxy_data;
|
|
|
|
Window proxy;
|
|
|
|
guint32 old_warnings;
|
|
|
|
|
|
|
|
XGrabServer (GDK_DISPLAY ());
|
|
|
|
|
|
|
|
xdnd_proxy_atom = gdk_atom_intern ("XdndProxy", FALSE);
|
|
|
|
proxy_xid = GDK_WINDOW_XWINDOW (proxy_window);
|
|
|
|
type = None;
|
|
|
|
proxy = None;
|
|
|
|
|
|
|
|
old_warnings = gdk_error_warnings;
|
|
|
|
|
|
|
|
gdk_error_code = 0;
|
|
|
|
gdk_error_warnings = 0;
|
|
|
|
|
|
|
|
/* Check if somebody else already owns drops on the root window */
|
|
|
|
|
|
|
|
XGetWindowProperty (GDK_DISPLAY (), xid,
|
|
|
|
xdnd_proxy_atom, 0,
|
|
|
|
1, False, AnyPropertyType,
|
|
|
|
&type, &format, &nitems, &after,
|
|
|
|
(guchar **) &proxy_data);
|
|
|
|
|
|
|
|
if (type != None) {
|
1998-12-11 05:05:19 +03:00
|
|
|
if (format == 32 && nitems == 1)
|
1998-12-03 02:37:27 +03:00
|
|
|
proxy = *proxy_data;
|
|
|
|
|
|
|
|
XFree (proxy_data);
|
|
|
|
}
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* The property was set, now check if the window it points to exists and
|
|
|
|
* has a XdndProxy property pointing to itself.
|
1998-12-03 02:37:27 +03:00
|
|
|
*/
|
|
|
|
if (proxy) {
|
1999-06-15 02:50:45 +04:00
|
|
|
XGetWindowProperty (GDK_DISPLAY (), proxy,
|
|
|
|
xdnd_proxy_atom, 0,
|
1998-12-03 02:37:27 +03:00
|
|
|
1, False, AnyPropertyType,
|
1999-06-15 02:50:45 +04:00
|
|
|
&type, &format, &nitems, &after,
|
1998-12-03 02:37:27 +03:00
|
|
|
(guchar **) &proxy_data);
|
|
|
|
|
|
|
|
if (!gdk_error_code && type != None) {
|
1998-12-11 05:05:19 +03:00
|
|
|
if (format == 32 && nitems == 1)
|
1998-12-03 02:37:27 +03:00
|
|
|
if (*proxy_data != proxy)
|
|
|
|
proxy = GDK_NONE;
|
|
|
|
|
|
|
|
XFree (proxy_data);
|
|
|
|
} else
|
|
|
|
proxy = GDK_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!proxy) {
|
|
|
|
/* OK, we can set the property to point to us */
|
|
|
|
|
|
|
|
XChangeProperty (GDK_DISPLAY (), xid,
|
|
|
|
xdnd_proxy_atom, gdk_atom_intern ("WINDOW", FALSE),
|
|
|
|
32, PropModeReplace,
|
|
|
|
(guchar *) &proxy_xid, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_error_code = 0;
|
|
|
|
gdk_error_warnings = old_warnings;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
XUngrabServer (GDK_DISPLAY ());
|
1998-12-11 15:59:47 +03:00
|
|
|
gdk_flush ();
|
1998-12-03 02:37:27 +03:00
|
|
|
|
|
|
|
if (!proxy) {
|
|
|
|
/* Mark our window as a valid proxy window with a XdndProxy
|
|
|
|
* property pointing recursively;
|
|
|
|
*/
|
|
|
|
XChangeProperty (GDK_DISPLAY (), proxy_xid,
|
|
|
|
xdnd_proxy_atom, gdk_atom_intern ("WINDOW", FALSE),
|
|
|
|
32, PropModeReplace,
|
|
|
|
(guchar *) &proxy_xid, 1);
|
1999-02-02 05:34:46 +03:00
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
return TRUE;
|
|
|
|
} else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
/* Sets up a window as a Motif DnD proxy */
|
|
|
|
static void
|
|
|
|
setup_motif_dnd_proxy (guint32 xid, GdkWindow *proxy_window)
|
|
|
|
{
|
1999-02-23 01:59:58 +03:00
|
|
|
Window proxy_xid;
|
1999-02-02 05:34:46 +03:00
|
|
|
MotifDragReceiverInfo info;
|
|
|
|
Atom receiver_info_atom;
|
|
|
|
guint32 myint;
|
|
|
|
|
|
|
|
myint = 0x01020304;
|
|
|
|
proxy_xid = GDK_WINDOW_XWINDOW (proxy_window);
|
|
|
|
receiver_info_atom = gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE);
|
|
|
|
|
|
|
|
info.byte_order = (*((gchar *) &myint) == 1) ? 'B' : 'l';
|
|
|
|
info.protocol_version = 0;
|
|
|
|
info.protocol_style = 5; /* XmDRAG_DYNAMIC */
|
|
|
|
info.proxy_window = proxy_xid;
|
|
|
|
info.num_drop_sites = 0;
|
1999-08-10 02:54:02 +04:00
|
|
|
info.total_size = sizeof (info);
|
1999-02-02 05:34:46 +03:00
|
|
|
|
|
|
|
XChangeProperty (gdk_display, xid,
|
|
|
|
receiver_info_atom,
|
|
|
|
receiver_info_atom,
|
|
|
|
8, PropModeReplace,
|
|
|
|
(guchar *)&info,
|
|
|
|
sizeof (info));
|
|
|
|
}
|
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
/* Callback used when we get a drag_motion event from the desktop. We must
|
|
|
|
* decide what kind of operation can be performed with what the user is
|
|
|
|
* dragging.
|
1998-12-07 18:47:00 +03:00
|
|
|
*/
|
1999-01-21 12:46:01 +03:00
|
|
|
static gboolean
|
|
|
|
desktop_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time,
|
|
|
|
gpointer data)
|
1998-12-07 18:47:00 +03:00
|
|
|
{
|
1999-01-21 12:46:01 +03:00
|
|
|
GdkDragAction action;
|
|
|
|
GtkWidget *source_widget;
|
1999-02-03 14:46:01 +03:00
|
|
|
int is_desktop_icon;
|
1998-12-07 18:47:00 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
gdnd_find_panel_by_drag_context (context, &source_widget);
|
|
|
|
is_desktop_icon = gdnd_drag_context_has_target (context, TARGET_MC_DESKTOP_ICON);
|
1998-12-07 18:47:00 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
action = gdnd_validate_action (context,
|
|
|
|
TRUE,
|
|
|
|
source_widget != NULL,
|
|
|
|
source_widget && is_desktop_icon,
|
1999-02-18 03:07:26 +03:00
|
|
|
desktop_directory,
|
1999-02-03 14:46:01 +03:00
|
|
|
NULL,
|
|
|
|
FALSE);
|
1998-12-07 18:47:00 +03:00
|
|
|
|
1999-01-21 12:46:01 +03:00
|
|
|
gdk_drag_status (context, action, time);
|
|
|
|
return TRUE;
|
1998-12-07 18:47:00 +03:00
|
|
|
}
|
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
/* Callback used when the root window receives a drop */
|
1998-12-03 19:11:01 +03:00
|
|
|
static void
|
1998-12-08 04:31:17 +03:00
|
|
|
desktop_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
|
|
|
GtkSelectionData *data, guint info, guint time, gpointer user_data)
|
1998-12-03 02:37:27 +03:00
|
|
|
{
|
1998-12-04 05:08:06 +03:00
|
|
|
gint dx, dy;
|
|
|
|
|
1998-12-08 00:07:27 +03:00
|
|
|
/* Fix the proxy window offsets */
|
|
|
|
|
|
|
|
gdk_window_get_position (widget->window, &dx, &dy);
|
|
|
|
x += dx;
|
|
|
|
y += dy;
|
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
if (gdnd_drag_context_has_target (context, TARGET_MC_DESKTOP_ICON))
|
1998-12-07 18:47:00 +03:00
|
|
|
drop_desktop_icons (context, data, x, y);
|
1999-02-03 14:46:01 +03:00
|
|
|
else {
|
|
|
|
file_entry *desktop_fe;
|
1998-12-05 04:01:13 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
desktop_fe = file_entry_from_file (desktop_directory);
|
|
|
|
if (!desktop_fe)
|
|
|
|
return; /* eeek */
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1999-02-23 22:21:35 +03:00
|
|
|
if (gdnd_perform_drop (context, data, desktop_directory, desktop_fe))
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_reload_icons (TRUE, x, y);
|
1999-02-02 05:34:46 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
file_entry_free (desktop_fe);
|
1998-12-03 02:37:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sets up drag and drop to the desktop root window */
|
|
|
|
static void
|
|
|
|
setup_desktop_dnd (void)
|
|
|
|
{
|
1999-02-02 05:34:46 +03:00
|
|
|
if (!setup_xdnd_proxy (GDK_ROOT_WINDOW (), proxy_invisible->window))
|
|
|
|
g_warning ("There is already a process taking drops on the desktop!\n");
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
setup_motif_dnd_proxy (GDK_ROOT_WINDOW (), proxy_invisible->window);
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_drag_dest_set (proxy_invisible,
|
1999-01-21 12:46:01 +03:00
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1998-12-08 04:31:17 +03:00
|
|
|
dnd_desktop_targets,
|
|
|
|
dnd_desktop_ntargets,
|
1998-12-04 05:08:06 +03:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "drag_motion",
|
1999-01-21 12:46:01 +03:00
|
|
|
(GtkSignalFunc) desktop_drag_motion,
|
|
|
|
NULL);
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "drag_data_received",
|
1999-01-21 12:46:01 +03:00
|
|
|
(GtkSignalFunc) desktop_drag_data_received,
|
1998-12-08 04:31:17 +03:00
|
|
|
NULL);
|
1998-12-03 02:37:27 +03:00
|
|
|
}
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Looks for the proxy window to get root window clicks from the window manager */
|
|
|
|
static GdkWindow *
|
|
|
|
find_click_proxy_window (void)
|
|
|
|
{
|
|
|
|
GdkAtom click_proxy_atom;
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, after;
|
|
|
|
Window *proxy_data;
|
|
|
|
Window proxy;
|
|
|
|
guint32 old_warnings;
|
|
|
|
GdkWindow *proxy_gdk_window;
|
|
|
|
|
|
|
|
XGrabServer (GDK_DISPLAY ());
|
|
|
|
|
|
|
|
click_proxy_atom = gdk_atom_intern ("_WIN_DESKTOP_BUTTON_PROXY", FALSE);
|
|
|
|
type = None;
|
|
|
|
proxy = None;
|
|
|
|
|
|
|
|
old_warnings = gdk_error_warnings;
|
|
|
|
|
|
|
|
gdk_error_code = 0;
|
|
|
|
gdk_error_warnings = 0;
|
|
|
|
|
|
|
|
/* Check if the proxy window exists */
|
|
|
|
|
|
|
|
XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
|
|
|
click_proxy_atom, 0,
|
|
|
|
1, False, AnyPropertyType,
|
|
|
|
&type, &format, &nitems, &after,
|
|
|
|
(guchar **) &proxy_data);
|
|
|
|
|
|
|
|
if (type != None) {
|
|
|
|
if (format == 32 && nitems == 1)
|
|
|
|
proxy = *proxy_data;
|
|
|
|
|
|
|
|
XFree (proxy_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The property was set, now check if the window it points to exists and
|
|
|
|
* has a _WIN_DESKTOP_BUTTON_PROXY property pointing to itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (proxy) {
|
|
|
|
XGetWindowProperty (GDK_DISPLAY (), proxy,
|
|
|
|
click_proxy_atom, 0,
|
|
|
|
1, False, AnyPropertyType,
|
|
|
|
&type, &format, &nitems, &after,
|
|
|
|
(guchar **) &proxy_data);
|
|
|
|
|
|
|
|
if (!gdk_error_code && type != None) {
|
|
|
|
if (format == 32 && nitems == 1)
|
|
|
|
if (*proxy_data != proxy)
|
|
|
|
proxy = GDK_NONE;
|
|
|
|
|
|
|
|
XFree (proxy_data);
|
|
|
|
} else
|
|
|
|
proxy = GDK_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_error_code = 0;
|
|
|
|
gdk_error_warnings = old_warnings;
|
|
|
|
|
|
|
|
XUngrabServer (GDK_DISPLAY ());
|
1998-12-11 15:59:47 +03:00
|
|
|
gdk_flush ();
|
1998-12-11 05:05:19 +03:00
|
|
|
|
|
|
|
if (proxy)
|
|
|
|
proxy_gdk_window = gdk_window_foreign_new (proxy);
|
|
|
|
else
|
|
|
|
proxy_gdk_window = NULL;
|
|
|
|
|
|
|
|
return proxy_gdk_window;
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by name */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_name (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_arrange_icons (SORT_NAME);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by file type */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_type (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_arrange_icons (SORT_EXTENSION);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by file size */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_size (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_arrange_icons (SORT_SIZE);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by access time */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_access (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_arrange_icons (SORT_ACCESS);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by modification time */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_mod (GtkWidget *widget, gpointer data)
|
1999-02-15 20:59:49 +03:00
|
|
|
{
|
1999-08-09 07:41:39 +04:00
|
|
|
desktop_arrange_icons (SORT_MODIFY);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Callback for arranging icons by change time */
|
|
|
|
static void
|
1999-08-09 07:41:39 +04:00
|
|
|
handle_arrange_icons_change (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_arrange_icons (SORT_CHANGE);
|
1999-02-15 20:59:49 +03:00
|
|
|
}
|
|
|
|
|
2000-05-15 21:29:02 +04:00
|
|
|
/* Callback for running all desktop icons through snap-to-grid */
|
|
|
|
static void
|
|
|
|
handle_tidy_icons (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_tidy_icons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-19 00:43:07 +03:00
|
|
|
/* Callback for creating a new panel window */
|
|
|
|
static void
|
|
|
|
handle_new_window (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
new_panel_at (gnome_user_home_dir);
|
|
|
|
}
|
|
|
|
|
1999-09-21 04:40:21 +04:00
|
|
|
/* Callback for rescanning the desktop directory */
|
|
|
|
static void
|
|
|
|
handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
}
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Rescans the mountable devices in the desktop and re-creates their icons */
|
1999-02-23 04:56:09 +03:00
|
|
|
void
|
|
|
|
desktop_rescan_devices (void)
|
|
|
|
{
|
1999-02-25 08:11:35 +03:00
|
|
|
desktop_cleanup_devices ();
|
1999-09-20 20:34:38 +04:00
|
|
|
gmount_setup_devices ();
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
}
|
|
|
|
|
1999-02-19 00:43:07 +03:00
|
|
|
/* Callback for rescanning the mountable devices */
|
|
|
|
static void
|
|
|
|
handle_rescan_devices (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_rescan_devices ();
|
1999-02-19 00:43:07 +03:00
|
|
|
}
|
|
|
|
|
1999-09-21 04:40:21 +04:00
|
|
|
void
|
|
|
|
desktop_recreate_default_icons (void)
|
|
|
|
{
|
|
|
|
gdesktop_links_init ();
|
|
|
|
gprint_setup_devices ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback for re-creating the default icons */
|
1999-02-15 20:59:49 +03:00
|
|
|
static void
|
1999-09-21 04:40:21 +04:00
|
|
|
handle_recreate_default_icons (GtkWidget *widget, gpointer data)
|
1999-02-15 20:59:49 +03:00
|
|
|
{
|
1999-09-21 04:40:21 +04:00
|
|
|
desktop_recreate_default_icons ();
|
1999-02-15 20:59:49 +03:00
|
|
|
}
|
1999-05-01 17:58:00 +04:00
|
|
|
|
1999-03-26 02:17:55 +03:00
|
|
|
static void
|
|
|
|
set_background_image (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
gchar *bg_capplet;
|
|
|
|
gchar *argv[1];
|
1999-03-30 10:09:56 +04:00
|
|
|
GtkWidget *msg_box;
|
|
|
|
|
1999-03-26 02:17:55 +03:00
|
|
|
bg_capplet = gnome_is_program_in_path ("background-properties-capplet");
|
1999-03-30 10:09:56 +04:00
|
|
|
|
1999-03-26 02:17:55 +03:00
|
|
|
if (bg_capplet) {
|
|
|
|
argv[0] = bg_capplet;
|
|
|
|
gnome_execute_async (bg_capplet, 1, argv);
|
|
|
|
g_free (bg_capplet);
|
|
|
|
} else {
|
1999-03-30 10:09:56 +04:00
|
|
|
msg_box = gnome_message_box_new (
|
|
|
|
_("Unable to locate the file:\nbackground-properties-capplet\n"
|
|
|
|
"in your path.\n\nWe are unable to set the background."),
|
|
|
|
GNOME_MESSAGE_BOX_WARNING,
|
|
|
|
GNOME_STOCK_BUTTON_OK,
|
|
|
|
NULL);
|
|
|
|
gnome_dialog_run (GNOME_DIALOG (msg_box));
|
1999-03-26 02:17:55 +03:00
|
|
|
}
|
|
|
|
}
|
1999-06-08 02:14:55 +04:00
|
|
|
|
2000-06-20 23:42:15 +04:00
|
|
|
static void
|
|
|
|
set_desktop_icons (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
gnome_configure_box_with_desktop (NULL, NULL, TRUE);
|
|
|
|
}
|
|
|
|
|
1999-06-08 02:14:55 +04:00
|
|
|
/* Callback from menus to create a terminal. If the user creates a terminal
|
|
|
|
* from the desktop, he usually wants the cwd to be his home directory, not the
|
|
|
|
* desktop directory.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
new_terminal (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
if (is_a_desktop_panel (cpanel))
|
|
|
|
mc_chdir (home_dir);
|
|
|
|
|
2001-04-21 06:06:22 +04:00
|
|
|
gnome_open_terminal ();
|
1999-06-08 02:14:55 +04:00
|
|
|
}
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
static GnomeUIInfo gnome_panel_new_menu [] = {
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Terminal"), N_("Launch a new terminal in the current directory"), new_terminal),
|
1999-03-11 05:40:53 +03:00
|
|
|
/* If this ever changes, make sure you update create_new_menu accordingly. */
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Directory..."), N_("Creates a new directory"), gnome_mkdir_cmd),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("URL L_ink..."), N_("Creates a new URL link"), gnome_new_link),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Launcher..."), N_("Creates a new launcher"), gnome_new_launcher),
|
1999-03-11 05:40:53 +03:00
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
1999-02-15 20:59:49 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Menu items for arranging the desktop icons */
|
|
|
|
GnomeUIInfo desktop_arrange_icons_items[] = {
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By _Name"), NULL, handle_arrange_icons_name),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By File _Type"), NULL, handle_arrange_icons_type),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By _Size"), NULL, handle_arrange_icons_size),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By Time Last _Accessed"), NULL, handle_arrange_icons_access),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By Time Last _Modified"), NULL, handle_arrange_icons_mod),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("By Time Last _Changed"), NULL, handle_arrange_icons_change),
|
1999-08-09 07:41:39 +04:00
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* The popup menu for the desktop */
|
1999-02-23 04:56:09 +03:00
|
|
|
GnomeUIInfo desktop_popup_items[] = {
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_MENU_NEW_SUBTREE (gnome_panel_new_menu),
|
1999-02-19 00:43:07 +03:00
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_SUBTREE (N_("_Arrange Icons"), desktop_arrange_icons_items),
|
2000-05-15 21:29:02 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Tidy Icons"), NULL, handle_tidy_icons),
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Create _New Window"), NULL, handle_new_window),
|
1999-02-19 00:43:07 +03:00
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-09-21 04:40:21 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Rescan _Desktop Directory"), NULL, handle_rescan_desktop),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Rescan De_vices"), NULL, handle_rescan_devices),
|
1999-09-21 09:50:22 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Recreate Default _Icons"), NULL, handle_recreate_default_icons),
|
1999-09-21 04:40:21 +04:00
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-08-10 02:54:02 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Configure _Background Image"), NULL, set_background_image),
|
2000-06-20 23:42:15 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Des_ktop Properties"), NULL, set_desktop_icons),
|
1999-02-15 20:59:49 +03:00
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
static int
|
|
|
|
strip_tearoff_menu_item (GnomeUIInfo *infos)
|
|
|
|
{
|
1999-08-09 07:41:39 +04:00
|
|
|
GtkWidget *shell;
|
|
|
|
GList *child_list;
|
1999-08-10 02:54:02 +04:00
|
|
|
int n;
|
|
|
|
|
|
|
|
g_assert (infos != NULL);
|
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
shell = infos[0].widget->parent;
|
|
|
|
child_list = gtk_container_children (GTK_CONTAINER (shell));
|
1999-08-10 02:54:02 +04:00
|
|
|
n = g_list_length (child_list);
|
|
|
|
|
|
|
|
if (child_list && GTK_IS_TEAROFF_MENU_ITEM (child_list->data)) {
|
|
|
|
n--;
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (child_list->data));
|
|
|
|
#if 0
|
1999-08-09 07:41:39 +04:00
|
|
|
gtk_widget_hide (GTK_WIDGET (child_list->data));
|
1999-08-10 02:54:02 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
1999-08-09 07:41:39 +04:00
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
/* Executes the popup menu for the desktop */
|
|
|
|
static void
|
|
|
|
desktop_popup (GdkEventButton *event)
|
|
|
|
{
|
1999-03-11 05:40:53 +03:00
|
|
|
GtkWidget *shell;
|
1999-02-15 20:59:49 +03:00
|
|
|
GtkWidget *popup;
|
1999-03-11 05:40:53 +03:00
|
|
|
gchar *file, *file2;
|
|
|
|
WPanel *panel;
|
|
|
|
gint i;
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Create the menu and then strip the tearoff menu items, sigh... */
|
|
|
|
|
2000-01-31 18:29:33 +03:00
|
|
|
if (nodesktop)
|
|
|
|
return;
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
popup = gnome_popup_menu_new (desktop_popup_items);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
strip_tearoff_menu_item (desktop_arrange_icons_items);
|
|
|
|
i = strip_tearoff_menu_item (gnome_panel_new_menu);
|
1999-03-11 05:40:53 +03:00
|
|
|
shell = gnome_panel_new_menu[0].widget->parent;
|
|
|
|
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 ();
|
1999-11-30 00:17:14 +03:00
|
|
|
|
|
|
|
/* Disable the "arrange icons" commands if there are no icons */
|
|
|
|
|
|
|
|
if (panel->count == 0)
|
|
|
|
for (i = 0; desktop_arrange_icons_items[i].type != GNOME_APP_UI_ENDOFINFO; i++)
|
|
|
|
gtk_widget_set_sensitive (desktop_arrange_icons_items[i].widget, FALSE);
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, NULL);
|
1999-03-11 05:40:53 +03:00
|
|
|
layout_panel_gone (panel);
|
1999-06-15 02:50:45 +04:00
|
|
|
free_panel_from_desktop (panel);
|
1999-02-15 20:59:49 +03:00
|
|
|
gtk_widget_destroy (popup);
|
1999-03-13 02:48:36 +03:00
|
|
|
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
1998-12-11 15:59:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draws the rubberband rectangle for selecting icons on the desktop */
|
|
|
|
static void
|
|
|
|
draw_rubberband (int x, int y)
|
|
|
|
{
|
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add macro %k it is block file name
Add macro %e it is error file name
Add macro %i it is cursor column indent of spaces, only for edit
Add macro %y, it is syntax of current file in editor, only for edit
Add condition y , it is syntax pattern of current file in edit
Add macro %x it is extension of current file
Add macro %m it is current menu filename
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editcmd.c: Modify External Formatter (was C indent formatter) .
Autocreate a scripts in home, from templates /usr/lib/mc/edit.indent.rc,
edit.ispell.rc, etc. Remove leading and trailing spaces into _(""),
(the message of David H. Martin <dmartina@usa.net>)
2000-05-05 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* src/user.c: Add condition (x filename) into mc.menu .
for "Open next a free console" and like.
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
src/user.c: fix segfault in chunk_alloc of glibc, when into condition
of .mnu we have quoted space. (~.mc/menu: + f \.\ test$).
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/edit.c:
Add ability user edit menus: system: /usr/lib/mc/cedit.menu,
* gtkedit/editmenu.c: home: ~/.cedit.menu, local: .cedit.menu
Marked block is access now from an user edit menu
Access ~/.cedit/cooledit.block for insert to cursor place from
user edit menu.
Created system cedit.menu
2000-05-04 Valery Kornienkov <vlk@dimavb.st.simbirsk.su>
* gtkedit/editdraw.c:
Improved a status string of cool editor for best understand,
and to add char,hex view.
2000-05-04 Richard Hestilow <hestgray@ionet.net>
* gnome/gdesktop.c: Fixes snap to grid.
2000-05-09 05:18:27 +04:00
|
|
|
int x1, y1, x2, y2;
|
1998-12-11 15:59:47 +03:00
|
|
|
|
|
|
|
if (click_start_x < x) {
|
|
|
|
x1 = click_start_x;
|
|
|
|
x2 = x;
|
|
|
|
} else {
|
|
|
|
x1 = x;
|
|
|
|
x2 = click_start_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (click_start_y < y) {
|
|
|
|
y1 = click_start_y;
|
|
|
|
y2 = y;
|
|
|
|
} else {
|
|
|
|
y1 = y;
|
|
|
|
y2 = click_start_y;
|
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
gdk_draw_rectangle (GDK_ROOT_PARENT (), click_gc, FALSE, x1, y1, x2 - x1, y2 - y1);
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Stores dii->selected into dii->tmp_selected to keep the original selection
|
1998-12-11 15:59:47 +03:00
|
|
|
* around while the user is rubberbanding.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
store_temp_selection (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-11 15:59:47 +03:00
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
|
|
|
|
dii->tmp_selected = dii->selected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/**
|
|
|
|
* icon_is_in_area:
|
|
|
|
* @dii: the desktop icon information
|
1999-06-15 02:50:45 +04:00
|
|
|
*
|
1998-12-17 07:51:24 +03:00
|
|
|
* Returns TRUE if the specified icon is at least partially inside the specified
|
1998-12-11 15:59:47 +03:00
|
|
|
* area, or FALSE otherwise.
|
|
|
|
*/
|
|
|
|
static int
|
1998-12-31 04:43:11 +03:00
|
|
|
icon_is_in_area (DesktopIconInfo *dii, int x1, int y1, int x2, int y2)
|
1998-12-11 15:59:47 +03:00
|
|
|
{
|
|
|
|
DesktopIcon *dicon;
|
|
|
|
|
|
|
|
dicon = DESKTOP_ICON (dii->dicon);
|
|
|
|
|
|
|
|
x1 -= dii->x;
|
|
|
|
y1 -= dii->y;
|
|
|
|
x2 -= dii->x;
|
|
|
|
y2 -= dii->y;
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (x1 == x2 && y1 == y2)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-06-15 02:50:45 +04:00
|
|
|
if (x1 < dicon->icon_x + dicon->icon_w
|
|
|
|
&& x2 >= dicon->icon_x
|
|
|
|
&& y1 < dicon->icon_y + dicon->icon_h
|
|
|
|
&& y2 >= dicon->icon_y)
|
1998-12-11 15:59:47 +03:00
|
|
|
return TRUE;
|
|
|
|
|
1999-06-15 02:50:45 +04:00
|
|
|
if (x1 < dicon->text_x + dicon->text_w
|
|
|
|
&& x2 >= dicon->text_x
|
|
|
|
&& y1 < dicon->text_y + dicon->text_h
|
|
|
|
&& y2 >= dicon->text_y)
|
1998-12-11 15:59:47 +03:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the selection being rubberbanded. It selects or unselects the icons
|
|
|
|
* as appropriate.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
update_drag_selection (int x, int y)
|
|
|
|
{
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
int i;
|
|
|
|
GList *l;
|
1998-12-31 04:43:11 +03:00
|
|
|
DesktopIconInfo *dii;
|
1998-12-11 15:59:47 +03:00
|
|
|
int additive, invert, in_area;
|
|
|
|
|
|
|
|
if (click_start_x < x) {
|
|
|
|
x1 = click_start_x;
|
|
|
|
x2 = x;
|
|
|
|
} else {
|
|
|
|
x1 = x;
|
|
|
|
x2 = click_start_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (click_start_y < y) {
|
|
|
|
y1 = click_start_y;
|
|
|
|
y2 = y;
|
|
|
|
} else {
|
|
|
|
y1 = y;
|
|
|
|
y2 = click_start_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Select or unselect icons as appropriate */
|
|
|
|
|
|
|
|
additive = click_start_state & GDK_SHIFT_MASK;
|
|
|
|
invert = click_start_state & GDK_CONTROL_MASK;
|
|
|
|
|
|
|
|
for (i = 0; i < (layout_cols * layout_rows); i++)
|
|
|
|
for (l = layout_slots[i].icons; l; l = l->next) {
|
|
|
|
dii = l->data;
|
|
|
|
|
|
|
|
in_area = icon_is_in_area (dii, x1, y1, x2, y2);
|
|
|
|
|
|
|
|
if (in_area) {
|
|
|
|
if (invert) {
|
|
|
|
if (dii->selected == dii->tmp_selected) {
|
1999-06-15 02:50:45 +04:00
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon),
|
|
|
|
!dii->selected);
|
1998-12-11 15:59:47 +03:00
|
|
|
dii->selected = !dii->selected;
|
|
|
|
}
|
|
|
|
} else if (additive) {
|
|
|
|
if (!dii->selected) {
|
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), TRUE);
|
|
|
|
dii->selected = TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!dii->selected) {
|
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), TRUE);
|
|
|
|
dii->selected = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (dii->selected != dii->tmp_selected) {
|
|
|
|
desktop_icon_select (DESKTOP_ICON (dii->dicon), dii->tmp_selected);
|
|
|
|
dii->selected = dii->tmp_selected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-05 07:17:19 +04:00
|
|
|
/* Terminates rubberbanding when the button is released. This is shared by the
|
|
|
|
* button_release handler and the motion_notify handler.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
perform_release (guint32 time)
|
|
|
|
{
|
|
|
|
draw_rubberband (click_current_x, click_current_y);
|
|
|
|
gdk_pointer_ungrab (time);
|
|
|
|
click_dragging = FALSE;
|
|
|
|
|
|
|
|
update_drag_selection (click_current_x, click_current_y);
|
|
|
|
|
|
|
|
XUngrabServer (GDK_DISPLAY ());
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
/* Handles button presses on the root window via the click_proxy_gdk_window */
|
1998-12-11 05:05:19 +03:00
|
|
|
static gint
|
1998-12-11 15:59:47 +03:00
|
|
|
click_proxy_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
|
1998-12-11 05:05:19 +03:00
|
|
|
{
|
1998-12-11 18:20:25 +03:00
|
|
|
GdkCursor *cursor;
|
|
|
|
|
1999-08-24 03:13:31 +04:00
|
|
|
/* maybe the user wants to click on the icon text */
|
|
|
|
if (event->button == 1 && desktop_use_shaped_text) {
|
|
|
|
int x = event->x;
|
|
|
|
int y = event->y;
|
|
|
|
GList *l, *icons = get_all_icons ();
|
|
|
|
DesktopIconInfo *clicked = NULL;
|
|
|
|
for (l = icons; l; l = l->next) {
|
|
|
|
DesktopIconInfo *dii = l->data;
|
|
|
|
DesktopIcon *di = DESKTOP_ICON (dii->dicon);
|
|
|
|
int x1 = dii->x + di->text_x;
|
|
|
|
int y1 = dii->y + di->text_y;
|
|
|
|
int x2 = x1 + di->text_w;
|
|
|
|
int y2 = y1 + di->text_h;
|
|
|
|
if (x>=x1 && y>=y1 && x<=x2 && y<=y2)
|
|
|
|
clicked = dii;
|
|
|
|
}
|
|
|
|
g_list_free (icons);
|
|
|
|
if (clicked) {
|
|
|
|
select_icon (clicked, event->state);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
1999-09-10 23:24:57 +04:00
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
if (event->button == 1) {
|
|
|
|
click_start_x = event->x;
|
|
|
|
click_start_y = event->y;
|
|
|
|
click_start_state = event->state;
|
|
|
|
|
|
|
|
XGrabServer (GDK_DISPLAY ());
|
|
|
|
|
2001-04-15 13:39:24 +04:00
|
|
|
cursor = gdk_cursor_new (GDK_LEFT_PTR);
|
1998-12-11 15:59:47 +03:00
|
|
|
gdk_pointer_grab (GDK_ROOT_PARENT (),
|
|
|
|
FALSE,
|
|
|
|
GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
|
|
|
|
NULL,
|
1998-12-11 18:20:25 +03:00
|
|
|
cursor,
|
1998-12-11 15:59:47 +03:00
|
|
|
event->time);
|
1998-12-11 18:20:25 +03:00
|
|
|
gdk_cursor_destroy (cursor);
|
1998-12-11 15:59:47 +03:00
|
|
|
|
|
|
|
/* If no modifiers are pressed, we unselect all the icons */
|
|
|
|
|
|
|
|
if ((click_start_state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == 0)
|
|
|
|
unselect_all (NULL);
|
|
|
|
|
|
|
|
store_temp_selection (); /* Save the original selection */
|
|
|
|
|
|
|
|
draw_rubberband (event->x, event->y);
|
|
|
|
click_current_x = event->x;
|
|
|
|
click_current_y = event->y;
|
|
|
|
click_dragging = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
} else if (event->button == 3) {
|
2000-04-05 07:17:19 +04:00
|
|
|
if (click_dragging)
|
|
|
|
perform_release (event->time);
|
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
desktop_popup (event);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-04-21 04:22:30 +04:00
|
|
|
/* Handles button releases on the root window via the click_proxy_gdk_window */
|
|
|
|
static gint
|
|
|
|
click_proxy_button_release (GtkWidget *widget, GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
if (!click_dragging || event->button != 1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
perform_release (event->time);
|
1998-12-11 15:59:47 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handles motion events when dragging the icon-selection rubberband on the desktop */
|
|
|
|
static gint
|
|
|
|
click_proxy_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data)
|
|
|
|
{
|
|
|
|
if (!click_dragging)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-04-21 04:22:30 +04:00
|
|
|
/* There exists the following race condition. If in the button_press
|
|
|
|
* handler we manage to grab the server before the window manager can
|
|
|
|
* proxy the button release to us, then we wil not get the release
|
|
|
|
* event. So we have to check the event mask and fake a release by
|
|
|
|
* hand.
|
|
|
|
*/
|
|
|
|
if (!(event->state & GDK_BUTTON1_MASK)) {
|
|
|
|
perform_release (event->time);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
draw_rubberband (click_current_x, click_current_y);
|
|
|
|
draw_rubberband (event->x, event->y);
|
|
|
|
update_drag_selection (event->x, event->y);
|
|
|
|
click_current_x = event->x;
|
|
|
|
click_current_y = event->y;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Filter that translates proxied events from virtual root windows into normal
|
1999-02-02 05:34:46 +03:00
|
|
|
* Gdk events for the proxy_invisible widget.
|
1998-12-11 15:59:47 +03:00
|
|
|
*/
|
|
|
|
static GdkFilterReturn
|
|
|
|
click_proxy_filter (GdkXEvent *xevent, GdkEvent *event, gpointer data)
|
|
|
|
{
|
|
|
|
XEvent *xev;
|
|
|
|
|
|
|
|
xev = xevent;
|
|
|
|
|
|
|
|
switch (xev->type) {
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Translate button events into events that come from the proxy
|
|
|
|
* window, so that we can catch them as a signal from the
|
|
|
|
* invisible widget.
|
|
|
|
*/
|
1998-12-11 15:59:47 +03:00
|
|
|
if (xev->type == ButtonPress)
|
|
|
|
event->button.type = GDK_BUTTON_PRESS;
|
|
|
|
else
|
|
|
|
event->button.type = GDK_BUTTON_RELEASE;
|
|
|
|
|
|
|
|
gdk_window_ref (click_proxy_gdk_window);
|
|
|
|
|
|
|
|
event->button.window = click_proxy_gdk_window;
|
|
|
|
event->button.send_event = xev->xbutton.send_event;
|
|
|
|
event->button.time = xev->xbutton.time;
|
|
|
|
event->button.x = xev->xbutton.x;
|
|
|
|
event->button.y = xev->xbutton.y;
|
|
|
|
event->button.state = xev->xbutton.state;
|
|
|
|
event->button.button = xev->xbutton.button;
|
1998-12-11 18:20:25 +03:00
|
|
|
|
|
|
|
return GDK_FILTER_TRANSLATE;
|
|
|
|
|
|
|
|
case DestroyNotify:
|
|
|
|
/* The proxy window was destroyed (i.e. the window manager
|
|
|
|
* died), so we have to cope with it
|
|
|
|
*/
|
1998-12-11 18:39:59 +03:00
|
|
|
if (((GdkEventAny *) event)->window == click_proxy_gdk_window) {
|
|
|
|
gdk_window_destroy_notify (click_proxy_gdk_window);
|
|
|
|
click_proxy_gdk_window = NULL;
|
|
|
|
}
|
1998-12-11 18:20:25 +03:00
|
|
|
|
|
|
|
return GDK_FILTER_REMOVE;
|
1998-12-11 15:59:47 +03:00
|
|
|
|
|
|
|
default:
|
1998-12-11 18:20:25 +03:00
|
|
|
break;
|
1998-12-11 15:59:47 +03:00
|
|
|
}
|
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
return GDK_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Creates a proxy window to receive clicks from the root window and
|
|
|
|
* sets up the necessary event filters.
|
1998-12-11 18:20:25 +03:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
setup_desktop_click_proxy_window (void)
|
|
|
|
{
|
|
|
|
click_proxy_gdk_window = find_click_proxy_window ();
|
|
|
|
if (!click_proxy_gdk_window) {
|
1999-02-23 04:56:09 +03:00
|
|
|
desktop_wm_is_gnome_compliant = 0;
|
1998-12-11 18:20:25 +03:00
|
|
|
g_warning ("Root window clicks will not work as no GNOME-compliant window manager could be found!");
|
|
|
|
return;
|
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
desktop_wm_is_gnome_compliant = 1;
|
1998-12-11 18:20:25 +03:00
|
|
|
|
|
|
|
/* Make the proxy window send events to the invisible proxy widget */
|
1999-02-02 05:34:46 +03:00
|
|
|
gdk_window_set_user_data (click_proxy_gdk_window, proxy_invisible);
|
1998-12-11 18:20:25 +03:00
|
|
|
|
|
|
|
/* Add our filter to get events */
|
|
|
|
gdk_window_add_filter (click_proxy_gdk_window, click_proxy_filter, NULL);
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* The proxy window for clicks sends us button press events with
|
1998-12-11 18:20:25 +03:00
|
|
|
* SubstructureNotifyMask. We need StructureNotifyMask to receive
|
|
|
|
* DestroyNotify events, too.
|
|
|
|
*/
|
|
|
|
|
|
|
|
XSelectInput (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (click_proxy_gdk_window),
|
|
|
|
SubstructureNotifyMask | StructureNotifyMask);
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
/*
|
|
|
|
* Handler for PropertyNotify events from the root window; it must change the
|
1998-12-11 18:20:25 +03:00
|
|
|
* proxy window to a new one.
|
|
|
|
*/
|
|
|
|
static gint
|
|
|
|
click_proxy_property_notify (GtkWidget *widget, GdkEventProperty *event, gpointer data)
|
|
|
|
{
|
|
|
|
if (event->window != GDK_ROOT_PARENT ())
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (event->atom != gdk_atom_intern ("_WIN_DESKTOP_BUTTON_PROXY", FALSE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* If there already is a proxy window, destroy it */
|
|
|
|
|
|
|
|
click_proxy_gdk_window = NULL;
|
|
|
|
|
|
|
|
/* Get the new proxy window */
|
|
|
|
|
|
|
|
setup_desktop_click_proxy_window ();
|
|
|
|
|
|
|
|
return TRUE;
|
1998-12-11 15:59:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define gray50_width 2
|
|
|
|
#define gray50_height 2
|
|
|
|
static char gray50_bits[] = {
|
|
|
|
0x02, 0x01, };
|
|
|
|
|
1998-12-11 05:05:19 +03:00
|
|
|
/* Sets up the window manager proxy window to receive clicks on the desktop root window */
|
|
|
|
static void
|
|
|
|
setup_desktop_clicks (void)
|
|
|
|
{
|
1998-12-11 15:59:47 +03:00
|
|
|
GdkColormap *cmap;
|
|
|
|
GdkColor color;
|
|
|
|
GdkBitmap *stipple;
|
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Make the root window send events to the invisible proxy widget */
|
1999-02-02 05:34:46 +03:00
|
|
|
gdk_window_set_user_data (GDK_ROOT_PARENT (), proxy_invisible);
|
1998-12-11 15:59:47 +03:00
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Add our filter to get button press/release events (they are sent by
|
|
|
|
* the WM * with the window set to the root). Our filter will translate
|
|
|
|
* them to a GdkEvent with the proxy window as its window field.
|
|
|
|
*/
|
1998-12-11 15:59:47 +03:00
|
|
|
gdk_window_add_filter (GDK_ROOT_PARENT (), click_proxy_filter, NULL);
|
1998-12-11 05:05:19 +03:00
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Select for PropertyNotify events from the root window */
|
|
|
|
|
|
|
|
XSelectInput (GDK_DISPLAY (), GDK_ROOT_WINDOW (), PropertyChangeMask);
|
1998-12-11 06:18:41 +03:00
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Create the proxy window for clicks on the root window */
|
|
|
|
setup_desktop_click_proxy_window ();
|
|
|
|
|
|
|
|
/* Connect the signals */
|
1998-12-11 06:18:41 +03:00
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "button_press_event",
|
1998-12-11 15:59:47 +03:00
|
|
|
(GtkSignalFunc) click_proxy_button_press,
|
|
|
|
NULL);
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "button_release_event",
|
1998-12-11 15:59:47 +03:00
|
|
|
(GtkSignalFunc) click_proxy_button_release,
|
1998-12-11 05:05:19 +03:00
|
|
|
NULL);
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "motion_notify_event",
|
1998-12-11 15:59:47 +03:00
|
|
|
(GtkSignalFunc) click_proxy_motion,
|
|
|
|
NULL);
|
|
|
|
|
1999-02-02 05:34:46 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (proxy_invisible), "property_notify_event",
|
1998-12-11 18:20:25 +03:00
|
|
|
(GtkSignalFunc) click_proxy_property_notify,
|
|
|
|
NULL);
|
|
|
|
|
1998-12-11 15:59:47 +03:00
|
|
|
/* Create the GC to paint the rubberband rectangle */
|
|
|
|
|
|
|
|
click_gc = gdk_gc_new (GDK_ROOT_PARENT ());
|
|
|
|
|
|
|
|
cmap = gdk_window_get_colormap (GDK_ROOT_PARENT ());
|
|
|
|
|
|
|
|
gdk_color_white (cmap, &color);
|
|
|
|
if (color.pixel == 0)
|
|
|
|
gdk_color_black (cmap, &color);
|
|
|
|
|
|
|
|
gdk_gc_set_foreground (click_gc, &color);
|
|
|
|
gdk_gc_set_function (click_gc, GDK_XOR);
|
|
|
|
|
|
|
|
gdk_gc_set_fill (click_gc, GDK_STIPPLED);
|
|
|
|
|
|
|
|
stipple = gdk_bitmap_create_from_data (NULL, gray50_bits, gray50_width, gray50_height);
|
|
|
|
gdk_gc_set_stipple (click_gc, stipple);
|
|
|
|
gdk_bitmap_unref (stipple);
|
1998-12-11 05:05:19 +03:00
|
|
|
}
|
|
|
|
|
2001-04-08 19:23:59 +04:00
|
|
|
static gboolean
|
2001-04-13 05:03:22 +04:00
|
|
|
do_rescan (gpointer data)
|
2001-04-08 19:23:59 +04:00
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
if (stat (desktop_directory, &buf) == -1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (buf.st_ctime == desktop_dir_modify_time)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RESCAN_TIMEOUT 4000
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_desktop_reload_monitor (void)
|
|
|
|
{
|
|
|
|
gtk_timeout_add (RESCAN_TIMEOUT, do_rescan, NULL);
|
|
|
|
}
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1998-10-30 03:47:54 +03:00
|
|
|
/**
|
|
|
|
* desktop_init
|
|
|
|
*
|
|
|
|
* Initializes the desktop by setting up the default icons (if necessary), setting up drag and drop,
|
|
|
|
* and other miscellaneous tasks.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
desktop_init (void)
|
|
|
|
{
|
1999-08-10 02:54:02 +04:00
|
|
|
icon_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
2000-01-31 18:05:23 +03:00
|
|
|
if (!nodesktop) {
|
|
|
|
gdnd_init ();
|
|
|
|
gicon_init ();
|
|
|
|
create_layout_info ();
|
|
|
|
create_desktop_dir ();
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
}
|
1999-02-02 05:34:46 +03:00
|
|
|
|
|
|
|
/* Create the proxy window and initialize all proxying stuff */
|
|
|
|
|
|
|
|
proxy_invisible = gtk_invisible_new ();
|
|
|
|
gtk_widget_show (proxy_invisible);
|
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
setup_desktop_dnd ();
|
1998-12-11 05:05:19 +03:00
|
|
|
setup_desktop_clicks ();
|
2001-04-08 19:23:59 +04:00
|
|
|
|
|
|
|
/* Setup reloading */
|
|
|
|
setup_desktop_reload_monitor ();
|
1998-10-30 03:47:54 +03:00
|
|
|
}
|
|
|
|
|
1998-11-03 04:32:38 +03:00
|
|
|
/**
|
|
|
|
* desktop_destroy
|
1998-10-30 03:47:54 +03:00
|
|
|
*
|
|
|
|
* Shuts the desktop down by destroying the desktop icons.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
desktop_destroy (void)
|
|
|
|
{
|
|
|
|
/* Destroy the desktop icons */
|
|
|
|
|
1998-12-03 02:37:27 +03:00
|
|
|
destroy_desktop_icons ();
|
1998-10-30 03:47:54 +03:00
|
|
|
|
|
|
|
/* Cleanup */
|
|
|
|
|
|
|
|
g_free (layout_slots);
|
|
|
|
layout_slots = NULL;
|
|
|
|
layout_cols = 0;
|
|
|
|
layout_rows = 0;
|
|
|
|
|
|
|
|
g_free (desktop_directory);
|
|
|
|
desktop_directory = NULL;
|
1998-12-03 02:37:27 +03:00
|
|
|
|
1998-12-11 18:20:25 +03:00
|
|
|
/* Remove click-on-desktop crap */
|
|
|
|
|
|
|
|
gdk_window_unref (click_proxy_gdk_window);
|
1999-02-02 05:34:46 +03:00
|
|
|
|
|
|
|
/* Remove DnD crap */
|
|
|
|
|
|
|
|
gtk_widget_destroy (proxy_invisible);
|
|
|
|
XDeleteProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (), gdk_atom_intern ("XdndProxy", FALSE));
|
1999-08-09 07:41:39 +04:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
g_hash_table_destroy (icon_hash);
|
1998-10-30 03:47:54 +03:00
|
|
|
}
|
1999-02-06 04:57:26 +03:00
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
void
|
2001-07-27 23:38:31 +04:00
|
|
|
desktop_create_url (const char *filename, const char *title,
|
|
|
|
const char *url, const char *icon, gboolean is_template)
|
1999-03-20 21:08:52 +03:00
|
|
|
{
|
|
|
|
FILE *f;
|
2001-07-27 23:38:31 +04:00
|
|
|
char *tmpname = NULL;
|
1999-03-20 21:08:52 +03:00
|
|
|
|
2001-07-27 23:38:31 +04:00
|
|
|
if (is_template) {
|
|
|
|
int fd;
|
1999-06-15 02:50:45 +04:00
|
|
|
|
2001-07-27 23:38:31 +04:00
|
|
|
fd = mc_mkstemps (&tmpname, filename, NULL);
|
|
|
|
if (fd == -1)
|
|
|
|
return;
|
|
|
|
f = fdopen (fd, "w");
|
|
|
|
filename = tmpname;
|
|
|
|
} else {
|
|
|
|
f = fopen (filename, "w");
|
|
|
|
}
|
1999-06-15 02:50:45 +04:00
|
|
|
|
2001-07-27 23:38:31 +04:00
|
|
|
if (!f) {
|
|
|
|
g_free (tmpname);
|
|
|
|
return;
|
1999-03-20 21:08:52 +03:00
|
|
|
}
|
2001-07-27 23:38:31 +04:00
|
|
|
|
|
|
|
fprintf (f, "URL: %s\n", url);
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
gnome_metadata_set (filename, "desktop-url",
|
|
|
|
strlen (url) + 1, url);
|
|
|
|
gnome_metadata_set (filename, "icon-caption",
|
|
|
|
strlen (title) + 1, title);
|
|
|
|
|
|
|
|
gnome_metadata_set (filename, "icon-filename", strlen (icon) + 1, icon);
|
1999-03-20 21:08:52 +03:00
|
|
|
}
|