1998-04-17 04:21:53 +04:00
|
|
|
/*
|
|
|
|
* Various Menu-invoked Command implementations specific to the GNOME port
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 the Free Software Foundation
|
|
|
|
*
|
|
|
|
* Author: Miguel de Icaza (miguel@kernel.org)
|
|
|
|
*/
|
1998-03-13 20:28:06 +03:00
|
|
|
#include <config.h>
|
|
|
|
#include "x.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include "dir.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "gscreen.h"
|
|
|
|
#include "main.h"
|
1998-04-17 04:59:58 +04:00
|
|
|
#include "gmain.h"
|
1998-03-13 20:28:06 +03:00
|
|
|
#include "cmd.h"
|
|
|
|
#include "boxes.h"
|
1999-01-06 03:33:40 +03:00
|
|
|
#include "profile.h"
|
|
|
|
#include "setup.h"
|
1998-03-13 20:28:06 +03:00
|
|
|
#include "panelize.h"
|
|
|
|
#include "gcmd.h"
|
1998-03-25 08:16:00 +03:00
|
|
|
#include "dialog.h"
|
1998-04-17 04:59:58 +04:00
|
|
|
#include "layout.h"
|
1999-03-19 20:13:33 +03:00
|
|
|
#include "gdesktop.h"
|
1999-09-02 22:31:17 +04:00
|
|
|
#include "gmain.h"
|
2000-06-16 22:16:44 +04:00
|
|
|
#include "file.h"
|
1998-12-11 06:18:41 +03:00
|
|
|
#include "../vfs/vfs.h"
|
1998-03-13 20:28:06 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
static char *panelize_section = "Panelize";
|
1998-12-30 03:19:46 +03:00
|
|
|
|
1998-03-13 20:28:06 +03:00
|
|
|
void
|
|
|
|
gnome_listing_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
int view_type, use_msformat;
|
|
|
|
char *user, *status;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-03-13 20:28:06 +03:00
|
|
|
view_type = display_box (panel, &user, &status, &use_msformat, get_current_index ());
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-03-13 20:28:06 +03:00
|
|
|
if (view_type == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
configure_panel_listing (panel, view_type, use_msformat, user, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_compare_panels (void)
|
|
|
|
{
|
|
|
|
if (get_other_panel () == NULL){
|
1998-03-25 08:16:00 +03:00
|
|
|
message (1, MSG_ERROR, _(" There is no other panel to compare contents to "));
|
1998-03-13 20:28:06 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
compare_dirs_cmd ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-02-16 00:19:03 +03:00
|
|
|
gnome_open_terminal_with_cmd (const char *command)
|
1998-03-13 20:28:06 +03:00
|
|
|
{
|
1998-04-17 04:21:53 +04:00
|
|
|
char *p;
|
1999-03-10 04:22:30 +03:00
|
|
|
int quote_all = 0;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-03-10 04:22:30 +03:00
|
|
|
if (!(p = gnome_is_program_in_path ("gnome-terminal"))){
|
1998-04-17 04:21:53 +04:00
|
|
|
if (!(p = gnome_is_program_in_path ("dtterm")))
|
|
|
|
if (!(p = gnome_is_program_in_path ("nxterm")))
|
|
|
|
if (!(p = gnome_is_program_in_path ("color-xterm")))
|
|
|
|
if (!(p = gnome_is_program_in_path ("rxvt")))
|
|
|
|
p = gnome_is_program_in_path ("xterm");
|
1999-03-10 04:22:30 +03:00
|
|
|
} else
|
|
|
|
quote_all = 1;
|
1998-04-17 04:21:53 +04:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
if (p){
|
|
|
|
if (command){
|
|
|
|
char *q;
|
1999-03-10 04:22:30 +03:00
|
|
|
|
|
|
|
if (quote_all)
|
|
|
|
q = g_strconcat (p, " -e '", command, "'", NULL);
|
|
|
|
else
|
|
|
|
q = g_strconcat (p, " -e ", command, NULL);
|
1999-02-16 00:19:03 +03:00
|
|
|
my_system (EXECUTE_AS_SHELL, shell, q);
|
|
|
|
g_free (q);
|
|
|
|
} else
|
|
|
|
my_system (EXECUTE_AS_SHELL, shell, p);
|
|
|
|
|
|
|
|
g_free (p);
|
|
|
|
} else
|
2000-04-18 12:55:59 +04:00
|
|
|
message (1, MSG_ERROR, _(" Could not start a terminal "));
|
1998-03-13 20:28:06 +03:00
|
|
|
}
|
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
void
|
|
|
|
gnome_open_terminal (void)
|
|
|
|
{
|
|
|
|
gnome_open_terminal_with_cmd (NULL);
|
|
|
|
}
|
|
|
|
|
1998-03-13 20:28:06 +03:00
|
|
|
void
|
|
|
|
gnome_about_cmd (void)
|
|
|
|
{
|
|
|
|
GtkWidget *about;
|
1999-04-02 01:31:55 +04:00
|
|
|
static int translated;
|
1999-08-01 15:37:25 +04:00
|
|
|
static const gchar *authors[] = {
|
1999-04-02 01:31:55 +04:00
|
|
|
N_("The Midnight Commander Team"),
|
1998-09-18 22:21:47 +04:00
|
|
|
"http://www.gnome.org/mc/",
|
1999-04-02 01:31:55 +04:00
|
|
|
N_("bug reports: http://bugs.gnome.org, or use gnome-bug"),
|
1998-03-13 20:28:06 +03:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
1999-04-02 01:31:55 +04:00
|
|
|
if (!translated){
|
|
|
|
int i;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-04-02 01:31:55 +04:00
|
|
|
for (i = 0; authors [i]; i++)
|
|
|
|
authors [i] = _(authors [i]);
|
|
|
|
translated = TRUE;
|
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-03-13 20:28:06 +03:00
|
|
|
about = gnome_about_new (_("GNU Midnight Commander"), VERSION,
|
1999-02-03 14:23:33 +03:00
|
|
|
"Copyright 1994-1999 the Free Software Foundation",
|
1998-03-13 20:28:06 +03:00
|
|
|
authors,
|
|
|
|
_("The GNOME edition of the Midnight Commander file manager."),
|
|
|
|
NULL);
|
|
|
|
gtk_widget_show (about);
|
|
|
|
}
|
|
|
|
|
1998-03-23 20:49:04 +03:00
|
|
|
void
|
|
|
|
gnome_open_panel (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
new_panel_at (panel->cwd);
|
|
|
|
}
|
1998-04-16 06:45:53 +04:00
|
|
|
|
1999-02-10 04:50:08 +03:00
|
|
|
void
|
1998-04-16 06:45:53 +04:00
|
|
|
gnome_close_panel (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
Dlg_head *h = panel->widget.parent;
|
1998-12-15 09:35:51 +03:00
|
|
|
if (panel->timer_id){
|
|
|
|
gtk_timeout_remove (panel->timer_id);
|
|
|
|
panel->timer_id = -1;
|
|
|
|
}
|
1999-02-10 04:50:08 +03:00
|
|
|
|
1998-04-16 06:45:53 +04:00
|
|
|
/* Remove the widgets from the dialog head */
|
|
|
|
remove_widget (h, panel->current_dir);
|
|
|
|
remove_widget (h, panel);
|
|
|
|
|
1999-04-05 09:39:26 +04:00
|
|
|
/* Free our own internal stuff */
|
|
|
|
g_free (panel->view_menu_items);
|
|
|
|
g_free (panel->view_toolbar_items);
|
|
|
|
|
|
|
|
/* Kill the widgets */
|
1998-04-16 06:45:53 +04:00
|
|
|
destroy_widget (panel->current_dir);
|
1999-02-10 04:50:08 +03:00
|
|
|
destroy_widget ((Widget *)panel);
|
1998-04-16 06:45:53 +04:00
|
|
|
|
1998-04-17 04:21:53 +04:00
|
|
|
layout_panel_gone (panel);
|
1998-12-11 05:58:48 +03:00
|
|
|
mc_chdir ("/");
|
1998-04-16 06:45:53 +04:00
|
|
|
}
|
1998-12-15 09:35:51 +03:00
|
|
|
|
1999-03-12 01:17:36 +03:00
|
|
|
static void
|
1999-09-21 09:50:22 +04:00
|
|
|
set_list_type (GtkWidget *widget, WPanel *panel, enum list_types type)
|
1998-12-30 03:19:46 +03:00
|
|
|
{
|
1999-03-12 01:17:36 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* This is kind of a hack to see whether we need to do something or not.
|
|
|
|
* This function (or at least the callback that calls it) can refer to a
|
|
|
|
* radio menu item or a radio button, so we need to see if it is active.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (GTK_OBJECT_TYPE (widget) == gtk_radio_menu_item_get_type ()) {
|
|
|
|
if (!GTK_CHECK_MENU_ITEM (widget)->active)
|
|
|
|
return;
|
|
|
|
} else if (GTK_OBJECT_TYPE (widget) == gtk_radio_button_get_type ()) {
|
|
|
|
if (!GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
/* Worth the effort? */
|
|
|
|
|
|
|
|
if (panel->list_type == type)
|
1998-12-30 03:19:46 +03:00
|
|
|
return;
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-09-21 09:50:22 +04:00
|
|
|
/* Set the list type */
|
1999-03-12 01:17:36 +03:00
|
|
|
|
|
|
|
panel->list_type = type;
|
1998-12-30 03:19:46 +03:00
|
|
|
set_panel_formats (panel);
|
|
|
|
paint_panel (panel);
|
|
|
|
do_refresh ();
|
1999-03-12 01:17:36 +03:00
|
|
|
|
|
|
|
/* Synchronize the widgets */
|
|
|
|
|
1999-04-05 09:39:26 +04:00
|
|
|
for (i = 0; panel->view_menu_items[i] && panel->view_toolbar_items[i]; i++)
|
1999-03-12 01:17:36 +03:00
|
|
|
if (widget == panel->view_menu_items[i]) {
|
|
|
|
gtk_signal_handler_block_by_data (
|
|
|
|
GTK_OBJECT (panel->view_toolbar_items[i]), panel);
|
|
|
|
gtk_toggle_button_set_active (
|
|
|
|
GTK_TOGGLE_BUTTON (panel->view_toolbar_items[i]), TRUE);
|
|
|
|
gtk_signal_handler_unblock_by_data (
|
|
|
|
GTK_OBJECT (panel->view_toolbar_items[i]), panel);
|
|
|
|
return;
|
|
|
|
} else if (widget == panel->view_toolbar_items[i]) {
|
|
|
|
gtk_signal_handler_block_by_data (
|
|
|
|
GTK_OBJECT (panel->view_menu_items[i]), panel);
|
|
|
|
gtk_check_menu_item_set_active (
|
|
|
|
GTK_CHECK_MENU_ITEM (panel->view_menu_items[i]), TRUE);
|
|
|
|
gtk_signal_handler_unblock_by_data (
|
|
|
|
GTK_OBJECT (panel->view_menu_items[i]), panel);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
1998-12-30 03:19:46 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
void
|
1999-03-12 01:17:36 +03:00
|
|
|
gnome_icon_view_cmd (GtkWidget *widget, WPanel *panel)
|
1998-12-30 03:19:46 +03:00
|
|
|
{
|
1999-09-21 09:50:22 +04:00
|
|
|
set_list_type (widget, panel, list_icons);
|
1998-12-30 03:19:46 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
void
|
1999-03-12 01:17:36 +03:00
|
|
|
gnome_brief_view_cmd (GtkWidget *widget, WPanel *panel)
|
1998-12-30 03:19:46 +03:00
|
|
|
{
|
1999-09-21 09:50:22 +04:00
|
|
|
set_list_type (widget, panel, list_brief);
|
1999-03-12 01:17:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_detailed_view_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
1999-09-21 09:50:22 +04:00
|
|
|
set_list_type (widget, panel, list_full);
|
1998-12-30 03:19:46 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
void
|
|
|
|
gnome_custom_view_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
1999-09-21 09:50:22 +04:00
|
|
|
set_list_type (widget, panel, list_user);
|
1998-12-30 03:19:46 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-03 01:06:00 +03:00
|
|
|
static void
|
|
|
|
sort_callback (GtkWidget *menu_item, GtkWidget *cbox1)
|
|
|
|
{
|
|
|
|
if (gtk_object_get_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE") == SORT_NAME)
|
|
|
|
gtk_widget_set_sensitive (cbox1, TRUE);
|
|
|
|
else
|
|
|
|
gtk_widget_set_sensitive (cbox1, FALSE);
|
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
/* Returns a sort function based on its type */
|
1999-08-09 07:41:39 +04:00
|
|
|
sortfn *
|
1999-08-10 02:54:02 +04:00
|
|
|
sort_get_func_from_type (SortType type)
|
|
|
|
{
|
1999-08-09 07:41:39 +04:00
|
|
|
sortfn *sfn = NULL;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
switch (type) {
|
1999-08-10 02:54:02 +04:00
|
|
|
case SORT_NAME:
|
|
|
|
sfn = (sortfn *) sort_name;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_EXTENSION:
|
|
|
|
sfn = (sortfn *) sort_ext;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_ACCESS:
|
|
|
|
sfn = (sortfn *) sort_atime;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_MODIFY:
|
|
|
|
sfn = (sortfn *) sort_time;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_CHANGE:
|
|
|
|
sfn = (sortfn *) sort_ctime;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_SIZE:
|
|
|
|
sfn = (sortfn *) sort_size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
1999-08-09 07:41:39 +04:00
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-08-09 07:41:39 +04:00
|
|
|
return sfn;
|
|
|
|
}
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
void
|
|
|
|
gnome_sort_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *sort_box;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *omenu;
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menu_item;
|
1999-01-02 02:08:38 +03:00
|
|
|
GtkWidget *cbox1, *cbox2;
|
1999-01-08 00:40:50 +03:00
|
|
|
sortfn *sfn = NULL;
|
1998-12-30 03:19:46 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
sort_box = gnome_dialog_new (_("Sort By"), GNOME_STOCK_BUTTON_OK,
|
1998-12-30 03:19:46 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-23 23:43:36 +03:00
|
|
|
gmc_window_setup_from_panel (GNOME_DIALOG (sort_box), panel);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-03 01:06:00 +03:00
|
|
|
/* we define this up here so we can pass it in to our callback */
|
1999-03-29 03:11:52 +04:00
|
|
|
cbox1 = gtk_check_button_new_with_label (_("Ignore case sensitivity."));
|
1998-12-30 03:19:46 +03:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box)->vbox), hbox, FALSE, FALSE, 0);
|
1999-04-06 23:00:16 +04:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Sort files by ")), FALSE, FALSE, 0);
|
1998-12-30 03:19:46 +03:00
|
|
|
|
|
|
|
omenu = gtk_option_menu_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, FALSE, 0);
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Name"));
|
1999-01-02 02:08:38 +03:00
|
|
|
/* FIXME: we want to set the option menu to be the correct ordering. */
|
1998-12-30 03:19:46 +03:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_NAME);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("File Type"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_EXTENSION);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-01-02 02:08:38 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Size"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_SIZE);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-01-02 02:08:38 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Time Last Accessed"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_ACCESS);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-01-02 02:08:38 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Time Last Modified"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_MODIFY);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-01-02 02:08:38 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
menu_item = gtk_menu_item_new_with_label ( _("Time Last Changed"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_item);
|
1999-01-02 02:08:38 +03:00
|
|
|
gtk_object_set_data (GTK_OBJECT (menu_item), "SORT_ORDER_CODE", (gpointer) SORT_CHANGE);
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (sort_callback), cbox1);
|
1999-01-02 02:08:38 +03:00
|
|
|
|
1998-12-30 03:19:46 +03:00
|
|
|
gtk_widget_show_all (menu);
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (cbox1), panel->case_sensitive);
|
1998-12-30 03:19:46 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box)->vbox),
|
1999-01-02 02:08:38 +03:00
|
|
|
cbox1, FALSE, FALSE, 0);
|
1999-01-03 01:06:00 +03:00
|
|
|
|
1999-03-29 03:11:52 +04:00
|
|
|
cbox2 = gtk_check_button_new_with_label (_("Reverse the order."));
|
1999-01-03 01:06:00 +03:00
|
|
|
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (cbox2), panel->reverse);
|
1998-12-30 03:19:46 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box)->vbox),
|
1999-01-02 02:08:38 +03:00
|
|
|
cbox2, FALSE, FALSE, 0);
|
1998-12-30 03:19:46 +03:00
|
|
|
/* off to the races */
|
|
|
|
gtk_widget_show_all (GNOME_DIALOG (sort_box)->vbox);
|
1999-01-02 02:08:38 +03:00
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (sort_box))) {
|
|
|
|
case 0:
|
1999-08-09 07:41:39 +04:00
|
|
|
sfn = sort_get_func_from_type(
|
|
|
|
GPOINTER_TO_UINT(gtk_object_get_data (GTK_OBJECT
|
1999-01-02 02:08:38 +03:00
|
|
|
(GTK_OPTION_MENU
|
|
|
|
(omenu)->menu_item),
|
1999-08-09 07:41:39 +04:00
|
|
|
"SORT_ORDER_CODE")));
|
1999-01-02 02:08:38 +03:00
|
|
|
/* case sensitive */
|
1999-01-03 01:06:00 +03:00
|
|
|
panel->case_sensitive = GTK_TOGGLE_BUTTON (cbox1)->active;
|
|
|
|
/* Reverse order */
|
|
|
|
panel->reverse = GTK_TOGGLE_BUTTON (cbox2)->active;
|
|
|
|
|
1999-01-02 02:08:38 +03:00
|
|
|
panel_set_sort_order (panel, sfn);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
break;
|
1999-05-27 06:06:27 +04:00
|
|
|
default:
|
|
|
|
return;
|
1999-01-02 02:08:38 +03:00
|
|
|
}
|
|
|
|
gtk_widget_destroy (sort_box);
|
1998-12-30 03:19:46 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
typedef struct ep_dlg_data {
|
|
|
|
GtkWidget *ep_dlg;
|
|
|
|
GtkWidget *clist;
|
|
|
|
GtkWidget *entry;
|
1999-01-06 08:25:59 +03:00
|
|
|
GtkWidget *add_button;
|
1999-01-06 03:33:40 +03:00
|
|
|
GtkWidget *remove_button;
|
|
|
|
gboolean setting_text;
|
|
|
|
gint selected; /* if this is -1 then nothing is selected, otherwise, it's the row selected */
|
|
|
|
} ep_dlg_data;
|
|
|
|
|
1999-01-06 08:25:59 +03:00
|
|
|
static gchar *
|
1999-01-06 23:23:31 +03:00
|
|
|
get_nickname (gchar *text)
|
1999-01-06 08:25:59 +03:00
|
|
|
{
|
|
|
|
GtkWidget *dlg;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *label;
|
|
|
|
gchar *retval = NULL;
|
1999-05-27 06:06:27 +04:00
|
|
|
int destroy;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
dlg = gnome_dialog_new (_("Enter name."), GNOME_STOCK_BUTTON_OK,
|
1999-01-06 08:25:59 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
|
1999-01-06 08:25:59 +03:00
|
|
|
entry = gtk_entry_new ();
|
1999-01-06 23:23:31 +03:00
|
|
|
if (text)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), text);
|
1999-01-06 08:25:59 +03:00
|
|
|
label = gtk_label_new (_("Enter label for command:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox),
|
|
|
|
label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox),
|
|
|
|
entry, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (GNOME_DIALOG (dlg)->vbox);
|
1999-05-27 06:06:27 +04:00
|
|
|
destroy = TRUE;
|
1999-01-06 08:25:59 +03:00
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (dlg))) {
|
1999-05-27 06:06:27 +04:00
|
|
|
case -1:
|
|
|
|
destroy = FALSE;
|
|
|
|
break;
|
1999-01-06 08:25:59 +03:00
|
|
|
case 0:
|
|
|
|
retval = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
default:
|
|
|
|
}
|
1999-05-27 06:06:27 +04:00
|
|
|
if (destroy)
|
|
|
|
gtk_widget_destroy (dlg);
|
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
return retval;
|
1999-01-06 08:25:59 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
static void
|
|
|
|
ep_add_callback (GtkWidget *widget, ep_dlg_data *data)
|
|
|
|
{
|
1999-01-06 08:25:59 +03:00
|
|
|
gint i;
|
|
|
|
gchar *insert_tab[1];
|
1999-01-06 03:33:40 +03:00
|
|
|
|
1999-01-06 23:23:31 +03:00
|
|
|
insert_tab[0] = get_nickname (NULL);
|
1999-01-06 08:25:59 +03:00
|
|
|
if (insert_tab[0] == NULL)
|
|
|
|
return;
|
|
|
|
i = gtk_clist_append (GTK_CLIST (data->clist), insert_tab);
|
|
|
|
gtk_clist_set_row_data (GTK_CLIST (data->clist), i,
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (data->entry))));
|
|
|
|
g_free (insert_tab [0]);
|
|
|
|
data->selected = -1;
|
|
|
|
gtk_widget_set_sensitive (data->add_button, FALSE);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (data->entry), "");
|
1999-01-06 03:33:40 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
static void
|
|
|
|
ep_remove_callback (GtkWidget *widget, ep_dlg_data *data)
|
|
|
|
{
|
1999-01-06 08:25:59 +03:00
|
|
|
if (data->selected > -1) {
|
|
|
|
g_free (gtk_clist_get_row_data (GTK_CLIST (data->clist), data->selected));
|
|
|
|
gtk_clist_remove (GTK_CLIST (data->clist), data->selected);
|
|
|
|
data->selected = -1;
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (data->entry), "");
|
|
|
|
}
|
|
|
|
gtk_widget_set_sensitive (data->remove_button, FALSE);
|
1999-01-06 03:33:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ep_select_callback (GtkWidget *widget,
|
|
|
|
gint row,
|
|
|
|
gint column,
|
|
|
|
GdkEventButton *event,
|
|
|
|
ep_dlg_data *data)
|
|
|
|
{
|
1999-01-06 23:23:31 +03:00
|
|
|
if (event && event->type == GDK_2BUTTON_PRESS) {
|
|
|
|
gchar *nick;
|
|
|
|
|
|
|
|
gtk_clist_get_text (GTK_CLIST (widget), row, 0, &nick);
|
|
|
|
/* ugly but correct... (: */
|
|
|
|
nick = get_nickname (nick);
|
|
|
|
gtk_clist_set_text (GTK_CLIST (data->clist), row, 0, nick);
|
|
|
|
gtk_clist_select_row (GTK_CLIST (data->clist), row, 0);
|
|
|
|
} else {
|
|
|
|
data->setting_text = TRUE;
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (data->entry),
|
|
|
|
(gchar *) gtk_clist_get_row_data (GTK_CLIST (widget), row));
|
|
|
|
data->setting_text = FALSE;
|
|
|
|
data->selected = row;
|
|
|
|
gtk_widget_set_sensitive (data->remove_button, TRUE);
|
|
|
|
gtk_widget_set_sensitive (data->add_button, FALSE);
|
|
|
|
}
|
1999-01-06 03:33:40 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
static void
|
|
|
|
ep_text_changed_callback (GtkWidget *widget, ep_dlg_data *data)
|
|
|
|
{
|
|
|
|
if (data->setting_text)
|
|
|
|
/* we don't want to deselect text if we just clicked on something */
|
|
|
|
return;
|
|
|
|
if (data->selected > -1) {
|
|
|
|
gtk_clist_unselect_row (GTK_CLIST (data->clist), data->selected, 0);
|
|
|
|
data->selected = -1;
|
|
|
|
}
|
1999-01-06 08:25:59 +03:00
|
|
|
gtk_widget_set_sensitive (data->remove_button, FALSE);
|
|
|
|
gtk_widget_set_sensitive (data->add_button, TRUE);
|
1999-01-06 03:33:40 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
static void
|
|
|
|
load_settings (GtkCList *clist)
|
|
|
|
{
|
1999-01-06 08:53:32 +03:00
|
|
|
gchar *insert_tab[1];
|
1999-01-06 03:33:40 +03:00
|
|
|
void *profile_keys;
|
1999-01-06 08:53:32 +03:00
|
|
|
gchar *key, *value;
|
1999-01-06 03:33:40 +03:00
|
|
|
gint i = 0;
|
|
|
|
|
|
|
|
profile_keys = profile_init_iterator (panelize_section, profile_name);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
if (!profile_keys){
|
|
|
|
insert_tab[0] = _("Find all core files");
|
1999-01-06 23:23:31 +03:00
|
|
|
i = gtk_clist_insert (clist, i, insert_tab);
|
|
|
|
gtk_clist_set_row_data (clist, i, g_strdup ("find / -name core"));
|
1999-01-06 03:33:40 +03:00
|
|
|
insert_tab[0] = _("Find rejects after patching");
|
1999-01-06 23:23:31 +03:00
|
|
|
i = gtk_clist_insert (clist, i, insert_tab);
|
|
|
|
gtk_clist_set_row_data (clist, i, g_strdup ("find . -name \\*.rej -print"));
|
1999-01-06 03:33:40 +03:00
|
|
|
} else {
|
|
|
|
while (profile_keys) {
|
|
|
|
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
|
|
|
insert_tab[0] = key;
|
1999-01-06 23:23:31 +03:00
|
|
|
i = gtk_clist_insert (clist, i, insert_tab);
|
|
|
|
gtk_clist_set_row_data (clist, i, g_strdup (value));
|
1999-01-06 03:33:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-06 08:53:32 +03:00
|
|
|
static void
|
|
|
|
save_settings (GtkCList *clist)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
profile_clean_section (panelize_section, profile_name);
|
|
|
|
for (i = 0; i < GTK_CLIST (clist)->rows; i++) {
|
|
|
|
gtk_clist_get_text (GTK_CLIST (clist), i, 0, &text);
|
|
|
|
WritePrivateProfileString (panelize_section,
|
|
|
|
text,
|
|
|
|
(gchar *) gtk_clist_get_row_data (GTK_CLIST (clist), i),
|
|
|
|
profile_name);
|
|
|
|
}
|
|
|
|
sync_profiles ();
|
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-01-03 01:06:00 +03:00
|
|
|
void
|
|
|
|
gnome_external_panelize (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
1999-01-06 03:33:40 +03:00
|
|
|
ep_dlg_data *data;
|
1999-01-05 02:45:02 +03:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *sw;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1999-01-06 08:25:59 +03:00
|
|
|
gint i;
|
|
|
|
gchar *row_data;
|
1999-05-27 06:06:27 +04:00
|
|
|
int destroy;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
data = g_new0 (ep_dlg_data, 1);
|
|
|
|
data->setting_text = FALSE;
|
|
|
|
data->selected = -1;
|
1999-08-10 02:54:02 +04:00
|
|
|
data->ep_dlg = gnome_dialog_new (_("Run Command"), GNOME_STOCK_BUTTON_OK,
|
1999-01-05 02:45:02 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (data->ep_dlg), GTK_WIN_POS_MOUSE);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-05 02:45:02 +03:00
|
|
|
/* Frame 1 */
|
|
|
|
frame = gtk_frame_new (_("Preset Commands"));
|
1999-01-06 03:33:40 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (data->ep_dlg)->vbox),
|
1999-01-05 02:45:02 +03:00
|
|
|
frame, FALSE, FALSE, 0);
|
1999-01-06 03:33:40 +03:00
|
|
|
data->clist = gtk_clist_new (1);
|
|
|
|
load_settings (GTK_CLIST (data->clist));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (data->clist), "select_row", GTK_SIGNAL_FUNC (ep_select_callback), (gpointer) data);
|
1999-01-05 02:45:02 +03:00
|
|
|
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
|
1999-01-06 23:23:31 +03:00
|
|
|
gtk_clist_columns_autosize (GTK_CLIST (data->clist));
|
|
|
|
gtk_clist_set_auto_sort (GTK_CLIST (data->clist), TRUE);
|
1999-01-05 02:45:02 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
|
1999-01-06 03:33:40 +03:00
|
|
|
sw = gtk_scrolled_window_new (GTK_CLIST (data->clist)->hadjustment, GTK_CLIST (data->clist)->vadjustment);
|
1999-01-05 02:45:02 +03:00
|
|
|
gtk_widget_set_usize (sw, 300, 100);
|
1999-01-06 03:33:40 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (sw), data->clist);
|
1999-01-05 02:45:02 +03:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
1999-01-06 08:25:59 +03:00
|
|
|
data->add_button = gtk_button_new_with_label (_("Add"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (data->add_button), "clicked", GTK_SIGNAL_FUNC (ep_add_callback), (gpointer) data);
|
|
|
|
gtk_widget_set_usize (data->add_button, 75, 25);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), data->add_button, FALSE, FALSE, 0);
|
1999-01-06 03:33:40 +03:00
|
|
|
data->remove_button = gtk_button_new_with_label (_("Remove"));
|
|
|
|
gtk_widget_set_sensitive (data->remove_button, FALSE);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (data->remove_button), "clicked", GTK_SIGNAL_FUNC (ep_remove_callback), (gpointer) data);
|
|
|
|
gtk_widget_set_usize (data->remove_button, 75, 25);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), data->remove_button, FALSE, FALSE, 0);
|
1999-01-05 02:45:02 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* Frame 2 */
|
|
|
|
frame = gtk_frame_new (_("Run this Command"));
|
1999-01-06 03:33:40 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (data->ep_dlg)->vbox),
|
1999-01-05 02:45:02 +03:00
|
|
|
frame, FALSE, FALSE, 0);
|
1999-01-06 03:33:40 +03:00
|
|
|
data->entry = gtk_entry_new ();
|
|
|
|
gtk_signal_connect (GTK_OBJECT (data->entry), "changed", GTK_SIGNAL_FUNC (ep_text_changed_callback), (gpointer) data);
|
1999-01-05 02:45:02 +03:00
|
|
|
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Command: ")), FALSE, FALSE, 0);
|
1999-01-06 03:33:40 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), data->entry, TRUE, TRUE, 0);
|
1999-01-05 02:45:02 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
1999-01-06 03:33:40 +03:00
|
|
|
gtk_widget_show_all (GNOME_DIALOG (data->ep_dlg)->vbox);
|
1999-05-27 06:06:27 +04:00
|
|
|
|
|
|
|
destroy = TRUE;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (data->ep_dlg))) {
|
|
|
|
case 0:
|
1999-01-06 09:14:15 +03:00
|
|
|
gtk_widget_hide (data->ep_dlg);
|
|
|
|
while (gtk_events_pending () )
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
1999-01-06 03:33:40 +03:00
|
|
|
do_external_panelize (gtk_entry_get_text (GTK_ENTRY (data->entry)));
|
1999-01-06 08:53:32 +03:00
|
|
|
save_settings (GTK_CLIST (data->clist));
|
1999-01-06 03:33:40 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
1999-05-27 06:06:27 +04:00
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
destroy = FALSE;
|
|
|
|
break;
|
1999-01-06 03:33:40 +03:00
|
|
|
default:
|
|
|
|
}
|
1999-01-06 08:25:59 +03:00
|
|
|
for (i = 0; i < GTK_CLIST (data->clist)->rows; i++) {
|
|
|
|
row_data = gtk_clist_get_row_data (GTK_CLIST (data->clist), i);
|
|
|
|
if (row_data)
|
|
|
|
g_free (row_data);
|
|
|
|
}
|
1999-05-27 06:06:27 +04:00
|
|
|
|
|
|
|
if (destroy)
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (data->ep_dlg));
|
1999-01-06 03:33:40 +03:00
|
|
|
g_free (data);
|
1999-01-03 01:06:00 +03:00
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
2000-06-16 22:16:44 +04:00
|
|
|
|
|
|
|
static WPanel *
|
|
|
|
create_trash_panel (void)
|
|
|
|
{
|
|
|
|
WPanel *retval;
|
|
|
|
gchar *trash_dir;
|
|
|
|
|
|
|
|
is_trash_panel = TRUE;
|
|
|
|
trash_dir = g_strconcat (gnome_user_home_dir, "/",
|
|
|
|
DESKTOP_DIR_NAME, "/",
|
2001-04-13 05:03:22 +04:00
|
|
|
"Trash.gmc",
|
2000-06-16 22:16:44 +04:00
|
|
|
NULL);
|
|
|
|
retval = new_panel_at (trash_dir);
|
|
|
|
g_free (trash_dir);
|
|
|
|
is_trash_panel = FALSE;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_empty_trash (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
WPanel *trash_panel;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
trash_panel = create_trash_panel ();
|
|
|
|
for (i = 0; i < trash_panel->count; i++){
|
|
|
|
if (!strcmp (trash_panel->dir.list [i].fname, "..")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
do_file_mark (trash_panel, i, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
panel_operate (trash_panel, OP_DELETE, NULL, FALSE);
|
|
|
|
|
|
|
|
gnome_close_panel (NULL, trash_panel);
|
|
|
|
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
|
|
|
do_refresh ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-03 01:06:00 +03:00
|
|
|
void
|
|
|
|
gnome_select_all_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
for (i = 0; i < panel->count; i++){
|
1999-02-06 02:52:44 +03:00
|
|
|
if (!strcmp (panel->dir.list [i].fname, "..")) {
|
1999-01-03 01:06:00 +03:00
|
|
|
continue;
|
1999-02-06 02:52:44 +03:00
|
|
|
}
|
1999-01-03 01:06:00 +03:00
|
|
|
do_file_mark (panel, i, 1);
|
|
|
|
}
|
|
|
|
paint_panel (panel);
|
|
|
|
do_refresh ();
|
|
|
|
}
|
1999-03-12 01:17:36 +03:00
|
|
|
|
1999-04-07 05:33:04 +04:00
|
|
|
void
|
|
|
|
gnome_start_search (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
start_search (panel);
|
|
|
|
}
|
|
|
|
|
1999-02-06 02:52:44 +03:00
|
|
|
void
|
1999-08-13 23:42:32 +04:00
|
|
|
gnome_reverse_selection_cmd_panel (GtkWidget *widget, WPanel *panel)
|
1999-02-06 02:52:44 +03:00
|
|
|
{
|
1999-08-13 23:42:32 +04:00
|
|
|
file_entry *file;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < panel->count; i++) {
|
|
|
|
if (!strcmp (panel->dir.list [i].fname, ".."))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
file = &panel->dir.list [i];
|
|
|
|
do_file_mark (panel, i, !file->f.marked);
|
|
|
|
}
|
|
|
|
|
|
|
|
paint_panel (panel);
|
1999-02-06 02:52:44 +03:00
|
|
|
}
|
|
|
|
|
1999-01-07 09:53:31 +03:00
|
|
|
void
|
|
|
|
gnome_filter_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *filter_dlg;
|
|
|
|
GtkWidget *entry;
|
1999-01-08 00:40:50 +03:00
|
|
|
GtkWidget *label;
|
1999-01-08 07:19:25 +03:00
|
|
|
gchar *text1, *text2, *text3;
|
1999-01-08 00:40:50 +03:00
|
|
|
|
1999-08-10 02:54:02 +04:00
|
|
|
filter_dlg = gnome_dialog_new (_("Set Filter"), GNOME_STOCK_BUTTON_OK,
|
1999-01-08 00:40:50 +03:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
1999-01-23 23:43:36 +03:00
|
|
|
gtk_window_set_position (GTK_WINDOW (filter_dlg), GTK_WIN_POS_MOUSE);
|
1999-01-08 07:19:25 +03:00
|
|
|
if (easy_patterns) {
|
|
|
|
text1 = "mc_filter_globs";
|
|
|
|
text3 = _("Show all files");
|
|
|
|
if (panel->filter && (strcmp (panel->filter, "*")))
|
|
|
|
text2 = panel->filter;
|
|
|
|
else
|
|
|
|
text2 = NULL;
|
|
|
|
} else {
|
|
|
|
text1 = ("mc_filter_regexps");
|
|
|
|
text3 = _(".");
|
|
|
|
if (!panel->filter)
|
|
|
|
text2 = NULL;
|
|
|
|
else
|
|
|
|
text2 = panel->filter;
|
|
|
|
}
|
|
|
|
entry = gnome_entry_new (text1);
|
|
|
|
gnome_entry_load_history (GNOME_ENTRY (entry));
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-08 07:19:25 +03:00
|
|
|
if (text2) {
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))), text2);
|
|
|
|
gnome_entry_prepend_history (GNOME_ENTRY (entry), FALSE, text3);
|
|
|
|
} else
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))), text3);
|
|
|
|
|
1999-01-08 00:40:50 +03:00
|
|
|
if (easy_patterns)
|
1999-04-08 03:26:49 +04:00
|
|
|
label = gtk_label_new (_("Enter a filter here for files in the panel view.\n\nFor example:\n*.png will show just png images"));
|
1999-01-08 00:40:50 +03:00
|
|
|
else
|
|
|
|
label = gtk_label_new (_("Enter a Regular Expression to filter files in the panel view."));
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-08 00:40:50 +03:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (filter_dlg)->vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (filter_dlg)->vbox), entry, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (GNOME_DIALOG (filter_dlg)->vbox);
|
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (filter_dlg))) {
|
|
|
|
case 0:
|
|
|
|
gtk_widget_hide (filter_dlg);
|
|
|
|
if (panel->filter) {
|
|
|
|
g_free (panel->filter);
|
|
|
|
panel->filter = NULL;
|
|
|
|
}
|
1999-01-08 07:19:25 +03:00
|
|
|
panel->filter = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry)))));
|
|
|
|
if (!strcmp (_("Show all files"), panel->filter)) {
|
|
|
|
g_free (panel->filter);
|
|
|
|
panel->filter = NULL;
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))),
|
|
|
|
"");
|
|
|
|
gtk_label_set_text (GTK_LABEL (panel->status), _("Show all files"));
|
|
|
|
} else if (!strcmp ("*", panel->filter)) {
|
1999-01-08 00:40:50 +03:00
|
|
|
g_free (panel->filter);
|
|
|
|
panel->filter = NULL;
|
|
|
|
gtk_label_set_text (GTK_LABEL (panel->status), _("Show all files"));
|
|
|
|
} else
|
|
|
|
gtk_label_set_text (GTK_LABEL (panel->status), panel->filter);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-08 07:19:25 +03:00
|
|
|
gnome_entry_save_history (GNOME_ENTRY (entry));
|
1999-01-08 00:40:50 +03:00
|
|
|
x_filter_changed (panel);
|
1999-05-27 05:46:22 +04:00
|
|
|
reread_cmd ();
|
1999-01-08 00:40:50 +03:00
|
|
|
break;
|
1999-05-27 06:06:27 +04:00
|
|
|
|
|
|
|
case -1:
|
|
|
|
return;
|
1999-01-08 00:40:50 +03:00
|
|
|
}
|
|
|
|
gtk_widget_destroy (filter_dlg);
|
|
|
|
}
|
1999-01-16 06:01:35 +03:00
|
|
|
|
1999-01-13 00:50:25 +03:00
|
|
|
void
|
|
|
|
gnome_open_files (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
GList *later = NULL;
|
1999-01-14 04:10:32 +03:00
|
|
|
#if 0
|
1999-01-13 00:50:25 +03:00
|
|
|
GList *now;
|
1999-01-14 04:10:32 +03:00
|
|
|
#endif
|
1999-01-13 00:50:25 +03:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
/* FIXME: this is the easy way to do things. We want the
|
|
|
|
* hard way sometime. */
|
|
|
|
for (i = 0; i < panel->count; i++) {
|
|
|
|
if (panel->dir.list [i].f.marked)
|
|
|
|
if (!do_enter_on_file_entry ((panel->dir.list) + i))
|
|
|
|
later = g_list_prepend (later, panel->dir.list + i);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
/* This is sorta ugly. Should we just skip these? There should be a better way. */
|
|
|
|
for (now = later; now; now = now->next) {
|
|
|
|
gchar *command;
|
|
|
|
command = input_expand_dialog (_(" Open with..."),
|
|
|
|
_("Enter extra arguments:"), (WPanel *) now->data);
|
|
|
|
if (!command)
|
|
|
|
/* we break out. */
|
|
|
|
break;
|
|
|
|
execute (command);
|
1999-01-27 04:14:57 +03:00
|
|
|
g_free (command);
|
1999-01-13 00:50:25 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
g_list_free (later);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-01-13 00:50:25 +03:00
|
|
|
}
|
1999-01-16 06:01:35 +03:00
|
|
|
|
1999-01-14 03:39:03 +03:00
|
|
|
void
|
|
|
|
gnome_run_new (GtkWidget *widget, GnomeDesktopEntry *gde)
|
|
|
|
{
|
|
|
|
gnome_desktop_entry_launch (gde);
|
|
|
|
}
|
1999-01-16 06:01:35 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
gnome_mkdir_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
mkdir_cmd (panel);
|
|
|
|
}
|
1999-05-28 09:41:18 +04:00
|
|
|
|
1999-09-02 22:31:17 +04:00
|
|
|
void
|
|
|
|
gnome_newfile_cmd (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
mc_chdir (panel->cwd);
|
|
|
|
gmc_edit ("");
|
|
|
|
}
|
|
|
|
|
1999-03-19 20:13:33 +03:00
|
|
|
static void
|
|
|
|
dentry_apply_callback(GtkWidget *widget, int page, gpointer data)
|
|
|
|
{
|
|
|
|
GnomeDesktopEntry *dentry;
|
|
|
|
gchar *desktop_directory;
|
|
|
|
|
|
|
|
if (page != -1)
|
|
|
|
return;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-03-19 20:13:33 +03:00
|
|
|
g_return_if_fail(data!=NULL);
|
|
|
|
g_return_if_fail(GNOME_IS_DENTRY_EDIT(data));
|
|
|
|
dentry = gnome_dentry_get_dentry(GNOME_DENTRY_EDIT(data));
|
|
|
|
|
|
|
|
if (getenv ("GNOME_DESKTOP_DIR") != NULL)
|
|
|
|
desktop_directory = g_strconcat (getenv ("GNOME_DESKTOP_DIR"),
|
|
|
|
"/",
|
|
|
|
dentry->name, ".desktop",
|
|
|
|
NULL);
|
|
|
|
else
|
|
|
|
desktop_directory = g_strconcat (gnome_user_home_dir, "/",
|
|
|
|
DESKTOP_DIR_NAME, "/",
|
|
|
|
dentry->name, ".desktop",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dentry->location = desktop_directory;
|
|
|
|
gnome_desktop_entry_save(dentry);
|
|
|
|
gnome_desktop_entry_free(dentry);
|
|
|
|
gnome_config_sync ();
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_new_launcher (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkObject *dentry;
|
1999-01-16 06:01:35 +03:00
|
|
|
|
1999-03-19 20:13:33 +03:00
|
|
|
dialog = gnome_property_box_new ();
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Desktop entry properties"));
|
|
|
|
gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, TRUE);
|
|
|
|
dentry = gnome_dentry_edit_new_notebook(GTK_NOTEBOOK(GNOME_PROPERTY_BOX(dialog)->notebook));
|
|
|
|
gtk_signal_connect_object(GTK_OBJECT(dentry), "changed",
|
|
|
|
GTK_SIGNAL_FUNC(gnome_property_box_changed),
|
|
|
|
GTK_OBJECT(dialog));
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(dialog), "apply",
|
|
|
|
GTK_SIGNAL_FUNC(dentry_apply_callback),
|
|
|
|
dentry);
|
|
|
|
gtk_widget_show(dialog);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
1999-04-08 03:26:49 +04:00
|
|
|
void
|
|
|
|
gnome_select (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
char *reg_exp, *reg_exp_t;
|
|
|
|
int i;
|
|
|
|
int c;
|
|
|
|
int dirflag = 0;
|
|
|
|
GtkWidget *select_dialog;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *label;
|
1999-05-27 06:06:27 +04:00
|
|
|
int run;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
|
|
|
select_dialog = gnome_dialog_new (_("Select File"), GNOME_STOCK_BUTTON_OK,
|
1999-04-08 03:26:49 +04:00
|
|
|
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
|
|
|
gtk_window_set_position (GTK_WINDOW (select_dialog), GTK_WIN_POS_MOUSE);
|
|
|
|
entry = gnome_entry_new ("mc_select");
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))), easy_patterns ? "*" : ".");
|
|
|
|
gnome_entry_load_history (GNOME_ENTRY (entry));
|
|
|
|
|
|
|
|
if (easy_patterns)
|
|
|
|
label = gtk_label_new (_("Enter a filter here to select files in the panel view with.\n\nFor example:\n*.png will select all png images"));
|
|
|
|
else
|
|
|
|
label = gtk_label_new (_("Enter a regular expression here to select files in the panel view with."));
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-04-08 03:26:49 +04:00
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-04-08 03:26:49 +04:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (select_dialog)->vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (select_dialog)->vbox), entry, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show_all (GNOME_DIALOG (select_dialog)->vbox);
|
|
|
|
reg_exp = NULL;
|
1999-05-27 06:06:27 +04:00
|
|
|
run = gnome_dialog_run (GNOME_DIALOG (select_dialog));
|
|
|
|
if (run == 0) {
|
1999-04-08 03:26:49 +04:00
|
|
|
gtk_widget_hide (select_dialog);
|
|
|
|
reg_exp = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry)))));
|
|
|
|
}
|
1999-05-27 06:06:27 +04:00
|
|
|
if (run != -1)
|
|
|
|
gtk_widget_destroy (select_dialog);
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-04-08 03:26:49 +04:00
|
|
|
if ((reg_exp == NULL) || (*reg_exp == '\000')) {
|
|
|
|
g_free (reg_exp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
reg_exp_t = reg_exp;
|
|
|
|
|
|
|
|
/* Check if they specified a directory */
|
|
|
|
if (*reg_exp_t == PATH_SEP){
|
|
|
|
dirflag = 1;
|
|
|
|
reg_exp_t++;
|
|
|
|
}
|
|
|
|
if (reg_exp_t [strlen(reg_exp_t) - 1] == PATH_SEP){
|
|
|
|
dirflag = 1;
|
|
|
|
reg_exp_t [strlen(reg_exp_t) - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < panel->count; i++){
|
|
|
|
if (!strcmp (panel->dir.list [i].fname, ".."))
|
|
|
|
continue;
|
|
|
|
if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
|
|
|
|
if (!dirflag)
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
if (dirflag)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
c = regexp_match (reg_exp_t, panel->dir.list [i].fname, match_file);
|
|
|
|
if (c == -1){
|
|
|
|
message (1, MSG_ERROR, _(" Malformed regular expression "));
|
|
|
|
g_free (reg_exp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (c){
|
|
|
|
do_file_mark (panel, i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paint_panel (panel);
|
|
|
|
g_free (reg_exp);
|
|
|
|
}
|
1999-04-09 16:58:10 +04:00
|
|
|
void
|
|
|
|
set_cursor_busy (WPanel *panel)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
if (is_a_desktop_panel (panel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
cursor = gdk_cursor_new (GDK_WATCH);
|
|
|
|
gdk_window_set_cursor (GTK_WIDGET (panel->xwindow)->window, cursor);
|
|
|
|
gdk_cursor_destroy (cursor);
|
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
}
|
|
|
|
void
|
|
|
|
set_cursor_normal (WPanel *panel)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
if (is_a_desktop_panel (panel))
|
|
|
|
return;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
2001-04-15 13:39:24 +04:00
|
|
|
gdk_window_set_cursor (GTK_WIDGET (panel->xwindow)->window, NULL);
|
1999-04-09 16:58:10 +04:00
|
|
|
gdk_flush ();
|
|
|
|
}
|
1999-05-01 17:58:00 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
gnome_new_link (GtkWidget *widget, WPanel *panel)
|
|
|
|
{
|
|
|
|
char *template;
|
|
|
|
char *url;
|
|
|
|
|
|
|
|
url = input_expand_dialog (_("Creating a desktop link"),
|
|
|
|
_("Enter the URL:"), "");
|
|
|
|
if (!url)
|
|
|
|
return;
|
1999-08-10 02:54:02 +04:00
|
|
|
|
1999-05-01 17:58:00 +04:00
|
|
|
template = g_concat_dir_and_file (desktop_directory, "urlXXXXXX");
|
|
|
|
|
|
|
|
if (mktemp (template)) {
|
|
|
|
char *icon;
|
|
|
|
|
|
|
|
icon = g_concat_dir_and_file (ICONDIR, "gnome-http-url.png");
|
|
|
|
desktop_create_url (template, url, url, icon);
|
|
|
|
g_free (icon);
|
|
|
|
}
|
|
|
|
g_free (template);
|
|
|
|
g_free (url);
|
|
|
|
}
|