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 <stdlib.h> /* atoi */
# include "fs.h"
1998-08-21 02:04:52 +04:00
# include "mad.h"
1998-02-27 07:54:42 +03:00
# include "x.h"
# 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"
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"
1998-03-24 08:25:56 +03:00
# include "gcliplabel.h"
1998-05-08 06:25:00 +04:00
# include "gblist.h"
1998-12-09 04:56:24 +03:00
# include "gicon.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-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"
1998-05-12 08:26:21 +04:00
# include "listing-list.xpm"
# include "listing-iconic.xpm"
1999-01-03 01:06:00 +03:00
# include "listing-custom.xpm"
# include "listing-brief-list.xpm"
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-01-22 03:59:11 +03:00
{ TARGET_URI_LIST_TYPE , 0 , TARGET_URI_LIST }
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 ;
1998-03-04 09:14:21 +03:00
1998-11-10 05:28:34 +03:00
static void panel_file_list_configure_contents ( GtkWidget * sw , WPanel * panel , int main_width , int height ) ;
1999-01-19 00:25:55 +03:00
1998-11-29 06:40:23 +03:00
# define CLIST_FROM_SW(panel_list) GTK_CLIST (GTK_BIN (panel_list)->child)
1998-11-10 05:28:34 +03:00
1998-05-08 06:25:00 +04: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 ;
}
}
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 ;
char * * texts ;
1999-01-02 05:21:14 +03:00
texts = malloc ( sizeof ( char * ) * ( items + 1 ) ) ;
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-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 ;
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 )
texts [ col ] = " " ;
else
texts [ col ] = ( * format - > string_fn ) ( fe , 10 ) ;
col + + ;
}
gtk_clist_append ( cl , texts ) ;
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 ) ;
1998-02-27 07:54:42 +03:00
}
1998-03-12 06:29:45 +03:00
/* This is needed as the gtk_clist_append changes selected under us :-( */
panel - > selected = selected ;
select_item ( panel ) ;
1998-02-27 07:54:42 +03:00
gtk_clist_thaw ( GTK_CLIST ( cl ) ) ;
free ( texts ) ;
}
1998-05-08 06:25:00 +04:00
/*
* Icon view : load the panel contents
*/
static void
panel_fill_panel_icons ( WPanel * panel )
{
GnomeIconList * icons = GNOME_ICON_LIST ( panel - > icons ) ;
const int top = panel - > count ;
const int selected = panel - > selected ;
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 ) ;
1998-12-12 02:10:15 +03:00
1998-05-08 06:25:00 +04:00
for ( i = 0 ; i < top ; i + + ) {
file_entry * fe = & panel - > dir . list [ i ] ;
1999-01-15 22:02:39 +03:00
int p ;
1999-01-20 13:40:21 +03:00
image = gicon_get_icon_for_file ( panel - > cwd , fe ) ;
1999-01-15 22:02:39 +03:00
p = gnome_icon_list_append_imlib ( icons , image , fe - > fname ) ;
if ( fe - > f . marked )
gnome_icon_list_select_icon ( icons , p ) ;
1998-05-08 06:25:00 +04:00
}
/* This is needed as the gtk_clist_append changes selected under us :-( */
panel - > selected = selected ;
gnome_icon_list_thaw ( icons ) ;
1998-10-14 06:56:18 +04:00
select_item ( panel ) ;
1998-05-08 06:25:00 +04:00
}
/*
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-01-21 06:44:03 +03:00
do_file_mark ( panel , panel - > selected , 1 ) ;
display_mini_info ( panel ) ;
1998-05-12 08:26:21 +04:00
if ( panel - > list_type = = list_icons ) {
GnomeIconList * list = GNOME_ICON_LIST ( 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 ) ;
1998-05-15 05:08:46 +04:00
1998-10-14 06:56:18 +04:00
if ( list - > icon_list ) {
1998-12-17 07:51:24 +03: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
}
1998-10-21 03:44:39 +04:00
gnome_canvas_update_now ( GNOME_CANVAS ( list ) ) ;
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 ;
if ( panel - > list_type = = list_icons )
1998-05-12 08:26:21 +04:00
gnome_icon_list_unselect_all ( GNOME_ICON_LIST ( 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 )
{
1998-03-24 08:25:56 +03:00
assign_text ( panel - > filter_w , panel - > filter ? panel - > filter : " " ) ;
1998-04-09 08:58:24 +04:00
update_input ( panel - > filter_w , 1 ) ;
1998-02-27 07:54:42 +03:00
}
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-05-08 06:25:00 +04:00
/*
* These two constants taken from Gtk sources , hack to figure out how much
* of the clist is visible
*/
1998-02-27 07:54:42 +03:00
# define COLUMN_INSET 3
# define CELL_SPACING 1
1998-05-08 06:25:00 +04:00
/*
* Configures the columns title sizes for the panel - > list CList widget
*/
static void
1998-11-10 05:28:34 +03:00
panel_file_list_configure_contents ( GtkWidget * sw , WPanel * panel , int main_width , int height )
1998-02-27 07:54:42 +03:00
{
1998-11-10 05:28:34 +03:00
GtkCList * clist ;
1998-02-27 07:54:42 +03:00
format_e * format = panel - > format ;
int i , used_columns , expandables , items ;
int char_width , usable_pixels , extra_pixels , width ;
int total_columns , extra_columns ;
int expand_space , extra_space , shrink_space ;
1998-03-24 08:25:56 +03:00
int lost_pixels , display_the_mini_info ;
1998-11-10 05:28:34 +03:00
1998-02-27 07:54:42 +03:00
/* Pass 1: Count minimum columns,
* set field_len to default to the requested_field_len
* and compute how much space we lost to the column decorations
*/
lost_pixels = used_columns = expandables = items = 0 ;
1998-11-10 05:28:34 +03:00
for ( format = panel - > format ; format ; format = format - > next ) {
1998-02-27 07:54:42 +03:00
format - > field_len = format - > requested_field_len ;
if ( ! format - > use_in_gui )
continue ;
1998-11-10 05:28:34 +03:00
1998-02-27 07:54:42 +03:00
used_columns + = format - > field_len ;
items + + ;
if ( format - > expand )
expandables + + ;
lost_pixels + = CELL_SPACING + ( 2 * COLUMN_INSET ) ;
}
/* The left scrollbar might take some space from us, use this information */
1998-11-10 05:28:34 +03:00
if ( GTK_WIDGET_VISIBLE ( GTK_SCROLLED_WINDOW ( sw ) - > vscrollbar ) ) {
int scrollbar_width = GTK_WIDGET ( GTK_SCROLLED_WINDOW ( sw ) - > vscrollbar ) - > requisition . width ;
int scrollbar_space = GTK_SCROLLED_WINDOW_CLASS ( GTK_OBJECT ( sw ) - > klass ) - > scrollbar_spacing ;
1998-02-27 07:54:42 +03:00
lost_pixels + = scrollbar_space + scrollbar_width ;
}
1998-11-10 05:28:34 +03:00
char_width = gdk_string_width ( sw - > style - > font , " xW " ) / 2 ;
1998-02-27 07:54:42 +03:00
width = main_width - lost_pixels ;
1998-11-12 21:08:53 +03:00
1998-02-27 07:54:42 +03:00
extra_pixels = width % char_width ;
usable_pixels = width - extra_pixels ;
total_columns = usable_pixels / char_width ;
extra_columns = total_columns - used_columns ;
1998-11-10 05:28:34 +03:00
if ( extra_columns > 0 ) {
1998-02-27 07:54:42 +03:00
expand_space = extra_columns / expandables ;
extra_space = extra_columns % expandables ;
} else
extra_space = expand_space = 0 ;
1998-12-02 08:18:20 +03:00
/*
* Hack : the default mini - info display only gets displayed
1998-03-24 08:25:56 +03:00
* if panel - > estimated_total is not zero , ie , if this has been
* initialized for the first time .
*/
1998-11-10 05:28:34 +03:00
1998-03-24 08:25:56 +03:00
display_the_mini_info = ( panel - > estimated_total = = 0 ) ;
1998-03-20 05:54:06 +03:00
panel - > estimated_total = total_columns ;
1998-03-24 08:25:56 +03:00
if ( display_the_mini_info )
display_mini_info ( panel ) ;
1998-11-10 05:28:34 +03:00
1998-02-27 07:54:42 +03:00
/* If we dont have enough space, shorten the fields */
1998-11-10 05:28:34 +03:00
if ( used_columns > total_columns ) {
1998-02-27 07:54:42 +03:00
expand_space = 0 ;
shrink_space = ( used_columns - total_columns ) / items ;
} else
shrink_space = 0 ;
1998-11-10 05:28:34 +03:00
1998-11-24 01:09:58 +03:00
clist = CLIST_FROM_SW ( sw ) ;
1998-11-10 05:28:34 +03:00
gtk_clist_freeze ( clist ) ;
for ( i = 0 , format = panel - > format ; format ; format = format - > next ) {
1998-02-27 07:54:42 +03:00
if ( ! format - > use_in_gui )
continue ;
format - > field_len + = ( format - > expand ? expand_space : 0 ) - shrink_space ;
1998-11-10 05:28:34 +03:00
gtk_clist_set_column_width ( clist , i , format - > field_len * char_width ) ;
1998-02-27 07:54:42 +03:00
i + + ;
}
1998-11-10 05:28:34 +03:00
gtk_clist_thaw ( clist ) ;
1998-02-27 07:54:42 +03:00
}
1999-01-13 00:50:25 +03:00
static int
panel_file_list_press_row ( GtkWidget * file_list , GdkEvent * event , WPanel * panel )
{
/* FIXME: This is still very broken. */
if ( event - > type = = GDK_BUTTON_PRESS & & event - > button . button = = 3 ) {
gint row , column ;
gtk_clist_get_selection_info ( GTK_CLIST ( file_list ) ,
event - > button . x , event - > button . y ,
& row , & column ) ;
gpopup_do_popup ( ( GdkEventButton * ) event , panel , NULL , row , panel - > dir . list [ row ] . fname ) ;
}
return TRUE ;
}
1998-03-04 09:14:21 +03:00
static void
1998-03-04 03:56:14 +03:00
panel_file_list_select_row ( GtkWidget * file_list , int row , int column , GdkEvent * event , WPanel * panel )
{
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-12-12 02:10:15 +03:00
1999-01-21 06:44:03 +03:00
if ( ! event )
return ;
1998-03-04 09:14:21 +03:00
switch ( event - > type ) {
1999-01-21 06:44:03 +03:00
case GDK_BUTTON_PRESS :
if ( event - > button . button = = 3 )
gpopup_do_popup ( ( GdkEventButton * ) event , panel , NULL , row , panel - > dir . list [ row ] . fname ) ;
break ;
1998-10-28 04:47:57 +03:00
case GDK_BUTTON_RELEASE :
1999-01-21 06:44:03 +03:00
if ( event - > button . button = = 2 ) {
char * fullname ;
1998-12-12 02:10:15 +03:00
1999-01-21 06:44:03 +03:00
if ( S_ISDIR ( panel - > dir . list [ row ] . buf . st_mode ) | |
panel - > dir . list [ row ] . f . link_to_dir ) {
fullname = concat_dir_and_file ( panel - > cwd , panel - > dir . list [ row ] . fname ) ;
1999-01-08 06:03:58 +03:00
new_panel_at ( fullname ) ;
free ( fullname ) ;
}
1998-03-10 04:50:55 +03:00
}
1998-03-04 09:14:21 +03:00
break ;
1999-01-21 06:44:03 +03:00
1998-03-04 09:14:21 +03:00
case GDK_2BUTTON_PRESS :
1998-03-10 04:50:55 +03:00
if ( event - > button . button = = 1 )
do_enter ( panel ) ;
1998-03-04 09:14:21 +03:00
break ;
default :
break ;
1998-03-04 03:56:14 +03:00
}
}
1999-01-21 06:44:03 +03:00
static void
panel_file_list_unselect_row ( GtkWidget * widget , int row , int columns , GdkEvent * event , WPanel * panel )
{
do_file_mark ( panel , row , 0 ) ;
display_mini_info ( panel ) ;
if ( panel - > marked = = 0 )
panel - > selected = 0 ;
}
1998-03-04 03:56:14 +03:00
/* Figure out the number of visible lines in the panel */
static void
1998-11-10 05:28:34 +03:00
panel_file_list_compute_lines ( GtkScrolledWindow * sw , WPanel * panel , int height )
1998-03-04 03:56:14 +03:00
{
int lost_pixels = 0 ;
1998-11-10 05:28:34 +03:00
if ( GTK_WIDGET_VISIBLE ( sw - > hscrollbar ) ) {
int scrollbar_width = GTK_WIDGET ( sw - > hscrollbar ) - > requisition . width ;
int scrollbar_space = GTK_SCROLLED_WINDOW_CLASS ( GTK_OBJECT ( sw ) - > klass ) - > scrollbar_spacing ;
1998-03-04 03:56:14 +03:00
lost_pixels = scrollbar_space + scrollbar_width ;
}
1998-11-24 01:09:58 +03:00
panel - > widget . lines = ( height - lost_pixels ) / ( CLIST_FROM_SW ( sw ) - > row_height + CELL_SPACING ) ;
1998-03-04 03:56:14 +03:00
}
static void
1998-11-10 05:28:34 +03:00
panel_file_list_size_allocate_hook ( GtkWidget * sw , GtkAllocation * allocation , WPanel * panel )
1998-03-04 03:56:14 +03:00
{
1998-11-10 05:28:34 +03:00
gtk_signal_handler_block_by_data ( GTK_OBJECT ( sw ) , panel ) ;
panel_file_list_configure_contents ( sw , panel , allocation - > width , allocation - > height ) ;
gtk_signal_handler_unblock_by_data ( GTK_OBJECT ( sw ) , panel ) ;
1998-12-12 02:10:15 +03:00
1998-11-10 05:28:34 +03:00
panel_file_list_compute_lines ( GTK_SCROLLED_WINDOW ( sw ) , panel , allocation - > height ) ;
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 ) ;
static gboolean
panel_setup_drag_motion ( WPanel * panel , int x , int y , desirable_fn desirable , scroll_fn scroll )
{
if ( panel - > timer_id ! = - 1 ) {
gtk_timeout_remove ( panel - > timer_id ) ;
panel - > timer_id = - 1 ;
}
panel - > drag_motion_x = x ;
panel - > drag_motion_y = y ;
if ( ( * desirable ) ( panel , x , y ) ) {
panel - > timer_id = gtk_timeout_add ( 60 , scroll , panel ) ;
return TRUE ;
}
return FALSE ;
}
1998-03-04 09:14:21 +03:00
static void
1998-11-10 05:28:34 +03:00
panel_configure_file_list ( WPanel * panel , GtkWidget * sw , GtkWidget * file_list )
1998-03-04 03:56:14 +03:00
{
format_e * format = panel - > format ;
GtkObject * adjustment ;
int i ;
/* Set sorting callback */
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " click_column " ,
GTK_SIGNAL_FUNC ( panel_file_list_column_callback ) , panel ) ;
/* Configure the CList */
1998-03-06 09:42:43 +03:00
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 ) {
1998-03-04 03:56:14 +03:00
GtkJustification just ;
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 */
if ( format - > just_mode = = J_LEFT )
just = GTK_JUSTIFY_LEFT ;
else
just = GTK_JUSTIFY_RIGHT ;
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 + + ;
}
/* Configure the scrolbars */
1998-11-10 05:28:34 +03:00
adjustment = GTK_OBJECT ( gtk_scrolled_window_get_vadjustment ( GTK_SCROLLED_WINDOW ( sw ) ) ) ;
1998-02-27 07:54:42 +03:00
}
1998-10-20 09:37:45 +04:00
/*
* Creates an uri list to be transfered during a drop operation .
*/
1998-03-04 09:14:21 +03:00
static void *
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 )
1998-10-20 09:37:45 +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 + + ;
1998-12-06 02:19:57 +03:00
data = copy = xmalloc ( total_len + 1 , " build_selected_file_list " ) ;
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 ( & copy [ filelen ] , panel - > cwd ) ;
copy [ filelen + cwdlen - 1 ] = ' / ' ;
strcpy ( & copy [ filelen + cwdlen ] , panel - > dir . list [ i ] . fname ) ;
strcpy ( & copy [ 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 ) ;
uri = copy_strings ( " file: " , fullname , NULL ) ;
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
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 ;
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
}
/**
* 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 )
{
GnomeIconList * gil = GNOME_ICON_LIST ( widget ) ;
char * dir ;
int idx ;
1999-01-08 04:53:42 +03:00
gboolean reload ;
1998-10-21 22:05:08 +04:00
idx = gnome_icon_list_get_icon_at ( gil , x , y ) ;
if ( idx = = - 1 )
dir = g_strdup ( panel - > cwd ) ;
else {
if ( panel - > dir . list [ idx ] . f . link_to_dir | |
S_ISDIR ( panel - > dir . list [ idx ] . buf . st_mode ) )
dir = concat_dir_and_file ( panel - > cwd , panel - > dir . list [ idx ] . fname ) ;
else
dir = g_strdup ( panel - > cwd ) ;
}
1998-11-10 05:28:34 +03:00
1999-01-08 04:53:42 +03:00
reload = gdnd_drop_on_directory ( context , selection_data , dir ) ;
1998-10-21 22:05:08 +04:00
free ( dir ) ;
1999-01-08 04:53:42 +03:00
if ( reload ) {
update_one_panel_widget ( panel , 0 , UP_KEEPSEL ) ;
panel_update_contents ( panel ) ;
}
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 )
{
GtkCList * clist = GTK_CLIST ( widget ) ;
char * dir ;
int row ;
1998-12-12 02:10:15 +03:00
1998-10-21 22:05:08 +04:00
if ( gtk_clist_get_selection_info ( clist , x , y , & row , NULL ) = = 0 )
dir = g_strdup ( panel - > cwd ) ;
else {
g_assert ( row < panel - > count ) ;
if ( S_ISDIR ( panel - > dir . list [ row ] . buf . st_mode ) | |
panel - > dir . list [ row ] . f . link_to_dir )
dir = concat_dir_and_file ( panel - > cwd , panel - > dir . list [ row ] . fname ) ;
1998-12-12 02:10:15 +03:00
else
1998-10-21 22:05:08 +04:00
dir = g_strdup ( panel - > cwd ) ;
}
1998-11-10 05:28:34 +03:00
gdnd_drop_on_directory ( context , selection_data , dir ) ;
1998-10-21 22:05:08 +04:00
free ( dir ) ;
update_one_panel_widget ( panel , 0 , UP_KEEPSEL ) ;
panel_update_contents ( panel ) ;
}
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 ;
char * path ;
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 ;
gtk_ctree_expand_recursive ( GTK_CTREE ( dtree ) , node ) ;
path = gtk_dtree_get_row_path ( dtree , node , 0 ) ;
gdnd_drop_on_directory ( context , selection_data , path ) ;
1998-12-12 02:10:15 +03:00
1998-12-03 19:10:25 +03:00
g_free ( path ) ;
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
}
1998-10-28 05:06:34 +03:00
static int
panel_clist_button_press ( GtkWidget * widget , GdkEventButton * event , WPanel * panel )
{
1999-01-22 03:59:11 +03:00
if ( event - > window ! = GTK_CLIST ( widget ) - > clist_window )
return FALSE ;
1998-10-28 05:06:34 +03:00
panel - > maybe_start_drag = event - > button ;
1998-12-12 02:10:15 +03:00
1998-10-28 05:06:34 +03:00
panel - > click_x = event - > x ;
panel - > click_y = event - > y ;
return FALSE ;
}
static int
panel_clist_button_release ( GtkWidget * widget , GdkEventButton * event , WPanel * panel )
{
panel - > maybe_start_drag = 0 ;
return FALSE ;
}
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
GtkTargetList * list ;
GdkDragContext * context ;
1998-12-17 11:28:05 +03:00
1998-10-28 05:06:34 +03:00
if ( ! panel - > maybe_start_drag )
return FALSE ;
1998-12-04 05:08:06 +03:00
if ( ( abs ( event - > x - panel - > click_x ) < 4 ) | |
1998-10-28 05:06:34 +03:00
( abs ( event - > y - panel - > click_y ) < 4 ) )
return FALSE ;
1998-12-12 02:10:15 +03:00
1998-10-28 05:06:34 +03:00
list = gtk_target_list_new ( drag_types , ELEMENTS ( drag_types ) ) ;
1999-01-21 20:59:30 +03:00
context = gtk_drag_begin ( widget , list ,
( GDK_ACTION_COPY | GDK_ACTION_MOVE
| GDK_ACTION_LINK | GDK_ACTION_ASK ) ,
1998-12-04 05:08:06 +03:00
panel - > maybe_start_drag , ( GdkEvent * ) event ) ;
1998-10-28 05:06:34 +03:00
gtk_drag_set_icon_default ( context ) ;
1998-12-12 02:10:15 +03:00
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 )
{
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 ;
va = scrolled_window_get_vadjustment ( panel - > list ) ;
if ( y < 10 ) {
if ( va - > value > va - > lower )
return TRUE ;
} else {
1999-01-20 13:40:21 +03:00
if ( y > ( GTK_WIDGET ( panel - > list ) - > allocation . height - 10 ) ) {
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 ;
}
/**
* panel_clist_drag_motion :
*
* Invoked when an application dragging over us has the the cursor moved .
* If we are close to the top or bottom , we scroll the window
*/
static gboolean
panel_clist_drag_motion ( GtkWidget * widget , GdkDragContext * ctx , int x , int y , guint time , void * data )
{
WPanel * panel = data ;
1999-01-22 03:59:11 +03:00
if ( ctx - > dest_window ! = GTK_CLIST ( widget ) - > clist_window )
gdk_drag_status ( ctx , 0 , time ) ;
else {
panel_setup_drag_motion ( panel , x , y ,
panel_clist_scrolling_is_desirable , panel_clist_scroll ) ;
gdk_drag_status ( ctx , ctx - > suggested_action , time ) ;
}
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
panel_clist_drag_leave ( GtkWidget * widget , GdkDragContext * ctx , guint time , void * data )
{
WPanel * panel = data ;
if ( panel - > timer_id ! = - 1 ) {
gtk_timeout_remove ( panel - > timer_id ) ;
panel - > timer_id = - 1 ;
}
}
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 ;
va = GNOME_ICON_LIST ( panel - > icons ) - > adj ;
if ( y < 10 ) {
if ( va - > value > va - > lower )
return TRUE ;
} else {
1999-01-20 13:40:21 +03:00
if ( y > ( GTK_WIDGET ( panel - > icons ) - > allocation . height - 10 ) ) {
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
va = GNOME_ICON_LIST ( panel - > icons ) - > adj ;
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-01 05:04:59 +03:00
/**
* panel_icon_list_drag_motion :
*
* Invoked when an application dragging over us has the the cursor moved .
* If we are close to the top or bottom , we scroll the window
*/
static gboolean
panel_icon_list_drag_motion ( GtkWidget * widget , GdkDragContext * ctx , int x , int y , guint time , void * data )
{
WPanel * panel = data ;
panel_setup_drag_motion ( panel , x , y , panel_icon_list_scrolling_is_desirable , panel_icon_list_scroll ) ;
return TRUE ;
}
/**
* panel_icon_list_drag_leave :
*
* Invoked when the dragged object has left our region
*/
static void
panel_icon_list_drag_leave ( GtkWidget * widget , GdkDragContext * ctx , guint time , void * data )
{
WPanel * panel = data ;
if ( panel - > timer_id ! = - 1 ) {
gtk_timeout_remove ( panel - > timer_id ) ;
panel - > timer_id = - 1 ;
}
}
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 ) ;
gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( sw ) , GTK_POLICY_AUTOMATIC , GTK_POLICY_AUTOMATIC ) ;
1999-01-21 06:44:03 +03:00
file_list = gtk_clist_new_with_titles ( items , titles ) ;
1998-11-10 05:28:34 +03:00
gtk_container_add ( GTK_CONTAINER ( sw ) , file_list ) ;
gtk_widget_show ( file_list ) ;
panel_configure_file_list ( panel , sw , file_list ) ;
1998-08-21 02:04:52 +04:00
g_free ( titles ) ;
1998-02-27 07:54:42 +03:00
1998-11-10 05:28:34 +03:00
gtk_signal_connect_after ( GTK_OBJECT ( sw ) , " size_allocate " ,
1998-03-11 01:34:28 +03:00
GTK_SIGNAL_FUNC ( panel_file_list_size_allocate_hook ) ,
panel ) ;
1998-03-04 09:14:21 +03:00
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " select_row " ,
1998-03-11 01:34:28 +03:00
GTK_SIGNAL_FUNC ( panel_file_list_select_row ) ,
panel ) ;
1999-01-21 06:44:03 +03:00
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " unselect_row " ,
GTK_SIGNAL_FUNC ( panel_file_list_unselect_row ) ,
panel ) ;
#if 0
1999-01-13 00:50:25 +03:00
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " button_press_event " ,
GTK_SIGNAL_FUNC ( panel_file_list_press_row ) ,
panel ) ;
1999-01-21 06:44:03 +03:00
# endif
1999-01-08 06:03:58 +03:00
gtk_clist_set_button_actions ( GTK_CLIST ( file_list ) , 1 , GTK_BUTTON_SELECTS | GTK_BUTTON_DRAGS ) ;
gtk_clist_set_button_actions ( GTK_CLIST ( file_list ) , 2 , GTK_BUTTON_SELECTS ) ;
1998-11-10 05:28:34 +03:00
/* Set up drag and drop */
load_dnd_icons ( ) ;
1999-01-22 03:59:11 +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 ) ;
1998-11-10 05:28:34 +03:00
1999-01-08 06:03:58 +03:00
/* Make directories draggable */
gtk_drag_source_set ( GTK_WIDGET ( file_list ) , GDK_BUTTON1_MASK | GDK_BUTTON2_MASK ,
drag_types , ELEMENTS ( drag_types ) ,
GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK ) ;
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-02 08:18:20 +03:00
/* These implement our drag-start activation code. We need to
* manually activate the drag as the DnD code in Gtk + will
* make the scrollbars in the CList activate drags when they
* are moved .
1998-11-10 05:28:34 +03:00
*/
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " button_press_event " ,
GTK_SIGNAL_FUNC ( panel_clist_button_press ) , panel ) ;
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " button_release_event " ,
GTK_SIGNAL_FUNC ( panel_clist_button_release ) , panel ) ;
gtk_signal_connect ( GTK_OBJECT ( file_list ) , " motion_notify_event " ,
GTK_SIGNAL_FUNC ( panel_widget_motion ) , 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 ) ;
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-01-08 06:03:58 +03:00
if ( event - > button . button = = 3 )
gpopup_do_popup ( ( GdkEventButton * ) event , panel , NULL , index , panel - > dir . list [ index ] . fname ) ;
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 ) ;
free ( fullname ) ;
}
1998-12-30 05:51:01 +03:00
}
1998-05-08 06:25:00 +04:00
break ;
1999-01-08 06:03:58 +03:00
1998-05-08 06:25:00 +04:00
case GDK_2BUTTON_PRESS :
if ( event - > button . button = = 1 )
do_enter ( panel ) ;
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 ;
}
1998-10-14 10:26:05 +04:00
static int
panel_icon_renamed ( GtkWidget * widget , int index , char * dest , WPanel * panel )
{
char * source ;
source = panel - > dir . list [ index ] . fname ;
if ( mc_rename ( source , dest ) = = 0 ) {
free ( panel - > dir . list [ index ] . fname ) ;
panel - > dir . list [ index ] . fname = strdup ( dest ) ;
return TRUE ;
} else
return FALSE ;
}
1998-12-05 00:32:19 +03:00
static void
1998-05-08 06:25:00 +04:00
load_imlib_icons ( void )
{
static int loaded ;
if ( loaded )
return ;
1998-12-12 02:10:15 +03:00
1998-05-08 06:25:00 +04:00
loaded = 1 ;
}
1998-10-14 06:56:18 +04:00
1998-05-08 06:25:00 +04:00
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 ;
icon = gnome_icon_list_get_icon_at ( gil , event - > x , event - > y ) ;
if ( icon = = - 1 )
1998-10-21 05:09:50 +04:00
panel - > maybe_start_drag = 0 ;
1998-12-30 05:51:01 +03:00
else {
if ( event - > button ! = 3 )
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
{
1998-11-10 05:28:34 +03:00
GnomeIconList * ilist ;
1998-12-14 07:23:33 +03:00
1999-01-22 05:14:00 +03:00
ilist = GNOME_ICON_LIST (
gnome_icon_list_new_flags (
90 , NULL ,
GNOME_ICON_LIST_IS_EDITABLE |
GNOME_ICON_LIST_STATIC_TEXT ) ) ;
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_imlib_icons ( ) ;
load_dnd_icons ( ) ;
1998-10-21 05:09:50 +04:00
1998-11-10 05:28:34 +03:00
gtk_drag_dest_set ( GTK_WIDGET ( ilist ) , GTK_DEST_DEFAULT_ALL ,
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-01-01 05:04:59 +03:00
/*
* This signal is provide for scrolling the main window if
* data is being dragged
*/
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 ) ;
1998-11-29 11:22:20 +03:00
return GTK_WIDGET ( ilist ) ;
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-14 01:58:10 +03:00
/* FIXME: for now, this list is hardcoded. We want a way to let the user configure it. */
static struct filter_item {
char * text ;
char * glob ;
} filter_items [ ] = {
1998-03-25 08:16:00 +03:00
{ N_ ( " All files " ) ,
1998-03-17 03:24:52 +03:00
" * " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Archives and compressed files " ) ,
1998-03-17 03:24:52 +03:00
" *.(tar|gz|tgz|taz|zip|lha|zoo|pak|sit|arc|arj|rar|huf|lzh) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " RPM/DEB files " ) ,
1998-03-17 03:24:52 +03:00
" *.(rpm|deb) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Text/Document files " ) ,
1998-03-17 03:24:52 +03:00
" *.(txt|tex|doc|rtf) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " HTML and SGML files " ) ,
1998-03-17 03:24:52 +03:00
" *.(html|htm|sgml|sgm) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Postscript and PDF files " ) ,
1998-03-17 03:24:52 +03:00
" *.(ps|pdf) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Spreadsheet files " ) ,
1998-03-17 03:24:52 +03:00
" *.(xls|wks|wk1) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Image files " ) ,
1998-03-14 01:58:10 +03:00
" *.(png|jpg|jpeg|xcf|gif|tif|tiff|xbm|xpm|pbm|pgm|ppm|tga|rgb|iff|lbm|ilbm| "
1998-03-17 03:24:52 +03:00
" bmp|pcx|pic|pict|psd|gbr|pat|ico|fig|cgm|rle|fits) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Video/animation files " ) ,
1998-03-17 03:24:52 +03:00
" *.(mpg|mpeg|mov|avi|fli|flc|flh|flx|dl) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Audio files " ) ,
1998-03-17 03:24:52 +03:00
" *.(au|wav|mp3|snd|mod|s3m|ra) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " C program files " ) ,
1998-03-17 03:24:52 +03:00
" *.[ch] " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " C++ program files " ) ,
1998-03-17 03:24:52 +03:00
" *.(cc|C|cpp|cxx|h|H) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Objective-C program files " ) ,
1998-03-17 03:24:52 +03:00
" *.[mh] " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Scheme program files " ) ,
1998-03-17 03:24:52 +03:00
" *.scm " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Assembler program files " ) ,
1998-03-17 03:24:52 +03:00
" *.(s|S|asm) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Misc. program files " ) ,
1998-03-17 03:24:52 +03:00
" *.(awk|sed|lex|l|y|sh|idl|pl|py|am|in|f|el|bas|pas|java|sl|p|m4|tcl|pov) " } ,
1998-03-25 08:16:00 +03:00
{ N_ ( " Font files " ) ,
1998-03-17 03:24:52 +03:00
" *.(pfa|pfb|afm|ttf|fon|pcf|pcf.gz|spd) " }
1998-03-06 09:42:43 +03:00
} ;
1998-03-14 01:58:10 +03:00
static GtkWidget * filter_menu ;
static void
filter_item_select ( GtkWidget * widget , gpointer data )
{
1998-03-20 05:00:09 +03:00
/* FIXME: the hintbar resizes horribly and screws the panel */
#if 0
1998-03-14 01:58:10 +03:00
struct filter_item * fi = gtk_object_get_user_data ( GTK_OBJECT ( widget ) ) ;
1998-03-20 05:00:09 +03:00
set_hintbar ( easy_patterns ? fi - > glob : fi - > regexp ) ;
# endif
1998-03-14 01:58:10 +03:00
}
static void
filter_item_deselect ( GtkWidget * widget , gpointer data )
{
1998-03-14 03:42:23 +03:00
/* set_hintbar (""); */
1998-03-14 01:58:10 +03:00
}
static void
filter_item_activate ( GtkWidget * widget , gpointer data )
{
struct filter_item * fi = gtk_object_get_user_data ( GTK_OBJECT ( widget ) ) ;
WPanel * panel = data ;
1998-03-17 03:24:52 +03:00
char * pattern ;
if ( easy_patterns )
pattern = g_strdup ( fi - > glob ) ;
else {
/* This is sort of a hack to force convert_pattern() to actually convert the thing */
easy_patterns = 1 ;
pattern = convert_pattern ( fi - > glob , match_file , 0 ) ;
easy_patterns = 0 ;
}
1998-03-14 01:58:10 +03:00
1998-03-17 03:24:52 +03:00
set_panel_filter_to ( panel , pattern ) ;
1998-03-14 01:58:10 +03:00
}
static void
build_filter_menu ( WPanel * panel , GtkWidget * button )
{
GtkWidget * item ;
int i ;
if ( filter_menu )
return ;
/* FIXME: the filter menu is global, and it is never destroyed */
filter_menu = gtk_menu_new ( ) ;
gtk_object_set_user_data ( GTK_OBJECT ( filter_menu ) , button ) ;
for ( i = 0 ; i < ELEMENTS ( filter_items ) ; i + + ) {
1998-03-25 08:16:00 +03:00
item = gtk_menu_item_new_with_label ( _ ( filter_items [ i ] . text ) ) ;
1998-03-14 01:58:10 +03:00
gtk_object_set_user_data ( GTK_OBJECT ( item ) , & filter_items [ i ] ) ;
gtk_signal_connect ( GTK_OBJECT ( item ) , " select " ,
( GtkSignalFunc ) filter_item_select ,
panel ) ;
gtk_signal_connect ( GTK_OBJECT ( item ) , " deselect " ,
( GtkSignalFunc ) filter_item_deselect ,
panel ) ;
gtk_signal_connect ( GTK_OBJECT ( item ) , " activate " ,
( GtkSignalFunc ) filter_item_activate ,
panel ) ;
gtk_widget_show ( item ) ;
gtk_menu_append ( GTK_MENU ( filter_menu ) , item ) ;
}
}
static void
position_filter_popup ( GtkMenu * menu , gint * x , gint * y , gpointer data )
{
int screen_width , screen_height ;
GtkWidget * wmenu = GTK_WIDGET ( menu ) ;
GtkWidget * button = GTK_WIDGET ( data ) ;
/* This code is mostly ripped off from gtkmenu.c - Federico */
screen_width = gdk_screen_width ( ) ;
screen_height = gdk_screen_height ( ) ;
gdk_window_get_origin ( button - > window , x , y ) ;
* y + = button - > allocation . height ;
if ( ( * x + wmenu - > requisition . width ) > screen_width )
* x - = ( * x + wmenu - > requisition . width ) - screen_width ;
if ( ( * y + wmenu - > requisition . height ) > screen_height )
* y - = ( * y + wmenu - > requisition . height ) - screen_height ;
if ( * y < 0 )
* y = 0 ;
}
static void
show_filter_popup ( GtkWidget * button , gpointer data )
{
WPanel * panel ;
panel = data ;
build_filter_menu ( panel , button ) ;
gtk_menu_popup ( GTK_MENU ( filter_menu ) , NULL , NULL ,
position_filter_popup ,
button ,
1 ,
GDK_CURRENT_TIME ) ;
}
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 ) ;
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 */
/* str = copy_strings ("-> ", link_target, NULL); */
1999-01-07 08:19:09 +03:00
gnome_appbar_pop ( bar ) ;
gnome_appbar_push ( bar , " " ) ;
/*free (str); */
} 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 ;
buffer = xmalloc ( len + 2 , " display_mini_info " ) ;
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 ) ;
1998-03-20 05:54:06 +03:00
free ( buffer ) ;
}
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-03-04 09:14:21 +03:00
static GtkWidget *
1998-03-24 08:25:56 +03:00
panel_create_filter ( Dlg_head * h , WPanel * panel , void * * filter_w )
1998-02-27 07:54:42 +03:00
{
1998-03-14 01:58:10 +03:00
GtkWidget * fhbox ;
GtkWidget * button ;
GtkWidget * arrow ;
1998-03-06 09:42:43 +03:00
GtkWidget * label ;
1998-03-14 01:58:10 +03:00
GtkWidget * ihbox ;
1998-03-13 08:18:52 +03:00
WInput * in ;
1998-03-06 09:42:43 +03:00
1998-03-14 01:58:10 +03:00
fhbox = gtk_hbox_new ( FALSE , 0 ) ;
1998-03-06 09:42:43 +03:00
1998-03-14 01:58:10 +03:00
/* Filter popup button */
button = gtk_button_new ( ) ;
gtk_signal_connect ( GTK_OBJECT ( button ) , " clicked " ,
( GtkSignalFunc ) show_filter_popup ,
panel ) ;
GTK_WIDGET_UNSET_FLAGS ( button , GTK_CAN_FOCUS ) ;
gtk_box_pack_start ( GTK_BOX ( fhbox ) , button , FALSE , FALSE , 0 ) ;
gtk_widget_show ( button ) ;
ihbox = gtk_hbox_new ( FALSE , 3 ) ;
gtk_container_add ( GTK_CONTAINER ( button ) , ihbox ) ;
gtk_widget_show ( ihbox ) ;
arrow = gtk_arrow_new ( GTK_ARROW_DOWN , GTK_SHADOW_OUT ) ;
gtk_box_pack_start ( GTK_BOX ( ihbox ) , arrow , TRUE , TRUE , 0 ) ;
gtk_widget_show ( arrow ) ;
1998-11-30 19:59:23 +03:00
label = gtk_label_new ( _ ( " Filter " ) ) ;
1998-03-14 01:58:10 +03:00
gtk_box_pack_start ( GTK_BOX ( ihbox ) , label , TRUE , TRUE , 0 ) ;
1998-03-06 09:42:43 +03:00
gtk_widget_show ( label ) ;
1998-03-14 01:58:10 +03:00
/* Filter input line */
1998-03-13 08:18:52 +03:00
in = input_new ( 0 , 0 , 0 , 10 , " " , " filter " ) ;
add_widget ( h , in ) ;
/* Force the creation of the gtk widget */
send_message_to ( h , ( Widget * ) in , WIDGET_INIT , 0 ) ;
1998-03-24 08:25:56 +03:00
* filter_w = in ;
1998-03-06 09:42:43 +03:00
1998-03-24 08:25:56 +03:00
gtk_box_pack_start ( GTK_BOX ( fhbox ) , GTK_WIDGET ( in - > widget . wdata ) , TRUE , TRUE , 0 ) ;
1998-02-27 07:54:42 +03:00
1998-03-14 01:58:10 +03:00
return fhbox ;
1998-02-27 07:54:42 +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 )
{
1998-12-04 00:56:11 +03:00
if ( ! panel - > dragging )
do_panel_cd ( panel , path , cd_exact ) ;
1998-12-02 08:18:20 +03:00
}
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 )
{
WPanel * panel = data ;
1998-12-13 00:16:01 +03:00
GtkDTree * dtree = GTK_DTREE ( panel - > tree ) ;
1998-12-02 09:51:40 +03:00
GtkCTreeNode * node ;
int row , col ;
int r ;
1998-12-12 02:10:15 +03:00
1998-12-02 09:51:40 +03:00
r = gtk_clist_get_selection_info (
GTK_CLIST ( panel - > tree ) ,
1998-12-15 09:35:51 +03:00
panel - > drag_motion_x ,
panel - > drag_motion_y ,
1998-12-02 09:51:40 +03:00
& row , & col ) ;
if ( ! r )
return FALSE ;
1998-12-12 02:10:15 +03:00
1998-12-02 09:51:40 +03:00
node = gtk_ctree_node_nth ( GTK_CTREE ( panel - > tree ) , row ) ;
if ( ! node )
return FALSE ;
1998-12-13 00:16:01 +03:00
if ( ! GTK_CTREE_ROW ( node ) - > expanded )
dtree - > auto_expanded_nodes = g_list_append ( dtree - > auto_expanded_nodes , node ) ;
gtk_ctree_expand ( GTK_CTREE ( panel - > tree ) , node ) ;
1998-12-02 09:51:40 +03:00
return FALSE ;
}
1998-12-04 00:56:11 +03:00
/**
* panel_tree_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_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 {
1999-01-20 13:40:21 +03:00
if ( y > ( GTK_WIDGET ( dtree ) - > allocation . height - 10 ) ) {
if ( va - > value < va - > upper - va - > page_size )
1998-12-04 00:56:11 +03:00
return TRUE ;
}
}
return FALSE ;
}
1998-12-13 00:16:01 +03:00
/**
* panel_tree_scrolling_is_desirable :
*
* Give a node of the tree , this panel checks to see if we ' ve
* auto - expanded any rows that aren ' t parents of this node ,
* and , if so , collapses them back .
*/
static void
panel_tree_check_auto_expand ( WPanel * panel , GtkCTreeNode * current )
{
GtkDTree * dtree = GTK_DTREE ( panel - > tree ) ;
GtkCList * clist = GTK_CLIST ( dtree ) ;
GList * tmp_list = dtree - > auto_expanded_nodes ;
GList * free_list ;
gint row , old_y , new_y ;
if ( current ) {
while ( tmp_list ) {
GtkCTreeNode * parent_node = tmp_list - > data ;
GtkCTreeNode * tmp_node = current ;
while ( tmp_node ) {
if ( tmp_node = = parent_node )
break ;
tmp_node = GTK_CTREE_ROW ( tmp_node ) - > parent ;
}
if ( ! tmp_node ) /* parent not found */
break ;
tmp_list = tmp_list - > next ;
}
}
/* Collapse the rows as necessary. If possible, try to do
* so that the " current " stays the same place on the
* screen
*/
if ( tmp_list ) {
if ( current ) {
row = g_list_position ( clist - > row_list , ( GList * ) current ) ;
old_y = row * clist - > row_height - clist - > vadjustment - > value ;
}
free_list = tmp_list ;
while ( tmp_list ) {
gtk_ctree_collapse ( GTK_CTREE ( panel - > tree ) , tmp_list - > data ) ;
tmp_list = tmp_list - > next ;
}
if ( current ) {
row = g_list_position ( clist - > row_list , ( GList * ) current ) ;
new_y = row * clist - > row_height - clist - > vadjustment - > value ;
if ( new_y ! = old_y ) {
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
/**
* panel_tree_scroll :
*
* Timer callback invoked to scroll the tree window
*/
static gboolean
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
}
1998-12-12 02:10:15 +03:00
/**
1998-12-02 09:51:40 +03:00
* panel_tree_drag_motion :
*
* This routine is invoked by GTK + when an item is being dragged on
* top of our widget . We setup a timed function that will open the
* Tree node
*/
static gboolean
panel_tree_drag_motion ( GtkWidget * widget , GdkDragContext * ctx , int x , int y , guint time , void * data )
{
WPanel * panel = data ;
int r , row , col ;
1998-12-12 02:10:15 +03:00
1998-12-15 09:35:51 +03:00
if ( panel_setup_drag_motion ( panel , x , y , panel_tree_scrolling_is_desirable , panel_tree_scroll ) )
1998-12-04 00:56:11 +03:00
return TRUE ;
1998-12-12 02:10:15 +03:00
1998-12-02 09:51:40 +03:00
r = gtk_clist_get_selection_info (
GTK_CLIST ( widget ) , x , y , & row , & col ) ;
1998-12-13 00:16:01 +03:00
if ( r ) {
GtkCTreeNode * current ;
current = gtk_ctree_node_nth ( GTK_CTREE ( widget ) , row ) ;
panel_tree_check_auto_expand ( panel , current ) ;
} else
panel_tree_check_auto_expand ( panel , NULL ) ;
1998-12-15 09:35:51 +03:00
panel - > timer_id = gtk_timeout_add ( 400 , tree_drag_open_directory , data ) ;
1998-12-02 09:51:40 +03:00
return TRUE ;
}
/**
* panel_tree_drag_leave :
*
* Invoked by GTK + when the dragging cursor has abandoned our widget .
* We kill any pending timers .
*/
static void
1998-12-13 00:16:01 +03:00
panel_tree_drag_leave ( GtkWidget * widget , GdkDragContext * ctx , guint time , void * data )
1998-12-02 09:51:40 +03:00
{
1998-12-13 00:16:01 +03:00
WPanel * panel = data ;
1998-12-04 02:50:05 +03:00
1998-12-15 09:35:51 +03:00
if ( panel - > timer_id ! = - 1 ) {
gtk_timeout_remove ( panel - > timer_id ) ;
panel - > timer_id = - 1 ;
1998-12-02 09:51:40 +03:00
}
1998-12-13 00:16:01 +03:00
panel_tree_check_auto_expand ( panel , NULL ) ;
1998-12-02 09:51:40 +03:00
}
1998-12-05 00:32:19 +03:00
/**
* panel_tree_drag_begin :
*
* callback invoked when the drag action starts from the Tree
*/
static void
panel_tree_drag_begin ( GtkWidget * widget , GdkDragContext * context , WPanel * panel )
{
GtkDTree * dtree = GTK_DTREE ( widget ) ;
panel - > dragging = 1 ;
dtree - > drag_dir = g_strdup ( dtree - > current_path ) ;
printf ( " This is the directory being dragged: %s \n " , dtree - > current_path ) ;
1998-12-12 02:10:15 +03:00
1998-12-05 00:32:19 +03:00
}
/**
* panel_tree_drag_end :
*
* callback invoked when the drag action initiated by the tree finishes .
*/
static void
panel_tree_drag_end ( GtkWidget * widget , GdkDragContext * context , WPanel * panel )
{
GtkDTree * dtree = GTK_DTREE ( widget ) ;
panel - > dragging = 0 ;
g_free ( dtree - > current_path ) ;
dtree - > current_path = NULL ;
}
/**
* panel_tree_drag_data_get :
*
* Invoked when the tree is required to provide the dragged data
*/
static void
panel_tree_drag_data_get ( GtkWidget * widget , GdkDragContext * context ,
GtkSelectionData * selection_data , guint info ,
guint32 time )
{
GtkDTree * dtree = GTK_DTREE ( widget ) ;
char * data ;
switch ( info ) {
case TARGET_URI_LIST :
case TARGET_TEXT_PLAIN :
data = copy_strings ( " file: " , dtree - > drag_dir , NULL ) ;
gtk_selection_data_set (
selection_data , selection_data - > target , 8 ,
data , strlen ( data ) + 1 ) ;
break ;
}
}
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 ( ) ;
1998-12-12 02:10:15 +03:00
gtk_ctree_set_line_style ( GTK_CTREE ( tree ) , GTK_CTREE_LINES_DOTTED ) ;
1998-12-11 05:47:09 +03:00
gtk_ctree_set_expander_style ( GTK_CTREE ( tree ) , GTK_CTREE_EXPANDER_SQUARE ) ;
gtk_ctree_set_indent ( GTK_CTREE ( tree ) , 10 ) ;
1998-12-02 08:18:20 +03:00
gtk_signal_connect ( GTK_OBJECT ( tree ) , " directory_changed " ,
GTK_SIGNAL_FUNC ( panel_chdir ) , panel ) ;
gtk_drag_dest_set ( GTK_WIDGET ( tree ) , GTK_DEST_DEFAULT_ALL ,
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-12-02 09:51:40 +03:00
/*
* Drag and drop signals .
*/
/* Data has been dropped signal handler */
1998-12-02 08:18:20 +03:00
gtk_signal_connect ( GTK_OBJECT ( tree ) , " drag_data_received " ,
GTK_SIGNAL_FUNC ( panel_tree_drag_data_received ) , panel ) ;
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
1998-12-05 00:32:19 +03:00
/* Make directories draggable */
1999-01-20 13:40:21 +03:00
gtk_drag_source_set ( GTK_WIDGET ( tree ) , GDK_BUTTON1_MASK | GDK_BUTTON2_MASK ,
1998-12-05 00:32:19 +03:00
drag_types , ELEMENTS ( drag_types ) ,
1999-01-20 13:40:21 +03:00
GDK_ACTION_LINK | GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_DEFAULT ) ;
1998-12-12 02:10:15 +03:00
1998-12-02 09:51:40 +03:00
/* Mouse is being moved over ourselves */
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 ) ;
1998-12-12 02:10:15 +03:00
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 ;
}
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 ;
1998-12-12 02:10:15 +03:00
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 ) ;
}
1998-05-12 08:26:21 +04:00
static void
do_switch_to_iconic ( GtkWidget * widget , WPanel * panel )
{
1999-01-19 00:56:59 +03:00
if ( GTK_TOGGLE_BUTTON ( widget ) - > active = = FALSE )
return ;
1998-05-12 08:26:21 +04:00
if ( panel - > list_type = = list_icons )
return ;
1998-05-13 00:43:42 +04:00
panel - > list_type = list_icons ;
set_panel_formats ( panel ) ;
1999-01-04 10:29:48 +03:00
panel_update_contents ( panel ) ;
1998-05-12 08:26:21 +04:00
}
static void
1999-01-03 01:06:00 +03:00
do_switch_to_brief_listing ( GtkWidget * widget , WPanel * panel )
{
1999-01-19 00:56:59 +03:00
if ( GTK_TOGGLE_BUTTON ( widget ) - > active = = FALSE )
return ;
1999-01-03 01:06:00 +03:00
if ( panel - > list_type = = list_brief )
return ;
panel - > list_type = list_brief ;
set_panel_formats ( panel ) ;
1999-01-04 10:29:48 +03:00
panel_update_contents ( panel ) ;
1999-01-03 01:06:00 +03:00
}
1999-01-04 10:29:48 +03:00
1999-01-03 01:06:00 +03:00
static void
do_switch_to_full_listing ( GtkWidget * widget , WPanel * panel )
1998-05-12 08:26:21 +04:00
{
1999-01-19 00:56:59 +03:00
if ( GTK_TOGGLE_BUTTON ( widget ) - > active = = FALSE )
return ;
1999-01-03 01:06:00 +03:00
if ( panel - > list_type = = list_full )
1998-05-12 08:26:21 +04:00
return ;
1998-05-13 00:43:42 +04:00
panel - > list_type = list_full ;
set_panel_formats ( panel ) ;
1999-01-04 10:29:48 +03:00
panel_update_contents ( panel ) ;
1998-05-12 08:26:21 +04:00
}
1999-01-04 10:29:48 +03:00
1999-01-03 01:06:00 +03:00
static void
do_switch_to_custom_listing ( GtkWidget * widget , WPanel * panel )
{
1999-01-19 00:56:59 +03:00
if ( GTK_TOGGLE_BUTTON ( widget ) - > active = = FALSE )
return ;
1999-01-03 01:06:00 +03:00
if ( panel - > list_type = = list_user )
return ;
panel - > list_type = list_user ;
set_panel_formats ( panel ) ;
1999-01-04 10:29:48 +03:00
panel_update_contents ( panel ) ;
1999-01-03 01:06:00 +03:00
}
1998-05-12 08:26:21 +04:00
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-01-19 00:25:55 +03:00
static GnomeUIInfo viewbar [ ] = {
1999-01-19 00:56:59 +03:00
{ GNOME_APP_UI_ITEM , N_ ( " Icon " ) , N_ ( " Switch view to an Icon view " ) , do_switch_to_iconic , NULL , NULL , \
1999-01-19 00:25:55 +03:00
GNOME_APP_PIXMAP_DATA , listing_iconic_xpm , 0 , ( GdkModifierType ) 0 , NULL } ,
1999-01-19 00:56:59 +03:00
{ GNOME_APP_UI_ITEM , N_ ( " Brief " ) , N_ ( " Switch view to show just file name and type " ) , do_switch_to_brief_listing , NULL , NULL , \
1999-01-19 00:25:55 +03:00
GNOME_APP_PIXMAP_DATA , listing_brief_list_xpm , 0 , ( GdkModifierType ) 0 , NULL } ,
1999-01-19 00:56:59 +03:00
{ GNOME_APP_UI_ITEM , N_ ( " Detailed " ) , N_ ( " Switch view to show detailed file statistics " ) , do_switch_to_full_listing , NULL , NULL , \
1999-01-19 00:25:55 +03:00
GNOME_APP_PIXMAP_DATA , listing_list_xpm , 0 , ( GdkModifierType ) 0 , NULL } ,
1999-01-20 05:16:09 +03:00
{ GNOME_APP_UI_ITEM , N_ ( " Custom " ) , N_ ( " Switch view to show custom determined statistics. You can set this in the " ) , do_switch_to_custom_listing , NULL , NULL , \
1999-01-19 00:25:55 +03:00
GNOME_APP_PIXMAP_DATA , listing_custom_xpm , 0 , ( GdkModifierType ) 0 , NULL } ,
GNOMEUIINFO_END
} ;
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 ,
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 ,
GNOMEUIINFO_RADIOLIST ( viewbar ) ,
GNOMEUIINFO_END
} ;
static void
do_ui_signal_connect ( GnomeUIInfo * uiinfo , gchar * signal_name ,
GnomeUIBuilderData * uibdata )
{
if ( uiinfo - > moreinfo )
gtk_signal_connect ( GTK_OBJECT ( uiinfo - > widget ) ,
signal_name , uiinfo - > moreinfo , uibdata - > data ?
uibdata - > data : uiinfo - > user_data ) ;
}
1998-05-12 08:26:21 +04:00
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 )
{
1998-11-28 03:01:38 +03:00
GtkWidget * status_line , * filter , * vbox , * ministatus_box ;
1999-01-20 05:16:09 +03:00
GtkWidget * cwd ;
1998-12-30 03:32:41 +03:00
GtkWidget * hbox , * evbox , * dock , * box ;
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 ) ;
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 ) ;
1998-10-21 05:09:50 +04:00
panel - > scrollbar = gtk_vscrollbar_new ( GNOME_ICON_LIST ( panel - > icons ) - > adj ) ;
gtk_widget_show ( panel - > scrollbar ) ;
1998-12-12 02:10:15 +03:00
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 ) ;
1998-12-30 03:32:41 +03:00
box = gtk_hbox_new ( FALSE , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( box ) , panel - > icons , TRUE , TRUE , 0 ) ;
gtk_box_pack_end ( GTK_BOX ( box ) , panel - > scrollbar , FALSE , TRUE , 0 ) ;
1999-01-04 10:29:48 +03:00
gtk_widget_show ( box ) ;
panel - > panel_listbox = gtk_event_box_new ( ) ;
gtk_widget_show ( panel - > panel_listbox ) ;
gtk_container_add ( GTK_CONTAINER ( panel - > panel_listbox ) , panel - > list ) ;
1998-02-27 07:54:42 +03:00
1999-01-04 10:29:48 +03:00
1998-12-30 03:32:41 +03:00
gtk_notebook_append_page ( GTK_NOTEBOOK ( panel - > notebook ) , box , NULL ) ;
1999-01-04 10:29:48 +03:00
gtk_notebook_append_page ( GTK_NOTEBOOK ( panel - > notebook ) , panel - > panel_listbox , NULL ) ;
1998-12-30 03:32:41 +03:00
gtk_notebook_set_page ( GTK_NOTEBOOK ( panel - > notebook ) , panel - > list_type = = list_icons ? 0 : 1 ) ;
gtk_widget_show_all ( box ) ;
gtk_widget_show ( panel - > list ) ;
gtk_widget_show ( panel - > notebook ) ;
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 ) ;
1998-11-29 10:50:44 +03:00
/*
* Filter
*/
1998-03-24 08:25:56 +03:00
filter = panel_create_filter ( h , panel , & panel - > filter_w ) ;
1998-11-29 10:50:44 +03:00
/*
* Current Working directory
*/
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-03-24 08:25:56 +03:00
/* We do not want the focus by default (and the previos add_widget just gave it to us) */
h - > current = h - > current - > prev ;
1999-01-19 00:25:55 +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 ) ;
panel - > back_b = toolbar [ 0 ] . widget ;
panel - > up_b = toolbar [ 1 ] . widget ;
panel - > fwd_b = toolbar [ 2 ] . widget ;
panel_update_marks ( panel ) ;
1999-01-20 05:16:09 +03:00
if ( panel - > list_type = = list_brief )
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( viewbar [ 1 ] . widget ) , TRUE ) ;
else if ( panel - > list_type = = list_full )
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( viewbar [ 2 ] . widget ) , TRUE ) ;
else if ( panel - > list_type = = list_user )
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( viewbar [ 3 ] . widget ) , TRUE ) ;
1998-12-11 09:48:21 +03:00
/*
1999-01-19 00:25:55 +03:00
* Here we make the view buttons .
1998-12-11 09:48:21 +03:00
*/
status_line = gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL , GTK_TOOLBAR_BOTH ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( status_line ) , 3 ) ;
evbox = gtk_event_box_new ( ) ;
hbox = gtk_hbox_new ( FALSE , 2 ) ;
gtk_container_add ( GTK_CONTAINER ( evbox ) , hbox ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
evbox ,
NULL , NULL ) ;
1999-01-19 00:25:55 +03:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , gtk_label_new ( _ ( " Location: " ) ) , FALSE , FALSE , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , cwd , FALSE , FALSE , 0 ) ;
dock = gnome_dock_item_new ( " gmc-toolbar1 " , GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL ) ;
gtk_container_add ( GTK_CONTAINER ( dock ) , status_line ) ;
gnome_dock_add_item ( GNOME_DOCK ( GNOME_APP ( panel - > xwindow ) - > dock ) ,
GNOME_DOCK_ITEM ( dock ) , GNOME_DOCK_TOP , 1 , 0 , 0 , FALSE ) ;
gtk_widget_show_all ( dock ) ;
#if 0
status_line = gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL , GTK_TOOLBAR_BOTH ) ;
1998-12-11 09:48:21 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
panel - > back_b ,
1999-01-14 04:10:32 +03:00
" Go to the previous directory " , NULL ) ;
1998-12-11 09:48:21 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
panel - > up_b ,
1999-01-14 04:10:32 +03:00
" Go up a level in the directory heirarchy " , NULL ) ;
1998-12-11 09:48:21 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
panel - > fwd_b ,
1999-01-14 04:10:32 +03:00
" Go to the next directory " , NULL ) ;
1998-12-11 09:48:21 +03:00
gtk_toolbar_append_space ( GTK_TOOLBAR ( status_line ) ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
button_switch_to_icon ( panel ) ,
1999-01-14 04:10:32 +03:00
" Icon view " , NULL ) ;
1999-01-03 01:06:00 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
button_switch_to_brief_listing ( panel ) ,
1999-01-14 04:10:32 +03:00
" Brief view " , NULL ) ;
1999-01-03 01:06:00 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
button_switch_to_full_listing ( panel ) ,
1999-01-14 04:10:32 +03:00
" Detailed view " , NULL ) ;
1998-12-11 09:48:21 +03:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( status_line ) ,
1999-01-03 01:06:00 +03:00
button_switch_to_custom_listing ( panel ) ,
1999-01-14 04:10:32 +03:00
" Custom view " , NULL ) ;
1999-01-19 00:25:55 +03:00
gnome_app_add_toolbar ( GNOME_APP ( panel - > xwindow ) ,
GTK_TOOLBAR ( status_line ) ,
" gmc-toolbar2 " ,
GNOME_DOCK_ITEM_BEH_EXCLUSIVE ,
GNOME_DOCK_TOP ,
2 , 0 , 0 ) ;
gtk_widget_show_all ( status_line ) ;
# endif
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 ) ;
gtk_frame_set_shadow_type ( GTK_FRAME ( ministatus_box ) , GTK_SHADOW_IN ) ;
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-01-07 09:53:31 +03:00
gtk_box_pack_start ( GTK_BOX ( panel - > ministatus ) , ministatus_box , FALSE , FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( ministatus_box ) , panel - > status ) ;
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-12-11 09:48:21 +03:00
#if 0
1998-03-05 07:53:47 +03:00
gtk_table_attach ( GTK_TABLE ( panel - > table ) , status_line , 0 , 1 , 0 , 1 ,
1998-02-27 07:54:42 +03:00
GTK_EXPAND | GTK_FILL , GTK_SHRINK , 0 , 0 ) ;
1998-12-11 09:48:21 +03:00
# endif
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
1998-05-05 00:25:27 +04:00
if ( ! ( panel - > widget . options & W_PANEL_HIDDEN ) )
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 ;
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
{
static char buffer [ 20 ] ;
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 {
sprintf ( buffer , " %ith Panel " , num ) ;
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 ) ;
free ( hint ) ;
} 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 ;
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 ) ) ;
}