2 * Various Menu-invoked Command implementations specific to the GNOME port
4 * Copyright (C) 1998 the Free Software Foundation
6 * Author: Miguel de Icaza (miguel@kernel.org)
28 #include "../vfs/vfs.h"
30 static char *panelize_section
= "Panelize";
33 gnome_open_terminal_with_cmd (const char *command
)
38 if (!(p
= gnome_is_program_in_path ("gnome-terminal"))){
39 if (!(p
= gnome_is_program_in_path ("dtterm")))
40 if (!(p
= gnome_is_program_in_path ("nxterm")))
41 if (!(p
= gnome_is_program_in_path ("color-xterm")))
42 if (!(p
= gnome_is_program_in_path ("rxvt")))
43 p
= gnome_is_program_in_path ("xterm");
52 q
= g_strconcat (p
, " --start-factory-server --use-factory -e '", command
, "'", NULL
);
54 q
= g_strconcat (p
, " -e ", command
, NULL
);
55 my_system (EXECUTE_AS_SHELL
, shell
, q
);
58 my_system (EXECUTE_AS_SHELL
, shell
, p
);
62 message (1, MSG_ERROR
, _(" Could not start a terminal "));
66 gnome_open_terminal (void)
68 gnome_open_terminal_with_cmd (NULL
);
72 gnome_about_cmd (void)
75 static int translated
;
76 static const gchar
*authors
[] = {
77 N_("The Midnight Commander Team"),
78 "http://www.gnome.org/mc/",
79 N_("bug reports: http://bugs.gnome.org, or use gnome-bug"),
86 for (i
= 0; authors
[i
]; i
++)
87 authors
[i
] = _(authors
[i
]);
91 about
= gnome_about_new (_("GNU Midnight Commander"), VERSION
,
92 "Copyright 1994-1999 the Free Software Foundation",
94 _("The GNOME edition of the Midnight Commander file manager."),
96 gtk_widget_show (about
);
100 gnome_open_panel (GtkWidget
*widget
, WPanel
*panel
)
102 new_panel_at (panel
->cwd
);
106 gnome_close_panel (GtkWidget
*widget
, WPanel
*panel
)
108 Dlg_head
*h
= panel
->widget
.parent
;
109 if (panel
->timer_id
){
110 gtk_timeout_remove (panel
->timer_id
);
111 panel
->timer_id
= -1;
114 /* Remove the widgets from the dialog head */
115 remove_widget (h
, panel
->current_dir
);
116 remove_widget (h
, panel
);
118 /* Free our own internal stuff */
119 g_free (panel
->view_menu_items
);
120 g_free (panel
->view_toolbar_items
);
122 /* Kill the widgets */
123 destroy_widget (panel
->current_dir
);
124 destroy_widget ((Widget
*)panel
);
126 layout_panel_gone (panel
);
131 set_list_type (GtkWidget
*widget
, WPanel
*panel
, enum list_types type
)
135 /* This is kind of a hack to see whether we need to do something or not.
136 * This function (or at least the callback that calls it) can refer to a
137 * radio menu item or a radio button, so we need to see if it is active.
140 if (GTK_OBJECT_TYPE (widget
) == gtk_radio_menu_item_get_type ()) {
141 if (!GTK_CHECK_MENU_ITEM (widget
)->active
)
143 } else if (GTK_OBJECT_TYPE (widget
) == gtk_radio_button_get_type ()) {
144 if (!GTK_TOGGLE_BUTTON (widget
)->active
)
147 g_assert_not_reached ();
149 /* Worth the effort? */
151 if (panel
->list_type
== type
)
154 /* Set the list type */
156 panel
->list_type
= type
;
157 set_panel_formats (panel
);
161 /* Synchronize the widgets */
163 for (i
= 0; panel
->view_menu_items
[i
] && panel
->view_toolbar_items
[i
]; i
++)
164 if (widget
== panel
->view_menu_items
[i
]) {
165 gtk_signal_handler_block_by_data (
166 GTK_OBJECT (panel
->view_toolbar_items
[i
]), panel
);
167 gtk_toggle_button_set_active (
168 GTK_TOGGLE_BUTTON (panel
->view_toolbar_items
[i
]), TRUE
);
169 gtk_signal_handler_unblock_by_data (
170 GTK_OBJECT (panel
->view_toolbar_items
[i
]), panel
);
172 } else if (widget
== panel
->view_toolbar_items
[i
]) {
173 gtk_signal_handler_block_by_data (
174 GTK_OBJECT (panel
->view_menu_items
[i
]), panel
);
175 gtk_check_menu_item_set_active (
176 GTK_CHECK_MENU_ITEM (panel
->view_menu_items
[i
]), TRUE
);
177 gtk_signal_handler_unblock_by_data (
178 GTK_OBJECT (panel
->view_menu_items
[i
]), panel
);
182 g_assert_not_reached ();
186 gnome_icon_view_cmd (GtkWidget
*widget
, WPanel
*panel
)
188 set_list_type (widget
, panel
, list_icons
);
192 gnome_brief_view_cmd (GtkWidget
*widget
, WPanel
*panel
)
194 set_list_type (widget
, panel
, list_brief
);
198 gnome_detailed_view_cmd (GtkWidget
*widget
, WPanel
*panel
)
200 set_list_type (widget
, panel
, list_full
);
204 gnome_custom_view_cmd (GtkWidget
*widget
, WPanel
*panel
)
206 set_list_type (widget
, panel
, list_user
);
210 sort_callback (GtkWidget
*menu_item
, GtkWidget
*cbox1
)
212 if (gtk_object_get_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE") == SORT_NAME
)
213 gtk_widget_set_sensitive (cbox1
, TRUE
);
215 gtk_widget_set_sensitive (cbox1
, FALSE
);
218 /* Returns a sort function based on its type */
220 sort_get_func_from_type (SortType type
)
226 sfn
= (sortfn
*) sort_name
;
230 sfn
= (sortfn
*) sort_ext
;
234 sfn
= (sortfn
*) sort_atime
;
238 sfn
= (sortfn
*) sort_time
;
242 sfn
= (sortfn
*) sort_ctime
;
246 sfn
= (sortfn
*) sort_size
;
250 g_assert_not_reached ();
257 gnome_sort_cmd (GtkWidget
*widget
, WPanel
*panel
)
263 GtkWidget
*menu_item
;
264 GtkWidget
*cbox1
, *cbox2
;
267 sort_box
= gnome_dialog_new (_("Sort By"), GNOME_STOCK_BUTTON_OK
,
268 GNOME_STOCK_BUTTON_CANCEL
, NULL
);
269 gmc_window_setup_from_panel (GNOME_DIALOG (sort_box
), panel
);
271 /* we define this up here so we can pass it in to our callback */
272 cbox1
= gtk_check_button_new_with_label (_("Ignore case sensitivity."));
273 hbox
= gtk_hbox_new (FALSE
, 0);
274 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box
)->vbox
), hbox
, FALSE
, FALSE
, 0);
275 gtk_box_pack_start (GTK_BOX (hbox
), gtk_label_new (_("Sort files by ")), FALSE
, FALSE
, 0);
277 omenu
= gtk_option_menu_new ();
278 gtk_box_pack_start (GTK_BOX (hbox
), omenu
, FALSE
, FALSE
, 0);
279 menu
= gtk_menu_new ();
280 menu_item
= gtk_menu_item_new_with_label ( _("Name"));
281 /* FIXME: we want to set the option menu to be the correct ordering. */
282 gtk_menu_append (GTK_MENU (menu
), menu_item
);
283 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_NAME
);
284 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
285 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
287 menu_item
= gtk_menu_item_new_with_label ( _("File Type"));
288 gtk_menu_append (GTK_MENU (menu
), menu_item
);
289 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_EXTENSION
);
290 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
291 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
293 menu_item
= gtk_menu_item_new_with_label ( _("Size"));
294 gtk_menu_append (GTK_MENU (menu
), menu_item
);
295 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_SIZE
);
296 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
297 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
299 menu_item
= gtk_menu_item_new_with_label ( _("Time Last Accessed"));
300 gtk_menu_append (GTK_MENU (menu
), menu_item
);
301 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_ACCESS
);
302 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
303 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
305 menu_item
= gtk_menu_item_new_with_label ( _("Time Last Modified"));
306 gtk_menu_append (GTK_MENU (menu
), menu_item
);
307 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_MODIFY
);
308 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
309 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
311 menu_item
= gtk_menu_item_new_with_label ( _("Time Last Changed"));
312 gtk_menu_append (GTK_MENU (menu
), menu_item
);
313 gtk_object_set_data (GTK_OBJECT (menu_item
), "SORT_ORDER_CODE", (gpointer
) SORT_CHANGE
);
314 gtk_signal_connect (GTK_OBJECT (menu_item
), "activate",
315 GTK_SIGNAL_FUNC (sort_callback
), cbox1
);
317 gtk_widget_show_all (menu
);
318 gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu
), menu
);
321 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (cbox1
), panel
->case_sensitive
);
322 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box
)->vbox
),
323 cbox1
, FALSE
, FALSE
, 0);
325 cbox2
= gtk_check_button_new_with_label (_("Reverse the order."));
326 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (cbox2
), panel
->reverse
);
327 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (sort_box
)->vbox
),
328 cbox2
, FALSE
, FALSE
, 0);
329 /* off to the races */
330 gtk_widget_show_all (GNOME_DIALOG (sort_box
)->vbox
);
331 switch (gnome_dialog_run (GNOME_DIALOG (sort_box
))) {
333 sfn
= sort_get_func_from_type(
334 GPOINTER_TO_UINT(gtk_object_get_data (GTK_OBJECT
337 "SORT_ORDER_CODE")));
339 panel
->case_sensitive
= GTK_TOGGLE_BUTTON (cbox1
)->active
;
341 panel
->reverse
= GTK_TOGGLE_BUTTON (cbox2
)->active
;
343 panel_set_sort_order (panel
, sfn
);
350 gtk_widget_destroy (sort_box
);
353 typedef struct ep_dlg_data
{
357 GtkWidget
*add_button
;
358 GtkWidget
*remove_button
;
359 gboolean setting_text
;
360 gint selected
; /* if this is -1 then nothing is selected, otherwise, it's the row selected */
364 get_nickname (gchar
*text
)
369 gchar
*retval
= NULL
;
372 dlg
= gnome_dialog_new (_("Enter name."), GNOME_STOCK_BUTTON_OK
,
373 GNOME_STOCK_BUTTON_CANCEL
, NULL
);
374 gtk_window_set_position (GTK_WINDOW (dlg
), GTK_WIN_POS_MOUSE
);
375 entry
= gtk_entry_new ();
377 gtk_entry_set_text (GTK_ENTRY (entry
), text
);
378 label
= gtk_label_new (_("Enter label for command:"));
379 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
380 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg
)->vbox
),
381 label
, FALSE
, FALSE
, 0);
382 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg
)->vbox
),
383 entry
, FALSE
, FALSE
, 0);
384 gtk_widget_show_all (GNOME_DIALOG (dlg
)->vbox
);
386 switch (gnome_dialog_run (GNOME_DIALOG (dlg
))) {
391 retval
= g_strdup (gtk_entry_get_text (GTK_ENTRY (entry
)));
397 gtk_widget_destroy (dlg
);
403 ep_add_callback (GtkWidget
*widget
, ep_dlg_data
*data
)
406 gchar
*insert_tab
[1];
408 insert_tab
[0] = get_nickname (NULL
);
409 if (insert_tab
[0] == NULL
)
411 i
= gtk_clist_append (GTK_CLIST (data
->clist
), insert_tab
);
412 gtk_clist_set_row_data (GTK_CLIST (data
->clist
), i
,
413 g_strdup (gtk_entry_get_text (GTK_ENTRY (data
->entry
))));
414 g_free (insert_tab
[0]);
416 gtk_widget_set_sensitive (data
->add_button
, FALSE
);
417 gtk_entry_set_text (GTK_ENTRY (data
->entry
), "");
421 ep_remove_callback (GtkWidget
*widget
, ep_dlg_data
*data
)
423 if (data
->selected
> -1) {
424 g_free (gtk_clist_get_row_data (GTK_CLIST (data
->clist
), data
->selected
));
425 gtk_clist_remove (GTK_CLIST (data
->clist
), data
->selected
);
427 gtk_entry_set_text (GTK_ENTRY (data
->entry
), "");
429 gtk_widget_set_sensitive (data
->remove_button
, FALSE
);
433 ep_select_callback (GtkWidget
*widget
,
436 GdkEventButton
*event
,
439 if (event
&& event
->type
== GDK_2BUTTON_PRESS
) {
442 gtk_clist_get_text (GTK_CLIST (widget
), row
, 0, &nick
);
443 /* ugly but correct... (: */
444 nick
= get_nickname (nick
);
445 gtk_clist_set_text (GTK_CLIST (data
->clist
), row
, 0, nick
);
446 gtk_clist_select_row (GTK_CLIST (data
->clist
), row
, 0);
448 data
->setting_text
= TRUE
;
449 gtk_entry_set_text (GTK_ENTRY (data
->entry
),
450 (gchar
*) gtk_clist_get_row_data (GTK_CLIST (widget
), row
));
451 data
->setting_text
= FALSE
;
452 data
->selected
= row
;
453 gtk_widget_set_sensitive (data
->remove_button
, TRUE
);
454 gtk_widget_set_sensitive (data
->add_button
, FALSE
);
459 ep_text_changed_callback (GtkWidget
*widget
, ep_dlg_data
*data
)
461 if (data
->setting_text
)
462 /* we don't want to deselect text if we just clicked on something */
464 if (data
->selected
> -1) {
465 gtk_clist_unselect_row (GTK_CLIST (data
->clist
), data
->selected
, 0);
468 gtk_widget_set_sensitive (data
->remove_button
, FALSE
);
469 gtk_widget_set_sensitive (data
->add_button
, TRUE
);
473 load_settings (GtkCList
*clist
)
475 gchar
*insert_tab
[1];
480 profile_keys
= profile_init_iterator (panelize_section
, profile_name
);
483 insert_tab
[0] = _("Find all core files");
484 i
= gtk_clist_insert (clist
, i
, insert_tab
);
485 gtk_clist_set_row_data (clist
, i
, g_strdup ("find / -name core"));
486 insert_tab
[0] = _("Find rejects after patching");
487 i
= gtk_clist_insert (clist
, i
, insert_tab
);
488 gtk_clist_set_row_data (clist
, i
, g_strdup ("find . -name \\*.rej -print"));
490 while (profile_keys
) {
491 profile_keys
= profile_iterator_next (profile_keys
, &key
, &value
);
493 i
= gtk_clist_insert (clist
, i
, insert_tab
);
494 gtk_clist_set_row_data (clist
, i
, g_strdup (value
));
500 save_settings (GtkCList
*clist
)
505 profile_clean_section (panelize_section
, profile_name
);
506 for (i
= 0; i
< GTK_CLIST (clist
)->rows
; i
++) {
507 gtk_clist_get_text (GTK_CLIST (clist
), i
, 0, &text
);
508 WritePrivateProfileString (panelize_section
,
510 (gchar
*) gtk_clist_get_row_data (GTK_CLIST (clist
), i
),
517 gnome_external_panelize (GtkWidget
*widget
, WPanel
*panel
)
528 data
= g_new0 (ep_dlg_data
, 1);
529 data
->setting_text
= FALSE
;
531 data
->ep_dlg
= gnome_dialog_new (_("Run Command"), GNOME_STOCK_BUTTON_OK
,
532 GNOME_STOCK_BUTTON_CANCEL
, NULL
);
533 gtk_window_set_position (GTK_WINDOW (data
->ep_dlg
), GTK_WIN_POS_MOUSE
);
536 frame
= gtk_frame_new (_("Preset Commands"));
537 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (data
->ep_dlg
)->vbox
),
538 frame
, FALSE
, FALSE
, 0);
539 data
->clist
= gtk_clist_new (1);
540 load_settings (GTK_CLIST (data
->clist
));
541 gtk_signal_connect (GTK_OBJECT (data
->clist
), "select_row", GTK_SIGNAL_FUNC (ep_select_callback
), (gpointer
) data
);
542 vbox
= gtk_vbox_new (FALSE
, GNOME_PAD_SMALL
);
543 gtk_clist_columns_autosize (GTK_CLIST (data
->clist
));
544 gtk_clist_set_auto_sort (GTK_CLIST (data
->clist
), TRUE
);
545 gtk_container_set_border_width (GTK_CONTAINER (vbox
), GNOME_PAD_SMALL
);
546 sw
= gtk_scrolled_window_new (GTK_CLIST (data
->clist
)->hadjustment
, GTK_CLIST (data
->clist
)->vadjustment
);
547 gtk_widget_set_usize (sw
, 300, 100);
548 gtk_container_add (GTK_CONTAINER (sw
), data
->clist
);
549 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw
), GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
550 gtk_box_pack_start (GTK_BOX (vbox
), sw
, TRUE
, TRUE
, 0);
551 gtk_container_add (GTK_CONTAINER (frame
), vbox
);
552 hbox
= gtk_hbox_new (FALSE
, GNOME_PAD_SMALL
);
553 data
->add_button
= gtk_button_new_with_label (_("Add"));
554 gtk_signal_connect (GTK_OBJECT (data
->add_button
), "clicked", GTK_SIGNAL_FUNC (ep_add_callback
), (gpointer
) data
);
555 gtk_widget_set_usize (data
->add_button
, 75, 25);
556 gtk_box_pack_end (GTK_BOX (hbox
), data
->add_button
, FALSE
, FALSE
, 0);
557 data
->remove_button
= gtk_button_new_with_label (_("Remove"));
558 gtk_widget_set_sensitive (data
->remove_button
, FALSE
);
559 gtk_signal_connect (GTK_OBJECT (data
->remove_button
), "clicked", GTK_SIGNAL_FUNC (ep_remove_callback
), (gpointer
) data
);
560 gtk_widget_set_usize (data
->remove_button
, 75, 25);
561 gtk_box_pack_end (GTK_BOX (hbox
), data
->remove_button
, FALSE
, FALSE
, 0);
562 gtk_box_pack_start (GTK_BOX (vbox
), hbox
, FALSE
, FALSE
, 0);
565 frame
= gtk_frame_new (_("Run this Command"));
566 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (data
->ep_dlg
)->vbox
),
567 frame
, FALSE
, FALSE
, 0);
568 data
->entry
= gtk_entry_new ();
569 gtk_signal_connect (GTK_OBJECT (data
->entry
), "changed", GTK_SIGNAL_FUNC (ep_text_changed_callback
), (gpointer
) data
);
570 hbox
= gtk_hbox_new (FALSE
, GNOME_PAD_SMALL
);
571 gtk_container_set_border_width (GTK_CONTAINER (hbox
), GNOME_PAD_SMALL
);
572 gtk_box_pack_start (GTK_BOX (hbox
), gtk_label_new (_("Command: ")), FALSE
, FALSE
, 0);
573 gtk_box_pack_start (GTK_BOX (hbox
), data
->entry
, TRUE
, TRUE
, 0);
574 gtk_container_add (GTK_CONTAINER (frame
), hbox
);
575 gtk_widget_show_all (GNOME_DIALOG (data
->ep_dlg
)->vbox
);
579 switch (gnome_dialog_run (GNOME_DIALOG (data
->ep_dlg
))) {
581 gtk_widget_hide (data
->ep_dlg
);
582 while (gtk_events_pending () )
583 gtk_main_iteration ();
585 do_external_panelize (gtk_entry_get_text (GTK_ENTRY (data
->entry
)));
586 save_settings (GTK_CLIST (data
->clist
));
595 for (i
= 0; i
< GTK_CLIST (data
->clist
)->rows
; i
++) {
596 row_data
= gtk_clist_get_row_data (GTK_CLIST (data
->clist
), i
);
602 gtk_widget_destroy (GTK_WIDGET (data
->ep_dlg
));
608 create_trash_panel (void)
613 is_trash_panel
= TRUE
;
614 trash_dir
= g_strconcat (gnome_user_home_dir
, "/",
615 DESKTOP_DIR_NAME
, "/",
618 retval
= new_panel_at (trash_dir
);
620 is_trash_panel
= FALSE
;
626 gnome_empty_trash (GtkWidget
*widget
, WPanel
*panel
)
631 trash_panel
= create_trash_panel ();
632 for (i
= 0; i
< trash_panel
->count
; i
++){
633 if (!strcmp (trash_panel
->dir
.list
[i
].fname
, "..")) {
636 do_file_mark (trash_panel
, i
, 1);
639 panel_operate (trash_panel
, OP_DELETE
, NULL
, FALSE
);
641 gnome_close_panel (NULL
, trash_panel
);
642 update_panels (UP_OPTIMIZE
, UP_KEEPSEL
);
648 gnome_select_all_cmd (GtkWidget
*widget
, WPanel
*panel
)
651 for (i
= 0; i
< panel
->count
; i
++){
652 if (!strcmp (panel
->dir
.list
[i
].fname
, "..")) {
655 do_file_mark (panel
, i
, 1);
662 gnome_start_search (GtkWidget
*widget
, WPanel
*panel
)
664 start_search (panel
);
668 gnome_reverse_selection_cmd_panel (GtkWidget
*widget
, WPanel
*panel
)
673 for (i
= 0; i
< panel
->count
; i
++) {
674 if (!strcmp (panel
->dir
.list
[i
].fname
, ".."))
677 file
= &panel
->dir
.list
[i
];
678 do_file_mark (panel
, i
, !file
->f
.marked
);
685 gnome_filter_cmd (GtkWidget
*widget
, WPanel
*panel
)
687 GtkWidget
*filter_dlg
;
690 gchar
*text1
, *text2
, *text3
;
692 filter_dlg
= gnome_dialog_new (_("Set Filter"), GNOME_STOCK_BUTTON_OK
,
693 GNOME_STOCK_BUTTON_CANCEL
, NULL
);
694 gtk_window_set_position (GTK_WINDOW (filter_dlg
), GTK_WIN_POS_MOUSE
);
696 text1
= "mc_filter_globs";
697 text3
= _("Show all files");
698 if (panel
->filter
&& (strcmp (panel
->filter
, "*")))
699 text2
= panel
->filter
;
703 text1
= "mc_filter_regexps";
708 text2
= panel
->filter
;
710 entry
= gnome_entry_new (text1
);
711 gnome_entry_load_history (GNOME_ENTRY (entry
));
714 gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
))), text2
);
715 gnome_entry_prepend_history (GNOME_ENTRY (entry
), FALSE
, text3
);
717 gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
))), text3
);
720 label
= gtk_label_new (_("Enter a filter here for files in the panel view.\n\nFor example:\n*.png will show just png images"));
722 label
= gtk_label_new (_("Enter a Regular Expression to filter files in the panel view."));
723 gtk_label_set_justify (GTK_LABEL (label
), GTK_JUSTIFY_LEFT
);
724 gtk_label_set_line_wrap (GTK_LABEL (label
), TRUE
);
726 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
727 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (filter_dlg
)->vbox
), label
, FALSE
, FALSE
, 0);
728 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (filter_dlg
)->vbox
), entry
, FALSE
, FALSE
, 0);
729 gtk_widget_show_all (GNOME_DIALOG (filter_dlg
)->vbox
);
730 switch (gnome_dialog_run (GNOME_DIALOG (filter_dlg
))) {
732 gtk_widget_hide (filter_dlg
);
734 g_free (panel
->filter
);
735 panel
->filter
= NULL
;
737 panel
->filter
= g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
)))));
738 if (!strcmp (_("Show all files"), panel
->filter
)) {
739 g_free (panel
->filter
);
740 panel
->filter
= NULL
;
741 gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
))),
743 gtk_label_set_text (GTK_LABEL (panel
->status
), _("Show all files"));
744 } else if (!strcmp ("*", panel
->filter
)) {
745 g_free (panel
->filter
);
746 panel
->filter
= NULL
;
747 gtk_label_set_text (GTK_LABEL (panel
->status
), _("Show all files"));
749 gtk_label_set_text (GTK_LABEL (panel
->status
), panel
->filter
);
751 gnome_entry_save_history (GNOME_ENTRY (entry
));
752 x_filter_changed (panel
);
759 gtk_widget_destroy (filter_dlg
);
763 gnome_open_files (GtkWidget
*widget
, WPanel
*panel
)
771 /* FIXME: this is the easy way to do things. We want the
772 * hard way sometime. */
773 for (i
= 0; i
< panel
->count
; i
++) {
774 if (panel
->dir
.list
[i
].f
.marked
)
775 if (!do_enter_on_file_entry ((panel
->dir
.list
) + i
))
776 later
= g_list_prepend (later
, panel
->dir
.list
+ i
);
779 /* This is sorta ugly. Should we just skip these? There should be a better way. */
780 for (now
= later
; now
; now
= now
->next
) {
782 command
= input_expand_dialog (_(" Open with..."),
783 _("Enter extra arguments:"), (WPanel
*) now
->data
);
796 gnome_run_new (GtkWidget
*widget
, GnomeDesktopEntry
*gde
)
798 gnome_desktop_entry_launch (gde
);
802 gnome_mkdir_cmd (GtkWidget
*widget
, WPanel
*panel
)
808 gnome_newfile_cmd (GtkWidget
*widget
, WPanel
*panel
)
810 mc_chdir (panel
->cwd
);
815 dentry_apply_callback(GtkWidget
*widget
, int page
, gpointer data
)
817 GnomeDesktopEntry
*dentry
;
818 gchar
*desktop_directory
;
823 g_return_if_fail(data
!=NULL
);
824 g_return_if_fail(GNOME_IS_DENTRY_EDIT(data
));
825 dentry
= gnome_dentry_get_dentry(GNOME_DENTRY_EDIT(data
));
827 if (getenv ("GNOME_DESKTOP_DIR") != NULL
)
828 desktop_directory
= g_strconcat (getenv ("GNOME_DESKTOP_DIR"),
830 dentry
->name
, ".desktop",
833 desktop_directory
= g_strconcat (gnome_user_home_dir
, "/",
834 DESKTOP_DIR_NAME
, "/",
835 dentry
->name
, ".desktop",
838 dentry
->location
= desktop_directory
;
839 gnome_desktop_entry_save(dentry
);
840 gnome_desktop_entry_free(dentry
);
841 gnome_config_sync ();
842 desktop_reload_icons (FALSE
, 0, 0);
847 gnome_new_launcher (GtkWidget
*widget
, WPanel
*panel
)
852 dialog
= gnome_property_box_new ();
853 gtk_window_set_title(GTK_WINDOW(dialog
), _("Desktop entry properties"));
854 gtk_window_set_policy(GTK_WINDOW(dialog
), FALSE
, FALSE
, TRUE
);
855 dentry
= gnome_dentry_edit_new_notebook(GTK_NOTEBOOK(GNOME_PROPERTY_BOX(dialog
)->notebook
));
856 gtk_signal_connect_object(GTK_OBJECT(dentry
), "changed",
857 GTK_SIGNAL_FUNC(gnome_property_box_changed
),
860 gtk_signal_connect(GTK_OBJECT(dialog
), "apply",
861 GTK_SIGNAL_FUNC(dentry_apply_callback
),
863 gtk_widget_show(dialog
);
868 gnome_select (GtkWidget
*widget
, WPanel
*panel
)
870 char *reg_exp
, *reg_exp_t
;
874 GtkWidget
*select_dialog
;
879 select_dialog
= gnome_dialog_new (_("Select File"), GNOME_STOCK_BUTTON_OK
,
880 GNOME_STOCK_BUTTON_CANCEL
, NULL
);
881 gtk_window_set_position (GTK_WINDOW (select_dialog
), GTK_WIN_POS_MOUSE
);
882 entry
= gnome_entry_new ("mc_select");
883 gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
))), easy_patterns
? "*" : ".");
884 gnome_entry_load_history (GNOME_ENTRY (entry
));
887 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"));
889 label
= gtk_label_new (_("Enter a regular expression here to select files in the panel view with."));
891 gtk_label_set_justify (GTK_LABEL (label
), GTK_JUSTIFY_LEFT
);
892 gtk_label_set_line_wrap (GTK_LABEL (label
), TRUE
);
894 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
895 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (select_dialog
)->vbox
), label
, FALSE
, FALSE
, 0);
896 gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (select_dialog
)->vbox
), entry
, FALSE
, FALSE
, 0);
897 gtk_widget_show_all (GNOME_DIALOG (select_dialog
)->vbox
);
899 run
= gnome_dialog_run (GNOME_DIALOG (select_dialog
));
901 gtk_widget_hide (select_dialog
);
902 reg_exp
= g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry
)))));
905 gtk_widget_destroy (select_dialog
);
907 if ((reg_exp
== NULL
) || (*reg_exp
== '\000')) {
913 /* Check if they specified a directory */
914 if (*reg_exp_t
== PATH_SEP
){
918 if (reg_exp_t
[strlen(reg_exp_t
) - 1] == PATH_SEP
){
920 reg_exp_t
[strlen(reg_exp_t
) - 1] = 0;
923 for (i
= 0; i
< panel
->count
; i
++){
924 if (!strcmp (panel
->dir
.list
[i
].fname
, ".."))
926 if (S_ISDIR (panel
->dir
.list
[i
].buf
.st_mode
)){
933 c
= regexp_match (reg_exp_t
, panel
->dir
.list
[i
].fname
, match_file
);
935 message (1, MSG_ERROR
, _(" Malformed regular expression "));
940 do_file_mark (panel
, i
, 1);
947 set_cursor_busy (WPanel
*panel
)
951 if (is_a_desktop_panel (panel
))
954 cursor
= gdk_cursor_new (GDK_WATCH
);
955 gdk_window_set_cursor (GTK_WIDGET (panel
->xwindow
)->window
, cursor
);
956 gdk_cursor_destroy (cursor
);
961 set_cursor_normal (WPanel
*panel
)
963 if (is_a_desktop_panel (panel
))
966 gdk_window_set_cursor (GTK_WIDGET (panel
->xwindow
)->window
, NULL
);
971 gnome_new_link (GtkWidget
*widget
, WPanel
*panel
)
976 url
= input_expand_dialog (_("Creating a desktop link"),
977 _("Enter the URL:"), "");
981 template = g_concat_dir_and_file (desktop_directory
, "urlXXXXXX");
983 if (mktemp (template)) {
986 icon
= g_concat_dir_and_file (ICONDIR
, "gnome-http-url.png");
987 desktop_create_url (template, url
, url
, icon
);