mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
2001-04-06 Miguel de Icaza <miguel@ximian.com>
* gdesktop.c (do_rescan): Added automatic desktop reloading.
This commit is contained in:
parent
bb912def1a
commit
d86427a196
@ -1,3 +1,7 @@
|
|||||||
|
2001-04-06 Miguel de Icaza <miguel@ximian.com>
|
||||||
|
|
||||||
|
* gdesktop.c (do_rescan): Added automatic desktop reloading.
|
||||||
|
|
||||||
2001-04-06 Pavel Roskin <proski@gnu.org>
|
2001-04-06 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* gscreen.c (tree_size_allocate): Don't call save_setup() if
|
* gscreen.c (tree_size_allocate): Don't call save_setup() if
|
||||||
|
@ -65,6 +65,9 @@ int desktop_use_shaped_text = 0;
|
|||||||
/* The computed name of the user's desktop directory */
|
/* The computed name of the user's desktop directory */
|
||||||
char *desktop_directory;
|
char *desktop_directory;
|
||||||
|
|
||||||
|
/* Time of the last directory reload */
|
||||||
|
time_t desktop_dir_modify_time;
|
||||||
|
|
||||||
/* Layout information: number of rows/columns for the layout slots, and the
|
/* 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
|
* array of slots. Each slot is an integer that specifies the number of icons
|
||||||
* that belong to that slot.
|
* that belong to that slot.
|
||||||
@ -202,7 +205,7 @@ auto_pos (int sx, int ex, int sy, int ey, int *slot)
|
|||||||
{
|
{
|
||||||
int min, min_slot;
|
int min, min_slot;
|
||||||
int x, y;
|
int x, y;
|
||||||
int val;
|
int val = 0;
|
||||||
int xinc, yinc;
|
int xinc, yinc;
|
||||||
int r, b;
|
int r, b;
|
||||||
|
|
||||||
@ -614,14 +617,13 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
|
|||||||
char *full_name;
|
char *full_name;
|
||||||
int have_pos, x, y, size;
|
int have_pos, x, y, size;
|
||||||
DesktopIconInfo *dii;
|
DesktopIconInfo *dii;
|
||||||
GSList *need_position_list, *sl, *drop_grid_list, *drop_gl_copy;
|
GSList *need_position_list, *sl, *drop_grid_list = NULL, *drop_gl_copy = NULL;
|
||||||
GList *all_icons, *l;
|
GList *all_icons, *l;
|
||||||
char *desktop_url, *caption;
|
char *desktop_url, *caption;
|
||||||
const char *mime;
|
const char *mime;
|
||||||
int orig_xpos, orig_ypos;
|
int orig_xpos, orig_ypos;
|
||||||
guint need_position_list_length;
|
guint need_position_list_length;
|
||||||
static int first_reload = TRUE;
|
static int first_reload = TRUE;
|
||||||
file_and_url_t *fau;
|
|
||||||
|
|
||||||
dir = mc_opendir (desktop_directory);
|
dir = mc_opendir (desktop_directory);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@ -632,6 +634,18 @@ desktop_reload_icons (int user_pos, int xpos, int ypos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
gnome_metadata_lock ();
|
gnome_metadata_lock ();
|
||||||
|
|
||||||
/* Read the directory. For each file for which we do have an existing
|
/* Read the directory. For each file for which we do have an existing
|
||||||
@ -3405,6 +3419,29 @@ setup_desktop_clicks (void)
|
|||||||
gdk_bitmap_unref (stipple);
|
gdk_bitmap_unref (stipple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
do_rescan (void)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* desktop_init
|
* desktop_init
|
||||||
@ -3432,6 +3469,9 @@ desktop_init (void)
|
|||||||
|
|
||||||
setup_desktop_dnd ();
|
setup_desktop_dnd ();
|
||||||
setup_desktop_clicks ();
|
setup_desktop_clicks ();
|
||||||
|
|
||||||
|
/* Setup reloading */
|
||||||
|
setup_desktop_reload_monitor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user