1998-02-27 07:54:42 +03:00
|
|
|
/* GNU Midnight Commander -- GNOME edition
|
|
|
|
*
|
|
|
|
* Directory display routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 The Free Software Foundation
|
|
|
|
*
|
1998-03-04 09:14:21 +03:00
|
|
|
* Authors: Miguel de Icaza
|
|
|
|
* Federico Mena
|
1998-02-27 07:54:42 +03:00
|
|
|
*/
|
1998-03-04 09:14:21 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "x.h"
|
1999-05-29 02:31:30 +04:00
|
|
|
#include "util.h"
|
1999-01-27 04:14:57 +03:00
|
|
|
#include "global.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "dir.h"
|
|
|
|
#include "command.h"
|
1998-12-04 05:08:06 +03:00
|
|
|
#include "panel.h"
|
|
|
|
#define WANT_WIDGETS /* bleah */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "main.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "layout.h" /* get_panel_widget */
|
|
|
|
#include "ext.h" /* regex_command */
|
|
|
|
#include "cmd.h" /* copy_cmd, ren_cmd, delete_cmd, ... */
|
|
|
|
#include "gscreen.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "dialog.h"
|
1999-01-20 13:40:21 +03:00
|
|
|
#include "setup.h"
|
1999-08-14 02:45:07 +04:00
|
|
|
#include "file.h"
|
1999-05-28 09:41:18 +04:00
|
|
|
#include "fileopctx.h"
|
1998-03-06 06:48:31 +03:00
|
|
|
#include "gdesktop.h"
|
1998-11-10 05:28:34 +03:00
|
|
|
#include "gdnd.h"
|
1998-12-02 08:18:20 +03:00
|
|
|
#include "gtkdtree.h"
|
1998-03-19 07:51:17 +03:00
|
|
|
#include "gpageprop.h"
|
1998-12-01 03:33:02 +03:00
|
|
|
#include "gpopup.h"
|
1999-02-26 10:17:51 +03:00
|
|
|
#include "gcmd.h"
|
1998-03-24 08:25:56 +03:00
|
|
|
#include "gcliplabel.h"
|
1998-12-09 04:56:24 +03:00
|
|
|
#include "gicon.h"
|
1999-04-10 01:13:04 +04:00
|
|
|
#include "gtkflist.h"
|
1998-04-17 04:59:58 +04:00
|
|
|
#include "../vfs/vfs.h"
|
1998-04-01 23:18:05 +04:00
|
|
|
#include <gdk/gdkprivate.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-08-01 22:29:11 +04:00
|
|
|
#ifndef MAX
|
|
|
|
# define MAX(a,b) ((a) > (b) ? a : b)
|
|
|
|
#endif
|
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
/* Offsets within the default_column_width array for the different listing types */
|
|
|
|
static const int column_width_pos[LIST_TYPES] = {
|
|
|
|
GMC_COLUMNS_BRIEF,
|
|
|
|
0,
|
|
|
|
-1,
|
|
|
|
GMC_COLUMNS_BRIEF + GMC_COLUMNS_DETAILED,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Default column widths for file listings */
|
|
|
|
int default_column_width[GMC_COLUMNS];
|
|
|
|
|
|
|
|
/* default format for custom view */
|
|
|
|
char* default_user_format = NULL;
|
|
|
|
|
1999-01-17 07:17:20 +03:00
|
|
|
/* Whether to display the tree view on the left */
|
|
|
|
int tree_panel_visible = -1;
|
|
|
|
|
1998-03-10 09:31:01 +03:00
|
|
|
/* The pixmaps */
|
1999-01-20 05:16:09 +03:00
|
|
|
#include "dir-close.xpm"
|
1998-03-10 09:31:01 +03:00
|
|
|
#include "link.xpm"
|
|
|
|
#include "dev.xpm"
|
1999-04-18 10:54:49 +04:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Timeout for auto-scroll on drag */
|
|
|
|
#define SCROLL_TIMEOUT 100
|
|
|
|
|
|
|
|
/* Timeout for opening a tree branch on drag */
|
|
|
|
#define TREE_OPEN_TIMEOUT 1000
|
1998-12-06 00:54:25 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* This is used to initialize our pixmaps */
|
|
|
|
static int pixmaps_ready;
|
1998-03-10 09:31:01 +03:00
|
|
|
GdkPixmap *icon_directory_pixmap;
|
|
|
|
GdkBitmap *icon_directory_mask;
|
|
|
|
GdkPixmap *icon_link_pixmap;
|
|
|
|
GdkBitmap *icon_link_mask;
|
|
|
|
GdkPixmap *icon_dev_pixmap;
|
|
|
|
GdkBitmap *icon_dev_mask;
|
1999-01-01 05:04:59 +03:00
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
static GtkTargetEntry drag_types [] = {
|
1999-01-22 03:59:11 +03:00
|
|
|
{ TARGET_URI_LIST_TYPE, 0, TARGET_URI_LIST },
|
|
|
|
{ TARGET_TEXT_PLAIN_TYPE, 0, TARGET_TEXT_PLAIN },
|
|
|
|
{ TARGET_URL_TYPE, 0, TARGET_URL }
|
1998-10-20 09:37:45 +04:00
|
|
|
};
|
1998-03-02 23:27:08 +03:00
|
|
|
|
1998-10-21 22:05:08 +04:00
|
|
|
static GtkTargetEntry drop_types [] = {
|
1999-02-03 14:49:33 +03:00
|
|
|
{ TARGET_URI_LIST_TYPE, 0, TARGET_URI_LIST },
|
|
|
|
{ TARGET_URL_TYPE, 0, TARGET_URL }
|
1998-10-21 22:05:08 +04:00
|
|
|
};
|
|
|
|
|
1998-03-02 23:27:08 +03:00
|
|
|
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
|
|
|
|
1998-03-12 08:59:43 +03:00
|
|
|
/* GtkWidgets with the shaped windows for dragging */
|
|
|
|
GtkWidget *drag_directory = NULL;
|
1998-03-06 06:48:31 +03:00
|
|
|
GtkWidget *drag_directory_ok = NULL;
|
1998-03-12 08:59:43 +03:00
|
|
|
GtkWidget *drag_multiple = NULL;
|
|
|
|
GtkWidget *drag_multiple_ok = NULL;
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
static void file_list_popup (GdkEventButton *event, WPanel *panel);
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
repaint_file (WPanel *panel, int file_index, int move, int attr, int isstatus)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Invoked by the generic code: show current working directory
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
show_dir (WPanel *panel)
|
|
|
|
{
|
1998-03-24 08:25:56 +03:00
|
|
|
assign_text (panel->current_dir, panel->cwd);
|
1998-04-09 08:58:24 +04:00
|
|
|
update_input (panel->current_dir, 1);
|
1998-04-16 02:38:36 +04:00
|
|
|
gtk_window_set_title (GTK_WINDOW (panel->xwindow), panel->cwd);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Utility routine: Try to load a bitmap for a file_entry
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
panel_file_list_set_type_bitmap (GtkCList *cl, int row, int column, int color, file_entry *fe)
|
|
|
|
{
|
|
|
|
/* Here, add more icons */
|
|
|
|
switch (color){
|
|
|
|
case DIRECTORY_COLOR:
|
1998-03-10 09:31:01 +03:00
|
|
|
gtk_clist_set_pixmap (cl, row, column, icon_directory_pixmap, icon_directory_mask);
|
|
|
|
break;
|
|
|
|
case LINK_COLOR:
|
|
|
|
gtk_clist_set_pixmap (cl, row, column, icon_link_pixmap, icon_link_mask);
|
|
|
|
break;
|
|
|
|
case DEVICE_COLOR:
|
|
|
|
gtk_clist_set_pixmap (cl, row, column, icon_dev_pixmap, icon_dev_mask);
|
1998-02-27 07:54:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
static void
|
|
|
|
panel_cancel_drag_scroll (WPanel *panel)
|
|
|
|
{
|
|
|
|
g_return_if_fail (panel != NULL);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
if (panel->timer_id != -1){
|
|
|
|
gtk_timeout_remove (panel->timer_id);
|
|
|
|
panel->timer_id = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Sets the color attributes for a given row.
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
static void
|
|
|
|
panel_file_list_set_row_colors (GtkCList *cl, int row, int color_pair)
|
|
|
|
{
|
1998-03-10 07:45:35 +03:00
|
|
|
gtk_clist_set_foreground (cl, row, gmc_color_pairs [color_pair].fore);
|
|
|
|
gtk_clist_set_background (cl, row, gmc_color_pairs [color_pair].back);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Update the status of the back and forward history buttons.
|
1998-12-12 02:10:15 +03:00
|
|
|
* Called from the generic code
|
1998-05-08 06:25:00 +04:00
|
|
|
*/
|
1998-04-09 08:58:24 +04:00
|
|
|
void
|
1998-04-09 09:05:14 +04:00
|
|
|
x_panel_update_marks (WPanel *panel)
|
1998-04-09 08:58:24 +04:00
|
|
|
{
|
1998-04-10 01:59:32 +04:00
|
|
|
int ff = panel->dir_history->next ? 1 : 0;
|
|
|
|
int bf = panel->dir_history->prev ? 1 : 0;
|
|
|
|
|
1998-04-17 05:21:27 +04:00
|
|
|
if (!panel->fwd_b)
|
|
|
|
return;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-04-10 01:59:32 +04:00
|
|
|
gtk_widget_set_sensitive (panel->fwd_b, ff);
|
|
|
|
gtk_widget_set_sensitive (panel->back_b, bf);
|
1998-04-09 08:58:24 +04:00
|
|
|
}
|
|
|
|
|
1998-12-15 09:35:51 +03:00
|
|
|
static GtkAdjustment *
|
|
|
|
scrolled_window_get_vadjustment (GtkScrolledWindow *sw)
|
|
|
|
{
|
|
|
|
GtkRange *vsb = GTK_RANGE (sw->vscrollbar);
|
|
|
|
GtkAdjustment *va = vsb->adjustment;
|
|
|
|
|
|
|
|
return va;
|
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Listing view: Load the contents
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_fill_panel_list (WPanel *panel)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
const int top = panel->count;
|
|
|
|
const int items = panel->format->items;
|
1998-03-12 06:29:45 +03:00
|
|
|
const int selected = panel->selected;
|
1998-11-10 05:28:34 +03:00
|
|
|
GtkCList *cl = CLIST_FROM_SW (panel->list);
|
1998-02-27 07:54:42 +03:00
|
|
|
int i, col, type_col, color;
|
1999-09-21 00:03:58 +04:00
|
|
|
int width, p;
|
1998-02-27 07:54:42 +03:00
|
|
|
char **texts;
|
2000-01-02 05:13:35 +03:00
|
|
|
GtkAdjustment *va;
|
|
|
|
double clist_v_pos;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
texts = g_new (char *, items + 1);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2000-01-02 05:13:35 +03:00
|
|
|
/* CList doesn't restore its vertical scroll position when its cleared,
|
|
|
|
* so we need to do it manually.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Save the vertical position */
|
|
|
|
va = scrolled_window_get_vadjustment (panel->list);
|
|
|
|
clist_v_pos = va->value;
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
gtk_clist_freeze (GTK_CLIST (cl));
|
|
|
|
gtk_clist_clear (GTK_CLIST (cl));
|
|
|
|
|
|
|
|
/* which column holds the type information */
|
|
|
|
type_col = -1;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-01-04 00:38:35 +03:00
|
|
|
g_assert (items == cl->columns);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-02 05:21:14 +03:00
|
|
|
texts [items] = NULL;
|
1998-02-27 07:54:42 +03:00
|
|
|
for (i = 0; i < top; i++){
|
|
|
|
file_entry *fe = &panel->dir.list [i];
|
|
|
|
format_e *format = panel->format;
|
1999-08-13 02:14:07 +04:00
|
|
|
int n;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
for (col = 0; format; format = format->next){
|
|
|
|
if (!format->use_in_gui)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (type_col == -1)
|
|
|
|
if (strcmp (format->id, "type") == 0)
|
|
|
|
type_col = col;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!format->string_fn)
|
1999-08-13 02:14:07 +04:00
|
|
|
texts[col] = "";
|
1998-02-27 07:54:42 +03:00
|
|
|
else
|
1999-08-13 02:14:07 +04:00
|
|
|
texts[col] = (* format->string_fn) (fe, 10);
|
1998-02-27 07:54:42 +03:00
|
|
|
col++;
|
|
|
|
}
|
1999-08-13 02:14:07 +04:00
|
|
|
|
|
|
|
n = gtk_clist_append (cl, texts);
|
|
|
|
|
|
|
|
/* Do not let the user select .. */
|
|
|
|
if (strcmp (fe->fname, "..") == 0)
|
|
|
|
gtk_clist_set_selectable (cl, n, FALSE);
|
1998-03-24 08:25:56 +03:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
color = file_compute_color (NORMAL, fe);
|
1998-02-27 07:54:42 +03:00
|
|
|
panel_file_list_set_row_colors (cl, i, color);
|
1999-01-21 06:44:03 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (type_col != -1)
|
|
|
|
panel_file_list_set_type_bitmap (cl, i, type_col, color, fe);
|
1999-01-21 06:44:03 +03:00
|
|
|
|
|
|
|
if (fe->f.marked)
|
|
|
|
gtk_clist_select_row (cl, i, 0);
|
1999-08-13 23:42:32 +04:00
|
|
|
else
|
|
|
|
gtk_clist_unselect_row (cl, i, 0);
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
1999-08-13 23:42:32 +04:00
|
|
|
|
|
|
|
g_free (texts);
|
|
|
|
|
1998-03-12 06:29:45 +03:00
|
|
|
/* This is needed as the gtk_clist_append changes selected under us :-( */
|
|
|
|
panel->selected = selected;
|
1999-08-13 23:42:32 +04:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
p = column_width_pos[panel->list_type]; /* offset in column_width */
|
|
|
|
g_assert (p >= 0);
|
|
|
|
for (i = 0; i < items; i++) {
|
|
|
|
width = panel->column_width[p + i];
|
|
|
|
if (width == 0)
|
|
|
|
width = gtk_clist_optimal_column_width (cl, i);
|
|
|
|
|
|
|
|
gtk_clist_set_column_width (cl, i, width);
|
|
|
|
}
|
|
|
|
|
2000-01-02 05:13:35 +03:00
|
|
|
/* Now restore the clist's vertical position */
|
|
|
|
gtk_adjustment_set_value (va, clist_v_pos);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
gtk_clist_thaw (GTK_CLIST (cl));
|
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Icon view: load the panel contents
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_fill_panel_icons (WPanel *panel)
|
|
|
|
{
|
|
|
|
const int top = panel->count;
|
|
|
|
const int selected = panel->selected;
|
1999-08-13 23:42:32 +04:00
|
|
|
GnomeIconList *icons = ILIST_FROM_SW (panel->icons);
|
1998-05-08 06:25:00 +04:00
|
|
|
int i;
|
|
|
|
GdkImlibImage *image;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
gnome_icon_list_freeze (icons);
|
|
|
|
gnome_icon_list_clear (icons);
|
1999-08-13 23:42:32 +04:00
|
|
|
|
1999-06-30 23:21:56 +04:00
|
|
|
for (i = 0; i < top; i++) {
|
1998-05-08 06:25:00 +04:00
|
|
|
file_entry *fe = &panel->dir.list [i];
|
1999-01-15 22:02:39 +03:00
|
|
|
int p;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-02-17 03:38:16 +03:00
|
|
|
image = gicon_get_icon_for_file (panel->cwd, fe, TRUE);
|
1999-01-15 22:02:39 +03:00
|
|
|
p = gnome_icon_list_append_imlib (icons, image, fe->fname);
|
1999-08-13 23:42:32 +04:00
|
|
|
|
1999-01-15 22:02:39 +03:00
|
|
|
if (fe->f.marked)
|
|
|
|
gnome_icon_list_select_icon (icons, p);
|
1999-08-13 23:42:32 +04:00
|
|
|
else
|
|
|
|
gnome_icon_list_unselect_icon (icons, p);
|
1998-05-08 06:25:00 +04:00
|
|
|
}
|
1999-08-13 23:42:32 +04:00
|
|
|
|
|
|
|
/* This is needed as the gtk_gnome_icon_list_append_imlib changes selected under us :-( */
|
1998-05-08 06:25:00 +04:00
|
|
|
panel->selected = selected;
|
1999-08-13 23:42:32 +04:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
gnome_icon_list_thaw (icons);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-12-12 02:10:15 +03:00
|
|
|
* Invoked from the generic code to fill the display
|
1998-05-08 06:25:00 +04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
x_fill_panel (WPanel *panel)
|
|
|
|
{
|
|
|
|
if (panel->list_type == list_icons)
|
|
|
|
panel_fill_panel_icons (panel);
|
|
|
|
else
|
|
|
|
panel_fill_panel_list (panel);
|
1998-11-29 11:22:20 +03:00
|
|
|
|
1998-12-01 09:12:34 +03:00
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (panel->tree), panel);
|
|
|
|
|
1999-01-15 22:02:39 +03:00
|
|
|
if (vfs_current_is_local ()){
|
|
|
|
char buffer [MC_MAXPATHLEN];
|
|
|
|
|
|
|
|
get_current_wd (buffer, sizeof (buffer)-1);
|
|
|
|
gtk_dtree_select_dir (GTK_DTREE (panel->tree), buffer);
|
|
|
|
} else
|
|
|
|
gtk_dtree_select_dir (GTK_DTREE (panel->tree), panel->cwd);
|
1998-12-01 09:12:34 +03:00
|
|
|
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (panel->tree), panel);
|
1998-05-08 06:25:00 +04:00
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
gmc_panel_set_size (int index, int boot)
|
|
|
|
{
|
|
|
|
Widget *w;
|
|
|
|
WPanel *p;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
w = (Widget *) get_panel_widget (index);
|
|
|
|
p = (WPanel *) w;
|
|
|
|
w->cols = 40;
|
|
|
|
w->lines = 25;
|
|
|
|
set_panel_formats (p);
|
|
|
|
paint_panel (p);
|
|
|
|
|
|
|
|
if (!boot)
|
|
|
|
paint_frame (p);
|
|
|
|
|
|
|
|
x_fill_panel (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_panel_set_size (int index)
|
|
|
|
{
|
|
|
|
printf ("WARNING: set size called\n");
|
|
|
|
gmc_panel_set_size (index, 1);
|
|
|
|
}
|
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/*
|
|
|
|
* Invoked when the f.mark field of a file item changes
|
|
|
|
*/
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
x_panel_select_item (WPanel *panel, int index, int value)
|
|
|
|
{
|
1998-03-10 07:45:35 +03:00
|
|
|
int color;
|
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
color = file_compute_color (NORMAL, &panel->dir.list[index]);
|
1998-11-10 05:28:34 +03:00
|
|
|
panel_file_list_set_row_colors (CLIST_FROM_SW (panel->list), index, color);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_select_item (WPanel *panel)
|
|
|
|
{
|
1999-03-11 05:40:53 +03:00
|
|
|
if (is_a_desktop_panel (panel))
|
|
|
|
return;
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
do_file_mark (panel, panel->selected, 1);
|
|
|
|
display_mini_info (panel);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1999-06-30 23:21:56 +04:00
|
|
|
if (panel->list_type == list_icons) {
|
1999-02-11 00:03:04 +03:00
|
|
|
GnomeIconList *list = ILIST_FROM_SW (panel->icons);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-05-12 08:26:21 +04:00
|
|
|
gnome_icon_list_select_icon (list, panel->selected);
|
1999-06-30 23:21:56 +04:00
|
|
|
if (GTK_WIDGET (list)->allocation.x != -1)
|
|
|
|
if (gnome_icon_list_icon_is_visible (list, panel->selected) != GTK_VISIBILITY_FULL)
|
|
|
|
gnome_icon_list_moveto (list, panel->selected, 0.5);
|
1998-05-12 08:26:21 +04:00
|
|
|
} else {
|
1998-11-10 05:28:34 +03:00
|
|
|
GtkCList *clist = CLIST_FROM_SW (panel->list);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
gtk_clist_select_row (clist, panel->selected, 0);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-05-12 08:26:21 +04:00
|
|
|
/* Make it visible */
|
|
|
|
if (gtk_clist_row_is_visible (clist, panel->selected) != GTK_VISIBILITY_FULL)
|
|
|
|
gtk_clist_moveto (clist, panel->selected, 0, 0.5, 0.0);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_unselect_item (WPanel *panel)
|
|
|
|
{
|
1999-01-21 06:44:03 +03:00
|
|
|
int selected = panel->selected;
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
if (panel->list_type == list_icons)
|
1999-02-11 00:03:04 +03:00
|
|
|
gnome_icon_list_unselect_all (ILIST_FROM_SW (panel->icons), NULL, NULL);
|
1999-01-21 06:44:03 +03:00
|
|
|
else
|
|
|
|
gtk_clist_unselect_all (CLIST_FROM_SW (panel->list));
|
1998-05-08 06:25:00 +04:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
panel->selected = selected;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_filter_changed (WPanel *panel)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
x_adjust_top_file (WPanel *panel)
|
|
|
|
{
|
1998-03-10 23:14:17 +03:00
|
|
|
/* gtk_clist_moveto (GTK_CLIST (panel->list), panel->top_file, 0, 0.0, 0.0); */
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
static void
|
1999-04-10 01:13:04 +04:00
|
|
|
panel_file_list_select_row (GtkWidget *file_list, gint row, gint column,
|
|
|
|
GdkEvent *event, gpointer data)
|
1998-03-04 03:56:14 +03:00
|
|
|
{
|
1999-04-10 01:13:04 +04:00
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
panel->selected = row;
|
|
|
|
do_file_mark (panel, row, 1);
|
|
|
|
display_mini_info (panel);
|
|
|
|
execute_hooks (select_file_hook);
|
1998-03-04 03:56:14 +03:00
|
|
|
}
|
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
static void
|
1999-04-10 01:13:04 +04:00
|
|
|
panel_file_list_unselect_row (GtkWidget *widget, int row, int columns, GdkEvent *event, gpointer data)
|
1999-01-21 06:44:03 +03:00
|
|
|
{
|
1999-04-10 01:13:04 +04:00
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
1999-01-21 06:44:03 +03:00
|
|
|
do_file_mark (panel, row, 0);
|
|
|
|
display_mini_info (panel);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1999-01-21 06:44:03 +03:00
|
|
|
if (panel->marked == 0)
|
|
|
|
panel->selected = 0;
|
|
|
|
}
|
|
|
|
|
1998-03-04 03:56:14 +03:00
|
|
|
static void
|
1999-09-21 00:03:58 +04:00
|
|
|
panel_file_list_resize_callback (GtkCList *clist, gint column, gint width, WPanel *panel)
|
1998-03-04 03:56:14 +03:00
|
|
|
{
|
1999-09-22 21:18:07 +04:00
|
|
|
int p;
|
1998-03-04 03:56:14 +03:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
p = column_width_pos[panel->list_type]; /* offset in column_width */
|
|
|
|
g_assert (p >= 0);
|
1998-03-04 03:56:14 +03:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
panel->column_width[p + column] = width;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
/* make this default */
|
|
|
|
memcpy (default_column_width, panel->column_width, sizeof (default_column_width));
|
1998-03-04 03:56:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_file_list_column_callback (GtkWidget *widget, int col, WPanel *panel)
|
|
|
|
{
|
|
|
|
format_e *format;
|
|
|
|
int i;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-04 03:56:14 +03:00
|
|
|
for (i = 0, format = panel->format; format; format = format->next){
|
|
|
|
if (!format->use_in_gui)
|
|
|
|
continue;
|
|
|
|
if (i == col){
|
|
|
|
sortfn *sorting_routine;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-04 03:56:14 +03:00
|
|
|
sorting_routine = get_sort_fn (format->id);
|
|
|
|
if (!sorting_routine)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (sorting_routine == panel->sort_type)
|
|
|
|
panel->reverse = !panel->reverse;
|
|
|
|
panel->sort_type = sorting_routine;
|
|
|
|
|
|
|
|
do_re_sort (panel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
/* Convenience function to load a pixmap and mask from xpm data */
|
1998-03-04 09:14:21 +03:00
|
|
|
static void
|
1998-11-10 05:28:34 +03:00
|
|
|
create_pixmap (char **data, GdkPixmap **pixmap, GdkBitmap **mask)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1998-11-10 05:28:34 +03:00
|
|
|
GdkImlibImage *im;
|
1998-03-04 03:56:14 +03:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
im = gdk_imlib_create_image_from_xpm_data (data);
|
|
|
|
gdk_imlib_render (im, im->rgb_width, im->rgb_height);
|
|
|
|
*pixmap = gdk_imlib_copy_image (im);
|
|
|
|
*mask = gdk_imlib_copy_mask (im);
|
|
|
|
gdk_imlib_destroy_image (im);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_create_pixmaps (void)
|
|
|
|
{
|
|
|
|
pixmaps_ready = TRUE;
|
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
create_pixmap (DIRECTORY_CLOSE_XPM, &icon_directory_pixmap, &icon_directory_mask);
|
1998-11-10 05:28:34 +03:00
|
|
|
create_pixmap (link_xpm, &icon_link_pixmap, &icon_link_mask);
|
|
|
|
create_pixmap (dev_xpm, &icon_dev_pixmap, &icon_dev_mask);
|
1998-03-04 03:56:14 +03:00
|
|
|
}
|
|
|
|
|
1998-12-15 09:35:51 +03:00
|
|
|
typedef gboolean (*desirable_fn)(WPanel *p, int x, int y);
|
|
|
|
typedef gboolean (*scroll_fn)(gpointer data);
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Sets up a timer to scroll a panel component when something is being dragged
|
|
|
|
* over it. The `desirable' function should return whether it is desirable to
|
|
|
|
* scroll at the specified coordinates; and the `scroll' function should
|
|
|
|
* actually scroll the view.
|
|
|
|
*/
|
|
|
|
static void
|
1999-01-26 09:53:48 +03:00
|
|
|
panel_setup_drag_scroll (WPanel *panel, int x, int y, desirable_fn desirable, scroll_fn scroll)
|
1998-12-15 09:35:51 +03:00
|
|
|
{
|
1999-03-20 21:08:52 +03:00
|
|
|
panel_cancel_drag_scroll (panel);
|
1998-12-15 09:35:51 +03:00
|
|
|
|
|
|
|
panel->drag_motion_x = x;
|
|
|
|
panel->drag_motion_y = y;
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
if ((* desirable) (panel, x, y))
|
|
|
|
panel->timer_id = gtk_timeout_add (SCROLL_TIMEOUT, scroll, panel);
|
1998-12-15 09:35:51 +03:00
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
static void
|
1999-04-10 01:13:04 +04:00
|
|
|
panel_file_list_configure (WPanel *panel, GtkWidget *sw, GtkWidget *file_list)
|
1998-03-04 03:56:14 +03:00
|
|
|
{
|
|
|
|
format_e *format = panel->format;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Set sorting callback */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "click_column",
|
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_column_callback), panel);
|
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
/* Set column resize callback */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "resize_column",
|
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_resize_callback), panel);
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* Avoid clist's broken focusing behavior */
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (file_list, GTK_CAN_FOCUS);
|
1998-03-06 09:42:43 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* Semi-sane selection mode */
|
1999-01-21 06:44:03 +03:00
|
|
|
gtk_clist_set_selection_mode (GTK_CLIST (file_list), GTK_SELECTION_EXTENDED);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
for (i = 0, format = panel->format; format; format = format->next) {
|
1999-04-08 03:26:49 +04:00
|
|
|
GtkJustification just = GTK_JUSTIFY_LEFT;
|
1998-03-04 03:56:14 +03:00
|
|
|
|
|
|
|
if (!format->use_in_gui)
|
|
|
|
continue;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-03-04 03:56:14 +03:00
|
|
|
/* Set desired justification */
|
1999-04-10 01:13:04 +04:00
|
|
|
switch (HIDE_FIT (format->just_mode)) {
|
1999-02-01 02:08:33 +03:00
|
|
|
case J_LEFT:
|
1999-04-10 01:13:04 +04:00
|
|
|
just = GTK_JUSTIFY_LEFT;
|
|
|
|
break;
|
|
|
|
|
1999-02-01 02:08:33 +03:00
|
|
|
case J_RIGHT:
|
1999-04-10 01:13:04 +04:00
|
|
|
just = GTK_JUSTIFY_RIGHT;
|
|
|
|
break;
|
|
|
|
|
1999-02-01 02:08:33 +03:00
|
|
|
case J_CENTER:
|
1999-04-10 01:13:04 +04:00
|
|
|
just = GTK_JUSTIFY_CENTER;
|
|
|
|
break;
|
1999-02-01 02:08:33 +03:00
|
|
|
}
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_clist_set_column_justification (GTK_CLIST (file_list), i, just);
|
1998-03-04 03:56:14 +03:00
|
|
|
i++;
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Creates an URI list to be transferred during a drop operation */
|
|
|
|
static char *
|
1998-03-02 23:27:08 +03:00
|
|
|
panel_build_selected_file_list (WPanel *panel, int *file_list_len)
|
|
|
|
{
|
|
|
|
if (panel->marked){
|
1998-10-20 09:37:45 +04:00
|
|
|
char *sep = "\r\n";
|
1998-03-02 23:27:08 +03:00
|
|
|
char *data, *copy;
|
1998-10-20 09:37:45 +04:00
|
|
|
int i, total_len;
|
1998-03-03 08:20:20 +03:00
|
|
|
int cwdlen = strlen (panel->cwd) + 1;
|
1998-10-20 09:37:45 +04:00
|
|
|
int filelen = strlen ("file:");
|
|
|
|
int seplen = strlen ("\r\n");
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-02 23:27:08 +03:00
|
|
|
/* first pass, compute the length */
|
1998-10-20 09:37:45 +04:00
|
|
|
total_len = 0;
|
1998-03-02 23:27:08 +03:00
|
|
|
for (i = 0; i < panel->count; i++)
|
|
|
|
if (panel->dir.list [i].f.marked)
|
1999-04-16 03:19:36 +04:00
|
|
|
total_len += (filelen + cwdlen
|
|
|
|
+ panel->dir.list [i].fnamelen
|
|
|
|
+ seplen);
|
1998-03-10 23:14:17 +03:00
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
total_len++;
|
1999-01-27 04:14:57 +03:00
|
|
|
data = copy = g_malloc (total_len+1);
|
1998-03-02 23:27:08 +03:00
|
|
|
for (i = 0; i < panel->count; i++)
|
|
|
|
if (panel->dir.list [i].f.marked){
|
1998-10-20 09:37:45 +04:00
|
|
|
strcpy (copy, "file:");
|
|
|
|
strcpy (© [filelen], panel->cwd);
|
|
|
|
copy [filelen+cwdlen-1] = '/';
|
|
|
|
strcpy (© [filelen + cwdlen], panel->dir.list [i].fname);
|
|
|
|
strcpy (© [filelen + cwdlen + panel->dir.list [i].fnamelen], sep);
|
|
|
|
copy += filelen + cwdlen + panel->dir.list [i].fnamelen + seplen;
|
1998-03-02 23:27:08 +03:00
|
|
|
}
|
1998-10-20 09:37:45 +04:00
|
|
|
data [total_len] = 0;
|
1998-03-02 23:27:08 +03:00
|
|
|
*file_list_len = total_len;
|
|
|
|
return data;
|
|
|
|
} else {
|
1998-10-20 09:37:45 +04:00
|
|
|
char *fullname, *uri;
|
|
|
|
|
|
|
|
fullname = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
|
|
|
|
1999-01-27 05:55:43 +03:00
|
|
|
uri = g_strconcat ("file:", fullname, NULL);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (fullname);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
*file_list_len = strlen (uri) + 1;
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_drag_data_get:
|
|
|
|
*
|
|
|
|
* Invoked when a drag operation has been performed, this routine
|
|
|
|
* provides the data to be transfered
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_drag_data_get (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint32 time,
|
|
|
|
WPanel *panel)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *data;
|
1998-12-11 21:12:21 +03:00
|
|
|
GList *files;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
panel_cancel_drag_scroll (panel);
|
1998-12-11 21:12:21 +03:00
|
|
|
data = panel_build_selected_file_list (panel, &len);
|
|
|
|
|
1998-10-20 09:37:45 +04:00
|
|
|
switch (info){
|
|
|
|
case TARGET_URI_LIST:
|
|
|
|
case TARGET_TEXT_PLAIN:
|
1998-12-05 04:01:13 +03:00
|
|
|
gtk_selection_data_set (selection_data, selection_data->target, 8, data, len);
|
1998-12-11 21:12:21 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TARGET_URL:
|
|
|
|
files = gnome_uri_list_extract_uris (data);
|
|
|
|
if (files) {
|
|
|
|
gtk_selection_data_set (selection_data,
|
|
|
|
selection_data->target,
|
|
|
|
8,
|
|
|
|
files->data,
|
|
|
|
strlen (files->data));
|
|
|
|
}
|
|
|
|
gnome_uri_list_free_strings (files);
|
1998-10-20 09:37:45 +04:00
|
|
|
break;
|
1999-04-16 03:19:36 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
1998-03-02 23:27:08 +03:00
|
|
|
}
|
1998-12-11 21:12:21 +03:00
|
|
|
|
|
|
|
g_free (data);
|
1998-03-02 23:27:08 +03:00
|
|
|
}
|
1998-10-20 05:52:16 +04:00
|
|
|
|
1998-10-21 22:05:08 +04:00
|
|
|
/**
|
|
|
|
* panel_drag_data_delete:
|
|
|
|
*
|
|
|
|
* Invoked when the destination requests the information to be deleted
|
|
|
|
* possibly because the operation was MOVE.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_drag_data_delete (GtkWidget *widget, GdkDragContext *context, WPanel *panel)
|
|
|
|
{
|
1998-11-29 10:50:44 +03:00
|
|
|
/* Things is: The File manager already handles file moving */
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
/* Performs a drop on a panel. If idx is -1, then drops on the panel's cwd
|
|
|
|
* itself.
|
1998-10-21 22:05:08 +04:00
|
|
|
*/
|
|
|
|
static void
|
1999-08-31 00:07:33 +04:00
|
|
|
drop_on_panel (WPanel *panel, int idx, GdkDragContext *context, GtkSelectionData *selection_data)
|
1998-10-21 22:05:08 +04:00
|
|
|
{
|
1999-02-03 14:46:01 +03:00
|
|
|
char *file;
|
1999-08-31 00:07:33 +04:00
|
|
|
file_entry *fe;
|
|
|
|
int drop_on_dir;
|
|
|
|
int reload;
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
g_assert (panel != NULL);
|
|
|
|
g_assert (idx == -1 || idx < panel->count);
|
|
|
|
g_assert (context != NULL);
|
|
|
|
g_assert (selection_data != NULL);
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
drop_on_dir = FALSE;
|
|
|
|
|
|
|
|
if (idx == -1)
|
|
|
|
drop_on_dir = TRUE;
|
|
|
|
else {
|
1999-02-03 14:46:01 +03:00
|
|
|
fe = &panel->dir.list[idx];
|
1999-08-31 00:07:33 +04:00
|
|
|
file = g_concat_dir_and_file (panel->cwd, fe->fname);
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
if (!((S_ISDIR (fe->buf.st_mode) || fe->f.link_to_dir)
|
|
|
|
|| gdnd_can_drop_on_file (file, fe))) {
|
|
|
|
g_free (file);
|
|
|
|
drop_on_dir = TRUE;
|
1999-02-24 04:40:08 +03:00
|
|
|
}
|
1999-08-31 00:07:33 +04:00
|
|
|
}
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
if (drop_on_dir) {
|
|
|
|
file = panel->cwd;
|
|
|
|
fe = file_entry_from_file (file);
|
|
|
|
if (!fe)
|
|
|
|
return; /* eeeek */
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
1998-11-10 05:28:34 +03:00
|
|
|
|
1999-02-23 22:21:35 +03:00
|
|
|
reload = gdnd_perform_drop (context, selection_data, file, fe);
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
if (file != panel->cwd)
|
1999-02-03 14:46:01 +03:00
|
|
|
g_free (file);
|
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
if (drop_on_dir)
|
1999-02-03 14:46:01 +03:00
|
|
|
file_entry_free (fe);
|
1998-10-21 22:05:08 +04:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
if (reload) {
|
1999-04-05 09:39:26 +04:00
|
|
|
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
|
|
|
repaint_screen ();
|
1999-01-08 04:53:42 +03:00
|
|
|
}
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
/**
|
|
|
|
* panel_icon_list_drag_data_received:
|
|
|
|
*
|
|
|
|
* Invoked on the target side of a Drag and Drop operation when data has been
|
|
|
|
* dropped.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_icon_list_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint32 time,
|
|
|
|
WPanel *panel)
|
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
idx = gnome_icon_list_get_icon_at (GNOME_ICON_LIST (widget), x, y);
|
|
|
|
drop_on_panel (panel, idx, context, selection_data);
|
|
|
|
}
|
|
|
|
|
1998-10-21 22:05:08 +04:00
|
|
|
/**
|
|
|
|
* panel_clist_drag_data_received:
|
|
|
|
*
|
|
|
|
* Invoked on the target side of a Drag and Drop operation when data has been
|
|
|
|
* dropped.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_clist_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint32 time,
|
|
|
|
WPanel *panel)
|
|
|
|
{
|
1999-08-31 00:07:33 +04:00
|
|
|
GtkCList *clist;
|
1998-10-21 22:05:08 +04:00
|
|
|
int row;
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
clist = GTK_CLIST (widget);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
/* Normalize the y coordinate to the clist_window */
|
1998-10-21 22:05:08 +04:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
y -= (GTK_CONTAINER (clist)->border_width
|
|
|
|
+ clist->column_title_area.y
|
|
|
|
+ clist->column_title_area.height);
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
if (gtk_clist_get_selection_info (GTK_CLIST (widget), x, y, &row, NULL) == 0)
|
|
|
|
row = -1;
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-08-31 00:07:33 +04:00
|
|
|
drop_on_panel (panel, row, context, selection_data);
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
/**
|
|
|
|
* panel_tree_drag_data_received:
|
|
|
|
*
|
|
|
|
* Invoked on the target side when a drop has been received in the Tree
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_tree_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint32 time,
|
|
|
|
WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkDTree *dtree = GTK_DTREE (widget);
|
1998-12-03 19:10:25 +03:00
|
|
|
GtkCTreeNode *node;
|
|
|
|
int row, col;
|
1999-02-03 14:46:01 +03:00
|
|
|
file_entry *fe;
|
1998-12-03 19:10:25 +03:00
|
|
|
char *path;
|
1999-04-05 09:39:26 +04:00
|
|
|
int reload;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-12-03 19:10:25 +03:00
|
|
|
if (!gtk_clist_get_selection_info (GTK_CLIST (dtree), x, y, &row, &col))
|
|
|
|
return;
|
1998-12-02 08:18:20 +03:00
|
|
|
|
1998-12-03 19:10:25 +03:00
|
|
|
node = gtk_ctree_node_nth (GTK_CTREE (dtree), row);
|
|
|
|
if (!node)
|
|
|
|
return;
|
1999-02-03 14:46:01 +03:00
|
|
|
|
1999-09-14 03:27:18 +04:00
|
|
|
path = gtk_dtree_get_row_path (dtree, node);
|
1999-02-03 14:46:01 +03:00
|
|
|
fe = file_entry_from_file (path);
|
1999-08-27 09:01:08 +04:00
|
|
|
if (!fe) {
|
|
|
|
g_free (path);
|
1999-02-03 14:46:01 +03:00
|
|
|
return; /* eeeek */
|
1999-08-27 09:01:08 +04:00
|
|
|
}
|
1998-12-03 19:10:25 +03:00
|
|
|
|
1999-04-05 09:39:26 +04:00
|
|
|
reload = gdnd_perform_drop (context, selection_data, path, fe);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-02-03 14:46:01 +03:00
|
|
|
file_entry_free (fe);
|
1998-12-03 19:10:25 +03:00
|
|
|
g_free (path);
|
1999-04-05 09:39:26 +04:00
|
|
|
|
|
|
|
if (reload) {
|
|
|
|
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
|
|
|
repaint_screen ();
|
|
|
|
}
|
1998-12-02 08:18:20 +03:00
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
static void
|
1998-05-08 06:25:00 +04:00
|
|
|
load_dnd_icons (void)
|
1998-03-03 03:31:05 +03:00
|
|
|
{
|
1998-03-06 06:48:31 +03:00
|
|
|
if (!drag_directory)
|
1998-05-22 05:07:00 +04:00
|
|
|
drag_directory = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_NOT, NULL);
|
1998-11-10 05:28:34 +03:00
|
|
|
|
1998-03-06 06:48:31 +03:00
|
|
|
if (!drag_directory_ok)
|
1998-05-22 05:07:00 +04:00
|
|
|
drag_directory_ok = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_NEW, NULL);
|
1998-11-10 05:28:34 +03:00
|
|
|
|
1998-03-12 08:59:43 +03:00
|
|
|
if (!drag_multiple)
|
1998-05-22 05:07:00 +04:00
|
|
|
drag_multiple = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_NOT, NULL);
|
1998-11-10 05:28:34 +03:00
|
|
|
|
1998-03-12 08:59:43 +03:00
|
|
|
if (!drag_multiple_ok)
|
1998-05-22 05:07:00 +04:00
|
|
|
drag_multiple_ok = gnome_stock_transparent_window (GNOME_STOCK_PIXMAP_MULTIPLE, NULL);
|
1998-05-08 06:25:00 +04:00
|
|
|
}
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* Convenience function to start a drag operation for the icon and file lists */
|
|
|
|
static void
|
|
|
|
start_drag (GtkWidget *widget, int button, GdkEvent *event)
|
1998-10-28 05:06:34 +03:00
|
|
|
{
|
1999-04-10 01:13:04 +04:00
|
|
|
GtkTargetList *list;
|
|
|
|
GdkDragContext *context;
|
1998-10-28 05:06:34 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
list = gtk_target_list_new (drag_types, ELEMENTS (drag_types));
|
1998-10-28 05:06:34 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
context = gtk_drag_begin (widget, list,
|
|
|
|
(GDK_ACTION_COPY | GDK_ACTION_MOVE
|
|
|
|
| GDK_ACTION_LINK | GDK_ACTION_ASK),
|
|
|
|
button, event);
|
|
|
|
gtk_drag_set_icon_default (context);
|
1998-10-28 05:06:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
panel_widget_motion (GtkWidget *widget, GdkEventMotion *event, WPanel *panel)
|
1998-10-21 22:05:08 +04:00
|
|
|
{
|
1998-10-28 05:06:34 +03:00
|
|
|
if (!panel->maybe_start_drag)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-04-10 04:54:10 +04:00
|
|
|
if (!((panel->maybe_start_drag == 1 && (event->state & GDK_BUTTON1_MASK))
|
|
|
|
|| (panel->maybe_start_drag == 2 && (event->state & GDK_BUTTON2_MASK))))
|
|
|
|
return FALSE;
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* This is the same threshold value that is used in gtkdnd.c */
|
1998-10-28 05:06:34 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
if (MAX (abs (panel->click_x - event->x),
|
|
|
|
abs (panel->click_y - event->y)) <= 3)
|
|
|
|
return FALSE;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
start_drag (widget, panel->maybe_start_drag, (GdkEvent *) event);
|
1998-10-28 05:06:34 +03:00
|
|
|
return FALSE;
|
1998-10-21 22:05:08 +04:00
|
|
|
}
|
|
|
|
|
1998-12-04 00:56:11 +03:00
|
|
|
/**
|
|
|
|
* panel_drag_begin:
|
|
|
|
*
|
|
|
|
* Invoked when a drag is starting in the List view or the Icon view
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_drag_begin (GtkWidget *widget, GdkDragContext *context, WPanel *panel)
|
|
|
|
{
|
|
|
|
panel->dragging = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_drag_end:
|
|
|
|
*
|
|
|
|
* Invoked when a drag has finished in the List view or the Icon view
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_drag_end (GtkWidget *widget, GdkDragContext *context, WPanel *panel)
|
|
|
|
{
|
1999-03-20 21:08:52 +03:00
|
|
|
panel_cancel_drag_scroll (panel);
|
1998-12-04 00:56:11 +03:00
|
|
|
panel->dragging = 0;
|
|
|
|
}
|
|
|
|
|
1998-12-15 09:35:51 +03:00
|
|
|
/**
|
|
|
|
* panel_clist_scrolling_is_desirable:
|
|
|
|
*
|
|
|
|
* If the cursor is in a position close to either edge (top or bottom)
|
|
|
|
* and there is possible to scroll the window, this routine returns
|
|
|
|
* true.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
panel_clist_scrolling_is_desirable (WPanel *panel, int x, int y)
|
|
|
|
{
|
|
|
|
GtkAdjustment *va;
|
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
va = scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (panel->list));
|
1998-12-15 09:35:51 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
if (y < 10) {
|
1998-12-15 09:35:51 +03:00
|
|
|
if (va->value > va->lower)
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
1999-04-10 01:13:04 +04:00
|
|
|
if (y > (CLIST_FROM_SW (panel->list)->clist_window_height - 10)) {
|
1999-01-20 13:40:21 +03:00
|
|
|
if (va->value < va->upper - va->page_size)
|
1998-12-15 09:35:51 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_clist_scroll:
|
|
|
|
*
|
|
|
|
* Timer callback invoked to scroll the clist window
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
panel_clist_scroll (gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel = data;
|
|
|
|
GtkAdjustment *va;
|
1999-01-20 13:40:21 +03:00
|
|
|
double v;
|
1998-12-15 09:35:51 +03:00
|
|
|
|
|
|
|
va = scrolled_window_get_vadjustment (panel->list);
|
|
|
|
|
1999-01-20 13:40:21 +03:00
|
|
|
if (panel->drag_motion_y < 10) {
|
|
|
|
v = va->value - va->step_increment;
|
|
|
|
if (v < va->lower)
|
|
|
|
v = va->lower;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
|
|
|
} else {
|
|
|
|
v = va->value + va->step_increment;
|
|
|
|
if (v > va->upper - va->page_size)
|
|
|
|
v = va->upper - va->page_size;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
1998-12-15 09:35:51 +03:00
|
|
|
}
|
1999-01-20 13:40:21 +03:00
|
|
|
|
1998-12-15 09:35:51 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
/* Callback used for drag motion events over the clist. We set up
|
|
|
|
* auto-scrolling and validate the drop to present the user with the correct
|
|
|
|
* feedback.
|
1998-12-15 09:35:51 +03:00
|
|
|
*/
|
|
|
|
static gboolean
|
1999-01-26 09:53:48 +03:00
|
|
|
panel_clist_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time,
|
|
|
|
gpointer data)
|
1998-12-15 09:35:51 +03:00
|
|
|
{
|
1999-01-26 09:53:48 +03:00
|
|
|
WPanel *panel;
|
1999-04-10 01:13:04 +04:00
|
|
|
GtkCList *clist;
|
1999-01-26 09:53:48 +03:00
|
|
|
GdkDragAction action;
|
|
|
|
GtkWidget *source_widget;
|
|
|
|
gint idx;
|
|
|
|
file_entry *fe;
|
1999-08-27 09:01:08 +04:00
|
|
|
char *full_name;
|
1999-01-22 03:59:11 +03:00
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
panel = data;
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* Normalize the y coordinate to the clist_window */
|
|
|
|
|
|
|
|
clist = CLIST_FROM_SW (panel->list);
|
|
|
|
y -= (GTK_CONTAINER (clist)->border_width
|
|
|
|
+ clist->column_title_area.y
|
|
|
|
+ clist->column_title_area.height);
|
|
|
|
|
|
|
|
if (y < 0) {
|
1999-01-26 09:53:48 +03:00
|
|
|
gdk_drag_status (context, 0, time);
|
1999-04-10 01:13:04 +04:00
|
|
|
goto out;
|
1999-01-22 03:59:11 +03:00
|
|
|
}
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
/* Set up auto-scrolling */
|
|
|
|
|
|
|
|
panel_setup_drag_scroll (panel, x, y,
|
|
|
|
panel_clist_scrolling_is_desirable,
|
|
|
|
panel_clist_scroll);
|
|
|
|
|
|
|
|
/* Validate the drop */
|
|
|
|
|
|
|
|
gdnd_find_panel_by_drag_context (context, &source_widget);
|
|
|
|
|
|
|
|
if (!gtk_clist_get_selection_info (GTK_CLIST (widget), x, y, &idx, NULL))
|
|
|
|
fe = NULL;
|
|
|
|
else
|
|
|
|
fe = &panel->dir.list[idx];
|
|
|
|
|
1999-08-27 09:01:08 +04:00
|
|
|
full_name = fe ? g_concat_dir_and_file (panel->cwd, fe->fname) : panel->cwd;
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
action = gdnd_validate_action (context,
|
1999-02-03 14:46:01 +03:00
|
|
|
FALSE,
|
1999-01-26 09:53:48 +03:00
|
|
|
source_widget != NULL,
|
|
|
|
source_widget == widget,
|
1999-08-27 09:01:08 +04:00
|
|
|
full_name,
|
1999-01-26 09:53:48 +03:00
|
|
|
fe,
|
|
|
|
fe ? fe->f.marked : FALSE);
|
|
|
|
|
1999-08-27 09:01:08 +04:00
|
|
|
if (full_name != panel->cwd)
|
|
|
|
g_free (full_name);
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
gdk_drag_status (context, action, time);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
|
|
|
out:
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "drag_motion");
|
1998-12-15 09:35:51 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_clist_drag_leave
|
|
|
|
*
|
|
|
|
* Invoked when the dragged object has left our region
|
|
|
|
*/
|
|
|
|
static void
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_clist_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
|
1998-12-15 09:35:51 +03:00
|
|
|
{
|
1999-04-16 03:19:36 +04:00
|
|
|
WPanel *panel;
|
1998-12-15 09:35:51 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
panel = data;
|
1999-03-20 21:08:52 +03:00
|
|
|
panel_cancel_drag_scroll (panel);
|
1998-12-15 09:35:51 +03:00
|
|
|
}
|
|
|
|
|
1999-01-01 05:04:59 +03:00
|
|
|
/**
|
|
|
|
* panel_icon_list_scrolling_is_desirable:
|
|
|
|
*
|
|
|
|
* If the cursor is in a position close to either edge (top or bottom)
|
|
|
|
* and there is possible to scroll the window, this routine returns
|
|
|
|
* true.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
panel_icon_list_scrolling_is_desirable (WPanel *panel, int x, int y)
|
|
|
|
{
|
|
|
|
GtkAdjustment *va;
|
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
va = scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (panel->icons));
|
1999-01-01 05:04:59 +03:00
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
if (y < 10) {
|
1999-01-01 05:04:59 +03:00
|
|
|
if (va->value > va->lower)
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
1999-02-11 00:03:04 +03:00
|
|
|
if (y > (GTK_WIDGET (ILIST_FROM_SW (panel->icons))->allocation.height - 10)) {
|
1999-01-20 13:40:21 +03:00
|
|
|
if (va->value < va->upper - va->page_size)
|
1999-01-01 05:04:59 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_icon_list_scroll:
|
|
|
|
*
|
|
|
|
* Timer callback invoked to scroll the clist window
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
panel_icon_list_scroll (gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel = data;
|
|
|
|
GtkAdjustment *va;
|
1999-01-20 13:40:21 +03:00
|
|
|
double v;
|
1999-01-01 05:04:59 +03:00
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
va = scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (panel->icons));
|
1999-01-01 05:04:59 +03:00
|
|
|
|
1999-01-20 13:40:21 +03:00
|
|
|
if (panel->drag_motion_y < 10) {
|
|
|
|
v = va->value - va->step_increment;
|
|
|
|
if (v < va->lower)
|
|
|
|
v = va->lower;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
|
|
|
} else {
|
|
|
|
v = va->value + va->step_increment;
|
|
|
|
if (v > va->upper - va->page_size)
|
|
|
|
v = va->upper - va->page_size;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
1999-01-01 05:04:59 +03:00
|
|
|
}
|
1999-01-20 13:40:21 +03:00
|
|
|
|
1999-01-01 05:04:59 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-01-25 19:50:38 +03:00
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
/* Callback used for drag motion events in the icon list. We need to set up
|
|
|
|
* auto-scrolling and validate the drop to present the user with the correct
|
|
|
|
* feedback.
|
1999-01-01 05:04:59 +03:00
|
|
|
*/
|
|
|
|
static gboolean
|
1999-01-26 09:53:48 +03:00
|
|
|
panel_icon_list_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time,
|
|
|
|
gpointer data)
|
1999-01-01 05:04:59 +03:00
|
|
|
{
|
1999-01-26 09:53:48 +03:00
|
|
|
WPanel *panel;
|
|
|
|
GdkDragAction action;
|
|
|
|
GtkWidget *source_widget;
|
|
|
|
int idx;
|
|
|
|
file_entry *fe;
|
1999-08-27 09:01:08 +04:00
|
|
|
char *full_name;
|
1999-01-26 09:53:48 +03:00
|
|
|
|
|
|
|
panel = data;
|
|
|
|
|
|
|
|
/* Set up auto-scrolling */
|
|
|
|
|
|
|
|
panel_setup_drag_scroll (panel, x, y,
|
|
|
|
panel_icon_list_scrolling_is_desirable,
|
|
|
|
panel_icon_list_scroll);
|
|
|
|
|
|
|
|
/* Validate the drop */
|
|
|
|
|
|
|
|
gdnd_find_panel_by_drag_context (context, &source_widget);
|
|
|
|
|
|
|
|
idx = gnome_icon_list_get_icon_at (GNOME_ICON_LIST (widget), x, y);
|
|
|
|
fe = (idx == -1) ? NULL : &panel->dir.list[idx];
|
|
|
|
|
1999-08-27 09:01:08 +04:00
|
|
|
full_name = fe ? g_concat_dir_and_file (panel->cwd, fe->fname) : panel->cwd;
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
action = gdnd_validate_action (context,
|
1999-02-03 14:46:01 +03:00
|
|
|
FALSE,
|
1999-01-26 09:53:48 +03:00
|
|
|
source_widget != NULL,
|
|
|
|
source_widget == widget,
|
1999-08-27 09:01:08 +04:00
|
|
|
full_name,
|
1999-01-26 09:53:48 +03:00
|
|
|
fe,
|
|
|
|
fe ? fe->f.marked : FALSE);
|
|
|
|
|
1999-08-27 09:01:08 +04:00
|
|
|
if (full_name != panel->cwd)
|
|
|
|
g_free (full_name);
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
gdk_drag_status (context, action, time);
|
1999-01-01 05:04:59 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* panel_icon_list_drag_leave:
|
|
|
|
*
|
|
|
|
* Invoked when the dragged object has left our region
|
|
|
|
*/
|
|
|
|
static void
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_icon_list_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
|
1999-01-01 05:04:59 +03:00
|
|
|
{
|
|
|
|
WPanel *panel = data;
|
|
|
|
|
1999-03-20 21:08:52 +03:00
|
|
|
panel_cancel_drag_scroll (panel);
|
1999-01-01 05:04:59 +03:00
|
|
|
}
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
/* Handler for the row_popup_menu signal of the file list. */
|
|
|
|
static void
|
|
|
|
panel_file_list_row_popup_menu (GtkFList *flist, GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
|
|
|
gpopup_do_popup2 (event, panel, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handler for the empty_popup_menu signal of the file list. */
|
|
|
|
static void
|
|
|
|
panel_file_list_empty_popup_menu (GtkFList *flist, GdkEventButton *event, gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
|
|
|
file_list_popup (event, panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handler for the open_row signal of the file list */
|
|
|
|
static void
|
|
|
|
panel_file_list_open_row (GtkFList *flist, gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
|
|
|
do_enter (panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handler for the start_drag signal of the file list */
|
|
|
|
static void
|
|
|
|
panel_file_list_start_drag (GtkFList *flist, gint button, GdkEvent *event, gpointer data)
|
|
|
|
{
|
|
|
|
start_drag (GTK_WIDGET (flist), button, event);
|
|
|
|
}
|
|
|
|
|
1998-04-11 06:53:35 +04:00
|
|
|
/*
|
|
|
|
* Create, setup the file listing display.
|
|
|
|
*/
|
1998-03-04 09:14:21 +03:00
|
|
|
static GtkWidget *
|
1998-02-27 07:54:42 +03:00
|
|
|
panel_create_file_list (WPanel *panel)
|
|
|
|
{
|
|
|
|
const int items = panel->format->items;
|
|
|
|
format_e *format = panel->format;
|
|
|
|
GtkWidget *file_list;
|
1998-11-10 05:28:34 +03:00
|
|
|
GtkWidget *sw;
|
1998-02-27 07:54:42 +03:00
|
|
|
gchar **titles;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
titles = g_new (char *, items);
|
|
|
|
for (i = 0; i < items; format = format->next)
|
|
|
|
if (format->use_in_gui)
|
|
|
|
titles [i++] = format->title;
|
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
1999-02-11 00:03:04 +03:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
1998-11-10 05:28:34 +03:00
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
file_list = gtk_flist_new_with_titles (panel, items, titles);
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (sw), file_list);
|
|
|
|
gtk_widget_show (file_list);
|
|
|
|
|
1999-04-10 01:13:04 +04:00
|
|
|
panel_file_list_configure (panel, sw, file_list);
|
1998-08-21 02:04:52 +04:00
|
|
|
g_free (titles);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "select_row",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_select_row),
|
1998-03-11 01:34:28 +03:00
|
|
|
panel);
|
1999-01-21 06:44:03 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "unselect_row",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_unselect_row),
|
1999-01-21 06:44:03 +03:00
|
|
|
panel);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
|
|
|
/* Connect to the flist signals */
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "row_popup_menu",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_row_popup_menu),
|
1999-04-10 01:13:04 +04:00
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "empty_popup_menu",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_empty_popup_menu),
|
1999-04-10 01:13:04 +04:00
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "open_row",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_open_row),
|
1999-04-10 01:13:04 +04:00
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "start_drag",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_file_list_start_drag),
|
1999-04-10 01:13:04 +04:00
|
|
|
panel);
|
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
/* Set up drag and drop */
|
|
|
|
|
|
|
|
load_dnd_icons ();
|
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (file_list),
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1998-11-10 05:28:34 +03:00
|
|
|
drop_types, ELEMENTS (drop_types),
|
1999-01-21 20:59:30 +03:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_data_get",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_data_get), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_data_delete",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_data_delete), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_data_received",
|
|
|
|
GTK_SIGNAL_FUNC (panel_clist_drag_data_received), panel);
|
|
|
|
|
1998-12-15 09:35:51 +03:00
|
|
|
/*
|
|
|
|
* This signal is provided for scrolling the main window
|
|
|
|
* if data is being dragged
|
|
|
|
*/
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_motion",
|
|
|
|
GTK_SIGNAL_FUNC (panel_clist_drag_motion), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_leave",
|
|
|
|
GTK_SIGNAL_FUNC (panel_clist_drag_leave), panel);
|
1998-12-04 00:56:11 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_begin",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_begin), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (file_list), "drag_end",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_end), panel);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-11 03:05:12 +03:00
|
|
|
return sw;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-04-11 06:53:35 +04:00
|
|
|
/*
|
|
|
|
* Callback: icon selected
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPanel *panel)
|
|
|
|
{
|
1998-05-08 06:25:00 +04:00
|
|
|
panel->selected = index;
|
|
|
|
do_file_mark (panel, index, 1);
|
|
|
|
display_mini_info (panel);
|
|
|
|
execute_hooks (select_file_hook);
|
|
|
|
|
1999-08-13 02:14:07 +04:00
|
|
|
/* Do not let the user select .. */
|
|
|
|
if (strcmp (panel->dir.list[index].fname, "..") == 0)
|
|
|
|
gnome_icon_list_unselect_icon (GNOME_ICON_LIST (widget), index);
|
|
|
|
|
1998-05-12 08:26:21 +04:00
|
|
|
if (!event)
|
|
|
|
return;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
switch (event->type){
|
|
|
|
case GDK_BUTTON_PRESS:
|
1999-04-10 01:13:04 +04:00
|
|
|
if (event->button.button == 3)
|
1999-03-11 05:40:53 +03:00
|
|
|
gpopup_do_popup2 ((GdkEventButton *) event, panel, NULL);
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1999-01-08 06:03:58 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
1998-12-17 11:28:05 +03:00
|
|
|
if (event->button.button == 2){
|
1998-12-07 20:08:59 +03:00
|
|
|
char *fullname;
|
|
|
|
|
|
|
|
if (S_ISDIR (panel->dir.list [index].buf.st_mode) ||
|
|
|
|
panel->dir.list [index].f.link_to_dir){
|
|
|
|
fullname = concat_dir_and_file (panel->cwd, panel->dir.list [index].fname);
|
|
|
|
new_panel_at (fullname);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (fullname);
|
1998-12-07 20:08:59 +03:00
|
|
|
}
|
1999-04-10 01:13:04 +04:00
|
|
|
}
|
1998-05-08 06:25:00 +04:00
|
|
|
break;
|
1999-04-10 01:13:04 +04:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
case GDK_2BUTTON_PRESS:
|
1999-04-08 03:26:49 +04:00
|
|
|
if (event->button.button == 1) {
|
1998-05-08 06:25:00 +04:00
|
|
|
do_enter (panel);
|
1999-04-08 03:26:49 +04:00
|
|
|
}
|
1998-05-08 06:25:00 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_icon_list_unselect_icon (GtkWidget *widget, int index, GdkEvent *event, WPanel *panel)
|
|
|
|
{
|
|
|
|
do_file_mark (panel, index, 0);
|
|
|
|
display_mini_info (panel);
|
|
|
|
if (panel->marked == 0)
|
|
|
|
panel->selected = 0;
|
|
|
|
}
|
|
|
|
|
1999-08-13 02:50:25 +04:00
|
|
|
static int
|
|
|
|
queue_reread_cmd (gpointer data)
|
|
|
|
{
|
|
|
|
reread_cmd ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-14 02:45:07 +04:00
|
|
|
/* Renames a file using a file operation context. Returns FILE_CONT on success. */
|
|
|
|
int
|
|
|
|
rename_file_with_context (char *source, char *dest)
|
|
|
|
{
|
|
|
|
FileOpContext *ctx;
|
|
|
|
struct stat s;
|
|
|
|
long count;
|
|
|
|
double bytes;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
if (mc_lstat (source, &s) != 0)
|
|
|
|
return FILE_ABORT;
|
|
|
|
|
|
|
|
ctx = file_op_context_new ();
|
|
|
|
file_op_context_create_ui (ctx, OP_MOVE, FALSE);
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
bytes = s.st_size;
|
|
|
|
|
|
|
|
retval = move_file_file (ctx, source, dest, &count, &bytes);
|
|
|
|
file_op_context_destroy (ctx);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
1998-10-14 10:26:05 +04:00
|
|
|
static int
|
|
|
|
panel_icon_renamed (GtkWidget *widget, int index, char *dest, WPanel *panel)
|
|
|
|
{
|
|
|
|
char *source;
|
1999-08-14 02:45:07 +04:00
|
|
|
char *fullname;
|
|
|
|
int retval;
|
|
|
|
|
1999-09-01 23:28:57 +04:00
|
|
|
if (strcmp (dest, panel->dir.list[index].fname) == 0)
|
|
|
|
return TRUE; /* do nothing if the name did not change */
|
|
|
|
|
|
|
|
source = g_concat_dir_and_file (cpanel->cwd, panel->dir.list[index].fname);
|
1999-08-14 02:45:07 +04:00
|
|
|
fullname = g_concat_dir_and_file (cpanel->cwd, dest);
|
1998-10-14 10:26:05 +04:00
|
|
|
|
1999-08-14 02:45:07 +04:00
|
|
|
if (rename_file_with_context (source, dest) == FILE_CONT) {
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (panel->dir.list [index].fname);
|
|
|
|
panel->dir.list [index].fname = g_strdup (dest);
|
1999-08-13 02:50:25 +04:00
|
|
|
|
|
|
|
gtk_idle_add (queue_reread_cmd, NULL);
|
1999-08-14 02:45:07 +04:00
|
|
|
retval = TRUE;
|
1998-10-14 10:26:05 +04:00
|
|
|
} else
|
1999-08-14 02:45:07 +04:00
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
g_free (source);
|
|
|
|
g_free (fullname);
|
|
|
|
|
|
|
|
return retval;
|
1998-10-14 10:26:05 +04:00
|
|
|
}
|
|
|
|
|
1999-02-15 20:59:49 +03:00
|
|
|
/* 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[] = {
|
1999-04-05 09:39:26 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Rescan Directory"), N_("Reloads the current directory"),
|
1999-02-15 20:59:49 +03:00
|
|
|
handle_rescan_directory),
|
1999-04-05 09:39:26 +04:00
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("New _Directory..."), N_("Creates a new directory here"),
|
1999-02-26 10:17:51 +03:00
|
|
|
gnome_mkdir_cmd),
|
2000-06-16 22:16:44 +04:00
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The popup menu for file panels */
|
|
|
|
static GnomeUIInfo trash_file_list_popup_items[] = {
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("Empty _Trash"), N_("Empties the Trash"),
|
|
|
|
gnome_empty_trash),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("_Rescan Directory"), N_("Reloads the current directory"),
|
|
|
|
handle_rescan_directory),
|
|
|
|
GNOMEUIINFO_ITEM_NONE (N_("New _Directory..."), N_("Creates a new directory here"),
|
|
|
|
gnome_mkdir_cmd),
|
1999-02-15 20:59:49 +03:00
|
|
|
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;
|
2000-06-16 22:16:44 +04:00
|
|
|
gchar *trash_dir;
|
|
|
|
GnomeUIInfo *items = file_list_popup_items;
|
|
|
|
|
|
|
|
trash_dir = g_strconcat (gnome_user_home_dir, "/",
|
|
|
|
DESKTOP_DIR_NAME, "/",
|
|
|
|
"Trash",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if ((strncmp (panel->cwd, trash_dir, strlen (trash_dir)) == 0) && (panel->count != 1))
|
|
|
|
items = trash_file_list_popup_items;
|
|
|
|
g_free (trash_dir);
|
1999-02-15 20:59:49 +03:00
|
|
|
|
2000-06-16 22:16:44 +04:00
|
|
|
popup = gnome_popup_menu_new (items);
|
1999-02-15 20:59:49 +03:00
|
|
|
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, panel);
|
|
|
|
gtk_widget_destroy (popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Returns whether an icon in the icon list is being edited. FIXME: This
|
|
|
|
* function uses a fantastically ugly hack to figure this out. It would be
|
|
|
|
* saner to have a function provided by the icon list widget to do it, but we
|
|
|
|
* can't break forwards compatibility at this point. It would be even saner to
|
|
|
|
* have a good DnD API for the icon list.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
editing_icon_list (GnomeIconList *gil)
|
|
|
|
{
|
|
|
|
GnomeCanvasItem *item;
|
|
|
|
|
|
|
|
item = GNOME_CANVAS (gil)->focused_item;
|
|
|
|
return (item && GNOME_IS_ICON_TEXT_ITEM (item) && GNOME_ICON_TEXT_ITEM (item)->editing);
|
|
|
|
}
|
|
|
|
|
1998-10-21 05:09:50 +04:00
|
|
|
/*
|
|
|
|
* Strategy for activaing the drags from the icon-list:
|
|
|
|
*
|
|
|
|
* The icon-list uses the button-press/motion-notify events for
|
|
|
|
* the banding selection. We catch the events and only if the
|
|
|
|
* click happens in an icon and the user moves the mouse enough (a
|
|
|
|
* threshold to give it a better feel) activa the drag and drop.
|
|
|
|
*
|
|
|
|
*/
|
1998-10-21 03:44:39 +04:00
|
|
|
static int
|
1998-10-21 05:09:50 +04:00
|
|
|
panel_icon_list_button_press (GtkWidget *widget, GdkEventButton *event, WPanel *panel)
|
1998-10-21 03:44:39 +04:00
|
|
|
{
|
|
|
|
GnomeIconList *gil = GNOME_ICON_LIST (widget);
|
|
|
|
int icon;
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
if (editing_icon_list (gil))
|
|
|
|
return FALSE;
|
|
|
|
|
1999-04-10 04:54:10 +04:00
|
|
|
if (event->type != GDK_BUTTON_PRESS)
|
|
|
|
return FALSE;
|
|
|
|
|
1998-10-21 03:44:39 +04:00
|
|
|
icon = gnome_icon_list_get_icon_at (gil, event->x, event->y);
|
|
|
|
|
1999-02-06 04:30:01 +03:00
|
|
|
if (icon == -1) {
|
1999-04-10 04:54:10 +04:00
|
|
|
if (event->button == 3) {
|
1999-02-15 20:59:49 +03:00
|
|
|
file_list_popup (event, panel);
|
1999-02-10 04:50:08 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-02-11 20:11:18 +03:00
|
|
|
} else if (event->button != 3)
|
1999-02-10 04:50:08 +03:00
|
|
|
panel->maybe_start_drag = event->button;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-10-21 05:09:50 +04:00
|
|
|
panel->click_x = event->x;
|
|
|
|
panel->click_y = event->y;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
panel_icon_list_button_release (GtkWidget *widget, GdkEventButton *event, WPanel *panel)
|
|
|
|
{
|
1998-10-28 05:06:34 +03:00
|
|
|
panel->maybe_start_drag = 0;
|
1998-10-21 03:44:39 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
/* Create and setup the icon field display */
|
|
|
|
static GtkWidget *
|
|
|
|
panel_create_icon_display (WPanel *panel)
|
1998-05-08 06:25:00 +04:00
|
|
|
{
|
1999-02-11 00:03:04 +03:00
|
|
|
GtkWidget *sw;
|
1998-11-10 05:28:34 +03:00
|
|
|
GnomeIconList *ilist;
|
1999-02-11 00:03:04 +03:00
|
|
|
|
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
|
1999-01-22 05:14:00 +03:00
|
|
|
ilist = GNOME_ICON_LIST (
|
1999-02-11 00:03:04 +03:00
|
|
|
gnome_icon_list_new_flags (90, NULL,
|
|
|
|
(GNOME_ICON_LIST_IS_EDITABLE
|
|
|
|
| GNOME_ICON_LIST_STATIC_TEXT)));
|
|
|
|
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (ilist));
|
|
|
|
gtk_widget_show (GTK_WIDGET (ilist));
|
1999-01-20 13:40:21 +03:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gnome_icon_list_set_separators (ilist, " /-_.");
|
|
|
|
gnome_icon_list_set_row_spacing (ilist, 2);
|
|
|
|
gnome_icon_list_set_col_spacing (ilist, 2);
|
|
|
|
gnome_icon_list_set_icon_border (ilist, 2);
|
|
|
|
gnome_icon_list_set_text_spacing (ilist, 2);
|
1998-10-21 22:05:08 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gnome_icon_list_set_selection_mode (ilist, GTK_SELECTION_MULTIPLE);
|
|
|
|
GTK_WIDGET_SET_FLAGS (ilist, GTK_CAN_FOCUS);
|
1998-10-21 05:09:50 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "select_icon",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_select_icon),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "unselect_icon",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_unselect_icon),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "text_changed",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_renamed),
|
|
|
|
panel);
|
1998-10-21 05:09:50 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
/* Setup the icons and DnD */
|
1998-10-21 03:44:39 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
load_dnd_icons ();
|
1998-10-21 05:09:50 +04:00
|
|
|
|
1999-01-26 09:53:48 +03:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (ilist),
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1998-11-10 05:28:34 +03:00
|
|
|
drop_types, ELEMENTS (drop_types),
|
1999-01-21 20:59:30 +03:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
1998-04-11 06:53:35 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_data_get",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_data_get),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_data_delete",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_data_delete),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_data_received",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_drag_data_received),
|
|
|
|
panel);
|
1998-12-04 00:56:11 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_begin",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_begin), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_end",
|
|
|
|
GTK_SIGNAL_FUNC (panel_drag_end), panel);
|
1998-04-11 06:53:35 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
/* These implement our drag-start activation code, as we have a pretty oveloaded widget */
|
1998-10-14 06:56:18 +04:00
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "button_press_event",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_button_press),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "button_release_event",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_button_release),
|
|
|
|
panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "motion_notify_event",
|
|
|
|
GTK_SIGNAL_FUNC (panel_widget_motion),
|
|
|
|
panel);
|
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
/* This signal is provide for scrolling the main window if data is being
|
|
|
|
* dragged.
|
1999-01-01 05:04:59 +03:00
|
|
|
*/
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_motion",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_drag_motion), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (ilist), "drag_leave",
|
|
|
|
GTK_SIGNAL_FUNC (panel_icon_list_drag_leave), panel);
|
1999-02-11 00:03:04 +03:00
|
|
|
|
|
|
|
return sw;
|
1998-04-11 06:53:35 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 00:32:19 +03:00
|
|
|
static void
|
1998-03-07 03:05:06 +03:00
|
|
|
panel_switch_new_display_mode (WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *old_list = panel->list;
|
1998-03-07 06:02:01 +03:00
|
|
|
|
|
|
|
if (!old_list)
|
|
|
|
return;
|
1998-12-02 00:56:54 +03:00
|
|
|
|
1998-03-07 03:05:06 +03:00
|
|
|
panel->list = panel_create_file_list (panel);
|
|
|
|
gtk_widget_destroy (old_list);
|
1999-01-04 10:29:48 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (panel->panel_listbox), panel->list);
|
|
|
|
gtk_widget_show_all (panel->list);
|
1998-03-07 03:05:06 +03:00
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
static GtkWidget *
|
1998-03-24 08:25:56 +03:00
|
|
|
panel_create_cwd (Dlg_head *h, WPanel *panel, void **entry)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1998-03-23 20:49:04 +03:00
|
|
|
WInput *in;
|
|
|
|
|
|
|
|
in = input_new (0, 0, 0, 10, "", "cwd");
|
|
|
|
add_widget (h, in);
|
1998-03-15 02:20:51 +03:00
|
|
|
|
1998-03-23 20:49:04 +03:00
|
|
|
/* Force the creation of the gtk widget */
|
|
|
|
send_message_to (h, (Widget *) in, WIDGET_INIT, 0);
|
|
|
|
|
1998-03-24 08:25:56 +03:00
|
|
|
*entry = in;
|
1998-12-11 09:48:21 +03:00
|
|
|
/* FIXME: for now, we set the usize. Ultimately, toolbar
|
1999-01-03 01:06:00 +03:00
|
|
|
* will let you expand it, we hope.
|
1998-12-11 09:48:21 +03:00
|
|
|
*/
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_widget_set_usize (GTK_WIDGET (in->widget.wdata), 296, -1);
|
1998-03-23 20:49:04 +03:00
|
|
|
return GTK_WIDGET (in->widget.wdata);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
1998-03-20 05:54:06 +03:00
|
|
|
void
|
|
|
|
display_mini_info (WPanel *panel)
|
|
|
|
{
|
1999-01-07 08:19:09 +03:00
|
|
|
GnomeAppBar *bar = GNOME_APPBAR (panel->ministatus);
|
1998-03-24 08:25:56 +03:00
|
|
|
|
1998-11-30 19:59:23 +03:00
|
|
|
if (panel->searching) {
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
buf = g_strdup_printf (_("Search: %s"), panel->search_buffer);
|
1999-01-07 08:19:09 +03:00
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, buf);
|
1998-11-30 19:59:23 +03:00
|
|
|
g_free (buf);
|
1998-03-20 05:54:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panel->marked){
|
1998-11-30 19:59:23 +03:00
|
|
|
char *buf;
|
|
|
|
|
|
|
|
buf = g_strdup_printf ((panel->marked == 1) ? _("%s bytes in %d file") : _("%s bytes in %d files"),
|
|
|
|
size_trunc_sep (panel->total),
|
|
|
|
panel->marked);
|
1999-01-07 08:19:09 +03:00
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, buf);
|
1998-11-30 19:59:23 +03:00
|
|
|
g_free (buf);
|
1998-03-24 08:25:56 +03:00
|
|
|
return;
|
1998-03-20 05:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (S_ISLNK (panel->dir.list [panel->selected].buf.st_mode)){
|
|
|
|
char *link, link_target [MC_MAXPATHLEN];
|
|
|
|
int len;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-20 05:54:06 +03:00
|
|
|
link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
|
|
|
len = mc_readlink (link, link_target, MC_MAXPATHLEN);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (link);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-20 05:54:06 +03:00
|
|
|
if (len > 0){
|
|
|
|
link_target [len] = 0;
|
1998-12-11 09:48:21 +03:00
|
|
|
/* FIXME: Links should be handled differently */
|
1999-01-27 05:55:43 +03:00
|
|
|
/* str = g_strconcat ("-> ", link_target, NULL); */
|
1999-01-07 08:19:09 +03:00
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, " ");
|
1999-01-27 04:14:57 +03:00
|
|
|
/* g_free (str); */
|
1999-01-07 08:19:09 +03:00
|
|
|
} else {
|
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, _("<readlink failed>"));
|
|
|
|
}
|
1998-03-20 05:54:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-12-30 03:32:41 +03:00
|
|
|
if (panel->estimated_total > 8){
|
1998-03-20 05:54:06 +03:00
|
|
|
int len = panel->estimated_total;
|
|
|
|
char *buffer;
|
|
|
|
|
1999-01-27 04:14:57 +03:00
|
|
|
buffer = g_malloc (len + 2);
|
1998-03-20 05:54:06 +03:00
|
|
|
format_file (buffer, panel, panel->selected, panel->estimated_total-2, 0, 1);
|
|
|
|
buffer [len] = 0;
|
1999-01-07 08:19:09 +03:00
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, buffer);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (buffer);
|
1998-03-20 05:54:06 +03:00
|
|
|
}
|
1998-05-08 06:25:00 +04:00
|
|
|
if (panel->list_type == list_icons){
|
|
|
|
if (panel->marked == 0){
|
1999-01-07 08:19:09 +03:00
|
|
|
gnome_appbar_pop (bar);
|
|
|
|
gnome_appbar_push (bar, " ");
|
1998-05-08 06:25:00 +04:00
|
|
|
}
|
|
|
|
}
|
1998-03-20 05:54:06 +03:00
|
|
|
}
|
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
/* Signal handler for DTree's "directory_changed" signal */
|
|
|
|
static void
|
|
|
|
panel_chdir (GtkDTree *dtree, char *path, WPanel *panel)
|
|
|
|
{
|
1999-09-22 21:18:07 +04:00
|
|
|
if (panel->dragging)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (do_panel_cd (panel, path, cd_exact))
|
|
|
|
return; /* success */
|
|
|
|
|
|
|
|
if (panel->list_type == list_icons)
|
|
|
|
gnome_icon_list_clear (ILIST_FROM_SW (panel->icons));
|
|
|
|
else
|
|
|
|
gtk_clist_clear (CLIST_FROM_SW (panel->list));
|
|
|
|
|
|
|
|
strncpy (panel->cwd, path, sizeof (panel->cwd));
|
|
|
|
show_dir (panel);
|
1998-12-02 08:18:20 +03:00
|
|
|
}
|
|
|
|
|
1999-02-09 23:10:10 +03:00
|
|
|
static void
|
|
|
|
set_cursor (WPanel *panel, GdkCursorType type)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
cursor = gdk_cursor_new (type);
|
|
|
|
gdk_window_set_cursor (GTK_WIDGET (panel->xwindow)->window, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
1999-03-11 22:23:23 +03:00
|
|
|
gdk_flush ();
|
1999-02-09 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_tree_scan_begin (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
set_cursor (data, GDK_WATCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_tree_scan_end (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
set_cursor (data, GDK_TOP_LEFT_ARROW);
|
|
|
|
}
|
|
|
|
|
1999-09-14 00:34:53 +04:00
|
|
|
/* Handler for the possibly_ungrab signal of the dtree widget */
|
|
|
|
static void
|
|
|
|
panel_tree_possibly_ungrab (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
panel = data;
|
|
|
|
|
|
|
|
/* The stupid clist button press handler grabs the mouse. We will get
|
|
|
|
* called when the user presses the mouse on the tree, so we ungrab it.
|
|
|
|
* Also, we have to make sure we don't knock away a DnD grab.
|
|
|
|
*/
|
|
|
|
if (!panel->drag_tree_dragging_over)
|
|
|
|
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Callback for the drag_begin signal of the tree */
|
|
|
|
static void
|
|
|
|
panel_tree_drag_begin (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDTree *dtree;
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
dtree = GTK_DTREE (widget);
|
|
|
|
panel = data;
|
|
|
|
|
|
|
|
panel->dragging = TRUE;
|
|
|
|
dtree->drag_dir = g_strdup (dtree->current_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback for the drag_end signal of the tree */
|
|
|
|
static void
|
|
|
|
panel_tree_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDTree *dtree;
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
dtree = GTK_DTREE (widget);
|
|
|
|
panel = data;
|
|
|
|
|
|
|
|
panel->dragging = FALSE;
|
|
|
|
g_free (dtree->drag_dir);
|
|
|
|
dtree->drag_dir = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback for the drag_data_get signal of the tree */
|
|
|
|
static void
|
|
|
|
panel_tree_drag_data_get (GtkWidget *widget, GdkDragContext *context,
|
|
|
|
GtkSelectionData *selection_data, guint info, guint time, gpointer data)
|
|
|
|
{
|
|
|
|
GtkDTree *dtree;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
dtree = GTK_DTREE (widget);
|
|
|
|
|
|
|
|
switch (info){
|
|
|
|
case TARGET_URI_LIST:
|
|
|
|
case TARGET_TEXT_PLAIN:
|
|
|
|
str = g_strconcat ("file:", dtree->drag_dir, NULL);
|
|
|
|
gtk_selection_data_set (selection_data, selection_data->target, 8,
|
|
|
|
str, strlen (str) + 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* FIXME: handle TARGET_URL */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-02 09:51:40 +03:00
|
|
|
/**
|
|
|
|
* tree_drag_open_directory:
|
|
|
|
*
|
|
|
|
* This routine is invoked in a delayed fashion if the user
|
|
|
|
* keeps the drag cursor still over the widget.
|
|
|
|
*/
|
|
|
|
static gint
|
|
|
|
tree_drag_open_directory (gpointer data)
|
|
|
|
{
|
1999-04-16 03:19:36 +04:00
|
|
|
WPanel *panel;
|
|
|
|
GtkDTree *dtree;
|
1998-12-02 09:51:40 +03:00
|
|
|
GtkCTreeNode *node;
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
panel = data;
|
|
|
|
dtree = GTK_DTREE (panel->tree);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
node = gtk_ctree_node_nth (GTK_CTREE (panel->tree), panel->drag_tree_row);
|
|
|
|
g_assert (node != NULL);
|
1998-12-02 09:51:40 +03:00
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
if (!GTK_CTREE_ROW (node)->expanded) {
|
1999-08-13 23:42:32 +04:00
|
|
|
#if 0
|
|
|
|
/* FIXME: Disabled until fully debugged. Should also be configurable. */
|
1998-12-13 00:16:01 +03:00
|
|
|
dtree->auto_expanded_nodes = g_list_append (dtree->auto_expanded_nodes, node);
|
1999-08-13 23:42:32 +04:00
|
|
|
#endif
|
1999-04-16 22:25:00 +04:00
|
|
|
gtk_ctree_expand (GTK_CTREE (panel->tree), node);
|
|
|
|
}
|
1998-12-04 00:56:11 +03:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
/* Handles automatic collapsing of the tree nodes when doing drag and drop */
|
1998-12-13 00:16:01 +03:00
|
|
|
static void
|
|
|
|
panel_tree_check_auto_expand (WPanel *panel, GtkCTreeNode *current)
|
|
|
|
{
|
1999-04-16 22:25:00 +04:00
|
|
|
GtkDTree *dtree;
|
|
|
|
GtkCTree *ctree;
|
|
|
|
GtkCList *clist;
|
|
|
|
GList *free_list;
|
|
|
|
GList *tmp_list;
|
1998-12-13 00:16:01 +03:00
|
|
|
gint row, old_y, new_y;
|
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
dtree = GTK_DTREE (panel->tree);
|
|
|
|
ctree = GTK_CTREE (panel->tree);
|
|
|
|
clist = GTK_CLIST (panel->tree);
|
|
|
|
tmp_list = dtree->auto_expanded_nodes;
|
1998-12-13 00:16:01 +03:00
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
if (current)
|
|
|
|
for (; tmp_list; tmp_list = tmp_list->next)
|
|
|
|
if (!gtk_dtree_is_ancestor (dtree, tmp_list->data, current))
|
1998-12-13 00:16:01 +03:00
|
|
|
break;
|
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
/* Collapse the rows as necessary. If possible, try to do so that the
|
|
|
|
* "current" stays the same place on the screen.
|
1998-12-13 00:16:01 +03:00
|
|
|
*/
|
|
|
|
if (tmp_list) {
|
|
|
|
if (current) {
|
1999-04-16 22:25:00 +04:00
|
|
|
row = g_list_position (clist->row_list, (GList *) current);
|
1998-12-13 00:16:01 +03:00
|
|
|
old_y = row * clist->row_height - clist->vadjustment->value;
|
|
|
|
}
|
1999-04-16 22:25:00 +04:00
|
|
|
|
1998-12-13 00:16:01 +03:00
|
|
|
free_list = tmp_list;
|
1999-04-16 22:25:00 +04:00
|
|
|
|
|
|
|
for (; tmp_list; tmp_list = tmp_list->next)
|
1998-12-13 00:16:01 +03:00
|
|
|
gtk_ctree_collapse (GTK_CTREE (panel->tree), tmp_list->data);
|
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
/* We have to calculate the row position again because rows may
|
|
|
|
* have shifted during the collapse.
|
|
|
|
*/
|
1998-12-13 00:16:01 +03:00
|
|
|
if (current) {
|
1999-04-16 22:25:00 +04:00
|
|
|
row = g_list_position (clist->row_list, (GList *) current);
|
1998-12-13 00:16:01 +03:00
|
|
|
new_y = row * clist->row_height - clist->vadjustment->value;
|
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
if (new_y != old_y)
|
1998-12-13 00:16:01 +03:00
|
|
|
gtk_adjustment_set_value (clist->vadjustment,
|
|
|
|
clist->vadjustment->value + new_y - old_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (free_list->prev)
|
|
|
|
free_list->prev->next = NULL;
|
|
|
|
else
|
|
|
|
dtree->auto_expanded_nodes = NULL;
|
|
|
|
|
|
|
|
free_list->prev = NULL;
|
|
|
|
g_list_free (free_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-04 00:56:11 +03:00
|
|
|
/**
|
1999-04-16 03:19:36 +04:00
|
|
|
* panel_tree_scrolling_is_desirable:
|
1998-12-04 00:56:11 +03:00
|
|
|
*
|
1999-04-16 03:19:36 +04:00
|
|
|
* If the cursor is in a position close to either edge (top or bottom)
|
|
|
|
* and there is possible to scroll the window, this routine returns
|
|
|
|
* true.
|
1998-12-04 00:56:11 +03:00
|
|
|
*/
|
|
|
|
static gboolean
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_tree_scrolling_is_desirable (WPanel *panel, int x, int y)
|
|
|
|
{
|
|
|
|
GtkDTree *dtree = GTK_DTREE (panel->tree);
|
|
|
|
GtkAdjustment *va;
|
|
|
|
|
|
|
|
va = scrolled_window_get_vadjustment (panel->tree_scrolled_window);
|
|
|
|
|
|
|
|
if (y < 10) {
|
|
|
|
if (va->value > va->lower)
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
if (y > (GTK_WIDGET (dtree)->allocation.height - 10)){
|
|
|
|
if (va->value < va->upper - va->page_size)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Timer callback to scroll the tree */
|
|
|
|
static gboolean
|
1998-12-04 00:56:11 +03:00
|
|
|
panel_tree_scroll (gpointer data)
|
|
|
|
{
|
|
|
|
WPanel *panel = data;
|
|
|
|
GtkAdjustment *va;
|
1999-01-20 13:40:21 +03:00
|
|
|
double v;
|
1998-12-04 00:56:11 +03:00
|
|
|
|
|
|
|
va = scrolled_window_get_vadjustment (panel->tree_scrolled_window);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-01-20 13:40:21 +03:00
|
|
|
if (panel->drag_motion_y < 10) {
|
|
|
|
v = va->value - va->step_increment;
|
|
|
|
if (v < va->lower)
|
|
|
|
v = va->lower;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
|
|
|
} else {
|
|
|
|
v = va->value + va->step_increment;
|
|
|
|
if (v > va->upper - va->page_size)
|
|
|
|
v = va->upper - va->page_size;
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (va, v);
|
1998-12-04 02:50:05 +03:00
|
|
|
}
|
1999-01-20 13:40:21 +03:00
|
|
|
|
1998-12-06 00:54:25 +03:00
|
|
|
return TRUE;
|
1998-12-04 00:56:11 +03:00
|
|
|
}
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Callback for the drag_motion signal of the tree. We set up a timer to
|
|
|
|
* automatically open nodes if the user hovers over them.
|
1998-12-02 09:51:40 +03:00
|
|
|
*/
|
|
|
|
static gboolean
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time,
|
|
|
|
gpointer data)
|
1998-12-02 09:51:40 +03:00
|
|
|
{
|
1999-04-16 03:19:36 +04:00
|
|
|
GtkDTree *dtree;
|
|
|
|
WPanel *panel;
|
|
|
|
int on_row, row, col;
|
1999-04-16 22:25:00 +04:00
|
|
|
GtkCTreeNode *node;
|
1999-04-16 03:19:36 +04:00
|
|
|
GdkDragAction action;
|
|
|
|
GtkWidget *source_widget;
|
|
|
|
char *row_path;
|
|
|
|
int on_drag_row;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
dtree = GTK_DTREE (widget);
|
|
|
|
panel = data;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-09-14 00:34:53 +04:00
|
|
|
panel->drag_tree_dragging_over = TRUE;
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_setup_drag_scroll (panel, x, y,
|
|
|
|
panel_tree_scrolling_is_desirable,
|
|
|
|
panel_tree_scroll);
|
1998-12-02 09:51:40 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
on_row = gtk_clist_get_selection_info (GTK_CLIST (widget), x, y, &row, &col);
|
1998-12-02 09:51:40 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Remove the auto-expansion timeout if we are on the blank area of the
|
|
|
|
* tree or on a row different from the previous one.
|
|
|
|
*/
|
|
|
|
if ((!on_row || row != panel->drag_tree_row) && panel->drag_tree_timeout_id != 0) {
|
|
|
|
gtk_timeout_remove (panel->drag_tree_timeout_id);
|
|
|
|
panel->drag_tree_timeout_id = 0;
|
1998-12-04 02:50:05 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
if (panel->drag_tree_fe) {
|
|
|
|
file_entry_free (panel->drag_tree_fe);
|
|
|
|
panel->drag_tree_fe = NULL;
|
|
|
|
}
|
1998-12-02 09:51:40 +03:00
|
|
|
}
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
action = 0;
|
1998-12-05 00:32:19 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
if (on_row) {
|
1999-04-16 22:25:00 +04:00
|
|
|
node = gtk_ctree_node_nth (GTK_CTREE (dtree), row);
|
1999-09-14 03:27:18 +04:00
|
|
|
row_path = gtk_dtree_get_row_path (dtree, node);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
if (row != panel->drag_tree_row) {
|
|
|
|
/* Highlight the row by selecting it */
|
1999-04-16 22:25:00 +04:00
|
|
|
|
|
|
|
panel_tree_check_auto_expand (panel, node);
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
dtree->internal = TRUE;
|
|
|
|
gtk_clist_select_row (GTK_CLIST (widget), row, 0);
|
|
|
|
dtree->internal = FALSE;
|
1998-12-05 00:32:19 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Create the file entry to validate drops */
|
1998-12-05 00:32:19 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
panel->drag_tree_fe = file_entry_from_file (row_path);
|
|
|
|
|
|
|
|
/* Install the timeout handler for auto-expansion */
|
|
|
|
|
|
|
|
panel->drag_tree_timeout_id = gtk_timeout_add (TREE_OPEN_TIMEOUT,
|
|
|
|
tree_drag_open_directory,
|
|
|
|
panel);
|
|
|
|
panel->drag_tree_row = row;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate the action */
|
|
|
|
|
|
|
|
gdnd_find_panel_by_drag_context (context, &source_widget);
|
|
|
|
|
|
|
|
/* If this tree is the drag source, see if the user is trying to
|
|
|
|
* drop on the row being dragged. Otherwise, consider all rows
|
|
|
|
* as not selected.
|
|
|
|
*/
|
|
|
|
if (source_widget == widget) {
|
|
|
|
g_assert (dtree->drag_dir != NULL);
|
|
|
|
on_drag_row = strcmp (row_path, dtree->drag_dir) == 0;
|
|
|
|
} else
|
|
|
|
on_drag_row = FALSE;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
action = gdnd_validate_action (context,
|
|
|
|
FALSE,
|
|
|
|
source_widget != NULL,
|
|
|
|
source_widget == widget,
|
1999-08-27 09:01:08 +04:00
|
|
|
row_path,
|
1999-04-16 03:19:36 +04:00
|
|
|
panel->drag_tree_fe,
|
|
|
|
on_drag_row);
|
|
|
|
|
|
|
|
g_free (row_path);
|
1999-04-16 22:25:00 +04:00
|
|
|
} else {
|
1999-04-16 03:19:36 +04:00
|
|
|
panel->drag_tree_row = -1;
|
1999-04-16 22:25:00 +04:00
|
|
|
panel_tree_check_auto_expand (panel, NULL);
|
|
|
|
}
|
1999-04-16 03:19:36 +04:00
|
|
|
|
|
|
|
gdk_drag_status (context, action, time);
|
|
|
|
return TRUE;
|
1998-12-05 00:32:19 +03:00
|
|
|
}
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Callback for the drag_leave signal of the tree. We deactivate the timeout for
|
|
|
|
* automatic branch expansion.
|
1998-12-05 00:32:19 +03:00
|
|
|
*/
|
|
|
|
static void
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
|
1998-12-05 00:32:19 +03:00
|
|
|
{
|
1999-04-16 03:19:36 +04:00
|
|
|
WPanel *panel;
|
1998-12-05 00:32:19 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
panel = data;
|
|
|
|
|
1999-09-14 00:34:53 +04:00
|
|
|
panel->drag_tree_dragging_over = FALSE;
|
1999-04-16 03:19:36 +04:00
|
|
|
panel_cancel_drag_scroll (panel);
|
|
|
|
|
|
|
|
if (panel->drag_tree_timeout_id != 0) {
|
|
|
|
gtk_timeout_remove (panel->drag_tree_timeout_id);
|
|
|
|
panel->drag_tree_timeout_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panel->drag_tree_fe) {
|
|
|
|
file_entry_free (panel->drag_tree_fe);
|
|
|
|
panel->drag_tree_fe = NULL;
|
1998-12-05 00:32:19 +03:00
|
|
|
}
|
1999-04-16 03:19:36 +04:00
|
|
|
|
1999-04-16 22:25:00 +04:00
|
|
|
if (panel->drag_tree_row != -1)
|
|
|
|
panel_tree_check_auto_expand (panel, NULL);
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
panel->drag_tree_row = -1;
|
1998-12-05 00:32:19 +03:00
|
|
|
}
|
|
|
|
|
1999-05-28 09:41:18 +04:00
|
|
|
#if CONTEXT_MENU_ON_TREE
|
|
|
|
static void
|
|
|
|
tree_do_op (GtkWidget *tree, WPanel *panel, int operation)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_copy_cmd (GtkWidget *tree, WPanel *panel)
|
|
|
|
{
|
|
|
|
tree_do_op (tree, panel, OP_COPY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_del_cmd (GtkWidget *tree, WPanel *panel)
|
|
|
|
{
|
|
|
|
tree_do_op (tree, panel, OP_DELETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tree_ren_cmd (GtkWidget *tree, WPanel *panel)
|
|
|
|
{
|
|
|
|
tree_do_op (tree, panel, OP_MOVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GnomeUIInfo tree_popup_items[] = {
|
|
|
|
GNOMEUIINFO_ITEM_STOCK(N_("_Copy..."), N_("Copy directory"), tree_copy_cmd, GNOME_STOCK_PIXMAP_COPY),
|
|
|
|
GNOMEUIINFO_ITEM_STOCK(N_("_Delete..."), N_("Delete directory"), tree_del_cmd, GNOME_STOCK_PIXMAP_TRASH),
|
|
|
|
GNOMEUIINFO_ITEM_NONE(N_("_Move..."), N_("Rename or move directory"), tree_ren_cmd),
|
|
|
|
|
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
panel_tree_button_press (GtkWidget *widget, GdkEventButton *event, WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *popup;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-05-28 09:41:18 +04:00
|
|
|
if (event->type != GDK_BUTTON_PRESS)
|
|
|
|
return;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-05-28 09:41:18 +04:00
|
|
|
if (event->button != 3)
|
|
|
|
return;
|
|
|
|
|
|
|
|
popup = gnome_popup_menu_new (tree_popup_items);
|
|
|
|
gnome_popup_menu_do_popup_modal (popup, NULL, NULL, event, panel);
|
|
|
|
gtk_widget_destroy (popup);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-12 02:10:15 +03:00
|
|
|
/**
|
1998-12-02 08:18:20 +03:00
|
|
|
* panel_create_tree_view:
|
|
|
|
*
|
|
|
|
* Create and initializes the GtkDTree widget for being used in the
|
|
|
|
* Panel
|
|
|
|
*/
|
|
|
|
static GtkWidget *
|
|
|
|
panel_create_tree_view (WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *tree;
|
|
|
|
|
|
|
|
tree = gtk_dtree_new ();
|
2000-06-20 23:42:15 +04:00
|
|
|
/*gtk_ctree_set_line_style (GTK_CTREE (tree), GTK_CTREE_LINES_DOTTED);*/
|
|
|
|
/*gtk_ctree_set_expander_style (GTK_CTREE (tree), GTK_CTREE_EXPANDER_SQUARE);*/
|
1998-12-11 05:47:09 +03:00
|
|
|
gtk_ctree_set_indent (GTK_CTREE (tree), 10);
|
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* DTree signals */
|
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "directory_changed",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_chdir), panel);
|
1999-02-09 23:10:10 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "scan_begin",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_tree_scan_begin), panel);
|
1999-02-09 23:10:10 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "scan_end",
|
1999-09-14 00:34:53 +04:00
|
|
|
GTK_SIGNAL_FUNC (panel_tree_scan_end), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "possibly_ungrab",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_possibly_ungrab), panel);
|
1998-12-02 08:18:20 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Set up drag source */
|
1998-12-02 09:51:40 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
gtk_drag_source_set (GTK_WIDGET (tree), GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
|
|
drag_types, ELEMENTS (drag_types),
|
|
|
|
(GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_COPY
|
|
|
|
| GDK_ACTION_ASK | GDK_ACTION_DEFAULT));
|
1998-12-02 09:51:40 +03:00
|
|
|
|
1998-12-05 00:32:19 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_begin",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_begin), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_end",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_end), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_data_get",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_data_get), panel);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-04-16 03:19:36 +04:00
|
|
|
/* Set up drag destination */
|
|
|
|
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (tree),
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
drop_types, ELEMENTS (drop_types),
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-12-02 09:51:40 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_motion",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_motion), panel);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_leave",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_leave), panel);
|
1999-04-16 03:19:36 +04:00
|
|
|
gtk_signal_connect (GTK_OBJECT (tree), "drag_data_received",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_drag_data_received), panel);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-05-28 09:41:18 +04:00
|
|
|
#ifdef CONTEXT_MENU_ON_TREE
|
|
|
|
/* Context sensitive menu */
|
|
|
|
gtk_signal_connect_after (GTK_OBJECT (tree), "button_press_event",
|
|
|
|
GTK_SIGNAL_FUNC (panel_tree_button_press), panel);
|
|
|
|
gtk_clist_set_button_actions (GTK_CLIST (tree), 2, GTK_BUTTON_SELECTS);
|
|
|
|
#endif
|
1998-12-02 08:18:20 +03:00
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
|
1998-12-04 00:56:11 +03:00
|
|
|
/*
|
|
|
|
* create_and_setup_pane:
|
|
|
|
*
|
|
|
|
* Creates the horizontal GtkPaned widget that holds the tree
|
|
|
|
* and the listing/iconing displays
|
|
|
|
*/
|
|
|
|
static GtkWidget *
|
|
|
|
create_and_setup_pane (WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *pane;
|
|
|
|
GtkWidget *tree = panel->tree;
|
|
|
|
GdkFont *tree_font = tree->style->font;
|
1999-01-17 07:17:20 +03:00
|
|
|
int size;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-12-04 00:56:11 +03:00
|
|
|
pane = gtk_hpaned_new ();
|
|
|
|
|
1999-01-17 07:17:20 +03:00
|
|
|
if (tree_panel_visible == -1)
|
|
|
|
size = 20 * gdk_string_width (tree_font, "W");
|
|
|
|
else {
|
|
|
|
if (tree_panel_visible)
|
|
|
|
size = tree_panel_visible;
|
|
|
|
else
|
|
|
|
size = 0;
|
|
|
|
}
|
1999-04-07 05:49:22 +04:00
|
|
|
#if 0
|
|
|
|
gtk_paned_set_position (GTK_PANED (pane), size);
|
|
|
|
#else
|
1998-12-04 00:56:11 +03:00
|
|
|
/*
|
|
|
|
* Hack: set the default startup size for the pane without
|
|
|
|
* using _set_usize which would set the minimal size
|
|
|
|
*/
|
1999-01-17 07:17:20 +03:00
|
|
|
GTK_PANED (pane)->child1_size = size;
|
1998-12-04 00:56:11 +03:00
|
|
|
GTK_PANED (pane)->position_set = TRUE;
|
1999-04-07 05:49:22 +04:00
|
|
|
#endif
|
1998-12-04 00:56:11 +03:00
|
|
|
gtk_widget_show (pane);
|
|
|
|
|
|
|
|
return pane;
|
|
|
|
}
|
|
|
|
|
1998-04-10 01:59:32 +04:00
|
|
|
static void
|
1998-04-09 08:58:24 +04:00
|
|
|
panel_back (GtkWidget *button, WPanel *panel)
|
|
|
|
{
|
|
|
|
directory_history_prev (panel);
|
|
|
|
}
|
|
|
|
|
1998-04-10 01:59:32 +04:00
|
|
|
static void
|
1998-04-09 08:58:24 +04:00
|
|
|
panel_fwd (GtkWidget *button, WPanel *panel)
|
|
|
|
{
|
|
|
|
directory_history_next (panel);
|
|
|
|
}
|
|
|
|
|
1998-04-10 01:59:32 +04:00
|
|
|
static void
|
|
|
|
panel_up (GtkWidget *button, WPanel *panel)
|
|
|
|
{
|
|
|
|
do_panel_cd (panel, "..", cd_exact);
|
|
|
|
}
|
|
|
|
|
1999-02-15 23:34:07 +03:00
|
|
|
static void
|
|
|
|
rescan_panel (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
reread_cmd ();
|
|
|
|
}
|
|
|
|
|
1999-01-19 00:56:59 +03:00
|
|
|
static void
|
|
|
|
go_home (GtkWidget *widget, WPanel *panel)
|
1999-01-03 01:06:00 +03:00
|
|
|
{
|
1999-01-19 00:56:59 +03:00
|
|
|
do_panel_cd (panel, "~", cd_exact);
|
1998-05-12 08:26:21 +04:00
|
|
|
}
|
1999-02-15 23:34:07 +03:00
|
|
|
|
|
|
|
/* The toolbar */
|
|
|
|
|
1999-01-19 00:25:55 +03:00
|
|
|
static GnomeUIInfo toolbar[] = {
|
|
|
|
GNOMEUIINFO_ITEM_STOCK (N_("Back"), N_("Go to the previously visited directory"),
|
|
|
|
panel_back, GNOME_STOCK_PIXMAP_BACK),
|
|
|
|
GNOMEUIINFO_ITEM_STOCK (N_("Up"), N_("Go up a level in the directory heirarchy"),
|
|
|
|
panel_up, GNOME_STOCK_PIXMAP_UP),
|
|
|
|
GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Go to the next directory"),
|
|
|
|
panel_fwd, GNOME_STOCK_PIXMAP_FORWARD),
|
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-02-15 23:34:07 +03:00
|
|
|
GNOMEUIINFO_ITEM_STOCK (N_("Rescan"), N_("Rescan the current directory"),
|
|
|
|
rescan_panel, GNOME_STOCK_PIXMAP_REFRESH),
|
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-01-19 00:25:55 +03:00
|
|
|
GNOMEUIINFO_ITEM_STOCK (N_("Home"), N_("Go to your home directory"),
|
1999-01-19 00:56:59 +03:00
|
|
|
go_home, GNOME_STOCK_PIXMAP_HOME),
|
1999-01-19 00:25:55 +03:00
|
|
|
GNOMEUIINFO_SEPARATOR,
|
1999-03-12 01:17:36 +03:00
|
|
|
GNOMEUIINFO_RADIOLIST(panel_view_toolbar_uiinfo),
|
1999-01-19 00:25:55 +03:00
|
|
|
GNOMEUIINFO_END
|
|
|
|
};
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-19 00:25:55 +03:00
|
|
|
static void
|
1999-08-11 01:52:06 +04:00
|
|
|
do_ui_signal_connect (GnomeUIInfo *uiinfo, gchar *signal_name,
|
1999-01-19 00:25:55 +03:00
|
|
|
GnomeUIBuilderData *uibdata)
|
|
|
|
{
|
|
|
|
if (uiinfo->moreinfo)
|
1999-08-11 01:52:06 +04:00
|
|
|
gtk_signal_connect (GTK_OBJECT (uiinfo->widget),
|
|
|
|
signal_name, uiinfo->moreinfo, uibdata->data ?
|
1999-01-19 00:25:55 +03:00
|
|
|
uibdata->data : uiinfo->user_data);
|
|
|
|
}
|
|
|
|
|
1999-01-17 07:17:20 +03:00
|
|
|
static void
|
|
|
|
tree_size_allocate (GtkWidget *widget, GtkAllocation *allocation, WPanel *panel)
|
|
|
|
{
|
|
|
|
if (allocation->width <= 0){
|
|
|
|
tree_panel_visible = 0;
|
|
|
|
} else {
|
|
|
|
tree_panel_visible = allocation->width;
|
|
|
|
}
|
|
|
|
save_setup ();
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
|
|
|
{
|
1999-07-02 03:15:08 +04:00
|
|
|
GtkWidget *status_line, *vbox, *ministatus_box;
|
1999-01-20 05:16:09 +03:00
|
|
|
GtkWidget *cwd;
|
1999-02-11 00:03:04 +03:00
|
|
|
GtkWidget *dock;
|
1999-01-19 00:25:55 +03:00
|
|
|
GnomeUIBuilderData uibdata;
|
|
|
|
|
1998-04-16 02:38:36 +04:00
|
|
|
panel->xwindow = gtk_widget_get_toplevel (GTK_WIDGET (panel->widget.wdata));
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-05 07:53:47 +03:00
|
|
|
panel->table = gtk_table_new (2, 1, 0);
|
1998-04-11 06:53:35 +04:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
|
|
|
* Tree View
|
|
|
|
*/
|
1998-12-04 00:56:11 +03:00
|
|
|
panel->tree_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
1998-11-29 11:22:20 +03:00
|
|
|
gtk_scrolled_window_set_policy (
|
1998-12-04 00:56:11 +03:00
|
|
|
GTK_SCROLLED_WINDOW (panel->tree_scrolled_window),
|
1998-11-29 11:22:20 +03:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
1998-12-02 08:18:20 +03:00
|
|
|
panel->tree = panel_create_tree_view (panel);
|
1998-12-04 00:56:11 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (panel->tree_scrolled_window), panel->tree);
|
|
|
|
gtk_widget_show_all (panel->tree_scrolled_window);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
|
|
|
* Icon and Listing display
|
|
|
|
*/
|
1998-12-30 03:32:41 +03:00
|
|
|
panel->notebook = gtk_notebook_new ();
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (panel->notebook), FALSE);
|
|
|
|
gtk_widget_show (panel->notebook);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
panel->icons = panel_create_icon_display (panel);
|
1999-01-04 10:29:48 +03:00
|
|
|
gtk_widget_show (panel->icons);
|
1999-02-11 15:50:25 +03:00
|
|
|
|
1999-09-21 00:03:58 +04:00
|
|
|
memcpy (panel->column_width, default_column_width, sizeof (default_column_width));
|
1998-05-08 06:25:00 +04:00
|
|
|
panel->list = panel_create_file_list (panel);
|
|
|
|
gtk_widget_ref (panel->icons);
|
|
|
|
gtk_widget_ref (panel->list);
|
|
|
|
|
1999-01-04 10:29:48 +03:00
|
|
|
panel->panel_listbox = gtk_event_box_new ();
|
|
|
|
gtk_widget_show (panel->panel_listbox);
|
|
|
|
gtk_container_add (GTK_CONTAINER (panel->panel_listbox), panel->list);
|
1999-02-11 02:56:59 +03:00
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), panel->icons, NULL);
|
1999-01-04 10:29:48 +03:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), panel->panel_listbox, NULL);
|
1999-02-11 15:50:25 +03:00
|
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (panel->notebook),
|
|
|
|
panel->list_type == list_icons ? 0 : 1);
|
|
|
|
|
1999-02-11 00:03:04 +03:00
|
|
|
gtk_widget_show (panel->icons);
|
1998-12-30 03:32:41 +03:00
|
|
|
gtk_widget_show (panel->list);
|
|
|
|
gtk_widget_show (panel->notebook);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
|
|
|
* Pane
|
|
|
|
*/
|
1998-12-04 00:56:11 +03:00
|
|
|
panel->pane = create_and_setup_pane (panel);
|
|
|
|
gtk_paned_add1 (GTK_PANED (panel->pane), panel->tree_scrolled_window);
|
1999-01-17 07:17:20 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (panel->tree_scrolled_window), "size_allocate",
|
|
|
|
GTK_SIGNAL_FUNC (tree_size_allocate), panel);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
|
|
|
* Current Working directory
|
|
|
|
*/
|
1999-09-21 12:09:54 +04:00
|
|
|
|
1998-03-23 20:49:04 +03:00
|
|
|
cwd = panel_create_cwd (h, panel, &panel->current_dir);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
1999-01-19 00:25:55 +03:00
|
|
|
* We go through a lot of pain, wrestling with gnome_app* and gmc's @#$&*#$ internal structure and
|
|
|
|
* make the #@$*&@#$ toolbars here...
|
1998-11-29 10:50:44 +03:00
|
|
|
*/
|
1998-12-11 09:48:21 +03:00
|
|
|
|
1999-01-19 00:25:55 +03:00
|
|
|
status_line = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
|
|
|
|
uibdata.connect_func = do_ui_signal_connect;
|
|
|
|
uibdata.data = panel;
|
|
|
|
uibdata.is_interp = FALSE;
|
|
|
|
uibdata.relay_func = NULL;
|
|
|
|
uibdata.destroy_func = NULL;
|
|
|
|
|
|
|
|
gnome_app_fill_toolbar_custom (GTK_TOOLBAR (status_line), toolbar, &uibdata, NULL);
|
|
|
|
gnome_app_add_toolbar (GNOME_APP (panel->xwindow),
|
|
|
|
GTK_TOOLBAR (status_line),
|
|
|
|
"gmc-toolbar0",
|
|
|
|
GNOME_DOCK_ITEM_BEH_EXCLUSIVE,
|
|
|
|
GNOME_DOCK_TOP,
|
|
|
|
2, 0, 0);
|
1999-04-05 09:39:26 +04:00
|
|
|
panel->view_toolbar_items = copy_uiinfo_widgets (panel_view_toolbar_uiinfo);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-19 00:25:55 +03:00
|
|
|
panel->back_b = toolbar[0].widget;
|
|
|
|
panel->up_b = toolbar[1].widget;
|
|
|
|
panel->fwd_b = toolbar[2].widget;
|
|
|
|
panel_update_marks (panel);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
|
|
|
/* Set the list type by poking a toolbar item. Yes, this is hackish.
|
|
|
|
* We fall back to icon view if a certain listing type is not supported.
|
|
|
|
* Be sure to keep this in sync with the uiinfo arrays in glayout.c.
|
|
|
|
*/
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1999-01-20 05:16:09 +03:00
|
|
|
if (panel->list_type == list_brief)
|
1999-03-12 01:17:36 +03:00
|
|
|
gtk_toggle_button_set_active (
|
|
|
|
GTK_TOGGLE_BUTTON (panel_view_toolbar_uiinfo[1].widget), TRUE);
|
1999-01-20 05:16:09 +03:00
|
|
|
else if (panel->list_type == list_full)
|
1999-03-12 01:17:36 +03:00
|
|
|
gtk_toggle_button_set_active (
|
|
|
|
GTK_TOGGLE_BUTTON (panel_view_toolbar_uiinfo[2].widget), TRUE);
|
1999-01-20 05:16:09 +03:00
|
|
|
else if (panel->list_type == list_user)
|
1999-03-12 01:17:36 +03:00
|
|
|
gtk_toggle_button_set_active (
|
|
|
|
GTK_TOGGLE_BUTTON (panel_view_toolbar_uiinfo[3].widget), TRUE);
|
|
|
|
else
|
|
|
|
gtk_toggle_button_set_active (
|
|
|
|
GTK_TOGGLE_BUTTON (panel_view_toolbar_uiinfo[0].widget), TRUE);
|
1999-01-20 05:16:09 +03:00
|
|
|
|
1999-02-07 01:43:17 +03:00
|
|
|
status_line = gtk_hbox_new (FALSE, 2);
|
1998-12-11 09:48:21 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (status_line), 3);
|
1999-02-07 01:43:17 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (status_line),
|
|
|
|
gtk_label_new (_("Location:")), FALSE, FALSE, 0);
|
1999-09-21 12:09:54 +04:00
|
|
|
gtk_box_pack_start (GTK_BOX (status_line), cwd, TRUE, TRUE, 0);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-02-07 01:43:17 +03:00
|
|
|
dock = gnome_dock_item_new ("gmc-toolbar1",
|
|
|
|
(GNOME_DOCK_ITEM_BEH_EXCLUSIVE
|
|
|
|
| GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL));
|
1999-09-21 00:03:58 +04:00
|
|
|
gtk_container_add (GTK_CONTAINER (dock), status_line);
|
|
|
|
gnome_dock_add_item (GNOME_DOCK (GNOME_APP (panel->xwindow)->dock),
|
1999-01-19 00:25:55 +03:00
|
|
|
GNOME_DOCK_ITEM (dock), GNOME_DOCK_TOP, 1, 0, 0, FALSE);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-19 00:25:55 +03:00
|
|
|
gtk_widget_show_all (dock);
|
|
|
|
|
1999-01-07 09:53:31 +03:00
|
|
|
panel->view_table = gtk_table_new (1, 1, 0);
|
|
|
|
gtk_widget_show (panel->view_table);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
1999-01-07 09:53:31 +03:00
|
|
|
* The status bar.
|
1998-11-29 10:50:44 +03:00
|
|
|
*/
|
1999-01-07 09:53:31 +03:00
|
|
|
ministatus_box = gtk_frame_new (NULL);
|
1999-09-21 00:03:58 +04:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (ministatus_box), GTK_SHADOW_IN);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-08 00:40:50 +03:00
|
|
|
panel->status = gtk_label_new (_("Show all files"));
|
1999-01-07 09:53:31 +03:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (panel->status), 0.0, 0.0);
|
1999-01-19 00:56:59 +03:00
|
|
|
gtk_misc_set_padding (GTK_MISC (panel->status), 2, 0);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-07 09:53:31 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (panel->ministatus), ministatus_box, FALSE, FALSE, 0);
|
1999-09-21 00:03:58 +04:00
|
|
|
gtk_container_add (GTK_CONTAINER (ministatus_box), panel->status);
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-07 09:53:31 +03:00
|
|
|
gtk_widget_show (ministatus_box);
|
|
|
|
gtk_widget_show (panel->status);
|
1998-12-04 01:08:04 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Put the icon list and the file listing in a nice frame
|
|
|
|
*/
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-05-08 06:25:00 +04:00
|
|
|
/* Add both the icon view and the listing view */
|
1998-12-30 03:32:41 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (panel->view_table), panel->notebook, 0, 1, 0, 1,
|
1998-05-08 06:25:00 +04:00
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
1998-10-14 06:56:18 +04:00
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
1998-11-29 10:50:44 +03:00
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (panel->table), panel->pane, 0, 1, 1, 2,
|
1998-12-12 02:10:15 +03:00
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
1998-11-29 10:50:44 +03:00
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
|
1999-01-13 00:50:25 +03:00
|
|
|
gtk_paned_add2 (GTK_PANED (panel->pane), panel->view_table);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-11-29 10:50:44 +03:00
|
|
|
/*
|
|
|
|
* ministatus_box is a container created just to put the
|
|
|
|
* panel->ministatus inside.
|
|
|
|
*
|
|
|
|
* Then the resize mode for ministatus_box is changed to stop
|
|
|
|
* any size-changed messages to be propagated above.
|
|
|
|
*
|
|
|
|
* This is required as the panel->ministatus Label is changed
|
|
|
|
* very often (to display status information). If this hack
|
|
|
|
* is not made, then the resize is queued and the whole window
|
|
|
|
* flickers each time this changes
|
|
|
|
*/
|
1998-12-11 09:48:21 +03:00
|
|
|
#if 0
|
1998-11-28 03:01:38 +03:00
|
|
|
ministatus_box = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (ministatus_box), panel->ministatus);
|
|
|
|
gtk_widget_show (ministatus_box);
|
|
|
|
gtk_container_set_resize_mode (GTK_CONTAINER (ministatus_box), GTK_RESIZE_QUEUE);
|
|
|
|
gtk_table_attach (GTK_TABLE (panel->table), ministatus_box, 0, 1, 2, 3,
|
1998-03-20 05:54:06 +03:00
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
1998-03-19 23:07:54 +03:00
|
|
|
0, 0, 0);
|
1998-11-28 03:01:38 +03:00
|
|
|
|
1998-03-23 20:49:04 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (panel->table), frame, 0, 1, 3, 4,
|
1998-03-13 06:44:54 +03:00
|
|
|
GTK_EXPAND | GTK_FILL,
|
1998-02-27 07:54:42 +03:00
|
|
|
0, 0, 0);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1999-01-07 09:53:31 +03:00
|
|
|
#endif
|
1998-03-01 04:29:42 +03:00
|
|
|
/* Ultra nasty hack: pull the vbox from wdata */
|
|
|
|
vbox = GTK_WIDGET (panel->widget.wdata);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-03-05 07:53:47 +03:00
|
|
|
panel->widget.wdata = (widget_data) panel->table;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Now, insert our table in our parent */
|
1998-03-05 07:53:47 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), panel->table);
|
1998-05-08 06:25:00 +04:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (panel->table);
|
1998-03-20 05:54:06 +03:00
|
|
|
|
2000-06-16 22:16:44 +04:00
|
|
|
if (!(panel->widget.options & W_PANEL_HIDDEN) && !is_trash_panel)
|
1998-05-08 06:25:00 +04:00
|
|
|
gtk_widget_show (gtk_widget_get_toplevel (panel->table));
|
|
|
|
|
1998-11-10 05:28:34 +03:00
|
|
|
if (!pixmaps_ready)
|
|
|
|
panel_create_pixmaps ();
|
1998-03-13 08:18:52 +03:00
|
|
|
|
|
|
|
/* In GNOME the panel wants to have the cursor, to avoid "auto" focusing the
|
|
|
|
* filter input line
|
|
|
|
*/
|
|
|
|
panel->widget.options |= W_WANT_CURSOR;
|
1998-03-20 05:54:06 +03:00
|
|
|
panel->estimated_total = 0;
|
1998-12-15 09:35:51 +03:00
|
|
|
|
|
|
|
panel->timer_id = -1;
|
1999-09-21 00:03:58 +04:00
|
|
|
|
|
|
|
/* re-set the user_format explicitly */
|
|
|
|
if (default_user_format != NULL) {
|
|
|
|
g_free (panel->user_format);
|
|
|
|
panel->user_format = g_strdup (default_user_format);
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
panel_update_cols (Widget *panel, int frame_size)
|
|
|
|
{
|
|
|
|
panel->cols = 60;
|
|
|
|
panel->lines = 20;
|
|
|
|
}
|
|
|
|
|
1998-03-04 09:14:21 +03:00
|
|
|
char *
|
|
|
|
get_nth_panel_name (int num)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-01-27 04:14:57 +03:00
|
|
|
static char buffer [BUF_TINY];
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!num)
|
|
|
|
return "New Left Panel";
|
|
|
|
else if (num == 1)
|
|
|
|
return "New Right Panel";
|
|
|
|
else {
|
1999-01-27 04:14:57 +03:00
|
|
|
g_snprintf (buffer, sizeof (buffer), "%ith Panel", num);
|
1998-02-27 07:54:42 +03:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
load_hint (void)
|
|
|
|
{
|
|
|
|
char *hint;
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if ((hint = get_random_hint ())){
|
|
|
|
if (*hint)
|
|
|
|
set_hintbar (hint);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (hint);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
1998-03-13 06:44:54 +03:00
|
|
|
set_hintbar ("The GNOME File Manager " VERSION);
|
1998-12-12 02:10:15 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
paint_frame (WPanel *panel)
|
|
|
|
{
|
|
|
|
}
|
1998-03-07 06:02:01 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
x_reset_sort_labels (WPanel *panel)
|
|
|
|
{
|
1999-01-04 10:29:48 +03:00
|
|
|
int page;
|
1999-08-11 01:52:06 +04:00
|
|
|
|
1998-12-30 03:32:41 +03:00
|
|
|
if (!panel->notebook)
|
|
|
|
return;
|
|
|
|
|
1999-01-04 10:29:48 +03:00
|
|
|
if (panel->list_type == list_icons){
|
|
|
|
page = 0;
|
|
|
|
} else {
|
|
|
|
page = 1;
|
|
|
|
panel_switch_new_display_mode (panel);
|
|
|
|
}
|
|
|
|
gtk_notebook_set_page (GTK_NOTEBOOK (panel->notebook), page);
|
1998-03-07 06:02:01 +03:00
|
|
|
}
|
1998-04-16 02:38:36 +04:00
|
|
|
|
1998-04-16 06:45:53 +04:00
|
|
|
/* Releases all of the X resources allocated */
|
|
|
|
void
|
|
|
|
x_panel_destroy (WPanel *panel)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (panel->xwindow));
|
|
|
|
}
|