Lots of usability changes for the desktop.

1998-12-29  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* gdesktop.c (desktop_icon_delete): New function, used for
	dicon_delete.
	(load_desktop_icons): Implemented the incremental reloading of
	desktop icons.  This should make the code much nicer.
	(reload_desktop_icons): Call x_flush_events to force a display at
	that point.

	* gpopup.c (dicon_delete): Implement this operation.
	(desktop_icon_execute): Use the existing implementation for
	launching desktop icons instead of a new hacked up version

	(desktop_icon_actions): Until copy/move is implemented, do not
	even list them to the user.

	* gdesktop.c (create_desktop_dir): No trashcan setup until it
	works.

	* gscren.c (panel_widget_motion): Use button 2 for dragging and
	asking.
This commit is contained in:
Miguel de Icaza 1998-12-30 02:51:01 +00:00
parent 94d3dbac8b
commit d24269087f
11 changed files with 813 additions and 853 deletions

View File

@ -1,5 +1,26 @@
1998-12-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_icon_delete): New function, used for
dicon_delete.
(load_desktop_icons): Implemented the incremental reloading of
desktop icons. This should make the code much nicer.
(reload_desktop_icons): Call x_flush_events to force a display at
that point.
* gpopup.c (dicon_delete): Implement this operation.
(desktop_icon_execute): Use the existing implementation for
launching desktop icons instead of a new hacked up version
(desktop_icon_actions): Until copy/move is implemented, do not
even list them to the user.
* gdesktop.c (create_desktop_dir): No trashcan setup until it
works.
* gscren.c (panel_widget_motion): Use button 2 for dragging and
asking.
* gscreen.c (panel_create_file_list): Use a notebook instead of
the hack I was using before for switching the panel contents.

View File

@ -34,6 +34,7 @@
#include "dialog.h"
#define DIR_H_INCLUDE_HANDLE_DIRENT /* bleah */
#include "dir.h"
#include "file.h"
#include "gdesktop.h"
#include "gdesktop-icon.h"
#include "gicon.h"
@ -129,7 +130,6 @@ static int click_dragging;
static struct desktop_icon_info *desktop_icon_info_new (char *filename, int auto_pos, int xpos, int ypos);
static void desktop_icon_info_free (struct desktop_icon_info *dii);
/* Looks for a free slot in the layout_slots array and returns the coordinates that coorespond to
@ -291,8 +291,40 @@ icon_exists (char *filename)
return FALSE;
}
static GList *
icon_exists_in_list (GList *list, char *filename)
{
GList *l;
for (l = list; l; l = l->next){
struct desktop_icon_info *dii = l->data;
if (strcmp (filename, dii->filename) == 0)
return l;
}
return NULL;
}
/*
* Reads the ~/Desktop directory and creates the desktop icons. If
* Returns a GList with all of the icons on the desktop
*/
GList *
desktop_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;
}
/*
* Reads the ~/desktop directory and creates the desktop icons. If
* incremental is TRUE, then an icon will not be created for a file if
* there is already an icon for it, and icons will be created starting
* at the specified position.
@ -306,6 +338,7 @@ load_desktop_icons (int incremental, int xpos, int ypos)
int have_pos, x, y;
struct desktop_icon_info *dii;
GSList *need_position_list, *l;
GList *all_icons;
dir = mc_opendir (desktop_directory);
if (!dir) {
@ -316,20 +349,33 @@ load_desktop_icons (int incremental, int xpos, int ypos)
return;
}
/* First create the icons for all the files that do have their icon position set. Build a
* list of the icons that do not have their position set.
/*
* First create the icons for all the files that do have their
* icon position set. Build a list of the icons that do not
* have their position set.
*/
need_position_list = NULL;
all_icons = desktop_get_all_icons ();
while ((dirent = mc_readdir (dir)) != NULL) {
if (((dirent->d_name[0] == '.') && (dirent->d_name[1] == 0))
|| ((dirent->d_name[0] == '.') && (dirent->d_name[1] == '.') && (dirent->d_name[2] == 0)))
continue;
if (incremental && icon_exists (dirent->d_name))
continue;
if (incremental){
GList *element;
element = icon_exists_in_list (all_icons, dirent->d_name);
if (element){
g_list_remove_link (all_icons, element);
continue;
}
}
full_name = g_concat_dir_and_file (desktop_directory, dirent->d_name);
have_pos = gmeta_get_icon_pos (full_name, &x, &y);
@ -345,7 +391,23 @@ load_desktop_icons (int incremental, int xpos, int ypos)
mc_closedir (dir);
/* Now create the icons for all the files that did not have their position set. This makes
/*
* all_icons now contains a list of all of the icons that were not found
* in the ~/desktop directory, remove them.
*/
if (incremental){
GList *l;
for (l = all_icons; l; l = l->next){
struct desktop_icon_info *dii = l->data;
desktop_icon_destroy (dii);
}
}
g_list_free (all_icons);
/*
* Now create the icons for all the files that did not have their position set. This makes
* auto-placement work correctly without overlapping icons.
*/
@ -375,7 +437,7 @@ destroy_desktop_icons (void)
dii = l->data;
l = l->next;
desktop_icon_info_free (dii);
desktop_icon_destroy (dii);
}
}
}
@ -392,6 +454,7 @@ reload_desktop_icons (int incremental, int x, int y)
destroy_desktop_icons ();
load_desktop_icons (incremental, x, y);
x_flush_events ();
}
/* Unselects all the desktop icons except the one in exclude */
@ -657,8 +720,8 @@ editing_stopped (GnomeIconTextItem *iti, gpointer data)
}
/* Used to open a desktop icon when the user double-clicks on it */
static void
open_desktop_icon (struct desktop_icon_info *dii)
void
desktop_icon_open (struct desktop_icon_info *dii)
{
char *filename;
file_entry *fe;
@ -675,6 +738,31 @@ open_desktop_icon (struct desktop_icon_info *dii)
file_entry_free (fe);
}
void
desktop_icon_delete (struct desktop_icon_info *dii)
{
char *full_name;
struct stat s;
long progress_count = 0;
double progress_bytes = 0;
/* 1. Delete the file */
create_op_win (OP_DELETE, 1);
x_flush_events ();
full_name = g_concat_dir_and_file (desktop_directory, dii->filename);
stat (full_name, &s);
if (S_ISDIR (s.st_mode))
erase_dir (full_name, &progress_count, &progress_bytes);
else
erase_file (full_name, &progress_count, &progress_bytes, TRUE);
g_free (full_name);
destroy_op_win ();
/* 2. Destroy the dicon */
desktop_icon_destroy (dii);
}
/* Used to execute the popup menu for desktop icons */
static void
do_popup_menu (struct desktop_icon_info *dii, GdkEventButton *event)
@ -684,7 +772,7 @@ do_popup_menu (struct desktop_icon_info *dii, GdkEventButton *event)
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
if (gpopup_do_popup (event, NULL, dii, 0, filename) != -1)
reload_desktop_icons (FALSE, 0, 0); /* bleah */
reload_desktop_icons (TRUE, 0, 0); /* bleah */
g_free (filename);
}
@ -770,7 +858,7 @@ icon_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
if (event->button != 1)
break;
open_desktop_icon (dii);
desktop_icon_open (dii);
retval = TRUE;
break;
@ -1152,8 +1240,8 @@ desktop_icon_info_new (char *filename, int auto_pos, int xpos, int ypos)
* Frees a desktop icon information structure, and destroy the icon
* widget. Does not remove the structure from the desktop_icons list!
*/
static void
desktop_icon_info_free (struct desktop_icon_info *dii)
void
desktop_icon_destroy (struct desktop_icon_info *dii)
{
gtk_widget_destroy (dii->dicon);
remove_from_slot (dii);
@ -1220,7 +1308,7 @@ create_desktop_dir (void)
g_free (home_link_name);
}
setup_trashcan (desktop_directory);
/* setup_trashcan (desktop_directory); */
}
/* Sets up a proxy window for DnD on the specified X window. Courtesy of Owen Taylor */

