tab-show-always is new, to be a customize later on.
and drop on the root window to create a new frame.
Frames created with frame parameter disable-tabs set to t will not have tabs.
-This parameter can't be toggeled at runtime, it must be set when creating
-the frame.
+This parameter can be toggeled at runtime.
-Lisp code is in native-tabs.el. Keybindings are:
+The lisp interface is in xfns.c and native-tabs.el
- (global-set-key "\C-x7\C-f" 'find-file-new-tab)
- (global-set-key "\C-x70" 'tab-delete)
- (global-set-key "\C-x71" 'tab-delete-other)
- (global-set-key "\C-x72" 'tab-new)
- (global-set-key "\C-x73" 'switch-to-buffer-tab)
- (global-set-key "\C-x7b" 'switch-to-buffer-other-tab)
- (global-set-key "\C-x7f" 'find-file-new-tab)
- (global-set-key "\C-x7o" 'tab-next)
- (global-set-key "\C-x7n" 'tab<-next)
- (global-set-key "\C-x7p" 'tab-previous)))
+To turn tabs off (default is on), use the menu Options => Show/Hide or
+customise tab-mode.
+C-h f tab-mode to see keybindings.
-
-The lisp interface is mostly in xfns.c:
+Some functions:
(find-file-new-tab FILENAME &optional WILDCARDS)
(tab-new &optional LABEL FRAME)
(tab-nr-of-tabs &optional FRAME)
(tab-configuration &optional FRAME)
(tab-current &optional FRAME)
-(tab-show KEY FRAME)
+(tab-show KEY &optional FRAME)
+(tab-enable ENABLE &optional FRAME)
+(tab-show-always SHOW)
(switch-to-buffer-tab BUFFER-OR-NAME &optional FRAME)
(switch-to-buffer-other-tab BUFFER-OR-NAME &optional NORECORD)
:visible (and (display-graphic-p) (fboundp 'x-show-tip))
:button (:toggle . tooltip-mode)))
+(define-key menu-bar-showhide-menu [showhide-tabs]
+ `(menu-item ,(purecopy "Tabs") tab-mode
+ :help ,(purecopy "Turn tab on/off")
+ :visible (and (display-graphic-p) (featurep 'tabs))
+ :button (:toggle . tab-mode)))
+
(define-key menu-bar-showhide-menu [menu-bar-mode]
`(menu-item ,(purecopy "Menu-bar") toggle-menu-bar-mode-from-frame
:help ,(purecopy "Turn menu-bar on/off")
;;; Code:
-;;; Customizable variables
+(defvar tab-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-x7\C-f" 'find-file-new-tab)
+ (define-key map "\C-x70" 'tab-delete)
+ (define-key map "\C-x71" 'tab-delete-other)
+ (define-key map "\C-x72" 'tab-new)
+ (define-key map "\C-x73" 'switch-to-buffer-tab)
+ (define-key map "\C-x7b" 'switch-to-buffer-other-tab)
+ (define-key map "\C-x7f" 'find-file-new-tab)
+ (define-key map "\C-x7o" 'tab-next)
+ (define-key map "\C-x7n" 'tab-next)
+ (define-key map "\C-x7p" 'tab-previous)
+ map)
+ "Keymap for `tab-mode´")
+
+;;;###autoload
+(define-minor-mode tab-mode
+ "Toggle use of tabs.
+This command applies to all frames that exist and frames to be
+created in the future.
+With numeric ARG, use tabs if and only if ARG is positive.
+
+Keyboard commands for tabs are:
+\\{tab-mode-map}."
+ :init-value t
+ :global t
+ :group 'mouse
+ :group 'frames
+ :keymap tab-mode-map
+ (modify-all-frames-parameters (list (cons 'disable-tabs (not tab-mode)))))
(declare-function tab-new "xfns.c" ())
(declare-function tab-delete "xfns.c" ())
(declare-function tab-configuration "xfns.c" ())
(declare-function tab-current "xfns.c" ())
(declare-function tab-show "xfns.c" ())
+(declare-function tab-enable "xfns.c" ())
(defun find-file-new-tab (filename &optional wildcards)
"Edit file FILENAME, in a new tab.
(frame (car n1))
(x (car (cdr n1)))
(y (cdr (cdr n1))))
- (if (eq type 2)
+ (if (eq type 2) ;; // A tab is dropped from another frame.
(let ((top y)
(left x)
(width (frame-pixel-width frame))
(cons 'top top)
(cons 'left left)))))))
-(if (featurep 'tabs)
- (progn
- (define-key special-event-map [tab-event]
- 'handle-tab-event)
- (global-set-key "\C-x7\C-f" 'find-file-new-tab)
- (global-set-key "\C-x70" 'tab-delete)
- (global-set-key "\C-x71" 'tab-delete-other)
- (global-set-key "\C-x72" 'tab-new)
- (global-set-key "\C-x73" 'switch-to-buffer-tab)
- (global-set-key "\C-x7b" 'switch-to-buffer-other-tab)
- (global-set-key "\C-x7f" 'find-file-new-tab)
- (global-set-key "\C-x7o" 'tab-next)
- (global-set-key "\C-x7n" 'tab-next)
- (global-set-key "\C-x7p" 'tab-previous)))
+(define-key special-event-map [tab-event] 'handle-tab-event)
+
static xg_list_node tabs_gc_list;
static GtkNotebook* notebook_on_hold;
-typedef struct tabs_gc_data_
+/* If 1, show tabs even if there is only one tab. */
+static int xg_always_show_tabs;
+
+typedef struct
{
xg_list_node ptrs;
Lisp_Object object;
{
gboolean shown = gtk_notebook_get_show_tabs (wnote);
int pages = gtk_notebook_get_n_pages (wnote);
-
- if ((shown && pages == 1) || (!shown && pages > 1))
+ int should_show = pages > 1 || xg_always_show_tabs;
+
+ if ((shown && !should_show) || (!shown && should_show))
{
GtkRequisition req;
int oldheight, row_add = 0;
- gtk_notebook_set_show_tabs (wnote, pages > 1);
+ gtk_notebook_set_show_tabs (wnote, should_show);
oldheight = FRAME_TABS_HEIGHT (f);
gtk_widget_size_request (f->output_data.x->notebook_widget, &req);
if (oldheight > 0 && FRAME_LINE_HEIGHT (f) > 0)
{
row_add = oldheight/FRAME_LINE_HEIGHT (f);
- if (row_add * FRAME_LINE_HEIGHT (f) != oldheight)
- --row_add;
}
else if (FRAME_TABS_HEIGHT (f) > 0 && FRAME_LINE_HEIGHT (f) > 0)
{
row_add = -(FRAME_TABS_HEIGHT (f)/FRAME_LINE_HEIGHT (f));
}
- xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f) + row_add);
+ if (row_add != 0)
+ xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f) + row_add);
}
}
return conf ? conf->object : Qnil;
}
+void
+xg_tabs_always_show (FRAME_PTR f, int show)
+{
+ if (f == 0)
+ xg_always_show_tabs = show;
+ else
+ {
+ GtkNotebook *wnote = GTK_NOTEBOOK (f->output_data.x->notebook_widget);
+ if (wnote) xg_check_show_tabs (f, wnote);
+ }
+}
+
static void
xg_setup_notebook (FRAME_PTR f, GtkWidget *wvbox, GtkWidget *wnote)
{
#else
gtk_notebook_set_group_id (GTK_NOTEBOOK (wnote), 1);
#endif
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (wnote), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (wnote), xg_always_show_tabs);
style = gtk_widget_get_modifier_style (wnote);
style->xthickness = style->ythickness = 0;
id_to_widget.widgets = 0;
xg_tab_nr = 1;
tabs_gc_list.prev = tabs_gc_list.next = 0;
+ xg_always_show_tabs = 0;
/* Remove F10 as a menu accelerator, it does not mix well with Emacs key
bindings. It doesn't seem to be any way to remove properties,
extern void xg_enable_tabs P_ ((FRAME_PTR f, int enable));
extern Lisp_Object xg_tab_get_win_config P_ ((FRAME_PTR f, int nr));
+extern void xg_tabs_always_show P_ ((FRAME_PTR f, int show));
+
extern GtkWidget *xg_create_widget P_ ((char *type,
char *name,
struct frame *f;
Lisp_Object new_value, old_value;
{
- if (! EQ (new_value, old_value))
- {
- f->no_tabs = !NILP (new_value);
+ f->no_tabs = !NILP (new_value);
#ifdef USE_GTK
- BLOCK_INPUT;
- xg_enable_tabs (f, NILP (new_value));
- UNBLOCK_INPUT;
+ BLOCK_INPUT;
+ xg_enable_tabs (f, NILP (new_value));
+ UNBLOCK_INPUT;
#endif
- }
}
#ifdef USE_GTK
Stab_enable, 1, 2, 0,
doc: /* Enable or disable tabs on FRAME.
FRAME nil means use the selected frame.
-If enable is non-nil, enable tabs. If it is nil, disable tabs. */)
+If ENABLE is non-nil, enable tabs. If it is nil, disable tabs. */)
(enable, frame)
Lisp_Object enable, frame;
{
return Qnil;
}
+DEFUN ("tab-show-always", Ftab_show_always,
+ Stab_show_always, 1, 1, 0,
+ doc: /* Set if tabs always should be visible on frames.
+If SHOW is non-nil, always show tabs. If it is nil, show tabs if there are
+more than one. */)
+ (show)
+ Lisp_Object show;
+{
+ xg_tabs_always_show (0, NILP (show));
+ Lisp_Object rest, frame;
+ FOR_EACH_FRAME (rest, frame)
+ {
+ struct frame *f = XFRAME (frame);
+ xg_tabs_always_show (f, !NILP (show));
+ }
+
+ return Qnil;
+}
+
+
#endif
void
defsubr (&Stab_current);
defsubr (&Stab_show);
defsubr (&Stab_enable);
-
+ defsubr (&Stab_show_always);
#endif /* USE_GTK */
/* X window properties. */