mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-02 13:12:53 +03:00
1999-02-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (desktop_popup): Handle popup menus for the desktop. (arrange_desktop_icons): New function to auto-arrange the desktop icons. (reload_desktop_icons): Take care of positioning the new icons by ourselves; do not rely on desktop_icon_info_new() to do it. (remove_from_slot): Reset the icon's slot to -1. (reload_desktop_icons): Show all the icons after they have been loaded, instead doing it one by one. * gscreen.c (file_list_popup): Handle popup menus for the blank areas of the file panels. (panel_icon_list_button_press): Call file_list_popup(). (panel_file_list_press_row): Likewise.
This commit is contained in:
parent
c0782a21c0
commit
2c1f45565b
@ -1,3 +1,19 @@
|
||||
1999-02-14 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* gdesktop.c (desktop_popup): Handle popup menus for the desktop.
|
||||
(arrange_desktop_icons): New function to auto-arrange the desktop
|
||||
icons.
|
||||
(reload_desktop_icons): Take care of positioning the new icons by
|
||||
ourselves; do not rely on desktop_icon_info_new() to do it.
|
||||
(remove_from_slot): Reset the icon's slot to -1.
|
||||
(reload_desktop_icons): Show all the icons after they have been
|
||||
loaded, instead doing it one by one.
|
||||
|
||||
* gscreen.c (file_list_popup): Handle popup menus for the blank
|
||||
areas of the file panels.
|
||||
(panel_icon_list_button_press): Call file_list_popup().
|
||||
(panel_file_list_press_row): Likewise.
|
||||
|
||||
1999-02-14 Sergey Panov <sipan@mit.edu>
|
||||
|
||||
* glayout.c: Fixed my own stupid typo( stock ID instead of NULL)
|
||||
|
104
gnome/gdesktop.c
104
gnome/gdesktop.c
@ -122,9 +122,7 @@ static int click_current_y;
|
||||
static int click_dragging;
|
||||
|
||||
|
||||
static DesktopIconInfo *desktop_icon_info_new (char *filename, char *url,
|
||||
char *caption,
|
||||
int user_pos, int auto_pos,
|
||||
static DesktopIconInfo *desktop_icon_info_new (char *filename, char *url, char *caption,
|
||||
int xpos, int ypos);
|
||||
|
||||
|
||||
@ -211,28 +209,21 @@ remove_from_slot (DesktopIconInfo *dii)
|
||||
|
||||
layout_slots[dii->slot].num_icons--;
|
||||
layout_slots[dii->slot].icons = g_list_remove (layout_slots[dii->slot].icons, dii);
|
||||
|
||||
dii->slot = -1;
|
||||
dii->x = 0;
|
||||
dii->y = 0;
|
||||
}
|
||||
|
||||
/* Places a desktop icon. If auto_pos is true, then the function will look for
|
||||
* a place to position the icon automatically, else it will use the specified
|
||||
* coordinates, snapped to the grid if the global desktop_snap_icons flag is
|
||||
* set.
|
||||
*/
|
||||
/* Places a desktop icon on the specified position */
|
||||
static void
|
||||
desktop_icon_info_place (DesktopIconInfo *dii, int user_pos, int auto_pos, int xpos, int ypos)
|
||||
desktop_icon_info_place (DesktopIconInfo *dii, int xpos, int ypos)
|
||||
{
|
||||
int u, v;
|
||||
char *filename;
|
||||
|
||||
remove_from_slot (dii);
|
||||
|
||||
if (!user_pos && auto_pos) {
|
||||
if (desktop_snap_icons)
|
||||
get_icon_snap_pos (&xpos, &ypos);
|
||||
else
|
||||
get_icon_auto_pos (&xpos, &ypos);
|
||||
}
|
||||
|
||||
if (xpos < 0)
|
||||
xpos = 0;
|
||||
else if (xpos > layout_screen_width)
|
||||
@ -326,8 +317,7 @@ typedef struct {
|
||||
char *caption;
|
||||
} file_and_url_t;
|
||||
|
||||
/*
|
||||
* Reloads the desktop icons efficiently. If there are "new" files for which no
|
||||
/* Reloads the desktop icons efficiently. If there are "new" files for which no
|
||||
* 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.
|
||||
@ -404,7 +394,7 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
gnome_metadata_get (full_name, "icon-caption", &size, &caption);
|
||||
|
||||
if (have_pos) {
|
||||
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, FALSE, FALSE, x, y);
|
||||
dii = desktop_icon_info_new (dirent->d_name, desktop_url, caption, x, y);
|
||||
gtk_widget_show (dii->dicon);
|
||||
|
||||
g_free (full_name);
|
||||
@ -455,7 +445,10 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
for (sl = need_position_list; sl; sl = sl->next) {
|
||||
file_and_url_t *fau = sl->data;
|
||||
|
||||
dii = desktop_icon_info_new (fau->filename, fau->url, fau->caption, user_pos, TRUE, xpos, ypos);
|
||||
if (!user_pos)
|
||||
get_icon_auto_pos (&xpos, &ypos);
|
||||
|
||||
dii = desktop_icon_info_new (fau->filename, fau->url, fau->caption, xpos, ypos);
|
||||
gtk_widget_show (dii->dicon);
|
||||
|
||||
if (fau->url)
|
||||
@ -467,13 +460,32 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
||||
}
|
||||
|
||||
g_slist_free (need_position_list);
|
||||
|
||||
gnome_metadata_unlock ();
|
||||
|
||||
/* Flush events to make the icons paint themselves */
|
||||
x_flush_events ();
|
||||
}
|
||||
|
||||
/* Perform automatic arrangement of the desktop icons */
|
||||
static void
|
||||
arrange_desktop_icons (void)
|
||||
{
|
||||
GList *icons, *l;
|
||||
int xpos, ypos;
|
||||
|
||||
icons = g_list_reverse (get_all_icons ());
|
||||
|
||||
for (l = icons; l; l = l->next)
|
||||
remove_from_slot (l->data);
|
||||
|
||||
for (l = icons; l; l = l->next) {
|
||||
get_icon_auto_pos (&xpos, &ypos);
|
||||
desktop_icon_info_place (l->data, xpos, ypos);
|
||||
}
|
||||
|
||||
g_list_free (icons);
|
||||
}
|
||||
|
||||
/* Unselects all the desktop icons except the one in exclude */
|
||||
static void
|
||||
unselect_all (DesktopIconInfo *exclude)
|
||||
@ -1278,21 +1290,22 @@ drop_desktop_icons (GdkDragContext *context, GtkSelectionData *data, int x, int
|
||||
sel_icons = g_slist_prepend (sel_icons, l->data);
|
||||
}
|
||||
|
||||
/* Move the icons */
|
||||
/* Move the icons. FIXME: handle auto-placement by reinserting the
|
||||
* icons in the proper place.
|
||||
*/
|
||||
|
||||
for (sl = sel_icons; sl; sl = sl->next) {
|
||||
dii = sl->data;
|
||||
desktop_icon_info_place (dii,
|
||||
!desktop_auto_placement,
|
||||
desktop_auto_placement,
|
||||
dii->x + dx, dii->y + dy);
|
||||
}
|
||||
if (!desktop_auto_placement)
|
||||
for (sl = sel_icons; sl; sl = sl->next) {
|
||||
dii = sl->data;
|
||||
desktop_icon_info_place (dii, dii->x + dx, dii->y + dy);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
|
||||
g_slist_free (sel_icons);
|
||||
}
|
||||
|
||||
/* Handler for drag_data_received for desktop icons */
|
||||
static void
|
||||
icon_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
||||
GtkSelectionData *data, guint info, guint time, gpointer user_data)
|
||||
@ -1313,7 +1326,7 @@ icon_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gin
|
||||
return; /* eeeek */
|
||||
|
||||
if (gdnd_perform_drop (context, data, fe, full_name))
|
||||
reload_desktop_icons (TRUE, x, y);
|
||||
reload_desktop_icons (FALSE, 0, 0);
|
||||
|
||||
file_entry_free (fe);
|
||||
}
|
||||
@ -1341,7 +1354,7 @@ setup_icon_dnd_dest (DesktopIconInfo *dii)
|
||||
* desktop directory. It does not show the icon.
|
||||
*/
|
||||
static DesktopIconInfo *
|
||||
desktop_icon_info_new (char *filename, char *url, char *caption, int user_pos, int auto_pos, int xpos, int ypos)
|
||||
desktop_icon_info_new (char *filename, char *url, char *caption, int xpos, int ypos)
|
||||
{
|
||||
DesktopIconInfo *dii;
|
||||
file_entry *fe;
|
||||
@ -1427,7 +1440,7 @@ desktop_icon_info_new (char *filename, char *url, char *caption, int user_pos, i
|
||||
|
||||
/* Place the icon and append it to the list */
|
||||
|
||||
desktop_icon_info_place (dii, user_pos, auto_pos, xpos, ypos);
|
||||
desktop_icon_info_place (dii, xpos, ypos);
|
||||
return dii;
|
||||
}
|
||||
|
||||
@ -1822,11 +1835,36 @@ find_click_proxy_window (void)
|
||||
return proxy_gdk_window;
|
||||
}
|
||||
|
||||
/* Callback for arranging the icons on the desktop */
|
||||
static void
|
||||
handle_arrange_icons (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
arrange_desktop_icons ();
|
||||
}
|
||||
|
||||
/* Callback for rescanning the desktop directory */
|
||||
static void
|
||||
handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
reload_desktop_icons (FALSE, 0, 0);
|
||||
}
|
||||
|
||||
/* The popup menu for the desktop */
|
||||
static GnomeUIInfo desktop_popup_items[] = {
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Desktop"), NULL, handle_rescan_desktop),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
/* Executes the popup menu for the desktop */
|
||||
static void
|
||||
desktop_popup (GdkEventButton *event)
|
||||
{
|
||||
printf ("FIXME: display desktop popup menu\n");
|
||||
GtkWidget *popup;
|
||||
|
||||
popup = gnome_popup_menu_new (desktop_popup_items);
|
||||
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, NULL);
|
||||
gtk_widget_destroy (popup);
|
||||
}
|
||||
|
||||
/* Draws the rubberband rectangle for selecting icons on the desktop */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gnome-file-property-dialog.h"
|
||||
#define CLIST_FROM_SW(panel_list) GTK_CLIST (GTK_BIN (panel_list)->child)
|
||||
|
||||
|
||||
/* Flags for the popup menu entries. They specify to which kinds of files an
|
||||
* entry is valid for.
|
||||
*/
|
||||
@ -34,10 +35,9 @@ enum {
|
||||
F_SYMLINK = 1 << 2, /* Applies only to symlinks */
|
||||
F_SINGLE = 1 << 3, /* Applies only to a single file, not to multiple files */
|
||||
F_NOTDIR = 1 << 4, /* Applies to non-directories */
|
||||
F_DICON = 1 << 5, /* Applies only to desktop icons */
|
||||
F_NOTDEV = 1 << 6, /* Applies to non-devices only (ie. reg, lnk, dir) */
|
||||
F_ADVANCED = 1 << 7, /* Only appears in advanced mode */
|
||||
F_MIME_ACTIONS = 1 << 8 /* Special marker for the position of MIME actions */
|
||||
F_NOTDEV = 1 << 5, /* Applies to non-devices only (ie. reg, lnk, dir) */
|
||||
F_ADVANCED = 1 << 6, /* Only appears in advanced mode */
|
||||
F_MIME_ACTIONS = 1 << 7 /* Special marker for the position of MIME actions */
|
||||
};
|
||||
|
||||
/* typedefs */
|
||||
@ -47,6 +47,7 @@ struct action {
|
||||
gpointer callback; /* Callback for menu item */
|
||||
};
|
||||
|
||||
|
||||
/* Multiple File commands */
|
||||
static void handle_open (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_view (GtkWidget *widget, WPanel *panel);
|
||||
@ -63,11 +64,6 @@ static void handle_hard_link (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_symlink (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_edit_symlink (GtkWidget *widget, WPanel *panel);
|
||||
|
||||
/* Generic Options */
|
||||
static void handle_display_properties (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_rescan (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_arrange_icons (GtkWidget *widget, WPanel *panel);
|
||||
static void handle_logout (GtkWidget *widget, WPanel *panel);
|
||||
|
||||
/* global vars */
|
||||
extern int we_can_afford_the_speed;
|
||||
@ -178,6 +174,7 @@ free_on_destroy (GtkObject *object, gpointer data)
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
/* Callback for MIME-based actions */
|
||||
static void
|
||||
mime_action_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
@ -187,7 +184,7 @@ mime_action_callback (GtkWidget *widget, gpointer data)
|
||||
char *value;
|
||||
|
||||
filename = data;
|
||||
key = gtk_object_get_user_data (widget);
|
||||
key = gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
g_assert (filename != NULL);
|
||||
g_assert (key != NULL);
|
||||
@ -262,9 +259,6 @@ create_mime_actions (GtkWidget *menu, WPanel *panel, int pos)
|
||||
gtk_signal_connect (GTK_OBJECT (uiinfo[0].widget), "destroy",
|
||||
(GtkSignalFunc) free_on_destroy,
|
||||
full_name);
|
||||
gtk_signal_connect (GTK_OBJECT (uiinfo[0].widget), "destroy",
|
||||
(GtkSignalFunc) free_on_destroy,
|
||||
key);
|
||||
}
|
||||
|
||||
g_list_free (keys);
|
||||
|
@ -77,6 +77,8 @@ GtkWidget *drag_directory_ok = NULL;
|
||||
GtkWidget *drag_multiple = NULL;
|
||||
GtkWidget *drag_multiple_ok = NULL;
|
||||
|
||||
static void file_list_popup (GdkEventButton *event, WPanel *panel);
|
||||
|
||||
|
||||
void
|
||||
repaint_file (WPanel *panel, int file_index, int move, int attr, int isstatus)
|
||||
@ -462,12 +464,18 @@ panel_file_list_press_row (GtkWidget *file_list, GdkEvent *event, WPanel *panel)
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button.button == 3) {
|
||||
gint row, column;
|
||||
|
||||
gtk_clist_get_selection_info (GTK_CLIST (file_list),
|
||||
event->button.x, event->button.y,
|
||||
&row, &column);
|
||||
gtk_clist_select_row (GTK_CLIST (file_list), row, 0);
|
||||
gpopup_do_popup ((GdkEventButton *) event, panel, NULL,
|
||||
row, panel->dir.list[row].fname);
|
||||
if (gtk_clist_get_selection_info (GTK_CLIST (file_list),
|
||||
event->button.x, event->button.y,
|
||||
&row, &column)) {
|
||||
gtk_clist_select_row (GTK_CLIST (file_list), row, 0);
|
||||
#if 0
|
||||
gpopup_do_popup2 ((GdkEventButton *) event, panel);
|
||||
#else
|
||||
gpopup_do_popup ((GdkEventButton *) event, panel,
|
||||
NULL, row, panel->dir.list[row].fname);
|
||||
#endif
|
||||
} else
|
||||
file_list_popup ((GdkEventButton *) event, panel);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -1361,9 +1369,14 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan
|
||||
|
||||
switch (event->type){
|
||||
case GDK_BUTTON_PRESS:
|
||||
if (event->button.button == 3)
|
||||
gpopup_do_popup ((GdkEventButton *) event, panel, NULL,
|
||||
index, panel->dir.list[index].fname);
|
||||
if (event->button.button == 3) {
|
||||
#if 0
|
||||
gpopup_do_popup2 ((GdkEventButton *) event, panel);
|
||||
#else
|
||||
gpopup_do_popup ((GdkEventButton *) event, panel,
|
||||
NULL, index, panel->dir.list[index].fname);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
@ -1412,6 +1425,34 @@ panel_icon_renamed (GtkWidget *widget, int index, char *dest, WPanel *panel)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Callback for rescanning the cwd */
|
||||
static void
|
||||
handle_rescan_directory (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
reread_cmd ();
|
||||
}
|
||||
|
||||
/* The popup menu for file panels */
|
||||
static GnomeUIInfo file_list_popup_items[] = {
|
||||
GNOMEUIINFO_ITEM_NONE (N_("Rescan Directory"), N_("Reloads the current directory"),
|
||||
handle_rescan_directory),
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
/* Creates the popup menu when the user clicks button 3 on the blank area of the
|
||||
* file panels.
|
||||
*/
|
||||
static void
|
||||
file_list_popup (GdkEventButton *event, WPanel *panel)
|
||||
{
|
||||
GtkWidget *popup;
|
||||
|
||||
popup = gnome_popup_menu_new (file_list_popup_items);
|
||||
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, panel);
|
||||
gtk_widget_destroy (popup);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Strategy for activaing the drags from the icon-list:
|
||||
*
|
||||
@ -1430,11 +1471,8 @@ panel_icon_list_button_press (GtkWidget *widget, GdkEventButton *event, WPanel *
|
||||
icon = gnome_icon_list_get_icon_at (gil, event->x, event->y);
|
||||
|
||||
if (icon == -1) {
|
||||
if (event->button == 3) {
|
||||
#if 0
|
||||
g_warning ("FIXME: icon_list_button_press menu");
|
||||
gpopup_do_popup ((GdkEventButton *) event, panel, NULL, FALSE);
|
||||
#endif
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
||||
file_list_popup (event, panel);
|
||||
return TRUE;
|
||||
}
|
||||
} else if (event->button != 3)
|
||||
|
Loading…
x
Reference in New Issue
Block a user