Weeeeeeeeee!
Filter widget on the main window works! Switched to use GnomeEntry instead of GtkEntry It really kicks KFM's ass. -Miguel.
Этот коммит содержится в:
родитель
791b34236c
Коммит
022b293b39
@ -1,4 +1,7 @@
|
||||
Thu Mar 12 21:29:33 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
Thu Mar 12 22:11:23 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gwidget.c (x_update_input): Use GnomeEntry widgets instead of
|
||||
the GtkEntry.
|
||||
|
||||
* gwidget.c (listbox_select): Fix for the listbox selection with
|
||||
the mouse.
|
||||
|
@ -252,12 +252,6 @@ setup_sigwinch ()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
|
||||
{
|
||||
return default_dlg_callback (h, id, msg);
|
||||
}
|
||||
|
||||
void
|
||||
x_flush_events (void)
|
||||
{
|
||||
@ -290,6 +284,28 @@ x_set_idle (Dlg_head *h, int enable_idle)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dialog_panel_callback (struct Dlg_head *h, int id, int msg)
|
||||
{
|
||||
WPanel *p;
|
||||
WInput *in;
|
||||
|
||||
if (msg == DLG_KEY && id == '\n'){
|
||||
if (h->current->widget->callback == panel_callback)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* If this was a keystroke, and the current widget is not the
|
||||
* panel, it is the filter
|
||||
*/
|
||||
p = (WPanel *) h->current->next->widget;
|
||||
in = (WInput *) h->current->widget;
|
||||
|
||||
set_panel_filter_to (p, strdup (in->buffer));
|
||||
}
|
||||
return default_dlg_callback (h, id, msg);
|
||||
}
|
||||
|
||||
void
|
||||
create_panels (void)
|
||||
{
|
||||
@ -306,6 +322,7 @@ create_panels (void)
|
||||
|
||||
panel = create_container (h, "My Panel");
|
||||
add_widget (h, panel);
|
||||
|
||||
set_current_panel (0);
|
||||
run_dlg (h);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ x_unselect_item (WPanel *panel)
|
||||
void
|
||||
x_filter_changed (WPanel *panel)
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (panel->filter_w),
|
||||
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (panel->filter_w))),
|
||||
panel->filter ? panel->filter : "");
|
||||
}
|
||||
|
||||
@ -926,24 +926,8 @@ panel_change_filter (GtkWidget *entry, WPanel *panel)
|
||||
{
|
||||
char *reg_exp;
|
||||
|
||||
/* This functionality is duplicated from set_panel_filter().
|
||||
* We cannot just call set_panel_filter() because in the Gnome
|
||||
* version we have a nice GnomeEntry in the panel to set the
|
||||
* filters, instead of having the user have to click on a menu
|
||||
* item to bring up a "set filter" dialog box.
|
||||
*/
|
||||
|
||||
reg_exp = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
|
||||
if (panel->filter) {
|
||||
g_free (panel->filter);
|
||||
panel->filter = NULL;
|
||||
}
|
||||
|
||||
if (!((reg_exp[0] == '*') && (reg_exp[1] == 0)))
|
||||
panel->filter = g_strdup (reg_exp);
|
||||
|
||||
reread_cmd ();
|
||||
reg_exp = gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))));
|
||||
set_panel_filter_to (panel, strdup (reg_exp));
|
||||
}
|
||||
|
||||
/* FIXME!!! These patterns only work if we are using glob (easy_patterns).
|
||||
@ -966,10 +950,11 @@ static char *default_filters[] = {
|
||||
};
|
||||
|
||||
static GtkWidget *
|
||||
panel_create_filter (WPanel *panel, GtkWidget **filter_w)
|
||||
panel_create_filter (Dlg_head *h, WPanel *panel, GtkWidget **filter_w)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
WInput *in;
|
||||
int i;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
@ -978,10 +963,20 @@ panel_create_filter (WPanel *panel, GtkWidget **filter_w)
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
||||
gtk_widget_show (label);
|
||||
|
||||
*filter_w = gnome_entry_new ("filter");
|
||||
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);
|
||||
*filter_w = (GtkWidget *) in->widget.wdata;
|
||||
|
||||
/* We do not want the focus by default (and the previos add_widget just gave it to us) */
|
||||
h->current = h->current->prev;
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < ELEMENTS (default_filters); i++)
|
||||
gnome_entry_append_history (GNOME_ENTRY (*filter_w), FALSE, default_filters[i]);
|
||||
#endif
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gnome_entry_gtk_entry (GNOME_ENTRY (*filter_w))),
|
||||
"activate",
|
||||
@ -1008,7 +1003,7 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
panel->current_dir = panel_create_cwd (panel);
|
||||
gtk_widget_show (panel->current_dir);
|
||||
|
||||
filter = panel_create_filter (panel, (GtkWidget **) &panel->filter_w);
|
||||
filter = panel_create_filter (h, panel, (GtkWidget **) &panel->filter_w);
|
||||
gtk_widget_show (filter);
|
||||
|
||||
status_line = gtk_hbox_new (0, 0);
|
||||
@ -1047,6 +1042,11 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
|
||||
gtk_widget_realize (panel->list);
|
||||
panel_create_pixmaps (panel->list);
|
||||
}
|
||||
|
||||
/* In GNOME the panel wants to have the cursor, to avoid "auto" focusing the
|
||||
* filter input line
|
||||
*/
|
||||
panel->widget.options |= W_WANT_CURSOR;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -16,12 +16,31 @@
|
||||
#include "gwidget.h"
|
||||
#include "dlg.h"
|
||||
|
||||
void
|
||||
x_focus_widget (Widget_Item *p)
|
||||
GtkWidget *
|
||||
get_gtk_widget (Widget_Item *p)
|
||||
{
|
||||
GtkWidget *w = GTK_WIDGET (p->widget->wdata);
|
||||
|
||||
gtk_widget_grab_focus (GTK_WIDGET (p->widget->wdata));
|
||||
if (GNOME_IS_ENTRY (w))
|
||||
return (gnome_entry_gtk_entry ((GnomeEntry *)(w)));
|
||||
else
|
||||
return (GTK_WIDGET (p->widget->wdata));
|
||||
}
|
||||
|
||||
void
|
||||
x_focus_widget (Widget_Item *p)
|
||||
{
|
||||
GtkWidget *w = get_gtk_widget (p);
|
||||
|
||||
gtk_widget_grab_focus (w);
|
||||
}
|
||||
|
||||
void
|
||||
x_unfocus_widget (Widget_Item *p)
|
||||
{
|
||||
GtkWidget *w = get_gtk_widget (p);
|
||||
|
||||
gtk_window_set_focus (GTK_WINDOW (gtk_widget_get_toplevel (w)), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -192,13 +211,23 @@ entry_release (GtkEditable *entry, GdkEvent *event, WInput *in)
|
||||
int
|
||||
x_create_input (Dlg_head *h, widget_data parent, WInput *in)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
GtkWidget *gnome_entry;
|
||||
GtkEntry *entry;
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_widget_show (entry);
|
||||
in->widget.wdata = (widget_data) entry;
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), in->buffer);
|
||||
gtk_entry_set_position (GTK_ENTRY (entry), in->point);
|
||||
/* The widget might have been initialized manually.
|
||||
* Look in gscreen.c for an example
|
||||
*/
|
||||
if (in->widget.wdata)
|
||||
return;
|
||||
|
||||
gnome_entry = gnome_entry_new (in->widget.tkname);
|
||||
gtk_widget_show (gnome_entry);
|
||||
in->widget.wdata = (widget_data) gnome_entry;
|
||||
|
||||
entry = GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gnome_entry)));
|
||||
|
||||
gtk_entry_set_text (entry, in->buffer);
|
||||
gtk_entry_set_position (entry, in->point);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (entry), "button_press_event",
|
||||
GTK_SIGNAL_FUNC (entry_click), in);
|
||||
@ -211,8 +240,9 @@ x_create_input (Dlg_head *h, widget_data parent, WInput *in)
|
||||
void
|
||||
x_update_input (WInput *in)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (in->widget.wdata);
|
||||
|
||||
GnomeEntry *gnome_entry = GNOME_ENTRY (in->widget.wdata);
|
||||
GtkEntry *entry = GTK_ENTRY (gnome_entry_gtk_entry (gnome_entry));
|
||||
|
||||
/* If the widget has not been initialized yet (done by WIDGET_INIT) */
|
||||
if (!entry)
|
||||
return;
|
||||
@ -220,7 +250,7 @@ x_update_input (WInput *in)
|
||||
gtk_entry_set_text (entry, in->buffer);
|
||||
printf ("POniendo el putno en %d\n", in->point);
|
||||
gtk_entry_set_position (entry, in->point);
|
||||
gtk_widget_draw (GTK_WIDGET (entry), NULL);
|
||||
gtk_widget_draw (GTK_WIDGET (gnome_entry), NULL);
|
||||
}
|
||||
|
||||
/* Listboxes */
|
||||
|
@ -1,5 +1,13 @@
|
||||
Thu Mar 12 21:08:36 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
Thu Mar 12 23:23:00 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* cmd.c (set_panel_filter_to): Implementation split. To be used
|
||||
by GNOME.
|
||||
|
||||
* widget.c (input_new): GNOME-entry widget is inspired in the
|
||||
WInput + the history patches from Paul. Use the GNOME-entry
|
||||
history, as this makes it easier to deal with the filter button on
|
||||
the panel.
|
||||
|
||||
* setup.c (save_panel_types): Do not use if running on the gnome
|
||||
edition. This need a lot of fixing for making this work with
|
||||
gnome and session management.
|
||||
|
24
src/cmd.c
24
src/cmd.c
@ -387,6 +387,21 @@ void find_cmd (void)
|
||||
do_find ();
|
||||
}
|
||||
|
||||
void
|
||||
set_panel_filter_to (WPanel *p, char *allocated_filter_string)
|
||||
{
|
||||
if (p->filter){
|
||||
free (p->filter);
|
||||
p->filter = 0;
|
||||
}
|
||||
if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0))
|
||||
p->filter = allocated_filter_string;
|
||||
else
|
||||
free (allocated_filter_string);
|
||||
reread_cmd ();
|
||||
x_filter_changed (p);
|
||||
}
|
||||
|
||||
/* Set a given panel filter expression */
|
||||
void set_panel_filter (WPanel *p)
|
||||
{
|
||||
@ -398,14 +413,7 @@ void set_panel_filter (WPanel *p)
|
||||
reg_exp = input_dialog (" Filter ", " Set expression for filtering filenames", x);
|
||||
if (!reg_exp)
|
||||
return;
|
||||
if (p->filter){
|
||||
free (p->filter);
|
||||
p->filter = 0;
|
||||
}
|
||||
if (!(reg_exp [0] == '*' && reg_exp [1] == 0))
|
||||
p->filter = reg_exp;
|
||||
reread_cmd ();
|
||||
x_filter_changed (p);
|
||||
set_panel_filter_to (p, reg_exp);
|
||||
}
|
||||
|
||||
/* Invoked from the left/right menus */
|
||||
|
@ -26,6 +26,7 @@ void find_cmd (void);
|
||||
void tree_mode_cmd (void);
|
||||
void filter_cmd (void);
|
||||
void set_panel_filter (WPanel *panel);
|
||||
void set_panel_filter_to (WPanel *p, char *allocated_filter_string);
|
||||
void reread_cmd (void);
|
||||
void do_re_sort (WPanel *panel);
|
||||
void quick_view_cmd (void);
|
||||
|
@ -171,6 +171,8 @@ int default_proc (Dlg_head *h, int Msg, int Par)
|
||||
return 1;
|
||||
|
||||
case WIDGET_UNFOCUS: /* We accept loose FOCUSes */
|
||||
if (h->current)
|
||||
x_unfocus_widget (h->current);
|
||||
return 1;
|
||||
|
||||
case WIDGET_DRAW:
|
||||
|
@ -297,10 +297,12 @@ void update_cursor (Dlg_head *h);
|
||||
#ifdef HAVE_X
|
||||
extern Dlg_head *midnight_dlg;
|
||||
void x_focus_widget (Widget_Item *p);
|
||||
void x_unfocus_widget (Widget_Item *p);
|
||||
void x_init_dlg (Dlg_head *h);
|
||||
void x_destroy_dlg (Dlg_head *h);
|
||||
#else
|
||||
# define x_focus_widget(x) {}
|
||||
# define x_unfocus_widget(x) {}
|
||||
# define x_init_dlg(x) {}
|
||||
# define x_destroy_dlg(x) {}
|
||||
#endif
|
||||
|
@ -2169,6 +2169,8 @@ panel_callback (Dlg_head *h, WPanel *panel, int msg, int par)
|
||||
define_label (h, (Widget *)panel, 8, "Delete", delete_cmd);
|
||||
redraw_labels (h, (Widget *)panel);
|
||||
#endif
|
||||
/* Chain behaviour */
|
||||
default_proc (h, WIDGET_FOCUS, par);
|
||||
return 1;
|
||||
|
||||
case WIDGET_UNFOCUS:
|
||||
|
11
src/widget.c
11
src/widget.c
@ -1628,7 +1628,13 @@ input_event (Gpm_Event *event, WInput *in)
|
||||
#endif
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
# define PORT_WIDGET_WANT_HISTORY 0
|
||||
#else
|
||||
# define PORT_WIDGET_WANT_HISTORY 1
|
||||
#endif
|
||||
|
||||
WInput *
|
||||
input_new (int y, int x, int color, int len, char *def_text, char *tkname)
|
||||
{
|
||||
@ -1642,11 +1648,12 @@ input_new (int y, int x, int color, int len, char *def_text, char *tkname)
|
||||
/* history setup */
|
||||
in->history = NULL;
|
||||
in->history_name = 0;
|
||||
if (tkname)
|
||||
if (tkname && PORT_WIDGET_WANT_HISTORY){
|
||||
if (*tkname) {
|
||||
in->history_name = strdup (tkname);
|
||||
in->history = history_get (tkname);
|
||||
}
|
||||
}
|
||||
if (def_text == INPUT_LAST_TEXT) {
|
||||
def_text = "";
|
||||
if (in->history)
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user