4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2005, the ROX-Filer team.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
22 /* minibuffer.c - for handling the path entry box at the bottom */
33 #include <sys/types.h>
37 #include <gdk/gdkkeysyms.h>
43 #include "gui_support.h"
45 #include "minibuffer.h"
52 #include "view_iface.h"
54 static GList
*shell_history
= NULL
;
56 /* Static prototypes */
57 static gint
key_press_event(GtkWidget
*widget
,
59 FilerWindow
*filer_window
);
60 static void changed(GtkEditable
*mini
, FilerWindow
*filer_window
);
61 static gboolean
find_next_match(FilerWindow
*filer_window
,
64 static gboolean
find_exact_match(FilerWindow
*filer_window
,
65 const gchar
*pattern
);
66 static gboolean
matches(ViewIter
*iter
, const char *pattern
);
67 static void search_in_dir(FilerWindow
*filer_window
, int dir
);
68 static const gchar
*mini_contents(FilerWindow
*filer_window
);
69 static void show_help(FilerWindow
*filer_window
);
70 static gboolean
grab_focus(GtkWidget
*minibuffer
);
71 static gboolean
select_if_glob(ViewIter
*iter
, gpointer data
);
73 /****************************************************************
74 * EXTERNAL INTERFACE *
75 ****************************************************************/
77 static Option o_filer_beep_fail
, o_filer_beep_multi
;
79 void minibuffer_init(void)
81 option_add_int(&o_filer_beep_fail
, "filer_beep_fail", 1);
82 option_add_int(&o_filer_beep_multi
, "filer_beep_multi", 1);
85 /* Creates the minibuffer widgets, setting the appropriate fields
88 void create_minibuffer(FilerWindow
*filer_window
)
90 GtkWidget
*hbox
, *label
, *mini
;
92 hbox
= gtk_hbox_new(FALSE
, 0);
94 gtk_box_pack_start(GTK_BOX(hbox
),
95 new_help_button((HelpFunc
) show_help
, filer_window
),
98 label
= gtk_label_new("");
99 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, TRUE
, 2);
101 mini
= gtk_entry_new();
102 gtk_box_pack_start(GTK_BOX(hbox
), mini
, TRUE
, TRUE
, 0);
103 gtk_widget_set_name(mini
, "fixed-style");
104 g_signal_connect(mini
, "key_press_event",
105 G_CALLBACK(key_press_event
), filer_window
);
106 g_signal_connect(mini
, "changed", G_CALLBACK(changed
), filer_window
);
108 /* Grabbing focus musn't select the text... */
109 g_signal_connect_swapped(mini
, "grab-focus",
110 G_CALLBACK(grab_focus
), mini
);
112 filer_window
->minibuffer
= mini
;
113 filer_window
->minibuffer_label
= label
;
114 filer_window
->minibuffer_area
= hbox
;
117 void minibuffer_show(FilerWindow
*filer_window
, MiniType mini_type
)
123 g_return_if_fail(filer_window
!= NULL
);
124 g_return_if_fail(filer_window
->minibuffer
!= NULL
);
126 mini
= GTK_ENTRY(filer_window
->minibuffer
);
127 entry_set_error(filer_window
->minibuffer
, FALSE
);
129 filer_window
->mini_type
= MINI_NONE
;
130 gtk_label_set_text(GTK_LABEL(filer_window
->minibuffer_label
),
131 mini_type
== MINI_PATH
? _("Goto:") :
132 mini_type
== MINI_SHELL
? _("Shell:") :
133 mini_type
== MINI_SELECT_IF
? _("Select If:") :
134 mini_type
== MINI_SELECT_BY_NAME
? _("Select Named:") :
135 mini_type
== MINI_FILTER
? _("Pattern:") :
141 view_show_cursor(filer_window
->view
);
142 view_get_cursor(filer_window
->view
, &cursor
);
143 view_set_base(filer_window
->view
, &cursor
);
145 gtk_entry_set_text(mini
,
146 make_path(filer_window
->sym_path
, ""));
147 if (filer_window
->temp_show_hidden
)
149 filer_window
->temp_show_hidden
= FALSE
;
150 display_update_hidden(filer_window
);
154 gtk_entry_set_text(mini
, "");
155 filer_window
->mini_cursor_base
= -1; /* History */
157 case MINI_SELECT_BY_NAME
:
158 gtk_entry_set_text(mini
, "*.");
159 filer_window
->mini_cursor_base
= -1; /* History */
160 view_select_if(filer_window
->view
, select_if_glob
, "*.");
163 if(filer_window
->filter
!=FILER_SHOW_GLOB
||
164 !filer_window
->filter_string
)
165 gtk_entry_set_text(mini
, "*");
167 gtk_entry_set_text(mini
,
168 filer_window
->filter_string
);
173 view_get_cursor(filer_window
->view
, &cursor
);
174 item
= cursor
.peek(&cursor
);
176 if (view_count_selected(filer_window
->view
) > 0)
177 gtk_entry_set_text(mini
, " \"$@\"");
182 tmp
= g_strconcat(" ", item
->leafname
, NULL
);
183 gtk_entry_set_text(mini
, tmp
);
187 gtk_entry_set_text(mini
, "");
188 filer_window
->mini_cursor_base
= -1; /* History */
192 g_warning("Bad minibuffer type\n");
196 filer_window
->mini_type
= mini_type
;
198 gtk_editable_set_position(GTK_EDITABLE(mini
), pos
);
200 gtk_widget_show_all(filer_window
->minibuffer_area
);
202 gtk_widget_grab_focus(filer_window
->minibuffer
);
205 void minibuffer_hide(FilerWindow
*filer_window
)
207 filer_window
->mini_type
= MINI_NONE
;
209 gtk_widget_hide(filer_window
->minibuffer_area
);
211 gtk_widget_child_focus(filer_window
->window
, GTK_DIR_TAB_FORWARD
);
213 if (filer_window
->temp_show_hidden
)
218 view_get_cursor(filer_window
->view
, &iter
);
219 item
= iter
.peek(&iter
);
221 if (item
== NULL
|| item
->leafname
[0] != '.')
222 display_update_hidden(filer_window
);
223 filer_window
->temp_show_hidden
= FALSE
;
227 /* Insert this leafname at the cursor (replacing the selection, if any).
228 * Must be in SHELL mode.
230 void minibuffer_add(FilerWindow
*filer_window
, const gchar
*leafname
)
233 GtkEditable
*edit
= GTK_EDITABLE(filer_window
->minibuffer
);
234 GtkEntry
*entry
= GTK_ENTRY(edit
);
237 g_return_if_fail(filer_window
->mini_type
== MINI_SHELL
);
239 esc
= shell_escape(leafname
);
241 gtk_editable_delete_selection(edit
);
242 pos
= gtk_editable_get_position(edit
);
244 if (pos
> 0 && gtk_entry_get_text(entry
)[pos
- 1] != ' ')
245 gtk_editable_insert_text(edit
, " ", 1, &pos
);
247 gtk_editable_insert_text(edit
, esc
, strlen(esc
), &pos
);
248 gtk_editable_set_position(edit
, pos
);
254 /****************************************************************
255 * INTERNAL FUNCTIONS *
256 ****************************************************************/
258 static void show_help(FilerWindow
*filer_window
)
260 switch (filer_window
->mini_type
)
264 _("Enter the name of a file and I'll display "
265 "it for you. Press Tab to fill in the longest "
266 "match. Escape to close the minibuffer."));
270 _("Enter a shell command to execute. Click "
271 "on a file to add it to the buffer."));
273 case MINI_SELECT_BY_NAME
:
275 _("Enter a file name pattern to select all matching files:\n\n"
276 "? means any character\n"
277 "* means zero or more characters\n"
278 "[aA] means 'a' or 'A'\n"
279 "[a-z] means any character from a to z (lowercase)\n"
280 "*.png means any name ending in '.png'"));
283 show_condition_help(NULL
);
287 _("Enter a pattern to match for files to "
288 "be shown. An empty filter turns the "
292 g_warning("Unknown minibuffer type!");
300 static void path_return_pressed(FilerWindow
*filer_window
, GdkEventKey
*event
)
302 const gchar
*path
, *pattern
;
303 int flags
= OPEN_FROM_MINI
| OPEN_SAME_WINDOW
;
307 path
= gtk_entry_get_text(GTK_ENTRY(filer_window
->minibuffer
));
308 pattern
= g_basename(path
);
310 view_get_cursor(filer_window
->view
, &iter
);
312 item
= iter
.peek(&iter
);
313 if (item
== NULL
|| !matches(&iter
, pattern
))
319 if ((event
->state
& GDK_SHIFT_MASK
) != 0)
322 filer_openitem(filer_window
, &iter
, flags
);
325 /* Use the cursor item to fill in the minibuffer.
326 * If there are multiple matches then fill in as much as possible and
329 static void complete(FilerWindow
*filer_window
)
332 DirItem
*item
, *other
;
333 int shortest_stem
= -1;
335 const gchar
*text
, *leaf
;
336 ViewIter cursor
, iter
;
338 view_get_cursor(filer_window
->view
, &cursor
);
339 item
= cursor
.peek(&cursor
);
347 entry
= GTK_ENTRY(filer_window
->minibuffer
);
349 text
= gtk_entry_get_text(entry
);
350 leaf
= strrchr(text
, '/');
358 if (!matches(&cursor
, leaf
))
364 current_stem
= strlen(leaf
);
366 /* Find the longest other match of this name. If it's longer than
367 * the currently entered text then complete only up to that length.
369 view_get_iter(filer_window
->view
, &iter
, 0);
370 while ((other
= iter
.next(&iter
)))
374 if (iter
.i
== cursor
.i
) /* XXX */
377 while (other
->leafname
[stem
] && item
->leafname
[stem
])
380 /* Like the matches() function below, the comparison of
381 * leafs must be case-insensitive.
383 a
= g_ascii_tolower(item
->leafname
[stem
]);
384 b
= g_ascii_tolower(other
->leafname
[stem
]);
390 /* stem is the index of the first difference */
391 if (stem
>= current_stem
&&
392 (shortest_stem
== -1 || stem
< shortest_stem
))
393 shortest_stem
= stem
;
396 if (current_stem
== shortest_stem
)
398 /* We didn't add anything... */
399 if (o_filer_beep_fail
.int_value
)
402 else if (current_stem
< shortest_stem
)
406 /* Have to replace the leafname text in the minibuffer rather
407 * than just append to it. Here's an example:
408 * Suppose we have two dirs, /tmp and /TMP.
409 * The user enters /t in the minibuffer and hits Tab.
410 * With the g_ascii_tolower() code above, this would result
411 * in /tMP being bisplayed in the minibuffer which isn't
412 * intuitive. Therefore all text after the / must be replaced.
414 tmp_pos
= leaf
- text
; /* index of start of leaf */
415 gtk_editable_delete_text(GTK_EDITABLE(entry
),
416 tmp_pos
, entry
->text_length
);
417 gtk_editable_insert_text(GTK_EDITABLE(entry
),
418 item
->leafname
, shortest_stem
,
421 gtk_editable_set_position(GTK_EDITABLE(entry
), -1);
423 if (o_filer_beep_multi
.int_value
)
430 new = make_path(filer_window
->sym_path
, item
->leafname
);
432 if (item
->base_type
== TYPE_DIRECTORY
&&
433 (item
->flags
& ITEM_FLAG_APPDIR
) == 0)
434 new = make_path(new, "");
436 gtk_entry_set_text(entry
, new);
437 gtk_editable_set_position(GTK_EDITABLE(entry
), -1);
441 static void path_changed(FilerWindow
*filer_window
)
443 GtkWidget
*mini
= filer_window
->minibuffer
;
444 const char *rawnew
, *leaf
;
447 gboolean error
= FALSE
;
449 rawnew
= gtk_entry_get_text(GTK_ENTRY(mini
));
452 /* Entry may be blank because we're in the middle of changing
453 * to something else...
455 entry_set_error(mini
, FALSE
);
462 new=g_strdup(rawnew
);
466 if (!rawnew
[1] || rawnew
[1]=='/')
468 new=g_strconcat(g_get_home_dir(), "/",
469 rawnew
[1]? rawnew
+2: "", "/",
476 struct passwd
*passwd
;
479 /* Need to lookup user name */
480 for(sl
=rawnew
+2; *sl
&& *sl
!='/'; sl
++)
482 username
=g_strndup(rawnew
+1, sl
-rawnew
-1);
483 passwd
=getpwnam(username
);
488 new=g_strconcat(passwd
->pw_dir
, "/",
493 new=g_strdup(rawnew
);
498 new=g_strdup(rawnew
);
503 leaf
= g_basename(new);
505 path
= g_strdup("/");
507 path
= g_path_get_dirname(new);
509 if (strcmp(path
, filer_window
->sym_path
) != 0)
511 /* The new path is in a different directory */
514 if (stat_with_timeout(path
, &info
) == 0 &&
515 S_ISDIR(info
.st_mode
))
517 filer_change_to(filer_window
, path
, leaf
);
524 if (*leaf
== '.' && !filer_window
->temp_show_hidden
)
526 filer_window
->temp_show_hidden
= TRUE
;
527 display_update_hidden(filer_window
);
530 if (find_exact_match(filer_window
, leaf
) == FALSE
&&
531 find_next_match(filer_window
, leaf
, 0) == FALSE
)
538 entry_set_error(mini
, error
);
541 /* Look for an exact match, and move the cursor to it if found.
544 static gboolean
find_exact_match(FilerWindow
*filer_window
,
545 const gchar
*pattern
)
549 ViewIface
*view
= filer_window
->view
;
551 view_get_iter(view
, &iter
, 0);
553 while ((item
= iter
.next(&iter
)))
555 if (strcmp(item
->leafname
, pattern
) == 0)
557 view_cursor_to_iter(view
, &iter
);
565 /* Find the next item in the view that matches 'pattern'. Start from
566 * cursor_base and loop at either end. dir is 1 for a forward search,
567 * -1 for backwards. 0 means forwards, but may stay the same.
569 * Does not automatically update cursor_base.
571 * Returns TRUE if a match is found.
573 static gboolean
find_next_match(FilerWindow
*filer_window
,
577 ViewIface
*view
= filer_window
->view
;
580 if (view_count_items(view
) < 1)
583 view_get_iter(view
, &iter
,
584 VIEW_ITER_FROM_BASE
|
585 (dir
>= 0 ? 0 : VIEW_ITER_BACKWARDS
));
588 iter
.next(&iter
); /* Don't look at the base itself */
590 while (iter
.next(&iter
))
592 if (matches(&iter
, pattern
))
594 view_cursor_to_iter(view
, &iter
);
599 /* No matches (except possibly base itself) */
600 view_get_iter(view
, &iter
,
601 VIEW_ITER_FROM_BASE
| VIEW_ITER_ONE_ONLY
|
602 (dir
>= 0 ? 0 : VIEW_ITER_BACKWARDS
));
604 view_cursor_to_iter(view
, &iter
);
609 static gboolean
matches(ViewIter
*iter
, const char *pattern
)
613 item
= iter
->peek(iter
);
615 return strncasecmp(item
->leafname
, pattern
, strlen(pattern
)) == 0;
618 /* Find next match and set base for future matches. */
619 static void search_in_dir(FilerWindow
*filer_window
, int dir
)
621 const char *path
, *pattern
;
624 path
= gtk_entry_get_text(GTK_ENTRY(filer_window
->minibuffer
));
625 pattern
= g_basename(path
);
627 view_get_cursor(filer_window
->view
, &iter
);
628 view_set_base(filer_window
->view
, &iter
);
629 find_next_match(filer_window
, pattern
, dir
);
630 view_get_cursor(filer_window
->view
, &iter
);
631 view_set_base(filer_window
->view
, &iter
);
636 static void add_to_history(const gchar
*line
)
640 last
= shell_history
? (guchar
*) shell_history
->data
: NULL
;
642 if (last
&& strcmp(last
, line
) == 0)
643 return; /* Duplicating last entry */
645 shell_history
= g_list_prepend(shell_history
, g_strdup(line
));
648 static void shell_done(FilerWindow
*filer_window
)
650 if (filer_exists(filer_window
))
651 filer_update_dir(filer_window
, TRUE
);
654 /* Given a list of matches, return the longest stem. g_free() the result.
655 * Special chars are escaped. If there is only a single (non-dir) match
656 * then a trailing space is added.
658 static guchar
*best_match(FilerWindow
*filer_window
, glob_t
*matches
)
660 gchar
*first
= matches
->gl_pathv
[0];
662 int longest
, path_len
;
665 longest
= strlen(first
);
667 for (i
= 1; i
< matches
->gl_pathc
; i
++)
670 guchar
*m
= matches
->gl_pathv
[i
];
672 for (j
= 0; j
< longest
; j
++)
673 if (m
[j
] != first
[j
])
677 path_len
= strlen(filer_window
->sym_path
);
678 if (strncmp(filer_window
->sym_path
, first
, path_len
) == 0 &&
679 first
[path_len
] == '/' && first
[path_len
+ 1])
681 path
= g_strndup(first
+ path_len
+ 1, longest
- path_len
- 1);
684 path
= g_strndup(first
, longest
);
686 tmp
= shell_escape(path
);
689 if (matches
->gl_pathc
== 1 && tmp
[strlen(tmp
) - 1] != '/')
691 path
= g_strdup_printf("%s ", tmp
);
699 static void shell_tab(FilerWindow
*filer_window
)
708 entry
= gtk_entry_get_text(GTK_ENTRY(filer_window
->minibuffer
));
709 pos
= gtk_editable_get_position(GTK_EDITABLE(filer_window
->minibuffer
));
710 leaf
= g_string_new(NULL
);
712 for (i
= 0; i
< pos
; i
++)
721 g_string_truncate(leaf
, 0);
724 else if (c
== '\\' && i
+ 1 < pos
)
726 else if (c
== '"' || c
== '\'')
728 for (++i
; i
< pos
; i
++)
730 guchar cc
= entry
[i
];
732 if (cc
== '\\' && i
+ 1 < pos
)
736 g_string_append_c(leaf
, cc
);
741 g_string_append_c(leaf
, c
);
747 if (leaf
->str
[0] != '/' && leaf
->str
[0] != '~')
749 g_string_prepend_c(leaf
, '/');
750 g_string_prepend(leaf
, filer_window
->sym_path
);
753 g_string_append_c(leaf
, '*');
759 GLOB_MARK
, NULL
, &matches
) == 0)
761 if (matches
.gl_pathc
> 0)
765 GTK_EDITABLE(filer_window
->minibuffer
);
767 best
= best_match(filer_window
, &matches
);
769 gtk_editable_delete_text(edit
, leaf_start
, pos
);
770 gtk_editable_insert_text(edit
, best
, strlen(best
),
772 gtk_editable_set_position(edit
, leaf_start
);
776 if (matches
.gl_pathc
!= 1)
782 g_string_free(leaf
, TRUE
);
785 static void run_child(gpointer unused
)
787 /* Ensure output is noticed - send stdout to stderr */
788 dup2(STDERR_FILENO
, STDOUT_FILENO
);
789 close_on_exec(STDOUT_FILENO
, FALSE
);
792 /* Either execute the command or make it the default run action */
793 static void shell_return_pressed(FilerWindow
*filer_window
)
797 GError
*error
= NULL
;
802 entry
= mini_contents(filer_window
);
807 add_to_history(entry
);
809 argv
= g_ptr_array_new();
810 g_ptr_array_add(argv
, "sh");
811 g_ptr_array_add(argv
, "-c");
812 g_ptr_array_add(argv
, (gchar
*) entry
);
813 g_ptr_array_add(argv
, "sh");
815 view_get_iter(filer_window
->view
, &iter
, 0);
816 while ((item
= iter
.next(&iter
)))
818 if (view_get_selected(filer_window
->view
, &iter
))
819 g_ptr_array_add(argv
, item
->leafname
);
822 g_ptr_array_add(argv
, NULL
);
824 if (!g_spawn_async_with_pipes(filer_window
->sym_path
,
825 (gchar
**) argv
->pdata
, NULL
,
826 G_SPAWN_DO_NOT_REAP_CHILD
|
828 run_child
, NULL
, /* Child setup fn */
829 &child
, /* Child PID */
830 NULL
, NULL
, NULL
, /* Standard pipes */
833 delayed_error("%s", error
? error
->message
: "(null)");
837 on_child_death(child
, (CallbackFn
) shell_done
, filer_window
);
839 g_ptr_array_free(argv
, TRUE
);
842 minibuffer_hide(filer_window
);
845 /* Move through the shell history */
846 static void shell_recall(FilerWindow
*filer_window
, int dir
)
849 int pos
= filer_window
->mini_cursor_base
;
854 command
= g_list_nth_data(shell_history
, pos
);
863 filer_window
->mini_cursor_base
= pos
;
865 gtk_entry_set_text(GTK_ENTRY(filer_window
->minibuffer
), command
);
872 FilerWindow
*filer_window
;
876 static gboolean
select_if_test(ViewIter
*iter
, gpointer user_data
)
879 SelectData
*data
= user_data
;
881 item
= iter
->peek(iter
);
882 g_return_val_if_fail(item
!= NULL
, FALSE
);
884 data
->info
.leaf
= item
->leafname
;
885 data
->info
.fullpath
= make_path(data
->filer_window
->sym_path
,
888 return mc_lstat(data
->info
.fullpath
, &data
->info
.stats
) == 0 &&
889 find_test_condition(data
->cond
, &data
->info
);
892 static void select_return_pressed(FilerWindow
*filer_window
, guint etime
)
897 entry
= mini_contents(filer_window
);
902 add_to_history(entry
);
904 data
.cond
= find_compile(entry
);
907 delayed_error(_("Invalid Find condition"));
911 data
.info
.now
= time(NULL
);
912 data
.info
.prune
= FALSE
; /* (don't care) */
913 data
.filer_window
= filer_window
;
915 view_select_if(filer_window
->view
, select_if_test
, &data
);
917 find_condition_free(data
.cond
);
919 minibuffer_hide(filer_window
);
922 static void filter_return_pressed(FilerWindow
*filer_window
, guint etime
)
926 entry
= mini_contents(filer_window
);
928 if (entry
&& *entry
&& strcmp(entry
, "*")!=0) {
929 display_set_filter(filer_window
, FILER_SHOW_GLOB
,
932 display_set_filter(filer_window
, FILER_SHOW_ALL
, NULL
);
934 minibuffer_hide(filer_window
);
940 static gint
key_press_event(GtkWidget
*widget
,
942 FilerWindow
*filer_window
)
944 if (event
->keyval
== GDK_Escape
)
946 if (filer_window
->mini_type
== MINI_SHELL
)
950 line
= mini_contents(filer_window
);
952 add_to_history(line
);
955 minibuffer_hide(filer_window
);
959 switch (filer_window
->mini_type
)
962 switch (event
->keyval
)
965 search_in_dir(filer_window
, -1);
968 search_in_dir(filer_window
, 1);
972 path_return_pressed(filer_window
,
976 complete(filer_window
);
984 switch (event
->keyval
)
987 shell_recall(filer_window
, 1);
990 shell_recall(filer_window
, -1);
993 shell_tab(filer_window
);
997 shell_return_pressed(filer_window
);
1003 case MINI_SELECT_IF
:
1004 switch (event
->keyval
)
1007 shell_recall(filer_window
, 1);
1010 shell_recall(filer_window
, -1);
1016 select_return_pressed(filer_window
,
1023 case MINI_SELECT_BY_NAME
:
1024 switch (event
->keyval
)
1027 filer_next_selected(filer_window
, -1);
1030 filer_next_selected(filer_window
, 1);
1036 minibuffer_hide(filer_window
);
1044 switch (event
->keyval
)
1048 filter_return_pressed(filer_window
,
1062 static gboolean
select_if_glob(ViewIter
*iter
, gpointer data
)
1065 const char *pattern
= (char *) data
;
1067 item
= iter
->peek(iter
);
1068 g_return_val_if_fail(item
!= NULL
, FALSE
);
1070 return fnmatch(pattern
, item
->leafname
, 0) == 0;
1073 static void changed(GtkEditable
*mini
, FilerWindow
*filer_window
)
1075 switch (filer_window
->mini_type
)
1078 path_changed(filer_window
);
1080 case MINI_SELECT_IF
:
1081 set_find_string_colour(GTK_WIDGET(mini
),
1083 GTK_ENTRY(filer_window
->minibuffer
)));
1085 case MINI_SELECT_BY_NAME
:
1086 view_select_if(filer_window
->view
,
1088 (gpointer
) gtk_entry_get_text(
1089 GTK_ENTRY(filer_window
->minibuffer
)));
1096 /* Returns a string (which must NOT be freed), or NULL if the buffer
1097 * is blank (whitespace only).
1099 static const gchar
*mini_contents(FilerWindow
*filer_window
)
1101 const gchar
*entry
, *c
;
1103 entry
= gtk_entry_get_text(GTK_ENTRY(filer_window
->minibuffer
));
1105 for (c
= entry
; *c
; c
++)
1106 if (!g_ascii_isspace(*c
))
1112 /* This is a really ugly hack to get around Gtk+-2.0's broken auto-select
1115 static gboolean
grab_focus(GtkWidget
*minibuffer
)
1117 GtkWidgetClass
*class;
1119 class = GTK_WIDGET_CLASS(gtk_type_class(GTK_TYPE_WIDGET
));
1121 class->grab_focus(minibuffer
);
1123 g_signal_stop_emission(minibuffer
,
1124 g_signal_lookup("grab_focus", G_OBJECT_TYPE(minibuffer
)), 0);