mirror of https://github.com/MidnightCommander/mc
Multiple panels key work; code cleanup; more dnd work; gone to eat now - mig
This commit is contained in:
parent
51e39b09b5
commit
d14a111c99
|
@ -193,6 +193,18 @@ gnome_init_panels ()
|
|||
other_panel_ptr = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
panel_enter_event (GtkWidget *widget, GdkEvent *event, WPanel *panel)
|
||||
{
|
||||
/* Avoid unnecessary code execution */
|
||||
if (get_current_panel () == panel)
|
||||
return;
|
||||
|
||||
set_new_current_panel (panel);
|
||||
dlg_select_widget (panel->widget.parent, panel);
|
||||
send_message (panel->widget.parent, (Widget *) panel, WIDGET_FOCUS, 0);
|
||||
}
|
||||
|
||||
WPanel *
|
||||
create_container (Dlg_head *h, char *name)
|
||||
{
|
||||
|
@ -213,6 +225,11 @@ create_container (Dlg_head *h, char *name)
|
|||
|
||||
panel = panel_new (name);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (app),
|
||||
"enter_notify_event",
|
||||
GTK_SIGNAL_FUNC (panel_enter_event),
|
||||
panel);
|
||||
|
||||
/* Ultra nasty hack follows:
|
||||
* I am setting the panel->widget.wdata value here before the
|
||||
* panel X stuff gets created in the INIT message section of the
|
||||
|
@ -246,10 +263,6 @@ new_panel_at (char *dir)
|
|||
panel = create_container (h, "Other");
|
||||
add_widget (h, panel);
|
||||
|
||||
/* Gross hack 2: add_widget should know that the dialog is already
|
||||
* executing and shold call the init method manually. We do so instead:
|
||||
*/
|
||||
panel->widget.callback (h, panel, WIDGET_INIT, 0);
|
||||
set_new_current_panel (panel);
|
||||
}
|
||||
|
||||
|
|
|
@ -180,6 +180,17 @@ x_focus_widget (Widget_Item *p)
|
|||
gtk_widget_grab_focus (GTK_WIDGET (p->widget->wdata));
|
||||
}
|
||||
|
||||
void
|
||||
x_add_widget (Dlg_head *h, Widget_Item *w)
|
||||
{
|
||||
if (!(h->grided & DLG_NO_TED)){
|
||||
GtkTed *ted = GTK_TED (GTK_BIN (h->wdata)->child);
|
||||
|
||||
gtk_ted_add (ted, GTK_WIDGET (w->widget->wdata), w->widget->tkname);
|
||||
bind_gtk_keys (GTK_WIDGET (w->widget->wdata), h);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
x_init_dlg (Dlg_head *h)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ int x_create_listbox (Dlg_head *h, widget_data parent, WListbox *l);
|
|||
int x_create_buttonbar (Dlg_head *h, widget_data parent, WButtonBar *bb);
|
||||
void x_list_insert (WListbox *l, WLEntry *p, WLEntry *e);
|
||||
void x_redefine_label (WButtonBar *bb, int idx);
|
||||
void x_add_widget (Dlg_head *h, Widget_Item *w);
|
||||
|
||||
struct gmc_color_pairs_s {
|
||||
GdkColor *fore, *back;
|
||||
|
|
|
@ -36,6 +36,10 @@ GdkBitmap *directory_mask;
|
|||
/* button bindings, mc text mode (1) or gui-like */
|
||||
static int mc_bindings;
|
||||
|
||||
static char *drag_types [] = { "text/plain", "url:ALL" };
|
||||
|
||||
#define ELEMENTS(x) (sizeof (x) / sizeof (x[0]))
|
||||
|
||||
void
|
||||
repaint_file (WPanel *panel, int file_index, int move, int attr, int isstatus)
|
||||
{
|
||||
|
@ -611,6 +615,45 @@ panel_file_list_row_selected (GtkWidget *file_list, int row, int col, GdkEvent *
|
|||
panel_list_new_bindings (file_list, row, col, event, panel);
|
||||
}
|
||||
|
||||
void *
|
||||
panel_build_selected_file_list (WPanel *panel, int *file_list_len)
|
||||
{
|
||||
if (panel->marked){
|
||||
char *data, *copy;
|
||||
int i, total_len = 0;
|
||||
|
||||
/* first pass, compute the length */
|
||||
for (i = 0; i < panel->count; i++)
|
||||
if (panel->dir.list [i].f.marked)
|
||||
total_len += panel->dir.list [i].fnamelen + 1;
|
||||
|
||||
data = copy = xmalloc (total_len, "build_selected_file_list");
|
||||
for (i = 0; i < panel->count; i++)
|
||||
if (panel->dir.list [i].f.marked){
|
||||
strcpy (copy, panel->dir.list [i].fname);
|
||||
copy += panel->dir.list [i].fnamelen + 1;
|
||||
}
|
||||
*file_list_len = total_len;
|
||||
return data;
|
||||
} else {
|
||||
*file_list_len = strlen (panel->dir.list [panel->selected].fname) + 1;
|
||||
return strdup (panel->dir.list [panel->selected].fname);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
panel_drag_request (GtkWidget *widget, GdkEventDragRequest *event, WPanel *panel)
|
||||
{
|
||||
void *data;
|
||||
int len;
|
||||
|
||||
if ((strcmp (event->data_type, "text/plain") == 0) ||
|
||||
(strcmp (event->data_type, "url:ALL"))){
|
||||
data = panel_build_selected_file_list (panel, &len);
|
||||
gtk_widget_dnd_data_set (widget, (GdkEvent *) event, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
panel_create_file_list (WPanel *panel)
|
||||
{
|
||||
|
@ -639,6 +682,14 @@ panel_create_file_list (WPanel *panel)
|
|||
GTK_SIGNAL_FUNC (panel_file_list_row_selected),
|
||||
panel);
|
||||
|
||||
#if 0
|
||||
gtk_signal_connect (GTK_OBJECT (file_list),
|
||||
"drag_request_event",
|
||||
GTK_SIGNAL_FUNC (panel_drag_request), panel);
|
||||
|
||||
gtk_widget_dnd_drag_set (file_list, TRUE, drag_types, ELEMENTS (drag_types));
|
||||
#endif
|
||||
|
||||
return file_list;
|
||||
}
|
||||
|
||||
|
|
10
src/dlg.c
10
src/dlg.c
|
@ -231,6 +231,7 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
|||
new_d->raw = 0;
|
||||
new_d->grided = 0;
|
||||
new_d->initfocus = NULL;
|
||||
new_d->running = 0;
|
||||
#ifdef HAVE_X
|
||||
if (callback != midnight_callback)
|
||||
new_d->wdata = xtoolkit_create_dialog (new_d, flags);
|
||||
|
@ -282,6 +283,15 @@ int add_widgetl (Dlg_head *where, void *what, WLay layout)
|
|||
where->current->widget->parent = where;
|
||||
|
||||
where->count++;
|
||||
|
||||
/* If the widget is inserted in a running dialog */
|
||||
if (where->running){
|
||||
send_message (where, widget, WIDGET_INIT, 0);
|
||||
send_message (where, widget, WIDGET_DRAW, 0);
|
||||
#ifdef HAVE_GNOME
|
||||
x_add_widget (where, where->current);
|
||||
#endif
|
||||
}
|
||||
return (where->count - 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue