FRAME_PIXEL_HEIGHT (f) = pixelheight;
xg_clear_under_internal_border (f);
- change_frame_size (f, rows, columns, 0, 0, 1);
+ change_frame_size (f, rows, columns, 0, 1, 0);
SET_FRAME_GARBAGED (f);
cancel_mouse_face (f);
}
}
}
+/* Callback called when a new tab has been added.
+ Handle the case when a page has been dropped from another frame. */
+static void
+xg_page_added_cb (GtkNotebook *notebook,
+ GtkWidget *child,
+ guint page_num,
+ gpointer user_data)
+{
+ FRAME_PTR f = (FRAME_PTR) user_data;
+ tabs_gc_data *conf = g_object_get_data (G_OBJECT (child), XG_TAB_CONFIG_KEY);
+
+ /* Dropped from another frame? */
+ if (conf
+ && Fwindow_configuration_p (conf->object) &&
+ XFRAME (Fwindow_configuration_frame (conf->object)) != f)
+ {
+ Lisp_Object frame;
+ XSETFRAME (frame, f);
+ Fchange_window_configuration_frame (conf->object, frame);
+ }
+}
+
/* Callback called when the current tab changes. */
static void
oconf->object = Fcurrent_window_configuration (frame);
EVENT_INIT (event);
- event.kind = TAB_CHANGED_EVENT;
+ event.kind = TAB_EVENT;
event.frame_or_window = frame;
- event.arg = Fcons (make_string (key, strlen (key)),
- make_string (oldkey, strlen (oldkey)));
+ event.arg = Fcons (make_number (1),
+ Fcons (make_string (key, strlen (key)),
+ make_string (oldkey, strlen (oldkey))));
kbd_buffer_store_event (&event);
}
- if (conf)
+ if (conf)
Fset_window_configuration (conf->object);
else
Fdelete_other_windows (Qnil);
remove_tab_cb (GtkButton *widget,
gpointer user_data)
{
+ BLOCK_INPUT;
GtkWidget *wfixed = GTK_WIDGET (user_data);
const char *key = g_object_get_data (G_OBJECT (wfixed), XG_TAB_KEY);
FRAME_PTR f = g_object_get_data (G_OBJECT (wfixed), XG_FRAME_DATA);
xg_delete_tab (f, key);
+ UNBLOCK_INPUT;
}
xg_add_tab (FRAME_PTR f,
const char *name)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
GtkWidget *wfixed = gtk_fixed_new ();
GdkColor bg;
gtk_widget_show (wfixed);
n = gtk_notebook_append_page (wnote, wfixed, wlbl);
gtk_notebook_set_tab_reorderable (wnote, wfixed, TRUE);
+ gtk_notebook_set_tab_detachable (wnote, wfixed, TRUE);
if (n > 0)
{
"destroy",
G_CALLBACK (xg_fixed_destroy_cb), 0);
+ UNBLOCK_INPUT;
return key;
}
xg_delete_tab (FRAME_PTR f,
const char *key)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
int i, pages = gtk_notebook_get_n_pages (wnote);
int page_to_remove = -1;
gtk_notebook_remove_page (wnote, page_to_remove);
}
xg_check_show_tabs (f, wnote);
+ UNBLOCK_INPUT;
}
/* Delete all tabs except the current tab. */
void
xg_delete_all_tabs (FRAME_PTR f)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
int i, pages = gtk_notebook_get_n_pages (wnote);
int current_page = gtk_notebook_get_current_page (wnote);
for (i = 0; i < current_page; ++i)
gtk_notebook_remove_page (wnote, 0);
xg_check_show_tabs (f, wnote);
+ UNBLOCK_INPUT;
}
/* Make the next tab current. If there are no next tabs, wrap around to 0. */
void
xg_tab_next (FRAME_PTR f)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
int current_page = gtk_notebook_get_current_page (wnote);
int pages = gtk_notebook_get_n_pages (wnote);
else
switch_to = current_page+1;
gtk_notebook_set_current_page (wnote, switch_to);
-
+ UNBLOCK_INPUT;
}
/* Make the previous tab current. If current is first, wrap around to last. */
void
xg_tab_previous (FRAME_PTR f)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
int current_page = gtk_notebook_get_current_page (wnote);
int pages = gtk_notebook_get_n_pages (wnote);
else
switch_to = current_page-1;
gtk_notebook_set_current_page (wnote, switch_to);
+ UNBLOCK_INPUT;
}
xg_set_tab_label (FRAME_PTR f,
const char *label)
{
+ BLOCK_INPUT;
GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
int current_page = gtk_notebook_get_current_page (wnote);
GtkWidget *w = gtk_notebook_get_nth_page (wnote, current_page);
if (utf8_label && utf8_label != label)
g_free (utf8_label);
}
+ UNBLOCK_INPUT;
+}
+
+static GtkNotebook* notebook_on_hold;
+
+
+GtkNotebook*
+xg_nb_window_create (GtkNotebook *source,
+ GtkWidget *page,
+ gint x,
+ gint y,
+ gpointer data)
+{
+ struct input_event event;
+ Lisp_Object frame;
+ FRAME_PTR f = g_object_get_data (G_OBJECT (page), XG_FRAME_DATA);
+ tabs_gc_data *oconf = g_object_get_data (G_OBJECT (page),
+ XG_TAB_CONFIG_KEY);
+ XSETFRAME (frame, f);
+ if (!oconf)
+ {
+ oconf = xmalloc (sizeof(*oconf));
+ g_object_set_data (G_OBJECT (page), XG_TAB_CONFIG_KEY, oconf);
+ xg_list_insert (&tabs_gc_list, &oconf->ptrs);
+ oconf->object = Fcurrent_window_configuration (frame);
+ }
+
+ EVENT_INIT (event);
+ event.kind = TAB_EVENT;
+ event.frame_or_window = frame;
+ event.arg = Fcons (make_number (2), Qnil);
+ event.x = make_number (x);
+ event.y = make_number (y);
+ kbd_buffer_store_event (&event);
+
+ return notebook_on_hold = GTK_NOTEBOOK (gtk_notebook_new ());
}
/* Create and set up the GTK widgets for frame F.
xg_set_screen (wtop, f);
wvbox = gtk_vbox_new (FALSE, 0);
- wnote = gtk_notebook_new ();
+ if (notebook_on_hold)
+ wnote = GTK_WIDGET (notebook_on_hold);
+ else
+ wnote = gtk_notebook_new ();
if (! wtop || ! wvbox || ! wnote)
{
gtk_box_pack_end (GTK_BOX (wvbox), wnote, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (wnote), "switch-page",
G_CALLBACK (xg_switch_page_cb), f);
-
+ g_signal_connect (G_OBJECT (wnote), "page-added",
+ G_CALLBACK (xg_page_added_cb), f);
+
if (FRAME_EXTERNAL_TOOL_BAR (f))
update_frame_tool_bar (f);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (wnote), TRUE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (wnote), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (wnote), 0);
+#if GTK_MAJOR_VERSION > 2 || GTK_MINOR_VERSION >= 12
+ gtk_notebook_set_group (GTK_NOTEBOOK (wnote), (gpointer)1);
+#else
+ gtk_notebook_set_group_id (GTK_NOTEBOOK (wnote), 1);
+#endif
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (wnote), FALSE);
GtkRcStyle *style = gtk_widget_get_modifier_style (wnote);
style->xthickness = style->ythickness = 0;
gtk_widget_modify_style (wnote, style);
-
- xg_add_tab (f, "Page 1");
+
+
+ if (!notebook_on_hold)
+ xg_add_tab (f, "Page 1");
+
+
+
GtkWidget *wfixed = gtk_notebook_get_nth_page (GTK_NOTEBOOK (wnote), 0);
/* Must realize the windows so the X window gets created. It is used
FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed);
FRAME_GTK_WIDGET (f) = wfixed;
+
+ tabs_gc_data *conf = g_object_get_data (G_OBJECT (wfixed), XG_TAB_CONFIG_KEY);
+ if (conf
+ && Fwindow_configuration_p (conf->object) &&
+ XFRAME (Fwindow_configuration_frame (conf->object)) != f)
+ {
+ Lisp_Object frame;
+ XSETFRAME (frame, f);
+ Fchange_window_configuration_frame (conf->object, frame);
+ Fset_window_configuration (conf->object);
+ }
+
+ notebook_on_hold = NULL;
+
UNBLOCK_INPUT;
return 1;
XftInit (0);
#endif
+ notebook_on_hold = NULL;
gdpy_def = NULL;
xg_ignore_gtk_scrollbar = 0;
xg_detached_menus = 0;
(GTK_TYPE_MENU_SHELL));
gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK,
"cancel", 0);
+
+ gtk_notebook_set_window_creation_hook (xg_nb_window_create, NULL, NULL);
}
#endif /* USE_GTK */
Lisp_Object Qdbus_event;
#endif
Lisp_Object Qconfig_changed_event;
-Lisp_Object Qtab_changed_event;
+Lisp_Object Qtab_event;
/* Lisp_Object Qmouse_movement; - also an event header */
obj = make_lispy_event (event);
kbd_fetch_ptr = event + 1;
}
- else if (event->kind == TAB_CHANGED_EVENT)
+ else if (event->kind == TAB_EVENT)
{
obj = make_lispy_event (event);
kbd_fetch_ptr = event + 1;
Fcons (event->arg,
Fcons (event->frame_or_window, Qnil)));
- case TAB_CHANGED_EVENT:
- return Fcons (Qtab_changed_event,
- Fcons (event->arg,
- Fcons (event->frame_or_window, Qnil)));
-
+ case TAB_EVENT:
+ return Fcons (Qtab_event,
+ Fcons (Fcons (event->frame_or_window,
+ Fcons (event->x, event->y)),
+ Fcons (event->arg, Qnil)));
+
#ifdef HAVE_GPM
case GPM_CLICK_EVENT:
{
Qconfig_changed_event = intern_c_string ("config-changed-event");
staticpro (&Qconfig_changed_event);
- Qtab_changed_event = intern_c_string ("tab-changed-event");
- staticpro (&Qtab_changed_event);
+ Qtab_event = intern_c_string ("tab-event");
+ staticpro (&Qtab_event);
Qmenu_enable = intern_c_string ("menu-enable");
staticpro (&Qmenu_enable);
initial_define_lispy_key (Vspecial_event_map, "config-changed-event",
"ignore");
- initial_define_lispy_key (Vspecial_event_map, "tab-changed-event",
+ initial_define_lispy_key (Vspecial_event_map, "tab-event",
"ignore");
}