View File

@ -32,6 +32,7 @@ void desktop_init (void);
/* Shuts the desktop down by destroying the desktop icons. */
void desktop_destroy (void);
/* This structure defines the information carried by a desktop icon */
typedef struct desktop_icon_info {
GtkWidget *dicon; /* The desktop icon widget */
@ -45,19 +46,16 @@ typedef struct desktop_icon_info {
*/
} desktop_icon_info;
void desktop_icon_destroy (struct desktop_icon_info *dii);
void desktop_icon_open (struct desktop_icon_info *dii);
void desktop_icon_delete (struct desktop_icon_info *dii);
typedef enum {
application,
directory,
file
} icon_t;
/* A structure that describes each icon on the desktop */
typedef struct {
GnomeDesktopEntry *dentry;

View File

@ -18,7 +18,6 @@
#include "gpopup.h"
#include "main.h"
#define CLIST_FROM_SW(panel_list) GTK_CLIST (GTK_BIN (panel_list)->child)
@ -82,39 +81,27 @@ panel_action_edit (GtkWidget *widget, WPanel *panel)
static void
desktop_icon_view(GtkWidget *widget, desktop_icon_info *dii)
{
g_warning("NYI");
g_warning ("Not yet implemented\n");
}
/* Pops up the icon properties pages */
void
desktop_icon_properties (GtkWidget *widget, desktop_icon_info *dii)
{
int retval;
char *path;
path = g_copy_strings(getenv("HOME"), "/desktop/", dii->filename, NULL);
retval = item_properties (dii->dicon, path, dii);
g_free(path);
if(retval)
reread_cmd(); /* Lame. Slow. Works. */
int retval;
char *path;
path = g_copy_strings (getenv("HOME"), "/desktop/", dii->filename, NULL);
retval = item_properties (dii->dicon, path, dii);
g_free(path);
if (retval)
reread_cmd ();
}
void
desktop_icon_execute (GtkWidget *ignored, desktop_icon_info *dii)
{
char *path;
/* Ultra lame-o execute. This should be replaced by the fixed regexp_command
* invocation
*/
path = g_copy_strings(getenv("HOME"), "/desktop/", dii->filename, NULL);
if (g_file_test(path, G_FILE_TEST_ISDIR))
new_panel_at (path);
else
gnome_desktop_entry_launch (path);
g_free(path);
desktop_icon_open (dii);
}
static void
@ -144,7 +131,7 @@ dicon_copy (GtkWidget *widget, desktop_icon_info *dii)
static void
dicon_delete (GtkWidget *widget, desktop_icon_info *dii)
{
g_warning ("Implement this function!");
desktop_icon_delete (dii);
}
/* This is our custom signal connection function for popup menu items -- see below for the
@ -243,8 +230,10 @@ static GnomeUIInfo panel_actions[] = {
/* Menu entries for files from desktop icons */
static GnomeUIInfo desktop_icon_actions[] = {
GNOMEUIINFO_SEPARATOR,
#if 0
GNOMEUIINFO_ITEM_NONE (N_("Move/rename..."), NULL, dicon_move),
GNOMEUIINFO_ITEM_NONE (N_("Copy..."), NULL, dicon_copy),
#endif
GNOMEUIINFO_ITEM_NONE (N_("Delete"), NULL, dicon_delete),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_END
@ -545,7 +534,7 @@ gpopup_do_popup (GdkEventButton *event,
/* Run it */
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3, event->time);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
gtk_grab_add (menu);
gtk_main ();
gtk_grab_remove (menu);

View File

@ -904,7 +904,7 @@ panel_widget_motion (GtkWidget *widget, GdkEventMotion *event, WPanel *panel)
list = gtk_target_list_new (drag_types, ELEMENTS (drag_types));
if (panel->maybe_start_drag == 3)
if (panel->maybe_start_drag == 2)
action = GDK_ACTION_ASK;
else
action = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK;
@ -1126,16 +1126,12 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan
new_panel_at (fullname);
free (fullname);
}
}
break;
}
if (event->button.button == 3)
gpopup_do_popup ((GdkEventButton *) event, panel, NULL, index, panel->dir.list[index].fname);
break;
case GDK_BUTTON_RELEASE:
if (event->button.button != 3)
return;
gpopup_do_popup ((GdkEventButton *) event, panel, NULL, index, panel->dir.list[index].fname);
return;
case GDK_2BUTTON_PRESS:
if (event->button.button == 1)
do_enter (panel);
@ -1200,8 +1196,10 @@ panel_icon_list_button_press (GtkWidget *widget, GdkEventButton *event, WPanel *
if (icon == -1)
panel->maybe_start_drag = 0;
else
panel->maybe_start_drag = event->button;
else {
if (event->button != 3)
panel->maybe_start_drag = event->button;
}
panel->click_x = event->x;
panel->click_y = event->y;

1436
po/mc.pot

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,7 @@
1998-12-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* cmd.c (check_for_default): Make this compile.
Tue Dec 29 22:25:34 1998 Timur Bakeyev <mc@bat.ru>
* mountlist.c: Compress all xBSD systems to one line and add check

View File

@ -232,8 +232,6 @@ char *op_names [3] = {
};
static int recursive_erase (char *s, long *progress_count, double *progress_bytes);
static int erase_file (char *s, long *progress_count,
double *progress_bytes, int is_toplevel_file);
/* }}} */
@ -1357,7 +1355,7 @@ oktoret:
/* {{{ Erase routines */
/* Don't update progress status if progress_count==NULL */
static int
int
erase_file (char *s,
long *progress_count,
double *progress_bytes,

View File

@ -41,6 +41,7 @@ int copy_dir_dir (char *s, char *d, int toplevel, int move_over,
int delete, struct link *parent_dirs,
long *progres_count, double *progress_bytes);
int erase_dir (char *s, long *progres_count, double *progress_bytes);
int erase_file (char *s, long *progress_count, double *progress_bytes, int is_toplevel_file);
int erase_dir_iff_empty (char *s);
/*

View File

@ -2684,6 +2684,9 @@ handle_args (int argc, char *argv [])
corba_register_server ();
#else
gnome_init_with_popt_table ("gmc", VERSION, argc, argv, argument_table, 0, &ctx);
gtk_widget_push_visual (gdk_imlib_get_visual ());
gtk_widget_push_colormap (gdk_imlib_get_colormap ());
#endif
poptResetContext (ctx);
#else
@ -2818,6 +2821,13 @@ int main (int argc, char *argv [])
bindtextdomain ("mc", LOCALEDIR);
textdomain ("mc");
{
volatile int i = 1;
while (!i)
;
}
/* Initialize list of all user group for timur_clr_mode */
init_groups ();

View File

@ -124,6 +124,7 @@ typedef struct {
void *list;
void *tree;
void *icons;
void *notebook;
void *scrollbar;
void *status;
void *ministatus;