@@ -49,6 +49,7 @@ struct _Workspaceviewlabel {
4949 GtkWidget * lock ;
5050 GtkWidget * error ;
5151 GtkWidget * right_click_menu ;
52+ GMenu * workspaceviewlabel_menu ;
5253
5354 /* State.
5455 */
@@ -137,10 +138,34 @@ workspaceviewlabel_init(Workspaceviewlabel *wviewlabel)
137138 gtk_widget_init_template (GTK_WIDGET (wviewlabel ));
138139}
139140
141+ static void *
142+ workspaceviewlabel_add_tab_item (Workspace * ws , void * user_data )
143+ {
144+ GMenu * tabs = G_MENU (user_data );
145+
146+ GMenuItem * item = g_menu_item_new (IOBJECT (ws )-> name , NULL );
147+ GVariant * target = g_variant_new_string (IOBJECT (ws )-> name );
148+ g_menu_item_set_action_and_target_value (item , "win.tab-merge" , target );
149+ g_menu_append_item (tabs , item );
150+
151+ return NULL ;
152+ }
153+
140154static void
141155workspaceviewlabel_menu (GtkGestureClick * gesture ,
142156 guint n_press , double x , double y , Workspaceviewlabel * wviewlabel )
143157{
158+ Workspaceview * wview = wviewlabel -> wview ;
159+ Workspace * ws = WORKSPACE (VOBJECT (wview )-> iobject );
160+ Workspacegroup * wsg = workspace_get_workspacegroup (ws );
161+
162+ // generate the dynamic tab submenu
163+ GMenu * tabs = g_menu_new ();
164+ workspacegroup_map (wsg , workspaceviewlabel_add_tab_item , tabs , NULL );
165+ GMenu * tab_menu = wviewlabel -> workspaceviewlabel_menu ;
166+ g_menu_remove (tab_menu , 1 );
167+ g_menu_insert_submenu (tab_menu , 1 , "Merge tab" , G_MENU_MODEL (tabs ));
168+
144169 mainwindow_set_action_view (VIEW (wviewlabel -> wview ));
145170
146171 gtk_popover_set_pointing_to (GTK_POPOVER (wviewlabel -> right_click_menu ),
@@ -213,6 +238,7 @@ workspaceviewlabel_class_init(WorkspaceviewlabelClass *class)
213238 BIND_VARIABLE (Workspaceviewlabel , lock );
214239 BIND_VARIABLE (Workspaceviewlabel , error );
215240 BIND_VARIABLE (Workspaceviewlabel , right_click_menu );
241+ BIND_VARIABLE (Workspaceviewlabel , workspaceviewlabel_menu );
216242
217243 BIND_CALLBACK (workspaceviewlabel_menu );
218244 BIND_CALLBACK (workspaceviewlabel_pressed );
0 commit comments